Skip to content

Commit

Permalink
xml/parser: parse level 6 metadata with decimals
Browse files Browse the repository at this point in the history
Fixes #274
  • Loading branch information
quietvoid committed Jan 5, 2024
1 parent 59be825 commit abbccda
Show file tree
Hide file tree
Showing 7 changed files with 224 additions and 39 deletions.
60 changes: 30 additions & 30 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ hevc_parser = { version = "0.6.2", features = ["hevc_io"] }
madvr_parse = "1.0.2"
hdr10plus = { version = "2.1.1", features = ["json"] }

anyhow = "1.0.77"
clap = { version = "4.4.11", features = ["derive", "wrap_help", "deprecated"] }
anyhow = "1.0.79"
clap = { version = "4.4.13", features = ["derive", "wrap_help", "deprecated"] }
clap_lex = "*"
indicatif = "0.17.7"
bitvec = "1.0.1"
serde = { version = "1.0.193", features = ["derive"] }
serde_json = { version = "1.0.108", features = ["preserve_order"] }
serde = { version = "1.0.194", features = ["derive"] }
serde_json = { version = "1.0.111", features = ["preserve_order"] }
itertools = "0.12.0"
plotters = { version = "0.3.5", default-features = false, features = ["bitmap_backend", "bitmap_encoder", "all_series"] }

Expand Down
154 changes: 154 additions & 0 deletions assets/tests/level6_decimals.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
<?xml version="1.0" encoding="UTF-8"?>
<DolbyLabsMDF xmlns="http://www.dolby.com/schemas/dvmd/5_1_0">
<!-- Unofficial XML sample, just edited version -->
<Version>5.1.0</Version>
<RevisionHistory>
<Revision>
<DateTime>2020-02-17T11:29:59Z</DateTime>
<Author>Blackmagic Design</Author>
<Software>DaVinci Resolve Studio</Software>
<SoftwareVersion>16.1.2.026</SoftwareVersion>
</Revision>
</RevisionHistory>
<Outputs>
<Output>
<CompositionName>Black</CompositionName>
<UniqueID>118cbebe-317f-4d84-9b10-604289433563</UniqueID>
<NumberVideoTracks>1</NumberVideoTracks>
<CanvasAspectRatio>1.77778</CanvasAspectRatio>
<ImageAspectRatio>1.77778</ImageAspectRatio>
<Video>
<Track>
<TrackName>V1</TrackName>
<UniqueID>852c64bc-9b4c-4546-b013-a333f6a871ca</UniqueID>
<EditRate>24000 1001</EditRate>
<ColorEncoding>
<Primaries>
<Red>0.68 0.32</Red>
<Green>0.265 0.69</Green>
<Blue>0.15 0.06</Blue>
</Primaries>
<WhitePoint>0.3127 0.329</WhitePoint>
<PeakBrightness>10000</PeakBrightness>
<MinimumBrightness>0</MinimumBrightness>
<Encoding>pq</Encoding>
<ColorSpace>rgb</ColorSpace>
<SignalRange>computer</SignalRange>
</ColorEncoding>
<Level6 level="6">
<MaxCLL>787.849</MaxCLL>
<MaxFALL>60.424</MaxFALL>
</Level6>
<PluginNode>
<DVGlobalData level="0">
<MasteringDisplay>
<ID>20</ID>
<ApplicationType>ALL</ApplicationType>
<Name>1000-nit, P3, D65, ST.2084, Full</Name>
<Primaries>
<Red>0.68 0.32</Red>
<Green>0.265 0.69</Green>
<Blue>0.15 0.06</Blue>
</Primaries>
<WhitePoint>0.3127 0.329</WhitePoint>
<PeakBrightness>1000</PeakBrightness>
<MinimumBrightness>0.0001</MinimumBrightness>
<DiagonalSize>42</DiagonalSize>
</MasteringDisplay>
<TargetDisplay>
<ID>42</ID>
<ApplicationType>CINEMA</ApplicationType>
<Name>108-nit, P3, D65, ST.2084, Full (CINEMA)</Name>
<Primaries>
<Red>0.68 0.32</Red>
<Green>0.265 0.69</Green>
<Blue>0.15 0.06</Blue>
</Primaries>
<WhitePoint>0.3127 0.329</WhitePoint>
<PeakBrightness>108</PeakBrightness>
<MinimumBrightness>0.005</MinimumBrightness>
<EOTF>pq</EOTF>
<DiagonalSize>42</DiagonalSize>
</TargetDisplay>
<TargetDisplay>
<ID>1</ID>
<ApplicationType>HOME</ApplicationType>
<Name>100-nit, BT.709, BT.1886, Full</Name>
<Primaries>
<Red>0.64 0.33</Red>
<Green>0.3 0.6</Green>
<Blue>0.15 0.06</Blue>
</Primaries>
<WhitePoint>0.3127 0.329</WhitePoint>
<PeakBrightness>100</PeakBrightness>
<MinimumBrightness>0.005</MinimumBrightness>
<EOTF>gamma_bt1886</EOTF>
<DiagonalSize>42</DiagonalSize>
</TargetDisplay>
<TargetDisplay>
<ID>27</ID>
<ApplicationType>HOME</ApplicationType>
<Name>600-nit, P3, D65, ST.2084, Full</Name>
<Primaries>
<Red>0.68 0.32</Red>
<Green>0.265 0.69</Green>
<Blue>0.15 0.06</Blue>
</Primaries>
<WhitePoint>0.3127 0.329</WhitePoint>
<PeakBrightness>600</PeakBrightness>
<MinimumBrightness>0</MinimumBrightness>
<EOTF>pq</EOTF>
<DiagonalSize>42</DiagonalSize>
</TargetDisplay>
<TargetDisplay>
<ID>48</ID>
<ApplicationType>HOME</ApplicationType>
<Name>1000-nit, P3, D65, ST.2084, Full</Name>
<Primaries>
<Red>0.68 0.32</Red>
<Green>0.265 0.69</Green>
<Blue>0.15 0.06</Blue>
</Primaries>
<WhitePoint>0.3127 0.329</WhitePoint>
<PeakBrightness>1000</PeakBrightness>
<MinimumBrightness>0</MinimumBrightness>
<EOTF>pq</EOTF>
<DiagonalSize>42</DiagonalSize>
</TargetDisplay>
</DVGlobalData>
<Level11 level="11">
<ContentType>2</ContentType>
<IntendedWhitePoint>0</IntendedWhitePoint>
</Level11>
<Level254 level="254">
<DMMode>0</DMMode>
<DMVersion>2</DMVersion>
<CMVersion>4 2</CMVersion>
</Level254>
</PluginNode>
<Shot>
<UniqueID>07e96e28-5bd9-47ef-8e21-4bbac5986052</UniqueID>
<Record>
<In>86400</In>
<Duration>24</Duration>
</Record>
<PluginNode>
<DVDynamicData>
<Level1 level="1">
<ImageCharacter>0 0.2 0.508078</ImageCharacter>
</Level1>
<Level3 level="3">
<L1Offset>0 -0.2 -0.508078</L1Offset>
</Level3>
<Level9 level="9">
<SourceColorModel>255</SourceColorModel>
<SourceColorPrimary>0.68 0.32 0.265 0.69 0.15 0.06 0.3127 0.329</SourceColorPrimary>
</Level9>
</DVDynamicData>
</PluginNode>
</Shot>
</Track>
</Video>
</Output>
</Outputs>
</DolbyLabsMDF>
1 change: 1 addition & 0 deletions dolby_vision/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Unreleased
- Added `write_av1_rpu_metadata_obu_t35_complete` function to encode RPUs in complete metadata OBU payloads.
- XML parser: support decimals when parsing Level6 MaxCLL/MaxFALL values.

C API:
- Added `dovi_write_av1_rpu_metadata_obu_t35_{payload,complete}` functions.
Expand Down
6 changes: 3 additions & 3 deletions dolby_vision/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ repository = "https://github.com/quietvoid/dovi_tool/tree/main/dolby_vision"

[dependencies]
bitvec_helpers = { version = "3.1.3", default-features = false, features = ["bitstream-io"] }
anyhow = "1.0.77"
anyhow = "1.0.79"
bitvec = "1.0.1"
crc = "3.0.1"
serde = { version = "1.0.193", features = ["derive"], "optional" = true }
serde_json = { version = "1.0.108", features = ["preserve_order"], "optional" = true }
serde = { version = "1.0.194", features = ["derive"], "optional" = true }
serde_json = { version = "1.0.111", features = ["preserve_order"], "optional" = true }
roxmltree = { version = "0.19.0", optional = true }

libc = { version = "0.2", optional = true }
Expand Down
6 changes: 4 additions & 2 deletions dolby_vision/src/xml/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,15 @@ impl CmXmlParser {
fn parse_level6(&self, video: &Node) -> (u16, u16) {
if let Some(node) = video.descendants().find(|e| e.has_tag_name("Level6")) {
let maxfall = if let Some(fall) = node.children().find(|e| e.has_tag_name("MaxFALL")) {
fall.text().map_or(0, |e| e.parse::<u16>().unwrap())
fall.text()
.map_or(0, |e| e.parse::<f32>().unwrap().round() as u16)
} else {
0
};

let maxcll = if let Some(cll) = node.children().find(|e| e.has_tag_name("MaxCLL")) {
cll.text().map_or(0, |e| e.parse::<u16>().unwrap())
cll.text()
.map_or(0, |e| e.parse::<f32>().unwrap().round() as u16)
} else {
0
};
Expand Down
Loading

0 comments on commit abbccda

Please sign in to comment.