package c.i.a.c.a2.j0; import android.util.SparseArray; import android.util.SparseBooleanArray; import android.util.SparseIntArray; 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.f0; import c.i.a.c.i2.v; import c.i.a.c.i2.w; import com.airbnb.lottie.parser.AnimatableValueParser; import com.google.android.exoplayer2.ParserException; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; /* compiled from: TsExtractor */ public final class h0 implements h { public final int a; public final int b; /* renamed from: c reason: collision with root package name */ public final List f722c; public final w d; public final SparseIntArray e; public final i0.c f; public final SparseArray g; public final SparseBooleanArray h; public final SparseBooleanArray i; public final g0 j; public f0 k; public j l; public int m; public boolean n; public boolean o; public boolean p; public i0 q; public int r; /* renamed from: s reason: collision with root package name */ public int f723s; /* compiled from: TsExtractor */ public class a implements c0 { public final v a = new v(new byte[4]); public a() { } @Override // c.i.a.c.a2.j0.c0 public void a(e0 e0Var, j jVar, i0.d dVar) { } @Override // c.i.a.c.a2.j0.c0 public void b(w wVar) { if (wVar.s() == 0 && (wVar.s() & 128) != 0) { wVar.E(6); int a = wVar.a() / 4; for (int i = 0; i < a; i++) { wVar.d(this.a, 4); int g = this.a.g(16); this.a.m(3); if (g == 0) { this.a.m(13); } else { int g2 = this.a.g(13); if (h0.this.g.get(g2) == null) { h0 h0Var = h0.this; h0Var.g.put(g2, new d0(new b(g2))); h0.this.m++; } } } h0 h0Var2 = h0.this; if (h0Var2.a != 2) { h0Var2.g.remove(0); } } } } /* compiled from: TsExtractor */ public class b implements c0 { public final v a = new v(new byte[5]); public final SparseArray b = new SparseArray<>(); /* renamed from: c reason: collision with root package name */ public final SparseIntArray f724c = new SparseIntArray(); public final int d; public b(int i) { this.d = i; } @Override // c.i.a.c.a2.j0.c0 public void a(e0 e0Var, j jVar, i0.d dVar) { } /* JADX WARNING: Code restructure failed: missing block: B:46:0x013d, code lost: if (r24.s() == r13) goto L_0x013f; */ /* JADX WARNING: Removed duplicated region for block: B:87:0x0222 */ /* JADX WARNING: Removed duplicated region for block: B:89:0x022f */ @Override // c.i.a.c.a2.j0.c0 public void b(w wVar) { e0 e0Var; int i; e0 e0Var2; i0 i0Var; int i2; int i3; int i4; e0 e0Var3; if (wVar.s() == 2) { h0 h0Var = h0.this; int i5 = h0Var.a; if (i5 == 1 || i5 == 2 || h0Var.m == 1) { e0Var = h0Var.f722c.get(0); } else { e0Var = new e0(h0Var.f722c.get(0).c()); h0.this.f722c.add(e0Var); } if ((wVar.s() & 128) != 0) { wVar.E(1); int x2 = wVar.x(); int i6 = 3; wVar.E(3); wVar.d(this.a, 2); this.a.m(3); int i7 = 13; h0.this.f723s = this.a.g(13); wVar.d(this.a, 2); int i8 = 4; this.a.m(4); int i9 = 12; wVar.E(this.a.g(12)); h0 h0Var2 = h0.this; int i10 = 21; if (h0Var2.a == 2 && h0Var2.q == null) { i0.b bVar = new i0.b(21, null, null, f0.f); h0 h0Var3 = h0.this; h0Var3.q = h0Var3.f.a(21, bVar); h0 h0Var4 = h0.this; h0Var4.q.a(e0Var, h0Var4.l, new i0.d(x2, 21, 8192)); } this.b.clear(); this.f724c.clear(); int a = wVar.a(); while (a > 0) { int i11 = 5; wVar.d(this.a, 5); int g = this.a.g(8); this.a.m(i6); int g2 = this.a.g(i7); this.a.m(i8); int g3 = this.a.g(i9); int i12 = wVar.b; int i13 = g3 + i12; int i14 = -1; String str = null; ArrayList arrayList = null; while (wVar.b < i13) { int s2 = wVar.s(); int s3 = wVar.b + wVar.s(); if (s3 > i13) { break; } if (s2 == i11) { long t = wVar.t(); if (t != 1094921523) { if (t != 1161904947) { if (t != 1094921524) { if (t == 1212503619) { i14 = 36; } i4 = x2; e0Var3 = e0Var; i3 = g2; wVar.E(s3 - wVar.b); e0Var = e0Var3; x2 = i4; g2 = i3; i11 = 5; i10 = 21; } i14 = 172; i4 = x2; e0Var3 = e0Var; i3 = g2; wVar.E(s3 - wVar.b); e0Var = e0Var3; x2 = i4; g2 = i3; i11 = 5; i10 = 21; } i14 = 135; i4 = x2; e0Var3 = e0Var; i3 = g2; wVar.E(s3 - wVar.b); e0Var = e0Var3; x2 = i4; g2 = i3; i11 = 5; i10 = 21; } } else if (s2 != 106) { if (s2 != 122) { if (s2 != 127) { if (s2 == 123) { i14 = 138; } else if (s2 == 10) { str = wVar.p(3).trim(); i4 = x2; e0Var3 = e0Var; i3 = g2; wVar.E(s3 - wVar.b); e0Var = e0Var3; x2 = i4; g2 = i3; i11 = 5; i10 = 21; } else { int i15 = 3; if (s2 == 89) { ArrayList arrayList2 = new ArrayList(); while (wVar.b < s3) { String trim = wVar.p(i15).trim(); int s4 = wVar.s(); byte[] bArr = new byte[4]; System.arraycopy(wVar.a, wVar.b, bArr, 0, 4); wVar.b += 4; arrayList2.add(new i0.a(trim, s4, bArr)); e0Var = e0Var; x2 = x2; g2 = g2; i15 = 3; } i4 = x2; e0Var3 = e0Var; i3 = g2; arrayList = arrayList2; i14 = 89; } else { i4 = x2; e0Var3 = e0Var; i3 = g2; if (s2 == 111) { i14 = 257; } } wVar.E(s3 - wVar.b); e0Var = e0Var3; x2 = i4; g2 = i3; i11 = 5; i10 = 21; } } i4 = x2; e0Var3 = e0Var; i3 = g2; wVar.E(s3 - wVar.b); e0Var = e0Var3; x2 = i4; g2 = i3; i11 = 5; i10 = 21; } i14 = 135; i4 = x2; e0Var3 = e0Var; i3 = g2; wVar.E(s3 - wVar.b); e0Var = e0Var3; x2 = i4; g2 = i3; i11 = 5; i10 = 21; } i14 = 129; i4 = x2; e0Var3 = e0Var; i3 = g2; wVar.E(s3 - wVar.b); e0Var = e0Var3; x2 = i4; g2 = i3; i11 = 5; i10 = 21; } wVar.D(i13); i0.b bVar2 = new i0.b(i14, str, arrayList, Arrays.copyOfRange(wVar.a, i12, i13)); if (g == 6 || g == 5) { g = i14; } a -= g3 + 5; h0 h0Var5 = h0.this; int i16 = h0Var5.a == 2 ? g : g2; if (!h0Var5.h.get(i16)) { h0 h0Var6 = h0.this; if (h0Var6.a == 2) { if (g == 21) { i0Var = h0Var6.q; if (h0.this.a != 2) { i2 = g2; if (i2 >= this.f724c.get(i16, 8192)) { } } else { i2 = g2; } this.f724c.put(i16, i2); this.b.put(i16, i0Var); } } i0Var = h0Var6.f.a(g, bVar2); if (h0.this.a != 2) { } this.f724c.put(i16, i2); this.b.put(i16, i0Var); } e0Var = e0Var; x2 = x2; i6 = 3; i8 = 4; i7 = 13; i9 = 12; i10 = 21; } int i17 = x2; e0 e0Var4 = e0Var; int size = this.f724c.size(); int i18 = 0; while (i18 < size) { int keyAt = this.f724c.keyAt(i18); int valueAt = this.f724c.valueAt(i18); h0.this.h.put(keyAt, true); h0.this.i.put(valueAt, true); i0 valueAt2 = this.b.valueAt(i18); if (valueAt2 != null) { h0 h0Var7 = h0.this; if (valueAt2 != h0Var7.q) { j jVar = h0Var7.l; i = i17; i0.d dVar = new i0.d(i, keyAt, 8192); e0Var2 = e0Var4; valueAt2.a(e0Var2, jVar, dVar); } else { e0Var2 = e0Var4; i = i17; } h0.this.g.put(valueAt, valueAt2); } else { e0Var2 = e0Var4; i = i17; } i18++; e0Var4 = e0Var2; i17 = i; } h0 h0Var8 = h0.this; if (h0Var8.a != 2) { h0Var8.g.remove(this.d); h0 h0Var9 = h0.this; int i19 = h0Var9.a == 1 ? 0 : h0Var9.m - 1; h0Var9.m = i19; if (i19 == 0) { h0Var9.l.j(); h0.this.n = true; } } else if (!h0Var8.n) { h0Var8.l.j(); h0 h0Var10 = h0.this; h0Var10.m = 0; h0Var10.n = true; } } } } } static { e eVar = e.a; } public h0(int i, int i2, int i3) { e0 e0Var = new e0(0); l lVar = new l(i2); this.f = lVar; this.b = i3; this.a = i; if (i == 1 || i == 2) { this.f722c = Collections.singletonList(e0Var); } else { ArrayList arrayList = new ArrayList(); this.f722c = arrayList; arrayList.add(e0Var); } this.d = new w(new byte[9400], 0); SparseBooleanArray sparseBooleanArray = new SparseBooleanArray(); this.h = sparseBooleanArray; this.i = new SparseBooleanArray(); SparseArray sparseArray = new SparseArray<>(); this.g = sparseArray; this.e = new SparseIntArray(); this.j = new g0(i3); this.f723s = -1; sparseBooleanArray.clear(); sparseArray.clear(); SparseArray b2 = lVar.b(); int size = b2.size(); for (int i4 = 0; i4 < size; i4++) { this.g.put(b2.keyAt(i4), b2.valueAt(i4)); } this.g.put(0, new d0(new a())); this.q = null; } @Override // c.i.a.c.a2.h public boolean b(i iVar) throws IOException { boolean z2; byte[] bArr = this.d.a; iVar.n(bArr, 0, 940); for (int i = 0; i < 188; i++) { int i2 = 0; while (true) { if (i2 >= 5) { z2 = true; break; } else if (bArr[(i2 * 188) + i] != 71) { z2 = false; break; } else { i2++; } } if (z2) { iVar.l(i); return true; } } return false; } /* JADX DEBUG: Multi-variable search result rejected for r9v4, resolved type: android.util.SparseBooleanArray */ /* JADX WARN: Multi-variable type inference failed */ /* JADX WARNING: Unknown variable types count: 2 */ @Override // c.i.a.c.a2.h public int e(i iVar, s sVar) throws IOException { ?? r4; ?? r3; int i; boolean z2; int i2; boolean z3; long b2 = iVar.b(); if (this.n) { long j = -9223372036854775807L; if ((b2 == -1 || this.a == 2) ? false : true) { g0 g0Var = this.j; if (!g0Var.d) { int i3 = this.f723s; if (i3 <= 0) { g0Var.a(iVar); return 0; } if (!g0Var.f) { long b3 = iVar.b(); int min = (int) Math.min((long) g0Var.a, b3); long j2 = b3 - ((long) min); if (iVar.getPosition() != j2) { sVar.a = j2; } else { g0Var.f720c.z(min); iVar.k(); iVar.n(g0Var.f720c.a, 0, min); w wVar = g0Var.f720c; int i4 = wVar.b; int i5 = wVar.f913c; while (true) { i5--; if (i5 < i4) { break; } else if (wVar.a[i5] == 71) { long l2 = AnimatableValueParser.l2(wVar, i5, i3); if (l2 != -9223372036854775807L) { j = l2; break; } } } g0Var.h = j; g0Var.f = true; return 0; } } else if (g0Var.h == -9223372036854775807L) { g0Var.a(iVar); return 0; } else if (!g0Var.e) { int min2 = (int) Math.min((long) g0Var.a, iVar.b()); long j3 = (long) 0; if (iVar.getPosition() != j3) { sVar.a = j3; } else { g0Var.f720c.z(min2); iVar.k(); iVar.n(g0Var.f720c.a, 0, min2); w wVar2 = g0Var.f720c; int i6 = wVar2.b; int i7 = wVar2.f913c; while (true) { if (i6 >= i7) { break; } if (wVar2.a[i6] == 71) { long l22 = AnimatableValueParser.l2(wVar2, i6, i3); if (l22 != -9223372036854775807L) { j = l22; break; } } i6++; } g0Var.g = j; g0Var.e = true; return 0; } } else { long j4 = g0Var.g; if (j4 == -9223372036854775807L) { g0Var.a(iVar); return 0; } g0Var.i = g0Var.b.b(g0Var.h) - g0Var.b.b(j4); g0Var.a(iVar); return 0; } return 1; } } if (!this.o) { this.o = true; g0 g0Var2 = this.j; long j5 = g0Var2.i; if (j5 != -9223372036854775807L) { f0 f0Var = new f0(g0Var2.b, j5, b2, this.f723s, this.b); this.k = f0Var; this.l.a(f0Var.a); } else { this.l.a(new t.b(j5, 0)); } } if (this.p) { z3 = false; this.p = false; g(0, 0); if (iVar.getPosition() != 0) { sVar.a = 0; return 1; } } else { z3 = false; } r4 = 1; r4 = 1; f0 f0Var2 = this.k; r3 = z3; if (f0Var2 != null) { r3 = z3; if (f0Var2.b()) { return this.k.a(iVar, sVar); } } } else { r3 = 0; r4 = 1; } w wVar3 = this.d; byte[] bArr = wVar3.a; if (9400 - wVar3.b < 188) { int a2 = wVar3.a(); if (a2 > 0) { System.arraycopy(bArr, this.d.b, bArr, r3, a2); } this.d.B(bArr, a2); } while (true) { if (this.d.a() >= 188) { i = -1; z2 = true; break; } int i8 = this.d.f913c; int read = iVar.read(bArr, i8, 9400 - i8); i = -1; if (read == -1) { z2 = false; break; } this.d.C(i8 + read); } if (!z2) { return i; } w wVar4 = this.d; int i9 = wVar4.b; int i10 = wVar4.f913c; byte[] bArr2 = wVar4.a; int i11 = i9; while (i11 < i10 && bArr2[i11] != 71) { i11++; } this.d.D(i11); int i12 = i11 + 188; if (i12 > i10) { int i13 = (i11 - i9) + this.r; this.r = i13; i2 = 2; if (this.a == 2 && i13 > 376) { throw new ParserException("Cannot find sync byte. Most likely not a Transport Stream."); } } else { i2 = 2; this.r = r3; } w wVar5 = this.d; int i14 = wVar5.f913c; if (i12 > i14) { return r3; } int f = wVar5.f(); if ((8388608 & f) != 0) { this.d.D(i12); return r3; } int i15 = (4194304 & f) != 0 ? 1 : 0; int i16 = r3 == true ? 1 : 0; boolean z4 = r3 == true ? 1 : 0; boolean z5 = r3 == true ? 1 : 0; boolean z6 = r3 == true ? 1 : 0; boolean z7 = r3 == true ? 1 : 0; int i17 = i15 | i16; int i18 = (2096896 & f) >> 8; boolean z8 = (f & 32) != 0; i0 i0Var = (f & 16) != 0 ? this.g.get(i18) : null; if (i0Var == null) { this.d.D(i12); return r3; } if (this.a != i2) { int i19 = f & 15; int i20 = this.e.get(i18, i19 - 1); this.e.put(i18, i19); if (i20 == i19) { this.d.D(i12); return r3; } else if (i19 != ((i20 + r4) & 15)) { i0Var.c(); } } if (z8) { int s2 = this.d.s(); i17 |= (this.d.s() & 64) != 0 ? 2 : 0; w wVar6 = this.d; int i21 = r4 == true ? 1 : 0; int i22 = r4 == true ? 1 : 0; int i23 = r4 == true ? 1 : 0; int i24 = r4 == true ? 1 : 0; wVar6.E(s2 - i21); } boolean z9 = this.n; if (this.a == i2 || z9 || !this.i.get(i18, r3)) { this.d.C(i12); i0Var.b(this.d, i17); this.d.C(i14); } if (this.a != i2 && !z9 && this.n && b2 != -1) { this.p = r4; } this.d.D(i12); int i25 = r3 == true ? 1 : 0; int i26 = r3 == true ? 1 : 0; int i27 = r3 == true ? 1 : 0; int i28 = r3 == true ? 1 : 0; int i29 = r3 == true ? 1 : 0; return i25; } @Override // c.i.a.c.a2.h public void f(j jVar) { this.l = jVar; } @Override // c.i.a.c.a2.h public void g(long j, long j2) { f0 f0Var; AnimatableValueParser.D(this.a != 2); int size = this.f722c.size(); for (int i = 0; i < size; i++) { e0 e0Var = this.f722c.get(i); if ((e0Var.d() == -9223372036854775807L) || !(e0Var.d() == 0 || e0Var.c() == j2)) { synchronized (e0Var) { e0Var.a = j2; e0Var.f903c = -9223372036854775807L; } } } if (!(j2 == 0 || (f0Var = this.k) == null)) { f0Var.e(j2); } this.d.z(0); this.e.clear(); for (int i2 = 0; i2 < this.g.size(); i2++) { this.g.valueAt(i2).c(); } this.r = 0; } @Override // c.i.a.c.a2.h public void release() { } }