Parse colr box CICP data for video tracks#447
Merged
kinetiknz merged 3 commits intomozilla:masterfrom Apr 18, 2026
Merged
Conversation
Add parsing of the ISO BMFF `colr` box (ISO 14496-12:2020 §12.1.5) in `read_video_sample_entry`, storing the result in a new `colour_info` field on `VideoSampleEntry`. Expose the nclx CICP values through the C API via four new fields on `Mp4parseTrackVideoSampleInfo`: `has_colour_info`, `colour_primaries`, `transfer_characteristics`, `matrix_coefficients`, and `full_range_flag`. This enables Firefox's MP4 demuxer to set `mVideoInfo.mTransferFunction` for fMP4 content (Netflix, Prime Video, DRM), fixing HDR10/HLG video appearing near-black on Windows HDR displays. - `read_video_sample_entry` now takes `strictness` (consistent with `read_audio_sample_entry`) and passes it to `read_colr`. - Duplicate `colr` boxes in a sample entry violate ISO 14496-12:2020 §12.1.5; we warn and keep the first rather than failing playback. - `has_colour_info: bool` is the canonical "present" flag; avoids misinterpreting MC=0 (Identity/GBR) as "absent". - `NclxColourInformation` fields made public for Rust callers. - Seven integration tests added. Test MP4 files were generated with ffmpeg using `-movflags +write_colr` and `-x264-params colorprim/transfer/colormatrix`: HDR10 (cp=9,tc=16,mc=9), HLG (tc=18), HDR10 full-range, HLG full-range, RGB/Identity (mc=0, exercises has_colour_info), and no-colr variants.
Member
Author
|
@kinetiknz could you help review this? This is a fix for bug 2030296 where we miss parse |
kinetiknz
requested changes
Apr 17, 2026
Collaborator
kinetiknz
left a comment
There was a problem hiding this comment.
Thanks! Looks good, just a couple of things to address.
- Add ColrBadQuantityBMFF status (distinct from the HEIF-specific ColrBadQuantity) and enforce it via fail_with_status_if when strictness != Permissive for duplicate colr boxes in video tracks. - Introduce ParsedColourInformation enum so read_colr returns Supported/Unsupported instead of always erroring on unknown colour_type values; the AVIF call site converts Unsupported to ColrBadType, while the video call site warns and continues. - Document that VideoSampleEntry::colour_info only surfaces Nclx through the C API.
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.
Summary
The
read_colrfunction andColourInformationBoxparsing already existed in this codebase, but were only wired upto the AVIF/image item path (
read_iprp). The video track path (read_video_sample_entry) silently discarded thecolrbox via the defaultskip_box_contentarm.This PR connects the existing
read_colrto video tracks and exposes the CICP values through the C API.Changes
mp4parse(Layer 1 — parser)colour_info: Option<ColourInformation>field toVideoSampleEntryBoxType::ColourInformationBoxarm inread_video_sample_entryto call the existingread_colrstrictnessparameter toread_video_sample_entry(needed to pass toread_colr, consistent withread_audio_sample_entry)NclxColourInformationfieldspubsomp4parse_capican read themcolrboxes violate ISO 14496-12:2020 §12.1.5 — we warn and keep the first rather than failing, toavoid breaking playback of malformed content
mp4parse_capi(Layer 2 — C API)Mp4parseTrackVideoSampleInfo:has_colour_info: bool— canonical presence flag; needed because MC=0 is a valid CICP value (Identity/GBR), notan absence indicator
colour_primaries: u8transfer_characteristics: u8matrix_coefficients: u8full_range_flag: boolvideo.colour_infoinmp4parse_get_track_video_info_safeTests
Six integration tests with ffmpeg-generated MP4 files (
-movflags +write_colr,-x264-params colorprim/transfer/colormatrix):colrbox