package uc; import ai.clova.cic.clientlib.exoplayer2.C; import com.google.android.gms.internal.ads.zzaiu; import com.google.android.gms.internal.ads.zzaiv; import com.google.android.gms.internal.ads.zzakn; import java.io.IOException; import java.io.StringReader; import java.util.Objects; import org.apache.cordova.camera.CameraLauncher; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; import org.xmlpull.v1.XmlPullParserFactory; public final class gr2 implements up2 { /* renamed from: a reason: collision with root package name */ public final u7 f156572a = new u7(6); /* renamed from: b reason: collision with root package name */ public wp2 f156573b; /* renamed from: c reason: collision with root package name */ public int f156574c; /* renamed from: d reason: collision with root package name */ public int f156575d; /* renamed from: e reason: collision with root package name */ public int f156576e; /* renamed from: f reason: collision with root package name */ public long f156577f = -1; /* renamed from: g reason: collision with root package name */ public zzakn f156578g; /* renamed from: h reason: collision with root package name */ public vp2 f156579h; /* renamed from: i reason: collision with root package name */ public jr2 f156580i; /* renamed from: j reason: collision with root package name */ public ts2 f156581j; /* JADX WARNING: Code restructure failed: missing block: B:88:0x016e, code lost: r17 = ai.clova.cic.clientlib.exoplayer2.C.TIME_UNSET; */ /* JADX WARNING: Removed duplicated region for block: B:119:0x0212 */ /* JADX WARNING: Removed duplicated region for block: B:144:0x0269 */ @Override // uc.up2 public final int a(vp2 vp22, kq2 kq22) throws IOException { zzakn zzakn; String str; int i14; String str2; ir2 ir22; int size; long j14; long j15; long j16; long j17; long j18; int i15 = this.f156574c; int i16 = 1; int i17 = 4; if (i15 == 0) { this.f156572a.i(2); ((qp2) vp22).k(this.f156572a.f162518a, 0, 2, false); int u14 = this.f156572a.u(); this.f156575d = u14; if (u14 == 65498) { if (this.f156577f != -1) { this.f156574c = 4; } else { c(); } } else if ((u14 < 65488 || u14 > 65497) && u14 != 65281) { this.f156574c = 1; } return 0; } else if (i15 == 1) { this.f156572a.i(2); ((qp2) vp22).k(this.f156572a.f162518a, 0, 2, false); this.f156576e = this.f156572a.u() - 2; this.f156574c = 2; return 0; } else if (i15 == 2) { if (this.f156575d == 65505) { int i18 = this.f156576e; byte[] bArr = new byte[i18]; ((qp2) vp22).k(bArr, 0, i18, false); if (this.f156578g == null) { zzakn = null; if (i18 + 0 != 0) { i14 = 0; while (i14 < i18 && bArr[i14] != 0) { i14++; } int i19 = d8.f155212a; str = new String(bArr, 0, i14 + 0, ez1.f155997b); if (i14 < i18) { i14++; } } else { i14 = 0; str = null; } if ("http://ns.adobe.com/xap/1.0/".equals(str)) { if (i18 - i14 != 0) { int i24 = i14; while (i24 < i18 && bArr[i24] != 0) { i24++; } int i25 = d8.f155212a; str2 = new String(bArr, i14, i24 - i14, ez1.f155997b); } else { str2 = null; } if (str2 != null) { long F = vp22.F(); if (F != -1) { try { XmlPullParser newPullParser = XmlPullParserFactory.newInstance().newPullParser(); newPullParser.setInput(new StringReader(str2)); newPullParser.next(); if (e8.b(newPullParser, "x:xmpmeta")) { rz1 rz12 = j12.f157496c; j12<Object> j122 = i22.f157181f; long j19 = C.TIME_UNSET; loop2: while (true) { newPullParser.next(); if (e8.b(newPullParser, "rdf:Description")) { String[] strArr = mr2.f159160a; int i26 = 0; while (true) { if (i26 >= i17) { break loop2; } String c14 = e8.c(newPullParser, strArr[i26]); if (c14 != null) { if (Integer.parseInt(c14) != i16) { break; } String[] strArr2 = mr2.f159161b; int i27 = 0; while (true) { if (i27 >= i17) { break; } String c15 = e8.c(newPullParser, strArr2[i27]); if (c15 != null) { long parseLong = Long.parseLong(c15); if (parseLong != -1) { j19 = parseLong; } } else { i27++; } } String[] strArr3 = mr2.f159162c; int i28 = 0; while (true) { if (i28 >= 2) { j122 = i22.f157181f; break; } String c16 = e8.c(newPullParser, strArr3[i28]); if (c16 != null) { j122 = j12.D(new hr2(CameraLauncher.JPEG_MIME_TYPE, "Primary", 0, 0), new hr2("video/mp4", "MotionPhoto", Long.parseLong(c16), 0)); break; } i28++; } } else { i26++; } } } else if (e8.b(newPullParser, "Container:Directory")) { j122 = mr2.a(newPullParser, "Container", "Item"); } else if (e8.b(newPullParser, "GContainer:Directory")) { j122 = mr2.a(newPullParser, "GContainer", "GContainerItem"); } if (!e8.a(newPullParser, "x:xmpmeta")) { j19 = j19; i16 = 1; i17 = 4; } else if (!j122.isEmpty()) { ir22 = new ir2(j19, j122); } } if (ir22 != null && ir22.f157421b.size() >= 2) { boolean z14 = false; j14 = -1; j15 = -1; j16 = -1; j17 = -1; for (size = ir22.f157421b.size() - 1; size >= 0; size--) { hr2 hr22 = ir22.f157421b.get(size); z14 |= "video/mp4".equals(hr22.f157083a); if (size == 0) { F -= hr22.f157085c; j18 = 0; } else { j18 = F - hr22.f157084b; } F = j18; if (z14 && F != F) { j17 = F - F; z14 = false; j16 = F; } if (size == 0) { j15 = F; } if (size == 0) { j14 = F; } } if (!(j16 == -1 || j17 == -1 || j14 == -1 || j15 == -1)) { zzakn = new zzakn(j14, j15, ir22.f157420a, j16, j17); } } } else { throw n4.a("Couldn't find xmp metadata", null); } } catch (NumberFormatException | XmlPullParserException | n4 unused) { } } this.f156578g = zzakn; if (zzakn != null) { this.f156577f = zzakn.f28858e; } } } } } else { ((qp2) vp22).m(this.f156576e, false); } this.f156574c = 0; return 0; } else if (i15 == 4) { long C = vp22.C(); long j24 = this.f156577f; if (C == j24) { if (!vp22.c(this.f156572a.f162518a, 0, 1, true)) { c(); } else { vp22.A(); if (this.f156581j == null) { this.f156581j = new ts2(0); } jr2 jr22 = new jr2(vp22, this.f156577f); this.f156580i = jr22; Objects.requireNonNull(this.f156581j); if (us2.a(jr22, false, false)) { ts2 ts22 = this.f156581j; long j25 = this.f156577f; wp2 wp22 = this.f156573b; Objects.requireNonNull(wp22); ts22.f162379p = new lr2(j25, wp22); zzakn zzakn2 = this.f156578g; Objects.requireNonNull(zzakn2); g(zzakn2); this.f156574c = 5; } else { c(); } } return 0; } kq22.f158223a = j24; return 1; } else if (i15 == 5) { if (this.f156580i == null || vp22 != this.f156579h) { this.f156579h = vp22; this.f156580i = new jr2(vp22, this.f156577f); } ts2 ts23 = this.f156581j; Objects.requireNonNull(ts23); int a14 = ts23.a(this.f156580i, kq22); if (a14 == 1) { kq22.f158223a += this.f156577f; } return a14; } else if (i15 == 6) { return -1; } else { throw new IllegalStateException(); } ir22 = null; boolean z142 = false; j14 = -1; j15 = -1; j16 = -1; j17 = -1; while (size >= 0) { } zzakn = new zzakn(j14, j15, ir22.f157420a, j16, j17); this.f156578g = zzakn; if (zzakn != null) { } this.f156574c = 0; return 0; } public final int b(vp2 vp22) throws IOException { this.f156572a.i(2); ((qp2) vp22).c(this.f156572a.f162518a, 0, 2, false); return this.f156572a.u(); } public final void c() { g(new zzaiu[0]); wp2 wp22 = this.f156573b; Objects.requireNonNull(wp22); wp22.M(); this.f156573b.a(new mq2(C.TIME_UNSET, 0)); this.f156574c = 6; } @Override // uc.up2 public final void d(long j14, long j15) { if (j14 == 0) { this.f156574c = 0; this.f156581j = null; } else if (this.f156574c == 5) { ts2 ts22 = this.f156581j; Objects.requireNonNull(ts22); ts22.d(j14, j15); } } @Override // uc.up2 public final boolean e(vp2 vp22) throws IOException { if (b(vp22) != 65496) { return false; } int b14 = b(vp22); this.f156575d = b14; if (b14 == 65504) { this.f156572a.i(2); qp2 qp22 = (qp2) vp22; qp22.c(this.f156572a.f162518a, 0, 2, false); qp22.o(this.f156572a.u() - 2, false); b14 = b(vp22); this.f156575d = b14; } if (b14 == 65505) { qp2 qp23 = (qp2) vp22; qp23.o(2, false); this.f156572a.i(6); qp23.c(this.f156572a.f162518a, 0, 6, false); if (this.f156572a.y() == 1165519206 && this.f156572a.u() == 0) { return true; } return false; } return false; } @Override // uc.up2 public final void f(wp2 wp22) { this.f156573b = wp22; } public final void g(zzaiu... zzaiuArr) { wp2 wp22 = this.f156573b; Objects.requireNonNull(wp22); rq2 f14 = wp22.f(1024, 4); o3 o3Var = new o3(); o3Var.f159686i = CameraLauncher.JPEG_MIME_TYPE; o3Var.f159685h = new zzaiv(zzaiuArr); f14.c(new p3(o3Var)); } }