Skip HDR10+ metadata processing when Dolby Vision Profile 8 is detected#3085
Skip HDR10+ metadata processing when Dolby Vision Profile 8 is detected#3085cgarst wants to merge 3 commits intoandroidx:releasefrom
Conversation
|
OMG, @cgarst you are an absolute legend! |
|
Wouldn't this cause a regression if playback device doesn't support Dolby Vision, but does support HDR10+, and the file has both? |
|
@nift4 good call - this should be fixed now. |
|
Just to start with an disclaimer, I'm not sure about this as I don't have a test setup and my understanding is limited. That said, I wonder if this could still cause a regression in the following case:
Edit: I was a bit mistaken in an initial analysis in this comment, sorry. (I edited it out now as it is not relevant, to prevent confusion.) Your prior fix seems to have already considered that scenario, and the change seems fine now. |
…ta/setParameters, but that path is unreachable for MKV DV Profile 8 — the HDR10+ is in-band as SEI NAL units in buffer.data, not out-of-band supplemental data. Now strips HDR10+ SEI directly from the AnnexB buffer in onQueueInputBuffer before it reaches the native DV codec. Tests were added to validate the fix and guard from regressions.
|
@nift4 Thanks again for the feedback. The fix has been redone to handle this at a different level after digging deeper into how the HDR10+ metadata flows. The HDR10+ in these MKV files is in-band as SEI NAL units in I've added the scenario you mentioned as an integration test ( I work on some additional testing with this change. |
|
You're right, that should just work with your new commit, because ExoPlayer already correctly falls back to HEVC codec, even if DV codec is present in STB but TV does not have DV. (I was mistaken about that not happening in my prior comment.) So everything should be good now! |
Strip in-band HDR10+ SEI from HEVC bitstream during Dolby Vision Profile 8 playback
Summary
Fixes freezes, black screens, and purple screens when playing DV Profile 8 MKV files that contain both Dolby Vision RPU and HDR10+ dynamic metadata on devices with buggy chipsets.
Related Issues
Fixes #1895
Problem
MKV files containing Dolby Vision Profile 8.1 (
dvhe.08) combined with HDR10+ metadata cause playback failures on many Android TV devices:The HEVC base layer bitstream contains HDR10+ dynamic metadata as in-band SEI NAL units (ITU-T T.35 / ST 2094-40). When a native Dolby Vision codec processes this stream, it also handles DV RPU for dynamic HDR. The conflicting dynamic metadata crashes the chipset.
Solution
Strip HDR10+ SEI NAL units from
buffer.datainonQueueInputBuffer()before the buffer is submitted to the native DV codec. This is the same approach used by Kodi.The stripping only activates when both conditions are met:
codecMimeType == VIDEO_DOLBY_VISION)When the TV doesn't support Dolby Vision,
doesDisplaySupportDolbyVision()returnsfalse,getDecoderInfos()falls back to HEVC,codecMimeTypeisVIDEO_H265, and stripping is not applied — HDR10+ metadata is preserved for the HEVC decoder.In this case
doesDisplaySupportDolbyVision()returnsfalse→ HEVC fallback is selected →stripHdr10PlusSeiNalUnitsstaysfalse→ HDR10+ SEI is preserved → no regression. This scenario is covered by thedvProfile8_hevcFallback_preservesHdr10PlusSeiInBufferintegration test.Changes
MediaCodecVideoRenderer.javastripHdr10PlusSeiNalUnitsboolean field, set inonCodecInitialized()onQueueInputBuffer()stripHdr10PlusSeiFromBuffer(): scans AnnexB buffer for start codes, identifies HEVC PREFIX_SEI/SUFFIX_SEI NAL units (types 39/40), parses SEI payloads to detect HDR10+ (ITU-T T.35 with country code0xB5, provider0x003C, oriented0x0001, app_id 4, version 0 or 1), removes matching NAL units by compacting the buffer in-placeMediaCodecInfo.javaisHdr10PlusOutOfBandMetadataSupported()to VP9-only — the HEVC extension was unreachable for this bugMediaCodecVideoRendererTest.javastripHdr10PlusSeiFromBuffer()and integration tests for the fixTest plan
Bug fix validation
These tests confirm that HDR10+ SEI NAL units are correctly stripped from the HEVC bitstream before it reaches a native Dolby Vision codec. They fail on unpatched code and pass with the fix.
stripHdr10PlusSei_removesHdr10PlusSeiNalUnit[VCL][HDR10+ SEI][VCL], verifies the HDR10+ SEI NAL is removed, VCL NALs are preserved, and the buffer limit is reduceddvProfile8_nativeDvCodec_stripsHdr10PlusSeiFromBufferRegression protection
These tests confirm that stripping does not activate when it shouldn't — non-HDR10+ SEI is never touched, buffers without SEI are left alone, and HEVC fallback playback preserves HDR10+ metadata for devices/TVs that need it.
stripHdr10PlusSei_preservesNonHdr10PlusSei[VCL][non-HDR10+ SEI][VCL], verifies all NAL units are preserved unchanged. Guards against accidentally stripping unrelated SEI messages (e.g. CEA-608 captions)stripHdr10PlusSei_noOpWhenNoSeiPresentdvProfile8_hevcFallback_preservesHdr10PlusSeiInBuffer