package c.i.a.c.a2.j0; import android.util.Pair; import androidx.annotation.Nullable; import c.i.a.c.a2.j; import c.i.a.c.a2.j0.i0; import c.i.a.c.a2.w; import c.i.a.c.i2.f0; import c.i.a.c.i2.u; import com.airbnb.lottie.parser.AnimatableValueParser; import com.google.android.exoplayer2.Format; import java.util.Arrays; import java.util.Collections; import java.util.Objects; /* compiled from: H262Reader */ public final class p implements o { public static final double[] a = {23.976023976023978d, 24.0d, 25.0d, 29.97002997002997d, 30.0d, 50.0d, 59.94005994005994d, 60.0d}; public String b; /* renamed from: c reason: collision with root package name */ public w f733c; @Nullable public final j0 d; @Nullable public final c.i.a.c.i2.w e; @Nullable public final w f; public final boolean[] g = new boolean[4]; public final a h = new a(128); public long i; public boolean j; public boolean k; public long l; public long m; public long n; public long o; public boolean p; public boolean q; /* compiled from: H262Reader */ public static final class a { public static final byte[] a = {0, 0, 1}; public boolean b; /* renamed from: c reason: collision with root package name */ public int f734c; public int d; public byte[] e; public a(int i) { this.e = new byte[i]; } public void a(byte[] bArr, int i, int i2) { if (this.b) { int i3 = i2 - i; byte[] bArr2 = this.e; int length = bArr2.length; int i4 = this.f734c; if (length < i4 + i3) { this.e = Arrays.copyOf(bArr2, (i4 + i3) * 2); } System.arraycopy(bArr, i, this.e, this.f734c, i3); this.f734c += i3; } } } public p(@Nullable j0 j0Var) { this.d = j0Var; if (j0Var != null) { this.f = new w(178, 128); this.e = new c.i.a.c.i2.w(); return; } this.f = null; this.e = null; } /* JADX WARNING: Removed duplicated region for block: B:28:0x0080 */ /* JADX WARNING: Removed duplicated region for block: B:41:0x00f4 */ /* JADX WARNING: Removed duplicated region for block: B:53:0x0150 */ /* JADX WARNING: Removed duplicated region for block: B:64:0x0193 */ /* JADX WARNING: Removed duplicated region for block: B:66:0x0197 */ /* JADX WARNING: Removed duplicated region for block: B:80:0x01d1 */ /* JADX WARNING: Removed duplicated region for block: B:85:0x01eb */ /* JADX WARNING: Removed duplicated region for block: B:90:0x0201 */ /* JADX WARNING: Removed duplicated region for block: B:91:0x0203 */ @Override // c.i.a.c.a2.j0.o public void b(c.i.a.c.i2.w wVar) { int i; int i2; w wVar2; int i3; boolean z2; long j; int i4; boolean z3; float f; int i5; long j2; int i6; float f2; AnimatableValueParser.H(this.f733c); int i7 = wVar.b; int i8 = wVar.f913c; byte[] bArr = wVar.a; this.i += (long) wVar.a(); this.f733c.c(wVar, wVar.a()); while (true) { int b = u.b(bArr, i7, i8, this.g); if (b == i8) { break; } int i9 = b + 3; int i10 = wVar.a[i9] & 255; int i11 = b - i7; if (!this.k) { if (i11 > 0) { this.h.a(bArr, i7, b); } int i12 = i11 < 0 ? -i11 : 0; a aVar = this.h; if (aVar.b) { int i13 = aVar.f734c - i12; aVar.f734c = i13; if (aVar.d == 0 && i10 == 181) { aVar.d = i13; } else { aVar.b = false; z3 = true; if (z3) { a aVar2 = this.h; String str = this.b; Objects.requireNonNull(str); byte[] copyOf = Arrays.copyOf(aVar2.e, aVar2.f734c); int i14 = copyOf[5] & 255; int i15 = ((copyOf[4] & 255) << 4) | (i14 >> 4); int i16 = ((i14 & 15) << 8) | (copyOf[6] & 255); int i17 = (copyOf[7] & 240) >> 4; if (i17 == 2) { f2 = (float) (i16 * 4); i6 = i15 * 3; } else if (i17 == 3) { f2 = (float) (i16 * 16); i6 = i15 * 9; } else if (i17 != 4) { f = 1.0f; Format.b bVar = new Format.b(); bVar.a = str; bVar.k = "video/mpeg2"; bVar.p = i15; bVar.q = i16; bVar.t = f; bVar.m = Collections.singletonList(copyOf); Format a2 = bVar.a(); i5 = (copyOf[7] & 15) - 1; if (i5 >= 0) { double[] dArr = a; if (i5 < dArr.length) { double d = dArr[i5]; int i18 = aVar2.d + 9; int i19 = (copyOf[i18] & 96) >> 5; int i20 = copyOf[i18] & 31; if (i19 != i20) { i = i10; i2 = i9; d *= (((double) i19) + 1.0d) / ((double) (i20 + 1)); } else { i = i10; i2 = i9; } j2 = (long) (1000000.0d / d); Pair create = Pair.create(a2, Long.valueOf(j2)); this.f733c.e((Format) create.first); this.l = ((Long) create.second).longValue(); this.k = true; wVar2 = this.f; if (wVar2 == null) { if (i11 > 0) { wVar2.a(bArr, i7, b); i4 = 0; } else { i4 = -i11; } if (this.f.b(i4)) { w wVar3 = this.f; int e = u.e(wVar3.d, wVar3.e); c.i.a.c.i2.w wVar4 = this.e; int i21 = f0.a; wVar4.B(this.f.d, e); this.d.a(this.o, this.e); } i3 = i; if (i3 == 178 && wVar.a[b + 2] == 1) { this.f.d(i3); } } else { i3 = i; } if (i3 != 0 || i3 == 179) { int i22 = i8 - b; if (this.j && this.q && this.k) { this.f733c.d(this.o, this.p ? 1 : 0, ((int) (this.i - this.n)) - i22, i22, null); } z2 = this.j; if (z2 || this.q) { this.n = this.i - ((long) i22); j = this.m; if (j == -9223372036854775807L) { j = z2 ? this.o + this.l : 0; } this.o = j; this.p = false; this.m = -9223372036854775807L; this.j = true; } this.q = i3 != 0; } else if (i3 == 184) { this.p = true; } i7 = i2; } } i = i10; i2 = i9; j2 = 0; Pair create = Pair.create(a2, Long.valueOf(j2)); this.f733c.e((Format) create.first); this.l = ((Long) create.second).longValue(); this.k = true; wVar2 = this.f; if (wVar2 == null) { } if (i3 != 0) { } int i22 = i8 - b; this.f733c.d(this.o, this.p ? 1 : 0, ((int) (this.i - this.n)) - i22, i22, null); z2 = this.j; if (z2) { } this.n = this.i - ((long) i22); j = this.m; if (j == -9223372036854775807L) { } this.o = j; this.p = false; this.m = -9223372036854775807L; this.j = true; this.q = i3 != 0; i7 = i2; } else { f2 = (float) (i16 * 121); i6 = i15 * 100; } f = f2 / ((float) i6); Format.b bVar = new Format.b(); bVar.a = str; bVar.k = "video/mpeg2"; bVar.p = i15; bVar.q = i16; bVar.t = f; bVar.m = Collections.singletonList(copyOf); Format a2 = bVar.a(); i5 = (copyOf[7] & 15) - 1; if (i5 >= 0) { } i = i10; i2 = i9; j2 = 0; Pair create = Pair.create(a2, Long.valueOf(j2)); this.f733c.e((Format) create.first); this.l = ((Long) create.second).longValue(); this.k = true; wVar2 = this.f; if (wVar2 == null) { } if (i3 != 0) { } int i22 = i8 - b; this.f733c.d(this.o, this.p ? 1 : 0, ((int) (this.i - this.n)) - i22, i22, null); z2 = this.j; if (z2) { } this.n = this.i - ((long) i22); j = this.m; if (j == -9223372036854775807L) { } this.o = j; this.p = false; this.m = -9223372036854775807L; this.j = true; this.q = i3 != 0; i7 = i2; } } } else if (i10 == 179) { aVar.b = true; } byte[] bArr2 = a.a; aVar.a(bArr2, 0, bArr2.length); z3 = false; if (z3) { } } i = i10; i2 = i9; wVar2 = this.f; if (wVar2 == null) { } if (i3 != 0) { } int i22 = i8 - b; this.f733c.d(this.o, this.p ? 1 : 0, ((int) (this.i - this.n)) - i22, i22, null); z2 = this.j; if (z2) { } this.n = this.i - ((long) i22); j = this.m; if (j == -9223372036854775807L) { } this.o = j; this.p = false; this.m = -9223372036854775807L; this.j = true; this.q = i3 != 0; i7 = i2; } if (!this.k) { this.h.a(bArr, i7, i8); } w wVar5 = this.f; if (wVar5 != null) { wVar5.a(bArr, i7, i8); } } @Override // c.i.a.c.a2.j0.o public void c() { u.a(this.g); a aVar = this.h; aVar.b = false; aVar.f734c = 0; aVar.d = 0; w wVar = this.f; if (wVar != null) { wVar.c(); } this.i = 0; this.j = 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.b = dVar.b(); this.f733c = jVar.p(dVar.c(), 2); j0 j0Var = this.d; if (j0Var != null) { j0Var.b(jVar, dVar); } } @Override // c.i.a.c.a2.j0.o public void f(long j, int i) { this.m = j; } }