❥ v1.0.0版本的 MD5 值为:6ae606845f10a6b2b654b679d6008d62
以下内容为反编译后的 SSRC.java 源代码,内容仅作参考
package im.pnpgvkcffv.ui.utils.translate.ssrc;
import com.google.firebase.remoteconfig.FirebaseRemoteConfig;
import im.pnpgvkcffv.messenger.FileLog;
import io.reactivex.annotations.SchedulerSupport;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.RandomAccessFile;
import java.lang.reflect.Array;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.channels.FileChannel;
import java.util.Random;
import kotlin.UByte;
import kotlin.jvm.internal.ByteCompanionObject;
public class SSRC {
static final boolean $assertionsDisabled = false;
private static final int POOLSIZE = 97;
private static final int RANDBUFLEN = 65536;
private static final String VERSION = "1.30";
private double AA;
private double DF;
private int FFTFIRLEN;
private ByteOrder byteOrder;
private SplitRadixFft fft;
private long lastshowed;
private int lastshowed2;
private boolean quiet;
private double[] randbuf;
private int randptr;
private double[][] shapebuf;
private int shaper_clipmax;
private int shaper_clipmin;
private int shaper_len;
private int shaper_type;
private long starttime;
private static final int[] scoeffreq = {0, 48000, 44100, 37800, 32000, 22050, 48000, 44100};
private static final int[] scoeflen = {1, 16, 20, 16, 16, 15, 16, 15};
private static final int[] samp = {8, 18, 27, 8, 8, 8, 10, 9};
private static final double[][] shapercoefs = {new double[]{-1.0d}, new double[]{-2.87207293510437d, 5.041323184967041d, -6.244299411773682d, 5.848398685455322d, -3.706754207611084d, 1.0495119094848633d, 1.1830236911773682d, -2.1126792430877686d, 1.9094531536102295d, -0.9991308450698853d, 0.17090806365013123d, 0.32615602016448975d, -0.39127644896507263d, 0.2687646150588989d, -0.0976761057972908d, 0.023473845794796944d}, new double[]{-2.6773197650909424d, 4.830892562866211d, -6.570110321044922d, 7.4572014808654785d, -6.726327419281006d, 4.848165035247803d, -2.0412089824676514d, -0.7006359100341797d, 2.95375657081604d, -4.080038547515869d, 4.184521675109863d, -3.331181287765503d, 2.117992639541626d, -0.879302978515625d, 0.031759146600961685d, 0.4238278865814209d, -0.4788210391998291d, 0.35490813851356506d, -0.1749683916568756d, 0.06090816855430603d}, new double[]{-1.6335992813110352d, 2.261549234390259d, -2.407702922821045d, 2.634171724319458d, -2.144036293029785d, 1.8153258562088013d, -1.0816224813461304d, 0.703026533126831d, -0.15991993248462677d, -0.04154951870441437d, 0.2941657602787018d, -0.25183168053627014d, 0.27766478061676025d, -0.15785403549671173d, 0.10165894031524658d, -0.016833892092108727d}, new double[]{-0.8290129899978638d, 0.9892265796661377d, -0.5982571244239807d, 1.0028809309005737d, -0.5993821620941162d, 0.7950245141983032d, -0.42723315954208374d, 0.5449252724647522d, -0.3079260587692261d, 0.3687179982662201d, -0.187920480966568d, 0.2261127084493637d, -0.10573341697454453d, 0.11435490846633911d, -0.0388006791472435d, 0.040842197835445404d}, new double[]{-0.06522997468709946d, 0.5498126149177551d, 0.4027854800224304d, 0.3178376853466034d, 0.2820179760456085d, 0.16985194385051727d, 0.15433363616466522d, 0.12507140636444092d, 0.08903945237398148d, 0.06441012024879456d, 0.04714600369334221d, 0.03280523791909218d, 0.028495194390416145d, 0.011695005930960178d, 0.011831838637590408d}, new double[]{-2.3925774097442627d, 3.4350297451019287d, -3.185370922088623d, 1.8117271661758423d, 0.2012477070093155d, -1.4759907722473145d, 1.7210904359817505d, -0.9774670004844666d, 0.13790138065814972d, 0.38185903429985046d, -0.27421241998672485d, -0.06658421456813812d, 0.35223302245140076d, -0.37672343850135803d, 0.23964276909828186d, -0.06867482513189316d}, new double[]{-2.0833916664123535d, 3.0418450832366943d, -3.204789876937866d, 2.757192611694336d, -1.4978630542755127d, 0.34275946021080017d, 0.7173374891281128d, -1.073705792427063d, 1.0225815773010254d, -0.5664999485015869d, 0.20968692004680634d, 0.06537853181362152d, -0.10322438180446625d, 0.06744202226400375d, 0.00495197344571352d}};
private static final double[] presets = {0.7d, 0.9d, 0.18d};
private int RINT(double x) {
return (int) (x >= FirebaseRemoteConfig.DEFAULT_VALUE_FOR_DOUBLE ? 0.5d + x : x - 0.5d);
}
public int init_shaper(int freq, int nch, int min, int max, int dtype, int pdf, double noiseamp) {
int[] pool;
int i = 97;
int[] pool2 = new int[97];
int i2 = 1;
while (i2 < 6 && freq != scoeffreq[i2]) {
i2++;
}
if ((dtype == 3 || dtype == 4) && i2 == 6) {
System.err.printf("Warning: ATH based noise shaping for destination frequency %dHz is not available, using triangular dither\n", Integer.valueOf(freq));
}
i2 = (dtype == 2 || i2 == 6) ? 0 : 0;
if (dtype == 4 && (i2 == 1 || i2 == 2)) {
i2 += 5;
}
this.shaper_type = i2;
this.shapebuf = new double[nch];
this.shaper_len = scoeflen[i2];
for (int i3 = 0; i3 < nch; i3++) {
this.shapebuf[i3] = new double[this.shaper_len];
}
this.shaper_clipmin = min;
this.shaper_clipmax = max;
this.randbuf = new double[65536];
Random random = new Random(System.currentTimeMillis());
for (int i4 = 0; i4 < 97; i4++) {
pool2[i4] = random.nextInt();
}
if (pdf == 0) {
for (int i5 = 0; i5 < 65536; i5++) {
int p = random.nextInt() % 97;
int r = pool2[p];
pool2[p] = random.nextInt();
this.randbuf[i5] = ((r / 2.147483647E9d) - 0.5d) * noiseamp;
}
} else if (pdf == 1) {
for (int i6 = 0; i6 < 65536; i6++) {
int p2 = random.nextInt() % 97;
int r1 = pool2[p2];
pool2[p2] = random.nextInt();
int p3 = random.nextInt() % 97;
int p4 = pool2[p3];
pool2[p3] = random.nextInt();
this.randbuf[i6] = noiseamp * ((r1 / 2.147483647E9d) - (p4 / 2.147483647E9d));
}
} else if (pdf == 2) {
int sw = 0;
double t = FirebaseRemoteConfig.DEFAULT_VALUE_FOR_DOUBLE;
double u = FirebaseRemoteConfig.DEFAULT_VALUE_FOR_DOUBLE;
int i7 = 0;
for (int i8 = 65536; i7 < i8; i8 = 65536) {
if (sw == 0) {
sw = 1;
int p5 = random.nextInt() % i;
double r2 = pool2[p5] / 2.147483647E9d;
pool2[p5] = random.nextInt();
if (r2 == 1.0d) {
r2 = FirebaseRemoteConfig.DEFAULT_VALUE_FOR_DOUBLE;
}
t = Math.sqrt(Math.log(1.0d - r2) * (-2.0d));
int p6 = random.nextInt() % i;
pool = pool2;
double r3 = pool2[p6] / 2.147483647E9d;
pool[p6] = random.nextInt();
double u2 = 6.283185307179586d * r3;
this.randbuf[i7] = noiseamp * t * Math.cos(u2);
u = u2;
} else {
pool = pool2;
this.randbuf[i7] = noiseamp * t * Math.sin(u);
sw = 0;
}
i7++;
pool2 = pool;
i = 97;
}
}
this.randptr = 0;
if (dtype == 0 || dtype == 1) {
return 1;
}
return samp[this.shaper_type];
}
public int do_shaping(double s, double[] peak, int dtype, int ch) {
int i;
double s2;
if (dtype == 1) {
double[] dArr = this.randbuf;
int i2 = this.randptr;
this.randptr = i2 + 1;
double s3 = s + dArr[65535 & i2];
int i3 = this.shaper_clipmin;
if (s3 < i3) {
double d = s3 / i3;
peak[0] = peak[0] < d ? d : peak[0];
s3 = this.shaper_clipmin;
}
int i4 = this.shaper_clipmax;
if (s3 > i4) {
double d2 = s3 / i4;
peak[0] = peak[0] < d2 ? d2 : peak[0];
s3 = this.shaper_clipmax;
}
return RINT(s3);
}
double h = FirebaseRemoteConfig.DEFAULT_VALUE_FOR_DOUBLE;
int i5 = 0;
while (true) {
i = this.shaper_len;
if (i5 >= i) {
break;
}
h += shapercoefs[this.shaper_type][i5] * this.shapebuf[ch][i5];
i5++;
}
double s4 = s + h;
double[] dArr2 = this.randbuf;
int i6 = this.randptr;
this.randptr = i6 + 1;
double s5 = s4 + dArr2[65535 & i6];
for (int i7 = i - 2; i7 >= 0; i7--) {
double[][] dArr3 = this.shapebuf;
dArr3[ch][i7 + 1] = dArr3[ch][i7];
}
int i8 = this.shaper_clipmin;
if (s5 >= i8) {
int i9 = this.shaper_clipmax;
if (s5 > i9) {
double d3 = s5 / i9;
peak[0] = peak[0] < d3 ? d3 : peak[0];
s2 = this.shaper_clipmax;
double[][] dArr4 = this.shapebuf;
dArr4[ch][0] = s2 - s4;
if (dArr4[ch][0] > 1.0d) {
dArr4[ch][0] = 1.0d;
}
double[][] dArr5 = this.shapebuf;
if (dArr5[ch][0] < -1.0d) {
dArr5[ch][0] = -1.0d;
}
} else {
s2 = RINT(s5);
this.shapebuf[ch][0] = s2 - s4;
}
} else {
double d4 = s5 / i8;
peak[0] = peak[0] < d4 ? d4 : peak[0];
s2 = this.shaper_clipmin;
double[][] dArr6 = this.shapebuf;
dArr6[ch][0] = s2 - s4;
if (dArr6[ch][0] > 1.0d) {
dArr6[ch][0] = 1.0d;
}
double[][] dArr7 = this.shapebuf;
if (dArr7[ch][0] < -1.0d) {
dArr7[ch][0] = -1.0d;
}
}
return (int) s2;
}
private void quit_shaper(int nch) {
}
private double alpha(double a) {
if (a <= 21.0d) {
return FirebaseRemoteConfig.DEFAULT_VALUE_FOR_DOUBLE;
}
if (a <= 50.0d) {
return (Math.pow(a - 21.0d, 0.4d) * 0.5842d) + ((a - 21.0d) * 0.07886d);
}
return (a - 8.7d) * 0.1102d;
}
private double win(double n, int len, double alp, double iza) {
return I0Bessel.value(Math.sqrt(1.0d - (((4.0d * n) * n) / ((len - 1.0d) * (len - 1.0d)))) * alp) / iza;
}
private double sinc(double x) {
if (x == FirebaseRemoteConfig.DEFAULT_VALUE_FOR_DOUBLE) {
return 1.0d;
}
return Math.sin(x) / x;
}
private double hn_lpf(int n, double lpf, double fs) {
double t = 1.0d / fs;
double omega = 6.283185307179586d * lpf;
return 2.0d * lpf * t * sinc(n * omega * t);
}
private void usage() {
System.err.printf("http://shibatch.sourceforge.net/\n\n", new Object[0]);
System.err.printf("usage: ssrc [<options>] <source wav file> <destination wav file>\n", new Object[0]);
System.err.printf("options : --rate <sampling rate> output sample rate\n", new Object[0]);
System.err.printf(" --att <attenuation(dB)> attenuate signal\n", new Object[0]);
System.err.printf(" --bits <number of bits> output quantization bit length\n", new Object[0]);
System.err.printf(" --tmpfile <file name> specify temporal file\n", new Object[0]);
System.err.printf(" --twopass two pass processing to avoid clipping\n", new Object[0]);
System.err.printf(" --normalize normalize the wave file\n", new Object[0]);
System.err.printf(" --quiet nothing displayed except error\n", new Object[0]);
System.err.printf(" --dither [<type>] dithering\n", new Object[0]);
System.err.printf(" 0 : no dither\n", new Object[0]);
System.err.printf(" 1 : no noise shaping\n", new Object[0]);
System.err.printf(" 2 : triangular spectral shape\n", new Object[0]);
System.err.printf(" 3 : ATH based noise shaping\n", new Object[0]);
System.err.printf(" 4 : less dither amplitude than type 3\n", new Object[0]);
System.err.printf(" --pdf <type> [<amp>] select p.d.f. of noise\n", new Object[0]);
System.err.printf(" 0 : rectangular\n", new Object[0]);
System.err.printf(" 1 : triangular\n", new Object[0]);
System.err.printf(" 2 : Gaussian\n", new Object[0]);
System.err.printf(" --profile <type> specify profile\n", new Object[0]);
System.err.printf(" standard : the default quality\n", new Object[0]);
System.err.printf(" fast : fast, not so bad quality\n", new Object[0]);
}
private void fmterr(int x) {
throw new IllegalStateException("unknown error " + x);
}
private void setstarttime() {
this.starttime = System.currentTimeMillis();
this.lastshowed = 0L;
this.lastshowed2 = -1;
}
private void showprogress(double p) {
int eta;
if (this.quiet) {
return;
}
long t = System.currentTimeMillis() - this.starttime;
if (p == FirebaseRemoteConfig.DEFAULT_VALUE_FOR_DOUBLE) {
eta = 0;
} else {
eta = (int) ((t * (1.0d - p)) / p);
}
int pc = (int) (100.0d * p);
if (pc != this.lastshowed2 || t != this.lastshowed) {
System.err.printf(" %3d%% processed", Integer.valueOf(pc));
this.lastshowed2 = pc;
}
if (t != this.lastshowed) {
System.err.printf(", ETA =%4dmsec", Integer.valueOf(eta));
this.lastshowed = t;
}
System.err.printf("\r", new Object[0]);
System.err.flush();
}
private int gcd(int x, int y) {
while (y != 0) {
int t = x % y;
x = y;
y = t;
}
return x;
}
public double upsample(InputStream fpi, OutputStream fpo, int nch, int bps, int dbps, int sfrq, int dfrq, double gain, int chanklen, boolean twopass, int dither) throws IOException {
int osf;
double d;
int n1;
double d2;
int n2;
double lpf;
int toberead;
int nsmplread;
int chanklen2;
byte[] tempData;
int n2b;
int n2b2;
int i;
ByteBuffer rawinbuf;
int n2b22;
int i2;
int n2b3;
double[] inbuf;
double[] outbuf;
int n2b4;
int n1x;
int n1x2;
int chanklen3;
ByteBuffer rawoutbuf;
int s;
int chanklen4;
double[] inbuf2;
ByteBuffer rawoutbuf2;
int i3;
int s2;
int i4;
int n2b5;
double[] inbuf3;
double[] outbuf2;
byte[] outbuf3;
int n2b6;
int n1x3;
int n1x4;
int s3;
int fs1;
int sumread;
int sumwrite;
int delay;
int i5;
int sumread2;
int nsmplwrt2;
SSRC ssrc;
SSRC ssrc2;
int inbuflen;
int sumread3;
int chanklen5;
int toberead2;
int toberead3;
int no;
int i6 = sfrq;
int sumwrite2 = dfrq;
Class<double> cls = double.class;
double[] peak = {FirebaseRemoteConfig.DEFAULT_VALUE_FOR_DOUBLE};
int filter2len = this.FFTFIRLEN;
double aa = this.AA;
int frqgcd = gcd(i6, sumwrite2);
int fs12 = (i6 / frqgcd) * sumwrite2;
if (fs12 / sumwrite2 == 1) {
osf = 1;
} else if ((fs12 / sumwrite2) % 2 == 0) {
osf = 2;
} else if ((fs12 / sumwrite2) % 3 == 0) {
osf = 3;
} else {
throw new IllegalArgumentException(String.format("Resampling from %dHz to %dHz is not supported.\n%d/gcd(%d,%d)=%d must be divided by 2 or 3.\n", Integer.valueOf(sfrq), Integer.valueOf(dfrq), Integer.valueOf(sfrq), Integer.valueOf(sfrq), Integer.valueOf(dfrq), Integer.valueOf(fs12 / dfrq)));
}
double df = ((((sumwrite2 * osf) / 2) - (i6 / 2)) * 2) / 2.0d;
double lpf2 = (i6 / 2) + ((((sumwrite2 * osf) / 2) - (i6 / 2)) / 2.0d);
if (aa <= 21.0d) {
d = 0.9222d;
} else {
double d3 = aa - 7.95d;
d = d3 / 14.36d;
}
int n12 = (int) (((fs12 / df) * d) + 1.0d);
if (n12 % 2 != 0) {
n1 = n12;
} else {
n1 = n12 + 1;
}
SSRC ssrc3 = this;
double alp = ssrc3.alpha(aa);
double iza = I0Bessel.value(alp);
int n1y = fs12 / i6;
int n1x5 = (n1 / n1y) + 1;
int[] f1order = new int[n1y * osf];
for (int i7 = 0; i7 < n1y * osf; i7++) {
f1order[i7] = (fs12 / i6) - (((fs12 / (sumwrite2 * osf)) * i7) % (fs12 / i6));
if (f1order[i7] == fs12 / i6) {
f1order[i7] = 0;
}
}
int[] f1inc = new int[n1y * osf];
int i8 = 0;
while (i8 < n1y * osf) {
double aa2 = aa;
f1inc[i8] = f1order[i8] < fs12 / (sumwrite2 * osf) ? nch : 0;
if (f1order[i8] == fs12 / i6) {
f1order[i8] = 0;
}
i8++;
aa = aa2;
}
double[][] stage1 = (double[][]) Array.newInstance((Class<?>) cls, n1y, n1x5);
int i9 = -(n1 / 2);
int i10 = i9;
while (i10 <= i) {
int i11 = i10;
int[] f1inc2 = f1inc;
int fs13 = fs12;
stage1[((n1 / 2) + i10) % n1y][((n1 / 2) + i10) / n1y] = ((win(i10, n1, alp, iza) * hn_lpf(i11, lpf2, fs13)) * fs13) / i6;
i10 = i11 + 1;
fs12 = fs13;
ssrc3 = ssrc3;
filter2len = filter2len;
cls = cls;
f1inc = f1inc2;
f1order = f1order;
n1x5 = n1x5;
}
int[] f1order2 = f1order;
int filter2len2 = filter2len;
SSRC ssrc4 = ssrc3;
int n22 = n1x5;
int[] f1inc3 = f1inc;
Class<double> cls2 = cls;
int fs14 = fs12;
double aa3 = ssrc4.AA;
if (aa3 <= 21.0d) {
d2 = 0.9222d;
} else {
double d4 = aa3 - 7.95d;
d2 = d4 / 14.36d;
}
int fs2 = sumwrite2 * osf;
int i12 = 1;
while (true) {
int n23 = filter2len2 * i12;
n2 = n23 % 2 != 0 ? n23 : n23 - 1;
double df2 = (fs2 * d2) / (n2 - 1);
lpf = i6 / 2;
if (df2 < ssrc4.DF) {
break;
}
i12 *= 2;
sumwrite2 = dfrq;
fs14 = fs14;
n22 = n22;
}
double alp2 = ssrc4.alpha(aa3);
double iza2 = I0Bessel.value(alp2);
int n2b7 = 1;
while (n2b7 < n2) {
n2b7 *= 2;
}
int n2b8 = n2b7 * 2;
double[] stage2 = new double[n2b8];
int i13 = -(n2 / 2);
int i14 = i13;
while (i14 <= i) {
double lpf3 = lpf;
int n2b9 = n2b8;
double[] stage22 = stage2;
int i15 = i14;
double aa4 = aa3;
int fs22 = fs2;
stage22[i14 + (n2 / 2)] = ((win(i14, n2, alp2, iza2) * hn_lpf(i15, lpf3, fs22)) / n2b9) * 2.0d;
i14 = i15 + 1;
fs2 = fs22;
n2 = n2;
n2b8 = n2b9;
lpf = lpf3;
stage2 = stage22;
aa3 = aa4;
}
double[] stage23 = stage2;
int ip_backup = i14;
int n2b10 = n2b8;
int fs23 = fs2;
int n24 = n2;
int ipsize = (int) (Math.sqrt(n2b10) + 2.0d);
int[] fft_ip = new int[ipsize];
fft_ip[0] = 0;
int wsize = n2b10 / 2;
double[] fft_w = new double[wsize];
ssrc4.fft.rdft(n2b10, 1, stage23, fft_ip, fft_w);
setstarttime();
int n2b23 = n2b10 / 2;
int ip = 0;
int[] iArr = {spcount, (n2b23 / osf) + 1};
int spcount = nch;
double[][] buf1 = (double[][]) Array.newInstance((Class<?>) cls2, iArr);
double[][] buf2 = (double[][]) Array.newInstance((Class<?>) cls2, spcount, n2b10);
int n1x6 = n22;
int i16 = bps;
ByteBuffer rawinbuf2 = ByteBuffer.allocate((n2b23 + n1x6) * spcount * i16);
ByteBuffer rawoutbuf3 = ByteBuffer.allocate(((n2b23 / osf) + 1) * spcount * dbps);
double[] inbuf4 = new double[spcount * (n2b23 + n1x6)];
int delay2 = spcount * ((n2b23 / osf) + 1);
double[] outbuf4 = new double[delay2];
int rp = 0;
int p = 0;
boolean init = true;
ByteBuffer rawoutbuf4 = rawoutbuf3;
int n25 = fs23 / sumwrite2;
int delay3 = (int) ((n24 / 2.0d) / n25);
int spcount2 = 0;
ByteBuffer rawinbuf3 = rawinbuf2;
int filter2len3 = ((n1 / 2) / (fs14 / i6)) + 1;
int s1p = 0;
int s1p_backup = 0;
int delay4 = 0;
int ch = delay3;
int delay5 = chanklen;
while (true) {
int delay6 = ch;
int sumwrite3 = delay4;
double[] inbuf5 = inbuf4;
double[] outbuf5 = outbuf4;
int toberead4 = (int) (((Math.floor((n2b23 * i6) / (sumwrite2 * osf)) + 1.0d) + n1x6) - filter2len3);
int toberead22 = toberead4;
if (toberead4 + s1p_backup <= delay5) {
toberead = toberead4;
} else {
toberead = delay5 - s1p_backup;
}
rawinbuf3.position(0);
rawinbuf3.limit(Math.min(rawinbuf3.limit(), i16 * spcount * toberead));
byte[] tempData2 = new byte[rawinbuf3.limit()];
int nsmplread2 = fpi.read(tempData2);
if (nsmplread2 >= 0) {
nsmplread = nsmplread2;
} else {
nsmplread = 0;
}
int nsmplread3 = delay5;
int chanklen6 = rawinbuf3.limit();
if (nsmplread >= chanklen6) {
chanklen2 = nsmplread3;
} else {
chanklen2 = s1p_backup + ((nsmplread / i16) * spcount);
}
rawinbuf3.limit(nsmplread);
ByteBuffer rawinbuf4 = ByteBuffer.wrap(tempData2);
rawinbuf4.position(nsmplread);
rawinbuf4.flip();
int nsmplread4 = nsmplread / (i16 * spcount);
if (i16 == 1) {
tempData = tempData2;
n2b = n2b10;
n2b2 = n1x6;
i = 0;
while (i < nsmplread4 * spcount) {
inbuf5[(spcount * filter2len3) + i] = (rawinbuf4.get(i) - 128.0d) * 0.007874015748031496d;
i++;
}
} else if (i16 == 2) {
tempData = tempData2;
n2b = n2b10;
i = 0;
while (i < nsmplread4 * spcount) {
int v = rawinbuf4.order(ssrc4.byteOrder).asShortBuffer().get(i);
inbuf5[(spcount * filter2len3) + i] = v * 3.051850947599719E-5d;
i++;
n1x6 = n1x6;
}
n2b2 = n1x6;
} else if (i16 == 3) {
tempData = tempData2;
n2b = n2b10;
i = 0;
while (i < nsmplread4 * spcount) {
inbuf5[(spcount * filter2len3) + i] = ((rawinbuf4.get(i * 3) << 0) | (rawinbuf4.get((i * 3) + 1) << 8) | (rawinbuf4.get((i * 3) + 2) << 16)) * 1.1920930376163766E-7d;
i++;
}
n2b2 = n1x6;
} else if (i16 != 4) {
tempData = tempData2;
n2b = n2b10;
i = ip_backup;
n2b2 = n1x6;
} else {
i = 0;
while (true) {
tempData = tempData2;
if (i >= nsmplread4 * spcount) {
break;
}
int v2 = rawinbuf4.order(ssrc4.byteOrder).asIntBuffer().get(i);
inbuf5[(spcount * filter2len3) + i] = v2 * 4.656612875245797E-10d;
i++;
tempData2 = tempData;
n2b10 = n2b10;
}
n2b = n2b10;
n2b2 = n1x6;
}
while (i < spcount * toberead22) {
inbuf5[(spcount * filter2len3) + i] = 0.0d;
i++;
}
int inbuflen2 = filter2len3 + toberead22;
int sumread4 = s1p_backup + nsmplread4;
boolean ending = sumread4 >= chanklen2;
int nsmplwrt1 = n2b23;
int ip2 = ((((rp - 1) * i6) + fs14) / fs14) * spcount;
int s1p_backup2 = s1p;
int osc_backup = p;
int ch2 = 0;
int nsmplwrt22 = ip;
while (true) {
rawinbuf = rawinbuf4;
if (ch2 >= spcount) {
break;
}
int op = ch2;
int n2b11 = n1y * osf;
s1p = s1p_backup2;
int ip3 = ip2 + ch2;
int i17 = i;
if (n2b2 == 7) {
toberead2 = toberead22;
toberead3 = toberead;
for (int p2 = 0; p2 < nsmplwrt1; p2++) {
int s1o = f1order2[s1p];
buf2[ch2][p2] = (stage1[s1o][0] * inbuf5[ip3 + (spcount * 0)]) + (stage1[s1o][1] * inbuf5[ip3 + (spcount * 1)]) + (stage1[s1o][2] * inbuf5[ip3 + (spcount * 2)]) + (stage1[s1o][3] * inbuf5[ip3 + (spcount * 3)]) + (stage1[s1o][4] * inbuf5[ip3 + (spcount * 4)]) + (stage1[s1o][5] * inbuf5[ip3 + (spcount * 5)]) + (stage1[s1o][6] * inbuf5[ip3 + (spcount * 6)]);
ip3 += f1inc3[s1p];
int s1p2 = s1p + 1;
if (s1p2 == n2b11) {
s1p2 = 0;
}
s1p = s1p2;
}
} else if (n2b2 == 9) {
toberead2 = toberead22;
int p3 = 0;
while (p3 < nsmplwrt1) {
int s1o2 = f1order2[s1p];
int toberead5 = toberead;
buf2[ch2][p3] = (stage1[s1o2][0] * inbuf5[ip3 + (spcount * 0)]) + (stage1[s1o2][1] * inbuf5[ip3 + (spcount * 1)]) + (stage1[s1o2][2] * inbuf5[ip3 + (spcount * 2)]) + (stage1[s1o2][3] * inbuf5[ip3 + (spcount * 3)]) + (stage1[s1o2][4] * inbuf5[ip3 + (spcount * 4)]) + (stage1[s1o2][5] * inbuf5[ip3 + (spcount * 5)]) + (stage1[s1o2][6] * inbuf5[ip3 + (spcount * 6)]) + (stage1[s1o2][7] * inbuf5[ip3 + (spcount * 7)]) + (stage1[s1o2][8] * inbuf5[ip3 + (spcount * 8)]);
ip3 += f1inc3[s1p];
int s1p3 = s1p + 1;
if (s1p3 == n2b11) {
s1p3 = 0;
}
s1p = s1p3;
p3++;
toberead = toberead5;
}
toberead3 = toberead;
} else {
int p4 = 0;
while (p4 < nsmplwrt1) {
double tmp = FirebaseRemoteConfig.DEFAULT_VALUE_FOR_DOUBLE;
int ip22 = ip3;
int s1o3 = f1order2[s1p];
int toberead23 = toberead22;
int toberead24 = 0;
while (toberead24 < n2b2) {
tmp += stage1[s1o3][toberead24] * inbuf5[ip22];
ip22 += spcount;
toberead24++;
}
buf2[ch2][p4] = tmp;
ip3 += f1inc3[s1p];
i17 = toberead24;
int s1p4 = s1p + 1;
if (s1p4 == n2b11) {
s1p4 = 0;
}
s1p = s1p4;
p4++;
toberead22 = toberead23;
}
toberead2 = toberead22;
toberead3 = toberead;
}
int p5 = nsmplwrt1;
while (true) {
int no2 = n2b11;
no = n2b;
if (p5 >= no) {
break;
}
buf2[ch2][p5] = 0.0d;
p5++;
n2b = no;
n2b11 = no2;
}
ssrc4.fft.rdft(no, 1, buf2[ch2], fft_ip, fft_w);
buf2[ch2][0] = stage23[0] * buf2[ch2][0];
buf2[ch2][1] = stage23[1] * buf2[ch2][1];
for (int i18 = 1; i18 < i; i18++) {
double re = (stage23[i18 * 2] * buf2[ch2][i18 * 2]) - (stage23[(i18 * 2) + 1] * buf2[ch2][(i18 * 2) + 1]);
double im2 = (stage23[(i18 * 2) + 1] * buf2[ch2][i18 * 2]) + (stage23[i18 * 2] * buf2[ch2][(i18 * 2) + 1]);
buf2[ch2][i18 * 2] = re;
buf2[ch2][(i18 * 2) + 1] = im2;
}
ssrc4.fft.rdft(no, -1, buf2[ch2], fft_ip, fft_w);
i = osc_backup;
int j = 0;
while (i < n2b23) {
outbuf5[op + (j * spcount)] = buf1[ch2][j] + buf2[ch2][i];
i += osf;
j++;
}
nsmplwrt22 = j;
int osc = i - n2b23;
int j2 = 0;
while (i < no) {
buf1[ch2][j2] = buf2[ch2][i];
i += osf;
j2++;
}
ch2++;
n2b = no;
p = osc;
rawinbuf4 = rawinbuf;
toberead22 = toberead2;
toberead = toberead3;
}
int i19 = i;
int n2b12 = n2b;
int i20 = i6 / frqgcd;
int rp2 = rp + ((i20 * nsmplwrt1) / osf);
rawoutbuf4.clear();
if (twopass) {
int i21 = 0;
while (i21 < nsmplwrt22 * spcount) {
double f = outbuf5[i21] > FirebaseRemoteConfig.DEFAULT_VALUE_FOR_DOUBLE ? outbuf5[i21] : -outbuf5[i21];
peak[0] = peak[0] < f ? f : peak[0];
rawoutbuf4.asDoubleBuffer().put(i21, outbuf5[i21]);
i21++;
ch2 = ch2;
n2b23 = n2b23;
nsmplwrt1 = nsmplwrt1;
}
n2b22 = n2b23;
i2 = dbps;
i19 = i21;
n2b3 = n2b12;
inbuf = inbuf5;
outbuf = outbuf5;
n2b4 = spcount;
n1x = n2b2;
n1x2 = nsmplwrt22;
ByteBuffer byteBuffer = rawoutbuf4;
chanklen3 = chanklen2;
rawoutbuf = byteBuffer;
} else {
int ch3 = ch2;
n2b22 = n2b23;
i2 = dbps;
if (i2 == 1) {
n2b3 = n2b12;
inbuf = inbuf5;
outbuf = outbuf5;
n2b4 = spcount;
n1x = n2b2;
n1x2 = nsmplwrt22;
ByteBuffer byteBuffer2 = rawoutbuf4;
chanklen3 = chanklen2;
rawoutbuf = byteBuffer2;
double gain2 = gain * 127.0d;
int ch4 = 0;
int i22 = 0;
while (i22 < n1x2 * n2b4) {
if (dither != 0) {
s = do_shaping(outbuf[i22] * gain2, peak, dither, ch4);
} else {
s = ssrc4.RINT(outbuf[i22] * gain2);
if (s < -128) {
double d5 = s / (-128.0d);
peak[0] = peak[0] < d5 ? d5 : peak[0];
s = -128;
}
if (127 < s) {
double d6 = s / 127.0d;
peak[0] = peak[0] < d6 ? d6 : peak[0];
s = 127;
}
}
rawoutbuf.put(i22, (byte) (s + 128));
int ch5 = ch4 + 1;
if (ch5 == n2b4) {
ch5 = 0;
}
ch4 = ch5;
i22++;
}
i19 = i22;
ch2 = ch4;
} else if (i2 == 2) {
n2b3 = n2b12;
double[] inbuf6 = inbuf5;
ByteBuffer rawoutbuf5 = rawoutbuf4;
outbuf = outbuf5;
n2b4 = spcount;
n1x = n2b2;
n1x2 = nsmplwrt22;
double gain22 = gain * 32767.0d;
int ch6 = 0;
int i23 = 0;
while (i23 < n1x2 * n2b4) {
if (dither != 0) {
chanklen4 = chanklen2;
rawoutbuf2 = rawoutbuf5;
inbuf2 = inbuf6;
i3 = i23;
int i24 = ch6;
s2 = do_shaping(outbuf[i23] * gain22, peak, dither, i24);
} else {
chanklen4 = chanklen2;
inbuf2 = inbuf6;
rawoutbuf2 = rawoutbuf5;
i3 = i23;
s2 = ssrc4.RINT(outbuf[i3] * gain22);
if (s2 < -32768) {
double d7 = s2 / (-32768.0d);
peak[0] = peak[0] < d7 ? d7 : peak[0];
s2 = -32768;
}
if (32767 < s2) {
double d8 = s2 / 32767.0d;
peak[0] = peak[0] < d8 ? d8 : peak[0];
s2 = 32767;
}
}
rawoutbuf2.order(ssrc4.byteOrder).asShortBuffer().put(i3, (short) s2);
int ch7 = ch6 + 1;
if (ch7 == n2b4) {
ch7 = 0;
}
ch6 = ch7;
i23 = i3 + 1;
rawoutbuf5 = rawoutbuf2;
chanklen2 = chanklen4;
inbuf6 = inbuf2;
}
chanklen3 = chanklen2;
inbuf = inbuf6;
rawoutbuf = rawoutbuf5;
i19 = i23;
ch2 = ch6;
} else if (i2 != 3) {
n2b3 = n2b12;
inbuf = inbuf5;
ch2 = ch3;
outbuf = outbuf5;
n2b4 = spcount;
n1x = n2b2;
n1x2 = nsmplwrt22;
ByteBuffer byteBuffer3 = rawoutbuf4;
chanklen3 = chanklen2;
rawoutbuf = byteBuffer3;
} else {
double gain23 = gain * 8388607.0d;
int ch8 = 0;
int i25 = 0;
while (i25 < ch) {
if (dither != 0) {
inbuf3 = inbuf5;
n2b5 = n2b12;
outbuf2 = outbuf5;
outbuf3 = tempData;
n2b6 = spcount;
n1x3 = n2b2;
n1x4 = nsmplwrt22;
i4 = i25;
int i26 = ch8;
s3 = do_shaping(outbuf5[i25] * gain23, peak, dither, i26);
} else {
i4 = i25;
n2b5 = n2b12;
inbuf3 = inbuf5;
outbuf2 = outbuf5;
outbuf3 = tempData;
n2b6 = spcount;
n1x3 = n2b2;
n1x4 = nsmplwrt22;
s3 = ssrc4.RINT(outbuf2[i4] * gain23);
if (s3 < -8388608) {
double d9 = s3 / (-8388608.0d);
peak[0] = peak[0] < d9 ? d9 : peak[0];
s3 = -8388608;
}
if (8388607 < s3) {
double d10 = s3 / 8388607.0d;
peak[0] = peak[0] < d10 ? d10 : peak[0];
s3 = 8388607;
}
}
ByteBuffer rawoutbuf6 = rawoutbuf4;
rawoutbuf6.put(i4 * 3, (byte) (s3 & 255));
int s4 = s3 >> 8;
rawoutbuf6.put((i4 * 3) + 1, (byte) (s4 & 255));
rawoutbuf6.put((i4 * 3) + 2, (byte) ((s4 >> 8) & 255));
int ch9 = ch8 + 1;
if (ch9 == n2b6) {
ch9 = 0;
}
ch8 = ch9;
i25 = i4 + 1;
rawoutbuf4 = rawoutbuf6;
spcount = n2b6;
inbuf5 = inbuf3;
nsmplwrt22 = n1x4;
n2b2 = n1x3;
n2b12 = n2b5;
tempData = outbuf3;
outbuf5 = outbuf2;
}
i19 = i25;
n2b3 = n2b12;
ByteBuffer rawoutbuf7 = rawoutbuf4;
outbuf = outbuf5;
n2b4 = spcount;
n1x = n2b2;
n1x2 = nsmplwrt22;
chanklen3 = chanklen2;
inbuf = inbuf5;
ch2 = ch8;
rawoutbuf = rawoutbuf7;
}
}
if (!init) {
if (ending) {
if (((sumread4 * dfrq) / i6) + 2.0d > sumwrite3 + n1x2) {
rawoutbuf.position(0);
rawoutbuf.limit(i2 * n2b4 * n1x2);
ssrc4.writeBuffers(fpo, rawoutbuf);
int i27 = sumwrite3 + n1x2;
fs1 = fs14;
ssrc = ssrc4;
sumwrite = inbuflen2;
i5 = i6;
sumread2 = sumread4;
nsmplwrt2 = n1x2;
sumread = i27;
delay = delay6;
} else {
rawoutbuf.position(0);
int limitData = (int) (i2 * n2b4 * ((Math.floor((sumread4 * dfrq) / i6) + 2.0d) - sumwrite3));
if (limitData > 0) {
rawoutbuf.limit(limitData);
ssrc4.writeBuffers(fpo, rawoutbuf);
ssrc2 = ssrc4;
} else {
ssrc2 = ssrc4;
}
}
} else {
fs1 = fs14;
int nsmplwrt23 = n1x2;
sumwrite = inbuflen2;
rawoutbuf.position(0);
rawoutbuf.limit(i2 * n2b4 * nsmplwrt23);
ssrc4.writeBuffers(fpo, rawoutbuf);
i5 = sfrq;
sumread2 = sumread4;
sumread = sumwrite3 + nsmplwrt23;
ssrc = ssrc4;
delay = delay6;
nsmplwrt2 = nsmplwrt23;
}
int ds = (rp2 - 1) / (fs1 / i5);
double[] inbuf7 = inbuf;
System.arraycopy(inbuf7, nch * ds, inbuf7, 0, (sumwrite - ds) * nch);
int inbuflen3 = sumwrite - ds;
rp = rp2 - ((fs1 / i5) * ds);
int spcount3 = spcount2 + 1;
if ((spcount2 & 7) == 7) {
inbuflen = inbuflen3;
sumread3 = sumread2;
chanklen5 = chanklen3;
} else {
sumread3 = sumread2;
inbuflen = inbuflen3;
chanklen5 = chanklen3;
ssrc.showprogress(sumread3 / chanklen5);
}
filter2len3 = inbuflen;
spcount2 = spcount3;
s1p_backup = sumread3;
i6 = i5;
rawoutbuf4 = rawoutbuf;
ip = nsmplwrt2;
ch = delay;
ssrc4 = ssrc;
delay4 = sumread;
inbuf4 = inbuf7;
fs14 = fs1;
ip_backup = i19;
outbuf4 = outbuf;
n1x6 = n1x;
n2b10 = n2b3;
rawinbuf3 = rawinbuf;
spcount = nch;
i16 = bps;
sumwrite2 = dfrq;
delay5 = chanklen5;
n2b23 = n2b22;
} else {
fs1 = fs14;
int nsmplwrt24 = n1x2;
sumread = sumwrite3;
sumwrite = inbuflen2;
delay = delay6;
if (nsmplwrt24 < delay) {
delay -= nsmplwrt24;
i5 = sfrq;
sumread2 = sumread4;
nsmplwrt2 = nsmplwrt24;
ssrc = ssrc4;
} else if (ending) {
i5 = sfrq;
if (((sumread4 * dfrq) / i5) + 2.0d > (sumread + nsmplwrt24) - delay) {
rawoutbuf.position(i2 * n2b4 * delay);
rawoutbuf.limit(i2 * n2b4 * (nsmplwrt24 - delay));
ssrc = this;
ssrc.writeBuffers(fpo, rawoutbuf);
sumread2 = sumread4;
sumread = (nsmplwrt24 - delay) + sumread;
nsmplwrt2 = nsmplwrt24;
} else {
ssrc2 = this;
rawoutbuf.position(i2 * n2b4 * delay);
rawoutbuf.limit((int) (i2 * n2b4 * ((((Math.floor((sumread4 * dfrq) / i5) + 2.0d) + sumread) + nsmplwrt24) - delay)));
ssrc2.writeBuffers(fpo, rawoutbuf);
break;
}
} else {
i5 = sfrq;
sumread2 = sumread4;
nsmplwrt2 = nsmplwrt24;
ssrc = ssrc4;
rawoutbuf.position(dbps * nch * delay);
rawoutbuf.limit(dbps * nch * nsmplwrt2);
ssrc.writeBuffers(fpo, rawoutbuf);
sumread = (nsmplwrt2 - delay) + sumread;
init = false;
}
int ds2 = (rp2 - 1) / (fs1 / i5);
double[] inbuf72 = inbuf;
System.arraycopy(inbuf72, nch * ds2, inbuf72, 0, (sumwrite - ds2) * nch);
int inbuflen32 = sumwrite - ds2;
rp = rp2 - ((fs1 / i5) * ds2);
int spcount32 = spcount2 + 1;
if ((spcount2 & 7) == 7) {
}
filter2len3 = inbuflen;
spcount2 = spcount32;
s1p_backup = sumread3;
i6 = i5;
rawoutbuf4 = rawoutbuf;
ip = nsmplwrt2;
ch = delay;
ssrc4 = ssrc;
delay4 = sumread;
inbuf4 = inbuf72;
fs14 = fs1;
ip_backup = i19;
outbuf4 = outbuf;
n1x6 = n1x;
n2b10 = n2b3;
rawinbuf3 = rawinbuf;
spcount = nch;
i16 = bps;
sumwrite2 = dfrq;
delay5 = chanklen5;
n2b23 = n2b22;
}
}
ssrc2.showprogress(1.0d);
return peak[0];
}
public double downsample(InputStream fpi, OutputStream fpo, int nch, int bps, int dbps, int sfrq, int dfrq, double gain, int chanklen, boolean twopass, int dither) throws IOException {
int osf;
double d;
int n1;
int n12;
double lpf;
double d2;
int n2;
double[][] stage2;
int fs2;
double[] fft_w;
int[] fft_ip;
int n22;
int ds;
int[] f2inc;
int n2y;
int[] f2order;
int i;
int chanklen2;
int chanklen3;
int chanklen4;
int delay;
int sumwrite;
SSRC ssrc;
int i2;
int i3;
int n2y2;
int rp;
int rps;
ByteBuffer rawoutbuf;
int s2p_backup;
ByteBuffer rawinbuf;
SSRC ssrc2;
int rp2;
int toberead;
double[] inbuf;
int i4;
int i5;
int s;
long j;
int i6;
int s2;
long j2;
int i7;
int n2y3;
int s2p_backup2;
int rp3;
int rps2;
ByteBuffer rawoutbuf2;
int s2p_backup3;
ByteBuffer rawinbuf2;
int n1b;
int rp4;
int toberead2;
int toberead3;
double[] inbuf2;
int s3;
int i8;
int sumread;
int chanklen5;
int nsmplwrt2;
int n13;
int nsmplwrt22;
int ch;
int n2x;
int sumread2;
int ds2;
int n1b2;
int ch2;
int ch3;
int sumread3;
int n1b3;
int chanklen6;
int n1b22 = nch;
int i9 = sfrq;
Class<double> cls = double.class;
int spcount = 0;
double[] peak = {FirebaseRemoteConfig.DEFAULT_VALUE_FOR_DOUBLE};
int filter1len = this.FFTFIRLEN;
double aa = this.AA;
int frqgcd = gcd(i9, dfrq);
if (dfrq / frqgcd == 1) {
osf = 1;
} else if ((dfrq / frqgcd) % 2 == 0) {
osf = 2;
} else if ((dfrq / frqgcd) % 3 == 0) {
osf = 3;
} else {
throw new IllegalArgumentException(String.format("Resampling from %dHz to %dHz is not supported.\n%d/gcd(%d,%d)=%d must be divided by 2 or 3.", Integer.valueOf(sfrq), Integer.valueOf(dfrq), Integer.valueOf(dfrq), Integer.valueOf(sfrq), Integer.valueOf(dfrq), Integer.valueOf(dfrq / frqgcd)));
}
int fs1 = i9 * osf;
if (aa <= 21.0d) {
d = 0.9222d;
} else {
double d3 = aa - 7.95d;
d = d3 / 14.36d;
}
int i10 = 1;
while (true) {
int n14 = filter1len * i10;
n1 = n14 % 2 != 0 ? n14 : n14 - 1;
n12 = osf;
int filter1len2 = filter1len;
double df = (fs1 * d) / (n1 - 1);
lpf = (dfrq - df) / 2.0d;
if (df < this.DF) {
break;
}
i10 *= 2;
i9 = sfrq;
filter1len = filter1len2;
osf = n12;
cls = cls;
aa = aa;
}
double alp = alpha(aa);
double iza = I0Bessel.value(alp);
FileLog.e("须打log, 不打的话在某些机型上会卡住");
int n1b4 = 1;
while (n1b4 < n1) {
n1b4 *= 2;
}
int n1b5 = n1b4 * 2;
double[] stage1 = new double[n1b5];
int i11 = -(n1 / 2);
while (i11 <= n1 / 2) {
int fs12 = fs1;
int osf2 = n12;
int i12 = i11;
int n1b6 = n1b5;
double[] stage12 = stage1;
stage12[i11 + (n1 / 2)] = ((((win(i11, n1, alp, iza) * hn_lpf(i12, lpf, fs12)) * fs12) / i9) / n1b6) * 2.0d;
i11 = i12 + 1;
fs1 = fs12;
n1b5 = n1b6;
n1 = n1;
aa = aa;
stage1 = stage12;
n12 = osf2;
}
int i13 = i11;
int n1b7 = n1b5;
double[] stage13 = stage1;
int osf3 = n12;
int osf4 = n1;
int n15 = fs1;
int ipsize = (int) (Math.sqrt(n1b7) + 2.0d);
int[] fft_ip2 = new int[ipsize];
fft_ip2[0] = 0;
int wsize = n1b7 / 2;
double[] fft_w2 = new double[wsize];
this.fft.rdft(n1b7, 1, stage13, fft_ip2, fft_w2);
if (osf3 == 1) {
int[] f2inc2 = {i9 / dfrq};
double[][] stage22 = (double[][]) Array.newInstance((Class<?>) cls, 1, 1);
stage22[0][0] = 1.0d;
stage2 = stage22;
f2inc = f2inc2;
fft_ip = fft_ip2;
fft_w = fft_w2;
fs2 = (i9 / frqgcd) * dfrq;
n22 = 1;
n2y = 1;
ds = 1;
f2order = new int[]{0};
i = i13;
} else {
double aa2 = this.AA;
int fs22 = (i9 / frqgcd) * dfrq;
double df2 = (((n15 / 2) - (i9 / 2)) * 2) / 2.0d;
int[] f2inc3 = fft_ip2;
double[] fft_w3 = fft_w2;
double lpf2 = (i9 / 2) + (((n15 / 2) - (i9 / 2)) / 2.0d);
if (aa2 <= 21.0d) {
d2 = 0.9222d;
} else {
double d4 = aa2 - 7.95d;
d2 = d4 / 14.36d;
}
int n23 = (int) (((fs22 / df2) * d2) + 1.0d);
if (n23 % 2 != 0) {
n2 = n23;
} else {
n2 = n23 + 1;
}
double alp2 = alpha(aa2);
double iza2 = I0Bessel.value(alp2);
int n2y4 = fs22 / n15;
int n2x2 = (n2 / n2y4) + 1;
int[] f2order2 = new int[n2y4];
for (int i14 = 0; i14 < n2y4; i14++) {
f2order2[i14] = (fs22 / n15) - (((fs22 / dfrq) * i14) % (fs22 / n15));
if (f2order2[i14] == fs22 / n15) {
f2order2[i14] = 0;
}
}
int[] f2inc4 = new int[n2y4];
for (int i15 = 0; i15 < n2y4; i15++) {
f2inc4[i15] = (((fs22 / dfrq) - f2order2[i15]) / (fs22 / n15)) + 1;
if (f2order2[i15 + 1 == n2y4 ? 0 : i15 + 1] == 0) {
f2inc4[i15] = f2inc4[i15] - 1;
}
}
stage2 = (double[][]) Array.newInstance((Class<?>) cls, n2y4, n2x2);
int i16 = -(n2 / 2);
while (i16 <= n2 / 2) {
int fs23 = fs22;
int i17 = i16;
stage2[((n2 / 2) + i16) % n2y4][((n2 / 2) + i16) / n2y4] = ((win(i16, n2, alp2, iza2) * hn_lpf(i17, lpf2, fs23)) * fs23) / n15;
i16 = i17 + 1;
fs22 = fs23;
f2inc4 = f2inc4;
f2inc3 = f2inc3;
aa2 = aa2;
n2y4 = n2y4;
f2order2 = f2order2;
fft_w3 = fft_w3;
}
fs2 = fs22;
int i18 = i16;
fft_w = fft_w3;
fft_ip = f2inc3;
int[] fft_ip3 = f2inc4;
n22 = n2;
ds = n2x2;
f2inc = fft_ip3;
n2y = n2y4;
f2order = f2order2;
i = i18;
}
setstarttime();
int n1b23 = n1b7 / 2;
int nsmplwrt23 = 0;
double[][] buf1 = (double[][]) Array.newInstance((Class<?>) cls, n1b22, n1b7);
double[][] buf2 = (double[][]) Array.newInstance((Class<?>) cls, n1b22, ds + 1 + n1b23);
int n16 = bps;
ByteBuffer rawinbuf3 = ByteBuffer.allocate(((n1b23 / osf3) + osf3 + 1) * n1b22 * n16);
int i19 = i;
int n2y5 = n2y;
ByteBuffer rawoutbuf3 = ByteBuffer.allocate((int) ((((n1b23 * dfrq) / i9) + 1.0d) * dbps * n1b22));
double[] inbuf3 = new double[((n1b23 / osf3) + osf3 + 1) * n1b22];
int n1b8 = n1b7;
double[] inbuf4 = inbuf3;
ByteBuffer rawoutbuf4 = rawoutbuf3;
double[] outbuf = new double[(int) (n1b22 * (((n1b23 * dfrq) / i9) + 1.0d))];
int rp5 = 0;
int rp22 = 0;
boolean init = true;
int n17 = osf4;
int s2p = 0;
int fs24 = fs2;
int delay2 = (int) (((n17 / 2.0d) / (n15 / dfrq)) + ((n22 / 2.0d) / (fs2 / dfrq)));
int delay3 = 0;
int delay4 = delay2;
int sumwrite2 = 0;
int sumread4 = i19;
ByteBuffer rawinbuf4 = rawinbuf3;
int ch4 = chanklen;
while (true) {
int toberead4 = (((n1b23 - 0) - 1) / osf3) + 1;
int rp6 = rp5;
int rp7 = toberead4 + delay3;
if (rp7 > ch4) {
toberead4 = ch4 - delay3;
}
rawinbuf4.position(0);
rawinbuf4.limit(n16 * n1b22 * toberead4);
byte[] tempData = new byte[rawinbuf4.limit()];
int n24 = n22;
int nsmplread = fpi.read(tempData);
if (nsmplread >= 0) {
chanklen2 = ch4;
chanklen3 = nsmplread;
} else {
chanklen2 = ch4;
chanklen3 = 0;
}
int nsmplread2 = sumread4;
int i20 = rawinbuf4.limit();
if (chanklen3 >= i20) {
chanklen4 = chanklen2;
} else {
chanklen4 = ((chanklen3 / n16) * n1b22) + delay3;
}
rawinbuf4.limit(chanklen3);
ByteBuffer rawinbuf5 = ByteBuffer.wrap(tempData);
rawinbuf5.position(chanklen3);
rawinbuf5.flip();
int nsmplread3 = chanklen3 / (n16 * n1b22);
if (n16 == 1) {
delay = delay4;
sumwrite = sumwrite2;
int n18 = n17;
ssrc = this;
i2 = 0;
while (i2 < nsmplread3 * n1b22) {
inbuf4[(n1b22 * 0) + i2] = ((rawinbuf5.get(i2) & UByte.MAX_VALUE) - 128) * 0.007874015748031496d;
i2++;
n18 = n18;
}
i3 = n18;
} else if (n16 == 2) {
delay = delay4;
sumwrite = sumwrite2;
ssrc = this;
i2 = 0;
while (i2 < nsmplread3 * n1b22) {
int v = rawinbuf5.order(ssrc.byteOrder).asShortBuffer().get(i2);
inbuf4[(n1b22 * 0) + i2] = v * 3.051850947599719E-5d;
i2++;
n17 = n17;
}
i3 = n17;
} else if (n16 == 3) {
delay = delay4;
sumwrite = sumwrite2;
ssrc = this;
i2 = 0;
while (i2 < nsmplread3 * n1b22) {
inbuf4[(n1b22 * 0) + i2] = (((rawinbuf5.get(i2 * 3) & UByte.MAX_VALUE) << 0) | ((rawinbuf5.get((i2 * 3) + 1) & UByte.MAX_VALUE) << 8) | ((rawinbuf5.get((i2 * 3) + 2) & UByte.MAX_VALUE) << 16)) * 1.1920930376163766E-7d;
i2++;
}
i3 = n17;
} else if (n16 != 4) {
delay = delay4;
sumwrite = sumwrite2;
i2 = nsmplread2;
ssrc = this;
i3 = n17;
} else {
i2 = 0;
while (true) {
byte[] tempData2 = tempData;
if (i2 >= nsmplread3 * n1b22) {
break;
}
int v2 = rawinbuf5.order(this.byteOrder).getInt(i2);
inbuf4[(n1b22 * 0) + i2] = v2 * 4.656612875245797E-10d;
i2++;
tempData = tempData2;
delay4 = delay4;
sumwrite2 = sumwrite2;
}
ssrc = this;
delay = delay4;
sumwrite = sumwrite2;
i3 = n17;
}
while (i2 < n1b22 * toberead4) {
inbuf4[i2] = 0.0d;
i2++;
}
int sumread5 = delay3 + nsmplread3;
int sumread6 = fpi.available();
boolean ending = sumread6 < 0 || sumread5 >= chanklen4;
int n2y6 = 0;
int n1b24 = s2p;
int ch5 = 0;
int rps3 = 0;
int nsmplwrt24 = nsmplwrt23;
int rps4 = rp6;
while (ch5 < n1b22) {
int rps5 = n2y6;
for (int i21 = 0; i21 < rps5; i21++) {
buf1[ch5][i21] = 0.0d;
}
int k = rps5;
int i22 = 0;
while (k < n1b23) {
buf1[ch5][k] = inbuf4[(i22 * n1b22) + ch5];
ByteBuffer rawinbuf6 = rawinbuf5;
int k2 = k + 1;
while (true) {
chanklen6 = chanklen4;
int chanklen7 = k + osf3;
if (k2 < chanklen7) {
buf1[ch5][k2] = 0.0d;
k2++;
chanklen4 = chanklen6;
}
}
k += osf3;
i22++;
rawinbuf5 = rawinbuf6;
chanklen4 = chanklen6;
}
ByteBuffer rawinbuf7 = rawinbuf5;
int chanklen8 = chanklen4;
int k3 = n1b23;
while (true) {
n1b3 = n1b8;
if (k3 >= n1b3) {
break;
}
buf1[ch5][k3] = 0.0d;
k3++;
n1b8 = n1b3;
}
rps3 = k - n1b23;
rps4 += i22;
ssrc.fft.rdft(n1b3, 1, buf1[ch5], fft_ip, fft_w);
buf1[ch5][0] = stage13[0] * buf1[ch5][0];
buf1[ch5][1] = stage13[1] * buf1[ch5][1];
for (int i23 = 1; i23 < n1b23; i23++) {
double re = (stage13[i23 * 2] * buf1[ch5][i23 * 2]) - (stage13[(i23 * 2) + 1] * buf1[ch5][(i23 * 2) + 1]);
double im2 = (stage13[(i23 * 2) + 1] * buf1[ch5][i23 * 2]) + (stage13[i23 * 2] * buf1[ch5][(i23 * 2) + 1]);
buf1[ch5][i23 * 2] = re;
buf1[ch5][(i23 * 2) + 1] = im2;
}
ssrc.fft.rdft(n1b3, -1, buf1[ch5], fft_ip, fft_w);
int i24 = 0;
while (i24 < n1b23) {
double[] dArr = buf2[ch5];
int i25 = ds + 1 + i24;
dArr[i25] = dArr[i25] + buf1[ch5][i24];
i24++;
}
int t1 = rp22 / (fs24 / n15);
if (rp22 % (fs24 / n15) != 0) {
t1++;
}
int i26 = i24;
char c = 0;
int i27 = (buf2[0].length * ch5) + t1;
s2p = n1b24;
int p = 0;
while (true) {
int k4 = k3;
if (i27 - (buf2[c].length * ch5) < n1b23 + 1) {
double tmp = FirebaseRemoteConfig.DEFAULT_VALUE_FOR_DOUBLE;
int bp2 = i27;
int s2o = f2order[s2p];
int bp = i27 + f2inc[s2p];
int bp3 = s2p + 1;
int rps_backup = n2y6;
int rps_backup2 = n2y5;
if (bp3 != rps_backup2) {
s2p = bp3;
} else {
s2p = 0;
}
int i28 = 0;
while (i28 < ds) {
tmp += stage2[s2o][i28] * buf2[bp2 / buf2[0].length][bp2 % buf2[0].length];
bp2++;
i28++;
n1b23 = n1b23;
n1b3 = n1b3;
}
outbuf[0 + (p * n1b22) + ch5] = tmp;
p++;
i26 = i28;
n2y5 = rps_backup2;
k3 = k4;
n2y6 = rps_backup;
n1b23 = n1b23;
c = 0;
i27 = bp;
}
}
int n1b9 = n1b3;
int rps_backup3 = n2y6;
nsmplwrt24 = p;
ch5++;
ssrc = this;
i2 = i26;
n2y6 = rps_backup3;
rawinbuf5 = rawinbuf7;
chanklen4 = chanklen8;
n1b8 = n1b9;
}
int i29 = i2;
ByteBuffer rawinbuf8 = rawinbuf5;
int chanklen9 = chanklen4;
int n2y7 = n2y5;
int n1b10 = n1b8;
int n1b11 = n1b23;
int chanklen10 = dfrq;
int rp23 = rp22 + ((fs24 / chanklen10) * nsmplwrt24);
rawoutbuf4.clear();
if (twopass) {
int i30 = 0;
while (i30 < nsmplwrt24 * n1b22) {
double f = outbuf[i30] > FirebaseRemoteConfig.DEFAULT_VALUE_FOR_DOUBLE ? outbuf[i30] : -outbuf[i30];
peak[0] = peak[0] < f ? f : peak[0];
rawoutbuf4.asDoubleBuffer().put(i30, outbuf[i30]);
i30++;
}
n2y2 = n2y7;
rp = rps4;
rps = rps3;
rawoutbuf = rawoutbuf4;
s2p_backup = n1b11;
rawinbuf = rawinbuf8;
n1b8 = n1b10;
ssrc2 = this;
rp2 = chanklen10;
i4 = i30;
toberead = chanklen9;
inbuf = inbuf4;
} else if (dbps != 1) {
if (dbps != 2) {
if (dbps != 3) {
n2y2 = n2y7;
rp = rps4;
rps = rps3;
rawoutbuf = rawoutbuf4;
s2p_backup = n1b11;
rawinbuf = rawinbuf8;
n1b8 = n1b10;
ssrc2 = this;
rp2 = chanklen10;
i4 = i29;
toberead = chanklen9;
inbuf = inbuf4;
} else {
double gain2 = gain * 8388607.0d;
int i31 = 0;
int ch6 = 0;
while (i31 < ch) {
if (dither != 0) {
double d5 = outbuf[i31] * gain2;
rawinbuf2 = rawinbuf8;
s2p_backup2 = n1b24;
s2p_backup3 = n1b11;
rp3 = rps4;
rps2 = rps3;
n1b = n1b10;
rp4 = chanklen10;
double[] dArr2 = inbuf4;
toberead2 = toberead4;
toberead3 = chanklen9;
inbuf2 = dArr2;
i7 = i31;
n2y3 = n2y7;
rawoutbuf2 = rawoutbuf4;
int i32 = ch6;
s3 = do_shaping(d5, peak, dither, i32);
} else {
i7 = i31;
n2y3 = n2y7;
s2p_backup2 = n1b24;
rp3 = rps4;
rps2 = rps3;
rawoutbuf2 = rawoutbuf4;
s2p_backup3 = n1b11;
rawinbuf2 = rawinbuf8;
n1b = n1b10;
rp4 = chanklen10;
double[] dArr3 = inbuf4;
toberead2 = toberead4;
toberead3 = chanklen9;
inbuf2 = dArr3;
s3 = RINT(outbuf[i7] * gain2);
if (s3 < -8388608) {
double d6 = s3 / (-8388608.0d);
peak[0] = peak[0] < d6 ? d6 : peak[0];
s3 = -8388608;
}
if (8388607 < s3) {
double d7 = s3 / 8388607.0d;
peak[0] = peak[0] < d7 ? d7 : peak[0];
s3 = 8388607;
}
}
rawoutbuf2.put(i7 * 3, (byte) (s3 & 255));
int s4 = s3 >> 8;
rawoutbuf2.put((i7 * 3) + 1, (byte) (s4 & 255));
rawoutbuf2.put((i7 * 3) + 2, (byte) ((s4 >> 8) & 255));
int ch7 = ch6 + 1;
if (ch7 == n1b22) {
ch7 = 0;
}
ch6 = ch7;
i31 = i7 + 1;
chanklen10 = rp4;
rawoutbuf4 = rawoutbuf2;
rps3 = rps2;
rps4 = rp3;
rawinbuf8 = rawinbuf2;
n1b10 = n1b;
n2y7 = n2y3;
n1b11 = s2p_backup3;
n1b24 = s2p_backup2;
double[] dArr4 = inbuf2;
chanklen9 = toberead3;
toberead4 = toberead2;
inbuf4 = dArr4;
}
n2y2 = n2y7;
rp = rps4;
rps = rps3;
rawoutbuf = rawoutbuf4;
s2p_backup = n1b11;
rawinbuf = rawinbuf8;
n1b8 = n1b10;
ssrc2 = this;
rp2 = chanklen10;
toberead = chanklen9;
inbuf = inbuf4;
i4 = i31;
ch5 = ch6;
}
} else {
n2y2 = n2y7;
rp = rps4;
rps = rps3;
rawoutbuf = rawoutbuf4;
s2p_backup = n1b11;
rawinbuf = rawinbuf8;
n1b8 = n1b10;
ssrc2 = this;
rp2 = chanklen10;
toberead = chanklen9;
inbuf = inbuf4;
double gain22 = gain * 32767.0d;
int ch8 = 0;
int i33 = 0;
while (i33 < ch) {
if (dither != 0) {
i6 = i33;
int i34 = ch8;
s2 = do_shaping(outbuf[i33] * gain22, peak, dither, i34);
j2 = 4674736138332667904L;
} else {
i6 = i33;
s2 = ssrc2.RINT(outbuf[i6] * gain22);
if (s2 < -32768) {
double d8 = s2 / (-32768.0d);
peak[0] = peak[0] < d8 ? d8 : peak[0];
s2 = -32768;
}
if (32767 >= s2) {
j2 = 4674736138332667904L;
} else {
j2 = 4674736138332667904L;
double d9 = s2 / 32767.0d;
peak[0] = peak[0] < d9 ? d9 : peak[0];
s2 = 32767;
}
}
rawoutbuf.order(ssrc2.byteOrder).asShortBuffer().put(i6, (short) s2);
int ch9 = ch8 + 1;
if (ch9 == n1b22) {
ch9 = 0;
}
ch8 = ch9;
i33 = i6 + 1;
}
i4 = i33;
ch5 = ch8;
}
} else {
n2y2 = n2y7;
rp = rps4;
rps = rps3;
rawoutbuf = rawoutbuf4;
s2p_backup = n1b11;
rawinbuf = rawinbuf8;
n1b8 = n1b10;
ssrc2 = this;
rp2 = chanklen10;
toberead = chanklen9;
inbuf = inbuf4;
double gain23 = gain * 127.0d;
int ch10 = 0;
int i35 = 0;
while (i35 < ch) {
if (dither != 0) {
i5 = i35;
int i36 = ch10;
s = do_shaping(outbuf[i35] * gain23, peak, dither, i36);
j = 4638637247447433216L;
} else {
i5 = i35;
s = ssrc2.RINT(outbuf[i5] * gain23);
if (s < -128) {
double d10 = s / (-128.0d);
peak[0] = peak[0] < d10 ? d10 : peak[0];
s = -128;
}
if (127 >= s) {
j = 4638637247447433216L;
} else {
j = 4638637247447433216L;
double d11 = s / 127.0d;
peak[0] = peak[0] < d11 ? d11 : peak[0];
s = 127;
}
}
rawoutbuf.put(i5, (byte) (s + 128));
int ch11 = ch10 + 1;
if (ch11 == n1b22) {
ch11 = 0;
}
ch10 = ch11;
i35 = i5 + 1;
}
i4 = i35;
ch5 = ch10;
}
if (!init) {
if (ending) {
i8 = i4;
n13 = i3;
if (((sumread5 * rp2) / sfrq) + 2.0d > sumwrite + nsmplwrt24) {
rawoutbuf.position(0);
rawoutbuf.limit(dbps * n1b22 * nsmplwrt24);
ssrc2.writeBuffers(fpo, rawoutbuf);
int i37 = sumwrite + nsmplwrt24;
sumread = sumread5;
n2x = ds;
sumread2 = n1b22;
chanklen5 = toberead;
nsmplwrt2 = nsmplwrt24;
ch = delay;
nsmplwrt22 = s2p_backup;
sumwrite2 = i37;
} else {
rawoutbuf.position(0);
int limitData = (int) (dbps * n1b22 * ((Math.floor((sumread5 * rp2) / sfrq) + 2.0d) - sumwrite));
if (limitData > 0) {
rawoutbuf.limit(limitData);
ssrc2.writeBuffers(fpo, rawoutbuf);
}
}
} else {
i8 = i4;
sumread = sumread5;
chanklen5 = toberead;
nsmplwrt2 = nsmplwrt24;
n13 = i3;
int chanklen11 = sumwrite;
nsmplwrt22 = s2p_backup;
rawoutbuf.position(0);
rawoutbuf.limit(dbps * nch * nsmplwrt2);
ssrc2.writeBuffers(fpo, rawoutbuf);
sumwrite2 = chanklen11 + nsmplwrt2;
sumread2 = nch;
n2x = ds;
ch = delay;
}
ds2 = (rp23 - 1) / (fs24 / n15);
n1b2 = nsmplwrt22;
if (ds2 > n1b2) {
ds2 = n1b2;
}
ch2 = 0;
while (ch2 < sumread2) {
System.arraycopy(buf2[ch2], ds2, buf2[ch2], 0, ((n2x + 1) + n1b2) - ds2);
ch2++;
nsmplwrt2 = nsmplwrt2;
}
int nsmplwrt25 = nsmplwrt2;
int nsmplwrt26 = fs24 / n15;
rp22 = rp23 - (nsmplwrt26 * ds2);
for (ch3 = 0; ch3 < sumread2; ch3++) {
System.arraycopy(buf1[ch3], n1b2, buf2[ch3], n2x + 1, n1b2);
}
int spcount2 = spcount + 1;
if ((spcount & 7) == 7) {
sumread3 = sumread;
ch4 = chanklen5;
} else {
sumread3 = sumread;
ch4 = chanklen5;
ssrc2.showprogress(sumread3 / ch4);
}
spcount = spcount2;
delay4 = ch;
n1b23 = n1b2;
rawoutbuf4 = rawoutbuf;
n17 = n13;
nsmplwrt23 = nsmplwrt25;
ds = n2x;
rp5 = rp;
rawinbuf4 = rawinbuf;
inbuf4 = inbuf;
n2y5 = n2y2;
n16 = bps;
delay3 = sumread3;
n1b22 = sumread2;
n22 = n24;
sumread4 = i8;
} else {
i8 = i4;
sumread = sumread5;
int i38 = n1b22;
chanklen5 = toberead;
nsmplwrt2 = nsmplwrt24;
n13 = i3;
int chanklen12 = sumwrite;
nsmplwrt22 = s2p_backup;
ch = delay;
if (nsmplwrt2 < ch) {
ch -= nsmplwrt2;
sumread2 = i38;
n2x = ds;
sumwrite2 = chanklen12;
} else if (ending) {
if (((sumread * rp2) / sfrq) + 2.0d > (chanklen12 + nsmplwrt2) - ch) {
rawoutbuf.position(dbps * nch * ch);
rawoutbuf.limit(dbps * nch * (nsmplwrt2 - ch));
ssrc2.writeBuffers(fpo, rawoutbuf);
sumwrite2 = chanklen12 + (nsmplwrt2 - ch);
sumread = sumread;
n2x = ds;
sumread2 = nch;
} else {
rawoutbuf.position(dbps * nch * ch);
rawoutbuf.limit((int) (dbps * nch * ((((Math.floor((sumread * rp2) / sfrq) + 2.0d) + chanklen12) + nsmplwrt2) - ch)));
ssrc2.writeBuffers(fpo, rawoutbuf);
break;
}
} else {
n2x = ds;
sumread2 = nch;
rawoutbuf.position(dbps * sumread2 * ch);
rawoutbuf.limit(dbps * sumread2 * nsmplwrt2);
ssrc2.writeBuffers(fpo, rawoutbuf);
sumwrite2 = chanklen12 + (nsmplwrt2 - ch);
init = false;
}
ds2 = (rp23 - 1) / (fs24 / n15);
n1b2 = nsmplwrt22;
if (ds2 > n1b2) {
}
ch2 = 0;
while (ch2 < sumread2) {
}
int nsmplwrt252 = nsmplwrt2;
int nsmplwrt262 = fs24 / n15;
rp22 = rp23 - (nsmplwrt262 * ds2);
while (ch3 < sumread2) {
}
int spcount22 = spcount + 1;
if ((spcount & 7) == 7) {
}
spcount = spcount22;
delay4 = ch;
n1b23 = n1b2;
rawoutbuf4 = rawoutbuf;
n17 = n13;
nsmplwrt23 = nsmplwrt252;
ds = n2x;
rp5 = rp;
rawinbuf4 = rawinbuf;
inbuf4 = inbuf;
n2y5 = n2y2;
n16 = bps;
delay3 = sumread3;
n1b22 = sumread2;
n22 = n24;
sumread4 = i8;
}
}
ssrc2.showprogress(1.0d);
return peak[0];
}
public double no_src(InputStream fpi, OutputStream fpo, int nch, int bps, int dbps, double gain, int chanklen, boolean twopass, int dither) throws IOException {
ByteBuffer leos;
ByteBuffer buf;
int sumread;
ByteBuffer leos2;
int s;
InputStream inputStream = fpi;
int i = 1;
int i2 = 0;
double[] peak = {FirebaseRemoteConfig.DEFAULT_VALUE_FOR_DOUBLE};
setstarttime();
if (!twopass) {
leos = null;
} else {
ByteBuffer leos3 = ByteBuffer.allocate(8);
leos = leos3;
}
int i3 = 4;
ByteBuffer buf2 = ByteBuffer.allocate(4);
int ch = 0;
int sumread2 = 0;
while (sumread2 < ch) {
double f = FirebaseRemoteConfig.DEFAULT_VALUE_FOR_DOUBLE;
if (bps == i) {
buf2.position(0);
buf2.limit(1);
byte[] tempData = new byte[buf2.limit()];
inputStream.read(tempData);
ByteBuffer buf3 = ByteBuffer.wrap(tempData);
buf3.position(buf3.limit());
buf3.flip();
double f2 = 0.007874015748031496d * (buf3.get(0) + ByteCompanionObject.MIN_VALUE);
buf = buf3;
f = f2;
} else if (bps != 2) {
if (bps == 3) {
buf2.position(i2);
buf2.limit(3);
byte[] tempData2 = new byte[buf2.limit()];
inputStream.read(tempData2);
ByteBuffer buf4 = ByteBuffer.wrap(tempData2);
buf4.position(buf4.limit());
buf4.flip();
f = (((buf4.get(1) & UByte.MAX_VALUE) << 8) | ((buf4.get(i2) & UByte.MAX_VALUE) << i2) | ((buf4.get(2) & UByte.MAX_VALUE) << 16)) * 1.1920930376163766E-7d;
buf = buf4;
} else if (bps != i3) {
buf = buf2;
} else {
buf2.position(i2);
buf2.limit(i3);
byte[] tempData3 = new byte[buf2.limit()];
inputStream.read(tempData3);
ByteBuffer buf5 = ByteBuffer.wrap(tempData3);
buf5.position(buf5.limit());
buf5.flip();
int s2 = buf5.order(this.byteOrder).asIntBuffer().get(i2);
f = s2 * 4.656612875245797E-10d;
buf = buf5;
}
} else {
buf2.position(0);
buf2.limit(2);
byte[] tempData4 = new byte[buf2.limit()];
inputStream.read(tempData4);
ByteBuffer buf6 = ByteBuffer.wrap(tempData4);
buf6.position(buf6.limit());
buf6.flip();
int s3 = buf6.order(this.byteOrder).asShortBuffer().get(0);
double f3 = s3;
f = f3 * 3.051850947599719E-5d;
buf = buf6;
}
if (fpi.available() == 0) {
break;
}
double f4 = f * gain;
if (!twopass) {
if (dbps == 1) {
sumread = sumread2;
leos2 = leos;
double f5 = f4 * 127.0d;
int s4 = dither != 0 ? do_shaping(f5, peak, dither, ch) : RINT(f5);
buf.position(0);
buf.limit(1);
buf.put(0, (byte) (s4 + 128));
buf.flip();
writeBuffers(fpo, buf);
} else if (dbps == 2) {
sumread = sumread2;
leos2 = leos;
double f6 = f4 * 32767.0d;
int s5 = dither != 0 ? do_shaping(f6, peak, dither, ch) : RINT(f6);
buf.position(0);
buf.limit(2);
buf.asShortBuffer().put(0, (short) s5);
buf.flip();
writeBuffers(fpo, buf);
} else if (dbps != 3) {
sumread = sumread2;
leos2 = leos;
} else {
double f7 = 8388607.0d * f4;
if (dither != 0) {
sumread = sumread2;
leos2 = leos;
s = do_shaping(f7, peak, dither, ch);
} else {
sumread = sumread2;
leos2 = leos;
s = RINT(f7);
}
buf.position(0);
buf.limit(3);
buf.put(0, (byte) (s & 255));
int s6 = s >> 8;
buf.put(1, (byte) (s6 & 255));
buf.put(2, (byte) ((s6 >> 8) & 255));
buf.flip();
writeBuffers(fpo, buf);
}
} else {
sumread = sumread2;
leos2 = leos;
double p = f4 > FirebaseRemoteConfig.DEFAULT_VALUE_FOR_DOUBLE ? f4 : -f4;
peak[0] = peak[0] < p ? p : peak[0];
leos2.position(0);
leos2.putDouble(f4);
leos2.flip();
writeBuffers(fpo, leos2);
}
int ch2 = ch + 1;
if (ch2 != nch) {
ch = ch2;
} else {
ch = 0;
}
int ch3 = sumread + 1;
if ((262143 & ch3) == 0) {
showprogress(ch3 / (chanklen * nch));
}
sumread2 = ch3;
leos = leos2;
buf2 = buf;
i3 = 4;
i = 1;
i2 = 0;
inputStream = fpi;
}
showprogress(1.0d);
return peak[0];
}
public static void main(String[] args) throws Exception {
new SSRC(args);
}
public SSRC() {
this.byteOrder = ByteOrder.LITTLE_ENDIAN;
this.fft = new SplitRadixFft();
this.AA = 170.0d;
this.DF = 100.0d;
this.FFTFIRLEN = 65536;
this.quiet = false;
}
SSRC(String[] argv) throws IOException {
int i;
int i2;
String tmpfn;
int nch;
int length;
String dfn;
double att;
int dbps;
int dfrq;
int dither;
int bps;
int dbps2;
int nch2;
FileInputStream fpi;
String dfn2;
FileOutputStream fpo;
String str;
int dbps3;
double att2;
int sfrq;
SSRC ssrc;
int samp2;
int i3;
String str2;
double d;
FileOutputStream fpo2;
int length2;
int dbps4;
SSRC ssrc2;
File ft;
String tmpfn2;
File ft2;
int samp3;
FileOutputStream fpo3;
int dbps5;
String str3;
int length3;
int dfrq2;
int sfrq2;
int nch3;
int nch4;
int length4;
double att3;
int i4;
double att4;
int samp4;
int dbps6;
int sumread;
ByteBuffer leis;
FileChannel fpti;
File ft3;
int samp5;
double att5;
FileOutputStream fpo4;
int s;
double f;
int s2;
double d2;
double d3;
double d4;
double d5;
double d6;
double d7;
int max;
int dbps7;
FileInputStream fpi2;
SSRC ssrc3 = this;
ssrc3.byteOrder = ByteOrder.LITTLE_ENDIAN;
ssrc3.fft = new SplitRadixFft();
ssrc3.AA = 170.0d;
ssrc3.DF = 100.0d;
ssrc3.FFTFIRLEN = 65536;
ssrc3.quiet = false;
FileInputStream fpi3 = null;
double[] peak = {FirebaseRemoteConfig.DEFAULT_VALUE_FOR_DOUBLE};
int dfrq3 = -1;
int i5 = 0;
double noiseamp = 0.18d;
int pdf = 0;
int pdf2 = 0;
String tmpfn3 = null;
int dbps8 = -1;
int dither2 = 0;
boolean twopass = false;
double att6 = 0.0d;
for (int i6 = 0; i5 < argv.length && argv[i5].charAt(i6) == '-'; i6 = 0) {
if (argv[i5].equals("--rate")) {
i5++;
int dfrq4 = Integer.parseInt(argv[i5]);
dfrq3 = dfrq4;
fpi2 = fpi3;
} else if (argv[i5].equals("--att")) {
i5++;
att6 = Float.parseFloat(argv[i5]);
fpi2 = fpi3;
} else if (argv[i5].equals("--bits")) {
i5++;
int dbps9 = Integer.parseInt(argv[i5]);
if (dbps9 != 8 && dbps9 != 16 && dbps9 != 24) {
throw new IllegalArgumentException("Error: Only 8bit, 16bit and 24bit PCM are supported.");
}
dbps8 = dbps9 / 8;
fpi2 = fpi3;
} else if (argv[i5].equals("--twopass")) {
twopass = true;
fpi2 = fpi3;
} else if (argv[i5].equals("--normalize")) {
twopass = true;
fpi2 = fpi3;
pdf2 = 1;
} else if (argv[i5].equals("--dither")) {
try {
dither2 = Integer.parseInt(argv[i5 + 1]);
if (dither2 < 0 || dither2 > 4) {
throw new IllegalArgumentException("unrecognized dither type : " + argv[i5 + 1]);
break;
}
i5++;
fpi2 = fpi3;
} catch (NumberFormatException e) {
dither2 = -1;
fpi2 = fpi3;
}
} else if (argv[i5].equals("--pdf")) {
try {
int pdf3 = Integer.parseInt(argv[i5 + 1]);
if (pdf3 < 0 || pdf3 > 2) {
try {
StringBuilder sb = new StringBuilder();
sb.append("unrecognized p.d.f. type : ");
try {
sb.append(argv[i5 + 1]);
throw new IllegalArgumentException(sb.toString());
} catch (NumberFormatException e2) {
throw new IllegalArgumentException("unrecognized p.d.f. type : " + argv[i5 + 1]);
}
} catch (NumberFormatException e3) {
}
} else {
i5++;
try {
double noiseamp2 = Double.parseDouble(argv[i5 + 1]);
i5++;
fpi2 = fpi3;
noiseamp = noiseamp2;
pdf = pdf3;
} catch (NumberFormatException e4) {
double noiseamp3 = presets[pdf3];
fpi2 = fpi3;
noiseamp = noiseamp3;
pdf = pdf3;
}
}
} catch (NumberFormatException e5) {
}
} else {
fpi2 = fpi3;
if (argv[i5].equals("--quiet")) {
ssrc3.quiet = true;
} else if (argv[i5].equals("--tmpfile")) {
i5++;
String tmpfn4 = argv[i5];
tmpfn3 = tmpfn4;
} else {
String tmpfn5 = argv[i5];
if (tmpfn5.equals("--profile")) {
if (argv[i5 + 1].equals("fast")) {
ssrc3.AA = 96.0d;
ssrc3.DF = 8000.0d;
ssrc3.FFTFIRLEN = 1024;
} else if (!argv[i5 + 1].equals("standard")) {
throw new IllegalArgumentException("unrecognized profile : " + argv[i5 + 1]);
}
i5++;
} else {
throw new IllegalArgumentException("unrecognized option : " + argv[i5]);
}
}
}
i5++;
fpi3 = fpi2;
}
if (!ssrc3.quiet) {
System.err.printf("Shibatch sampling rate converter version 1.30(high precision/nio)\n\n", new Object[0]);
}
if (argv.length - i5 != 2) {
usage();
throw new IllegalStateException("too few arguments");
}
String sfn = argv[i5];
String dfn3 = argv[i5 + 1];
try {
FileInputStream fpi4 = new FileInputStream(sfn);
ByteBuffer bb = ByteBuffer.allocate(256).order(ByteOrder.LITTLE_ENDIAN);
bb.limit(36);
fpi4.getChannel().read(bb);
bb.flip();
System.err.println("p: " + bb.position() + ", l: " + bb.limit());
if (bb.get() == 82) {
i = 1;
} else {
i = 1;
ssrc3.fmterr(1);
}
if (bb.get() != 73) {
ssrc3.fmterr(i);
}
if (bb.get() != 70) {
ssrc3.fmterr(i);
}
if (bb.get() != 70) {
ssrc3.fmterr(i);
}
bb.getInt();
if (bb.get() != 87) {
ssrc3.fmterr(2);
}
if (bb.get() != 65) {
ssrc3.fmterr(2);
}
if (bb.get() != 86) {
ssrc3.fmterr(2);
}
if (bb.get() != 69) {
ssrc3.fmterr(2);
}
if (bb.get() != 102) {
ssrc3.fmterr(2);
}
if (bb.get() != 109) {
ssrc3.fmterr(2);
}
if (bb.get() != 116) {
ssrc3.fmterr(2);
}
if (bb.get() != 32) {
ssrc3.fmterr(2);
}
int sizeOfFmt = bb.getInt();
if (bb.getShort() != 1) {
throw new IllegalStateException("Error: Only PCM is supported.");
}
int i7 = bb.getShort();
int sfrq3 = bb.getInt();
int bps2 = bb.getInt();
if ((bps2 % sfrq3) * i7 == 0) {
i2 = i5;
} else {
i2 = i5;
ssrc3.fmterr(4);
}
bb.getShort();
bb.getShort();
int length5 = bps2 / (sfrq3 * i7);
if (sizeOfFmt > 16) {
bb.position(0);
bb.limit(2);
fpi4.read(ssrc3.getDataFromByteBuffer(bb));
bb.flip();
int sizeofExtended = bb.getShort();
tmpfn = tmpfn3;
nch = i7;
fpi4.getChannel().position(fpi4.getChannel().position() + sizeofExtended);
} else {
tmpfn = tmpfn3;
nch = i7;
}
while (true) {
bb.position(0);
bb.limit(8);
fpi4.getChannel().read(bb);
bb.flip();
int c0 = bb.get();
int c1 = bb.get();
int c2 = bb.get();
int c3 = bb.get();
length = bb.getInt();
ByteBuffer bb2 = bb;
dfn = dfn3;
att = att6;
System.err.printf("chunk: %c%c%c%c\n", Integer.valueOf(c0), Integer.valueOf(c1), Integer.valueOf(c2), Integer.valueOf(c3));
if (c0 == 100 && c1 == 97) {
if (c2 == 116 && c3 == 97) {
break;
}
}
if (fpi4.getChannel().position() == fpi4.getChannel().size()) {
break;
}
FileInputStream fpi5 = fpi4;
fpi5.getChannel().position(fpi5.getChannel().position() + length);
dfn3 = dfn;
nch = nch;
i2 = i2;
att6 = att;
length5 = length5;
bb = bb2;
sfrq3 = sfrq3;
ssrc3 = ssrc3;
fpi4 = fpi5;
}
if (fpi4.getChannel().position() == fpi4.getChannel().size()) {
throw new IllegalStateException("Couldn't find data chank");
}
if (length5 != 1 && length5 != 2 && length5 != 3 && length5 != 4) {
throw new IllegalStateException("Error : Only 8bit, 16bit, 24bit and 32bit PCM are supported.");
}
if (dbps8 != -1) {
dbps = dbps8;
} else {
if (length5 != 1) {
dbps7 = length5;
} else {
dbps7 = 2;
}
if (dbps7 != 4) {
dbps = dbps7;
} else {
dbps = 3;
}
}
if (dfrq3 != -1) {
dfrq = dfrq3;
} else {
int dfrq5 = sfrq3;
dfrq = dfrq5;
}
if (dither2 != -1) {
dither = dither2;
} else if (dbps < length5) {
if (dbps == 1) {
dither = 4;
} else {
dither = 3;
}
} else {
dither = 1;
}
if (ssrc3.quiet) {
bps = length5;
dbps2 = dbps;
nch2 = nch;
} else {
String[] dtype = {SchedulerSupport.NONE, "no noise shaping", "triangular spectral shape", "ATH based noise shaping", "ATH based noise shaping(less amplitude)"};
String[] ptype = {"rectangular", "triangular", "gaussian"};
System.err.printf("frequency : %d -> %d\n", Integer.valueOf(sfrq3), Integer.valueOf(dfrq));
System.err.printf("attenuation : %gdB\n", Double.valueOf(att));
System.err.printf("bits per sample : %d -> %d\n", Integer.valueOf(length5 * 8), Integer.valueOf(dbps * 8));
System.err.printf("nchannels : %d\n", Integer.valueOf(nch));
dbps2 = dbps;
double d8 = length / length5;
bps = length5;
nch2 = nch;
System.err.printf("length : %d bytes, %g secs\n", Integer.valueOf(length), Double.valueOf((d8 / nch2) / sfrq3));
if (dither == 0) {
System.err.printf("dither type : none\n", new Object[0]);
} else {
System.err.printf("dither type : %s, %s p.d.f, amp = %g\n", dtype[dither], ptype[pdf], Double.valueOf(noiseamp));
}
System.err.printf("\n", new Object[0]);
}
try {
try {
try {
FileOutputStream fpo5 = new FileOutputStream(new File(dfn));
ByteBuffer leos = ByteBuffer.allocate(44).order(ByteOrder.LITTLE_ENDIAN);
leos.put("RIFF".getBytes());
leos.putInt(0);
leos.put("WAVEfmt ".getBytes());
leos.putInt(16);
leos.putShort((short) 1);
short word = (short) nch2;
leos.putShort(word);
int dword = dfrq;
leos.putInt(dword);
int dword2 = dfrq * nch2 * dbps2;
leos.putInt(dword2);
short word2 = (short) (dbps2 * nch2);
leos.putShort(word2);
short word3 = (short) (dbps2 * 8);
leos.putShort(word3);
leos.put("data".getBytes());
leos.putInt(0);
leos.flip();
writeBuffers(fpo5, leos);
if (dither == 0) {
fpi = fpi4;
dfn2 = dfn;
fpo = fpo5;
str = "\n";
dbps3 = dbps2;
att2 = att;
sfrq = sfrq3;
ssrc = this;
samp2 = 0;
} else {
int min = 0;
int max2 = 0;
int dbps10 = dbps2;
if (dbps10 == 1) {
min = -128;
max2 = 127;
}
if (dbps10 == 2) {
min = -32768;
max2 = 32767;
}
if (dbps10 == 3) {
min = -8388608;
max2 = 8388607;
}
fpo = fpo5;
if (dbps10 != 4) {
max = max2;
} else {
min = Integer.MIN_VALUE;
max = Integer.MAX_VALUE;
}
fpi = fpi4;
sfrq = sfrq3;
dfn2 = dfn;
dbps3 = dbps10;
str = "\n";
att2 = att;
ssrc = this;
samp2 = init_shaper(dfrq, nch2, min, max, dither, pdf, noiseamp);
}
if (twopass) {
double gain = FirebaseRemoteConfig.DEFAULT_VALUE_FOR_DOUBLE;
int ch = 0;
if (!ssrc.quiet) {
System.err.printf("Pass 1\n", new Object[0]);
}
if (tmpfn != null) {
try {
tmpfn2 = tmpfn;
try {
ft = new File(tmpfn2);
} catch (IOException e6) {
throw new IllegalStateException("cannot open temporary file.");
}
} catch (IOException e7) {
}
} else {
tmpfn2 = tmpfn;
try {
ft = File.createTempFile("ssrc_", ".tmp");
} catch (IOException e8) {
throw new IllegalStateException("cannot open temporary file.");
}
}
try {
FileOutputStream fpto = new FileOutputStream(ft);
if (pdf2 != 0) {
if (sfrq < dfrq) {
int dfrq6 = (length / bps) / nch2;
ft2 = ft;
samp3 = samp2;
fpo3 = fpo;
str3 = str;
i3 = 4;
length3 = 8;
int dfrq7 = dfrq;
int dfrq8 = dither;
peak[0] = upsample(fpi, fpto, nch2, bps, 8, sfrq, dfrq, 1.0d, dfrq6, twopass, dfrq8);
sfrq2 = sfrq;
nch3 = nch2;
dfrq2 = dfrq7;
dbps5 = dbps3;
length4 = length;
att3 = att2;
nch4 = 0;
} else {
ft2 = ft;
samp3 = samp2;
int dfrq9 = dfrq;
int nch5 = nch2;
int bps3 = bps;
fpo3 = fpo;
str3 = str;
i3 = 4;
length3 = 8;
int bps4 = sfrq;
if (bps4 > dfrq9) {
dbps5 = dbps3;
peak[0] = downsample(fpi, fpto, nch5, bps3, 8, bps4, dfrq9, 1.0d, (length / bps3) / nch5, twopass, dither);
nch3 = nch5;
att3 = att2;
length4 = length;
dfrq2 = dfrq9;
sfrq2 = bps4;
nch4 = 0;
} else {
dbps5 = dbps3;
int length6 = dither;
peak[0] = no_src(fpi, fpto, nch5, bps3, 8, 1.0d, (length / bps3) / nch5, twopass, length6);
nch3 = nch5;
att3 = att2;
dfrq2 = dfrq9;
sfrq2 = bps4;
length4 = length;
nch4 = 0;
}
}
} else {
ft2 = ft;
samp3 = samp2;
int sfrq4 = sfrq;
int dfrq10 = dfrq;
int nch6 = nch2;
int bps5 = bps;
fpo3 = fpo;
dbps5 = dbps3;
str3 = str;
i3 = 4;
length3 = 8;
if (sfrq4 < dfrq10) {
double att7 = att2;
peak[0] = upsample(fpi, fpto, nch6, bps5, 8, sfrq4, dfrq10, Math.pow(10.0d, (-att7) / 20.0d), (length / bps5) / nch6, twopass, dither);
att3 = att7;
fpto = fpto;
length4 = length;
dfrq2 = dfrq10;
sfrq2 = sfrq4;
nch3 = nch6;
nch4 = 0;
} else {
double att8 = att2;
if (sfrq4 > dfrq10) {
double pow = Math.pow(10.0d, (-att8) / 20.0d);
int i8 = (length / bps5) / nch6;
fpto = fpto;
nch3 = nch6;
dfrq2 = dfrq10;
sfrq2 = sfrq4;
nch4 = 0;
peak[0] = downsample(fpi, fpto, nch6, bps5, 8, sfrq4, dfrq10, pow, i8, twopass, dither);
att3 = att8;
length4 = length;
} else {
dfrq2 = dfrq10;
sfrq2 = sfrq4;
fpto = fpto;
nch3 = nch6;
nch4 = 0;
length4 = length;
att3 = att8;
peak[0] = no_src(fpi, fpto, nch3, bps5, 8, Math.pow(10.0d, (-att8) / 20.0d), (length / bps5) / nch3, twopass, dither);
}
}
}
fpto.close();
if (this.quiet) {
i4 = 1;
} else {
PrintStream printStream = System.err;
i4 = 1;
Object[] objArr = new Object[1];
objArr[nch4] = Double.valueOf(Math.log10(peak[nch4]) * 20.0d);
printStream.printf("\npeak : %gdB\n", objArr);
}
if (pdf2 == 0) {
att4 = att3;
if (peak[nch4] < Math.pow(10.0d, (-att4) / 20.0d)) {
peak[nch4] = 1.0d;
} else {
peak[nch4] = peak[nch4] * Math.pow(10.0d, att4 / 20.0d);
}
} else {
att4 = att3;
peak[nch4] = peak[nch4] * Math.pow(10.0d, att4 / 20.0d);
}
if (!this.quiet) {
System.err.printf("\nPass 2\n", new Object[nch4]);
}
if (dither != 0) {
dbps6 = dbps5;
if (dbps6 == i4) {
samp4 = samp3;
if (pdf2 != 0) {
d2 = 1.0d;
} else if (peak[nch4] >= (127 - samp4) / 127.0d) {
d2 = 1.0d;
} else {
d3 = (1.0d / peak[nch4]) * 127.0d;
gain = d3;
}
d3 = (d2 / peak[nch4]) * (127 - samp4);
gain = d3;
} else if (dbps6 == 2) {
samp4 = samp3;
if (pdf2 != 0) {
d4 = 1.0d;
} else if (peak[nch4] >= (32767 - samp4) / 32767.0d) {
d4 = 1.0d;
} else {
d5 = (1.0d / peak[nch4]) * 32767.0d;
gain = d5;
}
d5 = (d4 / peak[nch4]) * (32767 - samp4);
gain = d5;
} else if (dbps6 != 3) {
samp4 = samp3;
} else {
if (pdf2 == 0) {
samp4 = samp3;
if (peak[nch4] >= (8388607 - samp4) / 8388607.0d) {
d6 = 1.0d;
} else {
d7 = (1.0d / peak[nch4]) * 8388607.0d;
gain = d7;
}
} else {
samp4 = samp3;
d6 = 1.0d;
}
d7 = (d6 / peak[nch4]) * (8388607 - samp4);
gain = d7;
}
} else {
samp4 = samp3;
dbps6 = dbps5;
if (dbps6 == i4) {
gain = (1.0d / peak[nch4]) * 127.0d;
} else if (dbps6 == 2) {
gain = (1.0d / peak[nch4]) * 32767.0d;
} else if (dbps6 == 3) {
gain = (1.0d / peak[nch4]) * 8388607.0d;
}
}
this.randptr = nch4;
setstarttime();
int fptlen = (int) (ft2.length() / 8);
File ft4 = ft2;
FileChannel fpti2 = new FileInputStream(ft4).getChannel();
ByteBuffer leis2 = ByteBuffer.allocate(length3);
int sumread2 = 0;
while (sumread2 < fptlen) {
leis2.clear();
fpti2.read(leis2);
leis2.flip();
double f2 = leis2.getDouble() * gain;
int sumread3 = sumread2 + 1;
if (dbps6 == i4) {
sumread = sumread3;
leis = leis2;
fpti = fpti2;
ft3 = ft4;
samp5 = samp4;
att5 = att4;
fpo4 = fpo3;
int s3 = dither != 0 ? do_shaping(f2, peak, dither, ch) : RINT(f2);
ByteBuffer buf = ByteBuffer.allocate(1);
buf.put((byte) (s3 + 128));
buf.flip();
writeBuffers(fpo4, buf);
} else if (dbps6 == 2) {
sumread = sumread3;
leis = leis2;
fpti = fpti2;
ft3 = ft4;
FileOutputStream fpo6 = fpo3;
if (dither != 0) {
fpo4 = fpo6;
samp5 = samp4;
att5 = att4;
s = do_shaping(f2, peak, dither, ch);
} else {
fpo4 = fpo6;
samp5 = samp4;
att5 = att4;
s = RINT(f2);
}
ByteBuffer buf2 = ByteBuffer.allocate(2).order(ByteOrder.LITTLE_ENDIAN);
buf2.putShort((short) s);
buf2.flip();
writeBuffers(fpo4, buf2);
} else if (dbps6 != 3) {
sumread = sumread3;
leis = leis2;
fpti = fpti2;
ft3 = ft4;
samp5 = samp4;
att5 = att4;
fpo4 = fpo3;
} else {
if (dither != 0) {
sumread = sumread3;
leis = leis2;
fpti = fpti2;
ft3 = ft4;
s2 = do_shaping(f2, peak, dither, ch);
f = f2;
} else {
sumread = sumread3;
leis = leis2;
fpti = fpti2;
ft3 = ft4;
f = f2;
s2 = RINT(f);
}
ByteBuffer buf3 = ByteBuffer.allocate(3);
buf3.put((byte) (s2 & 255));
int s4 = s2 >> 8;
buf3.put((byte) (s4 & 255));
buf3.put((byte) ((s4 >> 8) & 255));
buf3.flip();
FileOutputStream fpo7 = fpo3;
writeBuffers(fpo7, buf3);
fpo4 = fpo7;
samp5 = samp4;
att5 = att4;
}
int s5 = ch + 1;
if (s5 != nch3) {
ch = s5;
} else {
ch = 0;
}
if ((262143 & sumread) == 0) {
showprogress(sumread / fptlen);
}
sumread2 = sumread;
fpo3 = fpo4;
leis2 = leis;
fpti2 = fpti;
ft4 = ft3;
att4 = att5;
samp4 = samp5;
i4 = 1;
}
FileChannel fpti3 = fpti2;
File ft5 = ft4;
FileOutputStream fpo8 = fpo3;
showprogress(1.0d);
if (!this.quiet) {
System.err.printf(str3, new Object[0]);
}
fpti3.close();
if (ft5 != null && !ft5.delete()) {
System.err.printf("Failed to remove %s\n", ft5);
}
ssrc2 = this;
d = 1.0d;
fpo2 = fpo8;
length2 = 0;
dbps4 = nch3;
} catch (IOException e9) {
throw new IllegalStateException("cannot open temporary file.");
}
} else {
int sfrq5 = sfrq;
int dfrq11 = dfrq;
int nch7 = nch2;
int bps6 = bps;
FileOutputStream fpo9 = fpo;
int bps7 = dbps3;
String str4 = str;
i3 = 4;
if (sfrq5 < dfrq11) {
fpo2 = fpo9;
str2 = str4;
d = 1.0d;
peak[0] = upsample(fpi, fpo9, nch7, bps6, bps7, sfrq5, dfrq11, Math.pow(10.0d, (-att2) / 20.0d), (length / bps6) / nch7, twopass, dither);
dbps4 = nch7;
length2 = 0;
} else {
str2 = str4;
d = 1.0d;
fpo2 = fpo9;
double att9 = att2;
if (sfrq5 > dfrq11) {
int i9 = (length / bps6) / nch7;
length2 = 0;
peak[0] = downsample(fpi, fpo2, nch7, bps6, bps7, sfrq5, dfrq11, Math.pow(10.0d, (-att9) / 20.0d), i9, twopass, dither);
dbps4 = nch7;
} else {
length2 = 0;
dbps4 = nch7;
peak[0] = no_src(fpi, fpo2, dbps4, bps6, bps7, Math.pow(10.0d, (-att9) / 20.0d), (length / bps6) / dbps4, twopass, dither);
}
}
ssrc2 = this;
if (!ssrc2.quiet) {
System.err.printf(str2, new Object[length2]);
}
}
if (dither != 0) {
ssrc2.quit_shaper(dbps4);
}
if (!twopass && peak[length2] > d && !ssrc2.quiet) {
PrintStream printStream2 = System.err;
Object[] objArr2 = new Object[1];
objArr2[length2] = Double.valueOf(Math.log10(peak[length2]) * 20.0d);
printStream2.printf("clipping detected : %gdB\n", objArr2);
}
fpo2.close();
File fo = new File(dfn2);
int len = (int) fo.length();
FileChannel fpo1 = new RandomAccessFile(fo, "rw").getChannel();
ByteBuffer leos2 = ByteBuffer.allocate(i3).order(ByteOrder.LITTLE_ENDIAN);
int dword3 = len - 8;
leos2.position(length2);
leos2.limit(4);
leos2.putInt(dword3);
leos2.flip();
fpo1.write(leos2, 4L);
int dword4 = len - 44;
leos2.position(length2);
leos2.limit(4);
leos2.putInt(dword4);
leos2.flip();
fpo1.write(leos2, 40L);
fpo1.close();
} catch (IOException e10) {
throw new IllegalArgumentException("cannot open output file.");
}
} catch (IOException e11) {
}
} catch (IOException e12) {
}
} catch (IOException e13) {
throw new IllegalArgumentException("cannot open input file.");
}
}
public SSRC(InputStream fpi, OutputStream fpo, int sfrq, int dfrq, int bps, int dbps, int nch, int length, double att, int dither, boolean quiet_) throws IOException {
int dither2;
int dfrq2;
int dfrq3;
String str;
int dbps2;
char c;
int min;
int max;
this.byteOrder = ByteOrder.LITTLE_ENDIAN;
this.fft = new SplitRadixFft();
this.AA = 170.0d;
this.DF = 100.0d;
this.FFTFIRLEN = 65536;
this.quiet = false;
double[] peak = new double[1];
peak[0] = 0.0d;
if (dither >= 0 && dither <= 4) {
this.quiet = quiet_;
if (bps != 1 && bps != 2 && bps != 3 && bps != 4) {
throw new IllegalStateException("Error : Only 8bit, 16bit, 24bit and 32bit PCM are supported.");
}
int dbps3 = dbps;
if (dbps3 == -1) {
if (bps != 1) {
dbps3 = bps;
} else {
dbps3 = 2;
}
if (dbps3 == 4) {
dbps3 = 3;
}
}
int dfrq4 = dfrq;
dfrq4 = dfrq4 == -1 ? sfrq : dfrq4;
if (dither != -1) {
dither2 = dither;
} else if (dbps3 < bps) {
if (dbps3 == 1) {
dither2 = 4;
} else {
dither2 = 3;
}
} else {
dither2 = 1;
}
if (this.quiet) {
dfrq2 = dfrq4;
} else {
String[] dtype = {SchedulerSupport.NONE, "no noise shaping", "triangular spectral shape", "ATH based noise shaping", "ATH based noise shaping(less amplitude)"};
String[] ptype = {"rectangular", "triangular", "gaussian"};
dfrq2 = dfrq4;
System.err.printf("frequency : %d -> %d\n", Integer.valueOf(sfrq), Integer.valueOf(dfrq4));
System.err.printf("attenuation : %gdB\n", Double.valueOf(att));
System.err.printf("bits per sample : %d -> %d\n", Integer.valueOf(bps * 8), Integer.valueOf(dbps3 * 8));
System.err.printf("nchannels : %d\n", Integer.valueOf(nch));
System.err.printf("length : %d bytes, %g secs\n", Integer.valueOf(length), Double.valueOf(((length / bps) / nch) / sfrq));
if (dither2 == 0) {
System.err.printf("dither type : none\n", new Object[0]);
} else {
System.err.printf("dither type : %s, %s p.d.f, amp = %g\n", dtype[dither2], ptype[0], Double.valueOf(0.18d));
}
System.err.printf("\n", new Object[0]);
}
if (dither2 == 0) {
dfrq3 = dfrq2;
str = "\n";
dbps2 = dbps3;
c = 0;
} else {
int min2 = 0;
int max2 = 0;
if (dbps3 == 1) {
min2 = -128;
max2 = 127;
}
if (dbps3 == 2) {
min2 = -32768;
max2 = 32767;
}
if (dbps3 == 3) {
min2 = -8388608;
max2 = 8388607;
}
if (dbps3 != 4) {
min = min2;
max = max2;
} else {
min = Integer.MIN_VALUE;
max = Integer.MAX_VALUE;
}
dfrq3 = dfrq2;
str = "\n";
dbps2 = dbps3;
int dbps4 = dither2;
c = 0;
init_shaper(dfrq3, nch, min, max, dbps4, 0, 0.18d);
}
if (sfrq < dfrq3) {
peak[c] = upsample(fpi, fpo, nch, bps, dbps2, sfrq, dfrq3, Math.pow(10.0d, (-att) / 20.0d), (length / bps) / nch, false, dither2);
} else {
int dfrq5 = dfrq3;
if (sfrq > dfrq5) {
int dfrq6 = (length / bps) / nch;
int dfrq7 = dither2;
peak[c] = downsample(fpi, fpo, nch, bps, dbps2, sfrq, dfrq5, Math.pow(10.0d, (-att) / 20.0d), dfrq6, false, dfrq7);
} else {
peak[c] = no_src(fpi, fpo, nch, bps, dbps2, Math.pow(10.0d, (-att) / 20.0d), (length / bps) / nch, false, dither2);
}
}
if (!this.quiet) {
System.err.printf(str, new Object[0]);
}
if (dither2 != 0) {
quit_shaper(nch);
}
if (0 == 0 && peak[0] > 1.0d && !this.quiet) {
System.err.printf("clipping detected : %gdB\n", Double.valueOf(Math.log10(peak[0]) * 20.0d));
return;
}
return;
}
throw new IllegalArgumentException("unrecognized dither type : " + dither);
}
protected byte[] getDataFromByteBuffer(ByteBuffer rawoutbuf) {
byte[] tempDataWrt = new byte[rawoutbuf.limit() - rawoutbuf.position()];
rawoutbuf.get(tempDataWrt, 0, tempDataWrt.length);
return tempDataWrt;
}
protected void writeBuffers(OutputStream fpo, ByteBuffer rawoutbuf) {
try {
fpo.write(getDataFromByteBuffer(rawoutbuf));
} catch (IOException e) {
}
}
}