discord-jadx/app/src/main/java/c/i/a/c/a2/k0/b.java

345 lines
12 KiB
Java

package c.i.a.c.a2.k0;
import android.util.Log;
import android.util.Pair;
import c.i.a.c.a2.h;
import c.i.a.c.a2.i;
import c.i.a.c.a2.j;
import c.i.a.c.a2.s;
import c.i.a.c.a2.w;
import c.i.a.c.i2.f0;
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.Objects;
/* compiled from: WavExtractor */
public final class b implements h {
public j a;
public w b;
/* renamed from: c reason: collision with root package name */
public AbstractC0083b f745c;
public int d = -1;
public long e = -1;
/* compiled from: WavExtractor */
public static final class a implements AbstractC0083b {
public static final int[] a = {-1, -1, -1, -1, 2, 4, 6, 8, -1, -1, -1, -1, 2, 4, 6, 8};
public static final int[] b = {7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, 130, 143, 157, 173, 190, 209, 230, 253, 279, 307, 337, 371, 408, 449, 494, 544, 598, 658, 724, 796, 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358, 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767};
/* renamed from: c reason: collision with root package name */
public final j f746c;
public final w d;
public final c e;
public final int f;
public final byte[] g;
public final c.i.a.c.i2.w h;
public final int i;
public final Format j;
public int k;
public long l;
public int m;
public long n;
public a(j jVar, w wVar, c cVar) throws ParserException {
this.f746c = jVar;
this.d = wVar;
this.e = cVar;
int max = Math.max(1, cVar.f748c / 10);
this.i = max;
byte[] bArr = cVar.f;
int length = bArr.length;
byte b2 = bArr[0];
byte b3 = bArr[1];
int i = ((bArr[3] & 255) << 8) | (bArr[2] & 255);
this.f = i;
int i2 = cVar.b;
int i3 = (((cVar.d - (i2 * 4)) * 8) / (cVar.e * i2)) + 1;
if (i == i3) {
int f = f0.f(max, i);
this.g = new byte[(cVar.d * f)];
this.h = new c.i.a.c.i2.w(i * 2 * i2 * f);
int i4 = cVar.f748c;
int i5 = ((cVar.d * i4) * 8) / i;
Format.b bVar = new Format.b();
bVar.k = "audio/raw";
bVar.f = i5;
bVar.g = i5;
bVar.l = max * 2 * i2;
bVar.f2199x = cVar.b;
bVar.f2200y = i4;
bVar.f2201z = 2;
this.j = bVar.a();
return;
}
throw new ParserException(c.d.b.a.a.o("Expected frames per block: ", i3, "; got: ", i));
}
@Override // c.i.a.c.a2.k0.b.AbstractC0083b
public void a(long j) {
this.k = 0;
this.l = j;
this.m = 0;
this.n = 0;
}
@Override // c.i.a.c.a2.k0.b.AbstractC0083b
public void b(int i, long j) {
this.f746c.a(new e(this.e, this.f, (long) i, j));
this.d.e(this.j);
}
/* JADX ERROR: JadxOverflowException in pass: RegionMakerVisitor
jadx.core.utils.exceptions.JadxOverflowException: Regions count limit reached
at jadx.core.utils.ErrorsCounter.addError(ErrorsCounter.java:57)
at jadx.core.utils.ErrorsCounter.error(ErrorsCounter.java:31)
at jadx.core.dex.attributes.nodes.NotificationAttrNode.addError(NotificationAttrNode.java:15)
*/
/* JADX WARNING: Removed duplicated region for block: B:41:0x0049 A[ADDED_TO_REGION, EDGE_INSN: B:41:0x0049->B:12:0x0049 ?: BREAK , SYNTHETIC] */
/* JADX WARNING: Removed duplicated region for block: B:6:0x002b */
@Override // c.i.a.c.a2.k0.b.AbstractC0083b
public boolean c(c.i.a.c.a2.i r19, long r20) throws java.io.IOException {
/*
// Method dump skipped, instructions count: 364
*/
throw new UnsupportedOperationException("Method not decompiled: c.i.a.c.a2.k0.b.a.c(c.i.a.c.a2.i, long):boolean");
}
public final int d(int i) {
return i / (this.e.b * 2);
}
public final void e(int i) {
long E = this.l + f0.E(this.n, 1000000, (long) this.e.f748c);
int i2 = i * 2 * this.e.b;
this.d.d(E, 1, i2, this.m - i2, null);
this.n += (long) i;
this.m -= i2;
}
}
/* compiled from: WavExtractor */
/* renamed from: c.i.a.c.a2.k0.b$b reason: collision with other inner class name */
public interface AbstractC0083b {
void a(long j);
void b(int i, long j) throws ParserException;
boolean c(i iVar, long j) throws IOException;
}
/* compiled from: WavExtractor */
public static final class c implements AbstractC0083b {
public final j a;
public final w b;
/* renamed from: c reason: collision with root package name */
public final c f747c;
public final Format d;
public final int e;
public long f;
public int g;
public long h;
public c(j jVar, w wVar, c cVar, String str, int i) throws ParserException {
this.a = jVar;
this.b = wVar;
this.f747c = cVar;
int i2 = (cVar.b * cVar.e) / 8;
if (cVar.d == i2) {
int i3 = cVar.f748c * i2;
int i4 = i3 * 8;
int max = Math.max(i2, i3 / 10);
this.e = max;
Format.b bVar = new Format.b();
bVar.k = str;
bVar.f = i4;
bVar.g = i4;
bVar.l = max;
bVar.f2199x = cVar.b;
bVar.f2200y = cVar.f748c;
bVar.f2201z = i;
this.d = bVar.a();
return;
}
StringBuilder M = c.d.b.a.a.M("Expected block size: ", i2, "; got: ");
M.append(cVar.d);
throw new ParserException(M.toString());
}
@Override // c.i.a.c.a2.k0.b.AbstractC0083b
public void a(long j) {
this.f = j;
this.g = 0;
this.h = 0;
}
@Override // c.i.a.c.a2.k0.b.AbstractC0083b
public void b(int i, long j) {
this.a.a(new e(this.f747c, 1, (long) i, j));
this.b.e(this.d);
}
@Override // c.i.a.c.a2.k0.b.AbstractC0083b
public boolean c(i iVar, long j) throws IOException {
int i;
int i2;
int i3;
long j2 = j;
while (true) {
i = (j2 > 0 ? 1 : (j2 == 0 ? 0 : -1));
if (i <= 0 || (i2 = this.g) >= (i3 = this.e)) {
break;
}
int b = this.b.b(iVar, (int) Math.min((long) (i3 - i2), j2), true);
if (b == -1) {
j2 = 0;
} else {
this.g += b;
j2 -= (long) b;
}
}
c cVar = this.f747c;
int i4 = cVar.d;
int i5 = this.g / i4;
if (i5 > 0) {
int i6 = i5 * i4;
int i7 = this.g - i6;
this.b.d(this.f + f0.E(this.h, 1000000, (long) cVar.f748c), 1, i6, i7, null);
this.h += (long) i5;
this.g = i7;
}
return i <= 0;
}
}
static {
a aVar = a.a;
}
@Override // c.i.a.c.a2.h
public boolean b(i iVar) throws IOException {
return AnimatableValueParser.X1(iVar) != null;
}
/* JADX WARNING: Removed duplicated region for block: B:27:0x006a */
/* JADX WARNING: Removed duplicated region for block: B:28:0x0079 */
@Override // c.i.a.c.a2.h
public int e(i iVar, s sVar) throws IOException {
int i;
int i2;
AnimatableValueParser.H(this.b);
int i3 = f0.a;
boolean z2 = true;
if (this.f745c == null) {
c X1 = AnimatableValueParser.X1(iVar);
if (X1 != null) {
int i4 = X1.a;
if (i4 == 17) {
this.f745c = new a(this.a, this.b, X1);
} else if (i4 == 6) {
this.f745c = new c(this.a, this.b, X1, "audio/g711-alaw", -1);
} else if (i4 == 7) {
this.f745c = new c(this.a, this.b, X1, "audio/g711-mlaw", -1);
} else {
int i5 = X1.e;
if (i4 != 1) {
if (i4 == 3) {
i2 = i5 == 32 ? 4 : 0;
i = i2;
if (i != 0) {
}
} else if (i4 != 65534) {
i = 0;
if (i != 0) {
this.f745c = new c(this.a, this.b, X1, "audio/raw", i);
} else {
StringBuilder L = c.d.b.a.a.L("Unsupported WAV format type: ");
L.append(X1.a);
throw new ParserException(L.toString());
}
}
}
i2 = f0.r(i5);
i = i2;
if (i != 0) {
}
}
} else {
throw new ParserException("Unsupported or unrecognized wav header.");
}
}
if (this.d == -1) {
Objects.requireNonNull(iVar);
iVar.k();
c.i.a.c.i2.w wVar = new c.i.a.c.i2.w(8);
d a2 = d.a(iVar, wVar);
while (true) {
int i6 = a2.a;
if (i6 != 1684108385) {
if (!(i6 == 1380533830 || i6 == 1718449184)) {
StringBuilder L2 = c.d.b.a.a.L("Ignoring unknown WAV chunk: ");
L2.append(a2.a);
Log.w("WavHeaderReader", L2.toString());
}
long j = a2.b + 8;
if (a2.a == 1380533830) {
j = 12;
}
if (j <= 2147483647L) {
iVar.l((int) j);
a2 = d.a(iVar, wVar);
} else {
StringBuilder L3 = c.d.b.a.a.L("Chunk is too large (~2GB+) to skip; id: ");
L3.append(a2.a);
throw new ParserException(L3.toString());
}
} else {
iVar.l(8);
long position = iVar.getPosition();
long j2 = a2.b + position;
long b = iVar.b();
if (b != -1 && j2 > b) {
StringBuilder O = c.d.b.a.a.O("Data exceeds input length: ", j2, ", ");
O.append(b);
Log.w("WavHeaderReader", O.toString());
j2 = b;
}
Pair create = Pair.create(Long.valueOf(position), Long.valueOf(j2));
this.d = ((Long) create.first).intValue();
long longValue = ((Long) create.second).longValue();
this.e = longValue;
this.f745c.b(this.d, longValue);
}
}
} else if (iVar.getPosition() == 0) {
iVar.l(this.d);
}
if (this.e == -1) {
z2 = false;
}
AnimatableValueParser.D(z2);
return this.f745c.c(iVar, this.e - iVar.getPosition()) ? -1 : 0;
}
@Override // c.i.a.c.a2.h
public void f(j jVar) {
this.a = jVar;
this.b = jVar.p(0, 1);
jVar.j();
}
@Override // c.i.a.c.a2.h
public void g(long j, long j2) {
AbstractC0083b bVar = this.f745c;
if (bVar != null) {
bVar.a(j2);
}
}
@Override // c.i.a.c.a2.h
public void release() {
}
}