package com.applovin.impl; import android.content.Context; import android.graphics.Point; import android.media.MediaCrypto; import android.media.MediaFormat; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.os.SystemClock; import android.util.Pair; import android.view.Surface; import androidx.work.WorkRequest; import com.applovin.impl.hd; import com.applovin.impl.nd; import com.applovin.impl.wq; import com.google.android.gms.common.Scopes; import com.mbridge.msdk.playercommon.exoplayer2.C; import com.unity3d.ads.core.domain.HandleInvocationsFromAdViewer; import java.nio.ByteBuffer; import java.util.Collections; import java.util.List; /* loaded from: classes.dex */ public class pd extends ld { private static final int[] s1 = {1920, 1600, 1440, 1280, 960, 854, 640, 540, 480}; private static boolean t1; private static boolean u1; private final Context J0; private final vq K0; private final wq.a L0; private final long M0; private final int N0; private final boolean O0; private a P0; private boolean Q0; private boolean R0; private Surface S0; private h7 T0; private boolean U0; private int V0; private boolean W0; private boolean X0; private boolean Y0; private long Z0; private long a1; private long b1; private int c1; private int d1; private int e1; private long f1; private long g1; private long h1; private int i1; private int j1; private int k1; private int l1; private float m1; private xq n1; private boolean o1; private int p1; b q1; private uq r1; private void d0() { this.n1 = null; } private static boolean e0() { return "NVIDIA".equals(xp.c); } /* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */ /* JADX WARN: Code restructure failed: missing block: B:454:0x07cd, code lost: if (r0.equals("NX573J") == false) goto L47; */ /* JADX WARN: Code restructure failed: missing block: B:46:0x082f, code lost: if (r0.equals("AFTN") == false) goto L610; */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ private static boolean f0() { /* Method dump skipped, instructions count: 3044 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: com.applovin.impl.pd.f0():boolean"); } private static boolean g(long j) { return j < -30000; } private static boolean h(long j) { return j < -500000; } @Override // com.applovin.impl.qi, com.applovin.impl.ri public String getName() { return "MediaCodecVideoRenderer"; } public pd(Context context, hd.b bVar, md mdVar, long j, boolean z, Handler handler, wq wqVar, int i) { super(2, bVar, mdVar, z, 30.0f); this.M0 = j; this.N0 = i; Context applicationContext = context.getApplicationContext(); this.J0 = applicationContext; this.K0 = new vq(applicationContext); this.L0 = new wq.a(handler, wqVar); this.O0 = e0(); this.a1 = C.TIME_UNSET; this.j1 = -1; this.k1 = -1; this.m1 = -1.0f; this.V0 = 1; this.p1 = 0; d0(); } @Override // com.applovin.impl.ld, com.applovin.impl.qi public boolean d() { h7 h7Var; if (super.d() && (this.W0 || (((h7Var = this.T0) != null && this.S0 == h7Var) || I() == null || this.o1))) { this.a1 = C.TIME_UNSET; return true; } if (this.a1 == C.TIME_UNSET) { return false; } if (SystemClock.elapsedRealtime() < this.a1) { return true; } this.a1 = C.TIME_UNSET; return false; } @Override // com.applovin.impl.ld, com.applovin.impl.e2 public void x() { super.x(); this.c1 = 0; this.b1 = SystemClock.elapsedRealtime(); this.g1 = SystemClock.elapsedRealtime() * 1000; this.h1 = 0L; this.i1 = 0; this.K0.e(); } @Override // com.applovin.impl.ld, com.applovin.impl.e2 public void y() { this.a1 = C.TIME_UNSET; g0(); i0(); this.K0.f(); super.y(); } @Override // com.applovin.impl.ld, com.applovin.impl.e2 public void v() { d0(); c0(); this.U0 = false; this.K0.b(); this.q1 = null; try { super.v(); } finally { this.L0.a(this.E0); } } @Override // com.applovin.impl.ld, com.applovin.impl.e2 public void w() { try { super.w(); h7 h7Var = this.T0; if (h7Var != null) { if (this.S0 == h7Var) { this.S0 = null; } h7Var.release(); this.T0 = null; } } catch (Throwable th) { if (this.T0 != null) { Surface surface = this.S0; h7 h7Var2 = this.T0; if (surface == h7Var2) { this.S0 = null; } h7Var2.release(); this.T0 = null; } throw th; } } public pd(Context context, md mdVar, long j, boolean z, Handler handler, wq wqVar, int i) { this(context, hd.b.a, mdVar, j, z, handler, wqVar, i); } @Override // com.applovin.impl.ld public boolean K() { return this.o1 && xp.a < 23; } @Override // com.applovin.impl.ld public void W() { super.W(); this.e1 = 0; } @Override // com.applovin.impl.ld public void g(String str) { this.L0.a(str); } @Override // com.applovin.impl.ld public q5 a(kd kdVar, f9 f9Var, f9 f9Var2) { q5 a2 = kdVar.a(f9Var, f9Var2); int i = a2.e; int i2 = f9Var2.r; a aVar = this.P0; if (i2 > aVar.a || f9Var2.s > aVar.b) { i |= 256; } if (c(kdVar, f9Var2) > this.P0.c) { i |= 64; } int i3 = i; return new q5(kdVar.a, f9Var, f9Var2, i3 != 0 ? 0 : a2.d, i3); } public void i(long j) { f(j); j0(); this.E0.e++; h0(); d(j); } /* JADX INFO: Access modifiers changed from: private */ public void m0() { a0(); } @Override // com.applovin.impl.ld public void Q() { super.Q(); c0(); } public void f(int i) { n5 n5Var = this.E0; n5Var.g += i; this.c1 += i; int i2 = this.d1 + i; this.d1 = i2; n5Var.h = Math.max(i2, n5Var.h); int i3 = this.N0; if (i3 <= 0 || this.c1 < i3) { return; } g0(); } public void j(long j) { this.E0.a(j); this.h1 += j; this.i1++; } private void n0() { this.a1 = this.M0 > 0 ? SystemClock.elapsedRealtime() + this.M0 : C.TIME_UNSET; } private void c0() { hd I; this.W0 = false; if (xp.a < 23 || !this.o1 || (I = I()) == null) { return; } this.q1 = new b(I); } public void h0() { this.Y0 = true; if (this.W0) { return; } this.W0 = true; this.L0.a(this.S0); this.U0 = true; } private void k0() { if (this.U0) { this.L0.a(this.S0); } } private void j0() { int i = this.j1; if (i == -1 && this.k1 == -1) { return; } xq xqVar = this.n1; if (xqVar != null && xqVar.a == i && xqVar.b == this.k1 && xqVar.c == this.l1 && xqVar.d == this.m1) { return; } xq xqVar2 = new xq(this.j1, this.k1, this.l1, this.m1); this.n1 = xqVar2; this.L0.b(xqVar2); } private void l0() { xq xqVar = this.n1; if (xqVar != null) { this.L0.b(xqVar); } } private void g0() { if (this.c1 > 0) { long elapsedRealtime = SystemClock.elapsedRealtime(); this.L0.a(this.c1, elapsedRealtime - this.b1); this.c1 = 0; this.b1 = elapsedRealtime; } } private void i0() { int i = this.i1; if (i != 0) { this.L0.b(this.h1, i); this.h1 = 0L; this.i1 = 0; } } private static Point b(kd kdVar, f9 f9Var) { int i = f9Var.s; int i2 = f9Var.r; boolean z = i > i2; int i3 = z ? i : i2; if (z) { i = i2; } float f = i / i3; for (int i4 : s1) { int i5 = (int) (i4 * f); if (i4 <= i3 || i5 <= i) { break; } if (xp.a >= 21) { int i6 = z ? i5 : i4; if (!z) { i4 = i5; } Point a2 = kdVar.a(i6, i4); if (kdVar.a(a2.x, a2.y, f9Var.t)) { return a2; } } else { try { int a3 = xp.a(i4, 16) * 16; int a4 = xp.a(i5, 16) * 16; if (a3 * a4 <= nd.b()) { int i7 = z ? a4 : a3; if (!z) { a3 = a4; } return new Point(i7, a3); } } catch (nd.c unused) { } } } return null; } @Override // com.applovin.impl.ld public void d(long j) { super.d(j); if (this.o1) { return; } this.e1--; } public static int c(kd kdVar, f9 f9Var) { if (f9Var.n != -1) { int size = f9Var.o.size(); int i = 0; for (int i2 = 0; i2 < size; i2++) { i += ((byte[]) f9Var.o.get(i2)).length; } return f9Var.n + i; } return a(kdVar, f9Var); } public boolean h(String str) { if (str.startsWith("OMX.google")) { return false; } synchronized (pd.class) { try { if (!t1) { u1 = f0(); t1 = true; } } catch (Throwable th) { throw th; } } return u1; } public static final class a { public final int a; public final int b; public final int c; public a(int i, int i2, int i3) { this.a = i; this.b = i2; this.c = i3; } } public final class b implements hd.c, Handler.Callback { private final Handler a; public b(hd hdVar) { Handler a = xp.a((Handler.Callback) this); this.a = a; hdVar.a(this, a); } @Override // android.os.Handler.Callback public boolean handleMessage(Message message) { if (message.what != 0) { return false; } a(xp.c(message.arg1, message.arg2)); return true; } private void a(long j) { pd pdVar = pd.this; if (this != pdVar.q1) { return; } if (j == Long.MAX_VALUE) { pdVar.m0(); return; } try { pdVar.i(j); } catch (a8 e) { pd.this.a(e); } } @Override // com.applovin.impl.hd.c public void a(hd hdVar, long j, long j2) { if (xp.a < 30) { this.a.sendMessageAtFrontOfQueue(Message.obtain(this.a, 0, (int) (j >> 32), (int) j)); } else { a(j); } } } private static void a(MediaFormat mediaFormat, int i) { mediaFormat.setFeatureEnabled("tunneled-playback", true); mediaFormat.setInteger("audio-session-id", i); } public boolean d(long j, long j2) { return g(j) && j2 > 100000; } public void c(hd hdVar, int i, long j) { ko.a("skipVideoBuffer"); hdVar.a(i, false); ko.a(); this.E0.f++; } public boolean b(long j, boolean z) { int b2 = b(j); if (b2 == 0) { return false; } n5 n5Var = this.E0; n5Var.i++; int i = this.e1 + b2; if (z) { n5Var.f += i; } else { f(i); } G(); return true; } private boolean c(kd kdVar) { return xp.a >= 23 && !this.o1 && !h(kdVar.a) && (!kdVar.g || h7.b(this.J0)); } public void a(hd hdVar, int i, long j) { ko.a("dropVideoBuffer"); hdVar.a(i, false); ko.a(); f(1); } @Override // com.applovin.impl.ld public void b(p5 p5Var) { boolean z = this.o1; if (!z) { this.e1++; } if (xp.a >= 23 || !z) { return; } i(p5Var.f); } public void b(hd hdVar, int i, long j) { j0(); ko.a("releaseOutputBuffer"); hdVar.a(i, true); ko.a(); this.g1 = SystemClock.elapsedRealtime() * 1000; this.E0.e++; this.d1 = 0; h0(); } /* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */ /* JADX WARN: Code restructure failed: missing block: B:50:0x0070, code lost: if (r3.equals("video/hevc") == false) goto L18; */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ private static int a(com.applovin.impl.kd r10, com.applovin.impl.f9 r11) { /* int r0 = r11.r int r1 = r11.s r2 = -1 if (r0 == r2) goto Lc4 if (r1 != r2) goto Lb goto Lc4 Lb: java.lang.String r3 = r11.m java.lang.String r4 = "video/dolby-vision" boolean r4 = r4.equals(r3) java.lang.String r5 = "video/avc" r6 = 1 java.lang.String r7 = "video/hevc" r8 = 2 if (r4 == 0) goto L34 android.util.Pair r11 = com.applovin.impl.nd.a(r11) if (r11 == 0) goto L33 java.lang.Object r11 = r11.first java.lang.Integer r11 = (java.lang.Integer) r11 int r11 = r11.intValue() r3 = 512(0x200, float:7.17E-43) if (r11 == r3) goto L31 if (r11 == r6) goto L31 if (r11 != r8) goto L33 L31: r3 = r5 goto L34 L33: r3 = r7 L34: r3.hashCode() int r11 = r3.hashCode() r4 = 4 r9 = 3 switch(r11) { case -1664118616: goto L73; case -1662541442: goto L6c; case 1187890754: goto L61; case 1331836730: goto L58; case 1599127256: goto L4d; case 1599127257: goto L42; default: goto L40; } L40: r6 = r2 goto L7d L42: java.lang.String r11 = "video/x-vnd.on2.vp9" boolean r11 = r3.equals(r11) if (r11 != 0) goto L4b goto L40 L4b: r6 = 5 goto L7d L4d: java.lang.String r11 = "video/x-vnd.on2.vp8" boolean r11 = r3.equals(r11) if (r11 != 0) goto L56 goto L40 L56: r6 = r4 goto L7d L58: boolean r11 = r3.equals(r5) if (r11 != 0) goto L5f goto L40 L5f: r6 = r9 goto L7d L61: java.lang.String r11 = "video/mp4v-es" boolean r11 = r3.equals(r11) if (r11 != 0) goto L6a goto L40 L6a: r6 = r8 goto L7d L6c: boolean r11 = r3.equals(r7) if (r11 != 0) goto L7d goto L40 L73: java.lang.String r11 = "video/3gpp" boolean r11 = r3.equals(r11) if (r11 != 0) goto L7c goto L40 L7c: r6 = 0 L7d: switch(r6) { case 0: goto Lbd; case 1: goto Lba; case 2: goto Lbd; case 3: goto L81; case 4: goto Lbd; case 5: goto Lba; default: goto L80; } L80: return r2 L81: java.lang.String r11 = com.applovin.impl.xp.d java.lang.String r3 = "BRAVIA 4K 2015" boolean r3 = r3.equals(r11) if (r3 != 0) goto Lb9 java.lang.String r3 = com.applovin.impl.xp.c java.lang.String r4 = "Amazon" boolean r3 = r4.equals(r3) if (r3 == 0) goto Laa java.lang.String r3 = "KFSOWI" boolean r3 = r3.equals(r11) if (r3 != 0) goto Lb9 java.lang.String r3 = "AFTS" boolean r11 = r3.equals(r11) if (r11 == 0) goto Laa boolean r10 = r10.g if (r10 == 0) goto Laa goto Lb9 Laa: r10 = 16 int r11 = com.applovin.impl.xp.a(r0, r10) int r10 = com.applovin.impl.xp.a(r1, r10) int r11 = r11 * r10 int r11 = r11 * 256 Lb7: r4 = r8 goto Lc0 Lb9: return r2 Lba: int r11 = r0 * r1 goto Lc0 Lbd: int r11 = r0 * r1 goto Lb7 Lc0: int r11 = r11 * r9 int r4 = r4 * r8 int r11 = r11 / r4 return r11 Lc4: return r2 */ throw new UnsupportedOperationException("Method not decompiled: com.applovin.impl.pd.a(com.applovin.impl.kd, com.applovin.impl.f9):int"); } public boolean b(long j, long j2, boolean z) { return g(j) && !z; } @Override // com.applovin.impl.ld public boolean b(kd kdVar) { return this.S0 != null || c(kdVar); } public a a(kd kdVar, f9 f9Var, f9[] f9VarArr) { int a2; int i = f9Var.r; int i2 = f9Var.s; int c = c(kdVar, f9Var); if (f9VarArr.length == 1) { if (c != -1 && (a2 = a(kdVar, f9Var)) != -1) { c = Math.min((int) (c * 1.5f), a2); } return new a(i, i2, c); } int length = f9VarArr.length; boolean z = false; for (int i3 = 0; i3 < length; i3++) { f9 f9Var2 = f9VarArr[i3]; if (f9Var.y != null && f9Var2.y == null) { f9Var2 = f9Var2.a().a(f9Var.y).a(); } if (kdVar.a(f9Var, f9Var2).d != 0) { int i4 = f9Var2.r; z |= i4 == -1 || f9Var2.s == -1; i = Math.max(i, i4); i2 = Math.max(i2, f9Var2.s); c = Math.max(c, c(kdVar, f9Var2)); } } if (z) { pc.d("MediaCodecVideoRenderer", "Resolutions unknown. Codec max resolution: " + i + "x" + i2); Point b2 = b(kdVar, f9Var); if (b2 != null) { i = Math.max(i, b2.x); i2 = Math.max(i2, b2.y); c = Math.max(c, a(kdVar, f9Var.a().q(i).g(i2).a())); pc.d("MediaCodecVideoRenderer", "Codec max resolution adjusted to: " + i + "x" + i2); } } return new a(i, i2, c); } @Override // com.applovin.impl.ld public float a(float f, f9 f9Var, f9[] f9VarArr) { float f2 = -1.0f; for (f9 f9Var2 : f9VarArr) { float f3 = f9Var2.t; if (f3 != -1.0f) { f2 = Math.max(f2, f3); } } if (f2 == -1.0f) { return -1.0f; } return f2 * f; } @Override // com.applovin.impl.ld public List a(md mdVar, f9 f9Var, boolean z) { return a(mdVar, f9Var, z, this.o1); } private static List a(md mdVar, f9 f9Var, boolean z, boolean z2) { Pair a2; String str = f9Var.m; if (str == null) { return Collections.emptyList(); } List a3 = nd.a(mdVar.a(str, z, z2), f9Var); if ("video/dolby-vision".equals(str) && (a2 = nd.a(f9Var)) != null) { int intValue = ((Integer) a2.first).intValue(); if (intValue == 16 || intValue == 256) { a3.addAll(mdVar.a("video/hevc", z, z2)); } else if (intValue == 512) { a3.addAll(mdVar.a("video/avc", z, z2)); } } return Collections.unmodifiableList(a3); } @Override // com.applovin.impl.ld public hd.a a(kd kdVar, f9 f9Var, MediaCrypto mediaCrypto, float f) { h7 h7Var = this.T0; if (h7Var != null && h7Var.a != kdVar.g) { h7Var.release(); this.T0 = null; } String str = kdVar.c; a a2 = a(kdVar, f9Var, t()); this.P0 = a2; MediaFormat a3 = a(f9Var, str, a2, f, this.O0, this.o1 ? this.p1 : 0); if (this.S0 == null) { if (!c(kdVar)) { throw new IllegalStateException(); } if (this.T0 == null) { this.T0 = h7.a(this.J0, kdVar.g); } this.S0 = this.T0; } return hd.a.a(kdVar, a3, f9Var, this.S0, mediaCrypto); } public MediaFormat a(f9 f9Var, String str, a aVar, float f, boolean z, int i) { Pair a2; MediaFormat mediaFormat = new MediaFormat(); mediaFormat.setString("mime", str); mediaFormat.setInteger("width", f9Var.r); mediaFormat.setInteger("height", f9Var.s); sd.a(mediaFormat, f9Var.o); sd.a(mediaFormat, "frame-rate", f9Var.t); sd.a(mediaFormat, "rotation-degrees", f9Var.u); sd.a(mediaFormat, f9Var.y); if ("video/dolby-vision".equals(f9Var.m) && (a2 = nd.a(f9Var)) != null) { sd.a(mediaFormat, Scopes.PROFILE, ((Integer) a2.first).intValue()); } mediaFormat.setInteger("max-width", aVar.a); mediaFormat.setInteger("max-height", aVar.b); sd.a(mediaFormat, "max-input-size", aVar.c); if (xp.a >= 23) { mediaFormat.setInteger(HandleInvocationsFromAdViewer.KEY_DOWNLOAD_PRIORITY, 0); if (f != -1.0f) { mediaFormat.setFloat("operating-rate", f); } } if (z) { mediaFormat.setInteger("no-post-process", 1); mediaFormat.setInteger("auto-frc", 0); } if (i != 0) { a(mediaFormat, i); } return mediaFormat; } @Override // com.applovin.impl.ld public void a(p5 p5Var) { if (this.R0) { ByteBuffer byteBuffer = (ByteBuffer) b1.a(p5Var.g); if (byteBuffer.remaining() >= 7) { byte b2 = byteBuffer.get(); short s = byteBuffer.getShort(); short s2 = byteBuffer.getShort(); byte b3 = byteBuffer.get(); byte b4 = byteBuffer.get(); byteBuffer.position(0); if (b2 == -75 && s == 60 && s2 == 1 && b3 == 4 && b4 == 0) { byte[] bArr = new byte[byteBuffer.remaining()]; byteBuffer.get(bArr); byteBuffer.position(0); a(I(), bArr); } } } } @Override // com.applovin.impl.e2, com.applovin.impl.rh.b public void a(int i, Object obj) { if (i == 1) { a(obj); return; } if (i == 7) { this.r1 = (uq) obj; return; } if (i == 10) { int intValue = ((Integer) obj).intValue(); if (this.p1 != intValue) { this.p1 = intValue; if (this.o1) { U(); return; } return; } return; } if (i != 4) { if (i != 5) { super.a(i, obj); return; } else { this.K0.a(((Integer) obj).intValue()); return; } } this.V0 = ((Integer) obj).intValue(); hd I = I(); if (I != null) { I.c(this.V0); } } private void a(long j, long j2, f9 f9Var) { uq uqVar = this.r1; if (uqVar != null) { uqVar.a(j, j2, f9Var, L()); } } @Override // com.applovin.impl.ld public void a(Exception exc) { pc.a("MediaCodecVideoRenderer", "Video codec error", exc); this.L0.b(exc); } @Override // com.applovin.impl.ld public void a(String str, long j, long j2) { this.L0.a(str, j, j2); this.Q0 = h(str); this.R0 = ((kd) b1.a(J())).b(); if (xp.a < 23 || !this.o1) { return; } this.q1 = new b((hd) b1.a(I())); } @Override // com.applovin.impl.ld, com.applovin.impl.e2 public void a(boolean z, boolean z2) { super.a(z, z2); boolean z3 = q().a; b1.b((z3 && this.p1 == 0) ? false : true); if (this.o1 != z3) { this.o1 = z3; U(); } this.L0.b(this.E0); this.K0.c(); this.X0 = z2; this.Y0 = false; } @Override // com.applovin.impl.ld public q5 a(g9 g9Var) { q5 a2 = super.a(g9Var); this.L0.a(g9Var.b, a2); return a2; } @Override // com.applovin.impl.ld public void a(f9 f9Var, MediaFormat mediaFormat) { int integer; int integer2; hd I = I(); if (I != null) { I.c(this.V0); } if (this.o1) { this.j1 = f9Var.r; this.k1 = f9Var.s; } else { b1.a(mediaFormat); boolean z = mediaFormat.containsKey("crop-right") && mediaFormat.containsKey("crop-left") && mediaFormat.containsKey("crop-bottom") && mediaFormat.containsKey("crop-top"); if (z) { integer = (mediaFormat.getInteger("crop-right") - mediaFormat.getInteger("crop-left")) + 1; } else { integer = mediaFormat.getInteger("width"); } this.j1 = integer; if (z) { integer2 = (mediaFormat.getInteger("crop-bottom") - mediaFormat.getInteger("crop-top")) + 1; } else { integer2 = mediaFormat.getInteger("height"); } this.k1 = integer2; } float f = f9Var.v; this.m1 = f; if (xp.a >= 21) { int i = f9Var.u; if (i == 90 || i == 270) { int i2 = this.j1; this.j1 = this.k1; this.k1 = i2; this.m1 = 1.0f / f; } } else { this.l1 = f9Var.u; } this.K0.a(f9Var.t); } @Override // com.applovin.impl.ld, com.applovin.impl.e2 public void a(long j, boolean z) { super.a(j, z); c0(); this.K0.d(); this.f1 = C.TIME_UNSET; this.Z0 = C.TIME_UNSET; this.d1 = 0; if (z) { n0(); } else { this.a1 = C.TIME_UNSET; } } @Override // com.applovin.impl.ld public boolean a(long j, long j2, hd hdVar, ByteBuffer byteBuffer, int i, int i2, int i3, long j3, boolean z, boolean z2, f9 f9Var) { boolean z3; long j4; b1.a(hdVar); if (this.Z0 == C.TIME_UNSET) { this.Z0 = j; } if (j3 != this.f1) { this.K0.b(j3); this.f1 = j3; } long M = M(); long j5 = j3 - M; if (z && !z2) { c(hdVar, i, j5); return true; } double N = N(); boolean z4 = b() == 2; long elapsedRealtime = SystemClock.elapsedRealtime() * 1000; long j6 = (long) ((j3 - j) / N); if (z4) { j6 -= elapsedRealtime - j2; } if (this.S0 == this.T0) { if (!g(j6)) { return false; } c(hdVar, i, j5); j(j6); return true; } long j7 = elapsedRealtime - this.g1; if (this.Y0 ? this.W0 : !(z4 || this.X0)) { j4 = j7; z3 = false; } else { z3 = true; j4 = j7; } if (this.a1 == C.TIME_UNSET && j >= M && (z3 || (z4 && d(j6, j4)))) { long nanoTime = System.nanoTime(); a(j5, nanoTime, f9Var); if (xp.a >= 21) { a(hdVar, i, j5, nanoTime); } else { b(hdVar, i, j5); } j(j6); return true; } if (z4 && j != this.Z0) { long nanoTime2 = System.nanoTime(); long a2 = this.K0.a((j6 * 1000) + nanoTime2); long j8 = (a2 - nanoTime2) / 1000; boolean z5 = this.a1 != C.TIME_UNSET; if (a(j8, j2, z2) && b(j, z5)) { return false; } if (b(j8, j2, z2)) { if (z5) { c(hdVar, i, j5); } else { a(hdVar, i, j5); } j(j8); return true; } if (xp.a >= 21) { if (j8 < 50000) { a(j5, a2, f9Var); a(hdVar, i, j5, a2); j(j8); return true; } } else if (j8 < WorkRequest.DEFAULT_BACKOFF_DELAY_MILLIS) { if (j8 > 11000) { try { Thread.sleep((j8 - WorkRequest.MIN_BACKOFF_MILLIS) / 1000); } catch (InterruptedException unused) { Thread.currentThread().interrupt(); return false; } } a(j5, a2, f9Var); b(hdVar, i, j5); j(j8); return true; } } return false; } public void a(hd hdVar, int i, long j, long j2) { j0(); ko.a("releaseOutputBuffer"); hdVar.a(i, j2); ko.a(); this.g1 = SystemClock.elapsedRealtime() * 1000; this.E0.e++; this.d1 = 0; h0(); } private static void a(hd hdVar, byte[] bArr) { Bundle bundle = new Bundle(); bundle.putByteArray("hdr10-plus-info", bArr); hdVar.a(bundle); } /* JADX WARN: Multi-variable type inference failed */ /* JADX WARN: Type inference failed for: r4v0, types: [com.applovin.impl.e2, com.applovin.impl.ld, com.applovin.impl.pd] */ /* JADX WARN: Type inference failed for: r5v8, types: [android.view.Surface] */ private void a(Object obj) { h7 h7Var = obj instanceof Surface ? (Surface) obj : null; if (h7Var == null) { h7 h7Var2 = this.T0; if (h7Var2 != null) { h7Var = h7Var2; } else { kd J = J(); if (J != null && c(J)) { h7Var = h7.a(this.J0, J.g); this.T0 = h7Var; } } } if (this.S0 == h7Var) { if (h7Var == null || h7Var == this.T0) { return; } l0(); k0(); return; } this.S0 = h7Var; this.K0.a(h7Var); this.U0 = false; int b2 = b(); hd I = I(); if (I != null) { if (xp.a >= 23 && h7Var != null && !this.Q0) { a(I, h7Var); } else { U(); P(); } } if (h7Var != null && h7Var != this.T0) { l0(); c0(); if (b2 == 2) { n0(); return; } return; } d0(); c0(); } public void a(hd hdVar, Surface surface) { hdVar.a(surface); } @Override // com.applovin.impl.ld, com.applovin.impl.qi public void a(float f, float f2) { super.a(f, f2); this.K0.b(f); } public boolean a(long j, long j2, boolean z) { return h(j) && !z; } @Override // com.applovin.impl.ld public int a(md mdVar, f9 f9Var) { int i = 0; if (!Cif.i(f9Var.m)) { return ri.a(0); } boolean z = f9Var.p != null; List a2 = a(mdVar, f9Var, z, false); if (z && a2.isEmpty()) { a2 = a(mdVar, f9Var, false, false); } if (a2.isEmpty()) { return ri.a(1); } if (!ld.d(f9Var)) { return ri.a(2); } kd kdVar = (kd) a2.get(0); boolean b2 = kdVar.b(f9Var); int i2 = kdVar.c(f9Var) ? 16 : 8; if (b2) { List a3 = a(mdVar, f9Var, z, true); if (!a3.isEmpty()) { kd kdVar2 = (kd) a3.get(0); if (kdVar2.b(f9Var) && kdVar2.c(f9Var)) { i = 32; } } } return ri.a(b2 ? 4 : 3, i2, i); } @Override // com.applovin.impl.ld public jd a(Throwable th, kd kdVar) { return new od(th, kdVar, this.S0); } }