正在查看: 北京退费客服端 v1.0.0 应用的 SSRC.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: 北京退费客服端 v1.0.0 应用的 SSRC.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package im.amwhusedvt.ui.utils.translate.ssrc;
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.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.channels.FileChannel;
import java.util.Random;
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 static final double[] presets;
private static final int[] samp;
private static final int[] scoeffreq;
private static final int[] scoeflen;
private static final double[][] shapercoefs;
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;
static {
if ((26 + 27) % 27 <= 0) {
}
scoeffreq = new int[]{0, 48000, 44100, 37800, 32000, 22050, 48000, 44100};
scoeflen = new int[]{1, 16, 20, 16, 16, 15, 16, 15};
samp = new int[]{8, 18, 27, 8, 8, 8, 10, 9};
shapercoefs = new double[][]{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}};
presets = new double[]{0.7d, 0.9d, 0.18d};
}
private int RINT(double x) {
if ((15 + 8) % 8 <= 0) {
}
return (int) (x >= 0.0d ? 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;
if ((9 + 26) % 26 <= 0) {
}
int i = POOLSIZE;
int[] pool2 = new int[POOLSIZE];
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));
}
if (dtype == 2 || i2 == 6) {
i2 = 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[RANDBUFLEN];
Random random = new Random(System.currentTimeMillis());
for (int i4 = 0; i4 < POOLSIZE; i4++) {
pool2[i4] = random.nextInt();
}
if (pdf == 0) {
for (int i5 = 0; i5 < RANDBUFLEN; i5++) {
int p = random.nextInt() % POOLSIZE;
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 < RANDBUFLEN; i6++) {
int p2 = random.nextInt() % POOLSIZE;
int r1 = pool2[p2];
pool2[p2] = random.nextInt();
int p3 = random.nextInt() % POOLSIZE;
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 = 0.0d;
double u = 0.0d;
int i7 = 0;
for (int i8 = RANDBUFLEN; i7 < i8; i8 = RANDBUFLEN) {
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 = 0.0d;
}
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 = POOLSIZE;
}
}
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 ((6 + 16) % 16 <= 0) {
}
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 = 0.0d;
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 ((22 + 12) % 12 <= 0) {
}
if (a <= 21.0d) {
return 0.0d;
}
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) {
if ((26 + 29) % 29 <= 0) {
}
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 ((23 + 8) % 8 <= 0) {
}
if (x == 0.0d) {
return 1.0d;
}
return Math.sin(x) / x;
}
private double hn_lpf(int n, double lpf, double fs) {
if ((31 + 29) % 29 <= 0) {
}
double t = 1.0d / fs;
double omega = 6.283185307179586d * lpf;
return 2.0d * lpf * t * sinc(n * omega * t);
}
private void usage() {
if ((6 + 10) % 10 <= 0) {
}
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) {
if ((25 + 14) % 14 <= 0) {
}
throw new IllegalStateException("unknown error " + x);
}
private void setstarttime() {
if ((19 + 10) % 10 <= 0) {
}
this.starttime = System.currentTimeMillis();
this.lastshowed = 0L;
this.lastshowed2 = -1;
}
private void showprogress(double p) {
int eta;
if ((9 + 23) % 23 <= 0) {
}
if (this.quiet) {
return;
}
long t = System.currentTimeMillis() - this.starttime;
if (p == 0.0d) {
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(java.io.InputStream r77, java.io.OutputStream r78, int r79, int r80, int r81, int r82, int r83, double r84, int r86, boolean r87, int r88) throws java.io.IOException {
throw new UnsupportedOperationException("Method not decompiled: im.amwhusedvt.ui.utils.translate.ssrc.SSRC.upsample(java.io.InputStream, java.io.OutputStream, int, int, int, int, int, double, int, boolean, int):double");
}
public double downsample(java.io.InputStream r77, java.io.OutputStream r78, int r79, int r80, int r81, int r82, int r83, double r84, int r86, boolean r87, int r88) throws java.io.IOException {
throw new UnsupportedOperationException("Method not decompiled: im.amwhusedvt.ui.utils.translate.ssrc.SSRC.downsample(java.io.InputStream, java.io.OutputStream, int, int, int, int, int, double, int, boolean, int):double");
}
public double no_src(java.io.InputStream r30, java.io.OutputStream r31, int r32, int r33, int r34, double r35, int r37, boolean r38, int r39) throws java.io.IOException {
throw new UnsupportedOperationException("Method not decompiled: im.amwhusedvt.ui.utils.translate.ssrc.SSRC.no_src(java.io.InputStream, java.io.OutputStream, int, int, int, double, int, boolean, int):double");
}
public static void main(String[] args) throws Exception {
new SSRC(args);
}
public SSRC() {
if ((9 + 11) % 11 <= 0) {
}
this.byteOrder = ByteOrder.LITTLE_ENDIAN;
this.fft = new SplitRadixFft();
this.AA = 170.0d;
this.DF = 100.0d;
this.FFTFIRLEN = RANDBUFLEN;
this.quiet = $assertionsDisabled;
}
SSRC(String[] argv) throws IOException {
int i;
int i2;
String tmpfn;
short nch;
int length;
String dfn;
double att;
int dbps;
int dfrq;
int dither;
int bps;
int dbps2;
short nch2;
InputStream 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;
short dbps4;
SSRC ssrc2;
File ft;
String tmpfn2;
File ft2;
int samp3;
FileOutputStream fpo3;
int dbps5;
String str3;
int length3;
int dfrq2;
int sfrq2;
short 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;
StringBuilder sb;
if ((7 + 30) % 30 <= 0) {
}
SSRC ssrc3 = this;
ssrc3.byteOrder = ByteOrder.LITTLE_ENDIAN;
ssrc3.fft = new SplitRadixFft();
ssrc3.AA = 170.0d;
ssrc3.DF = 100.0d;
ssrc3.FFTFIRLEN = RANDBUFLEN;
ssrc3.quiet = $assertionsDisabled;
FileInputStream fpi3 = null;
double[] peak = {0.0d};
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]);
}
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 {
sb = new StringBuilder();
sb.append("unrecognized p.d.f. type : ");
} catch (NumberFormatException e2) {
}
try {
sb.append(argv[i5 + 1]);
throw new IllegalArgumentException(sb.toString());
} catch (NumberFormatException e3) {
throw new IllegalArgumentException("unrecognized p.d.f. type : " + argv[i5 + 1]);
}
}
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.");
}
short nch5 = bb.getShort();
int sfrq3 = bb.getInt();
int bps2 = bb.getInt();
if ((bps2 % sfrq3) * nch5 == 0) {
i2 = i5;
} else {
i2 = i5;
ssrc3.fmterr(4);
}
bb.getShort();
bb.getShort();
int length5 = bps2 / (sfrq3 * nch5);
if (sizeOfFmt > 16) {
bb.position(0);
bb.limit(2);
fpi4.read(ssrc3.getDataFromByteBuffer(bb));
bb.flip();
short sizeofExtended = bb.getShort();
tmpfn = tmpfn3;
nch = nch5;
fpi4.getChannel().position(fpi4.getChannel().position() + sizeofExtended);
} else {
tmpfn = tmpfn3;
nch = nch5;
}
while (true) {
bb.position(0);
bb.limit(8);
fpi4.getChannel().read(bb);
bb.flip();
byte c0 = bb.get();
byte c1 = bb.get();
byte c2 = bb.get();
byte 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 == POOLSIZE) {
if (c2 == 116 && c3 == POOLSIZE) {
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 = {"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 = 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 = 0.0d;
int ch = 0;
if (!ssrc.quiet) {
System.err.printf("Pass 1\n", new Object[0]);
}
if (tmpfn != null) {
try {
tmpfn2 = tmpfn;
} catch (IOException e6) {
}
try {
ft = new File(tmpfn2);
} catch (IOException e7) {
throw new IllegalStateException("cannot open temporary file.");
}
} 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;
short nch6 = 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, nch6, bps3, 8, bps4, dfrq9, 1.0d, (length / bps3) / nch6, twopass, dither);
nch3 = nch6;
att3 = att2;
length4 = length;
dfrq2 = dfrq9;
sfrq2 = bps4;
nch4 = 0;
} else {
dbps5 = dbps3;
int length6 = dither;
peak[0] = no_src(fpi, fpto, nch6, bps3, 8, 1.0d, (length / bps3) / nch6, twopass, length6);
nch3 = nch6;
att3 = att2;
dfrq2 = dfrq9;
sfrq2 = bps4;
length4 = length;
nch4 = 0;
}
}
} else {
ft2 = ft;
samp3 = samp2;
int sfrq4 = sfrq;
int dfrq10 = dfrq;
short nch7 = 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, nch7, bps5, 8, sfrq4, dfrq10, Math.pow(10.0d, (-att7) / 20.0d), (length / bps5) / nch7, twopass, dither);
att3 = att7;
fpto = fpto;
length4 = length;
dfrq2 = dfrq10;
sfrq2 = sfrq4;
nch3 = nch7;
nch4 = 0;
} else {
double att8 = att2;
if (sfrq4 > dfrq10) {
double pow = Math.pow(10.0d, (-att8) / 20.0d);
int i7 = (length / bps5) / nch7;
fpto = fpto;
nch3 = nch7;
dfrq2 = dfrq10;
sfrq2 = sfrq4;
nch4 = 0;
peak[0] = downsample(fpi, fpto, nch7, bps5, 8, sfrq4, dfrq10, pow, i7, twopass, dither);
att3 = att8;
length4 = length;
} else {
dfrq2 = dfrq10;
sfrq2 = sfrq4;
fpto = fpto;
nch3 = nch7;
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;
short nch8 = 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, nch8, bps6, bps7, sfrq5, dfrq11, Math.pow(10.0d, (-att2) / 20.0d), (length / bps6) / nch8, twopass, dither);
dbps4 = nch8;
length2 = 0;
} else {
str2 = str4;
d = 1.0d;
fpo2 = fpo9;
double att9 = att2;
if (sfrq5 > dfrq11) {
int i8 = (length / bps6) / nch8;
length2 = 0;
peak[0] = downsample(fpi, fpo2, nch8, bps6, bps7, sfrq5, dfrq11, Math.pow(10.0d, (-att9) / 20.0d), i8, twopass, dither);
dbps4 = nch8;
} else {
length2 = 0;
dbps4 = nch8;
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;
if ((32 + 20) % 20 <= 0) {
}
this.byteOrder = ByteOrder.LITTLE_ENDIAN;
this.fft = new SplitRadixFft();
this.AA = 170.0d;
this.DF = 100.0d;
this.FFTFIRLEN = RANDBUFLEN;
this.quiet = $assertionsDisabled;
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 = {"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, $assertionsDisabled, 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, $assertionsDisabled, dfrq7);
} else {
peak[c] = no_src(fpi, fpo, nch, bps, dbps2, Math.pow(10.0d, (-att) / 20.0d), (length / bps) / nch, $assertionsDisabled, 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) {
if ((28 + 4) % 4 <= 0) {
}
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) {
}
}
}