package com.applovin.impl; import android.util.SparseArray; import com.applovin.impl.dp; import com.applovin.impl.f9; import com.applovin.impl.zf; import com.mbridge.msdk.playercommon.exoplayer2.C; import java.util.ArrayList; import java.util.Arrays; /* loaded from: classes.dex */ public final class ha implements q7 { private final nj a; private final boolean b; private final boolean c; private long g; private String i; private qo j; private b k; private boolean l; private boolean n; private final boolean[] h = new boolean[3]; private final yf d = new yf(7, 128); private final yf e = new yf(8, 128); private final yf f = new yf(6, 128); private long m = C.TIME_UNSET; private final bh o = new bh(); @Override // com.applovin.impl.q7 public void a(long j, int i) { if (j != C.TIME_UNSET) { this.m = j; } this.n |= (i & 2) != 0; } @Override // com.applovin.impl.q7 public void b() { } public ha(nj njVar, boolean z, boolean z2) { this.a = njVar; this.b = z; this.c = z2; } @Override // com.applovin.impl.q7 public void a(bh bhVar) { c(); int d = bhVar.d(); int e = bhVar.e(); byte[] c = bhVar.c(); this.g += bhVar.a(); this.j.a(bhVar, bhVar.a()); while (true) { int a2 = zf.a(c, d, e, this.h); if (a2 == e) { a(c, d, e); return; } int b2 = zf.b(c, a2); int i = a2 - d; if (i > 0) { a(c, d, a2); } int i2 = e - a2; long j = this.g - i2; a(j, i2, i < 0 ? -i : 0, this.m); a(j, b2, this.m); d = a2 + 3; } } private void c() { b1.b(this.j); xp.a(this.k); } @Override // com.applovin.impl.q7 public void a(m8 m8Var, dp.d dVar) { dVar.a(); this.i = dVar.b(); qo a2 = m8Var.a(dVar.c(), 2); this.j = a2; this.k = new b(a2, this.b, this.c); this.a.a(m8Var, dVar); } public static final class b { private final qo a; private final boolean b; private final boolean c; private final SparseArray d = new SparseArray(); private final SparseArray e = new SparseArray(); private final ch f; private byte[] g; private int h; private int i; private long j; private boolean k; private long l; private a m; private a n; private boolean o; private long p; private long q; private boolean r; public boolean a() { return this.c; } public b(qo qoVar, boolean z, boolean z2) { this.a = qoVar; this.b = z; this.c = z2; this.m = new a(); this.n = new a(); byte[] bArr = new byte[128]; this.g = bArr; this.f = new ch(bArr, 0, 0); b(); } public void b() { this.k = false; this.o = false; this.n.a(); } /* JADX WARN: Removed duplicated region for block: B:50:0x00fc */ /* JADX WARN: Removed duplicated region for block: B:52:0x0103 */ /* JADX WARN: Removed duplicated region for block: B:58:0x011b */ /* JADX WARN: Removed duplicated region for block: B:73:0x0153 */ /* JADX WARN: Removed duplicated region for block: B:88:0x0115 */ /* JADX WARN: Removed duplicated region for block: B:89:0x00ff */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public void a(byte[] r23, int r24, int r25) { /* Method dump skipped, instructions count: 412 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: com.applovin.impl.ha.b.a(byte[], int, int):void"); } public static final class a { private boolean a; private boolean b; private zf.b c; private int d; private int e; private int f; private int g; private boolean h; private boolean i; private boolean j; private boolean k; private int l; private int m; private int n; private int o; private int p; private a() { } public void a() { this.b = false; this.a = false; } public void a(int i) { this.e = i; this.b = true; } public void a(zf.b bVar, int i, int i2, int i3, int i4, boolean z, boolean z2, boolean z3, boolean z4, int i5, int i6, int i7, int i8, int i9) { this.c = bVar; this.d = i; this.e = i2; this.f = i3; this.g = i4; this.h = z; this.i = z2; this.j = z3; this.k = z4; this.l = i5; this.m = i6; this.n = i7; this.o = i8; this.p = i9; this.a = true; this.b = true; } public boolean b() { int i; return this.b && ((i = this.e) == 7 || i == 2); } /* JADX INFO: Access modifiers changed from: private */ public boolean a(a aVar) { int i; int i2; int i3; boolean z; if (!this.a) { return false; } if (!aVar.a) { return true; } zf.b bVar = (zf.b) b1.b(this.c); zf.b bVar2 = (zf.b) b1.b(aVar.c); return (this.f == aVar.f && this.g == aVar.g && this.h == aVar.h && (!this.i || !aVar.i || this.j == aVar.j) && (((i = this.d) == (i2 = aVar.d) || (i != 0 && i2 != 0)) && (((i3 = bVar.k) != 0 || bVar2.k != 0 || (this.m == aVar.m && this.n == aVar.n)) && ((i3 != 1 || bVar2.k != 1 || (this.o == aVar.o && this.p == aVar.p)) && (z = this.k) == aVar.k && (!z || this.l == aVar.l))))) ? false : true; } } public boolean a(long j, int i, boolean z, boolean z2) { boolean z3 = false; if (this.i == 9 || (this.c && this.n.a(this.m))) { if (z && this.o) { a(i + ((int) (j - this.j))); } this.p = this.j; this.q = this.l; this.r = false; this.o = true; } if (this.b) { z2 = this.n.b(); } boolean z4 = this.r; int i2 = this.i; if (i2 == 5 || (z2 && i2 == 1)) { z3 = true; } boolean z5 = z4 | z3; this.r = z5; return z5; } private void a(int i) { long j = this.q; if (j == C.TIME_UNSET) { return; } boolean z = this.r; this.a.a(j, z ? 1 : 0, (int) (this.j - this.p), i, null); } public void a(zf.a aVar) { this.e.append(aVar.a, aVar); } public void a(zf.b bVar) { this.d.append(bVar.d, bVar); } public void a(long j, int i, long j2) { this.i = i; this.l = j2; this.j = j; if (!this.b || i != 1) { if (!this.c) { return; } if (i != 5 && i != 1 && i != 2) { return; } } a aVar = this.m; this.m = this.n; this.n = aVar; aVar.a(); this.h = 0; this.k = true; } } private void a(long j, int i, int i2, long j2) { if (!this.l || this.k.a()) { this.d.a(i2); this.e.a(i2); if (!this.l) { if (this.d.a() && this.e.a()) { ArrayList arrayList = new ArrayList(); yf yfVar = this.d; arrayList.add(Arrays.copyOf(yfVar.d, yfVar.e)); yf yfVar2 = this.e; arrayList.add(Arrays.copyOf(yfVar2.d, yfVar2.e)); yf yfVar3 = this.d; zf.b c = zf.c(yfVar3.d, 3, yfVar3.e); yf yfVar4 = this.e; zf.a b2 = zf.b(yfVar4.d, 3, yfVar4.e); this.j.a(new f9.b().c(this.i).f("video/avc").a(o3.a(c.a, c.b, c.c)).q(c.e).g(c.f).b(c.g).a(arrayList).a()); this.l = true; this.k.a(c); this.k.a(b2); this.d.b(); this.e.b(); } } else if (this.d.a()) { yf yfVar5 = this.d; this.k.a(zf.c(yfVar5.d, 3, yfVar5.e)); this.d.b(); } else if (this.e.a()) { yf yfVar6 = this.e; this.k.a(zf.b(yfVar6.d, 3, yfVar6.e)); this.e.b(); } } if (this.f.a(i2)) { yf yfVar7 = this.f; this.o.a(this.f.d, zf.c(yfVar7.d, yfVar7.e)); this.o.f(4); this.a.a(j2, this.o); } if (this.k.a(j, i, this.l, this.n)) { this.n = false; } } private void a(byte[] bArr, int i, int i2) { if (!this.l || this.k.a()) { this.d.a(bArr, i, i2); this.e.a(bArr, i, i2); } this.f.a(bArr, i, i2); this.k.a(bArr, i, i2); } @Override // com.applovin.impl.q7 public void a() { this.g = 0L; this.n = false; this.m = C.TIME_UNSET; zf.a(this.h); this.d.b(); this.e.b(); this.f.b(); b bVar = this.k; if (bVar != null) { bVar.b(); } } private void a(long j, int i, long j2) { if (!this.l || this.k.a()) { this.d.b(i); this.e.b(i); } this.f.b(i); this.k.a(j, i, j2); } }