Parse mdcv and clli boxes in video sample entries#448
Merged
kinetiknz merged 3 commits intomozilla:masterfrom Apr 21, 2026
Merged
Parse mdcv and clli boxes in video sample entries#448kinetiknz merged 3 commits intomozilla:masterfrom
kinetiknz merged 3 commits intomozilla:masterfrom
Conversation
Member
Author
|
This is for 2033628. |
Add support for MasteringDisplayColourVolumeBox ('mdcv') and
ContentLightLevelBox ('clli') as defined in ISO/IEC 14496-12.
Both boxes are codec-agnostic children of VisualSampleEntry and carry
HDR10 static metadata (SMPTE ST 2086 mastering display + CTA-861.3
content light level). Parsed values are exposed through the C API via
new boolean-flagged fields on Mp4parseTrackVideoSampleInfo, following
the same pattern as the existing has_colour_info/colour_primaries fields.
12f7ef3 to
2de4aa5
Compare
Member
Author
|
@kinetiknz could you help me review this? Thanks! |
kinetiknz
requested changes
Apr 21, 2026
2de4aa5 to
f269f61
Compare
f269f61 to
2541374
Compare
Fix hex literal formatting in BoxType constants to use '_' separators, and fix read_mdcv to correctly remap wire order G, B, R to struct indices R[0], G[1], B[2] per ISO 14496-12.
2541374 to
5fe5578
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
MasteringDisplayColourVolumeBox(mdcv) andContentLightLevelBox(clli) are defined in ISO/IEC 14496-12 as codec-agnostic child boxes ofVisualSampleEntry. They carry HDR10 static metadata:mdcv— SMPTE ST 2086 mastering display colour volume (primaries, white point, luminance range)clli— CTA-861.3 content light level (MaxCLL, MaxFALL)Because they sit on
VisualSampleEntryrather than inside any codec-specific box, they apply to all video codecs:hvc1,av01,vp09,avc1, etc. This is particularly important for VP9-in-MP4, which has no in-bitstream HDR metadata mechanism and relies entirely on these container boxes.These boxes are distinct from the older
SmDm/CoLLboxes from the WebM VP9 binding spec. They carry the same data, butmdcv/clliare plainBox(no version/flags header), whileSmDm/CoLLareFullBox. Chromium handles both; this PR adds support for the ISO-standardizedmdcv/cllivariant.Design note: raw integers vs floats
We store raw fixed-point integers rather than converting to floats at parse time. This is lossless and matches the wire format exactly, letting the caller decide how to interpret the values. Chromium’s implementation converts to floats inside
Parse()—both approaches are valid; we prefer keeping the library as a faithful parser.Testing
Unit tests added to
mp4parse/src/tests.rs:read_mdcv— synthetic 24-byte payload, asserts all 8 fields round-trip correctlyread_clli— synthetic 4-byte payload, asserts both light level fields