Set HDR mastering display and content light level attributes on MFMediaEngine video media type
Categories
(Core :: Audio/Video: Playback, task, P3)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox153 | --- | affected |
People
(Reporter: alwu, Assigned: alwu)
References
(Blocks 1 open bug)
Details
MFMediaEngineVideoStream::CreateMediaType() currently sets transfer function and
primaries on the IMFMediaType for PlayReady-protected HDR content, but does not pass
through the static HDR10 mastering metadata that VideoInfo::mHDRMetadata now carries.
Currently set
(https://searchfox.org/mozilla-central/source/dom/media/platforms/wmf/MFMediaEngineVideoStream.cpp#160-184):
- MF_MT_TRANSFER_FUNCTION <- videoInfo.mTransferFunction (bug 2032534, Fx151)
- MF_MT_VIDEO_PRIMARIES <- videoInfo.mColorSpace
Missing when videoInfo.mHDRMetadata is Some(...):
- MF_MT_MAX_MASTERING_LUMINANCE <- mSmpte2086.mMaxLuminance (* 10000)
- MF_MT_MIN_MASTERING_LUMINANCE <- mSmpte2086.mMinLuminance (* 10000)
- MF_MT_MAX_LUMINANCE_LEVEL <- mContentLightLevel.mMaxCLL (MaxCLL, uint16)
- MF_MT_MAX_FRAME_AVERAGE_LUMINANCE_LEVEL <- mContentLightLevel.mMaxFALL (MaxFALL, uint16)
- MF_MT_CUSTOM_VIDEO_PRIMARIES <- mSmpte2086 primaries + white point
(MT_CUSTOM_VIDEO_PRIMARIES blob:
8 floats - RGB chromaticities + white x/y)
Impact:
PlayReady HDR content (Netflix HDR via PlayReady, etc.) currently arrives at the
Windows Media Engine's internal Video Processor with transfer function and color
space, but no mastering metadata. The internal VP tone-maps without knowing the
content's mastered peak luminance or per-frame light levels - the same correctness
gap that bug 1793908 (Fx152) closed for the non-DRM WMF + DXVA path via
VideoProcessorSetStreamHDRMetaData().
Without these attributes, highlights may clip or appear flat depending on the
driver's default assumptions, even on a calibrated HDR display.
Prerequisites already in place:
VideoInfo::mHDRMetadata is populated end-to-end as of Fx152:
- HEVC SEI 137/144, AV1 metadata OBUs, VP9/WebM mastering elements (bug 2033598)
- MP4 mdcv/clli boxes (bug 2033628)
- IPC serialization (bug 1793908 Part 1)
No new plumbing is required - the data is already on videoInfo, just not yet
consumed by MFMediaEngineVideoStream.
Proposed implementation:
- In MFMediaEngineVideoStream::CreateMediaType()
(https://searchfox.org/mozilla-central/source/dom/media/platforms/wmf/MFMediaEngineVideoStream.cpp#93),
after the existing MF_MT_VIDEO_PRIMARIES block, read videoInfo.mHDRMetadata and
set the five attributes above when it is Some(...). Per Microsoft docs:- Luminance values use 10000ths of a nit (MaxMasteringLuminance * 10000)
- MaxCLL/MaxFALL are direct nit values (uint16)
- MF_MT_CUSTOM_VIDEO_PRIMARIES takes a blob of MT_CUSTOM_VIDEO_PRIMARIES
(8 floats: 6 chromaticities + white point x/y)
- Apply the same in UpdateConfig()
(https://searchfox.org/mozilla-central/source/dom/media/platforms/wmf/MFMediaEngineVideoStream.cpp#405)
so mid-stream HDR metadata changes propagate (subject to the existing H264/HEVC
early-return; clarify whether MFMediaEngine consumes per-frame mastering metadata
via media type updates or whether a different mechanism is needed for those
codecs). - Add MFVideoMasteringMetadataToStr / MFVideoContentLightLevelToStr helpers and log
the values alongside the existing MFVideoTransferFunctionToStr line for
diagnostics.
Testing:
- Manual verification on PlayReady HDR content (Netflix HDR if available, or
self-hosted PlayReady HDR test vectors) on AMD/NVIDIA + HDR display. - Verify via MOZ_LOG=MFMediaEngine:5 that the attributes are set with values
matching the bitstream SEI / mdcv / clli. - Compare highlights against Chrome / Edge on the same content / hardware.
Notes:
- Not a Fx151/152 shipping blocker - non-DRM and HEVC-Widevine HDR paths already
have stream metadata via WMF DXVA (bug 1793908 Fx152). This bug is the
PlayReady/MFMediaEngine analogue. - MFMediaEngine owns its own internal VP, so we cannot call
VideoProcessorSetStreamHDRMetaData directly - the only Firefox-side surface to
pass mastering metadata is via the IMFMediaType attributes set in
CreateMediaType/UpdateConfig.
Description
•