package R0;

import A1.G;
import B0.C0021h;
import B0.C0022i;
import B0.C0030q;
import B0.L;
import B0.p0;
import C3.D;
import C3.E;
import C3.W;
import L0.c0;
import android.content.Context;
import android.graphics.Point;
import android.media.MediaCodecInfo;
import android.media.MediaCrypto;
import android.media.MediaFormat;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.SystemClock;
import android.os.Trace;
import android.util.Pair;
import android.util.SparseArray;
import android.view.Surface;
import d3.R0;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.PriorityQueue;
import n4.u0;
import u0.C1570f;
import u0.C1578n;
import u0.C1579o;
import u0.P;
import u0.S;
import u0.d0;
import x0.AbstractC1709a;

/* JADX INFO: loaded from: classes.dex */
public final class j extends I0.t {

    /* JADX INFO: renamed from: G1, reason: collision with root package name */
    public static final int[] f5901G1 = {1920, 1600, 1440, 1280, 960, 854, 640, 540, 480};

    /* JADX INFO: renamed from: H1, reason: collision with root package name */
    public static boolean f5902H1;

    /* JADX INFO: renamed from: I1, reason: collision with root package name */
    public static boolean f5903I1;

    /* JADX INFO: renamed from: A1, reason: collision with root package name */
    public t f5904A1;

    /* JADX INFO: renamed from: B1, reason: collision with root package name */
    public long f5905B1;

    /* JADX INFO: renamed from: C1, reason: collision with root package name */
    public long f5906C1;

    /* JADX INFO: renamed from: D1, reason: collision with root package name */
    public boolean f5907D1;

    /* JADX INFO: renamed from: E1, reason: collision with root package name */
    public boolean f5908E1;

    /* JADX INFO: renamed from: F1, reason: collision with root package name */
    public int f5909F1;

    /* JADX INFO: renamed from: S0, reason: collision with root package name */
    public final Context f5910S0;

    /* JADX INFO: renamed from: T0, reason: collision with root package name */
    public final boolean f5911T0;

    /* JADX INFO: renamed from: U0, reason: collision with root package name */
    public final D0.m f5912U0;

    /* JADX INFO: renamed from: V0, reason: collision with root package name */
    public final int f5913V0;
    public final boolean W0;

    /* JADX INFO: renamed from: X0, reason: collision with root package name */
    public final v f5914X0;

    /* JADX INFO: renamed from: Y0, reason: collision with root package name */
    public final u f5915Y0;

    /* JADX INFO: renamed from: Z0, reason: collision with root package name */
    public final long f5916Z0;
    public final PriorityQueue a1;

    /* JADX INFO: renamed from: b1, reason: collision with root package name */
    public h f5917b1;

    /* JADX INFO: renamed from: c1, reason: collision with root package name */
    public boolean f5918c1;

    /* JADX INFO: renamed from: d1, reason: collision with root package name */
    public boolean f5919d1;

    /* JADX INFO: renamed from: e1, reason: collision with root package name */
    public m f5920e1;

    /* JADX INFO: renamed from: f1, reason: collision with root package name */
    public boolean f5921f1;

    /* JADX INFO: renamed from: g1, reason: collision with root package name */
    public List f5922g1;

    /* JADX INFO: renamed from: h1, reason: collision with root package name */
    public Surface f5923h1;

    /* JADX INFO: renamed from: i1, reason: collision with root package name */
    public l f5924i1;

    /* JADX INFO: renamed from: j1, reason: collision with root package name */
    public x0.p f5925j1;

    /* JADX INFO: renamed from: k1, reason: collision with root package name */
    public boolean f5926k1;

    /* JADX INFO: renamed from: l1, reason: collision with root package name */
    public int f5927l1;

    /* JADX INFO: renamed from: m1, reason: collision with root package name */
    public int f5928m1;

    /* JADX INFO: renamed from: n1, reason: collision with root package name */
    public long f5929n1;

    /* JADX INFO: renamed from: o1, reason: collision with root package name */
    public int f5930o1;
    public int p1;

    /* JADX INFO: renamed from: q1, reason: collision with root package name */
    public int f5931q1;

    /* JADX INFO: renamed from: r1, reason: collision with root package name */
    public long f5932r1;

    /* JADX INFO: renamed from: s1, reason: collision with root package name */
    public int f5933s1;

    /* JADX INFO: renamed from: t1, reason: collision with root package name */
    public long f5934t1;

    /* JADX INFO: renamed from: u1, reason: collision with root package name */
    public d0 f5935u1;

    /* JADX INFO: renamed from: v1, reason: collision with root package name */
    public d0 f5936v1;

    /* JADX INFO: renamed from: w1, reason: collision with root package name */
    public int f5937w1;

    /* JADX INFO: renamed from: x1, reason: collision with root package name */
    public boolean f5938x1;

    /* JADX INFO: renamed from: y1, reason: collision with root package name */
    public int f5939y1;

    /* JADX INFO: renamed from: z1, reason: collision with root package name */
    public i f5940z1;

    public j(g gVar) {
        super(2, gVar.f5891c, 30.0f);
        Context applicationContext = gVar.f5889a.getApplicationContext();
        this.f5910S0 = applicationContext;
        this.f5913V0 = gVar.f5895g;
        this.f5920e1 = null;
        this.f5912U0 = new D0.m(gVar.f5893e, gVar.f5894f, 1);
        this.f5911T0 = this.f5920e1 == null;
        this.f5914X0 = new v(applicationContext, this, gVar.f5892d);
        this.f5915Y0 = new u();
        this.W0 = "NVIDIA".equals(Build.MANUFACTURER);
        this.f5925j1 = x0.p.f18542c;
        this.f5927l1 = 1;
        this.f5928m1 = 0;
        this.f5935u1 = d0.f17268d;
        this.f5939y1 = 0;
        this.f5936v1 = null;
        this.f5937w1 = -1000;
        this.f5905B1 = -9223372036854775807L;
        this.f5906C1 = -9223372036854775807L;
        this.a1 = new PriorityQueue();
        this.f5916Z0 = -9223372036854775807L;
    }

    /* JADX WARN: Failed to restore switch over string. Please report as a decompilation issue */
    /* JADX WARN: Removed duplicated region for block: B:49:0x008f A[FALL_THROUGH] */
    /* JADX WARN: Removed duplicated region for block: B:50:0x0092  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static boolean u0(String str) {
        byte b8;
        byte b9;
        byte b10 = 26;
        boolean z8 = false;
        if (str.startsWith("OMX.google")) {
            return false;
        }
        synchronized (j.class) {
            try {
                if (!f5902H1) {
                    int i = x0.v.f18553a;
                    if (i <= 28) {
                        String str2 = Build.DEVICE;
                        str2.getClass();
                        switch (str2.hashCode()) {
                            case -1339091551:
                                b9 = !str2.equals("dangal") ? (byte) -1 : (byte) 0;
                                break;
                            case -1220081023:
                                b9 = !str2.equals("dangalFHD") ? (byte) -1 : (byte) 1;
                                break;
                            case -1220066608:
                                b9 = !str2.equals("dangalUHD") ? (byte) -1 : (byte) 2;
                                break;
                            case -1012436106:
                                b9 = !str2.equals("oneday") ? (byte) -1 : (byte) 3;
                                break;
                            case -760312546:
                                b9 = !str2.equals("aquaman") ? (byte) -1 : (byte) 4;
                                break;
                            case -64886864:
                                b9 = !str2.equals("magnolia") ? (byte) -1 : (byte) 5;
                                break;
                            case 3415681:
                                b9 = !str2.equals("once") ? (byte) -1 : (byte) 6;
                                break;
                            case 825323514:
                                b9 = !str2.equals("machuca") ? (byte) -1 : (byte) 7;
                                break;
                            default:
                                b9 = -1;
                                break;
                        }
                        switch (b9) {
                            default:
                                if (i > 27 || !"HWEML".equals(Build.DEVICE)) {
                                    String str3 = Build.MODEL;
                                    str3.getClass();
                                    switch (str3.hashCode()) {
                                        case -349662828:
                                            b8 = !str3.equals("AFTJMST12") ? (byte) -1 : (byte) 0;
                                            break;
                                        case -321033677:
                                            b8 = !str3.equals("AFTKMST12") ? (byte) -1 : (byte) 1;
                                            break;
                                        case 2006354:
                                            b8 = !str3.equals("AFTA") ? (byte) -1 : (byte) 2;
                                            break;
                                        case 2006367:
                                            b8 = !str3.equals("AFTN") ? (byte) -1 : (byte) 3;
                                            break;
                                        case 2006371:
                                            b8 = !str3.equals("AFTR") ? (byte) -1 : (byte) 4;
                                            break;
                                        case 1785421873:
                                            b8 = !str3.equals("AFTEU011") ? (byte) -1 : (byte) 5;
                                            break;
                                        case 1785421876:
                                            b8 = !str3.equals("AFTEU014") ? (byte) -1 : (byte) 6;
                                            break;
                                        case 1798172390:
                                            b8 = !str3.equals("AFTSO001") ? (byte) -1 : (byte) 7;
                                            break;
                                        case 2119412532:
                                            b8 = !str3.equals("AFTEUFF014") ? (byte) -1 : (byte) 8;
                                            break;
                                        default:
                                            b8 = -1;
                                            break;
                                    }
                                    switch (b8) {
                                        default:
                                            if (i <= 26) {
                                                String str4 = Build.DEVICE;
                                                str4.getClass();
                                                switch (str4.hashCode()) {
                                                    case -2144781245:
                                                        b10 = !str4.equals("GIONEE_SWW1609") ? (byte) -1 : (byte) 0;
                                                        break;
                                                    case -2144781185:
                                                        b10 = !str4.equals("GIONEE_SWW1627") ? (byte) -1 : (byte) 1;
                                                        break;
                                                    case -2144781160:
                                                        b10 = !str4.equals("GIONEE_SWW1631") ? (byte) -1 : (byte) 2;
                                                        break;
                                                    case -2097309513:
                                                        b10 = !str4.equals("K50a40") ? (byte) -1 : (byte) 3;
                                                        break;
                                                    case -2022874474:
                                                        b10 = !str4.equals("CP8676_I02") ? (byte) -1 : (byte) 4;
                                                        break;
                                                    case -1978993182:
                                                        b10 = !str4.equals("NX541J") ? (byte) -1 : (byte) 5;
                                                        break;
                                                    case -1978990237:
                                                        b10 = !str4.equals("NX573J") ? (byte) -1 : (byte) 6;
                                                        break;
                                                    case -1936688988:
                                                        b10 = !str4.equals("PGN528") ? (byte) -1 : (byte) 7;
                                                        break;
                                                    case -1936688066:
                                                        b10 = !str4.equals("PGN610") ? (byte) -1 : (byte) 8;
                                                        break;
                                                    case -1936688065:
                                                        b10 = !str4.equals("PGN611") ? (byte) -1 : (byte) 9;
                                                        break;
                                                    case -1931988508:
                                                        b10 = !str4.equals("AquaPowerM") ? (byte) -1 : (byte) 10;
                                                        break;
                                                    case -1885099851:
                                                        b10 = !str4.equals("RAIJIN") ? (byte) -1 : (byte) 11;
                                                        break;
                                                    case -1696512866:
                                                        b10 = !str4.equals("XT1663") ? (byte) -1 : (byte) 12;
                                                        break;
                                                    case -1680025915:
                                                        b10 = !str4.equals("ComioS1") ? (byte) -1 : (byte) 13;
                                                        break;
                                                    case -1615810839:
                                                        b10 = !str4.equals("Phantom6") ? (byte) -1 : (byte) 14;
                                                        break;
                                                    case -1600724499:
                                                        b10 = !str4.equals("pacificrim") ? (byte) -1 : (byte) 15;
                                                        break;
                                                    case -1554255044:
                                                        b10 = !str4.equals("vernee_M5") ? (byte) -1 : (byte) 16;
                                                        break;
                                                    case -1481772737:
                                                        b10 = !str4.equals("panell_dl") ? (byte) -1 : (byte) 17;
                                                        break;
                                                    case -1481772730:
                                                        b10 = !str4.equals("panell_ds") ? (byte) -1 : (byte) 18;
                                                        break;
                                                    case -1481772729:
                                                        b10 = !str4.equals("panell_dt") ? (byte) -1 : (byte) 19;
                                                        break;
                                                    case -1320080169:
                                                        b10 = !str4.equals("GiONEE_GBL7319") ? (byte) -1 : (byte) 20;
                                                        break;
                                                    case -1217592143:
                                                        b10 = !str4.equals("BRAVIA_ATV2") ? (byte) -1 : (byte) 21;
                                                        break;
                                                    case -1180384755:
                                                        b10 = !str4.equals("iris60") ? (byte) -1 : (byte) 22;
                                                        break;
                                                    case -1139198265:
                                                        b10 = !str4.equals("Slate_Pro") ? (byte) -1 : (byte) 23;
                                                        break;
                                                    case -1052835013:
                                                        b10 = !str4.equals("namath") ? (byte) -1 : (byte) 24;
                                                        break;
                                                    case -993250464:
                                                        b10 = !str4.equals("A10-70F") ? (byte) -1 : (byte) 25;
                                                        break;
                                                    case -993250458:
                                                        if (!str4.equals("A10-70L")) {
                                                            b10 = -1;
                                                        }
                                                        break;
                                                    case -965403638:
                                                        b10 = !str4.equals("s905x018") ? (byte) -1 : (byte) 27;
                                                        break;
                                                    case -958336948:
                                                        b10 = !str4.equals("ELUGA_Ray_X") ? (byte) -1 : (byte) 28;
                                                        break;
                                                    case -879245230:
                                                        b10 = !str4.equals("tcl_eu") ? (byte) -1 : (byte) 29;
                                                        break;
                                                    case -842500323:
                                                        b10 = !str4.equals("nicklaus_f") ? (byte) -1 : (byte) 30;
                                                        break;
                                                    case -821392978:
                                                        b10 = !str4.equals("A7000-a") ? (byte) -1 : (byte) 31;
                                                        break;
                                                    case -797483286:
                                                        b10 = !str4.equals("SVP-DTV15") ? (byte) -1 : (byte) 32;
                                                        break;
                                                    case -794946968:
                                                        b10 = !str4.equals("watson") ? (byte) -1 : (byte) 33;
                                                        break;
                                                    case -788334647:
                                                        b10 = !str4.equals("whyred") ? (byte) -1 : (byte) 34;
                                                        break;
                                                    case -782144577:
                                                        b10 = !str4.equals("OnePlus5T") ? (byte) -1 : (byte) 35;
                                                        break;
                                                    case -575125681:
                                                        b10 = !str4.equals("GiONEE_CBL7513") ? (byte) -1 : (byte) 36;
                                                        break;
                                                    case -521118391:
                                                        b10 = !str4.equals("GIONEE_GBL7360") ? (byte) -1 : (byte) 37;
                                                        break;
                                                    case -430914369:
                                                        b10 = !str4.equals("Pixi4-7_3G") ? (byte) -1 : (byte) 38;
                                                        break;
                                                    case -290434366:
                                                        b10 = !str4.equals("taido_row") ? (byte) -1 : (byte) 39;
                                                        break;
                                                    case -282781963:
                                                        b10 = !str4.equals("BLACK-1X") ? (byte) -1 : (byte) 40;
                                                        break;
                                                    case -277133239:
                                                        b10 = !str4.equals("Z12_PRO") ? (byte) -1 : (byte) 41;
                                                        break;
                                                    case -173639913:
                                                        b10 = !str4.equals("ELUGA_A3_Pro") ? (byte) -1 : (byte) 42;
                                                        break;
                                                    case -56598463:
                                                        b10 = !str4.equals("woods_fn") ? (byte) -1 : (byte) 43;
                                                        break;
                                                    case 2126:
                                                        b10 = !str4.equals("C1") ? (byte) -1 : (byte) 44;
                                                        break;
                                                    case 2564:
                                                        b10 = !str4.equals("Q5") ? (byte) -1 : (byte) 45;
                                                        break;
                                                    case 2715:
                                                        b10 = !str4.equals("V1") ? (byte) -1 : (byte) 46;
                                                        break;
                                                    case 2719:
                                                        b10 = !str4.equals("V5") ? (byte) -1 : (byte) 47;
                                                        break;
                                                    case 3091:
                                                        b10 = !str4.equals("b5") ? (byte) -1 : (byte) 48;
                                                        break;
                                                    case 3483:
                                                        b10 = !str4.equals("mh") ? (byte) -1 : (byte) 49;
                                                        break;
                                                    case 73405:
                                                        b10 = !str4.equals("JGZ") ? (byte) -1 : (byte) 50;
                                                        break;
                                                    case 75537:
                                                        b10 = !str4.equals("M04") ? (byte) -1 : (byte) 51;
                                                        break;
                                                    case 75739:
                                                        b10 = !str4.equals("M5c") ? (byte) -1 : (byte) 52;
                                                        break;
                                                    case 76779:
                                                        b10 = !str4.equals("MX6") ? (byte) -1 : (byte) 53;
                                                        break;
                                                    case 78669:
                                                        b10 = !str4.equals("P85") ? (byte) -1 : (byte) 54;
                                                        break;
                                                    case 79305:
                                                        b10 = !str4.equals("PLE") ? (byte) -1 : (byte) 55;
                                                        break;
                                                    case 80618:
                                                        b10 = !str4.equals("QX1") ? (byte) -1 : (byte) 56;
                                                        break;
                                                    case 88274:
                                                        b10 = !str4.equals("Z80") ? (byte) -1 : (byte) 57;
                                                        break;
                                                    case 98846:
                                                        b10 = !str4.equals("cv1") ? (byte) -1 : (byte) 58;
                                                        break;
                                                    case 98848:
                                                        b10 = !str4.equals("cv3") ? (byte) -1 : (byte) 59;
                                                        break;
                                                    case 99329:
                                                        b10 = !str4.equals("deb") ? (byte) -1 : (byte) 60;
                                                        break;
                                                    case 101481:
                                                        b10 = !str4.equals("flo") ? (byte) -1 : (byte) 61;
                                                        break;
                                                    case 1513190:
                                                        b10 = !str4.equals("1601") ? (byte) -1 : (byte) 62;
                                                        break;
                                                    case 1514184:
                                                        b10 = !str4.equals("1713") ? (byte) -1 : (byte) 63;
                                                        break;
                                                    case 1514185:
                                                        b10 = !str4.equals("1714") ? (byte) -1 : (byte) 64;
                                                        break;
                                                    case 2133089:
                                                        b10 = !str4.equals("F01H") ? (byte) -1 : (byte) 65;
                                                        break;
                                                    case 2133091:
                                                        b10 = !str4.equals("F01J") ? (byte) -1 : (byte) 66;
                                                        break;
                                                    case 2133120:
                                                        b10 = !str4.equals("F02H") ? (byte) -1 : (byte) 67;
                                                        break;
                                                    case 2133151:
                                                        b10 = !str4.equals("F03H") ? (byte) -1 : (byte) 68;
                                                        break;
                                                    case 2133182:
                                                        b10 = !str4.equals("F04H") ? (byte) -1 : (byte) 69;
                                                        break;
                                                    case 2133184:
                                                        b10 = !str4.equals("F04J") ? (byte) -1 : (byte) 70;
                                                        break;
                                                    case 2436959:
                                                        b10 = !str4.equals("P681") ? (byte) -1 : (byte) 71;
                                                        break;
                                                    case 2463773:
                                                        b10 = !str4.equals("Q350") ? (byte) -1 : (byte) 72;
                                                        break;
                                                    case 2464648:
                                                        b10 = !str4.equals("Q427") ? (byte) -1 : (byte) 73;
                                                        break;
                                                    case 2689555:
                                                        b10 = !str4.equals("XE2X") ? (byte) -1 : (byte) 74;
                                                        break;
                                                    case 3154429:
                                                        b10 = !str4.equals("fugu") ? (byte) -1 : (byte) 75;
                                                        break;
                                                    case 3284551:
                                                        b10 = !str4.equals("kate") ? (byte) -1 : (byte) 76;
                                                        break;
                                                    case 3351335:
                                                        b10 = !str4.equals("mido") ? (byte) -1 : (byte) 77;
                                                        break;
                                                    case 3386211:
                                                        b10 = !str4.equals("p212") ? (byte) -1 : (byte) 78;
                                                        break;
                                                    case 41325051:
                                                        b10 = !str4.equals("MEIZU_M5") ? (byte) -1 : (byte) 79;
                                                        break;
                                                    case 51349633:
                                                        b10 = !str4.equals("601LV") ? (byte) -1 : (byte) 80;
                                                        break;
                                                    case 51350594:
                                                        b10 = !str4.equals("602LV") ? (byte) -1 : (byte) 81;
                                                        break;
                                                    case 55178625:
                                                        b10 = !str4.equals("Aura_Note_2") ? (byte) -1 : (byte) 82;
                                                        break;
                                                    case 61542055:
                                                        b10 = !str4.equals("A1601") ? (byte) -1 : (byte) 83;
                                                        break;
                                                    case 65355429:
                                                        b10 = !str4.equals("E5643") ? (byte) -1 : (byte) 84;
                                                        break;
                                                    case 66214468:
                                                        b10 = !str4.equals("F3111") ? (byte) -1 : (byte) 85;
                                                        break;
                                                    case 66214470:
                                                        b10 = !str4.equals("F3113") ? (byte) -1 : (byte) 86;
                                                        break;
                                                    case 66214473:
                                                        b10 = !str4.equals("F3116") ? (byte) -1 : (byte) 87;
                                                        break;
                                                    case 66215429:
                                                        b10 = !str4.equals("F3211") ? (byte) -1 : (byte) 88;
                                                        break;
                                                    case 66215431:
                                                        b10 = !str4.equals("F3213") ? (byte) -1 : (byte) 89;
                                                        break;
                                                    case 66215433:
                                                        b10 = !str4.equals("F3215") ? (byte) -1 : (byte) 90;
                                                        break;
                                                    case 66216390:
                                                        b10 = !str4.equals("F3311") ? (byte) -1 : (byte) 91;
                                                        break;
                                                    case 76402249:
                                                        b10 = !str4.equals("PRO7S") ? (byte) -1 : (byte) 92;
                                                        break;
                                                    case 76404105:
                                                        b10 = !str4.equals("Q4260") ? (byte) -1 : (byte) 93;
                                                        break;
                                                    case 76404911:
                                                        b10 = !str4.equals("Q4310") ? (byte) -1 : (byte) 94;
                                                        break;
                                                    case 80963634:
                                                        b10 = !str4.equals("V23GB") ? (byte) -1 : (byte) 95;
                                                        break;
                                                    case 82882791:
                                                        b10 = !str4.equals("X3_HK") ? (byte) -1 : (byte) 96;
                                                        break;
                                                    case 98715550:
                                                        b10 = !str4.equals("i9031") ? (byte) -1 : (byte) 97;
                                                        break;
                                                    case 101370885:
                                                        b10 = !str4.equals("l5460") ? (byte) -1 : (byte) 98;
                                                        break;
                                                    case 102844228:
                                                        b10 = !str4.equals("le_x6") ? (byte) -1 : (byte) 99;
                                                        break;
                                                    case 165221241:
                                                        b10 = !str4.equals("A2016a40") ? (byte) -1 : (byte) 100;
                                                        break;
                                                    case 182191441:
                                                        b10 = !str4.equals("CPY83_I00") ? (byte) -1 : (byte) 101;
                                                        break;
                                                    case 245388979:
                                                        b10 = !str4.equals("marino_f") ? (byte) -1 : (byte) 102;
                                                        break;
                                                    case 287431619:
                                                        b10 = !str4.equals("griffin") ? (byte) -1 : (byte) 103;
                                                        break;
                                                    case 307593612:
                                                        b10 = !str4.equals("A7010a48") ? (byte) -1 : (byte) 104;
                                                        break;
                                                    case 308517133:
                                                        b10 = !str4.equals("A7020a48") ? (byte) -1 : (byte) 105;
                                                        break;
                                                    case 316215098:
                                                        b10 = !str4.equals("TB3-730F") ? (byte) -1 : (byte) 106;
                                                        break;
                                                    case 316215116:
                                                        b10 = !str4.equals("TB3-730X") ? (byte) -1 : (byte) 107;
                                                        break;
                                                    case 316246811:
                                                        b10 = !str4.equals("TB3-850F") ? (byte) -1 : (byte) 108;
                                                        break;
                                                    case 316246818:
                                                        b10 = !str4.equals("TB3-850M") ? (byte) -1 : (byte) 109;
                                                        break;
                                                    case 407160593:
                                                        b10 = !str4.equals("Pixi5-10_4G") ? (byte) -1 : (byte) 110;
                                                        break;
                                                    case 507412548:
                                                        b10 = !str4.equals("QM16XE_U") ? (byte) -1 : (byte) 111;
                                                        break;
                                                    case 793982701:
                                                        b10 = !str4.equals("GIONEE_WBL5708") ? (byte) -1 : (byte) 112;
                                                        break;
                                                    case 794038622:
                                                        b10 = !str4.equals("GIONEE_WBL7365") ? (byte) -1 : (byte) 113;
                                                        break;
                                                    case 794040393:
                                                        b10 = !str4.equals("GIONEE_WBL7519") ? (byte) -1 : (byte) 114;
                                                        break;
                                                    case 835649806:
                                                        b10 = !str4.equals("manning") ? (byte) -1 : (byte) 115;
                                                        break;
                                                    case 917340916:
                                                        b10 = !str4.equals("A7000plus") ? (byte) -1 : (byte) 116;
                                                        break;
                                                    case 958008161:
                                                        b10 = !str4.equals("j2xlteins") ? (byte) -1 : (byte) 117;
                                                        break;
                                                    case 1060579533:
                                                        b10 = !str4.equals("panell_d") ? (byte) -1 : (byte) 118;
                                                        break;
                                                    case 1150207623:
                                                        b10 = !str4.equals("LS-5017") ? (byte) -1 : (byte) 119;
                                                        break;
                                                    case 1176899427:
                                                        b10 = !str4.equals("itel_S41") ? (byte) -1 : (byte) 120;
                                                        break;
                                                    case 1280332038:
                                                        b10 = !str4.equals("hwALE-H") ? (byte) -1 : (byte) 121;
                                                        break;
                                                    case 1306947716:
                                                        b10 = !str4.equals("EverStar_S") ? (byte) -1 : (byte) 122;
                                                        break;
                                                    case 1349174697:
                                                        b10 = !str4.equals("htc_e56ml_dtul") ? (byte) -1 : (byte) 123;
                                                        break;
                                                    case 1522194893:
                                                        b10 = !str4.equals("woods_f") ? (byte) -1 : (byte) 124;
                                                        break;
                                                    case 1691543273:
                                                        b10 = !str4.equals("CPH1609") ? (byte) -1 : (byte) 125;
                                                        break;
                                                    case 1691544261:
                                                        b10 = !str4.equals("CPH1715") ? (byte) -1 : (byte) 126;
                                                        break;
                                                    case 1709443163:
                                                        b10 = !str4.equals("iball8735_9806") ? (byte) -1 : (byte) 127;
                                                        break;
                                                    case 1865889110:
                                                        b10 = !str4.equals("santoni") ? (byte) -1 : (byte) 128;
                                                        break;
                                                    case 1906253259:
                                                        b10 = !str4.equals("PB2-670M") ? (byte) -1 : (byte) 129;
                                                        break;
                                                    case 1977196784:
                                                        b10 = !str4.equals("Infinix-X572") ? (byte) -1 : (byte) 130;
                                                        break;
                                                    case 2006372676:
                                                        b10 = !str4.equals("BRAVIA_ATV3_4K") ? (byte) -1 : (byte) 131;
                                                        break;
                                                    case 2019281702:
                                                        b10 = !str4.equals("DM-01K") ? (byte) -1 : (byte) 132;
                                                        break;
                                                    case 2029784656:
                                                        b10 = !str4.equals("HWBLN-H") ? (byte) -1 : (byte) 133;
                                                        break;
                                                    case 2030379515:
                                                        b10 = !str4.equals("HWCAM-H") ? (byte) -1 : (byte) 134;
                                                        break;
                                                    case 2033393791:
                                                        b10 = !str4.equals("ASUS_X00AD_2") ? (byte) -1 : (byte) 135;
                                                        break;
                                                    case 2047190025:
                                                        b10 = !str4.equals("ELUGA_Note") ? (byte) -1 : (byte) 136;
                                                        break;
                                                    case 2047252157:
                                                        b10 = !str4.equals("ELUGA_Prim") ? (byte) -1 : (byte) 137;
                                                        break;
                                                    case 2048319463:
                                                        b10 = !str4.equals("HWVNS-H") ? (byte) -1 : (byte) 138;
                                                        break;
                                                    case 2048855701:
                                                        b10 = !str4.equals("HWWAS-H") ? (byte) -1 : (byte) 139;
                                                        break;
                                                    default:
                                                        b10 = -1;
                                                        break;
                                                }
                                                switch (b10) {
                                                    default:
                                                        if (str3.equals("JSN-L21")) {
                                                        }
                                                    case u0.f15495q /* 0 */:
                                                    case 1:
                                                    case 2:
                                                    case 3:
                                                    case 4:
                                                    case 5:
                                                    case Z.g.STRING_SET_FIELD_NUMBER /* 6 */:
                                                    case Z.g.DOUBLE_FIELD_NUMBER /* 7 */:
                                                    case Z.g.BYTES_FIELD_NUMBER /* 8 */:
                                                    case 9:
                                                    case 10:
                                                    case 11:
                                                    case 12:
                                                    case 13:
                                                    case 14:
                                                    case 15:
                                                    case 16:
                                                    case 17:
                                                    case 18:
                                                    case 19:
                                                    case 20:
                                                    case 21:
                                                    case 22:
                                                    case 23:
                                                    case 24:
                                                    case 25:
                                                    case 26:
                                                    case 27:
                                                    case 28:
                                                    case 29:
                                                    case 30:
                                                    case 31:
                                                    case 32:
                                                    case 33:
                                                    case 34:
                                                    case 35:
                                                    case 36:
                                                    case 37:
                                                    case 38:
                                                    case 39:
                                                    case 40:
                                                    case 41:
                                                    case 42:
                                                    case 43:
                                                    case 44:
                                                    case 45:
                                                    case 46:
                                                    case 47:
                                                    case 48:
                                                    case 49:
                                                    case 50:
                                                    case 51:
                                                    case 52:
                                                    case 53:
                                                    case 54:
                                                    case 55:
                                                    case 56:
                                                    case 57:
                                                    case 58:
                                                    case 59:
                                                    case 60:
                                                    case 61:
                                                    case 62:
                                                    case 63:
                                                    case 64:
                                                    case 65:
                                                    case 66:
                                                    case 67:
                                                    case 68:
                                                    case 69:
                                                    case 70:
                                                    case 71:
                                                    case 72:
                                                    case 73:
                                                    case 74:
                                                    case 75:
                                                    case 76:
                                                    case 77:
                                                    case 78:
                                                    case 79:
                                                    case 80:
                                                    case 81:
                                                    case 82:
                                                    case 83:
                                                    case 84:
                                                    case 85:
                                                    case 86:
                                                    case 87:
                                                    case 88:
                                                    case 89:
                                                    case 90:
                                                    case 91:
                                                    case 92:
                                                    case 93:
                                                    case 94:
                                                    case 95:
                                                    case 96:
                                                    case 97:
                                                    case 98:
                                                    case 99:
                                                    case 100:
                                                    case 101:
                                                    case 102:
                                                    case 103:
                                                    case 104:
                                                    case 105:
                                                    case 106:
                                                    case 107:
                                                    case 108:
                                                    case 109:
                                                    case 110:
                                                    case 111:
                                                    case 112:
                                                    case 113:
                                                    case 114:
                                                    case 115:
                                                    case 116:
                                                    case 117:
                                                    case 118:
                                                    case 119:
                                                    case 120:
                                                    case 121:
                                                    case 122:
                                                    case 123:
                                                    case 124:
                                                    case 125:
                                                    case 126:
                                                    case 127:
                                                    case 128:
                                                    case 129:
                                                    case 130:
                                                    case 131:
                                                    case 132:
                                                    case 133:
                                                    case 134:
                                                    case 135:
                                                    case 136:
                                                    case 137:
                                                    case 138:
                                                    case 139:
                                                        z8 = true;
                                                        break;
                                                }
                                            }
                                        case u0.f15495q /* 0 */:
                                        case 1:
                                        case 2:
                                        case 3:
                                        case 4:
                                        case 5:
                                        case Z.g.STRING_SET_FIELD_NUMBER /* 6 */:
                                        case Z.g.DOUBLE_FIELD_NUMBER /* 7 */:
                                        case Z.g.BYTES_FIELD_NUMBER /* 8 */:
                                            break;
                                    }
                                }
                            case u0.f15495q /* 0 */:
                            case 1:
                            case 2:
                            case 3:
                            case 4:
                            case 5:
                            case Z.g.STRING_SET_FIELD_NUMBER /* 6 */:
                            case Z.g.DOUBLE_FIELD_NUMBER /* 7 */:
                                break;
                        }
                        f5903I1 = z8;
                        f5902H1 = true;
                    }
                }
            } catch (Throwable th) {
                throw th;
            }
        }
        return f5903I1;
    }

    /* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
    /* JADX WARN: Removed duplicated region for block: B:20:0x0041  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static int v0(I0.q qVar, C1579o c1579o) {
        int i;
        int i5 = c1579o.f17365u;
        if (i5 != -1 && (i = c1579o.f17366v) != -1) {
            String str = c1579o.f17358n;
            str.getClass();
            if ("video/dolby-vision".equals(str)) {
                Pair pairD = I0.z.d(c1579o);
                if (pairD == null) {
                    str = "video/hevc";
                } else {
                    int iIntValue = ((Integer) pairD.first).intValue();
                    if (iIntValue == 512 || iIntValue == 1 || iIntValue == 2) {
                        str = "video/avc";
                    } else if (iIntValue == 1024) {
                        str = "video/av01";
                    }
                }
            }
            switch (str) {
                case "video/3gpp":
                case "video/av01":
                case "video/mp4v-es":
                case "video/x-vnd.on2.vp8":
                    return ((i5 * i) * 3) / 4;
                case "video/hevc":
                    return Math.max(2097152, ((i5 * i) * 3) / 4);
                case "video/avc":
                    String str2 = Build.MODEL;
                    if (!"BRAVIA 4K 2015".equals(str2) && (!"Amazon".equals(Build.MANUFACTURER) || (!"KFSOWI".equals(str2) && (!"AFTS".equals(str2) || !qVar.f3239f)))) {
                        return ((x0.v.f(i, 16) * x0.v.f(i5, 16)) * 768) / 4;
                    }
                    break;
                case "video/x-vnd.on2.vp9":
                    return ((i5 * i) * 3) / 8;
            }
        }
        return -1;
    }

    public static List w0(Context context, I0.l lVar, C1579o c1579o, boolean z8, boolean z9) {
        List listE;
        String str = c1579o.f17358n;
        if (str == null) {
            return W.f1225u;
        }
        if (x0.v.f18553a >= 26 && "video/dolby-vision".equals(str) && !W2.g.m(context)) {
            String strB = I0.z.b(c1579o);
            if (strB == null) {
                listE = W.f1225u;
            } else {
                lVar.getClass();
                listE = I0.z.e(strB, z8, z9);
            }
            if (!listE.isEmpty()) {
                return listE;
            }
        }
        return I0.z.g(lVar, c1579o, z8, z9);
    }

    public static int x0(I0.q qVar, C1579o c1579o) {
        if (c1579o.f17359o == -1) {
            return v0(qVar, c1579o);
        }
        List list = c1579o.f17361q;
        int size = list.size();
        int length = 0;
        for (int i = 0; i < size; i++) {
            length += ((byte[]) list.get(i)).length;
        }
        return c1579o.f17359o + length;
    }

    public final void A0() {
        if (this.f5930o1 > 0) {
            this.f762w.getClass();
            long jElapsedRealtime = SystemClock.elapsedRealtime();
            long j8 = jElapsedRealtime - this.f5929n1;
            int i = this.f5930o1;
            D0.m mVar = this.f5912U0;
            Handler handler = mVar.f1569b;
            if (handler != null) {
                handler.post(new A(mVar, i, j8));
            }
            this.f5930o1 = 0;
            this.f5929n1 = jElapsedRealtime;
        }
    }

    @Override // I0.t
    public final C0022i B(I0.q qVar, C1579o c1579o, C1579o c1579o2) {
        C0022i c0022iB = qVar.b(c1579o, c1579o2);
        h hVar = this.f5917b1;
        hVar.getClass();
        int i = c1579o2.f17365u;
        int i5 = hVar.f5896a;
        int i8 = c0022iB.f789e;
        if (i > i5 || c1579o2.f17366v > hVar.f5897b) {
            i8 |= 256;
        }
        if (x0(qVar, c1579o2) > hVar.f5898c) {
            i8 |= 64;
        }
        int i9 = i8;
        return new C0022i(qVar.f3234a, c1579o, c1579o2, i9 != 0 ? 0 : c0022iB.f788d, i9);
    }

    public final void B0() {
        int i;
        I0.n nVar;
        if (!this.f5938x1 || (i = x0.v.f18553a) < 23 || (nVar = this.f3285a0) == null) {
            return;
        }
        this.f5940z1 = new i(this, nVar);
        if (i >= 33) {
            Bundle bundle = new Bundle();
            bundle.putInt("tunnel-peek", 1);
            nVar.c(bundle);
        }
    }

    @Override // I0.t
    public final I0.p C(IllegalStateException illegalStateException, I0.q qVar) {
        Surface surface = this.f5923h1;
        f fVar = new f(illegalStateException, qVar);
        System.identityHashCode(surface);
        if (surface != null) {
            surface.isValid();
        }
        return fVar;
    }

    public final void C0(I0.n nVar, int i, long j8) {
        Surface surface;
        Trace.beginSection("releaseOutputBuffer");
        nVar.j(j8, i);
        Trace.endSection();
        this.f3270N0.f773e++;
        this.p1 = 0;
        if (this.f5920e1 == null) {
            d0 d0Var = this.f5935u1;
            boolean zEquals = d0Var.equals(d0.f17268d);
            D0.m mVar = this.f5912U0;
            if (!zEquals && !d0Var.equals(this.f5936v1)) {
                this.f5936v1 = d0Var;
                mVar.c(d0Var);
            }
            v vVar = this.f5914X0;
            boolean z8 = vVar.f5987e != 3;
            vVar.f5987e = 3;
            vVar.f5993l.getClass();
            vVar.f5989g = x0.v.L(SystemClock.elapsedRealtime());
            if (!z8 || (surface = this.f5923h1) == null) {
                return;
            }
            Handler handler = mVar.f1569b;
            if (handler != null) {
                handler.post(new k4.p(mVar, surface, SystemClock.elapsedRealtime()));
            }
            this.f5926k1 = true;
        }
    }

    public final void D0(Object obj) throws C0030q {
        Handler handler;
        Surface surface = obj instanceof Surface ? (Surface) obj : null;
        Surface surface2 = this.f5923h1;
        D0.m mVar = this.f5912U0;
        if (surface2 == surface) {
            if (surface != null) {
                d0 d0Var = this.f5936v1;
                if (d0Var != null) {
                    mVar.c(d0Var);
                }
                Surface surface3 = this.f5923h1;
                if (surface3 == null || !this.f5926k1 || (handler = mVar.f1569b) == null) {
                    return;
                }
                handler.post(new k4.p(mVar, surface3, SystemClock.elapsedRealtime()));
                return;
            }
            return;
        }
        this.f5923h1 = surface;
        m mVar2 = this.f5920e1;
        v vVar = this.f5914X0;
        if (mVar2 == null) {
            vVar.getClass();
            vVar.f5994m = surface != null;
            vVar.f5995n = false;
            y yVar = vVar.f5984b;
            if (yVar.f6007e != surface) {
                yVar.b();
                yVar.f6007e = surface;
                yVar.d(true);
            }
            vVar.d(1);
        }
        this.f5926k1 = false;
        int i = this.f763x;
        I0.n nVar = this.f3285a0;
        if (nVar != null && this.f5920e1 == null) {
            I0.q qVar = this.f3292h0;
            qVar.getClass();
            boolean zZ0 = z0(qVar);
            int i5 = x0.v.f18553a;
            if (i5 < 23 || !zZ0 || this.f5918c1) {
                h0();
                S();
            } else {
                Surface surfaceY0 = y0(qVar);
                if (i5 >= 23 && surfaceY0 != null) {
                    nVar.m(surfaceY0);
                } else {
                    if (i5 < 35) {
                        throw new IllegalStateException();
                    }
                    nVar.k();
                }
            }
        }
        if (surface != null) {
            d0 d0Var2 = this.f5936v1;
            if (d0Var2 != null) {
                mVar.c(d0Var2);
            }
        } else {
            this.f5936v1 = null;
            m mVar3 = this.f5920e1;
            if (mVar3 != null) {
                p pVar = (p) mVar3.f5955e;
                int i8 = x0.p.f18542c.f18543a;
                pVar.f5965j = null;
            }
        }
        if (i == 2) {
            m mVar4 = this.f5920e1;
            if (mVar4 != null) {
                ((p) mVar4.f5955e).f5962f.f5868a.c(true);
            } else {
                vVar.c(true);
            }
        }
        B0();
    }

    public final boolean E0(long j8, long j9, boolean z8, boolean z9) throws C0030q {
        long j10 = this.f5916Z0;
        if (j10 != -9223372036854775807L) {
            this.f5908E1 = j9 > this.f751B + 200000 && j8 < j10;
        }
        if (j8 < -500000 && !z8) {
            c0 c0Var = this.f764y;
            c0Var.getClass();
            int iM = c0Var.m(j9 - this.f750A);
            if (iM != 0) {
                PriorityQueue priorityQueue = this.a1;
                if (z9) {
                    C0021h c0021h = this.f3270N0;
                    int i = c0021h.f772d + iM;
                    c0021h.f772d = i;
                    c0021h.f774f += this.f5931q1;
                    c0021h.f772d = priorityQueue.size() + i;
                } else {
                    this.f3270N0.f777j++;
                    H0(priorityQueue.size() + iM, this.f5931q1);
                }
                if (I()) {
                    S();
                }
                m mVar = this.f5920e1;
                if (mVar != null) {
                    mVar.b(false);
                }
                return true;
            }
        }
        return false;
    }

    public final boolean F0(I0.q qVar) {
        if (x0.v.f18553a < 23 || this.f5938x1 || u0(qVar.f3234a)) {
            return false;
        }
        return !qVar.f3239f || l.a(this.f5910S0);
    }

    public final void G0(I0.n nVar, int i) {
        Trace.beginSection("skipVideoBuffer");
        nVar.n(i);
        Trace.endSection();
        this.f3270N0.f774f++;
    }

    public final void H0(int i, int i5) {
        C0021h c0021h = this.f3270N0;
        c0021h.f776h += i;
        int i8 = i + i5;
        c0021h.f775g += i8;
        this.f5930o1 += i8;
        int i9 = this.p1 + i8;
        this.p1 = i9;
        c0021h.i = Math.max(i9, c0021h.i);
        int i10 = this.f5913V0;
        if (i10 <= 0 || this.f5930o1 < i10) {
            return;
        }
        A0();
    }

    public final void I0(long j8) {
        C0021h c0021h = this.f3270N0;
        c0021h.f778k += j8;
        c0021h.f779l++;
        this.f5932r1 += j8;
        this.f5933s1++;
    }

    @Override // I0.t
    public final int K(A0.h hVar) {
        return (x0.v.f18553a < 34 || !this.f5938x1 || hVar.f20w >= this.f751B) ? 0 : 32;
    }

    @Override // I0.t
    public final boolean L() {
        return this.f5938x1 && x0.v.f18553a < 23;
    }

    @Override // I0.t
    public final float M(float f3, C1579o[] c1579oArr) {
        float fMax = -1.0f;
        for (C1579o c1579o : c1579oArr) {
            float f7 = c1579o.f17367w;
            if (f7 != -1.0f) {
                fMax = Math.max(fMax, f7);
            }
        }
        if (fMax == -1.0f) {
            return -1.0f;
        }
        return fMax * f3;
    }

    @Override // I0.t
    public final ArrayList N(I0.l lVar, C1579o c1579o, boolean z8) {
        List listW0 = w0(this.f5910S0, lVar, c1579o, z8, this.f5938x1);
        HashMap map = I0.z.f3314a;
        ArrayList arrayList = new ArrayList(listW0);
        Collections.sort(arrayList, new I0.u(new G(16, c1579o)));
        return arrayList;
    }

    @Override // I0.t
    public final O3.q O(I0.q qVar, C1579o c1579o, MediaCrypto mediaCrypto, float f3) {
        C1570f c1570f;
        int i;
        h hVar;
        Point point;
        MediaCodecInfo.VideoCapabilities videoCapabilities;
        int i5;
        int i8;
        int i9;
        byte b8;
        boolean z8;
        Pair pairD;
        int iV0;
        String str = qVar.f3236c;
        C1579o[] c1579oArr = this.f765z;
        c1579oArr.getClass();
        int iMax = c1579o.f17365u;
        int iX0 = x0(qVar, c1579o);
        int length = c1579oArr.length;
        float f7 = c1579o.f17367w;
        int i10 = c1579o.f17365u;
        C1570f c1570f2 = c1579o.f17335B;
        int i11 = c1579o.f17366v;
        if (length == 1) {
            if (iX0 != -1 && (iV0 = v0(qVar, c1579o)) != -1) {
                iX0 = Math.min((int) (iX0 * 1.5f), iV0);
            }
            hVar = new h(iMax, i11, iX0);
            c1570f = c1570f2;
            i = i11;
        } else {
            int length2 = c1579oArr.length;
            int iMax2 = i11;
            int i12 = 0;
            boolean z9 = false;
            while (i12 < length2) {
                C1579o c1579o2 = c1579oArr[i12];
                C1579o[] c1579oArr2 = c1579oArr;
                if (c1570f2 != null && c1579o2.f17335B == null) {
                    C1578n c1578nA = c1579o2.a();
                    c1578nA.f17299A = c1570f2;
                    c1579o2 = new C1579o(c1578nA);
                }
                if (qVar.b(c1579o, c1579o2).f788d != 0) {
                    int i13 = c1579o2.f17366v;
                    i8 = length2;
                    int i14 = c1579o2.f17365u;
                    i9 = i12;
                    b8 = -1;
                    z9 |= i14 == -1 || i13 == -1;
                    iMax = Math.max(iMax, i14);
                    iMax2 = Math.max(iMax2, i13);
                    iX0 = Math.max(iX0, x0(qVar, c1579o2));
                } else {
                    i8 = length2;
                    i9 = i12;
                    b8 = -1;
                }
                length2 = i8;
                i12 = i9 + 1;
                c1579oArr = c1579oArr2;
            }
            if (z9) {
                AbstractC1709a.B("MediaCodecVideoRenderer", "Resolutions unknown. Codec max resolution: " + iMax + "x" + iMax2);
                boolean z10 = i11 > i10;
                int i15 = z10 ? i11 : i10;
                boolean z11 = z10;
                int i16 = z10 ? i10 : i11;
                float f8 = i16 / i15;
                int[] iArr = f5901G1;
                c1570f = c1570f2;
                int i17 = 0;
                while (i17 < 9) {
                    int i18 = iArr[i17];
                    int i19 = i17;
                    int i20 = (int) (i18 * f8);
                    if (i18 <= i15 || i20 <= i16) {
                        break;
                    }
                    if (!z11) {
                        i20 = i18;
                    }
                    if (!z11) {
                        i18 = i20;
                    }
                    int i21 = i16;
                    MediaCodecInfo.CodecCapabilities codecCapabilities = qVar.f3237d;
                    if (codecCapabilities == null || (videoCapabilities = codecCapabilities.getVideoCapabilities()) == null) {
                        i5 = i15;
                        point = null;
                    } else {
                        int widthAlignment = videoCapabilities.getWidthAlignment();
                        i5 = i15;
                        int heightAlignment = videoCapabilities.getHeightAlignment();
                        point = new Point(x0.v.f(i20, widthAlignment) * widthAlignment, x0.v.f(i18, heightAlignment) * heightAlignment);
                    }
                    if (point != null) {
                        i = i11;
                        if (qVar.g(point.x, point.y, f7)) {
                            break;
                        }
                    } else {
                        i = i11;
                    }
                    i17 = i19 + 1;
                    i11 = i;
                    i16 = i21;
                    i15 = i5;
                }
                i = i11;
                point = null;
                if (point != null) {
                    iMax = Math.max(iMax, point.x);
                    iMax2 = Math.max(iMax2, point.y);
                    C1578n c1578nA2 = c1579o.a();
                    c1578nA2.f17327t = iMax;
                    c1578nA2.f17328u = iMax2;
                    iX0 = Math.max(iX0, v0(qVar, new C1579o(c1578nA2)));
                    AbstractC1709a.B("MediaCodecVideoRenderer", "Codec max resolution adjusted to: " + iMax + "x" + iMax2);
                }
            } else {
                c1570f = c1570f2;
                i = i11;
            }
            hVar = new h(iMax, iMax2, iX0);
        }
        this.f5917b1 = hVar;
        int i22 = this.f5938x1 ? this.f5939y1 : 0;
        MediaFormat mediaFormat = new MediaFormat();
        mediaFormat.setString("mime", str);
        mediaFormat.setInteger("width", i10);
        mediaFormat.setInteger("height", i);
        AbstractC1709a.A(mediaFormat, c1579o.f17361q);
        if (f7 != -1.0f) {
            mediaFormat.setFloat("frame-rate", f7);
        }
        AbstractC1709a.w(mediaFormat, "rotation-degrees", c1579o.f17368x);
        if (c1570f != null) {
            C1570f c1570f3 = c1570f;
            AbstractC1709a.w(mediaFormat, "color-transfer", c1570f3.f17280c);
            AbstractC1709a.w(mediaFormat, "color-standard", c1570f3.f17278a);
            AbstractC1709a.w(mediaFormat, "color-range", c1570f3.f17279b);
            byte[] bArr = c1570f3.f17281d;
            if (bArr != null) {
                mediaFormat.setByteBuffer("hdr-static-info", ByteBuffer.wrap(bArr));
            }
        }
        if ("video/dolby-vision".equals(c1579o.f17358n) && (pairD = I0.z.d(c1579o)) != null) {
            AbstractC1709a.w(mediaFormat, "profile", ((Integer) pairD.first).intValue());
        }
        mediaFormat.setInteger("max-width", hVar.f5896a);
        mediaFormat.setInteger("max-height", hVar.f5897b);
        AbstractC1709a.w(mediaFormat, "max-input-size", hVar.f5898c);
        int i23 = x0.v.f18553a;
        if (i23 >= 23) {
            mediaFormat.setInteger("priority", 0);
            if (f3 != -1.0f) {
                mediaFormat.setFloat("operating-rate", f3);
            }
        }
        if (this.W0) {
            z8 = true;
            mediaFormat.setInteger("no-post-process", 1);
            mediaFormat.setInteger("auto-frc", 0);
        } else {
            z8 = true;
        }
        if (i22 != 0) {
            mediaFormat.setFeatureEnabled("tunneled-playback", z8);
            mediaFormat.setInteger("audio-session-id", i22);
        }
        if (i23 >= 35) {
            mediaFormat.setInteger("importance", Math.max(0, -this.f5937w1));
        }
        Surface surfaceY0 = y0(qVar);
        if (this.f5920e1 != null && !x0.v.I(this.f5910S0)) {
            mediaFormat.setInteger("allow-frame-drop", 0);
        }
        return new O3.q(qVar, mediaFormat, c1579o, surfaceY0, mediaCrypto, null);
    }

    @Override // I0.t
    public final void P(A0.h hVar) {
        if (this.f5919d1) {
            ByteBuffer byteBuffer = hVar.f21x;
            byteBuffer.getClass();
            if (byteBuffer.remaining() >= 7) {
                byte b8 = byteBuffer.get();
                short s8 = byteBuffer.getShort();
                short s9 = byteBuffer.getShort();
                byte b9 = byteBuffer.get();
                byte b10 = byteBuffer.get();
                byteBuffer.position(0);
                if (b8 == -75 && s8 == 60 && s9 == 1 && b9 == 4) {
                    if (b10 == 0 || b10 == 1) {
                        byte[] bArr = new byte[byteBuffer.remaining()];
                        byteBuffer.get(bArr);
                        byteBuffer.position(0);
                        I0.n nVar = this.f3285a0;
                        nVar.getClass();
                        Bundle bundle = new Bundle();
                        bundle.putByteArray("hdr10-plus-info", bArr);
                        nVar.c(bundle);
                    }
                }
            }
        }
    }

    @Override // I0.t
    public final boolean U(C1579o c1579o) throws C0030q {
        m mVar = this.f5920e1;
        if (mVar == null) {
            return true;
        }
        try {
            mVar.c(c1579o);
            throw null;
        } catch (C e8) {
            throw f(e8, c1579o, false, 7000);
        }
    }

    @Override // I0.t
    public final void V(Exception exc) {
        AbstractC1709a.p("MediaCodecVideoRenderer", "Video codec error", exc);
        D0.m mVar = this.f5912U0;
        Handler handler = mVar.f1569b;
        if (handler != null) {
            handler.post(new A(mVar, exc, 1));
        }
    }

    @Override // I0.t
    public final void W(long j8, String str, long j9) {
        String str2;
        MediaCodecInfo.CodecProfileLevel[] codecProfileLevelArr;
        D0.m mVar = this.f5912U0;
        Handler handler = mVar.f1569b;
        if (handler != null) {
            str2 = str;
            handler.post(new A(mVar, str2, j8, j9));
        } else {
            str2 = str;
        }
        this.f5918c1 = u0(str2);
        I0.q qVar = this.f3292h0;
        qVar.getClass();
        boolean z8 = false;
        if (x0.v.f18553a >= 29 && "video/x-vnd.on2.vp9".equals(qVar.f3235b)) {
            MediaCodecInfo.CodecCapabilities codecCapabilities = qVar.f3237d;
            if (codecCapabilities == null || (codecProfileLevelArr = codecCapabilities.profileLevels) == null) {
                codecProfileLevelArr = new MediaCodecInfo.CodecProfileLevel[0];
            }
            int length = codecProfileLevelArr.length;
            int i = 0;
            while (true) {
                if (i >= length) {
                    break;
                }
                if (codecProfileLevelArr[i].profile == 16384) {
                    z8 = true;
                    break;
                }
                i++;
            }
        }
        this.f5919d1 = z8;
        B0();
    }

    @Override // I0.t
    public final void X(String str) {
        D0.m mVar = this.f5912U0;
        Handler handler = mVar.f1569b;
        if (handler != null) {
            handler.post(new A(mVar, str, 2));
        }
    }

    @Override // I0.t
    public final C0022i Y(R0 r02) {
        C0022i c0022iY = super.Y(r02);
        C1579o c1579o = (C1579o) r02.f11693s;
        c1579o.getClass();
        D0.m mVar = this.f5912U0;
        Handler handler = mVar.f1569b;
        if (handler != null) {
            handler.post(new A(mVar, c1579o, c0022iY));
        }
        return c0022iY;
    }

    @Override // I0.t
    public final void Z(C1579o c1579o, MediaFormat mediaFormat) {
        int integer;
        int i;
        I0.n nVar = this.f3285a0;
        if (nVar != null) {
            nVar.z(this.f5927l1);
        }
        if (this.f5938x1) {
            i = c1579o.f17365u;
            integer = c1579o.f17366v;
        } else {
            mediaFormat.getClass();
            boolean z8 = mediaFormat.containsKey("crop-right") && mediaFormat.containsKey("crop-left") && mediaFormat.containsKey("crop-bottom") && mediaFormat.containsKey("crop-top");
            int integer2 = z8 ? (mediaFormat.getInteger("crop-right") - mediaFormat.getInteger("crop-left")) + 1 : mediaFormat.getInteger("width");
            integer = z8 ? (mediaFormat.getInteger("crop-bottom") - mediaFormat.getInteger("crop-top")) + 1 : mediaFormat.getInteger("height");
            i = integer2;
        }
        float f3 = c1579o.f17369y;
        int i5 = c1579o.f17368x;
        if (i5 == 90 || i5 == 270) {
            f3 = 1.0f / f3;
            int i8 = integer;
            integer = i;
            i = i8;
        }
        this.f5935u1 = new d0(f3, i, integer);
        m mVar = this.f5920e1;
        if (mVar == null || !this.f5907D1) {
            y yVar = this.f5914X0.f5984b;
            yVar.f6008f = c1579o.f17367w;
            e eVar = yVar.f6003a;
            eVar.f5884a.c();
            eVar.f5885b.c();
            eVar.f5886c = false;
            eVar.f5887d = -9223372036854775807L;
            eVar.f5888e = 0;
            yVar.c();
            this.f5907D1 = false;
            return;
        }
        C1578n c1578nA = c1579o.a();
        c1578nA.f17327t = i;
        c1578nA.f17328u = integer;
        c1578nA.f17331x = f3;
        C1579o c1579o2 = new C1579o(c1578nA);
        List list = this.f5922g1;
        if (list == null) {
            E e8 = C3.G.f1197r;
            list = W.f1225u;
        }
        AbstractC1709a.j(false);
        p pVar = (p) mVar.f5955e;
        pVar.f5959c.getClass();
        D d8 = new D(4);
        d8.d(list);
        d8.d(pVar.f5961e);
        mVar.f5953c = d8.g();
        mVar.f5954d = c1579o2;
        C1578n c1578nA2 = c1579o2.a();
        C1570f c1570f = c1579o2.f17335B;
        if (c1570f == null || !c1570f.d()) {
            c1570f = C1570f.f17277h;
        }
        c1578nA2.f17299A = c1570f;
        c1578nA2.a();
        AbstractC1709a.k(null);
        throw null;
    }

    @Override // I0.t
    public final void b0(long j8) {
        super.b0(j8);
        if (this.f5938x1) {
            return;
        }
        this.f5931q1--;
    }

    @Override // I0.t
    public final void c0() {
        m mVar = this.f5920e1;
        if (mVar != null) {
            mVar.k();
            this.f5920e1.h(this.f3272O0.f3248b, -this.f5905B1);
        } else {
            this.f5914X0.d(2);
        }
        this.f5907D1 = true;
        B0();
    }

    @Override // B0.AbstractC0020g, B0.l0
    public final void d(int i, Object obj) throws C0030q {
        if (i == 1) {
            D0(obj);
            return;
        }
        if (i == 7) {
            obj.getClass();
            t tVar = (t) obj;
            this.f5904A1 = tVar;
            m mVar = this.f5920e1;
            if (mVar != null) {
                mVar.j(tVar);
                return;
            }
            return;
        }
        if (i == 10) {
            obj.getClass();
            int iIntValue = ((Integer) obj).intValue();
            if (this.f5939y1 != iIntValue) {
                this.f5939y1 = iIntValue;
                if (this.f5938x1) {
                    h0();
                    return;
                }
                return;
            }
            return;
        }
        if (i == 4) {
            obj.getClass();
            int iIntValue2 = ((Integer) obj).intValue();
            this.f5927l1 = iIntValue2;
            I0.n nVar = this.f3285a0;
            if (nVar != null) {
                nVar.z(iIntValue2);
                return;
            }
            return;
        }
        if (i == 5) {
            obj.getClass();
            int iIntValue3 = ((Integer) obj).intValue();
            this.f5928m1 = iIntValue3;
            m mVar2 = this.f5920e1;
            if (mVar2 != null) {
                mVar2.e(iIntValue3);
                return;
            }
            y yVar = this.f5914X0.f5984b;
            if (yVar.f6011j == iIntValue3) {
                return;
            }
            yVar.f6011j = iIntValue3;
            yVar.d(true);
            return;
        }
        if (i == 13) {
            obj.getClass();
            List list = (List) obj;
            this.f5922g1 = list;
            m mVar3 = this.f5920e1;
            if (mVar3 != null) {
                mVar3.i(list);
                return;
            }
            return;
        }
        if (i == 14) {
            obj.getClass();
            x0.p pVar = (x0.p) obj;
            if (pVar.f18543a == 0 || pVar.f18544b == 0) {
                return;
            }
            this.f5925j1 = pVar;
            m mVar4 = this.f5920e1;
            if (mVar4 != null) {
                Surface surface = this.f5923h1;
                AbstractC1709a.k(surface);
                mVar4.f(surface, pVar);
                return;
            }
            return;
        }
        if (i == 16) {
            obj.getClass();
            this.f5937w1 = ((Integer) obj).intValue();
            I0.n nVar2 = this.f3285a0;
            if (nVar2 != null && x0.v.f18553a >= 35) {
                Bundle bundle = new Bundle();
                bundle.putInt("importance", Math.max(0, -this.f5937w1));
                nVar2.c(bundle);
                return;
            }
            return;
        }
        if (i == 17) {
            Surface surface2 = this.f5923h1;
            D0(null);
            obj.getClass();
            ((j) obj).d(1, surface2);
            return;
        }
        if (i == 11) {
            L l8 = (L) obj;
            l8.getClass();
            this.f3281V = l8;
        }
    }

    @Override // I0.t
    public final void d0(A0.h hVar) {
        Surface surface;
        this.f5909F1 = 0;
        boolean z8 = this.f5938x1;
        if (!z8) {
            this.f5931q1++;
        }
        if (x0.v.f18553a >= 23 || !z8) {
            return;
        }
        long j8 = hVar.f20w;
        t0(j8);
        d0 d0Var = this.f5935u1;
        boolean zEquals = d0Var.equals(d0.f17268d);
        D0.m mVar = this.f5912U0;
        if (!zEquals && !d0Var.equals(this.f5936v1)) {
            this.f5936v1 = d0Var;
            mVar.c(d0Var);
        }
        this.f3270N0.f773e++;
        v vVar = this.f5914X0;
        boolean z9 = vVar.f5987e != 3;
        vVar.f5987e = 3;
        vVar.f5993l.getClass();
        vVar.f5989g = x0.v.L(SystemClock.elapsedRealtime());
        if (z9 && (surface = this.f5923h1) != null) {
            Handler handler = mVar.f1569b;
            if (handler != null) {
                handler.post(new k4.p(mVar, surface, SystemClock.elapsedRealtime()));
            }
            this.f5926k1 = true;
        }
        b0(j8);
    }

    @Override // I0.t
    public final boolean f0(long j8, long j9, I0.n nVar, ByteBuffer byteBuffer, int i, int i5, int i8, long j10, boolean z8, boolean z9, C1579o c1579o) {
        nVar.getClass();
        long j11 = j10 - this.f3272O0.f3249c;
        int i9 = 0;
        while (true) {
            PriorityQueue priorityQueue = this.a1;
            Long l8 = (Long) priorityQueue.peek();
            if (l8 == null || l8.longValue() >= j10) {
                break;
            }
            i9++;
            priorityQueue.poll();
        }
        H0(i9, 0);
        m mVar = this.f5920e1;
        if (mVar == null) {
            int iA = this.f5914X0.a(j10, j8, j9, this.f3272O0.f3248b, z8, z9, this.f5915Y0);
            u uVar = this.f5915Y0;
            if (iA == 0) {
                this.f762w.getClass();
                long jNanoTime = System.nanoTime();
                t tVar = this.f5904A1;
                if (tVar != null) {
                    tVar.c(j11, jNanoTime, c1579o, this.f3287c0);
                }
                C0(nVar, i, jNanoTime);
                I0(uVar.f5981a);
                return true;
            }
            if (iA == 1) {
                long j12 = uVar.f5982b;
                long j13 = uVar.f5981a;
                if (j12 == this.f5934t1) {
                    G0(nVar, i);
                } else {
                    t tVar2 = this.f5904A1;
                    if (tVar2 != null) {
                        tVar2.c(j11, j12, c1579o, this.f3287c0);
                    }
                    C0(nVar, i, j12);
                }
                I0(j13);
                this.f5934t1 = j12;
                return true;
            }
            if (iA == 2) {
                Trace.beginSection("dropVideoBuffer");
                nVar.n(i);
                Trace.endSection();
                H0(0, 1);
                I0(uVar.f5981a);
                return true;
            }
            if (iA == 3) {
                G0(nVar, i);
                I0(uVar.f5981a);
                return true;
            }
            if (iA != 4 && iA != 5) {
                throw new IllegalStateException(String.valueOf(iA));
            }
        } else {
            if (z8 && !z9) {
                G0(nVar, i);
                return true;
            }
            AbstractC1709a.j(false);
            int i10 = ((p) mVar.f5955e).f5969n;
            if (i10 != -1 && i10 == 0) {
                AbstractC1709a.k(null);
                throw null;
            }
        }
        return false;
    }

    @Override // B0.AbstractC0020g
    public final void g() {
        m mVar = this.f5920e1;
        if (mVar != null) {
            v vVar = ((p) mVar.f5955e).f5962f.f5868a;
            if (vVar.f5987e == 0) {
                vVar.f5987e = 1;
                return;
            }
            return;
        }
        v vVar2 = this.f5914X0;
        if (vVar2.f5987e == 0) {
            vVar2.f5987e = 1;
        }
    }

    @Override // B0.AbstractC0020g
    public final String i() {
        return "MediaCodecVideoRenderer";
    }

    @Override // I0.t
    public final void i0() {
        m mVar = this.f5920e1;
        if (mVar != null) {
            mVar.k();
        }
    }

    @Override // I0.t
    public final void j0() {
        super.j0();
        this.a1.clear();
        this.f5908E1 = false;
        this.f5931q1 = 0;
        this.f5909F1 = 0;
    }

    @Override // B0.AbstractC0020g
    public final boolean k() {
        return this.f3263J0 && this.f5920e1 == null;
    }

    @Override // I0.t, B0.AbstractC0020g
    public final boolean l() {
        boolean zL = super.l();
        m mVar = this.f5920e1;
        if (mVar != null) {
            return ((p) mVar.f5955e).f5962f.f5868a.b(false);
        }
        if (zL && (this.f3285a0 == null || this.f5938x1)) {
            return true;
        }
        return this.f5914X0.b(zL);
    }

    @Override // I0.t, B0.AbstractC0020g
    public final void m() {
        D0.m mVar = this.f5912U0;
        this.f5936v1 = null;
        this.f5906C1 = -9223372036854775807L;
        m mVar2 = this.f5920e1;
        if (mVar2 != null) {
            ((p) mVar2.f5955e).f5962f.f5868a.d(0);
        } else {
            this.f5914X0.d(0);
        }
        B0();
        this.f5926k1 = false;
        this.f5940z1 = null;
        try {
            super.m();
            C0021h c0021h = this.f3270N0;
            mVar.getClass();
            synchronized (c0021h) {
            }
            Handler handler = mVar.f1569b;
            if (handler != null) {
                handler.post(new B0.A(mVar, 19, c0021h));
            }
            mVar.c(d0.f17268d);
        } catch (Throwable th) {
            mVar.a(this.f3270N0);
            mVar.c(d0.f17268d);
            throw th;
        }
    }

    @Override // B0.AbstractC0020g
    public final void n(boolean z8, boolean z9) {
        this.f3270N0 = new C0021h();
        p0 p0Var = this.f759t;
        p0Var.getClass();
        boolean z10 = p0Var.f871b;
        AbstractC1709a.j((z10 && this.f5939y1 == 0) ? false : true);
        if (this.f5938x1 != z10) {
            this.f5938x1 = z10;
            h0();
        }
        C0021h c0021h = this.f3270N0;
        D0.m mVar = this.f5912U0;
        Handler handler = mVar.f1569b;
        if (handler != null) {
            handler.post(new A(mVar, c0021h, 5));
        }
        boolean z11 = this.f5921f1;
        v vVar = this.f5914X0;
        if (!z11) {
            if (this.f5922g1 != null && this.f5920e1 == null) {
                L1.b bVar = new L1.b(this.f5910S0, vVar);
                x0.q qVar = this.f762w;
                qVar.getClass();
                bVar.f3945h = qVar;
                AbstractC1709a.j(!bVar.f3938a);
                if (((o) bVar.f3942e) == null) {
                    if (((n) bVar.f3941d) == null) {
                        bVar.f3941d = new n();
                    }
                    bVar.f3942e = new o((n) bVar.f3941d);
                }
                p pVar = new p(bVar);
                bVar.f3938a = true;
                pVar.f5969n = 1;
                SparseArray sparseArray = pVar.f5960d;
                AbstractC1709a.j(!x0.v.k(sparseArray, 0));
                m mVar2 = new m(pVar, pVar.f5957a);
                pVar.f5964h.add(mVar2);
                sparseArray.put(0, mVar2);
                this.f5920e1 = mVar2;
            }
            this.f5921f1 = true;
        }
        m mVar3 = this.f5920e1;
        if (mVar3 == null) {
            x0.q qVar2 = this.f762w;
            qVar2.getClass();
            vVar.f5993l = qVar2;
            vVar.f5987e = z9 ? 1 : 0;
            return;
        }
        t tVar = this.f5904A1;
        if (tVar != null) {
            mVar3.j(tVar);
        }
        if (this.f5923h1 != null && !this.f5925j1.equals(x0.p.f18542c)) {
            this.f5920e1.f(this.f5923h1, this.f5925j1);
        }
        this.f5920e1.e(this.f5928m1);
        this.f5920e1.g(this.f3283Y);
        List list = this.f5922g1;
        if (list != null) {
            this.f5920e1.i(list);
        }
        m mVar4 = this.f5920e1;
        ((p) mVar4.f5955e).f5962f.f5868a.f5987e = z9 ? 1 : 0;
        if (this.f3281V != null) {
            mVar4.getClass();
        }
    }

    @Override // I0.t
    public final boolean n0(A0.h hVar) {
        if (!j() && !hVar.d(536870912)) {
            long j8 = this.f5906C1;
            if (j8 != -9223372036854775807L && j8 - (hVar.f20w - this.f3272O0.f3249c) > 100000 && !hVar.d(1073741824)) {
                boolean z8 = hVar.f20w < this.f751B;
                if ((z8 || this.f5908E1) && !hVar.d(268435456)) {
                    boolean zD = hVar.d(67108864);
                    PriorityQueue priorityQueue = this.a1;
                    if (zD) {
                        hVar.e();
                        if (z8) {
                            this.f3270N0.f772d++;
                            return true;
                        }
                        if (this.f5908E1) {
                            priorityQueue.add(Long.valueOf(hVar.f20w));
                            this.f5909F1++;
                        }
                        return true;
                    }
                }
            }
        }
        return false;
    }

    @Override // I0.t, B0.AbstractC0020g
    public final void o(long j8, boolean z8) {
        m mVar = this.f5920e1;
        if (mVar != null) {
            if (!z8) {
                mVar.b(true);
            }
            this.f5920e1.h(this.f3272O0.f3248b, -this.f5905B1);
            this.f5907D1 = true;
        }
        super.o(j8, z8);
        m mVar2 = this.f5920e1;
        v vVar = this.f5914X0;
        if (mVar2 == null) {
            y yVar = vVar.f5984b;
            yVar.f6014m = 0L;
            yVar.f6017p = -1L;
            yVar.f6015n = -1L;
            vVar.f5990h = -9223372036854775807L;
            vVar.f5988f = -9223372036854775807L;
            vVar.d(1);
            vVar.i = -9223372036854775807L;
        }
        if (z8) {
            m mVar3 = this.f5920e1;
            if (mVar3 != null) {
                ((p) mVar3.f5955e).f5962f.f5868a.c(false);
            } else {
                vVar.c(false);
            }
        }
        B0();
        this.p1 = 0;
    }

    @Override // I0.t
    public final boolean o0(I0.q qVar) {
        return z0(qVar);
    }

    @Override // B0.AbstractC0020g
    public final void p() {
        m mVar = this.f5920e1;
        if (mVar == null || !this.f5911T0) {
            return;
        }
        p pVar = (p) mVar.f5955e;
        if (pVar.f5966k == 2) {
            return;
        }
        x0.s sVar = pVar.i;
        if (sVar != null) {
            sVar.f18548a.removeCallbacksAndMessages(null);
        }
        pVar.f5965j = null;
        pVar.f5966k = 2;
    }

    @Override // B0.AbstractC0020g
    public final void q() {
        try {
            try {
                D();
                h0();
                K4.c cVar = this.f3280U;
                if (cVar != null) {
                    cVar.J(null);
                }
                this.f3280U = null;
            } catch (Throwable th) {
                K4.c cVar2 = this.f3280U;
                if (cVar2 != null) {
                    cVar2.J(null);
                }
                this.f3280U = null;
                throw th;
            }
        } finally {
            this.f5921f1 = false;
            this.f5905B1 = -9223372036854775807L;
            l lVar = this.f5924i1;
            if (lVar != null) {
                lVar.release();
                this.f5924i1 = null;
            }
        }
    }

    @Override // I0.t
    public final int q0(I0.l lVar, C1579o c1579o) {
        boolean z8;
        int i = 16;
        int i5 = 0;
        if (!u0.E.l(c1579o.f17358n)) {
            return I1.a.e(0, 0, 0, 0);
        }
        boolean z9 = c1579o.f17362r != null;
        Context context = this.f5910S0;
        List listW0 = w0(context, lVar, c1579o, z9, false);
        if (z9 && listW0.isEmpty()) {
            listW0 = w0(context, lVar, c1579o, false, false);
        }
        if (listW0.isEmpty()) {
            return I1.a.e(1, 0, 0, 0);
        }
        int i8 = c1579o.f17344M;
        if (i8 != 0 && i8 != 2) {
            return I1.a.e(2, 0, 0, 0);
        }
        I0.q qVar = (I0.q) listW0.get(0);
        boolean zE = qVar.e(c1579o);
        if (zE) {
            z8 = true;
        } else {
            for (int i9 = 1; i9 < listW0.size(); i9++) {
                I0.q qVar2 = (I0.q) listW0.get(i9);
                if (qVar2.e(c1579o)) {
                    zE = true;
                    z8 = false;
                    qVar = qVar2;
                    break;
                }
            }
            z8 = true;
        }
        int i10 = zE ? 4 : 3;
        int i11 = qVar.f(c1579o) ? 16 : 8;
        int i12 = qVar.f3240g ? 64 : 0;
        int i13 = z8 ? 128 : 0;
        if (x0.v.f18553a >= 26 && "video/dolby-vision".equals(c1579o.f17358n) && !W2.g.m(context)) {
            i13 = 256;
        }
        if (zE) {
            List listW02 = w0(context, lVar, c1579o, z9, true);
            if (!listW02.isEmpty()) {
                HashMap map = I0.z.f3314a;
                ArrayList arrayList = new ArrayList(listW02);
                Collections.sort(arrayList, new I0.u(new G(i, c1579o)));
                I0.q qVar3 = (I0.q) arrayList.get(0);
                if (qVar3.e(c1579o) && qVar3.f(c1579o)) {
                    i5 = 32;
                }
            }
        }
        return i10 | i11 | i5 | i12 | i13;
    }

    @Override // B0.AbstractC0020g
    public final void r() {
        this.f5930o1 = 0;
        this.f762w.getClass();
        this.f5929n1 = SystemClock.elapsedRealtime();
        this.f5932r1 = 0L;
        this.f5933s1 = 0;
        m mVar = this.f5920e1;
        if (mVar != null) {
            ((p) mVar.f5955e).f5962f.f5868a.e();
        } else {
            this.f5914X0.e();
        }
    }

    @Override // B0.AbstractC0020g
    public final void s() {
        A0();
        int i = this.f5933s1;
        if (i != 0) {
            long j8 = this.f5932r1;
            D0.m mVar = this.f5912U0;
            Handler handler = mVar.f1569b;
            if (handler != null) {
                handler.post(new A(mVar, j8, i));
            }
            this.f5932r1 = 0L;
            this.f5933s1 = 0;
        }
        m mVar2 = this.f5920e1;
        if (mVar2 != null) {
            ((p) mVar2.f5955e).f5962f.f5868a.f();
        } else {
            this.f5914X0.f();
        }
    }

    @Override // I0.t, B0.AbstractC0020g
    public final void t(C1579o[] c1579oArr, long j8, long j9, L0.C c3) {
        super.t(c1579oArr, j8, j9, c3);
        if (this.f5905B1 == -9223372036854775807L) {
            this.f5905B1 = j8;
        }
        S s8 = this.f754F;
        if (s8.p()) {
            this.f5906C1 = -9223372036854775807L;
            return;
        }
        c3.getClass();
        this.f5906C1 = s8.g(c3.f3625a, new P()).f17178d;
    }

    @Override // I0.t, B0.AbstractC0020g
    public final void v(long j8, long j9) throws C0030q {
        m mVar = this.f5920e1;
        if (mVar != null) {
            try {
                C0281c c0281c = ((p) mVar.f5955e).f5962f;
                c0281c.getClass();
                try {
                    c0281c.f5870c.a(j8, j9);
                } catch (C0030q e8) {
                    throw new C(e8, c0281c.f5872e);
                }
            } catch (C e9) {
                throw f(e9, e9.f5865q, false, 7001);
            }
        }
        super.v(j8, j9);
    }

    @Override // I0.t, B0.AbstractC0020g
    public final void x(float f3, float f7) throws C0030q {
        super.x(f3, f7);
        m mVar = this.f5920e1;
        if (mVar != null) {
            mVar.g(f3);
        } else {
            this.f5914X0.g(f3);
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:30:0x0051  */
    /* JADX WARN: Removed duplicated region for block: B:31:0x0054  */
    /* JADX WARN: Removed duplicated region for block: B:64:0x006b A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Surface y0(I0.q qVar) {
        boolean z8;
        k kVar;
        boolean z9 = false;
        if (this.f5920e1 != null) {
            AbstractC1709a.j(false);
            AbstractC1709a.k(null);
            throw null;
        }
        Surface surface = this.f5923h1;
        if (surface != null) {
            return surface;
        }
        if (x0.v.f18553a >= 35 && qVar.f3241h) {
            return null;
        }
        AbstractC1709a.j(F0(qVar));
        l lVar = this.f5924i1;
        if (lVar != null && lVar.f5948q != qVar.f3239f && lVar != null) {
            lVar.release();
            this.f5924i1 = null;
        }
        if (this.f5924i1 == null) {
            Context context = this.f5910S0;
            boolean z10 = qVar.f3239f;
            if (z10) {
                if (!l.a(context)) {
                    z8 = false;
                }
                AbstractC1709a.j(z8);
                kVar = new k("ExoPlayer:PlaceholderSurface");
                int i = !z10 ? l.f5946t : 0;
                kVar.start();
                Handler handler = new Handler(kVar.getLooper(), kVar);
                kVar.f5942r = handler;
                kVar.f5941q = new x0.e(handler);
                synchronized (kVar) {
                    kVar.f5942r.obtainMessage(1, i, 0).sendToTarget();
                    while (kVar.f5945u == null && kVar.f5944t == null && kVar.f5943s == null) {
                        try {
                            kVar.wait();
                        } catch (InterruptedException unused) {
                            z9 = true;
                        }
                    }
                }
                if (z9) {
                    Thread.currentThread().interrupt();
                }
                RuntimeException runtimeException = kVar.f5944t;
                if (runtimeException != null) {
                    throw runtimeException;
                }
                Error error = kVar.f5943s;
                if (error != null) {
                    throw error;
                }
                l lVar2 = kVar.f5945u;
                lVar2.getClass();
                this.f5924i1 = lVar2;
            } else {
                int i5 = l.f5946t;
            }
            z8 = true;
            AbstractC1709a.j(z8);
            kVar = new k("ExoPlayer:PlaceholderSurface");
            if (!z10) {
            }
            kVar.start();
            Handler handler2 = new Handler(kVar.getLooper(), kVar);
            kVar.f5942r = handler2;
            kVar.f5941q = new x0.e(handler2);
            synchronized (kVar) {
            }
        }
        return this.f5924i1;
    }

    public final boolean z0(I0.q qVar) {
        if (this.f5920e1 != null) {
            return true;
        }
        Surface surface = this.f5923h1;
        if (surface == null || !surface.isValid()) {
            return (x0.v.f18553a >= 35 && qVar.f3241h) || F0(qVar);
        }
        return true;
    }
}
