Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1551,6 +1552,7 @@ protected void onCodecInitialized(
codecNeedsSetOutputSurfaceWorkaround = codecNeedsSetOutputSurfaceWorkaround(name);
codecHandlesHdr10PlusOutOfBandMetadata =
checkNotNull(getCodecInfo()).isHdr10PlusOutOfBandMetadataSupported();
isDolbyVisionProfile8 = isDolbyVisionProfile8(configuration.format);
maybeSetupTunnelingForFirstFrame();
}

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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<Integer, Integer> codecProfileAndLevel =
CodecSpecificDataUtil.getCodecProfileAndLevel(format);
return codecProfileAndLevel != null
&& codecProfileAndLevel.first == CodecProfileLevel.DolbyVisionProfileDvheSt;
}

/*
* TODO:
*
Expand Down