package com.applovin.impl; import android.util.Pair; import com.applovin.exoplayer2.common.base.Function; import com.applovin.impl.bf; import com.applovin.impl.f9; import com.applovin.impl.j1; import com.mbridge.msdk.playercommon.exoplayer2.C; import com.mbridge.msdk.playercommon.exoplayer2.extractor.ts.PsExtractor; import com.mbridge.msdk.playercommon.exoplayer2.util.MimeTypes; import java.util.ArrayList; import java.util.Arrays; import java.util.List; /* loaded from: classes.dex */ abstract class k1 { private static final byte[] a = xp.c("OpusHead"); public interface b { int a(); int b(); int c(); } private static int a(int i) { if (i == 1936684398) { return 1; } if (i == 1986618469) { return 2; } if (i == 1952807028 || i == 1935832172 || i == 1937072756 || i == 1668047728) { return 3; } return i == 1835365473 ? 5 : -1; } private static long e(bh bhVar) { bhVar.f(8); bhVar.g(j1.c(bhVar.j()) != 0 ? 16 : 8); return bhVar.y(); } private static f f(bh bhVar) { long j; bhVar.f(8); int c2 = j1.c(bhVar.j()); bhVar.g(c2 == 0 ? 8 : 16); int j2 = bhVar.j(); bhVar.g(4); int d2 = bhVar.d(); int i = c2 == 0 ? 4 : 8; int i2 = 0; int i3 = 0; while (true) { j = C.TIME_UNSET; if (i3 < i) { if (bhVar.c()[d2 + i3] != -1) { long y = c2 == 0 ? bhVar.y() : bhVar.B(); if (y != 0) { j = y; } } else { i3++; } } else { bhVar.g(i); break; } } bhVar.g(16); int j3 = bhVar.j(); int j4 = bhVar.j(); bhVar.g(4); int j5 = bhVar.j(); int j6 = bhVar.j(); if (j3 == 0 && j4 == 65536 && j5 == -65536 && j6 == 0) { i2 = 90; } else if (j3 == 0 && j4 == -65536 && j5 == 65536 && j6 == 0) { i2 = 270; } else if (j3 == -65536 && j4 == 0 && j5 == 0 && j6 == -65536) { i2 = 180; } return new f(j2, j, i2); } private static int c(bh bhVar) { bhVar.f(16); return bhVar.j(); } private static Pair d(bh bhVar) { bhVar.f(8); int c2 = j1.c(bhVar.j()); bhVar.g(c2 == 0 ? 8 : 16); long y = bhVar.y(); bhVar.g(c2 == 0 ? 4 : 8); int C = bhVar.C(); return Pair.create(Long.valueOf(y), "" + ((char) (((C >> 10) & 31) + 96)) + ((char) (((C >> 5) & 31) + 96)) + ((char) ((C & 31) + 96))); } private static bf e(bh bhVar, int i) { bhVar.g(8); a(bhVar); while (bhVar.d() < i) { int d2 = bhVar.d(); int j = bhVar.j(); if (bhVar.j() == 1768715124) { bhVar.f(d2); return b(bhVar, d2 + j); } bhVar.f(d2 + j); } return null; } public static Pair b(bh bhVar, int i, int i2) { int i3 = i + 8; int i4 = -1; int i5 = 0; String str = null; Integer num = null; while (i3 - i < i2) { bhVar.f(i3); int j = bhVar.j(); int j2 = bhVar.j(); if (j2 == 1718775137) { num = Integer.valueOf(bhVar.j()); } else if (j2 == 1935894637) { bhVar.g(4); str = bhVar.c(4); } else if (j2 == 1935894633) { i4 = i3; i5 = j; } i3 += j; } if (!C.CENC_TYPE_cenc.equals(str) && !C.CENC_TYPE_cbc1.equals(str) && !C.CENC_TYPE_cens.equals(str) && !C.CENC_TYPE_cbcs.equals(str)) { return null; } n8.a(num != null, "frma atom is mandatory"); n8.a(i4 != -1, "schi atom is mandatory"); mo a2 = a(bhVar, i4, i5, str); n8.a(a2 != null, "tenc atom is mandatory"); return Pair.create(num, (mo) xp.a(a2)); } private static boolean a(long[] jArr, long j, long j2, long j3) { int length = jArr.length - 1; return jArr[0] <= j2 && j2 < jArr[xp.a(4, 0, length)] && jArr[xp.a(jArr.length - 4, 0, length)] < j3 && j3 <= j; } public static final class a { public final int a; public int b; public int c; public long d; private final boolean e; private final bh f; private final bh g; private int h; private int i; public a(bh bhVar, bh bhVar2, boolean z) { this.g = bhVar; this.f = bhVar2; this.e = z; bhVar2.f(12); this.a = bhVar2.A(); bhVar.f(12); this.i = bhVar.A(); n8.a(bhVar.j() == 1, "first_chunk must be 1"); this.b = -1; } public boolean a() { long y; int i = this.b + 1; this.b = i; if (i == this.a) { return false; } if (this.e) { y = this.f.B(); } else { y = this.f.y(); } this.d = y; if (this.b == this.h) { this.c = this.g.A(); this.g.g(4); int i2 = this.i - 1; this.i = i2; this.h = i2 > 0 ? this.g.A() - 1 : -1; } return true; } } public static final class f { private final int a; private final long b; private final int c; public f(int i, long j, int i2) { this.a = i; this.b = j; this.c = i2; } } public static final class c { public final mo[] a; public f9 b; public int c; public int d = 0; public c(int i) { this.a = new mo[i]; } } public static final class d implements b { private final int a; private final int b; private final bh c; @Override // com.applovin.impl.k1.b public int a() { return this.a; } @Override // com.applovin.impl.k1.b public int b() { return this.b; } public d(j1.b bVar, f9 f9Var) { bh bhVar = bVar.b; this.c = bhVar; bhVar.f(12); int A = bhVar.A(); if (MimeTypes.AUDIO_RAW.equals(f9Var.m)) { int b = xp.b(f9Var.B, f9Var.z); if (A == 0 || A % b != 0) { pc.d("AtomParsers", "Audio sample size mismatch. stsd sample size: " + b + ", stsz sample size: " + A); A = b; } } this.a = A == 0 ? -1 : A; this.b = bhVar.A(); } @Override // com.applovin.impl.k1.b public int c() { int i = this.a; return i == -1 ? this.c.A() : i; } } public static final class e implements b { private final bh a; private final int b; private final int c; private int d; private int e; @Override // com.applovin.impl.k1.b public int a() { return -1; } @Override // com.applovin.impl.k1.b public int b() { return this.b; } public e(j1.b bVar) { bh bhVar = bVar.b; this.a = bhVar; bhVar.f(12); this.c = bhVar.A() & 255; this.b = bhVar.A(); } @Override // com.applovin.impl.k1.b public int c() { int i = this.c; if (i == 8) { return this.a.w(); } if (i == 16) { return this.a.C(); } int i2 = this.d; this.d = i2 + 1; if (i2 % 2 != 0) { return this.e & 15; } int w = this.a.w(); this.e = w; return (w & PsExtractor.VIDEO_STREAM_MASK) >> 4; } } private static float c(bh bhVar, int i) { bhVar.f(i + 8); return bhVar.A() / bhVar.A(); } private static Pair d(bh bhVar, int i, int i2) { Pair b2; int d2 = bhVar.d(); while (d2 - i < i2) { bhVar.f(d2); int j = bhVar.j(); n8.a(j > 0, "childAtomSize must be positive"); if (bhVar.j() == 1936289382 && (b2 = b(bhVar, d2, j)) != null) { return b2; } d2 += j; } return null; } private static int a(bh bhVar, int i, int i2) { int d2 = bhVar.d(); while (d2 - i < i2) { bhVar.f(d2); int j = bhVar.j(); n8.a(j > 0, "childAtomSize must be positive"); if (bhVar.j() == 1702061171) { return d2; } d2 += j; } return -1; } private static bf d(bh bhVar, int i) { bhVar.g(12); while (bhVar.d() < i) { int d2 = bhVar.d(); int j = bhVar.j(); if (bhVar.j() == 1935766900) { if (j < 14) { return null; } bhVar.g(5); int w = bhVar.w(); if (w != 12 && w != 13) { return null; } float f2 = w == 12 ? 240.0f : 120.0f; bhVar.g(1); return new bf(new kk(f2, bhVar.w())); } bhVar.f(d2 + j); } return null; } private static int b(bh bhVar) { int w = bhVar.w(); int i = w & 127; while ((w & 128) == 128) { w = bhVar.w(); i = (i << 7) | (w & 127); } return i; } public static void a(bh bhVar) { int d2 = bhVar.d(); bhVar.g(4); if (bhVar.j() != 1751411826) { d2 += 4; } bhVar.f(d2); } private static byte[] c(bh bhVar, int i, int i2) { int i3 = i + 8; while (i3 - i < i2) { bhVar.f(i3); int j = bhVar.j(); if (bhVar.j() == 1886547818) { return Arrays.copyOfRange(bhVar.c(), i3, j + i3); } i3 += j; } return null; } private static bf b(bh bhVar, int i) { bhVar.g(8); ArrayList arrayList = new ArrayList(); while (bhVar.d() < i) { bf.b b2 = hf.b(bhVar); if (b2 != null) { arrayList.add(b2); } } if (arrayList.isEmpty()) { return null; } return new bf(arrayList); } public static bf b(j1.a aVar) { j1.b e2 = aVar.e(1751411826); j1.b e3 = aVar.e(1801812339); j1.b e4 = aVar.e(1768715124); if (e2 == null || e3 == null || e4 == null || c(e2.b) != 1835299937) { return null; } bh bhVar = e3.b; bhVar.f(12); int j = bhVar.j(); String[] strArr = new String[j]; for (int i = 0; i < j; i++) { int j2 = bhVar.j(); bhVar.g(4); strArr[i] = bhVar.c(j2 - 8); } bh bhVar2 = e4.b; bhVar2.f(8); ArrayList arrayList = new ArrayList(); while (bhVar2.a() > 8) { int d2 = bhVar2.d(); int j3 = bhVar2.j(); int j4 = bhVar2.j() - 1; if (j4 >= 0 && j4 < j) { fd a2 = hf.a(bhVar2, d2 + j3, strArr[j4]); if (a2 != null) { arrayList.add(a2); } } else { pc.d("AtomParsers", "Skipped metadata with unknown key index: " + j4); } bhVar2.f(d2 + j3); } if (arrayList.isEmpty()) { return null; } return new bf(arrayList); } /* JADX WARN: Removed duplicated region for block: B:25:0x0151 */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ private static void a(com.applovin.impl.bh r20, int r21, int r22, int r23, int r24, java.lang.String r25, boolean r26, com.applovin.impl.y6 r27, com.applovin.impl.k1.c r28, int r29) { /* Method dump skipped, instructions count: 762 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: com.applovin.impl.k1.a(com.applovin.impl.bh, int, int, int, int, java.lang.String, boolean, com.applovin.impl.y6, com.applovin.impl.k1$c, int):void"); } private static Pair a(j1.a aVar) { j1.b e2 = aVar.e(1701606260); if (e2 == null) { return null; } bh bhVar = e2.b; bhVar.f(8); int c2 = j1.c(bhVar.j()); int A = bhVar.A(); long[] jArr = new long[A]; long[] jArr2 = new long[A]; for (int i = 0; i < A; i++) { jArr[i] = c2 == 1 ? bhVar.B() : bhVar.y(); jArr2[i] = c2 == 1 ? bhVar.s() : bhVar.j(); if (bhVar.u() == 1) { bhVar.g(2); } else { throw new IllegalArgumentException("Unsupported media rate."); } } return Pair.create(jArr, jArr2); } private static Pair a(bh bhVar, int i) { bhVar.f(i + 12); bhVar.g(1); b(bhVar); bhVar.g(2); int w = bhVar.w(); if ((w & 128) != 0) { bhVar.g(2); } if ((w & 64) != 0) { bhVar.g(bhVar.C()); } if ((w & 32) != 0) { bhVar.g(2); } bhVar.g(1); b(bhVar); String a2 = Cif.a(bhVar.w()); if (!MimeTypes.AUDIO_MPEG.equals(a2) && !MimeTypes.AUDIO_DTS.equals(a2) && !MimeTypes.AUDIO_DTS_HD.equals(a2)) { bhVar.g(12); bhVar.g(1); int b2 = b(bhVar); byte[] bArr = new byte[b2]; bhVar.a(bArr, 0, b2); return Pair.create(a2, bArr); } return Pair.create(a2, null); } private static void a(bh bhVar, int i, int i2, int i3, c cVar) { bhVar.f(i2 + 16); if (i == 1835365492) { bhVar.t(); String t = bhVar.t(); if (t != null) { cVar.b = new f9.b().h(i3).f(t).a(); } } } private static mo a(bh bhVar, int i, int i2, String str) { int i3; int i4; int i5 = i + 8; while (true) { byte[] bArr = null; if (i5 - i >= i2) { return null; } bhVar.f(i5); int j = bhVar.j(); if (bhVar.j() == 1952804451) { int c2 = j1.c(bhVar.j()); bhVar.g(1); if (c2 == 0) { bhVar.g(1); i4 = 0; i3 = 0; } else { int w = bhVar.w(); i3 = w & 15; i4 = (w & PsExtractor.VIDEO_STREAM_MASK) >> 4; } boolean z = bhVar.w() == 1; int w2 = bhVar.w(); byte[] bArr2 = new byte[16]; bhVar.a(bArr2, 0, 16); if (z && w2 == 0) { int w3 = bhVar.w(); bArr = new byte[w3]; bhVar.a(bArr, 0, w3); } return new mo(z, str, w2, bArr2, i4, i3, bArr); } i5 += j; } } /* JADX WARN: Removed duplicated region for block: B:100:0x0435 */ /* JADX WARN: Removed duplicated region for block: B:103:0x043c */ /* JADX WARN: Removed duplicated region for block: B:105:0x0442 */ /* JADX WARN: Removed duplicated region for block: B:107:0x0448 */ /* JADX WARN: Removed duplicated region for block: B:109:0x044e */ /* JADX WARN: Removed duplicated region for block: B:113:0x0460 */ /* JADX WARN: Removed duplicated region for block: B:133:0x0451 */ /* JADX WARN: Removed duplicated region for block: B:134:0x044a */ /* JADX WARN: Removed duplicated region for block: B:135:0x0445 */ /* JADX WARN: Removed duplicated region for block: B:136:0x043f */ /* JADX WARN: Removed duplicated region for block: B:137:0x0437 */ /* JADX WARN: Removed duplicated region for block: B:138:0x03b5 */ /* JADX WARN: Removed duplicated region for block: B:74:0x03b3 */ /* JADX WARN: Removed duplicated region for block: B:78:0x03cd */ /* JADX WARN: Removed duplicated region for block: B:97:0x042b A[EDGE_INSN: B:97:0x042b->B:98:0x042b BREAK A[LOOP:2: B:76:0x03c8->B:92:0x0423], SYNTHETIC] */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ private static com.applovin.impl.ro a(com.applovin.impl.lo r38, com.applovin.impl.j1.a r39, com.applovin.impl.z9 r40) { /* Method dump skipped, instructions count: 1303 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: com.applovin.impl.k1.a(com.applovin.impl.lo, com.applovin.impl.j1$a, com.applovin.impl.z9):com.applovin.impl.ro"); } private static c a(bh bhVar, int i, int i2, String str, y6 y6Var, boolean z) { int i3; bhVar.f(12); int j = bhVar.j(); c cVar = new c(j); for (int i4 = 0; i4 < j; i4++) { int d2 = bhVar.d(); int j2 = bhVar.j(); n8.a(j2 > 0, "childAtomSize must be positive"); int j3 = bhVar.j(); if (j3 == 1635148593 || j3 == 1635148595 || j3 == 1701733238 || j3 == 1831958048 || j3 == 1836070006 || j3 == 1752589105 || j3 == 1751479857 || j3 == 1932670515 || j3 == 1211250227 || j3 == 1987063864 || j3 == 1987063865 || j3 == 1635135537 || j3 == 1685479798 || j3 == 1685479729 || j3 == 1685481573 || j3 == 1685481521) { i3 = d2; a(bhVar, j3, i3, j2, i, i2, y6Var, cVar, i4); } else if (j3 == 1836069985 || j3 == 1701733217 || j3 == 1633889587 || j3 == 1700998451 || j3 == 1633889588 || j3 == 1685353315 || j3 == 1685353317 || j3 == 1685353320 || j3 == 1685353324 || j3 == 1685353336 || j3 == 1935764850 || j3 == 1935767394 || j3 == 1819304813 || j3 == 1936684916 || j3 == 1953984371 || j3 == 778924082 || j3 == 778924083 || j3 == 1835557169 || j3 == 1835560241 || j3 == 1634492771 || j3 == 1634492791 || j3 == 1970037111 || j3 == 1332770163 || j3 == 1716281667) { i3 = d2; a(bhVar, j3, d2, j2, i, str, z, y6Var, cVar, i4); } else { if (j3 == 1414810956 || j3 == 1954034535 || j3 == 2004251764 || j3 == 1937010800 || j3 == 1664495672) { a(bhVar, j3, d2, j2, i, str, cVar); } else if (j3 == 1835365492) { a(bhVar, j3, d2, i, cVar); } else if (j3 == 1667329389) { cVar.b = new f9.b().h(i).f(MimeTypes.APPLICATION_CAMERA_MOTION).a(); } i3 = d2; } bhVar.f(i3 + j2); } return cVar; } private static void a(bh bhVar, int i, int i2, int i3, int i4, String str, c cVar) { bhVar.f(i2 + 16); String str2 = MimeTypes.APPLICATION_TTML; eb ebVar = null; long j = Long.MAX_VALUE; if (i != 1414810956) { if (i == 1954034535) { int i5 = i3 - 16; byte[] bArr = new byte[i5]; bhVar.a(bArr, 0, i5); ebVar = eb.a(bArr); str2 = MimeTypes.APPLICATION_TX3G; } else if (i == 2004251764) { str2 = MimeTypes.APPLICATION_MP4VTT; } else if (i == 1937010800) { j = 0; } else if (i == 1664495672) { cVar.d = 1; str2 = MimeTypes.APPLICATION_MP4CEA608; } else { throw new IllegalStateException(); } } cVar.b = new f9.b().h(i4).f(str2).e(str).a(j).a(ebVar).a(); } private static lo a(j1.a aVar, j1.b bVar, long j, y6 y6Var, boolean z, boolean z2) { j1.b bVar2; long j2; long[] jArr; long[] jArr2; j1.a d2; Pair a2; j1.a aVar2 = (j1.a) b1.a(aVar.d(1835297121)); int a3 = a(c(((j1.b) b1.a(aVar2.e(1751411826))).b)); if (a3 == -1) { return null; } f f2 = f(((j1.b) b1.a(aVar.e(1953196132))).b); long j3 = C.TIME_UNSET; if (j == C.TIME_UNSET) { bVar2 = bVar; j2 = f2.b; } else { bVar2 = bVar; j2 = j; } long e2 = e(bVar2.b); if (j2 != C.TIME_UNSET) { j3 = xp.c(j2, 1000000L, e2); } long j4 = j3; j1.a aVar3 = (j1.a) b1.a(((j1.a) b1.a(aVar2.d(1835626086))).d(1937007212)); Pair d3 = d(((j1.b) b1.a(aVar2.e(1835296868))).b); c a4 = a(((j1.b) b1.a(aVar3.e(1937011556))).b, f2.a, f2.c, (String) d3.second, y6Var, z2); if (z || (d2 = aVar.d(1701082227)) == null || (a2 = a(d2)) == null) { jArr = null; jArr2 = null; } else { long[] jArr3 = (long[]) a2.first; jArr2 = (long[]) a2.second; jArr = jArr3; } if (a4.b == null) { return null; } return new lo(f2.a, a3, ((Long) d3.first).longValue(), e2, j4, a4.b, a4.d, a4.a, a4.c, jArr, jArr2); } public static Pair a(j1.b bVar) { bh bhVar = bVar.b; bhVar.f(8); bf bfVar = null; bf bfVar2 = null; while (bhVar.a() >= 8) { int d2 = bhVar.d(); int j = bhVar.j(); int j2 = bhVar.j(); if (j2 == 1835365473) { bhVar.f(d2); bfVar = e(bhVar, d2 + j); } else if (j2 == 1936553057) { bhVar.f(d2); bfVar2 = d(bhVar, d2 + j); } bhVar.f(d2 + j); } return Pair.create(bfVar, bfVar2); } /* JADX WARN: Code restructure failed: missing block: B:101:0x0190, code lost: if (r1 != 3) goto L42; */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ private static void a(com.applovin.impl.bh r20, int r21, int r22, int r23, int r24, int r25, com.applovin.impl.y6 r26, com.applovin.impl.k1.c r27, int r28) { /* Method dump skipped, instructions count: 613 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: com.applovin.impl.k1.a(com.applovin.impl.bh, int, int, int, int, int, com.applovin.impl.y6, com.applovin.impl.k1$c, int):void"); } public static List a(j1.a aVar, z9 z9Var, long j, y6 y6Var, boolean z, boolean z2, Function function) { lo loVar; ArrayList arrayList = new ArrayList(); for (int i = 0; i < aVar.d.size(); i++) { j1.a aVar2 = (j1.a) aVar.d.get(i); if (aVar2.a == 1953653099 && (loVar = (lo) function.apply(a(aVar2, (j1.b) b1.a(aVar.e(1836476516)), j, y6Var, z, z2))) != null) { arrayList.add(a(loVar, (j1.a) b1.a(((j1.a) b1.a(((j1.a) b1.a(aVar2.d(1835297121))).d(1835626086))).d(1937007212)), z9Var)); } } return arrayList; } }