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

198 lines
5.5 KiB
Java

package c.i.a.c.a2.b0;
import c.d.b.a.a;
import c.i.a.c.a2.d;
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.t;
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.EOFException;
import java.io.IOException;
import java.util.Arrays;
/* compiled from: AmrExtractor */
public final class b implements h {
public static final int[] a = {13, 14, 16, 18, 20, 21, 27, 32, 6, 7, 6, 6, 1, 1, 1, 1};
public static final int[] b;
/* renamed from: c reason: collision with root package name */
public static final byte[] f641c = f0.w("#!AMR\n");
public static final byte[] d = f0.w("#!AMR-WB\n");
public static final int e;
public final byte[] f;
public boolean g;
public long h;
public int i;
public int j;
public boolean k;
public long l;
public int m;
public int n;
public long o;
public j p;
public w q;
public t r;
/* renamed from: s reason: collision with root package name */
public boolean f642s;
static {
a aVar = a.a;
int[] iArr = {18, 24, 33, 37, 41, 47, 51, 59, 61, 6, 1, 1, 1, 1, 1, 1};
b = iArr;
e = iArr[8];
}
public b() {
this.f = new byte[1];
this.m = -1;
}
public b(int i) {
this.f = new byte[1];
this.m = -1;
}
/* JADX WARNING: Code restructure failed: missing block: B:21:0x0039, code lost:
if ((!r0 && (r4 < 12 || r4 > 14)) != false) goto L_0x003b;
*/
public final int a(i iVar) throws IOException {
iVar.k();
boolean z2 = false;
iVar.n(this.f, 0, 1);
byte b2 = this.f[0];
if ((b2 & 131) <= 0) {
int i = (b2 >> 3) & 15;
if (i >= 0 && i <= 15) {
boolean z3 = this.g;
if (!(z3 && (i < 10 || i > 13))) {
}
z2 = true;
}
if (z2) {
return this.g ? b[i] : a[i];
}
StringBuilder L = a.L("Illegal AMR ");
L.append(this.g ? "WB" : "NB");
L.append(" frame type ");
L.append(i);
throw new ParserException(L.toString());
}
throw new ParserException(a.l("Invalid padding bits for frame header ", b2));
}
@Override // c.i.a.c.a2.h
public boolean b(i iVar) throws IOException {
return c(iVar);
}
public final boolean c(i iVar) throws IOException {
byte[] bArr = f641c;
iVar.k();
byte[] bArr2 = new byte[bArr.length];
iVar.n(bArr2, 0, bArr.length);
if (Arrays.equals(bArr2, bArr)) {
this.g = false;
iVar.l(bArr.length);
return true;
}
byte[] bArr3 = d;
iVar.k();
byte[] bArr4 = new byte[bArr3.length];
iVar.n(bArr4, 0, bArr3.length);
if (!Arrays.equals(bArr4, bArr3)) {
return false;
}
this.g = true;
iVar.l(bArr3.length);
return true;
}
@Override // c.i.a.c.a2.h
public int e(i iVar, s sVar) throws IOException {
AnimatableValueParser.H(this.q);
if (iVar.getPosition() != 0 || c(iVar)) {
if (!this.f642s) {
this.f642s = true;
boolean z2 = this.g;
String str = z2 ? "audio/amr-wb" : "audio/3gpp";
int i = z2 ? 16000 : 8000;
w wVar = this.q;
Format.b bVar = new Format.b();
bVar.k = str;
bVar.l = e;
bVar.f2199x = 1;
bVar.f2200y = i;
wVar.e(bVar.a());
}
int i2 = -1;
if (this.j == 0) {
try {
int a2 = a(iVar);
this.i = a2;
this.j = a2;
if (this.m == -1) {
this.l = iVar.getPosition();
this.m = this.i;
}
if (this.m == this.i) {
this.n++;
}
} catch (EOFException unused) {
}
}
int b2 = this.q.b(iVar, this.j, true);
if (b2 != -1) {
int i3 = this.j - b2;
this.j = i3;
if (i3 <= 0) {
this.q.d(this.o + this.h, 1, this.i, 0, null);
this.h += 20000;
}
i2 = 0;
}
iVar.b();
if (!this.k) {
t.b bVar2 = new t.b(-9223372036854775807L, 0);
this.r = bVar2;
this.p.a(bVar2);
this.k = true;
}
return i2;
}
throw new ParserException("Could not find AMR header.");
}
@Override // c.i.a.c.a2.h
public void f(j jVar) {
this.p = jVar;
this.q = jVar.p(0, 1);
jVar.j();
}
@Override // c.i.a.c.a2.h
public void g(long j, long j2) {
this.h = 0;
this.i = 0;
this.j = 0;
if (j != 0) {
t tVar = this.r;
if (tVar instanceof d) {
d dVar = (d) tVar;
this.o = d.e(j, dVar.b, dVar.e);
return;
}
}
this.o = 0;
}
@Override // c.i.a.c.a2.h
public void release() {
}
}