diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/video/MediaCodecVideoRenderer.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/video/MediaCodecVideoRenderer.java index 2f0c734c093..421670e8599 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/video/MediaCodecVideoRenderer.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/video/MediaCodecVideoRenderer.java @@ -211,6 +211,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer private @MonotonicNonNull CodecMaxValues codecMaxValues; private boolean codecNeedsSetOutputSurfaceWorkaround; private boolean codecHandlesHdr10PlusOutOfBandMetadata; + private boolean isDolbyVisionProfile8; private @MonotonicNonNull VideoSink videoSink; private boolean hasSetVideoSink; private @VideoSink.FirstFrameReleaseInstruction int nextVideoSinkFirstFrameReleaseInstruction; @@ -1551,6 +1552,7 @@ protected void onCodecInitialized( codecNeedsSetOutputSurfaceWorkaround = codecNeedsSetOutputSurfaceWorkaround(name); codecHandlesHdr10PlusOutOfBandMetadata = checkNotNull(getCodecInfo()).isHdr10PlusOutOfBandMetadataSupported(); + isDolbyVisionProfile8 = isDolbyVisionProfile8(configuration.format); maybeSetupTunnelingForFirstFrame(); } @@ -1825,6 +1827,14 @@ protected void handleInputBufferSupplementalData(DecoderInputBuffer buffer) if (!codecHandlesHdr10PlusOutOfBandMetadata) { return; } + // Workaround for https://github.com/androidx/media/issues/1895 + // Skip HDR10+ metadata when using Dolby Vision Profile 8. The combination of DV Profile 8 + // (which has its own dynamic metadata) with HDR10+ causes playback issues on many devices. + // Since DV Profile 8 already provides dynamic HDR metadata, HDR10+ is redundant and the + // conflicting metadata can cause severe issues (freezes, black screens). + if (isDolbyVisionProfile8) { + return; + } ByteBuffer data = checkNotNull(buffer.supplementalData); if (data.remaining() >= 7) { // Check for HDR10+ out-of-band metadata. See User_data_registered_itu_t_t35 in ST 2094-40. @@ -2635,6 +2645,23 @@ private static boolean deviceNeedsNoPostProcessWorkaround() { return "NVIDIA".equals(Build.MANUFACTURER); } + /** + * Returns whether the format contains Dolby Vision Profile 8. + * + * @param format The {@link Format} to check. + * @return Whether the format contains Dolby Vision Profile 8. + */ + private static boolean isDolbyVisionProfile8(Format format) { + if (!MimeTypes.VIDEO_DOLBY_VISION.equals(format.sampleMimeType)) { + return false; + } + @Nullable + Pair codecProfileAndLevel = + CodecSpecificDataUtil.getCodecProfileAndLevel(format); + return codecProfileAndLevel != null + && codecProfileAndLevel.first == CodecProfileLevel.DolbyVisionProfileDvheSt; + } + /* * TODO: *