package com.applovin.impl; import android.support.v4.media.session.PlaybackStateCompat; import com.applovin.impl.f9; import com.ironsource.v8; import com.mbridge.msdk.playercommon.exoplayer2.C; import com.mbridge.msdk.playercommon.exoplayer2.util.MimeTypes; import java.util.ArrayList; import java.util.Collections; import java.util.List; import kotlin.jvm.internal.ByteCompanionObject; /* loaded from: classes.dex */ public final class a9 { public final int a; public final int b; public final int c; public final int d; public final int e; public final int f; public final int g; public final int h; public final int i; public final long j; public final a k; private final bf l; private static int a(int i) { if (i == 8) { return 1; } if (i == 12) { return 2; } if (i == 16) { return 4; } if (i != 20) { return i != 24 ? -1 : 6; } return 5; } private static int b(int i) { switch (i) { case 8000: return 4; case 16000: return 5; case 22050: return 6; case 24000: return 7; case 32000: return 8; case 44100: return 9; case 48000: return 10; case 88200: return 1; case 96000: return 11; case 176400: return 2; case 192000: return 3; default: return -1; } } public static class a { public final long[] a; public final long[] b; public a(long[] jArr, long[] jArr2) { this.a = jArr; this.b = jArr2; } } private a9(int i, int i2, int i3, int i4, int i5, int i6, int i7, long j, a aVar, bf bfVar) { this.a = i; this.b = i2; this.c = i3; this.d = i4; this.e = i5; this.f = b(i5); this.g = i6; this.h = i7; this.i = a(i7); this.j = j; this.k = aVar; this.l = bfVar; } public a9 b(List list) { return new a9(this.a, this.b, this.c, this.d, this.e, this.g, this.h, this.j, this.k, a(a(list, Collections.emptyList()))); } public a9(byte[] bArr, int i) { ah ahVar = new ah(bArr); ahVar.c(i * 8); this.a = ahVar.a(16); this.b = ahVar.a(16); this.c = ahVar.a(24); this.d = ahVar.a(24); int a2 = ahVar.a(20); this.e = a2; this.f = b(a2); this.g = ahVar.a(3) + 1; int a3 = ahVar.a(5) + 1; this.h = a3; this.i = a(a3); this.j = ahVar.b(36); this.k = null; this.l = null; } private static bf a(List list, List list2) { if (list.isEmpty() && list2.isEmpty()) { return null; } ArrayList arrayList = new ArrayList(); for (int i = 0; i < list.size(); i++) { String str = (String) list.get(i); String[] b = xp.b(str, v8.i.b); if (b.length != 2) { pc.d("FlacStreamMetadata", "Failed to parse Vorbis comment: " + str); } else { arrayList.add(new dr(b[0], b[1])); } } arrayList.addAll(list2); if (arrayList.isEmpty()) { return null; } return new bf(arrayList); } public long b() { long j = this.j; return j == 0 ? C.TIME_UNSET : (j * 1000000) / this.e; } public a9 a(List list) { return new a9(this.a, this.b, this.c, this.d, this.e, this.g, this.h, this.j, this.k, a(a(Collections.emptyList(), list))); } public long a() { long j; long j2; int i = this.d; if (i > 0) { j = (i + this.c) / 2; j2 = 1; } else { int i2 = this.a; j = ((((i2 != this.b || i2 <= 0) ? PlaybackStateCompat.ACTION_SKIP_TO_QUEUE_ITEM : i2) * this.g) * this.h) / 8; j2 = 64; } return j + j2; } public f9 a(byte[] bArr, bf bfVar) { bArr[4] = ByteCompanionObject.MIN_VALUE; int i = this.d; if (i <= 0) { i = -1; } return new f9.b().f(MimeTypes.AUDIO_FLAC).i(i).c(this.g).n(this.e).a(Collections.singletonList(bArr)).a(a(bfVar)).a(); } public bf a(bf bfVar) { bf bfVar2 = this.l; return bfVar2 == null ? bfVar : bfVar2.a(bfVar); } public long a(long j) { return xp.b((j * this.e) / 1000000, 0L, this.j - 1); } public a9 a(a aVar) { return new a9(this.a, this.b, this.c, this.d, this.e, this.g, this.h, this.j, aVar, this.l); } }