package defpackage;

import android.content.Context;
import android.graphics.Point;
import android.media.MediaCodecInfo;
import android.os.Build;
import android.util.Pair;
import android.util.Range;
import j$.util.Objects;
import java.util.HashMap;

/* JADX INFO: renamed from: ˊٴᵝ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C1354 {

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public final String f5594;

    /* JADX INFO: renamed from: ˊᵫᵗ, reason: contains not printable characters */
    public final boolean f5595;

    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public final String f5596;

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public final boolean f5597;

    /* JADX INFO: renamed from: ᵮᵣᵗˈ, reason: contains not printable characters */
    public float f5598;

    /* JADX INFO: renamed from: ᵱᵽʡᵚ, reason: contains not printable characters */
    public int f5599;

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final String f5600;

    /* JADX INFO: renamed from: ᵵᵽ, reason: contains not printable characters */
    public final boolean f5601;

    /* JADX INFO: renamed from: ᵶᵥᵝ, reason: contains not printable characters */
    public int f5602;

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public final MediaCodecInfo.CodecCapabilities f5603;

    /* JADX INFO: renamed from: ᵻʽᵯ, reason: contains not printable characters */
    public final boolean f5604;

    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    public final boolean f5605;

    public C1354(String str, String str2, String str3, MediaCodecInfo.CodecCapabilities codecCapabilities, boolean z, boolean z2, boolean z3, boolean z4, boolean z5, boolean z6) {
        str.getClass();
        this.f5600 = str;
        this.f5594 = str2;
        this.f5596 = str3;
        this.f5603 = codecCapabilities;
        this.f5601 = z;
        this.f5597 = z4;
        this.f5605 = z5;
        this.f5595 = z6;
        this.f5604 = AbstractC4208.m9134(str2);
        this.f5598 = -3.4028235E38f;
        this.f5599 = -1;
        this.f5602 = -1;
    }

    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public static boolean m3874(MediaCodecInfo.VideoCapabilities videoCapabilities, int i, int i2, double d) {
        Range<Double> achievableFrameRatesFor;
        int widthAlignment = videoCapabilities.getWidthAlignment();
        int heightAlignment = videoCapabilities.getHeightAlignment();
        Point point = new Point(AbstractC0956.m3265(i, widthAlignment) * widthAlignment, AbstractC0956.m3265(i2, heightAlignment) * heightAlignment);
        int i3 = point.x;
        int i4 = point.y;
        if (d == -1.0d || d < 1.0d) {
            return videoCapabilities.isSizeSupported(i3, i4);
        }
        double dFloor = Math.floor(d);
        if (videoCapabilities.areSizeAndRateSupported(i3, i4, dFloor)) {
            return Build.VERSION.SDK_INT < 24 || (achievableFrameRatesFor = videoCapabilities.getAchievableFrameRatesFor(i3, i4)) == null || dFloor <= ((Double) achievableFrameRatesFor.getUpper()).doubleValue();
        }
        return false;
    }

    /* JADX WARN: Removed duplicated region for block: B:34:0x006f  */
    /* JADX INFO: renamed from: ᵻʽᵯ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static C1354 m3875(String str, String str2, String str3, MediaCodecInfo.CodecCapabilities codecCapabilities, boolean z, boolean z2, boolean z3, boolean z4) {
        boolean z5;
        String str4;
        String str5;
        MediaCodecInfo.CodecCapabilities codecCapabilities2;
        boolean z6;
        boolean z7;
        boolean z8;
        String str6;
        boolean z9 = codecCapabilities != null && codecCapabilities.isFeatureSupported("adaptive-playback");
        if (codecCapabilities != null) {
            codecCapabilities.isFeatureSupported("tunneled-playback");
        }
        boolean z10 = z4 || (codecCapabilities != null && codecCapabilities.isFeatureSupported("secure-playback"));
        if (Build.VERSION.SDK_INT < 35 || codecCapabilities == null || !codecCapabilities.isFeatureSupported("detached-surface")) {
            z5 = false;
            str4 = str2;
            str5 = str3;
            codecCapabilities2 = codecCapabilities;
            z6 = z;
            z7 = z2;
            z8 = z3;
            str6 = str;
        } else {
            String str7 = Build.MANUFACTURER;
            if (!str7.equals("Xiaomi") && !str7.equals("OPPO") && !str7.equals("realme") && !str7.equals("motorola") && !str7.equals("LENOVO")) {
                z5 = true;
                str6 = str;
                str5 = str3;
                codecCapabilities2 = codecCapabilities;
                z6 = z;
                z7 = z2;
                z8 = z3;
                str4 = str2;
            }
        }
        return new C1354(str6, str4, str5, codecCapabilities2, z6, z7, z8, z9, z10, z5);
    }

    public final String toString() {
        return this.f5600;
    }

    /* JADX INFO: renamed from: ʽˈˋ, reason: contains not printable characters */
    public final C4394 m3876(C5286 c5286, C5286 c52862) {
        C5286 c52863;
        C5286 c52864;
        int i;
        String str = c5286.f19987;
        C3281 c3281 = c5286.f19978;
        String str2 = c52862.f19987;
        C3281 c32812 = c52862.f19978;
        int i2 = !Objects.equals(str, str2) ? 8 : 0;
        if (this.f5604) {
            if (c5286.f19995 != c52862.f19995) {
                i2 |= 1024;
            }
            boolean z = (c5286.f19973 == c52862.f19973 && c5286.f19981 == c52862.f19981) ? false : true;
            if (!this.f5597 && z) {
                i2 |= 512;
            }
            if ((!C3281.m7515(c3281) || !C3281.m7515(c32812)) && !Objects.equals(c3281, c32812)) {
                i2 |= 2048;
            }
            if (Build.MODEL.startsWith("SM-T230") && "OMX.MARVELL.VIDEO.HW.CODA7542DECODER".equals(this.f5600) && !c5286.m10877(c52862)) {
                i2 |= 2;
            }
            int i3 = c5286.f19979;
            if (i3 != -1 && (i = c5286.f19986) != -1 && i3 == c52862.f19979 && i == c52862.f19986 && z) {
                i2 |= 2;
            }
            if (i2 == 0 && Objects.equals(c52862.f19987, "video/dolby-vision")) {
                Pair pairM5109 = AbstractC1879.m5109(c5286);
                Pair pairM51092 = AbstractC1879.m5109(c52862);
                if (pairM5109 == null || pairM51092 == null || !((Integer) pairM5109.first).equals(pairM51092.first)) {
                    i2 |= 2;
                }
            }
            if (i2 == 0) {
                return new C4394(this.f5600, c5286, c52862, c5286.m10877(c52862) ? 3 : 2, 0);
            }
            c52863 = c5286;
            c52864 = c52862;
        } else {
            c52863 = c5286;
            c52864 = c52862;
            if (c52863.f19984 != c52864.f19984) {
                i2 |= 4096;
            }
            if (c52863.f19966 != c52864.f19966) {
                i2 |= 8192;
            }
            if (c52863.f19962 != c52864.f19962) {
                i2 |= 16384;
            }
            String str3 = this.f5594;
            if (i2 == 0 && (str3.equals("audio/mp4a-latm") || str3.equals("audio/ac4"))) {
                Pair pairM51093 = AbstractC1879.m5109(c52863);
                Pair pairM51094 = AbstractC1879.m5109(c52864);
                if (pairM51093 != null && pairM51094 != null) {
                    int iIntValue = ((Integer) pairM51093.first).intValue();
                    int iIntValue2 = ((Integer) pairM51094.first).intValue();
                    if (iIntValue == 42 && iIntValue2 == 42) {
                        return new C4394(this.f5600, c52863, c52864, 3, 0);
                    }
                    if (str3.equals("audio/ac4") && pairM51093.equals(pairM51094)) {
                        return new C4394(this.f5600, c52863, c52864, 3, 0);
                    }
                }
            }
            if (i2 == 0 && (str3.equals("audio/eac3-joc") || str3.equals("audio/eac3"))) {
                return new C4394(this.f5600, c52863, c52864, 3, 0);
            }
            if (!c52863.m10877(c52864)) {
                i2 |= 32;
            }
            if ("audio/opus".equals(str3)) {
                i2 |= 2;
            }
            if (i2 == 0) {
                return new C4394(this.f5600, c52863, c52864, 1, 0);
            }
        }
        return new C4394(this.f5600, c52863, c52864, 0, i2);
    }

    /* JADX INFO: renamed from: ˊᵫᵗ, reason: contains not printable characters */
    public final void m3877(String str) {
        ˋˀᵧ.ᵶᵥᵝ("NoSupport [" + str + "] [" + this.f5600 + ", " + this.f5594 + "] [" + AbstractC0956.f4222 + "]");
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:113:0x01ab  */
    /* JADX WARN: Removed duplicated region for block: B:17:0x004e  */
    /* JADX WARN: Removed duplicated region for block: B:70:0x012a  */
    /* JADX WARN: Removed duplicated region for block: B:78:0x014c  */
    /* JADX WARN: Removed duplicated region for block: B:81:0x0153  */
    /* JADX WARN: Removed duplicated region for block: B:82:0x0156  */
    /* JADX WARN: Type inference failed for: r16v0 */
    /* JADX WARN: Type inference failed for: r16v1, types: [boolean] */
    /* JADX WARN: Type inference failed for: r16v2 */
    /* JADX WARN: Type inference failed for: r3v22 */
    /* JADX WARN: Type inference failed for: r3v6 */
    /* JADX WARN: Type inference failed for: r3v7 */
    /* JADX WARN: Type inference failed for: r4v34 */
    /* JADX WARN: Type inference failed for: r4v4 */
    /* JADX WARN: Type inference failed for: r4v5, types: [int] */
    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean m3878(Context context, C5286 c5286, boolean z) {
        MediaCodecInfo.CodecProfileLevel[] codecProfileLevelArr;
        ?? r16;
        int i;
        int length;
        ?? r4;
        MediaCodecInfo.VideoCapabilities videoCapabilities;
        MediaCodecInfo.AudioCapabilities audioCapabilities;
        Pair pairM5109 = AbstractC1879.m5109(c5286);
        String str = c5286.f19987;
        String str2 = this.f5596;
        if (str != null && str.equals("video/mv-hevc")) {
            String strM9132 = AbstractC4208.m9132(str2);
            if (!strM9132.equals("video/mv-hevc")) {
                if (strM9132.equals("video/hevc")) {
                    HashMap map = AbstractC2124.f8440;
                    String str3 = ᵥˇᵛˎ.ˈᵲᵢ(c5286.f19967);
                    if (str3 == null) {
                        pairM5109 = null;
                    } else {
                        String strTrim = str3.trim();
                        String str4 = AbstractC0956.f4222;
                        pairM5109 = AbstractC1879.m5111(str3, strTrim.split("\\.", -1), c5286.f19978);
                    }
                }
                if (pairM5109 != null) {
                }
            }
        } else if (pairM5109 != null) {
            int iIntValue = ((Integer) pairM5109.first).intValue();
            int iIntValue2 = ((Integer) pairM5109.second).intValue();
            boolean zEquals = "video/dolby-vision".equals(str);
            String str5 = this.f5594;
            if (zEquals) {
                str5.getClass();
                switch (str5) {
                    case "video/av01":
                    case "video/hevc":
                        iIntValue = 2;
                        iIntValue2 = 0;
                        break;
                    case "video/avc":
                        iIntValue2 = 0;
                        iIntValue = 8;
                        break;
                }
            }
            if (this.f5604 || str5.equals("audio/ac4") || iIntValue == 42) {
                MediaCodecInfo.CodecCapabilities codecCapabilities = this.f5603;
                if (codecCapabilities == null || (codecProfileLevelArr = codecCapabilities.profileLevels) == null) {
                    codecProfileLevelArr = new MediaCodecInfo.CodecProfileLevel[0];
                }
                if (!str5.equals("audio/ac4") || codecProfileLevelArr.length != 0) {
                    r16 = 0;
                    i = 4;
                    if (Build.VERSION.SDK_INT == 23 && "video/x-vnd.on2.vp9".equals(str5) && codecProfileLevelArr.length == 0) {
                        ?? IntValue = (codecCapabilities != null || (videoCapabilities = codecCapabilities.getVideoCapabilities()) == null) ? r16 : ((Integer) videoCapabilities.getBitrateRange().getUpper()).intValue();
                        codecProfileLevelArr = new MediaCodecInfo.CodecProfileLevel[1];
                        codecProfileLevelArr[r16] = AbstractC2124.m5628(1, IntValue < 180000000 ? 1024 : IntValue >= 120000000 ? 512 : IntValue >= 60000000 ? 256 : IntValue >= 30000000 ? 128 : IntValue >= 18000000 ? 64 : IntValue >= 12000000 ? 32 : IntValue >= 7200000 ? 16 : IntValue >= 3600000 ? 8 : IntValue >= 1800000 ? i : IntValue >= 800000 ? 2 : 1);
                    }
                    length = codecProfileLevelArr.length;
                    for (r4 = r16; r4 < length; r4++) {
                        MediaCodecInfo.CodecProfileLevel codecProfileLevel = codecProfileLevelArr[r4];
                        if (codecProfileLevel.profile == iIntValue && (codecProfileLevel.level >= iIntValue2 || !z)) {
                            if ("video/hevc".equals(str5) && 2 == iIntValue) {
                                String str6 = Build.DEVICE;
                                if ("sailfish".equals(str6) || "marlin".equals(str6)) {
                                }
                            }
                        }
                    }
                    m3877("codec.profileLevel, " + c5286.f19996 + ", " + str2);
                    return r16;
                }
                int i2 = ((codecCapabilities == null || (audioCapabilities = codecCapabilities.getAudioCapabilities()) == null) ? 2 : audioCapabilities.getMaxInputChannelCount()) > 18 ? 16 : 8;
                if (!context.getPackageManager().hasSystemFeature("android.hardware.type.automotive")) {
                    r16 = 0;
                    i = 4;
                    codecProfileLevelArr = new MediaCodecInfo.CodecProfileLevel[]{AbstractC2124.m5628(257, i2), AbstractC2124.m5628(513, i2), AbstractC2124.m5628(514, i2), AbstractC2124.m5628(1026, i2), AbstractC2124.m5628(1028, i2)};
                    if (Build.VERSION.SDK_INT == 23) {
                    }
                    length = codecProfileLevelArr.length;
                    while (r4 < length) {
                    }
                    m3877("codec.profileLevel, " + c5286.f19996 + ", " + str2);
                    return r16;
                }
                codecProfileLevelArr = new MediaCodecInfo.CodecProfileLevel[]{AbstractC2124.m5628(1026, i2)};
                r16 = 0;
                i = 4;
                if (Build.VERSION.SDK_INT == 23) {
                    if (codecCapabilities != null) {
                        codecProfileLevelArr = new MediaCodecInfo.CodecProfileLevel[1];
                        codecProfileLevelArr[r16] = AbstractC2124.m5628(1, IntValue < 180000000 ? 1024 : IntValue >= 120000000 ? 512 : IntValue >= 60000000 ? 256 : IntValue >= 30000000 ? 128 : IntValue >= 18000000 ? 64 : IntValue >= 12000000 ? 32 : IntValue >= 7200000 ? 16 : IntValue >= 3600000 ? 8 : IntValue >= 1800000 ? i : IntValue >= 800000 ? 2 : 1);
                    }
                }
                length = codecProfileLevelArr.length;
                while (r4 < length) {
                }
                m3877("codec.profileLevel, " + c5286.f19996 + ", " + str2);
                return r16;
            }
        }
        return true;
    }

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public final boolean m3879(Context context, C5286 c5286) {
        int i;
        String str = c5286.f19987;
        String str2 = this.f5594;
        if ((!str2.equals(str) && !str2.equals(AbstractC2124.m5630(c5286))) || !m3878(context, c5286, true) || !m3881(c5286)) {
            return false;
        }
        if (this.f5604) {
            int i2 = c5286.f19973;
            if (i2 > 0 && (i = c5286.f19981) > 0) {
                return m3880(i2, i, c5286.f19989);
            }
        } else {
            int i3 = c5286.f19966;
            MediaCodecInfo.CodecCapabilities codecCapabilities = this.f5603;
            if (i3 != -1) {
                if (codecCapabilities == null) {
                    m3877("sampleRate.caps");
                    return false;
                }
                MediaCodecInfo.AudioCapabilities audioCapabilities = codecCapabilities.getAudioCapabilities();
                if (audioCapabilities == null) {
                    m3877("sampleRate.aCaps");
                    return false;
                }
                if (!audioCapabilities.isSampleRateSupported(i3)) {
                    m3877("sampleRate.support, " + i3);
                    return false;
                }
            }
            int i4 = c5286.f19984;
            if (i4 != -1) {
                if (codecCapabilities == null) {
                    m3877("channelCount.caps");
                    return false;
                }
                MediaCodecInfo.AudioCapabilities audioCapabilities2 = codecCapabilities.getAudioCapabilities();
                if (audioCapabilities2 == null) {
                    m3877("channelCount.aCaps");
                    return false;
                }
                int maxInputChannelCount = audioCapabilities2.getMaxInputChannelCount();
                if (maxInputChannelCount <= 1 && ((Build.VERSION.SDK_INT < 26 || maxInputChannelCount <= 0) && !"audio/mpeg".equals(str2) && !"audio/3gpp".equals(str2) && !"audio/amr-wb".equals(str2) && !"audio/mp4a-latm".equals(str2) && !"audio/vorbis".equals(str2) && !"audio/opus".equals(str2) && !"audio/raw".equals(str2) && !"audio/flac".equals(str2) && !"audio/g711-alaw".equals(str2) && !"audio/g711-mlaw".equals(str2) && !"audio/gsm".equals(str2))) {
                    int i5 = "audio/ac3".equals(str2) ? 6 : "audio/eac3".equals(str2) ? 16 : 30;
                    ˋˀᵧ.ʿٴˇ("AssumedMaxChannelAdjustment: " + this.f5600 + ", [" + maxInputChannelCount + " to " + i5 + "]");
                    maxInputChannelCount = i5;
                }
                if (maxInputChannelCount < i4) {
                    m3877("channelCount.support, " + i4);
                    return false;
                }
            }
        }
        return true;
    }

    /* JADX WARN: Removed duplicated region for block: B:28:0x0053  */
    /* JADX INFO: renamed from: ᵵᵽ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean m3880(int i, int i2, double d) {
        Boolean bool;
        MediaCodecInfo.CodecCapabilities codecCapabilities = this.f5603;
        if (codecCapabilities == null) {
            m3877("sizeAndRate.caps");
            return false;
        }
        MediaCodecInfo.VideoCapabilities videoCapabilities = codecCapabilities.getVideoCapabilities();
        if (videoCapabilities == null) {
            m3877("sizeAndRate.vCaps");
            return false;
        }
        int i3 = Build.VERSION.SDK_INT;
        if (i3 >= 29) {
            int iM4487 = (i3 < 29 || ((bool = ᵷˆᵣ.ᵝᵶ) != null && bool.booleanValue())) ? 0 : AbstractC1630.m4487(videoCapabilities, i, i2, d);
            if (iM4487 != 2) {
                if (iM4487 == 1) {
                    StringBuilder sbM8103 = AbstractC3589.m8103("sizeAndRate.cover, ", i, "x", i2, "@");
                    sbM8103.append(d);
                    m3877(sbM8103.toString());
                    return false;
                }
                if (!m3874(videoCapabilities, i, i2, d)) {
                }
            }
        } else if (!m3874(videoCapabilities, i, i2, d)) {
            if (i < i2) {
                String str = this.f5600;
                if ((!"OMX.MTK.VIDEO.DECODER.HEVC".equals(str) || !"mcv5a".equals(Build.DEVICE)) && m3874(videoCapabilities, i2, i, d)) {
                    StringBuilder sbM81032 = AbstractC3589.m8103("sizeAndRate.rotated, ", i, "x", i2, "@");
                    sbM81032.append(d);
                    StringBuilder sbM8226 = AbstractC3653.m8226("AssumedSupport [", sbM81032.toString(), "] [", str, ", ");
                    sbM8226.append(this.f5594);
                    sbM8226.append("] [");
                    sbM8226.append(AbstractC0956.f4222);
                    sbM8226.append("]");
                    ˋˀᵧ.ᵶᵥᵝ(sbM8226.toString());
                    return true;
                }
            }
            StringBuilder sbM81033 = AbstractC3589.m8103("sizeAndRate.support, ", i, "x", i2, "@");
            sbM81033.append(d);
            m3877(sbM81033.toString());
            return false;
        }
        return true;
    }

    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public final boolean m3881(C5286 c5286) {
        return (Objects.equals(c5286.f19987, "audio/flac") && c5286.f19962 == 22 && Build.VERSION.SDK_INT < 34 && this.f5600.equals("c2.android.flac.decoder")) ? false : true;
    }

    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    public final boolean m3882(C5286 c5286) {
        if (this.f5604) {
            return this.f5597;
        }
        Pair pairM5109 = AbstractC1879.m5109(c5286);
        return pairM5109 != null && ((Integer) pairM5109.first).intValue() == 42;
    }
}
