Rabbit-R1/android (non root)/java/sources/com/google/android/exoplayer2/mediacodec/MediaCodecUtil.java
2024-05-21 17:08:36 -04:00

1469 lines
52 KiB
Java

package com.google.android.exoplayer2.mediacodec;
import android.media.MediaCodecInfo;
import android.media.MediaCodecList;
import android.text.TextUtils;
import android.util.Pair;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.exifinterface.media.ExifInterface;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.mediacodec.MediaCodecUtil;
import com.google.android.exoplayer2.util.Log;
import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.exoplayer2.util.Util;
import com.google.android.exoplayer2.video.ColorInfo;
import com.google.common.base.Ascii;
import com.google.common.collect.ImmutableList;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import kotlinx.coroutines.internal.LockFreeTaskQueueCore;
import org.checkerframework.checker.nullness.qual.EnsuresNonNull;
import tech.rabbit.r1systemupdater.model.UpdateEngineErrorCodes;
/* loaded from: classes2.dex */
public final class MediaCodecUtil {
private static final String CODEC_ID_AV01 = "av01";
private static final String CODEC_ID_AVC1 = "avc1";
private static final String CODEC_ID_AVC2 = "avc2";
private static final String CODEC_ID_HEV1 = "hev1";
private static final String CODEC_ID_HVC1 = "hvc1";
private static final String CODEC_ID_MP4A = "mp4a";
private static final String CODEC_ID_VP09 = "vp09";
private static final String TAG = "MediaCodecUtil";
private static final Pattern PROFILE_PATTERN = Pattern.compile("^\\D?(\\d+)$");
private static final HashMap<CodecKey, List<MediaCodecInfo>> decoderInfosCache = new HashMap<>();
private static int maxH264DecodableFrameSize = -1;
/* JADX INFO: Access modifiers changed from: private */
/* loaded from: classes2.dex */
public interface MediaCodecListCompat {
int getCodecCount();
android.media.MediaCodecInfo getCodecInfoAt(int i);
boolean isFeatureRequired(String str, String str2, MediaCodecInfo.CodecCapabilities codecCapabilities);
boolean isFeatureSupported(String str, String str2, MediaCodecInfo.CodecCapabilities codecCapabilities);
boolean secureDecodersExplicit();
}
/* JADX INFO: Access modifiers changed from: private */
/* loaded from: classes2.dex */
public interface ScoreProvider<T> {
int getScore(T t);
}
private static int av1LevelNumberToConst(int i) {
switch (i) {
case 0:
return 1;
case 1:
return 2;
case 2:
return 4;
case 3:
return 8;
case 4:
return 16;
case 5:
return 32;
case 6:
return 64;
case 7:
return 128;
case 8:
return 256;
case 9:
return 512;
case 10:
return 1024;
case 11:
return 2048;
case 12:
return 4096;
case 13:
return 8192;
case 14:
return 16384;
case 15:
return 32768;
case 16:
return 65536;
case 17:
return 131072;
case 18:
return 262144;
case 19:
return 524288;
case 20:
return 1048576;
case 21:
return 2097152;
case 22:
return 4194304;
case 23:
return 8388608;
default:
return -1;
}
}
private static int avcLevelNumberToConst(int i) {
switch (i) {
case 10:
return 1;
case 11:
return 4;
case 12:
return 8;
case 13:
return 16;
default:
switch (i) {
case 20:
return 32;
case 21:
return 64;
case 22:
return 128;
default:
switch (i) {
case 30:
return 256;
case 31:
return 512;
case 32:
return 1024;
default:
switch (i) {
case 40:
return 2048;
case 41:
return 4096;
case 42:
return 8192;
default:
switch (i) {
case 50:
return 16384;
case ConstraintLayout.LayoutParams.Table.LAYOUT_CONSTRAINT_TAG /* 51 */:
return 32768;
case UpdateEngineErrorCodes.UPDATED_BUT_NOT_ACTIVE /* 52 */:
return 65536;
default:
return -1;
}
}
}
}
}
}
private static int avcLevelToMaxFrameSize(int i) {
if (i == 1 || i == 2) {
return 25344;
}
switch (i) {
case 8:
case 16:
case 32:
return 101376;
case 64:
return 202752;
case 128:
case 256:
return 414720;
case 512:
return 921600;
case 1024:
return 1310720;
case 2048:
case 4096:
return 2097152;
case 8192:
return 2228224;
case 16384:
return 5652480;
case 32768:
case 65536:
return 9437184;
case 131072:
case 262144:
case 524288:
return 35651584;
default:
return -1;
}
}
private static int avcProfileNumberToConst(int i) {
if (i == 66) {
return 1;
}
if (i == 77) {
return 2;
}
if (i == 88) {
return 4;
}
if (i == 100) {
return 8;
}
if (i == 110) {
return 16;
}
if (i != 122) {
return i != 244 ? -1 : 64;
}
return 32;
}
private static int mp4aAudioObjectTypeToProfile(int i) {
int i2 = 17;
if (i != 17) {
i2 = 20;
if (i != 20) {
i2 = 23;
if (i != 23) {
i2 = 29;
if (i != 29) {
i2 = 39;
if (i != 39) {
i2 = 42;
if (i != 42) {
switch (i) {
case 1:
return 1;
case 2:
return 2;
case 3:
return 3;
case 4:
return 4;
case 5:
return 5;
case 6:
return 6;
default:
return -1;
}
}
}
}
}
}
}
return i2;
}
private static int vp9LevelNumberToConst(int i) {
if (i == 10) {
return 1;
}
if (i == 11) {
return 2;
}
if (i == 20) {
return 4;
}
if (i == 21) {
return 8;
}
if (i == 30) {
return 16;
}
if (i == 31) {
return 32;
}
if (i == 40) {
return 64;
}
if (i == 41) {
return 128;
}
if (i == 50) {
return 256;
}
if (i == 51) {
return 512;
}
switch (i) {
case LockFreeTaskQueueCore.FROZEN_SHIFT /* 60 */:
return 2048;
case LockFreeTaskQueueCore.CLOSED_SHIFT /* 61 */:
return 4096;
case 62:
return 8192;
default:
return -1;
}
}
private static int vp9ProfileNumberToConst(int i) {
if (i == 0) {
return 1;
}
if (i == 1) {
return 2;
}
if (i != 2) {
return i != 3 ? -1 : 8;
}
return 4;
}
/* loaded from: classes2.dex */
public static class DecoderQueryException extends Exception {
private DecoderQueryException(Throwable th) {
super("Failed to query underlying media codecs", th);
}
}
private MediaCodecUtil() {
}
public static void warmDecoderInfoCache(String str, boolean z, boolean z2) {
try {
getDecoderInfos(str, z, z2);
} catch (DecoderQueryException e) {
Log.e(TAG, "Codec warming failed", e);
}
}
public static synchronized void clearDecoderInfoCache() {
synchronized (MediaCodecUtil.class) {
decoderInfosCache.clear();
}
}
public static MediaCodecInfo getDecryptOnlyDecoderInfo() throws DecoderQueryException {
return getDecoderInfo("audio/raw", false, false);
}
public static MediaCodecInfo getDecoderInfo(String str, boolean z, boolean z2) throws DecoderQueryException {
List<MediaCodecInfo> decoderInfos = getDecoderInfos(str, z, z2);
if (decoderInfos.isEmpty()) {
return null;
}
return decoderInfos.get(0);
}
public static synchronized List<MediaCodecInfo> getDecoderInfos(String str, boolean z, boolean z2) throws DecoderQueryException {
MediaCodecListCompat mediaCodecListCompatV16;
synchronized (MediaCodecUtil.class) {
CodecKey codecKey = new CodecKey(str, z, z2);
HashMap<CodecKey, List<MediaCodecInfo>> hashMap = decoderInfosCache;
List<MediaCodecInfo> list = hashMap.get(codecKey);
if (list != null) {
return list;
}
if (Util.SDK_INT >= 21) {
mediaCodecListCompatV16 = new MediaCodecListCompatV21(z, z2);
} else {
mediaCodecListCompatV16 = new MediaCodecListCompatV16();
}
ArrayList<MediaCodecInfo> decoderInfosInternal = getDecoderInfosInternal(codecKey, mediaCodecListCompatV16);
if (z && decoderInfosInternal.isEmpty() && 21 <= Util.SDK_INT && Util.SDK_INT <= 23) {
decoderInfosInternal = getDecoderInfosInternal(codecKey, new MediaCodecListCompatV16());
if (!decoderInfosInternal.isEmpty()) {
Log.w(TAG, "MediaCodecList API didn't list secure decoder for: " + str + ". Assuming: " + decoderInfosInternal.get(0).name);
}
}
applyWorkarounds(str, decoderInfosInternal);
ImmutableList copyOf = ImmutableList.copyOf((Collection) decoderInfosInternal);
hashMap.put(codecKey, copyOf);
return copyOf;
}
}
public static List<MediaCodecInfo> getDecoderInfosSortedByFormatSupport(List<MediaCodecInfo> list, final Format format) {
ArrayList arrayList = new ArrayList(list);
sortByScore(arrayList, new ScoreProvider() { // from class: com.google.android.exoplayer2.mediacodec.MediaCodecUtil$$ExternalSyntheticLambda3
@Override // com.google.android.exoplayer2.mediacodec.MediaCodecUtil.ScoreProvider
public final int getScore(Object obj) {
return MediaCodecUtil.lambda$getDecoderInfosSortedByFormatSupport$0(Format.this, (MediaCodecInfo) obj);
}
});
return arrayList;
}
/* JADX INFO: Access modifiers changed from: package-private */
public static /* synthetic */ int lambda$getDecoderInfosSortedByFormatSupport$0(Format format, MediaCodecInfo mediaCodecInfo) {
return mediaCodecInfo.isFormatFunctionallySupported(format) ? 1 : 0;
}
public static int maxH264DecodableFrameSize() throws DecoderQueryException {
if (maxH264DecodableFrameSize == -1) {
int i = 0;
MediaCodecInfo decoderInfo = getDecoderInfo("video/avc", false, false);
if (decoderInfo != null) {
MediaCodecInfo.CodecProfileLevel[] profileLevels = decoderInfo.getProfileLevels();
int length = profileLevels.length;
int i2 = 0;
while (i < length) {
i2 = Math.max(avcLevelToMaxFrameSize(profileLevels[i].level), i2);
i++;
}
i = Math.max(i2, Util.SDK_INT >= 21 ? 345600 : 172800);
}
maxH264DecodableFrameSize = i;
}
return maxH264DecodableFrameSize;
}
/* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
/* JADX WARN: Code restructure failed: missing block: B:43:0x0077, code lost:
if (r3.equals(com.google.android.exoplayer2.mediacodec.MediaCodecUtil.CODEC_ID_AV01) == false) goto L11;
*/
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public static android.util.Pair<java.lang.Integer, java.lang.Integer> getCodecProfileAndLevel(com.google.android.exoplayer2.Format r6) {
/*
java.lang.String r0 = r6.codecs
r1 = 0
if (r0 != 0) goto L6
return r1
L6:
java.lang.String r0 = r6.codecs
java.lang.String r2 = "\\."
java.lang.String[] r0 = r0.split(r2)
java.lang.String r2 = "video/dolby-vision"
java.lang.String r3 = r6.sampleMimeType
boolean r2 = r2.equals(r3)
if (r2 == 0) goto L1f
java.lang.String r6 = r6.codecs
android.util.Pair r6 = getDolbyVisionProfileAndLevel(r6, r0)
return r6
L1f:
r2 = 0
r3 = r0[r2]
r3.hashCode()
int r4 = r3.hashCode()
r5 = -1
switch(r4) {
case 3004662: goto L71;
case 3006243: goto L66;
case 3006244: goto L5b;
case 3199032: goto L50;
case 3214780: goto L45;
case 3356560: goto L3a;
case 3624515: goto L2f;
default: goto L2d;
}
L2d:
r2 = r5
goto L7a
L2f:
java.lang.String r2 = "vp09"
boolean r2 = r3.equals(r2)
if (r2 != 0) goto L38
goto L2d
L38:
r2 = 6
goto L7a
L3a:
java.lang.String r2 = "mp4a"
boolean r2 = r3.equals(r2)
if (r2 != 0) goto L43
goto L2d
L43:
r2 = 5
goto L7a
L45:
java.lang.String r2 = "hvc1"
boolean r2 = r3.equals(r2)
if (r2 != 0) goto L4e
goto L2d
L4e:
r2 = 4
goto L7a
L50:
java.lang.String r2 = "hev1"
boolean r2 = r3.equals(r2)
if (r2 != 0) goto L59
goto L2d
L59:
r2 = 3
goto L7a
L5b:
java.lang.String r2 = "avc2"
boolean r2 = r3.equals(r2)
if (r2 != 0) goto L64
goto L2d
L64:
r2 = 2
goto L7a
L66:
java.lang.String r2 = "avc1"
boolean r2 = r3.equals(r2)
if (r2 != 0) goto L6f
goto L2d
L6f:
r2 = 1
goto L7a
L71:
java.lang.String r4 = "av01"
boolean r3 = r3.equals(r4)
if (r3 != 0) goto L7a
goto L2d
L7a:
switch(r2) {
case 0: goto L9c;
case 1: goto L95;
case 2: goto L95;
case 3: goto L8c;
case 4: goto L8c;
case 5: goto L85;
case 6: goto L7e;
default: goto L7d;
}
L7d:
return r1
L7e:
java.lang.String r6 = r6.codecs
android.util.Pair r6 = getVp9ProfileAndLevel(r6, r0)
return r6
L85:
java.lang.String r6 = r6.codecs
android.util.Pair r6 = getAacCodecProfileAndLevel(r6, r0)
return r6
L8c:
java.lang.String r1 = r6.codecs
com.google.android.exoplayer2.video.ColorInfo r6 = r6.colorInfo
android.util.Pair r6 = getHevcProfileAndLevel(r1, r0, r6)
return r6
L95:
java.lang.String r6 = r6.codecs
android.util.Pair r6 = getAvcProfileAndLevel(r6, r0)
return r6
L9c:
java.lang.String r1 = r6.codecs
com.google.android.exoplayer2.video.ColorInfo r6 = r6.colorInfo
android.util.Pair r6 = getAv1ProfileAndLevel(r1, r0, r6)
return r6
*/
throw new UnsupportedOperationException("Method not decompiled: com.google.android.exoplayer2.mediacodec.MediaCodecUtil.getCodecProfileAndLevel(com.google.android.exoplayer2.Format):android.util.Pair");
}
public static String getAlternativeCodecMimeType(Format format) {
Pair<Integer, Integer> codecProfileAndLevel;
if ("audio/eac3-joc".equals(format.sampleMimeType)) {
return "audio/eac3";
}
if (!"video/dolby-vision".equals(format.sampleMimeType) || (codecProfileAndLevel = getCodecProfileAndLevel(format)) == null) {
return null;
}
int intValue = ((Integer) codecProfileAndLevel.first).intValue();
if (intValue == 16 || intValue == 256) {
return "video/hevc";
}
if (intValue == 512) {
return "video/avc";
}
return null;
}
/* JADX WARN: Can't wrap try/catch for region: R(7:30|(4:(2:75|76)|55|(9:58|59|60|61|62|63|64|66|67)|9)|34|35|36|37|9) */
/* JADX WARN: Code restructure failed: missing block: B:38:0x00a8, code lost:
r0 = e;
*/
/* JADX WARN: Code restructure failed: missing block: B:77:0x0083, code lost:
if (r1.secure == false) goto L35;
*/
/* JADX WARN: Removed duplicated region for block: B:44:0x0108 A[Catch: Exception -> 0x015e, TRY_ENTER, TryCatch #0 {Exception -> 0x015e, blocks: (B:3:0x0008, B:5:0x001b, B:9:0x012a, B:10:0x002d, B:13:0x0038, B:41:0x0100, B:44:0x0108, B:46:0x010e, B:49:0x0134, B:50:0x015c), top: B:2:0x0008 }] */
/* JADX WARN: Removed duplicated region for block: B:53:0x0134 A[ADDED_TO_REGION, SYNTHETIC] */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
private static java.util.ArrayList<com.google.android.exoplayer2.mediacodec.MediaCodecInfo> getDecoderInfosInternal(com.google.android.exoplayer2.mediacodec.MediaCodecUtil.CodecKey r24, com.google.android.exoplayer2.mediacodec.MediaCodecUtil.MediaCodecListCompat r25) throws com.google.android.exoplayer2.mediacodec.MediaCodecUtil.DecoderQueryException {
/*
Method dump skipped, instructions count: 358
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: com.google.android.exoplayer2.mediacodec.MediaCodecUtil.getDecoderInfosInternal(com.google.android.exoplayer2.mediacodec.MediaCodecUtil$CodecKey, com.google.android.exoplayer2.mediacodec.MediaCodecUtil$MediaCodecListCompat):java.util.ArrayList");
}
private static String getCodecMimeType(android.media.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";
}
if (str2.equals("audio/ac3") && "OMX.lge.ac3.decoder".equals(str)) {
return "audio/lg-ac3";
}
return null;
}
private static boolean isCodecUsableDecoder(android.media.MediaCodecInfo mediaCodecInfo, String str, boolean z, String str2) {
if (mediaCodecInfo.isEncoder() || (!z && str.endsWith(".secure"))) {
return false;
}
if (Util.SDK_INT < 21 && ("CIPAACDecoder".equals(str) || "CIPMP3Decoder".equals(str) || "CIPVorbisDecoder".equals(str) || "CIPAMRNBDecoder".equals(str) || "AACDecoder".equals(str) || "MP3Decoder".equals(str))) {
return false;
}
if (Util.SDK_INT < 18 && "OMX.MTK.AUDIO.DECODER.AAC".equals(str) && ("a70".equals(Util.DEVICE) || ("Xiaomi".equals(Util.MANUFACTURER) && Util.DEVICE.startsWith("HM")))) {
return false;
}
if (Util.SDK_INT == 16 && "OMX.qcom.audio.decoder.mp3".equals(str) && ("dlxu".equals(Util.DEVICE) || "protou".equals(Util.DEVICE) || "ville".equals(Util.DEVICE) || "villeplus".equals(Util.DEVICE) || "villec2".equals(Util.DEVICE) || Util.DEVICE.startsWith("gee") || "C6602".equals(Util.DEVICE) || "C6603".equals(Util.DEVICE) || "C6606".equals(Util.DEVICE) || "C6616".equals(Util.DEVICE) || "L36h".equals(Util.DEVICE) || "SO-02E".equals(Util.DEVICE))) {
return false;
}
if (Util.SDK_INT == 16 && "OMX.qcom.audio.decoder.aac".equals(str) && ("C1504".equals(Util.DEVICE) || "C1505".equals(Util.DEVICE) || "C1604".equals(Util.DEVICE) || "C1605".equals(Util.DEVICE))) {
return false;
}
if (Util.SDK_INT < 24 && (("OMX.SEC.aac.dec".equals(str) || "OMX.Exynos.AAC.Decoder".equals(str)) && "samsung".equals(Util.MANUFACTURER) && (Util.DEVICE.startsWith("zeroflte") || Util.DEVICE.startsWith("zerolte") || Util.DEVICE.startsWith("zenlte") || "SC-05G".equals(Util.DEVICE) || "marinelteatt".equals(Util.DEVICE) || "404SC".equals(Util.DEVICE) || "SC-04G".equals(Util.DEVICE) || "SCV31".equals(Util.DEVICE)))) {
return false;
}
if (Util.SDK_INT <= 19 && "OMX.SEC.vp8.dec".equals(str) && "samsung".equals(Util.MANUFACTURER) && (Util.DEVICE.startsWith("d2") || Util.DEVICE.startsWith("serrano") || Util.DEVICE.startsWith("jflte") || Util.DEVICE.startsWith("santos") || Util.DEVICE.startsWith("t0"))) {
return false;
}
if (Util.SDK_INT <= 19 && Util.DEVICE.startsWith("jflte") && "OMX.qcom.video.decoder.vp8".equals(str)) {
return false;
}
return (Util.SDK_INT <= 23 && "audio/eac3-joc".equals(str2) && "OMX.MTK.AUDIO.DECODER.DSPAC3".equals(str)) ? false : true;
}
private static void applyWorkarounds(String str, List<MediaCodecInfo> list) {
if ("audio/raw".equals(str)) {
if (Util.SDK_INT < 26 && Util.DEVICE.equals("R9") && list.size() == 1 && list.get(0).name.equals("OMX.MTK.AUDIO.DECODER.RAW")) {
list.add(MediaCodecInfo.newInstance("OMX.google.raw.decoder", "audio/raw", "audio/raw", null, false, true, false, false, false));
}
sortByScore(list, new ScoreProvider() { // from class: com.google.android.exoplayer2.mediacodec.MediaCodecUtil$$ExternalSyntheticLambda1
@Override // com.google.android.exoplayer2.mediacodec.MediaCodecUtil.ScoreProvider
public final int getScore(Object obj) {
return MediaCodecUtil.lambda$applyWorkarounds$1((MediaCodecInfo) obj);
}
});
}
if (Util.SDK_INT < 21 && list.size() > 1) {
String str2 = list.get(0).name;
if ("OMX.SEC.mp3.dec".equals(str2) || "OMX.SEC.MP3.Decoder".equals(str2) || "OMX.brcm.audio.mp3.decoder".equals(str2)) {
sortByScore(list, new ScoreProvider() { // from class: com.google.android.exoplayer2.mediacodec.MediaCodecUtil$$ExternalSyntheticLambda2
@Override // com.google.android.exoplayer2.mediacodec.MediaCodecUtil.ScoreProvider
public final int getScore(Object obj) {
return MediaCodecUtil.lambda$applyWorkarounds$2((MediaCodecInfo) obj);
}
});
}
}
if (Util.SDK_INT >= 32 || list.size() <= 1 || !"OMX.qti.audio.decoder.flac".equals(list.get(0).name)) {
return;
}
list.add(list.remove(0));
}
/* JADX INFO: Access modifiers changed from: package-private */
public static /* synthetic */ int lambda$applyWorkarounds$1(MediaCodecInfo mediaCodecInfo) {
String str = mediaCodecInfo.name;
if (str.startsWith("OMX.google") || str.startsWith("c2.android")) {
return 1;
}
return (Util.SDK_INT >= 26 || !str.equals("OMX.MTK.AUDIO.DECODER.RAW")) ? 0 : -1;
}
/* JADX INFO: Access modifiers changed from: package-private */
public static /* synthetic */ int lambda$applyWorkarounds$2(MediaCodecInfo mediaCodecInfo) {
return mediaCodecInfo.name.startsWith("OMX.google") ? 1 : 0;
}
private static boolean isAlias(android.media.MediaCodecInfo mediaCodecInfo) {
return Util.SDK_INT >= 29 && isAliasV29(mediaCodecInfo);
}
private static boolean isAliasV29(android.media.MediaCodecInfo mediaCodecInfo) {
return mediaCodecInfo.isAlias();
}
private static boolean isHardwareAccelerated(android.media.MediaCodecInfo mediaCodecInfo, String str) {
if (Util.SDK_INT >= 29) {
return isHardwareAcceleratedV29(mediaCodecInfo);
}
return !isSoftwareOnly(mediaCodecInfo, str);
}
private static boolean isHardwareAcceleratedV29(android.media.MediaCodecInfo mediaCodecInfo) {
return mediaCodecInfo.isHardwareAccelerated();
}
private static boolean isSoftwareOnly(android.media.MediaCodecInfo mediaCodecInfo, String str) {
if (Util.SDK_INT >= 29) {
return isSoftwareOnlyV29(mediaCodecInfo);
}
if (MimeTypes.isAudio(str)) {
return true;
}
String lowerCase = Ascii.toLowerCase(mediaCodecInfo.getName());
if (lowerCase.startsWith("arc.")) {
return false;
}
if (lowerCase.startsWith("omx.google.") || lowerCase.startsWith("omx.ffmpeg.")) {
return true;
}
if ((lowerCase.startsWith("omx.sec.") && lowerCase.contains(".sw.")) || lowerCase.equals("omx.qcom.video.decoder.hevcswvdec") || lowerCase.startsWith("c2.android.") || lowerCase.startsWith("c2.google.")) {
return true;
}
return (lowerCase.startsWith("omx.") || lowerCase.startsWith("c2.")) ? false : true;
}
private static boolean isSoftwareOnlyV29(android.media.MediaCodecInfo mediaCodecInfo) {
return mediaCodecInfo.isSoftwareOnly();
}
private static boolean isVendor(android.media.MediaCodecInfo mediaCodecInfo) {
if (Util.SDK_INT >= 29) {
return isVendorV29(mediaCodecInfo);
}
String lowerCase = Ascii.toLowerCase(mediaCodecInfo.getName());
return (lowerCase.startsWith("omx.google.") || lowerCase.startsWith("c2.android.") || lowerCase.startsWith("c2.google.")) ? false : true;
}
private static boolean isVendorV29(android.media.MediaCodecInfo mediaCodecInfo) {
return mediaCodecInfo.isVendor();
}
private static Pair<Integer, Integer> getDolbyVisionProfileAndLevel(String str, String[] strArr) {
if (strArr.length < 3) {
Log.w(TAG, "Ignoring malformed Dolby Vision codec string: " + str);
return null;
}
Matcher matcher = PROFILE_PATTERN.matcher(strArr[1]);
if (!matcher.matches()) {
Log.w(TAG, "Ignoring malformed Dolby Vision codec string: " + str);
return null;
}
String group = matcher.group(1);
Integer dolbyVisionStringToProfile = dolbyVisionStringToProfile(group);
if (dolbyVisionStringToProfile == null) {
Log.w(TAG, "Unknown Dolby Vision profile string: " + group);
return null;
}
String str2 = strArr[2];
Integer dolbyVisionStringToLevel = dolbyVisionStringToLevel(str2);
if (dolbyVisionStringToLevel == null) {
Log.w(TAG, "Unknown Dolby Vision level string: " + str2);
return null;
}
return new Pair<>(dolbyVisionStringToProfile, dolbyVisionStringToLevel);
}
private static Pair<Integer, Integer> getHevcProfileAndLevel(String str, String[] strArr, ColorInfo colorInfo) {
if (strArr.length < 4) {
Log.w(TAG, "Ignoring malformed HEVC codec string: " + str);
return null;
}
int i = 1;
Matcher matcher = PROFILE_PATTERN.matcher(strArr[1]);
if (!matcher.matches()) {
Log.w(TAG, "Ignoring malformed HEVC codec string: " + str);
return null;
}
String group = matcher.group(1);
if (!"1".equals(group)) {
if (ExifInterface.GPS_MEASUREMENT_2D.equals(group)) {
i = (colorInfo == null || colorInfo.colorTransfer != 6) ? 2 : 4096;
} else {
Log.w(TAG, "Unknown HEVC profile string: " + group);
return null;
}
}
String str2 = strArr[3];
Integer hevcCodecStringToProfileLevel = hevcCodecStringToProfileLevel(str2);
if (hevcCodecStringToProfileLevel == null) {
Log.w(TAG, "Unknown HEVC level string: " + str2);
return null;
}
return new Pair<>(Integer.valueOf(i), hevcCodecStringToProfileLevel);
}
private static Pair<Integer, Integer> getAvcProfileAndLevel(String str, String[] strArr) {
int parseInt;
int i;
if (strArr.length < 2) {
Log.w(TAG, "Ignoring malformed AVC codec string: " + str);
return null;
}
try {
if (strArr[1].length() == 6) {
i = Integer.parseInt(strArr[1].substring(0, 2), 16);
parseInt = Integer.parseInt(strArr[1].substring(4), 16);
} else if (strArr.length >= 3) {
int parseInt2 = Integer.parseInt(strArr[1]);
parseInt = Integer.parseInt(strArr[2]);
i = parseInt2;
} else {
Log.w(TAG, "Ignoring malformed AVC codec string: " + str);
return null;
}
int avcProfileNumberToConst = avcProfileNumberToConst(i);
if (avcProfileNumberToConst == -1) {
Log.w(TAG, "Unknown AVC profile: " + i);
return null;
}
int avcLevelNumberToConst = avcLevelNumberToConst(parseInt);
if (avcLevelNumberToConst == -1) {
Log.w(TAG, "Unknown AVC level: " + parseInt);
return null;
}
return new Pair<>(Integer.valueOf(avcProfileNumberToConst), Integer.valueOf(avcLevelNumberToConst));
} catch (NumberFormatException unused) {
Log.w(TAG, "Ignoring malformed AVC codec string: " + str);
return null;
}
}
private static Pair<Integer, Integer> getVp9ProfileAndLevel(String str, String[] strArr) {
if (strArr.length < 3) {
Log.w(TAG, "Ignoring malformed VP9 codec string: " + str);
return null;
}
try {
int parseInt = Integer.parseInt(strArr[1]);
int parseInt2 = Integer.parseInt(strArr[2]);
int vp9ProfileNumberToConst = vp9ProfileNumberToConst(parseInt);
if (vp9ProfileNumberToConst == -1) {
Log.w(TAG, "Unknown VP9 profile: " + parseInt);
return null;
}
int vp9LevelNumberToConst = vp9LevelNumberToConst(parseInt2);
if (vp9LevelNumberToConst == -1) {
Log.w(TAG, "Unknown VP9 level: " + parseInt2);
return null;
}
return new Pair<>(Integer.valueOf(vp9ProfileNumberToConst), Integer.valueOf(vp9LevelNumberToConst));
} catch (NumberFormatException unused) {
Log.w(TAG, "Ignoring malformed VP9 codec string: " + str);
return null;
}
}
private static Pair<Integer, Integer> getAv1ProfileAndLevel(String str, String[] strArr, ColorInfo colorInfo) {
if (strArr.length < 4) {
Log.w(TAG, "Ignoring malformed AV1 codec string: " + str);
return null;
}
int i = 1;
try {
int parseInt = Integer.parseInt(strArr[1]);
int parseInt2 = Integer.parseInt(strArr[2].substring(0, 2));
int parseInt3 = Integer.parseInt(strArr[3]);
if (parseInt != 0) {
Log.w(TAG, "Unknown AV1 profile: " + parseInt);
return null;
}
if (parseInt3 != 8 && parseInt3 != 10) {
Log.w(TAG, "Unknown AV1 bit depth: " + parseInt3);
return null;
}
if (parseInt3 != 8) {
i = (colorInfo == null || !(colorInfo.hdrStaticInfo != null || colorInfo.colorTransfer == 7 || colorInfo.colorTransfer == 6)) ? 2 : 4096;
}
int av1LevelNumberToConst = av1LevelNumberToConst(parseInt2);
if (av1LevelNumberToConst == -1) {
Log.w(TAG, "Unknown AV1 level: " + parseInt2);
return null;
}
return new Pair<>(Integer.valueOf(i), Integer.valueOf(av1LevelNumberToConst));
} catch (NumberFormatException unused) {
Log.w(TAG, "Ignoring malformed AV1 codec string: " + str);
return null;
}
}
private static Pair<Integer, Integer> getAacCodecProfileAndLevel(String str, String[] strArr) {
int mp4aAudioObjectTypeToProfile;
if (strArr.length != 3) {
Log.w(TAG, "Ignoring malformed MP4A codec string: " + str);
return null;
}
try {
if ("audio/mp4a-latm".equals(MimeTypes.getMimeTypeFromMp4ObjectType(Integer.parseInt(strArr[1], 16))) && (mp4aAudioObjectTypeToProfile = mp4aAudioObjectTypeToProfile(Integer.parseInt(strArr[2]))) != -1) {
return new Pair<>(Integer.valueOf(mp4aAudioObjectTypeToProfile), 0);
}
} catch (NumberFormatException unused) {
Log.w(TAG, "Ignoring malformed MP4A codec string: " + str);
}
return null;
}
/* JADX INFO: Access modifiers changed from: package-private */
public static /* synthetic */ int lambda$sortByScore$3(ScoreProvider scoreProvider, Object obj, Object obj2) {
return scoreProvider.getScore(obj2) - scoreProvider.getScore(obj);
}
private static <T> void sortByScore(List<T> list, final ScoreProvider<T> scoreProvider) {
Collections.sort(list, new Comparator() { // from class: com.google.android.exoplayer2.mediacodec.MediaCodecUtil$$ExternalSyntheticLambda0
@Override // java.util.Comparator
public final int compare(Object obj, Object obj2) {
return MediaCodecUtil.lambda$sortByScore$3(MediaCodecUtil.ScoreProvider.this, obj, obj2);
}
});
}
/* JADX INFO: Access modifiers changed from: private */
/* loaded from: classes2.dex */
public static final class MediaCodecListCompatV21 implements MediaCodecListCompat {
private final int codecKind;
private android.media.MediaCodecInfo[] mediaCodecInfos;
@Override // com.google.android.exoplayer2.mediacodec.MediaCodecUtil.MediaCodecListCompat
public boolean secureDecodersExplicit() {
return true;
}
public MediaCodecListCompatV21(boolean z, boolean z2) {
this.codecKind = (z || z2) ? 1 : 0;
}
@Override // com.google.android.exoplayer2.mediacodec.MediaCodecUtil.MediaCodecListCompat
public int getCodecCount() {
ensureMediaCodecInfosInitialized();
return this.mediaCodecInfos.length;
}
@Override // com.google.android.exoplayer2.mediacodec.MediaCodecUtil.MediaCodecListCompat
public android.media.MediaCodecInfo getCodecInfoAt(int i) {
ensureMediaCodecInfosInitialized();
return this.mediaCodecInfos[i];
}
@Override // com.google.android.exoplayer2.mediacodec.MediaCodecUtil.MediaCodecListCompat
public boolean isFeatureSupported(String str, String str2, MediaCodecInfo.CodecCapabilities codecCapabilities) {
return codecCapabilities.isFeatureSupported(str);
}
@Override // com.google.android.exoplayer2.mediacodec.MediaCodecUtil.MediaCodecListCompat
public boolean isFeatureRequired(String str, String str2, MediaCodecInfo.CodecCapabilities codecCapabilities) {
return codecCapabilities.isFeatureRequired(str);
}
@EnsuresNonNull({"mediaCodecInfos"})
private void ensureMediaCodecInfosInitialized() {
if (this.mediaCodecInfos == null) {
this.mediaCodecInfos = new MediaCodecList(this.codecKind).getCodecInfos();
}
}
}
/* JADX INFO: Access modifiers changed from: private */
/* loaded from: classes2.dex */
public static final class MediaCodecListCompatV16 implements MediaCodecListCompat {
@Override // com.google.android.exoplayer2.mediacodec.MediaCodecUtil.MediaCodecListCompat
public boolean isFeatureRequired(String str, String str2, MediaCodecInfo.CodecCapabilities codecCapabilities) {
return false;
}
@Override // com.google.android.exoplayer2.mediacodec.MediaCodecUtil.MediaCodecListCompat
public boolean secureDecodersExplicit() {
return false;
}
private MediaCodecListCompatV16() {
}
@Override // com.google.android.exoplayer2.mediacodec.MediaCodecUtil.MediaCodecListCompat
public int getCodecCount() {
return MediaCodecList.getCodecCount();
}
@Override // com.google.android.exoplayer2.mediacodec.MediaCodecUtil.MediaCodecListCompat
public android.media.MediaCodecInfo getCodecInfoAt(int i) {
return MediaCodecList.getCodecInfoAt(i);
}
@Override // com.google.android.exoplayer2.mediacodec.MediaCodecUtil.MediaCodecListCompat
public boolean isFeatureSupported(String str, String str2, MediaCodecInfo.CodecCapabilities codecCapabilities) {
return "secure-playback".equals(str) && "video/avc".equals(str2);
}
}
/* JADX INFO: Access modifiers changed from: private */
/* loaded from: classes2.dex */
public static final class CodecKey {
public final String mimeType;
public final boolean secure;
public final boolean tunneling;
public CodecKey(String str, boolean z, boolean z2) {
this.mimeType = str;
this.secure = z;
this.tunneling = z2;
}
public int hashCode() {
return ((((this.mimeType.hashCode() + 31) * 31) + (this.secure ? 1231 : 1237)) * 31) + (this.tunneling ? 1231 : 1237);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || obj.getClass() != CodecKey.class) {
return false;
}
CodecKey codecKey = (CodecKey) obj;
return TextUtils.equals(this.mimeType, codecKey.mimeType) && this.secure == codecKey.secure && this.tunneling == codecKey.tunneling;
}
}
private static Integer hevcCodecStringToProfileLevel(String str) {
if (str == null) {
return null;
}
str.hashCode();
char c = 65535;
switch (str.hashCode()) {
case 70821:
if (str.equals("H30")) {
c = 0;
break;
}
break;
case 70914:
if (str.equals("H60")) {
c = 1;
break;
}
break;
case 70917:
if (str.equals("H63")) {
c = 2;
break;
}
break;
case 71007:
if (str.equals("H90")) {
c = 3;
break;
}
break;
case 71010:
if (str.equals("H93")) {
c = 4;
break;
}
break;
case 74665:
if (str.equals("L30")) {
c = 5;
break;
}
break;
case 74758:
if (str.equals("L60")) {
c = 6;
break;
}
break;
case 74761:
if (str.equals("L63")) {
c = 7;
break;
}
break;
case 74851:
if (str.equals("L90")) {
c = '\b';
break;
}
break;
case 74854:
if (str.equals("L93")) {
c = '\t';
break;
}
break;
case 2193639:
if (str.equals("H120")) {
c = '\n';
break;
}
break;
case 2193642:
if (str.equals("H123")) {
c = 11;
break;
}
break;
case 2193732:
if (str.equals("H150")) {
c = '\f';
break;
}
break;
case 2193735:
if (str.equals("H153")) {
c = '\r';
break;
}
break;
case 2193738:
if (str.equals("H156")) {
c = 14;
break;
}
break;
case 2193825:
if (str.equals("H180")) {
c = 15;
break;
}
break;
case 2193828:
if (str.equals("H183")) {
c = 16;
break;
}
break;
case 2193831:
if (str.equals("H186")) {
c = 17;
break;
}
break;
case 2312803:
if (str.equals("L120")) {
c = 18;
break;
}
break;
case 2312806:
if (str.equals("L123")) {
c = 19;
break;
}
break;
case 2312896:
if (str.equals("L150")) {
c = 20;
break;
}
break;
case 2312899:
if (str.equals("L153")) {
c = 21;
break;
}
break;
case 2312902:
if (str.equals("L156")) {
c = 22;
break;
}
break;
case 2312989:
if (str.equals("L180")) {
c = 23;
break;
}
break;
case 2312992:
if (str.equals("L183")) {
c = 24;
break;
}
break;
case 2312995:
if (str.equals("L186")) {
c = 25;
break;
}
break;
}
switch (c) {
case 0:
return 2;
case 1:
return 8;
case 2:
return 32;
case 3:
return 128;
case 4:
return 512;
case 5:
return 1;
case 6:
return 4;
case 7:
return 16;
case '\b':
return 64;
case '\t':
return 256;
case '\n':
return 2048;
case 11:
return 8192;
case '\f':
return 32768;
case '\r':
return 131072;
case 14:
return 524288;
case 15:
return 2097152;
case 16:
return 8388608;
case 17:
return 33554432;
case 18:
return 1024;
case 19:
return 4096;
case 20:
return 16384;
case 21:
return 65536;
case 22:
return 262144;
case 23:
return 1048576;
case 24:
return 4194304;
case 25:
return 16777216;
default:
return null;
}
}
private static Integer dolbyVisionStringToProfile(String str) {
if (str == null) {
return null;
}
str.hashCode();
char c = 65535;
switch (str.hashCode()) {
case 1536:
if (str.equals("00")) {
c = 0;
break;
}
break;
case 1537:
if (str.equals("01")) {
c = 1;
break;
}
break;
case 1538:
if (str.equals("02")) {
c = 2;
break;
}
break;
case 1539:
if (str.equals("03")) {
c = 3;
break;
}
break;
case 1540:
if (str.equals("04")) {
c = 4;
break;
}
break;
case 1541:
if (str.equals("05")) {
c = 5;
break;
}
break;
case 1542:
if (str.equals("06")) {
c = 6;
break;
}
break;
case 1543:
if (str.equals("07")) {
c = 7;
break;
}
break;
case 1544:
if (str.equals("08")) {
c = '\b';
break;
}
break;
case 1545:
if (str.equals("09")) {
c = '\t';
break;
}
break;
}
switch (c) {
case 0:
return 1;
case 1:
return 2;
case 2:
return 4;
case 3:
return 8;
case 4:
return 16;
case 5:
return 32;
case 6:
return 64;
case 7:
return 128;
case '\b':
return 256;
case '\t':
return 512;
default:
return null;
}
}
private static Integer dolbyVisionStringToLevel(String str) {
if (str == null) {
return null;
}
str.hashCode();
char c = 65535;
switch (str.hashCode()) {
case 1537:
if (str.equals("01")) {
c = 0;
break;
}
break;
case 1538:
if (str.equals("02")) {
c = 1;
break;
}
break;
case 1539:
if (str.equals("03")) {
c = 2;
break;
}
break;
case 1540:
if (str.equals("04")) {
c = 3;
break;
}
break;
case 1541:
if (str.equals("05")) {
c = 4;
break;
}
break;
case 1542:
if (str.equals("06")) {
c = 5;
break;
}
break;
case 1543:
if (str.equals("07")) {
c = 6;
break;
}
break;
case 1544:
if (str.equals("08")) {
c = 7;
break;
}
break;
case 1545:
if (str.equals("09")) {
c = '\b';
break;
}
break;
case 1567:
if (str.equals("10")) {
c = '\t';
break;
}
break;
case 1568:
if (str.equals("11")) {
c = '\n';
break;
}
break;
case 1569:
if (str.equals("12")) {
c = 11;
break;
}
break;
case 1570:
if (str.equals("13")) {
c = '\f';
break;
}
break;
}
switch (c) {
case 0:
return 1;
case 1:
return 2;
case 2:
return 4;
case 3:
return 8;
case 4:
return 16;
case 5:
return 32;
case 6:
return 64;
case 7:
return 128;
case '\b':
return 256;
case '\t':
return 512;
case '\n':
return 1024;
case 11:
return 2048;
case '\f':
return 4096;
default:
return null;
}
}
}