discord-jadx/app/src/main/java/c/i/a/c/a2/i0/j.java

401 lines
17 KiB
Java

package c.i.a.c.a2.i0;
import android.util.Log;
import androidx.annotation.Nullable;
import c.i.a.c.a2.a0;
import c.i.a.c.a2.i0.i;
import c.i.a.c.a2.x;
import c.i.a.c.a2.y;
import c.i.a.c.a2.z;
import c.i.a.c.i2.w;
import com.airbnb.lottie.parser.AnimatableValueParser;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.ParserException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Objects;
import org.checkerframework.checker.nullness.qual.EnsuresNonNullIf;
/* compiled from: VorbisReader */
public final class j extends i {
@Nullable
public a n;
public int o;
public boolean p;
@Nullable
public a0 q;
@Nullable
public y r;
/* compiled from: VorbisReader */
public static final class a {
public final a0 a;
public final byte[] b;
/* renamed from: c reason: collision with root package name */
public final z[] f707c;
public final int d;
public a(a0 a0Var, y yVar, byte[] bArr, z[] zVarArr, int i) {
this.a = a0Var;
this.b = bArr;
this.f707c = zVarArr;
this.d = i;
}
}
@Override // c.i.a.c.a2.i0.i
public void b(long j) {
this.g = j;
int i = 0;
this.p = j != 0;
a0 a0Var = this.q;
if (a0Var != null) {
i = a0Var.e;
}
this.o = i;
}
@Override // c.i.a.c.a2.i0.i
public long c(w wVar) {
byte[] bArr = wVar.a;
int i = 0;
if ((bArr[0] & 1) == 1) {
return -1;
}
byte b = bArr[0];
a aVar = this.n;
AnimatableValueParser.H(aVar);
a aVar2 = aVar;
int i2 = !aVar2.f707c[(b >> 1) & (255 >>> (8 - aVar2.d))].a ? aVar2.a.e : aVar2.a.f;
if (this.p) {
i = (this.o + i2) / 4;
}
long j = (long) i;
byte[] bArr2 = wVar.a;
int length = bArr2.length;
int i3 = wVar.f908c + 4;
if (length < i3) {
wVar.A(Arrays.copyOf(bArr2, i3));
} else {
wVar.C(i3);
}
byte[] bArr3 = wVar.a;
int i4 = wVar.f908c;
bArr3[i4 - 4] = (byte) ((int) (j & 255));
bArr3[i4 - 3] = (byte) ((int) ((j >>> 8) & 255));
bArr3[i4 - 2] = (byte) ((int) ((j >>> 16) & 255));
bArr3[i4 - 1] = (byte) ((int) ((j >>> 24) & 255));
this.p = true;
this.o = i2;
return j;
}
/* JADX WARNING: Removed duplicated region for block: B:168:0x03c3 A[RETURN] */
/* JADX WARNING: Removed duplicated region for block: B:169:0x03c5 */
@Override // c.i.a.c.a2.i0.i
@EnsuresNonNullIf(expression = {"#3.format"}, result = false)
public boolean d(w wVar, long j, i.b bVar) throws IOException {
a aVar;
int i;
int i2;
byte[] bArr;
int i3;
byte[] bArr2;
if (this.n != null) {
Objects.requireNonNull(bVar.a);
return false;
}
a0 a0Var = this.q;
if (a0Var == null) {
AnimatableValueParser.L2(1, wVar, false);
int k = wVar.k();
int s2 = wVar.s();
int k2 = wVar.k();
int h = wVar.h();
int i4 = h <= 0 ? -1 : h;
int h2 = wVar.h();
int i5 = h2 <= 0 ? -1 : h2;
int h3 = wVar.h();
int i6 = h3 <= 0 ? -1 : h3;
int s3 = wVar.s();
this.q = new a0(k, s2, k2, i4, i5, i6, (int) Math.pow(2.0d, (double) (s3 & 15)), (int) Math.pow(2.0d, (double) ((s3 & 240) >> 4)), (1 & wVar.s()) > 0, Arrays.copyOf(wVar.a, wVar.f908c));
} else {
y yVar = this.r;
if (yVar == null) {
this.r = AnimatableValueParser.n2(wVar, true, true);
} else {
int i7 = wVar.f908c;
byte[] bArr3 = new byte[i7];
System.arraycopy(wVar.a, 0, bArr3, 0, i7);
int i8 = a0Var.a;
int i9 = 5;
AnimatableValueParser.L2(5, wVar, false);
int s4 = wVar.s() + 1;
x xVar = new x(wVar.a);
xVar.c(wVar.b * 8);
int i10 = 0;
while (true) {
int i11 = 16;
if (i10 >= s4) {
int i12 = 6;
int b = xVar.b(6) + 1;
for (int i13 = 0; i13 < b; i13++) {
if (xVar.b(16) != 0) {
throw new ParserException("placeholder of time domain transforms not zeroed out");
}
}
int i14 = 1;
int b2 = xVar.b(6) + 1;
int i15 = 0;
while (true) {
int i16 = 3;
if (i15 < b2) {
int b3 = xVar.b(i11);
if (b3 == 0) {
i = b2;
int i17 = 8;
xVar.c(8);
xVar.c(16);
xVar.c(16);
xVar.c(6);
xVar.c(8);
int b4 = xVar.b(4) + 1;
int i18 = 0;
while (i18 < b4) {
xVar.c(i17);
i18++;
i17 = 8;
}
} else if (b3 == i14) {
int b5 = xVar.b(5);
int[] iArr = new int[b5];
int i19 = -1;
for (int i20 = 0; i20 < b5; i20++) {
iArr[i20] = xVar.b(4);
if (iArr[i20] > i19) {
i19 = iArr[i20];
}
}
int i21 = i19 + 1;
int[] iArr2 = new int[i21];
int i22 = 0;
while (i22 < i21) {
iArr2[i22] = xVar.b(i16) + 1;
int b6 = xVar.b(2);
if (b6 > 0) {
xVar.c(8);
}
for (int i23 = 0; i23 < (1 << b6); i23++) {
xVar.c(8);
}
i22++;
i16 = 3;
b2 = b2;
}
i = b2;
xVar.c(2);
int b7 = xVar.b(4);
int i24 = 0;
int i25 = 0;
for (int i26 = 0; i26 < b5; i26++) {
i24 += iArr2[iArr[i26]];
while (i25 < i24) {
xVar.c(b7);
i25++;
}
}
} else {
throw new ParserException(c.d.b.a.a.l("floor type greater than 1 not decodable: ", b3));
}
i15++;
i12 = 6;
i14 = 1;
b2 = i;
i11 = 16;
} else {
int i27 = 1;
int b8 = xVar.b(i12) + 1;
int i28 = 0;
while (i28 < b8) {
if (xVar.b(16) <= 2) {
xVar.c(24);
xVar.c(24);
xVar.c(24);
int b9 = xVar.b(i12) + i27;
int i29 = 8;
xVar.c(8);
int[] iArr3 = new int[b9];
for (int i30 = 0; i30 < b9; i30++) {
iArr3[i30] = ((xVar.a() ? xVar.b(5) : 0) * 8) + xVar.b(3);
}
int i31 = 0;
while (i31 < b9) {
int i32 = 0;
while (i32 < i29) {
if ((iArr3[i31] & (1 << i32)) != 0) {
xVar.c(i29);
}
i32++;
i29 = 8;
}
i31++;
i29 = 8;
}
i28++;
i12 = 6;
i27 = 1;
} else {
throw new ParserException("residueType greater than 2 is not decodable");
}
}
int b10 = xVar.b(i12) + 1;
for (int i33 = 0; i33 < b10; i33++) {
int b11 = xVar.b(16);
if (b11 != 0) {
Log.e("VorbisUtil", "mapping type other than 0 not supported: " + b11);
} else {
int b12 = xVar.a() ? xVar.b(4) + 1 : 1;
if (xVar.a()) {
int b13 = xVar.b(8) + 1;
for (int i34 = 0; i34 < b13; i34++) {
int i35 = i8 - 1;
xVar.c(AnimatableValueParser.Y0(i35));
xVar.c(AnimatableValueParser.Y0(i35));
}
}
if (xVar.b(2) == 0) {
if (b12 > 1) {
for (int i36 = 0; i36 < i8; i36++) {
xVar.c(4);
}
}
for (int i37 = 0; i37 < b12; i37++) {
xVar.c(8);
xVar.c(8);
xVar.c(8);
}
} else {
throw new ParserException("to reserved bits must be zero after mapping coupling steps");
}
}
}
int b14 = xVar.b(6) + 1;
z[] zVarArr = new z[b14];
for (int i38 = 0; i38 < b14; i38++) {
zVarArr[i38] = new z(xVar.a(), xVar.b(16), xVar.b(16), xVar.b(8));
}
if (xVar.a()) {
aVar = new a(a0Var, yVar, bArr3, zVarArr, AnimatableValueParser.Y0(b14 - 1));
} else {
throw new ParserException("framing bit after modes not set as expected");
}
}
}
} else if (xVar.b(24) == 5653314) {
int b15 = xVar.b(16);
int b16 = xVar.b(24);
long[] jArr = new long[b16];
if (!xVar.a()) {
boolean a2 = xVar.a();
int i39 = 0;
while (i39 < b16) {
if (!a2) {
bArr2 = bArr3;
i3 = s4;
jArr[i39] = (long) (xVar.b(i9) + 1);
} else if (xVar.a()) {
bArr2 = bArr3;
i3 = s4;
jArr[i39] = (long) (xVar.b(i9) + 1);
} else {
bArr2 = bArr3;
i3 = s4;
jArr[i39] = 0;
}
i39++;
i9 = 5;
s4 = i3;
bArr3 = bArr2;
}
i2 = s4;
bArr = bArr3;
} else {
byte[] bArr4 = bArr3;
i2 = s4;
int b17 = xVar.b(5) + 1;
int i40 = 0;
while (i40 < b16) {
int b18 = xVar.b(AnimatableValueParser.Y0(b16 - i40));
int i41 = 0;
while (i41 < b18 && i40 < b16) {
jArr[i40] = (long) b17;
i40++;
i41++;
bArr4 = bArr4;
}
b17++;
bArr4 = bArr4;
}
bArr = bArr4;
}
int b19 = xVar.b(4);
if (b19 <= 2) {
if (b19 == 1 || b19 == 2) {
xVar.c(32);
xVar.c(32);
int b20 = xVar.b(4) + 1;
xVar.c(1);
xVar.c((int) (((long) b20) * (b19 == 1 ? b15 != 0 ? (long) Math.floor(Math.pow((double) ((long) b16), 1.0d / ((double) ((long) b15)))) : 0 : ((long) b16) * ((long) b15))));
}
i10++;
i9 = 5;
s4 = i2;
bArr3 = bArr;
} else {
throw new ParserException(c.d.b.a.a.l("lookup type greater than 2 not decodable: ", b19));
}
} else {
StringBuilder L = c.d.b.a.a.L("expected code book to start with [0x56, 0x43, 0x42] at ");
L.append((xVar.f755c * 8) + xVar.d);
throw new ParserException(L.toString());
}
}
this.n = aVar;
if (aVar != null) {
return true;
}
a0 a0Var2 = aVar.a;
ArrayList arrayList = new ArrayList();
arrayList.add(a0Var2.g);
arrayList.add(aVar.b);
Format.b bVar2 = new Format.b();
bVar2.k = "audio/vorbis";
bVar2.f = a0Var2.d;
bVar2.g = a0Var2.f640c;
bVar2.f2199x = a0Var2.a;
bVar2.f2200y = a0Var2.b;
bVar2.m = arrayList;
bVar.a = bVar2.a();
return true;
}
}
aVar = null;
this.n = aVar;
if (aVar != null) {
}
}
@Override // c.i.a.c.a2.i0.i
public void e(boolean z2) {
super.e(z2);
if (z2) {
this.n = null;
this.q = null;
this.r = null;
}
this.o = 0;
this.p = false;
}
}