feat(mux): emit HDR10 static metadata from HEVC SEI
Parse the two HDR10 HEVC SEI messages and emit the corresponding Matroska Colour metadata, only when actually present in the bitstream (SDR / no-SEI tracks omit it; nothing is fabricated). Parse (Rec. ITU-T H.265 Annex D): - Mastering Display Colour Volume SEI, payloadType 137 (D.2.28): display_primaries_x/y[3] (SEI order G,B,R), white_point_x/y (0.00002 units), max/min_display_mastering_luminance (0.0001 cd/m²). - Content Light Level Info SEI, payloadType 144 (D.2.35): MaxCLL / MaxFALL (cd/m² integers). HevcParser::scan_sei walks the sei_rbsp ff-extension payloadType/ payloadSize coding and de-emulates (00 00 03) before reading, reusing the existing strip_emulation_prevention helper. Both SEI are required before any metadata is surfaced; SEI NALs still pass through unchanged. Carry: the measured Hdr10Metadata rides PictureInfo (the same per-coded- picture seam FieldOrder uses), flowing through from_codec_frame onto PesFrame.coding to the deferred-muxer activate path, where apply_coding_to_track stamps it on the video track before the header is written. Set only when both SEI were seen. Emit (RFC 9559 / Matroska): new Colour children in ebml.rs (MasteringMetadata 0x55D0, Primary R/G/B + WhitePoint chromaticity 0x55D1..0x55D8, Luminance max/min 0x55D9/0x55DA, MaxCLL 0x55BC, MaxFALL 0x55BD). write_hdr10 converts chromaticity SEI int × 0.00002 → Matroska float, luminance SEI int × 0.0001 → cd/m² float; MaxCLL/MaxFALL are uints verbatim. SEI primary index 0/1/2 (G/B/R) mapped to the Matroska R/G/B element layout. Emitted only when hdr10 is present. Tests: SEI parse with exact raw values, requires-both-SEI, SDR omission, and emulation-prevention stripping (hevc.rs); muxer emit with exact unit scaling + SDR omission of MasteringMetadata/MaxCLL/MaxFALL (mkv.rs); apply_coding_to_track HDR10 plumbing (mkvstream.rs).
This commit is contained in:
@@ -456,6 +456,25 @@ pub const TRANSFER_CHARACTERISTICS: u32 = 0x55BA;
|
||||
pub const MATRIX_COEFFICIENTS: u32 = 0x55B1;
|
||||
pub const PRIMARIES: u32 = 0x55BB;
|
||||
pub const RANGE: u32 = 0x55B9;
|
||||
// HDR10 static metadata — children of COLOUR (RFC 9559 / Matroska spec).
|
||||
//
|
||||
// MaxCLL / MaxFALL are direct children of Colour and are UINTs (cd/m²).
|
||||
pub const MAX_CLL: u32 = 0x55BC;
|
||||
pub const MAX_FALL: u32 = 0x55BD;
|
||||
// MasteringMetadata is a master child of Colour; its chromaticity / luminance
|
||||
// children are EBML FLOATs. Chromaticity values are in the 0..1 range; the
|
||||
// luminance values are in cd/m².
|
||||
pub const MASTERING_METADATA: u32 = 0x55D0;
|
||||
pub const PRIMARY_R_CHROMATICITY_X: u32 = 0x55D1;
|
||||
pub const PRIMARY_R_CHROMATICITY_Y: u32 = 0x55D2;
|
||||
pub const PRIMARY_G_CHROMATICITY_X: u32 = 0x55D3;
|
||||
pub const PRIMARY_G_CHROMATICITY_Y: u32 = 0x55D4;
|
||||
pub const PRIMARY_B_CHROMATICITY_X: u32 = 0x55D5;
|
||||
pub const PRIMARY_B_CHROMATICITY_Y: u32 = 0x55D6;
|
||||
pub const WHITE_POINT_CHROMATICITY_X: u32 = 0x55D7;
|
||||
pub const WHITE_POINT_CHROMATICITY_Y: u32 = 0x55D8;
|
||||
pub const LUMINANCE_MAX: u32 = 0x55D9;
|
||||
pub const LUMINANCE_MIN: u32 = 0x55DA;
|
||||
|
||||
// Dolby Vision — BlockAdditionMapping carries the DOVIDecoderConfigurationRecord
|
||||
// (dvcC) so players / mediainfo recognise the track as Dolby Vision.
|
||||
|
||||
Reference in New Issue
Block a user