Skip to content

Commit

Permalink
Allow mode 2 to be used with profile 8 RPU
Browse files Browse the repository at this point in the history
Fixes #112
  • Loading branch information
quietvoid committed Jan 17, 2022
1 parent c215a0a commit 1242bd5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
1 change: 1 addition & 0 deletions dolby_vision/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
15 changes: 13 additions & 2 deletions dolby_vision/src/rpu/dovi_rpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down
15 changes: 15 additions & 0 deletions src/dovi/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}

0 comments on commit 1242bd5

Please sign in to comment.