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

306 lines
10 KiB
Java

package c.i.a.c.a2.j0;
import android.util.SparseArray;
import androidx.annotation.Nullable;
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.j0.i0;
import c.i.a.c.a2.s;
import c.i.a.c.a2.t;
import c.i.a.c.i2.e0;
import c.i.a.c.i2.v;
import c.i.a.c.i2.w;
import com.airbnb.lottie.parser.AnimatableValueParser;
import java.io.IOException;
/* compiled from: PsExtractor */
public final class b0 implements h {
public final e0 a = new e0(0);
public final SparseArray<a> b = new SparseArray<>();
/* renamed from: c reason: collision with root package name */
public final w f714c = new w(4096);
public final a0 d = new a0();
public boolean e;
public boolean f;
public boolean g;
public long h;
@Nullable
public z i;
public j j;
public boolean k;
/* compiled from: PsExtractor */
public static final class a {
public final o a;
public final e0 b;
/* renamed from: c reason: collision with root package name */
public final v f715c = new v(new byte[64]);
public boolean d;
public boolean e;
public boolean f;
public int g;
public long h;
public a(o oVar, e0 e0Var) {
this.a = oVar;
this.b = e0Var;
}
}
static {
d dVar = d.a;
}
@Override // c.i.a.c.a2.h
public boolean b(i iVar) throws IOException {
byte[] bArr = new byte[14];
iVar.n(bArr, 0, 14);
if (442 != (((bArr[0] & 255) << 24) | ((bArr[1] & 255) << 16) | ((bArr[2] & 255) << 8) | (bArr[3] & 255)) || (bArr[4] & 196) != 68 || (bArr[6] & 4) != 4 || (bArr[8] & 4) != 4 || (bArr[9] & 1) != 1 || (bArr[12] & 3) != 3) {
return false;
}
iVar.g(bArr[13] & 7);
iVar.n(bArr, 0, 3);
return 1 == ((((bArr[0] & 255) << 16) | ((bArr[1] & 255) << 8)) | (bArr[2] & 255));
}
/* JADX WARNING: Removed duplicated region for block: B:98:0x020a */
@Override // c.i.a.c.a2.h
public int e(i iVar, s sVar) throws IOException {
o pVar;
AnimatableValueParser.H(this.j);
long b = iVar.b();
int i = (b > -1 ? 1 : (b == -1 ? 0 : -1));
long j = -9223372036854775807L;
if (i != 0) {
a0 a0Var = this.d;
if (!a0Var.f713c) {
if (!a0Var.e) {
long b2 = iVar.b();
int min = (int) Math.min(20000L, b2);
long j2 = b2 - ((long) min);
if (iVar.getPosition() != j2) {
sVar.a = j2;
} else {
a0Var.b.z(min);
iVar.k();
iVar.n(a0Var.b.a, 0, min);
w wVar = a0Var.b;
int i2 = wVar.b;
int i3 = wVar.f913c - 4;
while (true) {
if (i3 < i2) {
break;
}
if (a0Var.b(wVar.a, i3) == 442) {
wVar.D(i3 + 4);
long c2 = a0.c(wVar);
if (c2 != -9223372036854775807L) {
j = c2;
break;
}
}
i3--;
}
a0Var.g = j;
a0Var.e = true;
return 0;
}
} else if (a0Var.g == -9223372036854775807L) {
a0Var.a(iVar);
return 0;
} else if (!a0Var.d) {
int min2 = (int) Math.min(20000L, iVar.b());
long j3 = (long) 0;
if (iVar.getPosition() != j3) {
sVar.a = j3;
} else {
a0Var.b.z(min2);
iVar.k();
iVar.n(a0Var.b.a, 0, min2);
w wVar2 = a0Var.b;
int i4 = wVar2.b;
int i5 = wVar2.f913c;
while (true) {
if (i4 >= i5 - 3) {
break;
}
if (a0Var.b(wVar2.a, i4) == 442) {
wVar2.D(i4 + 4);
long c3 = a0.c(wVar2);
if (c3 != -9223372036854775807L) {
j = c3;
break;
}
}
i4++;
}
a0Var.f = j;
a0Var.d = true;
return 0;
}
} else {
long j4 = a0Var.f;
if (j4 == -9223372036854775807L) {
a0Var.a(iVar);
return 0;
}
a0Var.h = a0Var.a.b(a0Var.g) - a0Var.a.b(j4);
a0Var.a(iVar);
return 0;
}
return 1;
}
}
if (!this.k) {
this.k = true;
a0 a0Var2 = this.d;
long j5 = a0Var2.h;
if (j5 != -9223372036854775807L) {
z zVar = new z(a0Var2.a, j5, b);
this.i = zVar;
this.j.a(zVar.a);
} else {
this.j.a(new t.b(j5, 0));
}
}
z zVar2 = this.i;
if (zVar2 != null && zVar2.b()) {
return this.i.a(iVar, sVar);
}
iVar.k();
long f = i != 0 ? b - iVar.f() : -1;
if ((f != -1 && f < 4) || !iVar.e(this.f714c.a, 0, 4, true)) {
return -1;
}
this.f714c.D(0);
int f2 = this.f714c.f();
if (f2 == 441) {
return -1;
}
if (f2 == 442) {
iVar.n(this.f714c.a, 0, 10);
this.f714c.D(9);
iVar.l((this.f714c.s() & 7) + 14);
return 0;
} else if (f2 == 443) {
iVar.n(this.f714c.a, 0, 2);
this.f714c.D(0);
iVar.l(this.f714c.x() + 6);
return 0;
} else if (((f2 & -256) >> 8) != 1) {
iVar.l(1);
return 0;
} else {
int i6 = f2 & 255;
a aVar = this.b.get(i6);
if (!this.e) {
if (aVar == null) {
o oVar = null;
if (i6 == 189) {
pVar = new g(null);
this.f = true;
this.h = iVar.getPosition();
} else if ((i6 & 224) == 192) {
pVar = new v(null);
this.f = true;
this.h = iVar.getPosition();
} else {
if ((i6 & 240) == 224) {
pVar = new p(null);
this.g = true;
this.h = iVar.getPosition();
}
if (oVar != null) {
oVar.e(this.j, new i0.d(Integer.MIN_VALUE, i6, 256));
aVar = new a(oVar, this.a);
this.b.put(i6, aVar);
}
}
oVar = pVar;
if (oVar != null) {
}
}
if (iVar.getPosition() > ((!this.f || !this.g) ? 1048576 : this.h + 8192)) {
this.e = true;
this.j.j();
}
}
iVar.n(this.f714c.a, 0, 2);
this.f714c.D(0);
int x2 = this.f714c.x() + 6;
if (aVar == null) {
iVar.l(x2);
return 0;
}
this.f714c.z(x2);
iVar.readFully(this.f714c.a, 0, x2);
this.f714c.D(6);
w wVar3 = this.f714c;
wVar3.e(aVar.f715c.a, 0, 3);
aVar.f715c.k(0);
aVar.f715c.m(8);
aVar.d = aVar.f715c.f();
aVar.e = aVar.f715c.f();
aVar.f715c.m(6);
int g = aVar.f715c.g(8);
aVar.g = g;
wVar3.e(aVar.f715c.a, 0, g);
aVar.f715c.k(0);
aVar.h = 0;
if (aVar.d) {
aVar.f715c.m(4);
aVar.f715c.m(1);
aVar.f715c.m(1);
long g2 = (((long) aVar.f715c.g(3)) << 30) | ((long) (aVar.f715c.g(15) << 15)) | ((long) aVar.f715c.g(15));
aVar.f715c.m(1);
if (!aVar.f && aVar.e) {
aVar.f715c.m(4);
aVar.f715c.m(1);
aVar.f715c.m(1);
aVar.f715c.m(1);
aVar.b.b((((long) aVar.f715c.g(3)) << 30) | ((long) (aVar.f715c.g(15) << 15)) | ((long) aVar.f715c.g(15)));
aVar.f = true;
}
aVar.h = aVar.b.b(g2);
}
aVar.a.f(aVar.h, 4);
aVar.a.b(wVar3);
aVar.a.d();
w wVar4 = this.f714c;
wVar4.C(wVar4.a.length);
return 0;
}
}
@Override // c.i.a.c.a2.h
public void f(j jVar) {
this.j = jVar;
}
@Override // c.i.a.c.a2.h
public void g(long j, long j2) {
if ((this.a.d() == -9223372036854775807L) || !(this.a.c() == 0 || this.a.c() == j2)) {
e0 e0Var = this.a;
synchronized (e0Var) {
e0Var.a = j2;
e0Var.f903c = -9223372036854775807L;
}
}
z zVar = this.i;
if (zVar != null) {
zVar.e(j2);
}
for (int i = 0; i < this.b.size(); i++) {
a valueAt = this.b.valueAt(i);
valueAt.f = false;
valueAt.a.c();
}
}
@Override // c.i.a.c.a2.h
public void release() {
}
}