From 1242bd5b3a47b04044a1ff5060fd358cb32794b6 Mon Sep 17 00:00:00 2001 From: quietvoid <39477805+quietvoid@users.noreply.github.com> Date: Mon, 17 Jan 2022 16:28:37 -0500 Subject: [PATCH] Allow mode 2 to be used with profile 8 RPU Fixes #112 --- dolby_vision/CHANGELOG.md | 1 + dolby_vision/src/rpu/dovi_rpu.rs | 15 +++++++++++++-- src/dovi/tests.rs | 15 +++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/dolby_vision/CHANGELOG.md b/dolby_vision/CHANGELOG.md index 9a7a890..8b8c11f 100644 --- a/dolby_vision/CHANGELOG.md +++ b/dolby_vision/CHANGELOG.md @@ -1,6 +1,7 @@ ## ?? - Updated `bitvec` dependency to 1.0.0. +- Allowed noop conversion when converting a profile 8 RPU with mode 2. ## 1.6.1 diff --git a/dolby_vision/src/rpu/dovi_rpu.rs b/dolby_vision/src/rpu/dovi_rpu.rs index c6b6883..446baaf 100644 --- a/dolby_vision/src/rpu/dovi_rpu.rs +++ b/dolby_vision/src/rpu/dovi_rpu.rs @@ -269,6 +269,13 @@ impl DoviRpu { Ok(()) } + /// Modes: + /// 0: Don't modify the RPU + /// 1: Converts the RPU to be MEL compatible + /// 2: Converts the RPU to be profile 8.1 compatible + /// 3: Converts profile 5 to 8 + /// + /// noop when profile 8 and mode 2 is used pub fn convert_with_mode(&mut self, mode: u8) -> Result<()> { if mode != 0 { self.modified = true; @@ -282,8 +289,12 @@ impl DoviRpu { }; } else if self.dovi_profile == 5 && mode == 3 { self.p5_to_p81()?; - } else if self.dovi_profile == 8 && mode == 1 { - self.convert_to_mel()?; + } else if self.dovi_profile == 8 && (mode == 1 || mode == 2) { + match mode { + 1 => self.convert_to_mel()?, + 2 => self.modified = false, // Ignore conversion + _ => (), + }; } else if mode != 0 { bail!("Invalid profile for mode {} conversion!", mode); } diff --git a/src/dovi/tests.rs b/src/dovi/tests.rs index 4787f4a..09c6ea6 100644 --- a/src/dovi/tests.rs +++ b/src/dovi/tests.rs @@ -997,3 +997,18 @@ fn mel_variable_l8_length13() -> Result<()> { Ok(()) } + +#[test] +fn p8_bypass() -> Result<()> { + let (original_data, mut dovi_rpu) = _parse_file(PathBuf::from("./assets/tests/profile8.bin"))?; + assert_eq!(dovi_rpu.dovi_profile, 8); + let mut parsed_data = dovi_rpu.write_hevc_unspec62_nalu()?; + + assert_eq!(&original_data[4..], &parsed_data[2..]); + + dovi_rpu.convert_with_mode(2)?; + parsed_data = dovi_rpu.write_hevc_unspec62_nalu()?; + assert_eq!(&original_data[4..], &parsed_data[2..]); + + Ok(()) +}