package com.applovin.impl; import android.util.SparseArray; import android.util.SparseBooleanArray; import android.util.SparseIntArray; import com.applovin.impl.dp; import com.applovin.impl.ij; import com.mbridge.msdk.playercommon.exoplayer2.C; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; /* loaded from: classes.dex */ public final class cp implements k8 { public static final o8 t = new o8() { // from class: com.applovin.impl.cp$$ExternalSyntheticLambda0 @Override // com.applovin.impl.o8 public final k8[] a() { k8[] c; c = cp.c(); return c; } }; private final int a; private final int b; private final List c; private final bh d; private final SparseIntArray e; private final dp.c f; private final SparseArray g; private final SparseBooleanArray h; private final SparseBooleanArray i; private final bp j; private ap k; private m8 l; private int m; private boolean n; private boolean o; private boolean p; private dp q; private int r; private int s; @Override // com.applovin.impl.k8 public void a() { } @Override // com.applovin.impl.k8 public void a(m8 m8Var) { this.l = m8Var; } public static /* synthetic */ int d(cp cpVar) { int i = cpVar.m; cpVar.m = i + 1; return i; } /* JADX INFO: Access modifiers changed from: private */ public static /* synthetic */ k8[] c() { return new k8[]{new cp()}; } public cp() { this(0); } public cp(int i) { this(1, i, 112800); } public cp(int i, int i2, int i3) { this(i, new ho(0L), new n6(i2), i3); } public class a implements gj { private final ah a = new ah(new byte[4]); @Override // com.applovin.impl.gj public void a(ho hoVar, m8 m8Var, dp.d dVar) { } public a() { } @Override // com.applovin.impl.gj public void a(bh bhVar) { if (bhVar.w() == 0 && (bhVar.w() & 128) != 0) { bhVar.g(6); int a = bhVar.a() / 4; for (int i = 0; i < a; i++) { bhVar.a(this.a, 4); int a2 = this.a.a(16); this.a.d(3); if (a2 == 0) { this.a.d(13); } else { int a3 = this.a.a(13); if (cp.this.g.get(a3) == null) { cp.this.g.put(a3, new hj(cp.this.new b(a3))); cp.d(cp.this); } } } if (cp.this.a != 2) { cp.this.g.remove(0); } } } } private boolean b(l8 l8Var) { byte[] c = this.d.c(); if (9400 - this.d.d() < 188) { int a2 = this.d.a(); if (a2 > 0) { System.arraycopy(c, this.d.d(), c, 0, a2); } this.d.a(c, a2); } while (this.d.a() < 188) { int e = this.d.e(); int a3 = l8Var.a(c, e, 9400 - e); if (a3 == -1) { return false; } this.d.e(e + a3); } return true; } private void d() { this.h.clear(); this.g.clear(); SparseArray a2 = this.f.a(); int size = a2.size(); for (int i = 0; i < size; i++) { this.g.put(a2.keyAt(i), (dp) a2.valueAt(i)); } this.g.put(0, new hj(new a())); this.q = null; } public class b implements gj { private final ah a = new ah(new byte[5]); private final SparseArray b = new SparseArray(); private final SparseIntArray c = new SparseIntArray(); private final int d; @Override // com.applovin.impl.gj public void a(ho hoVar, m8 m8Var, dp.d dVar) { } public b(int i) { this.d = i; } @Override // com.applovin.impl.gj public void a(bh bhVar) { ho hoVar; if (bhVar.w() != 2) { return; } if (cp.this.a == 1 || cp.this.a == 2 || cp.this.m == 1) { hoVar = (ho) cp.this.c.get(0); } else { hoVar = new ho(((ho) cp.this.c.get(0)).a()); cp.this.c.add(hoVar); } if ((bhVar.w() & 128) == 0) { return; } bhVar.g(1); int C = bhVar.C(); int i = 3; bhVar.g(3); bhVar.a(this.a, 2); this.a.d(3); int i2 = 13; cp.this.s = this.a.a(13); bhVar.a(this.a, 2); int i3 = 4; this.a.d(4); bhVar.g(this.a.a(12)); if (cp.this.a == 2 && cp.this.q == null) { dp.b bVar = new dp.b(21, null, null, xp.f); cp cpVar = cp.this; cpVar.q = cpVar.f.a(21, bVar); if (cp.this.q != null) { cp.this.q.a(hoVar, cp.this.l, new dp.d(C, 21, 8192)); } } this.b.clear(); this.c.clear(); int a = bhVar.a(); while (a > 0) { bhVar.a(this.a, 5); int a2 = this.a.a(8); this.a.d(i); int a3 = this.a.a(i2); this.a.d(i3); int a4 = this.a.a(12); dp.b a5 = a(bhVar, a4); if (a2 == 6 || a2 == 5) { a2 = a5.a; } a -= a4 + 5; int i4 = cp.this.a == 2 ? a2 : a3; if (!cp.this.h.get(i4)) { dp a6 = (cp.this.a == 2 && a2 == 21) ? cp.this.q : cp.this.f.a(a2, a5); if (cp.this.a != 2 || a3 < this.c.get(i4, 8192)) { this.c.put(i4, a3); this.b.put(i4, a6); } } i = 3; i3 = 4; i2 = 13; } int size = this.c.size(); for (int i5 = 0; i5 < size; i5++) { int keyAt = this.c.keyAt(i5); int valueAt = this.c.valueAt(i5); cp.this.h.put(keyAt, true); cp.this.i.put(valueAt, true); dp dpVar = (dp) this.b.valueAt(i5); if (dpVar != null) { if (dpVar != cp.this.q) { dpVar.a(hoVar, cp.this.l, new dp.d(C, keyAt, 8192)); } cp.this.g.put(valueAt, dpVar); } } if (cp.this.a == 2) { if (cp.this.n) { return; } cp.this.l.c(); cp.this.m = 0; cp.this.n = true; return; } cp.this.g.remove(this.d); cp cpVar2 = cp.this; cpVar2.m = cpVar2.a == 1 ? 0 : cp.this.m - 1; if (cp.this.m == 0) { cp.this.l.c(); cp.this.n = true; } } private dp.b a(bh bhVar, int i) { int d = bhVar.d(); int i2 = i + d; int i3 = -1; String str = null; ArrayList arrayList = null; while (bhVar.d() < i2) { int w = bhVar.w(); int d2 = bhVar.d() + bhVar.w(); if (d2 > i2) { break; } if (w == 5) { long y = bhVar.y(); if (y != 1094921523) { if (y != 1161904947) { if (y != 1094921524) { if (y == 1212503619) { i3 = 36; } } i3 = 172; } i3 = 135; } i3 = 129; } else { if (w != 106) { if (w != 122) { if (w == 127) { if (bhVar.w() != 21) { } i3 = 172; } else if (w == 123) { i3 = 138; } else if (w == 10) { str = bhVar.c(3).trim(); } else if (w == 89) { ArrayList arrayList2 = new ArrayList(); while (bhVar.d() < d2) { String trim = bhVar.c(3).trim(); int w2 = bhVar.w(); byte[] bArr = new byte[4]; bhVar.a(bArr, 0, 4); arrayList2.add(new dp.a(trim, w2, bArr)); } arrayList = arrayList2; i3 = 89; } else if (w == 111) { i3 = 257; } } i3 = 135; } i3 = 129; } bhVar.g(d2 - bhVar.d()); } bhVar.f(i2); return new dp.b(i3, str, arrayList, Arrays.copyOfRange(bhVar.c(), d, i2)); } } public cp(int i, ho hoVar, dp.c cVar, int i2) { this.f = (dp.c) b1.a(cVar); this.b = i2; this.a = i; if (i != 1 && i != 2) { ArrayList arrayList = new ArrayList(); this.c = arrayList; arrayList.add(hoVar); } else { this.c = Collections.singletonList(hoVar); } this.d = new bh(new byte[9400], 0); this.h = new SparseBooleanArray(); this.i = new SparseBooleanArray(); this.g = new SparseArray(); this.e = new SparseIntArray(); this.j = new bp(i2); this.l = m8.e; this.s = -1; d(); } private void a(long j) { if (this.o) { return; } this.o = true; if (this.j.a() != C.TIME_UNSET) { ap apVar = new ap(this.j.b(), this.j.a(), j, this.s, this.b); this.k = apVar; this.l.a(apVar.a()); return; } this.l.a(new ij.b(this.j.a())); } private int b() { int d = this.d.d(); int e = this.d.e(); int a2 = ep.a(this.d.c(), d, e); this.d.f(a2); int i = a2 + 188; if (i > e) { int i2 = this.r + (a2 - d); this.r = i2; if (this.a == 2 && i2 > 376) { throw dh.a("Cannot find sync byte. Most likely not a Transport Stream.", null); } } else { this.r = 0; } return i; } @Override // com.applovin.impl.k8 public int a(l8 l8Var, th thVar) { long a2 = l8Var.a(); if (this.n) { if (a2 != -1 && this.a != 2 && !this.j.c()) { return this.j.a(l8Var, thVar, this.s); } a(a2); if (this.p) { this.p = false; a(0L, 0L); if (l8Var.f() != 0) { thVar.a = 0L; return 1; } } ap apVar = this.k; if (apVar != null && apVar.b()) { return this.k.a(l8Var, thVar); } } if (!b(l8Var)) { return -1; } int b2 = b(); int e = this.d.e(); if (b2 > e) { return 0; } int j = this.d.j(); if ((8388608 & j) != 0) { this.d.f(b2); return 0; } int i = (4194304 & j) != 0 ? 1 : 0; int i2 = (2096896 & j) >> 8; boolean z = (j & 32) != 0; dp dpVar = (j & 16) != 0 ? (dp) this.g.get(i2) : null; if (dpVar == null) { this.d.f(b2); return 0; } if (this.a != 2) { int i3 = j & 15; int i4 = this.e.get(i2, i3 - 1); this.e.put(i2, i3); if (i4 == i3) { this.d.f(b2); return 0; } if (i3 != ((i4 + 1) & 15)) { dpVar.a(); } } if (z) { int w = this.d.w(); i |= (this.d.w() & 64) != 0 ? 2 : 0; this.d.g(w - 1); } boolean z2 = this.n; if (a(i2)) { this.d.e(b2); dpVar.a(this.d, i); this.d.e(e); } if (this.a != 2 && !z2 && this.n && a2 != -1) { this.p = true; } this.d.f(b2); return 0; } @Override // com.applovin.impl.k8 public void a(long j, long j2) { int i; ap apVar; b1.b(this.a != 2); int size = this.c.size(); for (0; i < size; i + 1) { ho hoVar = (ho) this.c.get(i); boolean z = hoVar.c() == C.TIME_UNSET; if (!z) { long a2 = hoVar.a(); if (a2 != C.TIME_UNSET) { if (a2 != 0) { if (a2 == j2) { } hoVar.d(j2); } } } else { i = z ? 0 : i + 1; hoVar.d(j2); } } if (j2 != 0 && (apVar = this.k) != null) { apVar.b(j2); } this.d.d(0); this.e.clear(); for (int i2 = 0; i2 < this.g.size(); i2++) { ((dp) this.g.valueAt(i2)).a(); } this.r = 0; } private boolean a(int i) { return this.a == 2 || this.n || !this.i.get(i, false); } /* JADX WARN: Code restructure failed: missing block: B:11:0x001e, code lost: r1 = r1 + 1; */ @Override // com.applovin.impl.k8 /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public boolean a(com.applovin.impl.l8 r7) { /* r6 = this; com.applovin.impl.bh r0 = r6.d byte[] r0 = r0.c() r1 = 940(0x3ac, float:1.317E-42) r2 = 0 r7.c(r0, r2, r1) r1 = r2 Ld: r3 = 188(0xbc, float:2.63E-43) if (r1 >= r3) goto L29 r3 = r2 L12: r4 = 5 if (r3 >= r4) goto L24 int r4 = r3 * 188 int r4 = r4 + r1 r4 = r0[r4] r5 = 71 if (r4 == r5) goto L21 int r1 = r1 + 1 goto Ld L21: int r3 = r3 + 1 goto L12 L24: r7.a(r1) r7 = 1 return r7 L29: return r2 */ throw new UnsupportedOperationException("Method not decompiled: com.applovin.impl.cp.a(com.applovin.impl.l8):boolean"); } }