discord-jadx/app/src/main/java/c/i/a/c/a2/h0/g.java

1442 lines
64 KiB
Java

package c.i.a.c.a2.h0;
import android.util.Log;
import android.util.Pair;
import android.util.SparseArray;
import androidx.annotation.Nullable;
import c.i.a.c.a2.c;
import c.i.a.c.a2.h;
import c.i.a.c.a2.h0.d;
import c.i.a.c.a2.i;
import c.i.a.c.a2.j;
import c.i.a.c.a2.p;
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 c.i.a.c.i2.u;
import c.i.a.c.v1.m;
import com.airbnb.lottie.parser.AnimatableValueParser;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.ParserException;
import com.google.android.exoplayer2.drm.DrmInitData;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
/* compiled from: FragmentedMp4Extractor */
public class g implements h {
public static final byte[] a = {-94, 57, 79, 82, 90, -101, 79, 20, -94, 68, 108, 66, 124, 100, -115, -12};
public static final Format b;
public int A;
public int B;
public boolean C;
public j D;
public w[] E;
public w[] F;
public boolean G;
/* renamed from: c reason: collision with root package name */
public final int f686c;
public final List<Format> d;
public final SparseArray<b> e;
public final c.i.a.c.i2.w f = new c.i.a.c.i2.w(u.a);
public final c.i.a.c.i2.w g = new c.i.a.c.i2.w(5);
public final c.i.a.c.i2.w h = new c.i.a.c.i2.w();
public final byte[] i;
public final c.i.a.c.i2.w j;
public final c.i.a.c.c2.i.b k = new c.i.a.c.c2.i.b();
public final c.i.a.c.i2.w l = new c.i.a.c.i2.w(16);
public final ArrayDeque<d.a> m;
public final ArrayDeque<a> n;
public int o;
public int p;
public long q;
public int r;
@Nullable
/* renamed from: s reason: collision with root package name */
public c.i.a.c.i2.w f687s;
public long t;
public int u;
public long v;
public long w;
/* renamed from: x reason: collision with root package name */
public long f688x;
@Nullable
/* renamed from: y reason: collision with root package name */
public b f689y;
/* renamed from: z reason: collision with root package name */
public int f690z;
/* compiled from: FragmentedMp4Extractor */
public static final class a {
public final long a;
public final int b;
public a(long j, int i) {
this.a = j;
this.b = i;
}
}
/* compiled from: FragmentedMp4Extractor */
public static final class b {
public final w a;
public final o b = new o();
/* renamed from: c reason: collision with root package name */
public final c.i.a.c.i2.w f691c = new c.i.a.c.i2.w();
public p d;
public f e;
public int f;
public int g;
public int h;
public int i;
public final c.i.a.c.i2.w j = new c.i.a.c.i2.w(1);
public final c.i.a.c.i2.w k = new c.i.a.c.i2.w();
public boolean l;
public b(w wVar, p pVar, f fVar) {
this.a = wVar;
this.d = pVar;
this.e = fVar;
this.d = pVar;
this.e = fVar;
wVar.e(pVar.a.f);
e();
}
public long a() {
return !this.l ? this.d.f702c[this.f] : this.b.f[this.h];
}
@Nullable
public n b() {
if (!this.l) {
return null;
}
o oVar = this.b;
f fVar = oVar.a;
int i = f0.a;
int i2 = fVar.a;
n nVar = oVar.n;
if (nVar == null) {
nVar = this.d.a.a(i2);
}
if (nVar == null || !nVar.a) {
return null;
}
return nVar;
}
public boolean c() {
this.f++;
if (!this.l) {
return false;
}
int i = this.g + 1;
this.g = i;
int[] iArr = this.b.g;
int i2 = this.h;
if (i != iArr[i2]) {
return true;
}
this.h = i2 + 1;
this.g = 0;
return false;
}
public int d(int i, int i2) {
c.i.a.c.i2.w wVar;
n b = b();
if (b == null) {
return 0;
}
int i3 = b.d;
if (i3 != 0) {
wVar = this.b.o;
} else {
byte[] bArr = b.e;
int i4 = f0.a;
c.i.a.c.i2.w wVar2 = this.k;
int length = bArr.length;
wVar2.a = bArr;
wVar2.f910c = length;
wVar2.b = 0;
i3 = bArr.length;
wVar = wVar2;
}
o oVar = this.b;
boolean z2 = oVar.l && oVar.m[this.f];
boolean z3 = z2 || i2 != 0;
c.i.a.c.i2.w wVar3 = this.j;
wVar3.a[0] = (byte) ((z3 ? 128 : 0) | i3);
wVar3.D(0);
this.a.f(this.j, 1, 1);
this.a.f(wVar, i3, 1);
if (!z3) {
return i3 + 1;
}
if (!z2) {
this.f691c.z(8);
c.i.a.c.i2.w wVar4 = this.f691c;
byte[] bArr2 = wVar4.a;
bArr2[0] = 0;
bArr2[1] = 1;
bArr2[2] = (byte) ((i2 >> 8) & 255);
bArr2[3] = (byte) (i2 & 255);
bArr2[4] = (byte) ((i >> 24) & 255);
bArr2[5] = (byte) ((i >> 16) & 255);
bArr2[6] = (byte) ((i >> 8) & 255);
bArr2[7] = (byte) (i & 255);
this.a.f(wVar4, 8, 1);
return i3 + 1 + 8;
}
c.i.a.c.i2.w wVar5 = this.b.o;
int x2 = wVar5.x();
wVar5.E(-2);
int i5 = (x2 * 6) + 2;
if (i2 != 0) {
this.f691c.z(i5);
byte[] bArr3 = this.f691c.a;
wVar5.e(bArr3, 0, i5);
int i6 = (((bArr3[2] & 255) << 8) | (bArr3[3] & 255)) + i2;
bArr3[2] = (byte) ((i6 >> 8) & 255);
bArr3[3] = (byte) (i6 & 255);
wVar5 = this.f691c;
}
this.a.f(wVar5, i5, 1);
return i3 + 1 + i5;
}
public void e() {
o oVar = this.b;
oVar.d = 0;
oVar.q = 0;
oVar.r = false;
oVar.l = false;
oVar.p = false;
oVar.n = null;
this.f = 0;
this.h = 0;
this.g = 0;
this.i = 0;
this.l = false;
}
}
static {
Format.b bVar = new Format.b();
bVar.k = "application/x-emsg";
b = bVar.a();
}
public g(int i) {
List emptyList = Collections.emptyList();
this.f686c = i;
this.d = Collections.unmodifiableList(emptyList);
byte[] bArr = new byte[16];
this.i = bArr;
this.j = new c.i.a.c.i2.w(bArr);
this.m = new ArrayDeque<>();
this.n = new ArrayDeque<>();
this.e = new SparseArray<>();
this.w = -9223372036854775807L;
this.v = -9223372036854775807L;
this.f688x = -9223372036854775807L;
this.D = j.d;
this.E = new w[0];
this.F = new w[0];
}
public static int a(int i) throws ParserException {
if (i >= 0) {
return i;
}
throw new ParserException(c.d.b.a.a.k("Unexpected negative value: ", i));
}
@Nullable
public static DrmInitData h(List<d.b> list) {
int size = list.size();
ArrayList arrayList = null;
for (int i = 0; i < size; i++) {
d.b bVar = list.get(i);
if (bVar.a == 1886614376) {
if (arrayList == null) {
arrayList = new ArrayList();
}
byte[] bArr = bVar.b.a;
j V1 = AnimatableValueParser.V1(bArr);
UUID uuid = V1 == null ? null : V1.a;
if (uuid == null) {
Log.w("FragmentedMp4Extractor", "Skipped pssh atom (failed to extract uuid)");
} else {
arrayList.add(new DrmInitData.SchemeData(uuid, "video/mp4", bArr));
}
}
}
if (arrayList == null) {
return null;
}
return new DrmInitData(null, false, (DrmInitData.SchemeData[]) arrayList.toArray(new DrmInitData.SchemeData[0]));
}
public static void i(c.i.a.c.i2.w wVar, int i, o oVar) throws ParserException {
wVar.D(i + 8);
int f = wVar.f() & 16777215;
if ((f & 1) == 0) {
boolean z2 = (f & 2) != 0;
int v = wVar.v();
if (v == 0) {
Arrays.fill(oVar.m, 0, oVar.e, false);
} else if (v == oVar.e) {
Arrays.fill(oVar.m, 0, v, z2);
int a2 = wVar.a();
c.i.a.c.i2.w wVar2 = oVar.o;
byte[] bArr = wVar2.a;
if (bArr.length < a2) {
bArr = new byte[a2];
}
wVar2.a = bArr;
wVar2.f910c = a2;
wVar2.b = 0;
oVar.l = true;
oVar.p = true;
wVar.e(bArr, 0, a2);
oVar.o.D(0);
oVar.p = false;
} else {
StringBuilder M = c.d.b.a.a.M("Senc sample count ", v, " is different from fragment sample count");
M.append(oVar.e);
throw new ParserException(M.toString());
}
} else {
throw new ParserException("Overriding TrackEncryptionBox parameters is unsupported.");
}
}
@Override // c.i.a.c.a2.h
public boolean b(i iVar) throws IOException {
return l.a(iVar, true, false);
}
public final void c() {
this.o = 0;
this.r = 0;
}
public final f d(SparseArray<f> sparseArray, int i) {
if (sparseArray.size() == 1) {
return sparseArray.valueAt(0);
}
f fVar = sparseArray.get(i);
Objects.requireNonNull(fVar);
return fVar;
}
/* JADX DEBUG: Multi-variable search result rejected for r6v32, resolved type: boolean */
/* JADX WARN: Multi-variable type inference failed */
/* JADX WARNING: Removed duplicated region for block: B:336:0x02d2 A[SYNTHETIC] */
/* JADX WARNING: Removed duplicated region for block: B:347:0x075f A[SYNTHETIC] */
/* JADX WARNING: Removed duplicated region for block: B:350:0x0004 A[SYNTHETIC] */
/* JADX WARNING: Removed duplicated region for block: B:354:0x0004 A[SYNTHETIC] */
@Override // c.i.a.c.a2.h
public int e(i iVar, s sVar) throws IOException {
long j;
int i;
boolean z2;
long j2;
long j3;
long j4;
String str;
String str2;
long j5;
long j6;
boolean z3;
i iVar2 = iVar;
while (true) {
int i2 = this.o;
int i3 = 1;
if (i2 == 0) {
if (this.r == 0) {
if (!iVar2.c(this.l.a, 0, 8, true)) {
z3 = false;
if (z3) {
return -1;
}
} else {
this.r = 8;
this.l.D(0);
this.q = this.l.t();
this.p = this.l.f();
}
}
long j7 = this.q;
if (j7 == 1) {
iVar2.readFully(this.l.a, 8, 8);
this.r += 8;
this.q = this.l.w();
} else if (j7 == 0) {
long b2 = iVar.b();
if (b2 == -1 && !this.m.isEmpty()) {
b2 = this.m.peek().b;
}
if (b2 != -1) {
this.q = (b2 - iVar.getPosition()) + ((long) this.r);
}
}
if (this.q >= ((long) this.r)) {
long position = iVar.getPosition() - ((long) this.r);
int i4 = this.p;
if ((i4 == 1836019558 || i4 == 1835295092) && !this.G) {
this.D.a(new t.b(this.w, position));
this.G = true;
}
if (this.p == 1836019558) {
int size = this.e.size();
for (int i5 = 0; i5 < size; i5++) {
o oVar = this.e.valueAt(i5).b;
Objects.requireNonNull(oVar);
oVar.f701c = position;
oVar.b = position;
}
}
int i6 = this.p;
if (i6 == 1835295092) {
this.f689y = null;
this.t = position + this.q;
this.o = 2;
} else if (i6 == 1836019574 || i6 == 1953653099 || i6 == 1835297121 || i6 == 1835626086 || i6 == 1937007212 || i6 == 1836019558 || i6 == 1953653094 || i6 == 1836475768 || i6 == 1701082227) {
long position2 = (iVar.getPosition() + this.q) - 8;
this.m.push(new d.a(this.p, position2));
if (this.q == ((long) this.r)) {
j(position2);
} else {
c();
}
} else if (i6 == 1751411826 || i6 == 1835296868 || i6 == 1836476516 || i6 == 1936286840 || i6 == 1937011556 || i6 == 1937011827 || i6 == 1668576371 || i6 == 1937011555 || i6 == 1937011578 || i6 == 1937013298 || i6 == 1937007471 || i6 == 1668232756 || i6 == 1937011571 || i6 == 1952867444 || i6 == 1952868452 || i6 == 1953196132 || i6 == 1953654136 || i6 == 1953658222 || i6 == 1886614376 || i6 == 1935763834 || i6 == 1935763823 || i6 == 1936027235 || i6 == 1970628964 || i6 == 1935828848 || i6 == 1936158820 || i6 == 1701606260 || i6 == 1835362404 || i6 == 1701671783) {
if (this.r == 8) {
long j8 = this.q;
if (j8 <= 2147483647L) {
c.i.a.c.i2.w wVar = new c.i.a.c.i2.w((int) j8);
System.arraycopy(this.l.a, 0, wVar.a, 0, 8);
this.f687s = wVar;
this.o = 1;
} else {
throw new ParserException("Leaf atom with length > 2147483647 (unsupported).");
}
} else {
throw new ParserException("Leaf atom defines extended atom size (unsupported).");
}
} else if (this.q <= 2147483647L) {
this.f687s = null;
this.o = 1;
} else {
throw new ParserException("Skipping atom with length > 2147483647 (unsupported).");
}
z3 = true;
if (z3) {
}
} else {
throw new ParserException("Atom size less than header length (unsupported).");
}
} else if (i2 != 1) {
long j9 = Long.MAX_VALUE;
if (i2 != 2) {
b bVar = this.f689y;
if (bVar == null) {
SparseArray<b> sparseArray = this.e;
int size2 = sparseArray.size();
long j10 = Long.MAX_VALUE;
b bVar2 = null;
for (int i7 = 0; i7 < size2; i7++) {
b valueAt = sparseArray.valueAt(i7);
boolean z4 = valueAt.l;
if ((z4 || valueAt.f != valueAt.d.b) && (!z4 || valueAt.h != valueAt.b.d)) {
long a2 = valueAt.a();
if (a2 < j10) {
bVar2 = valueAt;
j10 = a2;
}
}
}
if (bVar2 == null) {
int position3 = (int) (this.t - iVar.getPosition());
if (position3 >= 0) {
iVar2.l(position3);
c();
i3 = 0;
if (i3 != 0) {
return 0;
}
} else {
throw new ParserException("Offset to end of mdat was negative.");
}
} else {
int a3 = (int) (bVar2.a() - iVar.getPosition());
if (a3 < 0) {
Log.w("FragmentedMp4Extractor", "Ignoring negative offset to sample data.");
a3 = 0;
}
iVar2.l(a3);
this.f689y = bVar2;
bVar = bVar2;
}
}
char c2 = 6;
if (this.o == 3) {
int i8 = !bVar.l ? bVar.d.d[bVar.f] : bVar.b.h[bVar.f];
this.f690z = i8;
if (bVar.f < bVar.i) {
iVar2.l(i8);
n b3 = bVar.b();
if (b3 != null) {
c.i.a.c.i2.w wVar2 = bVar.b.o;
int i9 = b3.d;
if (i9 != 0) {
wVar2.E(i9);
}
o oVar2 = bVar.b;
if (oVar2.l && oVar2.m[bVar.f]) {
wVar2.E(wVar2.x() * 6);
}
}
if (!bVar.c()) {
this.f689y = null;
}
this.o = 3;
if (i3 != 0) {
}
} else {
if (bVar.d.a.g == 1) {
this.f690z = i8 - 8;
iVar2.l(8);
}
if ("audio/ac4".equals(bVar.d.a.f.t)) {
this.A = bVar.d(this.f690z, 7);
m.a(this.f690z, this.j);
bVar.a.c(this.j, 7);
this.A += 7;
} else {
this.A = bVar.d(this.f690z, 0);
}
this.f690z += this.A;
this.o = 4;
this.B = 0;
}
}
p pVar = bVar.d;
m mVar = pVar.a;
w wVar3 = bVar.a;
if (!bVar.l) {
j = pVar.f[bVar.f];
} else {
o oVar3 = bVar.b;
int i10 = bVar.f;
j = ((long) oVar3.i[i10]) + oVar3.j[i10];
}
int i11 = mVar.j;
if (i11 == 0) {
while (true) {
int i12 = this.A;
int i13 = this.f690z;
if (i12 >= i13) {
break;
}
this.A += wVar3.b(iVar2, i13 - i12, false);
}
} else {
byte[] bArr = this.g.a;
bArr[0] = 0;
bArr[1] = 0;
bArr[2] = 0;
int i14 = i11 + 1;
int i15 = 4 - i11;
while (this.A < this.f690z) {
int i16 = this.B;
if (i16 == 0) {
iVar2.readFully(bArr, i15, i14);
this.g.D(0);
int f = this.g.f();
if (f >= i3) {
this.B = f - 1;
this.f.D(0);
wVar3.c(this.f, 4);
wVar3.c(this.g, i3);
if (this.F.length > 0) {
String str3 = mVar.f.t;
byte b4 = bArr[4];
byte[] bArr2 = u.a;
if (("video/avc".equals(str3) && (b4 & 31) == c2) || ("video/hevc".equals(str3) && ((b4 & 126) >> i3) == 39)) {
z2 = true;
this.C = z2;
this.A += 5;
this.f690z += i15;
}
}
z2 = false;
this.C = z2;
this.A += 5;
this.f690z += i15;
} else {
throw new ParserException("Invalid NAL length");
}
} else {
if (this.C) {
this.h.z(i16);
iVar2.readFully(this.h.a, 0, this.B);
wVar3.c(this.h, this.B);
i = this.B;
c.i.a.c.i2.w wVar4 = this.h;
int e = u.e(wVar4.a, wVar4.f910c);
this.h.D("video/hevc".equals(mVar.f.t) ? 1 : 0);
this.h.C(e);
AnimatableValueParser.L(j, this.h, this.F);
} else {
i = wVar3.b(iVar2, i16, false);
}
this.A += i;
this.B -= i;
c2 = 6;
i3 = 1;
}
}
}
int i17 = !bVar.l ? bVar.d.g[bVar.f] : bVar.b.k[bVar.f] ? 1 : 0;
if (bVar.b() != null) {
i17 |= 1073741824;
}
n b5 = bVar.b();
wVar3.d(j, i17, this.f690z, 0, b5 != null ? b5.f700c : null);
while (!this.n.isEmpty()) {
a removeFirst = this.n.removeFirst();
this.u -= removeFirst.b;
long j11 = removeFirst.a + j;
w[] wVarArr = this.E;
int i18 = 0;
for (int length = wVarArr.length; i18 < length; length = length) {
wVarArr[i18].d(j11, 1, removeFirst.b, this.u, null);
i18++;
}
}
if (!bVar.c()) {
this.f689y = null;
}
this.o = 3;
i3 = 1;
if (i3 != 0) {
}
} else {
int size3 = this.e.size();
b bVar3 = null;
for (int i19 = 0; i19 < size3; i19++) {
o oVar4 = this.e.valueAt(i19).b;
if (oVar4.p) {
long j12 = oVar4.f701c;
if (j12 < j9) {
bVar3 = this.e.valueAt(i19);
j9 = j12;
}
}
}
if (bVar3 == null) {
this.o = 3;
} else {
int position4 = (int) (j9 - iVar.getPosition());
if (position4 >= 0) {
iVar2.l(position4);
o oVar5 = bVar3.b;
c.i.a.c.i2.w wVar5 = oVar5.o;
iVar2.readFully(wVar5.a, 0, wVar5.f910c);
oVar5.o.D(0);
oVar5.p = false;
} else {
throw new ParserException("Offset to encryption data was negative.");
}
}
}
} else {
int i20 = ((int) this.q) - this.r;
c.i.a.c.i2.w wVar6 = this.f687s;
if (wVar6 != null) {
iVar2.readFully(wVar6.a, 8, i20);
int i21 = this.p;
d.b bVar4 = new d.b(i21, wVar6);
long position5 = iVar.getPosition();
if (!this.m.isEmpty()) {
this.m.peek().f682c.add(bVar4);
} else {
if (i21 == 1936286840) {
wVar6.D(8);
int f2 = (wVar6.f() >> 24) & 255;
wVar6.E(4);
long t = wVar6.t();
if (f2 == 0) {
j6 = wVar6.t();
j5 = wVar6.t();
} else {
j6 = wVar6.w();
j5 = wVar6.w();
}
long j13 = j5 + position5;
long E = f0.E(j6, 1000000, t);
wVar6.E(2);
int x2 = wVar6.x();
int[] iArr = new int[x2];
long[] jArr = new long[x2];
long[] jArr2 = new long[x2];
long[] jArr3 = new long[x2];
long j14 = E;
int i22 = 0;
while (i22 < x2) {
int f3 = wVar6.f();
if ((f3 & Integer.MIN_VALUE) == 0) {
long t2 = wVar6.t();
iArr[i22] = f3 & Integer.MAX_VALUE;
jArr[i22] = j13;
jArr3[i22] = j14;
long j15 = j6 + t2;
j14 = f0.E(j15, 1000000, t);
jArr2[i22] = j14 - jArr3[i22];
wVar6.E(4);
j13 += (long) iArr[i22];
i22++;
jArr3 = jArr3;
jArr2 = jArr2;
j6 = j15;
x2 = x2;
} else {
throw new ParserException("Unhandled indirect reference");
}
}
Pair create = Pair.create(Long.valueOf(E), new c(iArr, jArr, jArr2, jArr3));
this.f688x = ((Long) create.first).longValue();
this.D.a((t) create.second);
this.G = true;
} else if (i21 == 1701671783 && this.E.length != 0) {
wVar6.D(8);
int f4 = (wVar6.f() >> 24) & 255;
long j16 = -9223372036854775807L;
if (f4 == 0) {
str2 = wVar6.n();
Objects.requireNonNull(str2);
str = wVar6.n();
Objects.requireNonNull(str);
long t3 = wVar6.t();
long E2 = f0.E(wVar6.t(), 1000000, t3);
long j17 = this.f688x;
if (j17 != -9223372036854775807L) {
j16 = j17 + E2;
}
j4 = f0.E(wVar6.t(), 1000, t3);
j3 = wVar6.t();
j2 = j16;
j16 = E2;
} else if (f4 != 1) {
c.d.b.a.a.f0("Skipping unsupported emsg version: ", f4, "FragmentedMp4Extractor");
} else {
long t4 = wVar6.t();
long E3 = f0.E(wVar6.w(), 1000000, t4);
j4 = f0.E(wVar6.t(), 1000, t4);
j3 = wVar6.t();
str2 = wVar6.n();
Objects.requireNonNull(str2);
str = wVar6.n();
Objects.requireNonNull(str);
j2 = E3;
}
byte[] bArr3 = new byte[wVar6.a()];
int a4 = wVar6.a();
System.arraycopy(wVar6.a, wVar6.b, bArr3, 0, a4);
wVar6.b += a4;
c.i.a.c.c2.i.b bVar5 = this.k;
bVar5.a.reset();
try {
DataOutputStream dataOutputStream = bVar5.b;
dataOutputStream.writeBytes(str2);
dataOutputStream.writeByte(0);
DataOutputStream dataOutputStream2 = bVar5.b;
dataOutputStream2.writeBytes(str);
dataOutputStream2.writeByte(0);
c.i.a.c.c2.i.b.a(bVar5.b, j4);
c.i.a.c.c2.i.b.a(bVar5.b, j3);
bVar5.b.write(bArr3);
bVar5.b.flush();
c.i.a.c.i2.w wVar7 = new c.i.a.c.i2.w(bVar5.a.toByteArray());
int a5 = wVar7.a();
w[] wVarArr2 = this.E;
for (w wVar8 : wVarArr2) {
wVar7.D(0);
wVar8.c(wVar7, a5);
}
if (j2 == -9223372036854775807L) {
this.n.addLast(new a(j16, a5));
this.u += a5;
} else {
for (w wVar9 : this.E) {
wVar9.d(j2, 1, a5, 0, null);
}
}
} catch (IOException e2) {
throw new RuntimeException(e2);
}
}
iVar2 = iVar;
}
} else {
iVar2.l(i20);
}
j(iVar.getPosition());
}
}
}
@Override // c.i.a.c.a2.h
public void f(j jVar) {
int i;
this.D = jVar;
c();
w[] wVarArr = new w[2];
this.E = wVarArr;
int i2 = 100;
int i3 = 0;
if ((this.f686c & 4) != 0) {
wVarArr[0] = this.D.p(100, 5);
i2 = 101;
i = 1;
} else {
i = 0;
}
w[] wVarArr2 = (w[]) f0.C(this.E, i);
this.E = wVarArr2;
for (w wVar : wVarArr2) {
wVar.e(b);
}
this.F = new w[this.d.size()];
while (i3 < this.F.length) {
w p = this.D.p(i2, 3);
p.e(this.d.get(i3));
this.F[i3] = p;
i3++;
i2++;
}
}
@Override // c.i.a.c.a2.h
public void g(long j, long j2) {
int size = this.e.size();
for (int i = 0; i < size; i++) {
this.e.valueAt(i).e();
}
this.n.clear();
this.u = 0;
this.v = j2;
this.m.clear();
c();
}
/* JADX WARNING: Removed duplicated region for block: B:145:0x039c */
public final void j(long j) throws ParserException {
g gVar;
int i;
d.a aVar;
int i2;
SparseArray<b> sparseArray;
int i3;
byte[] bArr;
int i4;
byte[] bArr2;
byte[] bArr3;
int i5;
int i6;
o oVar;
int i7;
byte[] bArr4;
d.a aVar2;
d.a aVar3;
int i8;
int i9;
List<d.b> list;
b bVar;
int i10;
long j2;
boolean z2;
int i11;
int i12;
boolean z3;
int i13;
boolean z4;
int i14;
boolean z5;
int i15;
f fVar;
c.i.a.c.i2.w wVar;
boolean z6;
int[] iArr;
int i16;
b bVar2;
g gVar2 = this;
g gVar3 = gVar2;
while (!gVar3.m.isEmpty() && gVar3.m.peek().b == j) {
d.a pop = gVar3.m.pop();
int i17 = pop.a;
int i18 = 12;
if (i17 == 1836019574) {
AnimatableValueParser.E(true, "Unexpected moov box.");
DrmInitData h = h(pop.f682c);
d.a b2 = pop.b(1836475768);
Objects.requireNonNull(b2);
SparseArray<f> sparseArray2 = new SparseArray<>();
int size = b2.f682c.size();
long j3 = -9223372036854775807L;
int i19 = 0;
while (i19 < size) {
d.b bVar3 = b2.f682c.get(i19);
int i20 = bVar3.a;
if (i20 == 1953654136) {
c.i.a.c.i2.w wVar2 = bVar3.b;
wVar2.D(i18);
Pair create = Pair.create(Integer.valueOf(wVar2.f()), new f(wVar2.f() - 1, wVar2.f(), wVar2.f(), wVar2.f()));
sparseArray2.put(((Integer) create.first).intValue(), (f) create.second);
} else if (i20 == 1835362404) {
c.i.a.c.i2.w wVar3 = bVar3.b;
wVar3.D(8);
j3 = ((wVar3.f() >> 24) & 255) == 0 ? wVar3.t() : wVar3.w();
i19++;
i18 = 12;
}
i19++;
i18 = 12;
}
ArrayList arrayList = (ArrayList) e.e(pop, new p(), j3, h, (gVar3.f686c & 16) != 0, false, new c(gVar3));
int size2 = arrayList.size();
if (gVar3.e.size() == 0) {
for (int i21 = 0; i21 < size2; i21++) {
p pVar = (p) arrayList.get(i21);
m mVar = pVar.a;
gVar3.e.put(mVar.a, new b(gVar3.D.p(i21, mVar.b), pVar, gVar3.d(sparseArray2, mVar.a)));
gVar3.w = Math.max(gVar3.w, mVar.e);
}
gVar3.D.j();
} else {
AnimatableValueParser.D(gVar3.e.size() == size2);
for (int i22 = 0; i22 < size2; i22++) {
p pVar2 = (p) arrayList.get(i22);
m mVar2 = pVar2.a;
b bVar4 = gVar3.e.get(mVar2.a);
f d = gVar3.d(sparseArray2, mVar2.a);
bVar4.d = pVar2;
bVar4.e = d;
bVar4.a.e(pVar2.a.f);
bVar4.e();
}
}
gVar = gVar2;
} else {
int i23 = 8;
if (i17 == 1836019558) {
SparseArray<b> sparseArray3 = gVar3.e;
int i24 = gVar3.f686c;
byte[] bArr5 = gVar3.i;
int size3 = pop.d.size();
int i25 = 0;
while (i25 < size3) {
d.a aVar4 = pop.d.get(i25);
if (aVar4.a == 1953653094) {
d.b c2 = aVar4.c(1952868452);
Objects.requireNonNull(c2);
c.i.a.c.i2.w wVar4 = c2.b;
wVar4.D(i23);
int f = wVar4.f() & 16777215;
b valueAt = sparseArray3.size() == 1 ? sparseArray3.valueAt(0) : sparseArray3.get(wVar4.f());
if (valueAt == null) {
valueAt = null;
} else {
if ((f & 1) != 0) {
long w = wVar4.w();
o oVar2 = valueAt.b;
oVar2.b = w;
oVar2.f701c = w;
}
f fVar2 = valueAt.e;
valueAt.b.a = new f((f & 2) != 0 ? wVar4.f() - 1 : fVar2.a, (f & 8) != 0 ? wVar4.f() : fVar2.b, (f & 16) != 0 ? wVar4.f() : fVar2.f685c, (f & 32) != 0 ? wVar4.f() : fVar2.d);
}
if (valueAt != null) {
o oVar3 = valueAt.b;
long j4 = oVar3.q;
boolean z7 = oVar3.r;
valueAt.e();
valueAt.l = true;
d.b c3 = aVar4.c(1952867444);
if (c3 == null || (i24 & 2) != 0) {
oVar3.q = j4;
oVar3.r = z7;
} else {
c.i.a.c.i2.w wVar5 = c3.b;
wVar5.D(i23);
oVar3.q = ((wVar5.f() >> 24) & 255) == 1 ? wVar5.w() : wVar5.t();
oVar3.r = true;
}
List<d.b> list2 = aVar4.f682c;
int size4 = list2.size();
int i26 = 0;
int i27 = 0;
int i28 = 0;
while (true) {
i4 = 1953658222;
if (i26 >= size4) {
break;
}
d.b bVar5 = list2.get(i26);
if (bVar5.a == 1953658222) {
c.i.a.c.i2.w wVar6 = bVar5.b;
wVar6.D(12);
int v = wVar6.v();
if (v > 0) {
i28 += v;
i27++;
}
}
i26++;
size3 = size3;
sparseArray3 = sparseArray3;
}
sparseArray = sparseArray3;
i3 = size3;
valueAt.h = 0;
valueAt.g = 0;
valueAt.f = 0;
o oVar4 = valueAt.b;
oVar4.d = i27;
oVar4.e = i28;
if (oVar4.g.length < i27) {
oVar4.f = new long[i27];
oVar4.g = new int[i27];
}
if (oVar4.h.length < i28) {
int i29 = (i28 * 125) / 100;
oVar4.h = new int[i29];
oVar4.i = new int[i29];
oVar4.j = new long[i29];
oVar4.k = new boolean[i29];
oVar4.m = new boolean[i29];
}
int i30 = 0;
int i31 = 0;
int i32 = 0;
while (i30 < size4) {
d.b bVar6 = list2.get(i30);
if (bVar6.a == i4) {
int i33 = i31 + 1;
c.i.a.c.i2.w wVar7 = bVar6.b;
wVar7.D(8);
int f2 = wVar7.f() & 16777215;
list = list2;
m mVar3 = valueAt.d.a;
i9 = size4;
o oVar5 = valueAt.b;
f fVar3 = oVar5.a;
int i34 = f0.a;
oVar5.g[i31] = wVar7.v();
long[] jArr = oVar5.f;
i8 = i25;
aVar3 = aVar4;
jArr[i31] = oVar5.b;
if ((f2 & 1) != 0) {
aVar2 = pop;
bArr4 = bArr5;
i7 = i30;
jArr[i31] = jArr[i31] + ((long) wVar7.f());
} else {
bArr4 = bArr5;
i7 = i30;
aVar2 = pop;
}
boolean z8 = (f2 & 4) != 0;
int i35 = fVar3.d;
if (z8) {
i35 = wVar7.f();
}
boolean z9 = (f2 & 256) != 0;
boolean z10 = (f2 & 512) != 0;
boolean z11 = (f2 & 1024) != 0;
boolean z12 = (f2 & 2048) != 0;
long[] jArr2 = mVar3.h;
if (jArr2 != null) {
i10 = i35;
oVar = oVar3;
if (jArr2.length == 1 && jArr2[0] == 0) {
z2 = z12;
j2 = f0.E(mVar3.i[0], 1000000, mVar3.f699c);
int[] iArr2 = oVar5.h;
int[] iArr3 = oVar5.i;
long[] jArr3 = oVar5.j;
boolean[] zArr = oVar5.k;
b bVar7 = valueAt;
boolean z13 = (mVar3.b == 2 || (i24 & 1) == 0) ? false : true;
i11 = oVar5.g[i31] + i32;
long j5 = mVar3.f699c;
int[] iArr4 = iArr3;
long j6 = oVar5.q;
i6 = i24;
i12 = i32;
while (i12 < i11) {
if (z9) {
z3 = z9;
i13 = wVar7.f();
} else {
z3 = z9;
i13 = fVar3.b;
}
a(i13);
if (z10) {
z4 = z10;
i14 = wVar7.f();
} else {
z4 = z10;
i14 = fVar3.f685c;
}
a(i14);
if (z11) {
z5 = z8;
i15 = wVar7.f();
} else if (i12 != 0 || !z8) {
z5 = z8;
i15 = fVar3.d;
} else {
z5 = z8;
i15 = i10;
}
if (z2) {
z6 = z2;
wVar = wVar7;
fVar = fVar3;
iArr4[i12] = (int) ((((long) wVar7.f()) * 1000000) / j5);
} else {
z6 = z2;
wVar = wVar7;
fVar = fVar3;
iArr4[i12] = 0;
}
jArr3[i12] = f0.E(j6, 1000000, j5) - j2;
if (!oVar5.r) {
bVar2 = bVar7;
i16 = i11;
iArr = iArr4;
jArr3[i12] = jArr3[i12] + bVar2.d.h;
} else {
iArr = iArr4;
bVar2 = bVar7;
i16 = i11;
}
iArr2[i12] = i14;
zArr[i12] = ((i15 >> 16) & 1) == 0 && (!z13 || i12 == 0);
j6 += (long) i13;
i12++;
i11 = i16;
iArr4 = iArr;
z9 = z3;
z10 = z4;
z8 = z5;
wVar7 = wVar;
fVar3 = fVar;
bVar7 = bVar2;
z2 = z6;
}
bVar = bVar7;
oVar5.q = j6;
i31 = i33;
i32 = i11;
} else {
z2 = z12;
}
} else {
i10 = i35;
z2 = z12;
oVar = oVar3;
}
j2 = 0;
int[] iArr2 = oVar5.h;
int[] iArr3 = oVar5.i;
long[] jArr3 = oVar5.j;
boolean[] zArr = oVar5.k;
b bVar7 = valueAt;
if (mVar3.b == 2) {
}
i11 = oVar5.g[i31] + i32;
long j5 = mVar3.f699c;
int[] iArr4 = iArr3;
long j6 = oVar5.q;
i6 = i24;
i12 = i32;
while (i12 < i11) {
}
bVar = bVar7;
oVar5.q = j6;
i31 = i33;
i32 = i11;
} else {
bArr4 = bArr5;
i7 = i30;
aVar2 = pop;
i6 = i24;
list = list2;
i8 = i25;
aVar3 = aVar4;
oVar = oVar3;
i9 = size4;
bVar = valueAt;
}
i30 = i7 + 1;
i4 = 1953658222;
valueAt = bVar;
list2 = list;
size4 = i9;
i25 = i8;
aVar4 = aVar3;
pop = aVar2;
bArr5 = bArr4;
oVar3 = oVar;
i24 = i6;
}
byte[] bArr6 = bArr5;
aVar = pop;
i = i24;
i2 = i25;
m mVar4 = valueAt.d.a;
f fVar4 = oVar3.a;
Objects.requireNonNull(fVar4);
n a2 = mVar4.a(fVar4.a);
d.b c4 = aVar4.c(1935763834);
if (c4 != null) {
Objects.requireNonNull(a2);
c.i.a.c.i2.w wVar8 = c4.b;
int i36 = a2.d;
wVar8.D(8);
if ((wVar8.f() & 16777215 & 1) == 1) {
wVar8.E(8);
}
int s2 = wVar8.s();
int v2 = wVar8.v();
if (v2 <= oVar3.e) {
if (s2 == 0) {
boolean[] zArr2 = oVar3.m;
i5 = 0;
for (int i37 = 0; i37 < v2; i37++) {
int s3 = wVar8.s();
i5 += s3;
zArr2[i37] = s3 > i36;
}
} else {
i5 = (s2 * v2) + 0;
Arrays.fill(oVar3.m, 0, v2, s2 > i36);
}
Arrays.fill(oVar3.m, v2, oVar3.e, false);
if (i5 > 0) {
c.i.a.c.i2.w wVar9 = oVar3.o;
byte[] bArr7 = wVar9.a;
if (bArr7.length < i5) {
bArr7 = new byte[i5];
}
wVar9.B(bArr7, i5);
oVar3.l = true;
oVar3.p = true;
}
} else {
StringBuilder M = c.d.b.a.a.M("Saiz sample count ", v2, " is greater than fragment sample count");
M.append(oVar3.e);
throw new ParserException(M.toString());
}
}
d.b c5 = aVar4.c(1935763823);
if (c5 != null) {
c.i.a.c.i2.w wVar10 = c5.b;
wVar10.D(8);
int f3 = wVar10.f();
if ((16777215 & f3 & 1) == 1) {
wVar10.E(8);
}
int v3 = wVar10.v();
if (v3 == 1) {
oVar3.f701c += ((f3 >> 24) & 255) == 0 ? wVar10.t() : wVar10.w();
} else {
throw new ParserException(c.d.b.a.a.k("Unexpected saio entry count: ", v3));
}
}
d.b c6 = aVar4.c(1936027235);
if (c6 != null) {
i(c6.b, 0, oVar3);
}
String str = a2 != null ? a2.b : null;
c.i.a.c.i2.w wVar11 = null;
c.i.a.c.i2.w wVar12 = null;
for (int i38 = 0; i38 < aVar4.f682c.size(); i38++) {
d.b bVar8 = aVar4.f682c.get(i38);
c.i.a.c.i2.w wVar13 = bVar8.b;
int i39 = bVar8.a;
if (i39 == 1935828848) {
wVar13.D(12);
if (wVar13.f() == 1936025959) {
wVar11 = wVar13;
}
} else if (i39 == 1936158820) {
wVar13.D(12);
if (wVar13.f() == 1936025959) {
wVar12 = wVar13;
}
}
}
if (!(wVar11 == null || wVar12 == null)) {
wVar11.D(8);
int f4 = (wVar11.f() >> 24) & 255;
wVar11.E(4);
if (f4 == 1) {
wVar11.E(4);
}
if (wVar11.f() == 1) {
wVar12.D(8);
int f5 = (wVar12.f() >> 24) & 255;
wVar12.E(4);
if (f5 == 1) {
if (wVar12.t() == 0) {
throw new ParserException("Variable length description in sgpd found (unsupported)");
}
} else if (f5 >= 2) {
wVar12.E(4);
}
if (wVar12.t() == 1) {
wVar12.E(1);
int s4 = wVar12.s();
int i40 = (s4 & 240) >> 4;
int i41 = s4 & 15;
boolean z14 = wVar12.s() == 1;
if (z14) {
int s5 = wVar12.s();
byte[] bArr8 = new byte[16];
System.arraycopy(wVar12.a, wVar12.b, bArr8, 0, 16);
wVar12.b += 16;
if (s5 == 0) {
int s6 = wVar12.s();
byte[] bArr9 = new byte[s6];
System.arraycopy(wVar12.a, wVar12.b, bArr9, 0, s6);
wVar12.b += s6;
bArr3 = bArr9;
} else {
bArr3 = null;
}
oVar3.l = true;
oVar3.n = new n(z14, str, s5, bArr8, i40, i41, bArr3);
}
} else {
throw new ParserException("Entry count in sgpd != 1 (unsupported).");
}
} else {
throw new ParserException("Entry count in sbgp != 1 (unsupported).");
}
}
int size5 = aVar4.f682c.size();
int i42 = 0;
while (i42 < size5) {
d.b bVar9 = aVar4.f682c.get(i42);
if (bVar9.a == 1970628964) {
c.i.a.c.i2.w wVar14 = bVar9.b;
wVar14.D(8);
bArr2 = bArr6;
System.arraycopy(wVar14.a, wVar14.b, bArr2, 0, 16);
wVar14.b += 16;
if (Arrays.equals(bArr2, a)) {
i(wVar14, 16, oVar3);
}
} else {
bArr2 = bArr6;
}
i42++;
bArr6 = bArr2;
}
bArr = bArr6;
i25 = i2 + 1;
i23 = 8;
bArr5 = bArr;
size3 = i3;
sparseArray3 = sparseArray;
pop = aVar;
i24 = i;
}
}
bArr = bArr5;
sparseArray = sparseArray3;
aVar = pop;
i = i24;
i3 = size3;
i2 = i25;
i25 = i2 + 1;
i23 = 8;
bArr5 = bArr;
size3 = i3;
sparseArray3 = sparseArray;
pop = aVar;
i24 = i;
}
DrmInitData h2 = h(pop.f682c);
gVar = this;
if (h2 != null) {
int size6 = gVar.e.size();
for (int i43 = 0; i43 < size6; i43++) {
b valueAt2 = gVar.e.valueAt(i43);
m mVar5 = valueAt2.d.a;
f fVar5 = valueAt2.b.a;
int i44 = f0.a;
n a3 = mVar5.a(fVar5.a);
DrmInitData a4 = h2.a(a3 != null ? a3.b : null);
Format.b a5 = valueAt2.d.a.f.a();
a5.n = a4;
valueAt2.a.e(a5.a());
}
}
if (gVar.v != -9223372036854775807L) {
int size7 = gVar.e.size();
for (int i45 = 0; i45 < size7; i45++) {
b valueAt3 = gVar.e.valueAt(i45);
long j7 = gVar.v;
int i46 = valueAt3.f;
while (true) {
o oVar6 = valueAt3.b;
if (i46 >= oVar6.e || oVar6.j[i46] + ((long) oVar6.i[i46]) >= j7) {
break;
}
if (oVar6.k[i46]) {
valueAt3.i = i46;
}
i46++;
}
}
gVar.v = -9223372036854775807L;
}
gVar3 = gVar;
} else {
gVar = gVar2;
if (!gVar3.m.isEmpty()) {
gVar3.m.peek().d.add(pop);
}
}
}
gVar2 = gVar;
}
c();
}
@Override // c.i.a.c.a2.h
public void release() {
}
}