Skip to content

Commit

Permalink
Set RPU source/min pq correctly from XML
Browse files Browse the repository at this point in the history
Instead of relying on L6
  • Loading branch information
quietvoid committed Feb 16, 2024
1 parent abbccda commit 07a19d0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion assets/tests/level6_decimals.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<Blue>0.15 0.06</Blue>
</Primaries>
<WhitePoint>0.3127 0.329</WhitePoint>
<PeakBrightness>1000</PeakBrightness>
<PeakBrightness>2000</PeakBrightness>
<MinimumBrightness>0.0001</MinimumBrightness>
<DiagonalSize>42</DiagonalSize>
</MasteringDisplay>
Expand Down
1 change: 1 addition & 0 deletions dolby_vision/src/rpu/extension_metadata/blocks/level6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ impl ExtMetadataBlockLevel6 {

let source_max_pq = match mdl_max {
1000 => 3079,
2000 => 3388,
4000 => 3696,
10000 => 4095,
_ => 3079,
Expand Down
8 changes: 8 additions & 0 deletions dolby_vision/src/xml/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ impl CmXmlParser {
let (min_display_mastering_luminance, max_display_mastering_luminance) =
parser.parse_mastering_display_metadata(&video);

let source_min_pq = (nits_to_pq(min_display_mastering_luminance as f64 / 10000.0)
* 4095.0)
.round() as u16;
let source_max_pq =
(nits_to_pq(max_display_mastering_luminance as f64) * 4095.0).round() as u16;
parser.config.source_min_pq = Some(source_min_pq);
parser.config.source_max_pq = Some(source_max_pq);

parser.config.level6 = Some(ExtMetadataBlockLevel6 {
max_display_mastering_luminance,
min_display_mastering_luminance,
Expand Down
6 changes: 5 additions & 1 deletion dolby_vision/src/xml/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,14 @@ fn parse_level6_decimals() -> Result<()> {
let rpu = &rpus[0];
let vdr_dm_data = rpu.vdr_dm_data.as_ref().unwrap();

// Source mastering display
assert_eq!(vdr_dm_data.source_min_pq, 7);
assert_eq!(vdr_dm_data.source_max_pq, 3388);

// L6
let level6 = vdr_dm_data.get_block(6).unwrap();
if let ExtMetadataBlock::Level6(block) = level6 {
assert_eq!(block.max_display_mastering_luminance, 1000);
assert_eq!(block.max_display_mastering_luminance, 2000);
assert_eq!(block.min_display_mastering_luminance, 1);
assert_eq!(block.max_content_light_level, 788);
assert_eq!(block.max_frame_average_light_level, 60);
Expand Down

0 comments on commit 07a19d0

Please sign in to comment.