package c.i.a.c.d2; import androidx.annotation.Nullable; import c.i.a.c.d2.v; import c.i.a.c.f2.g; import c.i.a.c.i2.f0; import c.i.a.c.i2.s; import c.i.a.c.o1; import c.i.a.c.s0; import com.airbnb.lottie.parser.AnimatableValueParser; import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.decoder.DecoderInputBuffer; import com.google.android.exoplayer2.source.TrackGroupArray; import java.io.IOException; import java.util.Objects; /* compiled from: ClippingMediaPeriod */ public final class l implements v, v.a { public final v i; @Nullable public v.a j; public a[] k = new a[0]; public long l; public long m; public long n; /* compiled from: ClippingMediaPeriod */ public final class a implements f0 { public final f0 a; public boolean b; public a(f0 f0Var) { this.a = f0Var; } @Override // c.i.a.c.d2.f0 public int a(s0 s0Var, DecoderInputBuffer decoderInputBuffer, boolean z2) { if (l.this.d()) { return -3; } if (this.b) { decoderInputBuffer.i = 4; return -4; } int a = this.a.a(s0Var, decoderInputBuffer, z2); if (a == -5) { Format format = s0Var.b; Objects.requireNonNull(format); int i = format.J; if (!(i == 0 && format.K == 0)) { l lVar = l.this; int i2 = 0; if (lVar.m != 0) { i = 0; } if (lVar.n == Long.MIN_VALUE) { i2 = format.K; } Format.b a2 = format.a(); a2.A = i; a2.B = i2; s0Var.b = a2.a(); } return -5; } l lVar2 = l.this; long j = lVar2.n; if (j == Long.MIN_VALUE || ((a != -4 || decoderInputBuffer.m < j) && (a != -3 || lVar2.q() != Long.MIN_VALUE || decoderInputBuffer.l))) { return a; } decoderInputBuffer.p(); decoderInputBuffer.i = 4; this.b = true; return -4; } @Override // c.i.a.c.d2.f0 public void b() throws IOException { this.a.b(); } @Override // c.i.a.c.d2.f0 public int c(long j) { if (l.this.d()) { return -3; } return this.a.c(j); } @Override // c.i.a.c.d2.f0 public boolean d() { return !l.this.d() && this.a.d(); } } public l(v vVar, boolean z2, long j, long j2) { this.i = vVar; this.l = z2 ? j : -9223372036854775807L; this.m = j; this.n = j2; } /* JADX DEBUG: Method arguments types fixed to match base method, original types: [c.i.a.c.d2.g0] */ @Override // c.i.a.c.d2.g0.a public void a(v vVar) { v.a aVar = this.j; Objects.requireNonNull(aVar); aVar.a(this); } @Override // c.i.a.c.d2.v.a public void b(v vVar) { v.a aVar = this.j; Objects.requireNonNull(aVar); aVar.b(this); } @Override // c.i.a.c.d2.v public long c() { long c2 = this.i.c(); if (c2 != Long.MIN_VALUE) { long j = this.n; if (j == Long.MIN_VALUE || c2 < j) { return c2; } } return Long.MIN_VALUE; } public boolean d() { return this.l != -9223372036854775807L; } @Override // c.i.a.c.d2.v public void e() throws IOException { this.i.e(); } /* JADX WARNING: Code restructure failed: missing block: B:13:0x0031, code lost: if (r0 > r7) goto L_0x0034; */ @Override // c.i.a.c.d2.v public long f(long j) { this.l = -9223372036854775807L; a[] aVarArr = this.k; boolean z2 = false; for (a aVar : aVarArr) { if (aVar != null) { aVar.b = false; } } long f = this.i.f(j); if (f != j) { if (f >= this.m) { long j2 = this.n; if (j2 != Long.MIN_VALUE) { } } AnimatableValueParser.D(z2); return f; } z2 = true; AnimatableValueParser.D(z2); return f; } @Override // c.i.a.c.d2.v public boolean g(long j) { return this.i.g(j); } @Override // c.i.a.c.d2.v public boolean h() { return this.i.h(); } @Override // c.i.a.c.d2.v public long i(long j, o1 o1Var) { long j2 = this.m; if (j == j2) { return j2; } long i = f0.i(o1Var.f936c, 0, j - j2); long j3 = o1Var.d; long j4 = this.n; long i2 = f0.i(j3, 0, j4 == Long.MIN_VALUE ? Long.MAX_VALUE : j4 - j); if (!(i == o1Var.f936c && i2 == o1Var.d)) { o1Var = new o1(i, i2); } return this.i.i(j, o1Var); } @Override // c.i.a.c.d2.v public long k() { if (d()) { long j = this.l; this.l = -9223372036854775807L; long k = k(); return k != -9223372036854775807L ? k : j; } long k2 = this.i.k(); if (k2 == -9223372036854775807L) { return -9223372036854775807L; } boolean z2 = true; AnimatableValueParser.D(k2 >= this.m); long j2 = this.n; if (j2 != Long.MIN_VALUE && k2 > j2) { z2 = false; } AnimatableValueParser.D(z2); return k2; } @Override // c.i.a.c.d2.v public void l(v.a aVar, long j) { this.j = aVar; this.i.l(this, j); } /* JADX WARNING: Code restructure failed: missing block: B:32:0x0085, code lost: if (r1 > r5) goto L_0x0088; */ /* JADX WARNING: Removed duplicated region for block: B:23:0x0068 */ /* JADX WARNING: Removed duplicated region for block: B:27:0x0075 */ /* JADX WARNING: Removed duplicated region for block: B:37:0x008f */ @Override // c.i.a.c.d2.v public long m(g[] gVarArr, boolean[] zArr, f0[] f0VarArr, boolean[] zArr2, long j) { long j2; boolean z2; this.k = new a[f0VarArr.length]; f0[] f0VarArr2 = new f0[f0VarArr.length]; int i = 0; while (true) { f0 f0Var = null; if (i >= f0VarArr.length) { break; } a[] aVarArr = this.k; aVarArr[i] = (a) f0VarArr[i]; if (aVarArr[i] != null) { f0Var = aVarArr[i].a; } f0VarArr2[i] = f0Var; i++; } long m = this.i.m(gVarArr, zArr, f0VarArr2, zArr2, j); boolean z3 = true; if (d()) { long j3 = this.m; if (j == j3) { if (j3 != 0) { int length = gVarArr.length; int i2 = 0; while (true) { if (i2 >= length) { break; } g gVar = gVarArr[i2]; if (gVar != null) { Format h = gVar.h(); if (!s.a(h.t, h.q)) { z2 = true; break; } } i2++; } if (z2) { j2 = m; this.l = j2; if (m != j) { if (m >= this.m) { long j4 = this.n; if (j4 != Long.MIN_VALUE) { } } z3 = false; } AnimatableValueParser.D(z3); for (int i3 = 0; i3 < f0VarArr.length; i3++) { if (f0VarArr2[i3] == null) { this.k[i3] = null; } else { a[] aVarArr2 = this.k; if (aVarArr2[i3] == null || aVarArr2[i3].a != f0VarArr2[i3]) { aVarArr2[i3] = new a(f0VarArr2[i3]); } } f0VarArr[i3] = this.k[i3]; } return m; } } z2 = false; if (z2) { } } } j2 = -9223372036854775807L; this.l = j2; if (m != j) { } AnimatableValueParser.D(z3); while (i3 < f0VarArr.length) { } return m; } @Override // c.i.a.c.d2.v public TrackGroupArray n() { return this.i.n(); } @Override // c.i.a.c.d2.v public long q() { long q = this.i.q(); if (q != Long.MIN_VALUE) { long j = this.n; if (j == Long.MIN_VALUE || q < j) { return q; } } return Long.MIN_VALUE; } @Override // c.i.a.c.d2.v public void r(long j, boolean z2) { this.i.r(j, z2); } @Override // c.i.a.c.d2.v public void s(long j) { this.i.s(j); } }