package c.i.a.c.a2.j0; import androidx.annotation.Nullable; import c.i.a.c.a2.j; import c.i.a.c.a2.j0.i0; import c.i.a.c.i2.f0; import c.i.a.c.i2.v; import c.i.a.c.i2.w; import c.i.a.c.v1.l; import com.airbnb.lottie.parser.AnimatableValueParser; import com.google.android.exoplayer2.Format; /* compiled from: Ac3Reader */ public final class g implements o { public final v a; public final w b; @Nullable /* renamed from: c reason: collision with root package name */ public final String f719c; public String d; public c.i.a.c.a2.w e; public int f = 0; public int g; public boolean h; public long i; public Format j; public int k; public long l; public g(@Nullable String str) { v vVar = new v(new byte[128]); this.a = vVar; this.b = new w(vVar.a); this.f719c = str; } /* JADX WARNING: Removed duplicated region for block: B:120:0x0209 */ /* JADX WARNING: Removed duplicated region for block: B:129:0x0225 */ @Override // c.i.a.c.a2.j0.o public void b(w wVar) { int i; int i2; int i3; String str; int i4; int i5; int i6; int i7; int i8; int i9; int i10; int i11; int i12; boolean z2; AnimatableValueParser.H(this.e); while (wVar.a() > 0) { int i13 = this.f; if (i13 == 0) { while (true) { if (wVar.a() <= 0) { z2 = false; break; } else if (!this.h) { this.h = wVar.s() == 11; } else { int s2 = wVar.s(); if (s2 == 119) { this.h = false; z2 = true; break; } this.h = s2 == 11; } } if (z2) { this.f = 1; byte[] bArr = this.b.a; bArr[0] = 11; bArr[1] = 119; this.g = 2; } } else if (i13 == 1) { byte[] bArr2 = this.b.a; int min = Math.min(wVar.a(), 128 - this.g); System.arraycopy(wVar.a, wVar.b, bArr2, this.g, min); wVar.b += min; int i14 = this.g + min; this.g = i14; if (i14 == 128) { this.a.k(0); v vVar = this.a; int e = vVar.e(); vVar.m(40); boolean z3 = vVar.g(5) > 10; vVar.k(e); int i15 = -1; if (z3) { vVar.m(16); int g = vVar.g(2); if (g == 0) { i15 = 0; } else if (g == 1) { i15 = 1; } else if (g == 2) { i15 = 2; } vVar.m(3); i3 = (vVar.g(11) + 1) * 2; int g2 = vVar.g(2); if (g2 == 3) { i5 = l.f992c[vVar.g(2)]; i7 = 6; i6 = 3; } else { int g3 = vVar.g(2); i6 = g3; i7 = l.a[g3]; i5 = l.b[g2]; } i2 = i7 * 256; int g4 = vVar.g(3); boolean f = vVar.f(); i = l.d[g4] + (f ? 1 : 0); vVar.m(10); if (vVar.f()) { vVar.m(8); } if (g4 == 0) { vVar.m(5); if (vVar.f()) { vVar.m(8); } } if (i15 == 1 && vVar.f()) { vVar.m(16); } if (vVar.f()) { if (g4 > 2) { vVar.m(2); } if ((g4 & 1) == 0 || g4 <= 2) { i10 = 6; } else { i10 = 6; vVar.m(6); } if ((g4 & 4) != 0) { vVar.m(i10); } if (f && vVar.f()) { vVar.m(5); } if (i15 == 0) { if (vVar.f()) { i11 = 6; vVar.m(6); } else { i11 = 6; } if (g4 == 0 && vVar.f()) { vVar.m(i11); } if (vVar.f()) { vVar.m(i11); } int g5 = vVar.g(2); if (g5 == 1) { vVar.m(5); } else if (g5 == 2) { vVar.m(12); } else if (g5 == 3) { int g6 = vVar.g(5); if (vVar.f()) { vVar.m(5); if (vVar.f()) { vVar.m(4); } if (vVar.f()) { vVar.m(4); } if (vVar.f()) { vVar.m(4); } if (vVar.f()) { vVar.m(4); } if (vVar.f()) { vVar.m(4); } if (vVar.f()) { vVar.m(4); } if (vVar.f()) { vVar.m(4); } if (vVar.f()) { if (vVar.f()) { vVar.m(4); } if (vVar.f()) { vVar.m(4); } } } if (vVar.f()) { vVar.m(5); if (vVar.f()) { vVar.m(7); if (vVar.f()) { vVar.m(8); i12 = 2; vVar.m((g6 + 2) * 8); vVar.c(); if (g4 < i12) { if (vVar.f()) { vVar.m(14); } if (g4 == 0 && vVar.f()) { vVar.m(14); } } if (vVar.f()) { if (i6 == 0) { vVar.m(5); } else { for (int i16 = 0; i16 < i7; i16++) { if (vVar.f()) { vVar.m(5); } } } } } } } i12 = 2; vVar.m((g6 + 2) * 8); vVar.c(); if (g4 < i12) { } if (vVar.f()) { } } i12 = 2; if (g4 < i12) { } if (vVar.f()) { } } } if (vVar.f()) { vVar.m(5); if (g4 == 2) { vVar.m(4); } if (g4 >= 6) { vVar.m(2); } if (vVar.f()) { i9 = 8; vVar.m(8); } else { i9 = 8; } if (g4 == 0 && vVar.f()) { vVar.m(i9); } if (g2 < 3) { vVar.l(); } } if (i15 == 0 && i6 != 3) { vVar.l(); } if (i15 != 2 || (i6 != 3 && !vVar.f())) { i8 = 6; } else { i8 = 6; vVar.m(6); } str = (vVar.f() && vVar.g(i8) == 1 && vVar.g(8) == 1) ? "audio/eac3-joc" : "audio/eac3"; i15 = i5; } else { vVar.m(32); int g7 = vVar.g(2); String str2 = g7 == 3 ? null : "audio/ac3"; int a = l.a(g7, vVar.g(6)); vVar.m(8); int g8 = vVar.g(3); if ((g8 & 1) == 0 || g8 == 1) { i4 = 2; } else { i4 = 2; vVar.m(2); } if ((g8 & 4) != 0) { vVar.m(i4); } if (g8 == i4) { vVar.m(i4); } int[] iArr = l.b; if (g7 < iArr.length) { i15 = iArr[g7]; } i = l.d[g8] + (vVar.f() ? 1 : 0); i2 = 1536; str = str2; i3 = a; } Format format = this.j; if (format == null || i != format.G || i15 != format.H || !f0.a(str, format.t)) { Format.b bVar = new Format.b(); bVar.a = this.d; bVar.k = str; bVar.f2218x = i; bVar.f2219y = i15; bVar.f2216c = this.f719c; Format a2 = bVar.a(); this.j = a2; this.e.e(a2); } this.k = i3; this.i = (((long) i2) * 1000000) / ((long) this.j.H); this.b.D(0); this.e.c(this.b, 128); this.f = 2; } } else if (i13 == 2) { int min2 = Math.min(wVar.a(), this.k - this.g); this.e.c(wVar, min2); int i17 = this.g + min2; this.g = i17; int i18 = this.k; if (i17 == i18) { this.e.d(this.l, 1, i18, 0, null); this.l += this.i; this.f = 0; } } } } @Override // c.i.a.c.a2.j0.o public void c() { this.f = 0; this.g = 0; this.h = false; } @Override // c.i.a.c.a2.j0.o public void d() { } @Override // c.i.a.c.a2.j0.o public void e(j jVar, i0.d dVar) { dVar.a(); this.d = dVar.b(); this.e = jVar.p(dVar.c(), 1); } @Override // c.i.a.c.a2.j0.o public void f(long j, int i) { this.l = j; } }