Support CM v4.0 extension metadata levels 15-18 (rebase + C-FFI completion of #362) - #412
Closed
MeeeetRain wants to merge 2 commits into
Closed
Support CM v4.0 extension metadata levels 15-18 (rebase + C-FFI completion of #362)#412MeeeetRain wants to merge 2 commits into
MeeeetRain wants to merge 2 commits into
Conversation
Rebases and completes quietvoid#362 on top of current main: - Add ExtMetadataBlockLevel15 (Dolby Image Engine, Standard mode): confidence / precision_rendering_strength / d_local_contrast / d_brightness / d_saturation / d_contrast (+ *_no_pr variants). 11 bytes / 88 bits. - Add ExtMetadataBlockLevel16 (Reference mode Image Engine): variable length, revision + count + Level16Params[] (contrast_target / precision_rendering_strength / d_local_contrast / max_d_brightness / max_d_saturation_plus_one). - Add ExtMetadataBlockLevel17 (up-mapping metadata): 10 bytes / 80 bits. Kept for forward compatibility; DM ignores it (Metadata Spec v1.5.1 removed the L17 grammar, superseded by L18). - Add ExtMetadataBlockLevel18 (Precision Black / creative environment): 4x 12-bit PQ luminance (surround / min_preserved / adaptation / max_preserved) + revision. 7 bytes / 56 bits. - Wire dispatch in cmv40.rs (ALLOWED_BLOCK_LEVELS + parse arms), ExtMetadataBlock enum + trait match arms, vdr_dm_data replace path, and the CSV/JSON exporter. - Complete the libdovi C-FFI mapping (c_structs/extension_metadata.rs) that was left as // TODO stubs, so FFmpeg/Kodi/CoreELEC can read the new blocks through the C ABI. - Add a round-trip test against a real DV2 sample (l15_to_l18.bin).
The third byte of the Level 11 block is not reserved in DV2: per Dolby Vision Metadata Spec v1.5.1 and HDMI Transmission Spec v5.1.1 (PB[13]), bits [3:0] carry frc_strength (0..=15) and bit 4 carries frc_type (0 = De-judder, 1 = Smoothness), used by the DV2 Max Authentic Motion feature. The existing reserved_byte3 == 0 validation (left in place after quietvoid#384 relaxed byte 2) rejected every DV2 stream carrying L11 motion metadata (e.g. the official MFV-L18 and CST-DV2 test vectors, where byte3 = 8). - Drop the byte3 == 0 ensure (byte is still stored for round-trip). - Add frc_strength() and frc_type() accessors documenting the layout.
MeeeetRain
added a commit
to MeeeetRain/MediaInfoLib
that referenced
this pull request
Aug 6, 2026
PR MediaArea#2392 leaves L15/L16 as Skip_BS stubs and L18 is missing entirely. This implements proper bitstream parsing for the three DV2 (CMv4.0) blocks. Field layouts cross-validated against three independent sources: Dolby Vision Metadata Spec v1.5.1, quietvoid/dovi_tool (PR quietvoid/dovi_tool#412), and the official Dolby Vision TV SDK v6.0 test vectors (MFV-L15/L16/L18, CST-DV2; Profile 5 HEVC VES). This C++ impl and the Rust dovi_tool produce bit-identical values on the official samples, e.g. CST-DV2 frame 0: L15 confidence=255, L16 contrast_target=64, L18 adaptation_luminance_PQ=1741. L17 intentionally left as Skip_BS (Spec v1.5.1 removed its grammar, superseded by L18). Also fixes a missing break in case 17. Values surface in Trace/Details output; Fill() wiring is future work.
MeeeetRain
added a commit
to MeeeetRain/MediaInfoLib
that referenced
this pull request
Aug 6, 2026
Adds Dolby Vision RPU (Reference Processing Unit, NAL type 62) parsing for HEVC streams, including the DV2 / CMv4.0 extension metadata blocks L15, L16 and L18 that are not yet handled anywhere. ## Provenance This is a focused slice of cjee21's PR MediaArea#2392 ('Dolby Vision: Parse RPU in HEVC and AV1'), restricted to the HEVC path, plus L15/L16/L18 field parsing that MediaArea#2392 leaves as Skip_BS stubs (L15, L16) or misses (L18). The AV1/EMDF portion of MediaArea#2392 is intentionally omitted here, per @JeromeMartinez's request in MediaArea#2392 to defer AV1 until a File_T35.cpp parser exists. Once MediaArea#2392 lands, this PR should be rebased onto it and reduced to just the L15/L16/L18 delta. ## Files (5, source only — no CI/CMake/project changes) - File__Analyze.h / File__Analyze_MinimizeSize.h: DV_RPU struct + parser decl - File__Analyze_Streams.cpp: Get_DolbyVision_ReferenceProcessingUnit() — the RPU parser, including the CMv4.0 ext_metadata_block switch with: - L15 (11 B): confidence, precision_rendering_strength, d_local_contrast, d_brightness, d_saturation_plus_one, d_contrast_plus_one, {confidence,d_brightness,d_saturation,d_contrast}_no_pr, revision, reserved - L16 (variable): revision, count, count x Level16Params - L18 (7 B): surround/min/adaptation/max_preserved_luminance_PQ, revision, reserved (L17 stays Skip_BS: Spec v1.5.1 removed its grammar, superseded by L18.) - File_Hevc.cpp / File_Hevc.h: HEVC NAL type 62 dispatch + member ## Validation — three independent sources agree Field layouts cross-validated against Dolby Vision Metadata Spec v1.5.1, quietvoid/dovi_tool (PR quietvoid/dovi_tool#412), and the official Dolby Vision TV SDK v6.0 test vectors (MFV-L15/L16/L18, CST-DV2). This C++ impl and the Rust dovi_tool produce bit-identical values, e.g. CST-DV2 frame 0: L15 confidence=255, L16 contrast_target=64, L18 adaptation_luminance_PQ=1741. Built on macOS arm64 (MEDIAINFO_HEVC=ON). Values surface in Trace output; Fill() wiring is future work. cc @cjee21 @JeromeMartinez
MeeeetRain
added a commit
to MeeeetRain/MediaInfoLib
that referenced
this pull request
Aug 6, 2026
Adds Dolby Vision RPU (Reference Processing Unit, NAL type 62) parsing for HEVC streams, including the DV2 / CMv4.0 extension metadata blocks L15, L16 and L18 that are not yet handled anywhere. ## Provenance A focused slice of cjee21's PR MediaArea#2392 ('Dolby Vision: Parse RPU in HEVC and AV1'), restricted to the HEVC path, plus L15/L16/L18 field parsing that MediaArea#2392 leaves as Skip_BS stubs (L15, L16) or misses (L18). The AV1/EMDF portion of MediaArea#2392 is intentionally omitted, per @JeromeMartinez's request in MediaArea#2392 to defer AV1 until a File_T35.cpp parser exists. Once MediaArea#2392 lands, this PR should be rebased onto it and reduced to just the L15/L16/L18 delta. ## Files (5, source only — no CI/CMake/project changes) - File__Analyze.h / File__Analyze_MinimizeSize.h: DV_RPU struct + parser decl - File__Analyze_Streams.cpp: Get_DolbyVision_ReferenceProcessingUnit() — the RPU parser, with the CMv4.0 ext_metadata_block switch handling: - L15 (11 B): confidence, precision_rendering_strength, d_local_contrast, d_brightness, d_saturation_plus_one, d_contrast_plus_one, {confidence,d_brightness,d_saturation,d_contrast}_no_pr, revision, reserved - L16 (variable): revision, count, count x Level16Params - L18 (7 B): surround/min/adaptation/max_preserved_luminance_PQ, revision, reserved (L17 stays Skip_BS: Spec v1.5.1 removed its grammar, superseded by L18. Each new case has its own break; the existing case 17 already had one.) - File_Hevc.cpp / File_Hevc.h: HEVC NAL type 62 dispatch + member Also fixes signed/unsigned comparison warnings (C4018) in the imported DV code so it passes the current -warnaserror CI standard. ## Validation — three independent sources agree Field layouts cross-validated against Dolby Vision Metadata Spec v1.5.1, quietvoid/dovi_tool (PR quietvoid/dovi_tool#412), and the official Dolby Vision TV SDK v6.0 test vectors (MFV-L15/L16/L18, CST-DV2). This C++ impl and the Rust dovi_tool produce bit-identical values, e.g. CST-DV2 frame 0: L15 confidence=255, L16 contrast_target=64, L18 adaptation_luminance_PQ=1741. cc @cjee21 @JeromeMartinez
Owner
|
What are you doing? There is already #362. |
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.
Rebases and completes #362 (cc @quietvoid) onto current
main.Context
#362 implements the four DV2 / CM v4.0 extension metadata blocks (L15/L16/L17/L18) but has been dormant and was ~39 commits behind
main, and thelibdoviC-FFI mapping for the new blocks was left as// TODOstubs. This PR rebases the block implementations ontomain, completes the C-FFI, and wires the new blocks into features added onmainafter #362 forked.Changes
Blocks (L15-L18, struct definitions unchanged from #362):
Level15— Dolby Image Engine (Standard mode): confidence / precision_rendering_strength / d_local_contrast / d_brightness / d_saturation / d_contrast (+*_no_prvariants). 11 B / 88 bits.Level16— Reference mode Image Engine: variable length,revision + count + Level16Params[].Level17— up-mapping metadata (10 B / 80 bits). Kept for forward compatibility; DM ignores it (Metadata Spec v1.5.1 removed the L17 grammar, superseded by L18).Level18— Precision Black / creative environment: 4× 12-bit PQ luminance. 7 B / 56 bits.Wiring:
cmv40.rs:ALLOWED_BLOCK_LEVELS+ parse dispatch.blocks/mod.rs: enum variants + trait match arms.vdr_dm_data.rs:replace_metadata_blockpath.commands/export.rs+src/dovi/exporter.rs:--levels level15/16/17/18CLI option + CSV/JSON exporter arms (new onmain).libdoviC-FFI completion (c_structs/extension_metadata.rs):// TODOstubs so L15-L18 are exposed through the C ABI (DmDatastruct fields +set_blocks+drop+Default), unblocking FFmpeg / Kodi / CoreELEC consumers. L16 (variable length) is boxed whole; itsVec<Level16Params>is owned by Rust and round-trips correctly, though the nested params are not yet individually exposed across the C boundary (same limitation as the existing L8/L10 block lists).L11 Authentic Motion (separate commit):
reserved_byte3 == 0validation (left after dovi/level11: improve byte1 parsing and remove byte2 validation #384 relaxed byte 2) rejected every DV2 stream carrying L11 motion metadata. Per Metadata Spec v1.5.1 / HDMI Transmission Spec v5.1.1 PB[13], byte 3 carriesfrc_strength[3:0]+frc_type[4]. Relaxed the check and addedfrc_strength()/frc_type()accessors.Validation
Verified every field against the Dolby Vision TV SDK v6.0 official test vectors (
MFV-L15/L16/L18,CST-DV2, Profile 5 HEVC VES) cross-referenced with Metadata Spec v1.5.1:max_preserved_luminance_pq = 4095, L16count == params.len(), L15/L18reserved == 0).--levels level15/16/17/18export (CSV + JSON) verified against the official samples.cargo fmtclean; no new clippy warnings.cargo build --features capisucceeds.Notes
l15_to_l18.binfixture are @quietvoid's from Add support for extension metadata levels 15-18 #362 — kept intact (byte-identical).level15-18branch directly if you'd prefer to keep the history on Add support for extension metadata levels 15-18 #362. See my comment there: Add support for extension metadata levels 15-18 #362 (comment)