package com.applovin.impl; import android.util.Pair; import com.applovin.exoplayer2.common.base.Ascii; import com.applovin.impl.f9; import com.facebook.internal.FacebookRequestErrorClassification; import com.mbridge.msdk.playercommon.exoplayer2.util.MimeTypes; import com.vungle.ads.internal.signals.SignalKey; /* loaded from: classes.dex */ public final class lr implements k8 { public static final o8 f = new o8() { // from class: com.applovin.impl.lr$$ExternalSyntheticLambda0 @Override // com.applovin.impl.o8 public final k8[] a() { k8[] c2; c2 = lr.c(); return c2; } }; private m8 a; private qo b; private b c; private int d = -1; private long e = -1; public interface b { void a(int i, long j); void a(long j); boolean a(l8 l8Var, long j); } /* JADX INFO: Access modifiers changed from: private */ public static /* synthetic */ k8[] c() { return new k8[]{new lr()}; } @Override // com.applovin.impl.k8 public void a() { } @Override // com.applovin.impl.k8 public void a(m8 m8Var) { this.a = m8Var; this.b = m8Var.a(0, 1); m8Var.c(); } private void b() { b1.b(this.b); xp.a(this.a); } @Override // com.applovin.impl.k8 public int a(l8 l8Var, th thVar) { b(); if (this.c == null) { mr a2 = nr.a(l8Var); if (a2 != null) { int i = a2.a; if (i == 17) { this.c = new a(this.a, this.b, a2); } else if (i == 6) { this.c = new c(this.a, this.b, a2, MimeTypes.AUDIO_ALAW, -1); } else if (i == 7) { this.c = new c(this.a, this.b, a2, MimeTypes.AUDIO_MLAW, -1); } else { int a3 = pr.a(i, a2.f); if (a3 != 0) { this.c = new c(this.a, this.b, a2, MimeTypes.AUDIO_RAW, a3); } else { throw dh.a("Unsupported WAV format type: " + a2.a); } } } else { throw dh.a("Unsupported or unrecognized wav header.", null); } } if (this.d == -1) { Pair b2 = nr.b(l8Var); this.d = ((Long) b2.first).intValue(); long longValue = ((Long) b2.second).longValue(); this.e = longValue; this.c.a(this.d, longValue); } else if (l8Var.f() == 0) { l8Var.a(this.d); } b1.b(this.e != -1); return this.c.a(l8Var, this.e - l8Var.f()) ? -1 : 0; } public static final class c implements b { private final m8 a; private final qo b; private final mr c; private final f9 d; private final int e; private long f; private int g; private long h; @Override // com.applovin.impl.lr.b public void a(long j) { this.f = j; this.g = 0; this.h = 0L; } public c(m8 m8Var, qo qoVar, mr mrVar, String str, int i) { this.a = m8Var; this.b = qoVar; this.c = mrVar; int i2 = (mrVar.b * mrVar.f) / 8; if (mrVar.e == i2) { int i3 = mrVar.c * i2; int i4 = i3 * 8; int max = Math.max(i2, i3 / 10); this.e = max; this.d = new f9.b().f(str).b(i4).k(i4).i(max).c(mrVar.b).n(mrVar.c).j(i).a(); return; } throw dh.a("Expected block size: " + i2 + "; got: " + mrVar.e, null); } @Override // com.applovin.impl.lr.b public void a(int i, long j) { this.a.a(new or(this.c, 1, i, j)); this.b.a(this.d); } @Override // com.applovin.impl.lr.b public boolean a(l8 l8Var, long j) { int i; int i2; long j2 = j; while (j2 > 0 && (i = this.g) < (i2 = this.e)) { int a = this.b.a((g5) l8Var, (int) Math.min(i2 - i, j2), true); if (a == -1) { j2 = 0; } else { this.g += a; j2 -= a; } } int i3 = this.c.e; int i4 = this.g / i3; if (i4 > 0) { long c = this.f + xp.c(this.h, 1000000L, r1.c); int i5 = i4 * i3; int i6 = this.g - i5; this.b.a(c, 1, i5, i6, null); this.h += i4; this.g = i6; } return j2 <= 0; } } @Override // com.applovin.impl.k8 public void a(long j, long j2) { b bVar = this.c; if (bVar != null) { bVar.a(j2); } } public static final class a implements b { private static final int[] m = {-1, -1, -1, -1, 2, 4, 6, 8, -1, -1, -1, -1, 2, 4, 6, 8}; private static final int[] n = {7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, 50, 55, 60, 66, 73, 80, 88, 97, SignalKey.EVENT_ID, 118, 130, 143, 157, 173, FacebookRequestErrorClassification.EC_INVALID_TOKEN, 209, 230, 253, 279, 307, 337, 371, 408, 449, 494, 544, 598, 658, 724, 796, 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358, 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767}; private final m8 a; private final qo b; private final mr c; private final int d; private final byte[] e; private final bh f; private final int g; private final f9 h; private int i; private long j; private int k; private long l; private static int a(int i, int i2) { return i * 2 * i2; } @Override // com.applovin.impl.lr.b public void a(long j) { this.i = 0; this.j = j; this.k = 0; this.l = 0L; } public a(m8 m8Var, qo qoVar, mr mrVar) { this.a = m8Var; this.b = qoVar; this.c = mrVar; int max = Math.max(1, mrVar.c / 10); this.g = max; bh bhVar = new bh(mrVar.g); bhVar.r(); int r = bhVar.r(); this.d = r; int i = mrVar.b; int i2 = (((mrVar.e - (i * 4)) * 8) / (mrVar.f * i)) + 1; if (r == i2) { int a = xp.a(max, r); this.e = new byte[mrVar.e * a]; this.f = new bh(a * a(r, i)); int i3 = ((mrVar.c * mrVar.e) * 8) / r; this.h = new f9.b().f(MimeTypes.AUDIO_RAW).b(i3).k(i3).i(a(max, i)).c(mrVar.b).n(mrVar.c).j(2).a(); return; } throw dh.a("Expected frames per block: " + i2 + "; got: " + r, null); } private void c(int i) { long c = this.j + xp.c(this.l, 1000000L, this.c.c); int b = b(i); this.b.a(c, 1, b, this.k - b, null); this.l += i; this.k -= b; } private void a(byte[] bArr, int i, bh bhVar) { for (int i2 = 0; i2 < i; i2++) { for (int i3 = 0; i3 < this.c.b; i3++) { a(bArr, i2, i3, bhVar.c()); } } int b = b(this.d * i); bhVar.f(0); bhVar.e(b); } private int b(int i) { return a(i, this.c.b); } private void a(byte[] bArr, int i, int i2, byte[] bArr2) { mr mrVar = this.c; int i3 = mrVar.e; int i4 = mrVar.b; int i5 = (i * i3) + (i2 * 4); int i6 = (i4 * 4) + i5; int i7 = (i3 / i4) - 4; int i8 = (short) (((bArr[i5 + 1] & 255) << 8) | (bArr[i5] & 255)); int min = Math.min(bArr[i5 + 2] & 255, 88); int i9 = n[min]; int i10 = ((i * this.d * i4) + i2) * 2; bArr2[i10] = (byte) (i8 & 255); bArr2[i10 + 1] = (byte) (i8 >> 8); for (int i11 = 0; i11 < i7 * 2; i11++) { byte b = bArr[((i11 / 8) * i4 * 4) + i6 + ((i11 / 2) % 4)]; int i12 = i11 % 2 == 0 ? b & Ascii.SI : (b & 255) >> 4; int i13 = ((((i12 & 7) * 2) + 1) * i9) >> 3; if ((i12 & 8) != 0) { i13 = -i13; } i8 = xp.a(i8 + i13, -32768, 32767); i10 += i4 * 2; bArr2[i10] = (byte) (i8 & 255); bArr2[i10 + 1] = (byte) (i8 >> 8); int i14 = min + m[i12]; int[] iArr = n; min = xp.a(i14, 0, iArr.length - 1); i9 = iArr[min]; } } @Override // com.applovin.impl.lr.b public void a(int i, long j) { this.a.a(new or(this.c, this.d, i, j)); this.b.a(this.h); } private int a(int i) { return i / (this.c.b * 2); } /* JADX WARN: Removed duplicated region for block: B:16:0x0048 */ /* JADX WARN: Removed duplicated region for block: B:7:0x0020 */ /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:9:0x0035 -> B:4:0x0037). Please report as a decompilation issue!!! */ @Override // com.applovin.impl.lr.b /* 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, long r8) { /* r6 = this; int r0 = r6.g int r1 = r6.k int r1 = r6.a(r1) int r0 = r0 - r1 int r1 = r6.d int r0 = com.applovin.impl.xp.a(r0, r1) com.applovin.impl.mr r1 = r6.c int r1 = r1.e int r0 = r0 * r1 r1 = 0 int r1 = (r8 > r1 ? 1 : (r8 == r1 ? 0 : -1)) if (r1 != 0) goto L1c r2 = r6 goto L37 L1c: r1 = 0 r2 = r6 L1e: if (r1 != 0) goto L3f int r3 = r2.i if (r3 >= r0) goto L3f int r3 = r0 - r3 long r3 = (long) r3 long r3 = java.lang.Math.min(r3, r8) int r3 = (int) r3 byte[] r4 = r2.e int r5 = r2.i int r3 = r7.a(r4, r5, r3) r4 = -1 if (r3 != r4) goto L39 L37: r1 = 1 goto L1e L39: int r4 = r2.i int r4 = r4 + r3 r2.i = r4 goto L1e L3f: int r7 = r2.i com.applovin.impl.mr r8 = r2.c int r8 = r8.e int r7 = r7 / r8 if (r7 <= 0) goto L76 byte[] r8 = r2.e com.applovin.impl.bh r9 = r2.f r2.a(r8, r7, r9) int r8 = r2.i com.applovin.impl.mr r9 = r2.c int r9 = r9.e int r7 = r7 * r9 int r8 = r8 - r7 r2.i = r8 com.applovin.impl.bh r7 = r2.f int r7 = r7.e() com.applovin.impl.qo r8 = r2.b com.applovin.impl.bh r9 = r2.f r8.a(r9, r7) int r8 = r2.k int r8 = r8 + r7 r2.k = r8 int r7 = r2.a(r8) int r8 = r2.g if (r7 < r8) goto L76 r2.c(r8) L76: if (r1 == 0) goto L83 int r7 = r2.k int r7 = r2.a(r7) if (r7 <= 0) goto L83 r2.c(r7) L83: return r1 */ throw new UnsupportedOperationException("Method not decompiled: com.applovin.impl.lr.a.a(com.applovin.impl.l8, long):boolean"); } } @Override // com.applovin.impl.k8 public boolean a(l8 l8Var) { return nr.a(l8Var) != null; } }