Skip to content

Parse mdcv and clli boxes in video sample entries#448

Merged
kinetiknz merged 3 commits intomozilla:masterfrom
alastor0325:parse-mdcv-clli
Apr 21, 2026
Merged

Parse mdcv and clli boxes in video sample entries#448
kinetiknz merged 3 commits intomozilla:masterfrom
alastor0325:parse-mdcv-clli

Conversation

@alastor0325
Copy link
Copy Markdown
Member

@alastor0325 alastor0325 commented Apr 21, 2026

Background

MasteringDisplayColourVolumeBox (mdcv) and ContentLightLevelBox (clli) are defined in ISO/IEC 14496-12 as codec-agnostic child boxes of VisualSampleEntry. 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 VisualSampleEntry rather 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/CoLL boxes from the WebM VP9 binding spec. They carry the same data, but mdcv/clli are plain Box (no version/flags header), while SmDm/CoLL are FullBox. Chromium handles both; this PR adds support for the ISO-standardized mdcv/clli variant.

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 correctly
  • read_clli — synthetic 4-byte payload, asserts both light level fields

@alastor0325
Copy link
Copy Markdown
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.
@alastor0325
Copy link
Copy Markdown
Member Author

@kinetiknz could you help me review this? Thanks!

Comment thread mp4parse/src/boxes.rs Outdated
Comment thread mp4parse/src/lib.rs Outdated
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.
Copy link
Copy Markdown
Collaborator

@kinetiknz kinetiknz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@kinetiknz kinetiknz merged commit fb7ed9e into mozilla:master Apr 21, 2026
15 checks passed
@alastor0325 alastor0325 deleted the parse-mdcv-clli branch April 22, 2026 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants