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.v; import c.i.a.c.i2.w; import c.i.a.c.v1.m; import com.airbnb.lottie.parser.AnimatableValueParser; import com.google.android.exoplayer2.Format; /* compiled from: Ac4Reader */ public final class i implements o { public final v a; public final w b; @Nullable /* renamed from: c reason: collision with root package name */ public final String f725c; public String d; public c.i.a.c.a2.w e; public int f = 0; public int g = 0; public boolean h = false; public boolean i = false; public long j; public Format k; public int l; public long m; public i(@Nullable String str) { v vVar = new v(new byte[16]); this.a = vVar; this.b = new w(vVar.a); this.f725c = str; } @Override // c.i.a.c.a2.j0.o public void b(w wVar) { int i; boolean z2; int s2; AnimatableValueParser.H(this.e); while (wVar.a() > 0) { int i2 = this.f; boolean z3 = true; if (i2 == 0) { while (true) { i = 65; if (wVar.a() <= 0) { z2 = false; break; } else if (!this.h) { this.h = wVar.s() == 172; } else { s2 = wVar.s(); this.h = s2 == 172; if (s2 == 64 || s2 == 65) { break; } } } this.i = s2 == 65; z2 = true; if (z2) { this.f = 1; byte[] bArr = this.b.a; bArr[0] = -84; if (!this.i) { i = 64; } bArr[1] = (byte) i; this.g = 2; } } else if (i2 == 1) { byte[] bArr2 = this.b.a; int min = Math.min(wVar.a(), 16 - this.g); System.arraycopy(wVar.a, wVar.b, bArr2, this.g, min); wVar.b += min; int i3 = this.g + min; this.g = i3; if (i3 != 16) { z3 = false; } if (z3) { this.a.k(0); m.b b = m.b(this.a); Format format = this.k; if (format == null || 2 != format.G || b.a != format.H || !"audio/ac4".equals(format.t)) { Format.b bVar = new Format.b(); bVar.a = this.d; bVar.k = "audio/ac4"; bVar.f2218x = 2; bVar.f2219y = b.a; bVar.f2216c = this.f725c; Format a = bVar.a(); this.k = a; this.e.e(a); } this.l = b.b; this.j = (((long) b.f993c) * 1000000) / ((long) this.k.H); this.b.D(0); this.e.c(this.b, 16); this.f = 2; } } else if (i2 == 2) { int min2 = Math.min(wVar.a(), this.l - this.g); this.e.c(wVar, min2); int i4 = this.g + min2; this.g = i4; int i5 = this.l; if (i4 == i5) { this.e.d(this.m, 1, i5, 0, null); this.m += this.j; this.f = 0; } } } } @Override // c.i.a.c.a2.j0.o public void c() { this.f = 0; this.g = 0; this.h = false; this.i = 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.m = j; } }