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.w; import c.i.a.c.v1.z; import com.airbnb.lottie.parser.AnimatableValueParser; import com.google.android.exoplayer2.Format; /* compiled from: MpegAudioReader */ public final class v implements o { public final w a; public final z.a b; @Nullable /* renamed from: c reason: collision with root package name */ public final String f746c; public c.i.a.c.a2.w d; public String e; public int f = 0; public int g; public boolean h; public boolean i; public long j; public int k; public long l; public v(@Nullable String str) { w wVar = new w(4); this.a = wVar; wVar.a[0] = -1; this.b = new z.a(); this.f746c = str; } @Override // c.i.a.c.a2.j0.o public void b(w wVar) { AnimatableValueParser.H(this.d); while (wVar.a() > 0) { int i = this.f; if (i == 0) { byte[] bArr = wVar.a; int i2 = wVar.b; int i3 = wVar.f913c; while (true) { if (i2 >= i3) { wVar.D(i3); break; } boolean z2 = (bArr[i2] & 255) == 255; boolean z3 = this.i && (bArr[i2] & 224) == 224; this.i = z2; if (z3) { wVar.D(i2 + 1); this.i = false; this.a.a[1] = bArr[i2]; this.g = 2; this.f = 1; break; } i2++; } } else if (i == 1) { int min = Math.min(wVar.a(), 4 - this.g); wVar.e(this.a.a, this.g, min); int i4 = this.g + min; this.g = i4; if (i4 >= 4) { this.a.D(0); if (!this.b.a(this.a.f())) { this.g = 0; this.f = 1; } else { z.a aVar = this.b; this.k = aVar.f1006c; if (!this.h) { int i5 = aVar.d; this.j = (((long) aVar.g) * 1000000) / ((long) i5); Format.b bVar = new Format.b(); bVar.a = this.e; bVar.k = aVar.b; bVar.l = 4096; bVar.f2218x = aVar.e; bVar.f2219y = i5; bVar.f2216c = this.f746c; this.d.e(bVar.a()); this.h = true; } this.a.D(0); this.d.c(this.a, 4); this.f = 2; } } } else if (i == 2) { int min2 = Math.min(wVar.a(), this.k - this.g); this.d.c(wVar, min2); int i6 = this.g + min2; this.g = i6; int i7 = this.k; if (i6 >= i7) { this.d.d(this.l, 1, i7, 0, null); this.l += this.j; this.g = 0; this.f = 0; } } else { throw new IllegalStateException(); } } } @Override // c.i.a.c.a2.j0.o public void c() { this.f = 0; this.g = 0; 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.e = dVar.b(); this.d = jVar.p(dVar.c(), 1); } @Override // c.i.a.c.a2.j0.o public void f(long j, int i) { this.l = j; } }