package com.applovin.impl; import android.support.v4.media.session.PlaybackStateCompat; import android.util.SparseArray; import com.applovin.impl.dp; import com.applovin.impl.ij; import com.mbridge.msdk.playercommon.exoplayer2.C; import com.mbridge.msdk.playercommon.exoplayer2.extractor.ts.PsExtractor; /* loaded from: classes.dex */ public final class ii implements k8 { public static final o8 l = new o8() { // from class: com.applovin.impl.ii$$ExternalSyntheticLambda0 @Override // com.applovin.impl.o8 public final k8[] a() { k8[] b; b = ii.b(); return b; } }; private final ho a; private final SparseArray b; private final bh c; private final hi d; private boolean e; private boolean f; private boolean g; private long h; private gi i; private m8 j; private boolean k; /* JADX INFO: Access modifiers changed from: private */ public static /* synthetic */ k8[] b() { return new k8[]{new ii()}; } @Override // com.applovin.impl.k8 public void a() { } @Override // com.applovin.impl.k8 public void a(m8 m8Var) { this.j = m8Var; } public ii() { this(new ho(0L)); } public ii(ho hoVar) { this.a = hoVar; this.c = new bh(4096); this.b = new SparseArray(); this.d = new hi(); } public static final class a { private final q7 a; private final ho b; private final ah c = new ah(new byte[64]); private boolean d; private boolean e; private boolean f; private int g; private long h; public a(q7 q7Var, ho hoVar) { this.a = q7Var; this.b = hoVar; } public void c() { this.f = false; this.a.a(); } public void a(bh bhVar) { bhVar.a(this.c.a, 0, 3); this.c.c(0); a(); bhVar.a(this.c.a, 0, this.g); this.c.c(0); b(); this.a.a(this.h, 4); this.a.a(bhVar); this.a.b(); } private void b() { this.h = 0L; if (this.d) { this.c.d(4); this.c.d(1); this.c.d(1); long a = (this.c.a(3) << 30) | (this.c.a(15) << 15) | this.c.a(15); this.c.d(1); if (!this.f && this.e) { this.c.d(4); this.c.d(1); this.c.d(1); this.c.d(1); this.b.b((this.c.a(3) << 30) | (this.c.a(15) << 15) | this.c.a(15)); this.f = true; } this.h = this.b.b(a); } } private void a() { this.c.d(8); this.d = this.c.f(); this.e = this.c.f(); this.c.d(6); this.g = this.c.a(8); } } private void a(long j) { if (this.k) { return; } this.k = true; if (this.d.a() != C.TIME_UNSET) { gi giVar = new gi(this.d.b(), this.d.a(), j); this.i = giVar; this.j.a(giVar.a()); return; } this.j.a(new ij.b(this.d.a())); } @Override // com.applovin.impl.k8 public int a(l8 l8Var, th thVar) { q7 q7Var; b1.b(this.j); long a2 = l8Var.a(); if (a2 != -1 && !this.d.c()) { return this.d.a(l8Var, thVar); } a(a2); gi giVar = this.i; if (giVar != null && giVar.b()) { return this.i.a(l8Var, thVar); } l8Var.b(); long d = a2 != -1 ? a2 - l8Var.d() : -1L; if ((d != -1 && d < 4) || !l8Var.b(this.c.c(), 0, 4, true)) { return -1; } this.c.f(0); int j = this.c.j(); if (j == 441) { return -1; } if (j == 442) { l8Var.c(this.c.c(), 0, 10); this.c.f(9); l8Var.a((this.c.w() & 7) + 14); return 0; } if (j == 443) { l8Var.c(this.c.c(), 0, 2); this.c.f(0); l8Var.a(this.c.C() + 6); return 0; } if (((j & (-256)) >> 8) != 1) { l8Var.a(1); return 0; } int i = j & 255; a aVar = (a) this.b.get(i); if (!this.e) { if (aVar == null) { if (i == 189) { q7Var = new j(); this.f = true; this.h = l8Var.f(); } else if ((j & 224) == 192) { q7Var = new sf(); this.f = true; this.h = l8Var.f(); } else if ((j & PsExtractor.VIDEO_STREAM_MASK) == 224) { q7Var = new fa(); this.g = true; this.h = l8Var.f(); } else { q7Var = null; } if (q7Var != null) { q7Var.a(this.j, new dp.d(i, 256)); aVar = new a(q7Var, this.a); this.b.put(i, aVar); } } if (l8Var.f() > ((this.f && this.g) ? this.h + PlaybackStateCompat.ACTION_PLAY_FROM_URI : PlaybackStateCompat.ACTION_SET_CAPTIONING_ENABLED)) { this.e = true; this.j.c(); } } l8Var.c(this.c.c(), 0, 2); this.c.f(0); int C = this.c.C() + 6; if (aVar == null) { l8Var.a(C); } else { this.c.d(C); l8Var.d(this.c.c(), 0, C); this.c.f(6); aVar.a(this.c); bh bhVar = this.c; bhVar.e(bhVar.b()); } return 0; } /* JADX WARN: Code restructure failed: missing block: B:10:0x0027, code lost: if (r2 != r7) goto L15; */ /* JADX WARN: Code restructure failed: missing block: B:11:0x002c, code lost: r4.a.d(r7); */ /* JADX WARN: Code restructure failed: missing block: B:22:0x002a, code lost: if (r5 != false) goto L15; */ @Override // com.applovin.impl.k8 /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public void a(long r5, long r7) { /* r4 = this; com.applovin.impl.ho r5 = r4.a long r5 = r5.c() r0 = -9223372036854775807(0x8000000000000001, double:-4.9E-324) int r5 = (r5 > r0 ? 1 : (r5 == r0 ? 0 : -1)) r6 = 0 if (r5 != 0) goto L12 r5 = 1 goto L13 L12: r5 = r6 L13: if (r5 != 0) goto L2a com.applovin.impl.ho r5 = r4.a long r2 = r5.a() int r5 = (r2 > r0 ? 1 : (r2 == r0 ? 0 : -1)) if (r5 == 0) goto L31 r0 = 0 int r5 = (r2 > r0 ? 1 : (r2 == r0 ? 0 : -1)) if (r5 == 0) goto L31 int r5 = (r2 > r7 ? 1 : (r2 == r7 ? 0 : -1)) if (r5 == 0) goto L31 goto L2c L2a: if (r5 == 0) goto L31 L2c: com.applovin.impl.ho r5 = r4.a r5.d(r7) L31: com.applovin.impl.gi r5 = r4.i if (r5 == 0) goto L38 r5.b(r7) L38: android.util.SparseArray r5 = r4.b int r5 = r5.size() if (r6 >= r5) goto L4e android.util.SparseArray r5 = r4.b java.lang.Object r5 = r5.valueAt(r6) com.applovin.impl.ii$a r5 = (com.applovin.impl.ii.a) r5 r5.c() int r6 = r6 + 1 goto L38 L4e: return */ throw new UnsupportedOperationException("Method not decompiled: com.applovin.impl.ii.a(long, long):void"); } @Override // com.applovin.impl.k8 public boolean a(l8 l8Var) { byte[] bArr = new byte[14]; l8Var.c(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; } l8Var.c(bArr[13] & 7); l8Var.c(bArr, 0, 3); return 1 == ((((bArr[0] & 255) << 16) | ((bArr[1] & 255) << 8)) | (bArr[2] & 255)); } }