package c.i.a.c.a2.i0; import androidx.annotation.Nullable; import c.i.a.c.a2.i; import c.i.a.c.a2.t; import c.i.a.c.a2.u; import c.i.a.c.i2.f0; import com.airbnb.lottie.parser.AnimatableValueParser; import java.io.EOFException; import java.io.IOException; /* compiled from: DefaultOggSeeker */ public final class b implements g { public final f a; public final long b; /* renamed from: c reason: collision with root package name */ public final long f706c; public final i d; public int e; public long f; public long g; public long h; public long i; public long j; public long k; public long l; /* compiled from: DefaultOggSeeker */ /* renamed from: c.i.a.c.a2.i0.b$b reason: collision with other inner class name */ public final class C0083b implements t { public C0083b(a aVar) { } @Override // c.i.a.c.a2.t public boolean c() { return true; } @Override // c.i.a.c.a2.t public t.a h(long j) { b bVar = b.this; long j2 = bVar.b; long j3 = bVar.f706c; return new t.a(new u(j, f0.i(((((j3 - j2) * ((((long) bVar.d.i) * j) / 1000000)) / bVar.f) + j2) - 30000, j2, j3 - 1))); } @Override // c.i.a.c.a2.t public long i() { b bVar = b.this; return (bVar.f * 1000000) / ((long) bVar.d.i); } } public b(i iVar, long j, long j2, long j3, long j4, boolean z2) { AnimatableValueParser.k(j >= 0 && j2 > j); this.d = iVar; this.b = j; this.f706c = j2; if (j3 == j2 - j || z2) { this.f = j4; this.e = 4; } else { this.e = 0; } this.a = new f(); } @Override // c.i.a.c.a2.i0.g @Nullable public t a() { if (this.f != 0) { return new C0083b(null); } return null; } /* JADX WARNING: Removed duplicated region for block: B:38:0x00c2 A[RETURN] */ /* JADX WARNING: Removed duplicated region for block: B:39:0x00c3 */ @Override // c.i.a.c.a2.i0.g public long b(i iVar) throws IOException { long j; long j2; int i = this.e; if (i == 0) { long position = iVar.getPosition(); this.g = position; this.e = 1; long j3 = this.f706c - 65307; if (j3 > position) { return j3; } } else if (i != 1) { if (i == 2) { if (this.i != this.j) { long position2 = iVar.getPosition(); if (!this.a.c(iVar, this.j)) { j2 = this.i; if (j2 == position2) { throw new IOException("No ogg page can be found."); } } else { this.a.a(iVar, false); iVar.k(); long j4 = this.h; f fVar = this.a; long j5 = fVar.f710c; long j6 = j4 - j5; int i2 = fVar.e + fVar.f; if (0 > j6 || j6 >= 72000) { int i3 = (j6 > 0 ? 1 : (j6 == 0 ? 0 : -1)); if (i3 < 0) { this.j = position2; this.l = j5; } else { this.i = iVar.getPosition() + ((long) i2); this.k = this.a.f710c; } long j7 = this.j; long j8 = this.i; if (j7 - j8 < 100000) { this.j = j8; j2 = j8; } else { long position3 = iVar.getPosition() - (((long) i2) * (i3 <= 0 ? 2 : 1)); long j9 = this.j; long j10 = this.i; j2 = f0.i((((j9 - j10) * j6) / (this.l - this.k)) + position3, j10, j9 - 1); } } } j = -1; if (j2 == -1) { return j2; } this.e = 3; } j2 = -1; j = -1; if (j2 == -1) { } } else if (i == 3) { j = -1; } else if (i == 4) { return -1; } else { throw new IllegalStateException(); } while (true) { this.a.c(iVar, j); this.a.a(iVar, false); f fVar2 = this.a; if (fVar2.f710c > this.h) { iVar.k(); this.e = 4; return -(this.k + 2); } iVar.l(fVar2.e + fVar2.f); this.i = iVar.getPosition(); this.k = this.a.f710c; j = -1; } } this.a.b(); if (this.a.c(iVar, -1)) { do { this.a.a(iVar, false); f fVar3 = this.a; iVar.l(fVar3.e + fVar3.f); f fVar4 = this.a; if ((fVar4.b & 4) == 4 || !fVar4.c(iVar, -1)) { break; } } while (iVar.getPosition() < this.f706c); this.f = this.a.f710c; this.e = 4; return this.g; } throw new EOFException(); } @Override // c.i.a.c.a2.i0.g public void c(long j) { this.h = f0.i(j, 0, this.f - 1); this.e = 2; this.i = this.b; this.j = this.f706c; this.k = 0; this.l = this.f; } }