From 045048f6f54aafb0f801aa80df514027b04452b7 Mon Sep 17 00:00:00 2001 From: kimvde Date: Thu, 4 Feb 2021 09:16:43 +0000 Subject: [PATCH] Fall back to AVC/HEVC for Dolby Vision levels 10-13 Before, the level was set to null in this case. MediaCodecUtil.getCodecProfileAndLevel() was therefore returning null and the fallback to AVC/HEVC was not enabled in MediaCodecVideoRenderer. Issue:#8530 PiperOrigin-RevId: 355574499 --- .../android/exoplayer2/video/DolbyVisionConfig.java | 2 +- .../android/exoplayer2/mediacodec/MediaCodecUtil.java | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/library/common/src/main/java/com/google/android/exoplayer2/video/DolbyVisionConfig.java b/library/common/src/main/java/com/google/android/exoplayer2/video/DolbyVisionConfig.java index 3a13540e12f..9321330061e 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/video/DolbyVisionConfig.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/video/DolbyVisionConfig.java @@ -45,7 +45,7 @@ public static DolbyVisionConfig parse(ParsableByteArray data) { } else { return null; } - String codecs = codecsPrefix + ".0" + dvProfile + ".0" + dvLevel; + String codecs = codecsPrefix + ".0" + dvProfile + (dvLevel < 10 ? ".0" : ".") + dvLevel; return new DolbyVisionConfig(dvProfile, dvLevel, codecs); } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecUtil.java b/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecUtil.java index 20ca6db9dd6..bcaf8a07b15 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecUtil.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecUtil.java @@ -1272,6 +1272,7 @@ private static Integer dolbyVisionStringToLevel(@Nullable String levelString) { if (levelString == null) { return null; } + // TODO (Internal: b/179261323): use framework constants for levels 10 to 13. switch (levelString) { case "01": return CodecProfileLevel.DolbyVisionLevelHd24; @@ -1291,6 +1292,14 @@ private static Integer dolbyVisionStringToLevel(@Nullable String levelString) { return CodecProfileLevel.DolbyVisionLevelUhd48; case "09": return CodecProfileLevel.DolbyVisionLevelUhd60; + case "10": + return 0x200; + case "11": + return 0x400; + case "12": + return 0x800; + case "13": + return 0x1000; default: return null; }