package com.google.android.exoplayer2.mediacodec;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.media.MediaCodecInfo;
import android.media.MediaCodecList;
import android.text.TextUtils;
import android.util.Log;
import android.util.Pair;
import android.util.SparseIntArray;
import com.google.android.exoplayer2.mediacodec.MediaCodecUtil;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import p138.p139.p143.p144.C2803;
import p138.p176.p177.p190.C3431;
import p138.p176.p177.p190.p209.C3707;
import p138.p176.p177.p190.p239.C4134;
import p138.p176.p177.p190.p239.C4150;
import p138.p176.p177.p190.p240.C4159;

/* JADX INFO: loaded from: classes.dex */
@SuppressLint({"InlinedApi"})
public final class MediaCodecUtil {

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public static final SparseIntArray f1734;

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public static final SparseIntArray f1735;

    /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
    public static final SparseIntArray f1736;

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public static final SparseIntArray f1737;

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public static final Map<String, Integer> f1738;

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public static final Map<String, Integer> f1739;

    /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
    public static final Map<String, Integer> f1740;

    /* JADX INFO: renamed from: އ, reason: contains not printable characters */
    public static final SparseIntArray f1741;

    /* JADX INFO: renamed from: ވ, reason: contains not printable characters */
    public static final SparseIntArray f1742;

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static final Pattern f1732 = Pattern.compile("^\\D?(\\d+)$");

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public static final HashMap<C0286, List<C3707>> f1733 = new HashMap<>();

    /* JADX INFO: renamed from: މ, reason: contains not printable characters */
    public static int f1743 = -1;

    public static class DecoderQueryException extends Exception {
        public /* synthetic */ DecoderQueryException(Throwable th, C0285 c0285) {
            super("Failed to query underlying media codecs", th);
        }
    }

    /* JADX INFO: renamed from: com.google.android.exoplayer2.mediacodec.MediaCodecUtil$ؠ, reason: contains not printable characters */
    public static final class C0286 {

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final String f1744;

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public final boolean f1745;

        /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
        public final boolean f1746;

        public C0286(String str, boolean z, boolean z2) {
            this.f1744 = str;
            this.f1745 = z;
            this.f1746 = z2;
        }

        public boolean equals(Object obj) {
            if (this == obj) {
                return true;
            }
            if (obj == null || obj.getClass() != C0286.class) {
                return false;
            }
            C0286 c0286 = (C0286) obj;
            return TextUtils.equals(this.f1744, c0286.f1744) && this.f1745 == c0286.f1745 && this.f1746 == c0286.f1746;
        }

        public int hashCode() {
            return ((((this.f1744.hashCode() + 31) * 31) + (this.f1745 ? 1231 : 1237)) * 31) + (this.f1746 ? 1231 : 1237);
        }
    }

    /* JADX INFO: renamed from: com.google.android.exoplayer2.mediacodec.MediaCodecUtil$ހ, reason: contains not printable characters */
    public interface InterfaceC0287 {
        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        int mo1203();

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        MediaCodecInfo mo1204(int i);

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        boolean mo1205(String str, String str2, MediaCodecInfo.CodecCapabilities codecCapabilities);

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        boolean mo1206();

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        boolean mo1207(String str, String str2, MediaCodecInfo.CodecCapabilities codecCapabilities);
    }

    /* JADX INFO: renamed from: com.google.android.exoplayer2.mediacodec.MediaCodecUtil$ށ, reason: contains not printable characters */
    public static final class C0288 implements InterfaceC0287 {
        public /* synthetic */ C0288(C0285 c0285) {
        }

        @Override // com.google.android.exoplayer2.mediacodec.MediaCodecUtil.InterfaceC0287
        /* JADX INFO: renamed from: ֏ */
        public int mo1203() {
            return MediaCodecList.getCodecCount();
        }

        @Override // com.google.android.exoplayer2.mediacodec.MediaCodecUtil.InterfaceC0287
        /* JADX INFO: renamed from: ֏ */
        public MediaCodecInfo mo1204(int i) {
            return MediaCodecList.getCodecInfoAt(i);
        }

        @Override // com.google.android.exoplayer2.mediacodec.MediaCodecUtil.InterfaceC0287
        /* JADX INFO: renamed from: ֏ */
        public boolean mo1205(String str, String str2, MediaCodecInfo.CodecCapabilities codecCapabilities) {
            return false;
        }

        @Override // com.google.android.exoplayer2.mediacodec.MediaCodecUtil.InterfaceC0287
        /* JADX INFO: renamed from: ؠ */
        public boolean mo1206() {
            return false;
        }

        @Override // com.google.android.exoplayer2.mediacodec.MediaCodecUtil.InterfaceC0287
        /* JADX INFO: renamed from: ؠ */
        public boolean mo1207(String str, String str2, MediaCodecInfo.CodecCapabilities codecCapabilities) {
            return "secure-playback".equals(str) && "video/avc".equals(str2);
        }
    }

    /* JADX INFO: renamed from: com.google.android.exoplayer2.mediacodec.MediaCodecUtil$ނ, reason: contains not printable characters */
    @TargetApi(21)
    public static final class C0289 implements InterfaceC0287 {

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final int f1747;

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public MediaCodecInfo[] f1748;

        public C0289(boolean z, boolean z2) {
            this.f1747 = (z || z2) ? 1 : 0;
        }

        @Override // com.google.android.exoplayer2.mediacodec.MediaCodecUtil.InterfaceC0287
        /* JADX INFO: renamed from: ֏ */
        public int mo1203() {
            if (this.f1748 == null) {
                this.f1748 = new MediaCodecList(this.f1747).getCodecInfos();
            }
            return this.f1748.length;
        }

        @Override // com.google.android.exoplayer2.mediacodec.MediaCodecUtil.InterfaceC0287
        /* JADX INFO: renamed from: ֏ */
        public MediaCodecInfo mo1204(int i) {
            if (this.f1748 == null) {
                this.f1748 = new MediaCodecList(this.f1747).getCodecInfos();
            }
            return this.f1748[i];
        }

        @Override // com.google.android.exoplayer2.mediacodec.MediaCodecUtil.InterfaceC0287
        /* JADX INFO: renamed from: ֏ */
        public boolean mo1205(String str, String str2, MediaCodecInfo.CodecCapabilities codecCapabilities) {
            return codecCapabilities.isFeatureRequired(str);
        }

        @Override // com.google.android.exoplayer2.mediacodec.MediaCodecUtil.InterfaceC0287
        /* JADX INFO: renamed from: ؠ */
        public boolean mo1206() {
            return true;
        }

        @Override // com.google.android.exoplayer2.mediacodec.MediaCodecUtil.InterfaceC0287
        /* JADX INFO: renamed from: ؠ */
        public boolean mo1207(String str, String str2, MediaCodecInfo.CodecCapabilities codecCapabilities) {
            return codecCapabilities.isFeatureSupported(str);
        }
    }

    /* JADX INFO: renamed from: com.google.android.exoplayer2.mediacodec.MediaCodecUtil$ރ, reason: contains not printable characters */
    public interface InterfaceC0290<T> {
        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        int mo1208(T t);
    }

    static {
        SparseIntArray sparseIntArray = new SparseIntArray();
        f1734 = sparseIntArray;
        sparseIntArray.put(66, 1);
        f1734.put(77, 2);
        f1734.put(88, 4);
        f1734.put(100, 8);
        f1734.put(110, 16);
        f1734.put(122, 32);
        f1734.put(244, 64);
        SparseIntArray sparseIntArray2 = new SparseIntArray();
        f1735 = sparseIntArray2;
        sparseIntArray2.put(10, 1);
        f1735.put(11, 4);
        f1735.put(12, 8);
        f1735.put(13, 16);
        f1735.put(20, 32);
        f1735.put(21, 64);
        f1735.put(22, 128);
        f1735.put(30, 256);
        f1735.put(31, 512);
        f1735.put(32, 1024);
        f1735.put(40, 2048);
        f1735.put(41, 4096);
        f1735.put(42, 8192);
        f1735.put(50, 16384);
        f1735.put(51, 32768);
        f1735.put(52, 65536);
        SparseIntArray sparseIntArray3 = new SparseIntArray();
        f1736 = sparseIntArray3;
        sparseIntArray3.put(0, 1);
        f1736.put(1, 2);
        f1736.put(2, 4);
        f1736.put(3, 8);
        SparseIntArray sparseIntArray4 = new SparseIntArray();
        f1737 = sparseIntArray4;
        sparseIntArray4.put(10, 1);
        f1737.put(11, 2);
        f1737.put(20, 4);
        f1737.put(21, 8);
        f1737.put(30, 16);
        f1737.put(31, 32);
        f1737.put(40, 64);
        f1737.put(41, 128);
        f1737.put(50, 256);
        f1737.put(51, 512);
        f1737.put(60, 2048);
        f1737.put(61, 4096);
        f1737.put(62, 8192);
        HashMap map = new HashMap();
        f1738 = map;
        map.put("L30", 1);
        f1738.put("L60", 4);
        f1738.put("L63", 16);
        f1738.put("L90", 64);
        f1738.put("L93", 256);
        f1738.put("L120", 1024);
        f1738.put("L123", 4096);
        f1738.put("L150", 16384);
        f1738.put("L153", 65536);
        f1738.put("L156", 262144);
        f1738.put("L180", 1048576);
        f1738.put("L183", 4194304);
        f1738.put("L186", 16777216);
        f1738.put("H30", 2);
        f1738.put("H60", 8);
        f1738.put("H63", 32);
        f1738.put("H90", 128);
        f1738.put("H93", 512);
        f1738.put("H120", 2048);
        f1738.put("H123", 8192);
        f1738.put("H150", 32768);
        f1738.put("H153", 131072);
        f1738.put("H156", 524288);
        f1738.put("H180", 2097152);
        f1738.put("H183", 8388608);
        f1738.put("H186", 33554432);
        HashMap map2 = new HashMap();
        f1739 = map2;
        map2.put("00", 1);
        f1739.put("01", 2);
        f1739.put("02", 4);
        f1739.put("03", 8);
        f1739.put("04", 16);
        f1739.put("05", 32);
        f1739.put("06", 64);
        f1739.put("07", 128);
        f1739.put("08", 256);
        f1739.put("09", 512);
        HashMap map3 = new HashMap();
        f1740 = map3;
        map3.put("01", 1);
        f1740.put("02", 2);
        f1740.put("03", 4);
        f1740.put("04", 8);
        f1740.put("05", 16);
        f1740.put("06", 32);
        f1740.put("07", 64);
        f1740.put("08", 128);
        f1740.put("09", 256);
        SparseIntArray sparseIntArray5 = new SparseIntArray();
        f1741 = sparseIntArray5;
        sparseIntArray5.put(0, 1);
        f1741.put(1, 2);
        f1741.put(2, 4);
        f1741.put(3, 8);
        f1741.put(4, 16);
        f1741.put(5, 32);
        f1741.put(6, 64);
        f1741.put(7, 128);
        f1741.put(8, 256);
        f1741.put(9, 512);
        f1741.put(10, 1024);
        f1741.put(11, 2048);
        f1741.put(12, 4096);
        f1741.put(13, 8192);
        f1741.put(14, 16384);
        f1741.put(15, 32768);
        f1741.put(16, 65536);
        f1741.put(17, 131072);
        f1741.put(18, 262144);
        f1741.put(19, 524288);
        f1741.put(20, 1048576);
        f1741.put(21, 2097152);
        f1741.put(22, 4194304);
        f1741.put(23, 8388608);
        SparseIntArray sparseIntArray6 = new SparseIntArray();
        f1742 = sparseIntArray6;
        sparseIntArray6.put(1, 1);
        f1742.put(2, 2);
        f1742.put(3, 3);
        f1742.put(4, 4);
        f1742.put(5, 5);
        f1742.put(6, 6);
        f1742.put(17, 17);
        f1742.put(20, 20);
        f1742.put(23, 23);
        f1742.put(29, 29);
        f1742.put(39, 39);
        f1742.put(42, 42);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static /* synthetic */ int m1187(InterfaceC0290 interfaceC0290, Object obj, Object obj2) {
        return interfaceC0290.mo1208(obj2) - interfaceC0290.mo1208(obj);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static /* synthetic */ int m1188(C3431 c3431, C3707 c3707) {
        try {
            return c3707.m6050(c3431) ? 1 : 0;
        } catch (DecoderQueryException unused) {
            return -1;
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static /* synthetic */ int m1189(C3707 c3707) {
        String str = c3707.f11431;
        if (str.startsWith("OMX.google") || str.startsWith("c2.android")) {
            return 1;
        }
        return (C4150.f13259 >= 26 || !str.equals("OMX.MTK.AUDIO.DECODER.RAW")) ? 0 : -1;
    }

    /* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
    /* JADX WARN: Removed duplicated region for block: B:45:0x00b8  */
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static Pair<Integer, Integer> m1190(C3431 c3431) {
        int i;
        int i2;
        int i3;
        String str = c3431.f10087;
        if (str == null) {
            return null;
        }
        String[] strArrSplit = str.split("\\.");
        if ("video/dolby-vision".equals(c3431.f10090)) {
            String str2 = c3431.f10087;
            if (strArrSplit.length < 3) {
                C2803.m4901("Ignoring malformed Dolby Vision codec string: ", str2, "MediaCodecUtil");
                return null;
            }
            Matcher matcher = f1732.matcher(strArrSplit[1]);
            if (!matcher.matches()) {
                C2803.m4901("Ignoring malformed Dolby Vision codec string: ", str2, "MediaCodecUtil");
                return null;
            }
            String strGroup = matcher.group(1);
            Integer num = f1739.get(strGroup);
            if (num == null) {
                C2803.m4901("Unknown Dolby Vision profile string: ", strGroup, "MediaCodecUtil");
                return null;
            }
            String str3 = strArrSplit[2];
            Integer num2 = f1740.get(str3);
            if (num2 != null) {
                return new Pair<>(num, num2);
            }
            C2803.m4901("Unknown Dolby Vision level string: ", str3, "MediaCodecUtil");
            return null;
        }
        switch (strArrSplit[0]) {
            case "avc1":
            case "avc2":
                String str4 = c3431.f10087;
                if (strArrSplit.length < 2) {
                    C2803.m4901("Ignoring malformed AVC codec string: ", str4, "MediaCodecUtil");
                    return null;
                }
                try {
                    if (strArrSplit[1].length() == 6) {
                        i = Integer.parseInt(strArrSplit[1].substring(0, 2), 16);
                        i2 = Integer.parseInt(strArrSplit[1].substring(4), 16);
                    } else {
                        if (strArrSplit.length < 3) {
                            Log.w("MediaCodecUtil", "Ignoring malformed AVC codec string: " + str4);
                            return null;
                        }
                        i = Integer.parseInt(strArrSplit[1]);
                        i2 = Integer.parseInt(strArrSplit[2]);
                    }
                    int i4 = f1734.get(i, -1);
                    if (i4 == -1) {
                        C2803.m4900("Unknown AVC profile: ", i, "MediaCodecUtil");
                        return null;
                    }
                    int i5 = f1735.get(i2, -1);
                    if (i5 != -1) {
                        return new Pair<>(Integer.valueOf(i4), Integer.valueOf(i5));
                    }
                    C2803.m4900("Unknown AVC level: ", i2, "MediaCodecUtil");
                    return null;
                } catch (NumberFormatException unused) {
                    C2803.m4901("Ignoring malformed AVC codec string: ", str4, "MediaCodecUtil");
                    return null;
                }
            case "vp09":
                String str5 = c3431.f10087;
                if (strArrSplit.length < 3) {
                    C2803.m4901("Ignoring malformed VP9 codec string: ", str5, "MediaCodecUtil");
                    return null;
                }
                try {
                    int i6 = Integer.parseInt(strArrSplit[1]);
                    int i7 = Integer.parseInt(strArrSplit[2]);
                    int i8 = f1736.get(i6, -1);
                    if (i8 == -1) {
                        C2803.m4900("Unknown VP9 profile: ", i6, "MediaCodecUtil");
                        return null;
                    }
                    int i9 = f1737.get(i7, -1);
                    if (i9 != -1) {
                        return new Pair<>(Integer.valueOf(i8), Integer.valueOf(i9));
                    }
                    C2803.m4900("Unknown VP9 level: ", i7, "MediaCodecUtil");
                    return null;
                } catch (NumberFormatException unused2) {
                    C2803.m4901("Ignoring malformed VP9 codec string: ", str5, "MediaCodecUtil");
                    return null;
                }
            case "hev1":
            case "hvc1":
                String str6 = c3431.f10087;
                if (strArrSplit.length < 4) {
                    C2803.m4901("Ignoring malformed HEVC codec string: ", str6, "MediaCodecUtil");
                    return null;
                }
                Matcher matcher2 = f1732.matcher(strArrSplit[1]);
                if (!matcher2.matches()) {
                    C2803.m4901("Ignoring malformed HEVC codec string: ", str6, "MediaCodecUtil");
                    return null;
                }
                String strGroup2 = matcher2.group(1);
                if (!"1".equals(strGroup2)) {
                    if (!"2".equals(strGroup2)) {
                        C2803.m4901("Unknown HEVC profile string: ", strGroup2, "MediaCodecUtil");
                        return null;
                    }
                    i = 2;
                }
                String str7 = strArrSplit[3];
                Integer num3 = f1738.get(str7);
                if (num3 != null) {
                    return new Pair<>(Integer.valueOf(i), num3);
                }
                C2803.m4901("Unknown HEVC level string: ", str7, "MediaCodecUtil");
                return null;
            case "av01":
                String str8 = c3431.f10087;
                C4159 c4159 = c3431.f10102;
                if (strArrSplit.length < 4) {
                    C2803.m4901("Ignoring malformed AV1 codec string: ", str8, "MediaCodecUtil");
                    return null;
                }
                try {
                    int i10 = Integer.parseInt(strArrSplit[1]);
                    int i11 = Integer.parseInt(strArrSplit[2].substring(0, 2));
                    int i12 = Integer.parseInt(strArrSplit[3]);
                    if (i10 != 0) {
                        C2803.m4900("Unknown AV1 profile: ", i10, "MediaCodecUtil");
                        return null;
                    }
                    if (i12 != 8 && i12 != 10) {
                        C2803.m4900("Unknown AV1 bit depth: ", i12, "MediaCodecUtil");
                        return null;
                    }
                    i = i12 != 8 ? (c4159 == null || !(c4159.f13300 != null || (i3 = c4159.f13299) == 7 || i3 == 6)) ? 2 : 4096 : 1;
                    int i13 = f1741.get(i11, -1);
                    if (i13 != -1) {
                        return new Pair<>(Integer.valueOf(i), Integer.valueOf(i13));
                    }
                    C2803.m4900("Unknown AV1 level: ", i11, "MediaCodecUtil");
                    return null;
                } catch (NumberFormatException unused3) {
                    C2803.m4901("Ignoring malformed AV1 codec string: ", str8, "MediaCodecUtil");
                    return null;
                }
            case "mp4a":
                String str9 = c3431.f10087;
                if (strArrSplit.length != 3) {
                    C2803.m4901("Ignoring malformed MP4A codec string: ", str9, "MediaCodecUtil");
                    return null;
                }
                try {
                    if (!"audio/mp4a-latm".equals(C4134.m6649(Integer.parseInt(strArrSplit[1], 16)))) {
                        return null;
                    }
                    int i14 = f1742.get(Integer.parseInt(strArrSplit[2]), -1);
                    if (i14 != -1) {
                        return new Pair<>(Integer.valueOf(i14), 0);
                    }
                    return null;
                } catch (NumberFormatException unused4) {
                    C2803.m4901("Ignoring malformed MP4A codec string: ", str9, "MediaCodecUtil");
                    return null;
                }
            default:
                return null;
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static String m1191(MediaCodecInfo mediaCodecInfo, String str, String str2) {
        for (String str3 : mediaCodecInfo.getSupportedTypes()) {
            if (str3.equalsIgnoreCase(str2)) {
                return str3;
            }
        }
        if (str2.equals("video/dolby-vision")) {
            if ("OMX.MS.HEVCDV.Decoder".equals(str)) {
                return "video/hevcdv";
            }
            if ("OMX.RTK.video.decoder".equals(str) || "OMX.realtek.video.decoder.tunneled".equals(str)) {
                return "video/dv_hevc";
            }
            return null;
        }
        if (str2.equals("audio/alac") && "OMX.lge.alac.decoder".equals(str)) {
            return "audio/x-lg-alac";
        }
        if (str2.equals("audio/flac") && "OMX.lge.flac.decoder".equals(str)) {
            return "audio/x-lg-flac";
        }
        return null;
    }

    /* JADX WARN: Removed duplicated region for block: B:114:0x01a4 A[ADDED_TO_REGION, REMOVE, SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:12:0x0031  */
    /* JADX WARN: Removed duplicated region for block: B:66:0x00fc  */
    /* JADX WARN: Removed duplicated region for block: B:72:0x012c  */
    /* JADX WARN: Removed duplicated region for block: B:90:0x017b A[Catch: Exception -> 0x01c9, TRY_ENTER, TryCatch #2 {Exception -> 0x01c9, blocks: (B:3:0x0008, B:5:0x001c, B:7:0x0026, B:93:0x019a, B:13:0x0039, B:16:0x0044, B:87:0x0173, B:90:0x017b, B:92:0x0181, B:94:0x01a4, B:95:0x01c7), top: B:104:0x0008 }] */
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static ArrayList<C3707> m1192(C0286 c0286, InterfaceC0287 interfaceC0287) throws DecoderQueryException {
        String strM1191;
        String str;
        String str2;
        int i;
        boolean z;
        int i2;
        boolean zIsVendor;
        String str3;
        C0286 c02862 = c0286;
        try {
            ArrayList<C3707> arrayList = new ArrayList<>();
            String str4 = c02862.f1744;
            boolean zMo1206 = interfaceC0287.mo1206();
            int i3 = 0;
            for (int iMo1203 = interfaceC0287.mo1203(); i3 < iMo1203; iMo1203 = i2) {
                MediaCodecInfo mediaCodecInfoMo1204 = interfaceC0287.mo1204(i3);
                if (C4150.f13259 >= 29 && mediaCodecInfoMo1204.isAlias()) {
                    i = i3;
                    z = zMo1206;
                    i2 = iMo1203;
                } else {
                    String name = mediaCodecInfoMo1204.getName();
                    if (m1199(mediaCodecInfoMo1204, name, zMo1206, str4) && (strM1191 = m1191(mediaCodecInfoMo1204, name, str4)) != null) {
                        try {
                            MediaCodecInfo.CodecCapabilities capabilitiesForType = mediaCodecInfoMo1204.getCapabilitiesForType(strM1191);
                            boolean zMo1207 = interfaceC0287.mo1207("tunneled-playback", strM1191, capabilitiesForType);
                            boolean zMo1205 = interfaceC0287.mo1205("tunneled-playback", strM1191, capabilitiesForType);
                            if ((c02862.f1746 || !zMo1205) && (!c02862.f1746 || zMo1207)) {
                                boolean zMo12072 = interfaceC0287.mo1207("secure-playback", strM1191, capabilitiesForType);
                                boolean zMo12052 = interfaceC0287.mo1205("secure-playback", strM1191, capabilitiesForType);
                                if ((c02862.f1745 || !zMo12052) && (!c02862.f1745 || zMo12072)) {
                                    boolean zIsHardwareAccelerated = C4150.f13259 >= 29 ? mediaCodecInfoMo1204.isHardwareAccelerated() : !m1198(mediaCodecInfoMo1204);
                                    boolean zM1198 = m1198(mediaCodecInfoMo1204);
                                    if (C4150.f13259 >= 29) {
                                        zIsVendor = mediaCodecInfoMo1204.isVendor();
                                    } else {
                                        String strM6809 = C4150.m6809(mediaCodecInfoMo1204.getName());
                                        zIsVendor = (strM6809.startsWith("omx.google.") || strM6809.startsWith("c2.android.") || strM6809.startsWith("c2.google.")) ? false : true;
                                    }
                                    boolean z2 = C4150.f13259 <= 22 && ("ODROID-XU3".equals(C4150.f13262) || "Nexus 10".equals(C4150.f13262)) && ("OMX.Exynos.AVC.Decoder".equals(name) || "OMX.Exynos.AVC.Decoder.secure".equals(name));
                                    if (!zMo1206 || c02862.f1745 != zMo12072) {
                                        if (!zMo1206) {
                                            try {
                                                if (c02862.f1745) {
                                                    str = strM1191;
                                                    str3 = name;
                                                    i = i3;
                                                    z = zMo1206;
                                                    i2 = iMo1203;
                                                    if (!z && zMo12072) {
                                                        StringBuilder sb = new StringBuilder();
                                                        try {
                                                            sb.append(str3);
                                                            sb.append(".secure");
                                                            str2 = str3;
                                                        } catch (Exception e) {
                                                            e = e;
                                                            str2 = str3;
                                                        }
                                                        try {
                                                            arrayList.add(C3707.m6046(sb.toString(), str4, str, capabilitiesForType, zIsHardwareAccelerated, zM1198, zIsVendor, z2, true));
                                                            return arrayList;
                                                        } catch (Exception e2) {
                                                            e = e2;
                                                            if (C4150.f13259 > 23) {
                                                            }
                                                            Log.e("MediaCodecUtil", "Failed to query codec " + str2 + " (" + str + ")");
                                                            throw e;
                                                        }
                                                    }
                                                } else {
                                                    str = strM1191;
                                                    str3 = name;
                                                    i = i3;
                                                    z = zMo1206;
                                                    i2 = iMo1203;
                                                    try {
                                                        arrayList.add(C3707.m6046(name, str4, strM1191, capabilitiesForType, zIsHardwareAccelerated, zM1198, zIsVendor, z2, false));
                                                    } catch (Exception e3) {
                                                        e = e3;
                                                        str2 = str3;
                                                        if (C4150.f13259 > 23 || arrayList.isEmpty()) {
                                                            Log.e("MediaCodecUtil", "Failed to query codec " + str2 + " (" + str + ")");
                                                            throw e;
                                                        }
                                                        Log.e("MediaCodecUtil", "Skipping codec " + str2 + " (failed to query capabilities)");
                                                    }
                                                }
                                            } catch (Exception e4) {
                                                e = e4;
                                                str = strM1191;
                                                i = i3;
                                                z = zMo1206;
                                                i2 = iMo1203;
                                                str2 = name;
                                                if (C4150.f13259 > 23) {
                                                }
                                                Log.e("MediaCodecUtil", "Failed to query codec " + str2 + " (" + str + ")");
                                                throw e;
                                            }
                                        }
                                    }
                                }
                            }
                        } catch (Exception e5) {
                            e = e5;
                            str = strM1191;
                            str2 = name;
                            i = i3;
                            z = zMo1206;
                            i2 = iMo1203;
                        }
                    }
                }
                i3 = i + 1;
                c02862 = c0286;
                zMo1206 = z;
            }
            return arrayList;
        } catch (Exception e6) {
            throw new DecoderQueryException(e6, null);
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static List<C3707> m1193(List<C3707> list, final C3431 c3431) {
        ArrayList arrayList = new ArrayList(list);
        m1197(arrayList, new InterfaceC0290() { // from class: ދ.ހ.֏.ؠ.ഩ.ؠ
            @Override // com.google.android.exoplayer2.mediacodec.MediaCodecUtil.InterfaceC0290
            /* JADX INFO: renamed from: ֏ */
            public final int mo1208(Object obj) {
                return MediaCodecUtil.m1188(c3431, (C3707) obj);
            }
        });
        return arrayList;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static C3707 m1194() {
        C3707 c3707M1195 = m1195("audio/raw", false, false);
        if (c3707M1195 == null) {
            return null;
        }
        return new C3707(c3707M1195.f11431, null, null, null, true, false, true, false, false, false);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static C3707 m1195(String str, boolean z, boolean z2) {
        List<C3707> listM1202 = m1202(str, z, z2);
        if (listM1202.isEmpty()) {
            return null;
        }
        return listM1202.get(0);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static void m1196(String str, List<C3707> list) {
        if ("audio/raw".equals(str)) {
            if (C4150.f13259 < 26 && C4150.f13260.equals("R9") && list.size() == 1 && list.get(0).f11431.equals("OMX.MTK.AUDIO.DECODER.RAW")) {
                list.add(C3707.m6046("OMX.google.raw.decoder", "audio/raw", "audio/raw", null, false, true, false, false, false));
            }
            m1197(list, new InterfaceC0290() { // from class: ދ.ހ.֏.ؠ.ഩ.ހ
                @Override // com.google.android.exoplayer2.mediacodec.MediaCodecUtil.InterfaceC0290
                /* JADX INFO: renamed from: ֏ */
                public final int mo1208(Object obj) {
                    return MediaCodecUtil.m1189((C3707) obj);
                }
            });
        }
        if (C4150.f13259 < 21 && list.size() > 1) {
            String str2 = list.get(0).f11431;
            if ("OMX.SEC.mp3.dec".equals(str2) || "OMX.SEC.MP3.Decoder".equals(str2) || "OMX.brcm.audio.mp3.decoder".equals(str2)) {
                m1197(list, new InterfaceC0290() { // from class: ދ.ހ.֏.ؠ.ഩ.֏
                    @Override // com.google.android.exoplayer2.mediacodec.MediaCodecUtil.InterfaceC0290
                    /* JADX INFO: renamed from: ֏ */
                    public final int mo1208(Object obj) {
                        return MediaCodecUtil.m1201((C3707) obj);
                    }
                });
            }
        }
        if (C4150.f13259 >= 30 || list.size() <= 1 || !"OMX.qti.audio.decoder.flac".equals(list.get(0).f11431)) {
            return;
        }
        list.add(list.remove(0));
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static <T> void m1197(List<T> list, final InterfaceC0290<T> interfaceC0290) {
        Collections.sort(list, new Comparator() { // from class: ދ.ހ.֏.ؠ.ഩ.ށ
            @Override // java.util.Comparator
            public final int compare(Object obj, Object obj2) {
                return MediaCodecUtil.m1187(interfaceC0290, obj, obj2);
            }
        });
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static boolean m1198(MediaCodecInfo mediaCodecInfo) {
        if (C4150.f13259 >= 29) {
            return mediaCodecInfo.isSoftwareOnly();
        }
        String strM6809 = C4150.m6809(mediaCodecInfo.getName());
        if (strM6809.startsWith("arc.")) {
            return false;
        }
        return strM6809.startsWith("omx.google.") || strM6809.startsWith("omx.ffmpeg.") || (strM6809.startsWith("omx.sec.") && strM6809.contains(".sw.")) || strM6809.equals("omx.qcom.video.decoder.hevcswvdec") || strM6809.startsWith("c2.android.") || strM6809.startsWith("c2.google.") || !(strM6809.startsWith("omx.") || strM6809.startsWith("c2."));
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static boolean m1199(MediaCodecInfo mediaCodecInfo, String str, boolean z, String str2) {
        if (mediaCodecInfo.isEncoder() || (!z && str.endsWith(".secure"))) {
            return false;
        }
        if (C4150.f13259 < 21 && ("CIPAACDecoder".equals(str) || "CIPMP3Decoder".equals(str) || "CIPVorbisDecoder".equals(str) || "CIPAMRNBDecoder".equals(str) || "AACDecoder".equals(str) || "MP3Decoder".equals(str))) {
            return false;
        }
        if (C4150.f13259 < 18 && "OMX.MTK.AUDIO.DECODER.AAC".equals(str) && ("a70".equals(C4150.f13260) || ("Xiaomi".equals(C4150.f13261) && C4150.f13260.startsWith("HM")))) {
            return false;
        }
        if (C4150.f13259 == 16 && "OMX.qcom.audio.decoder.mp3".equals(str) && ("dlxu".equals(C4150.f13260) || "protou".equals(C4150.f13260) || "ville".equals(C4150.f13260) || "villeplus".equals(C4150.f13260) || "villec2".equals(C4150.f13260) || C4150.f13260.startsWith("gee") || "C6602".equals(C4150.f13260) || "C6603".equals(C4150.f13260) || "C6606".equals(C4150.f13260) || "C6616".equals(C4150.f13260) || "L36h".equals(C4150.f13260) || "SO-02E".equals(C4150.f13260))) {
            return false;
        }
        if (C4150.f13259 == 16 && "OMX.qcom.audio.decoder.aac".equals(str) && ("C1504".equals(C4150.f13260) || "C1505".equals(C4150.f13260) || "C1604".equals(C4150.f13260) || "C1605".equals(C4150.f13260))) {
            return false;
        }
        if (C4150.f13259 < 24 && (("OMX.SEC.aac.dec".equals(str) || "OMX.Exynos.AAC.Decoder".equals(str)) && "samsung".equals(C4150.f13261) && (C4150.f13260.startsWith("zeroflte") || C4150.f13260.startsWith("zerolte") || C4150.f13260.startsWith("zenlte") || "SC-05G".equals(C4150.f13260) || "marinelteatt".equals(C4150.f13260) || "404SC".equals(C4150.f13260) || "SC-04G".equals(C4150.f13260) || "SCV31".equals(C4150.f13260)))) {
            return false;
        }
        if (C4150.f13259 <= 19 && "OMX.SEC.vp8.dec".equals(str) && "samsung".equals(C4150.f13261) && (C4150.f13260.startsWith("d2") || C4150.f13260.startsWith("serrano") || C4150.f13260.startsWith("jflte") || C4150.f13260.startsWith("santos") || C4150.f13260.startsWith("t0"))) {
            return false;
        }
        if (C4150.f13259 <= 19 && C4150.f13260.startsWith("jflte") && "OMX.qcom.video.decoder.vp8".equals(str)) {
            return false;
        }
        return ("audio/eac3-joc".equals(str2) && "OMX.MTK.AUDIO.DECODER.DSPAC3".equals(str)) ? false : true;
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public static int m1200() {
        int i;
        if (f1743 == -1) {
            int iMax = 0;
            C3707 c3707M1195 = m1195("video/avc", false, false);
            if (c3707M1195 != null) {
                MediaCodecInfo.CodecProfileLevel[] codecProfileLevelArrM6052 = c3707M1195.m6052();
                int length = codecProfileLevelArrM6052.length;
                int iMax2 = 0;
                while (iMax < length) {
                    int i2 = codecProfileLevelArrM6052[iMax].level;
                    if (i2 != 1 && i2 != 2) {
                        switch (i2) {
                            case 8:
                            case 16:
                            case 32:
                                i = 101376;
                                break;
                            case 64:
                                i = 202752;
                                break;
                            case 128:
                            case 256:
                                i = 414720;
                                break;
                            case 512:
                                i = 921600;
                                break;
                            case 1024:
                                i = 1310720;
                                break;
                            case 2048:
                            case 4096:
                                i = 2097152;
                                break;
                            case 8192:
                                i = 2228224;
                                break;
                            case 16384:
                                i = 5652480;
                                break;
                            case 32768:
                            case 65536:
                                i = 9437184;
                                break;
                            default:
                                i = -1;
                                break;
                        }
                    } else {
                        i = 25344;
                    }
                    iMax2 = Math.max(i, iMax2);
                    iMax++;
                }
                iMax = Math.max(iMax2, C4150.f13259 >= 21 ? 345600 : 172800);
            }
            f1743 = iMax;
        }
        return f1743;
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public static /* synthetic */ int m1201(C3707 c3707) {
        return c3707.f11431.startsWith("OMX.google") ? 1 : 0;
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public static synchronized List<C3707> m1202(String str, boolean z, boolean z2) {
        C0286 c0286 = new C0286(str, z, z2);
        List<C3707> list = f1733.get(c0286);
        if (list != null) {
            return list;
        }
        C0285 c0285 = null;
        ArrayList<C3707> arrayListM1192 = m1192(c0286, C4150.f13259 >= 21 ? new C0289(z, z2) : new C0288(c0285));
        if (z && arrayListM1192.isEmpty() && 21 <= C4150.f13259 && C4150.f13259 <= 23) {
            arrayListM1192 = m1192(c0286, new C0288(c0285));
            if (!arrayListM1192.isEmpty()) {
                Log.w("MediaCodecUtil", "MediaCodecList API didn't list secure decoder for: " + str + ". Assuming: " + arrayListM1192.get(0).f11431);
            }
        }
        m1196(str, arrayListM1192);
        List<C3707> listUnmodifiableList = Collections.unmodifiableList(arrayListM1192);
        f1733.put(c0286, listUnmodifiableList);
        return listUnmodifiableList;
    }
}
