From 52f976179622c764794859195dbecd6bea4104a4 Mon Sep 17 00:00:00 2001 From: Googler Date: Wed, 11 Dec 2024 10:56:06 -0800 Subject: [PATCH] Don't check codec's profile for MV-HEVC video. Currently as there is no formal support for MV-HEVC within Android framework, the profile is not correctly specified by the underlying codec; just assume the profile obtained from the MV-HEVC sample is supported. PiperOrigin-RevId: 705164738 (cherry picked from commit 3936c27b6d0fd5e5795beab029c0216613e3f0ba) --- .../java/androidx/media3/common/MimeTypes.java | 3 +++ .../exoplayer/mediacodec/MediaCodecInfo.java | 17 ++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/libraries/common/src/main/java/androidx/media3/common/MimeTypes.java b/libraries/common/src/main/java/androidx/media3/common/MimeTypes.java index bd35e90d2cd..dace1c56f8c 100644 --- a/libraries/common/src/main/java/androidx/media3/common/MimeTypes.java +++ b/libraries/common/src/main/java/androidx/media3/common/MimeTypes.java @@ -685,6 +685,9 @@ public static String getMimeTypeFromMp4ObjectType(int objectType) { } mimeType = Ascii.toLowerCase(mimeType); switch (mimeType) { + // Normalize uncommon versions of some video MIME types to their standard equivalent. + case BASE_TYPE_VIDEO + "/x-mvhevc": + return VIDEO_MV_HEVC; // Normalize uncommon versions of some audio MIME types to their standard equivalent. case BASE_TYPE_AUDIO + "/x-flac": return AUDIO_FLAC; diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/mediacodec/MediaCodecInfo.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/mediacodec/MediaCodecInfo.java index d9826a3b975..2485793e556 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/mediacodec/MediaCodecInfo.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/mediacodec/MediaCodecInfo.java @@ -297,12 +297,19 @@ private boolean isSampleMimeTypeSupported(Format format) { private boolean isCodecProfileAndLevelSupported( Format format, boolean checkPerformanceCapabilities) { Pair codecProfileAndLevel = MediaCodecUtil.getCodecProfileAndLevel(format); - if (format.sampleMimeType != null - && format.sampleMimeType.equals(MimeTypes.VIDEO_MV_HEVC) - && codecMimeType.equals(MimeTypes.VIDEO_H265)) { - // Falling back to single-layer HEVC from MV-HEVC. Get base layer profile and level. - codecProfileAndLevel = MediaCodecUtil.getHevcBaseLayerCodecProfileAndLevel(format); + if (format.sampleMimeType != null && format.sampleMimeType.equals(MimeTypes.VIDEO_MV_HEVC)) { + String normalizedCodecMimeType = MimeTypes.normalizeMimeType(codecMimeType); + if (normalizedCodecMimeType.equals(MimeTypes.VIDEO_MV_HEVC)) { + // Currently as there is no formal support for MV-HEVC within Android framework, the profile + // is not correctly specified by the underlying codec; just assume the profile obtained from + // the MV-HEVC sample is supported. + return true; + } else if (normalizedCodecMimeType.equals(MimeTypes.VIDEO_H265)) { + // Falling back to single-layer HEVC from MV-HEVC. Get base layer profile and level. + codecProfileAndLevel = MediaCodecUtil.getHevcBaseLayerCodecProfileAndLevel(format); + } } + if (codecProfileAndLevel == null) { // If we don't know any better, we assume that the profile and level are supported. return true;