diff --git a/Cargo.lock b/Cargo.lock index 69cc003..408e0cc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -494,7 +494,7 @@ checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" [[package]] name = "dolby_vision" -version = "3.1.0" +version = "3.1.1" dependencies = [ "anyhow", "bitvec", @@ -509,7 +509,7 @@ dependencies = [ [[package]] name = "dovi_tool" -version = "2.0.1" +version = "2.0.2" dependencies = [ "anyhow", "assert_cmd", @@ -809,9 +809,9 @@ dependencies = [ [[package]] name = "hevc_parser" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce7a8f2b967679b2d12bf851b0c68f3cbc7a4dcf3b5ca063fd9b3efe37f8a5a4" +checksum = "e447b63b4e80dac36e368a9d147d7ba212b4c4b10c516312137f39cea60ff617" dependencies = [ "anyhow", "bitvec_helpers", diff --git a/Cargo.toml b/Cargo.toml index ca4c21d..25ff712 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dovi_tool" -version = "2.0.1" +version = "2.0.2" authors = ["quietvoid"] edition = "2021" rust-version = "1.64.0" @@ -18,7 +18,7 @@ members = [ [dependencies] bitvec_helpers = { version = "3.1.2", default-features = false, features = ["bitstream-io"] } -hevc_parser = { version = "0.6.0", features = ["hevc_io"] } +hevc_parser = { version = "0.6.1", features = ["hevc_io"] } dolby_vision = { path = "dolby_vision", "features" = ["xml", "serde"] } madvr_parse = "1.0.1" diff --git a/README.md b/README.md index 21f3fe2..8482091 100644 --- a/README.md +++ b/README.md @@ -209,9 +209,11 @@ For working with an HEVC source file, there are multiple options that apply to m **Flags**: - `--eos-before-el` Write the EOS/EOB NALUs before the EL. Defaults to `false`. - This flag enables the same behaviour as MakeMKV and yusesope's mux script. + This flag enables the same behaviour yusesope's mux script. Enabling this therefore results in identical output using **`dovi_tool`**. + In recent versions of `MakeMKV`, EOS/EOB NALUs are removed. + - `--no-add-aud` Disable adding AUD NALUs between frames - `--discard` Discard the EL while muxing. This is equivalent to injecting the RPU, but without extracting first. diff --git a/assets/tests/source_p5_to_p8_001_end_crc32.bin b/assets/tests/source_p5_to_p8_001_end_crc32.bin new file mode 100644 index 0000000..8f1c316 Binary files /dev/null and b/assets/tests/source_p5_to_p8_001_end_crc32.bin differ diff --git a/dolby_vision/CHANGELOG.md b/dolby_vision/CHANGELOG.md index d18f02c..3e74dfa 100644 --- a/dolby_vision/CHANGELOG.md +++ b/dolby_vision/CHANGELOG.md @@ -1,3 +1,6 @@ +## 3.1.1 +- Fixed RPU writing edge case that resulted in non conformant NALU bytes when using `write_hevc_unspec62_nalu`. + ## 3.1.0 - Conversion mode 2 now defaults to remove luma and chroma mapping by default, only for profile 7 FEL. - Added `ConversionMode::To81MappingPreserved` for old mode 2 behaviour. diff --git a/dolby_vision/Cargo.toml b/dolby_vision/Cargo.toml index fe07f3b..a301929 100644 --- a/dolby_vision/Cargo.toml +++ b/dolby_vision/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dolby_vision" -version = "3.1.0" +version = "3.1.1" authors = ["quietvoid"] edition = "2021" rust-version = "1.60.0" diff --git a/dolby_vision/src/utils.rs b/dolby_vision/src/utils.rs index ba309cb..c734177 100644 --- a/dolby_vision/src/utils.rs +++ b/dolby_vision/src/utils.rs @@ -62,7 +62,7 @@ pub fn add_start_code_emulation_prevention_3_byte(data: &mut Vec) { let mut i = 0; while i < count { - if i > 2 && i < count - 2 && data[i - 2] == 0 && data[i - 1] == 0 && data[i] <= 3 { + if i > 2 && data[i - 2] == 0 && data[i - 1] == 0 && data[i] <= 3 { data.insert(i, 3); count += 1; } diff --git a/src/tests/rpu.rs b/src/tests/rpu.rs index 6252ff0..2734e12 100644 --- a/src/tests/rpu.rs +++ b/src/tests/rpu.rs @@ -4,7 +4,7 @@ use std::{io::Read, path::PathBuf}; use anyhow::Result; use dolby_vision::rpu::dovi_rpu::DoviRpu; -use dolby_vision::rpu::extension_metadata::blocks::ExtMetadataBlock; +use dolby_vision::rpu::extension_metadata::blocks::{ExtMetadataBlock, ExtMetadataBlockLevel6}; use dolby_vision::rpu::extension_metadata::{ColorPrimaries, MasteringDisplayPrimaries}; use dolby_vision::rpu::generate::GenerateConfig; use dolby_vision::rpu::rpu_data_nlq::DoviELType; @@ -1087,3 +1087,35 @@ fn fel_to_p81_preserve_mapping() -> Result<()> { Ok(()) } + +#[test] +fn source_p5_to_p8_001_end_crc32() -> Result<()> { + use dolby_vision::rpu::utils::parse_rpu_file; + + let mut rpus = parse_rpu_file(PathBuf::from( + "./assets/tests/source_p5_to_p8_001_end_crc32.bin", + ))?; + assert_eq!(rpus.len(), 1); + + let dovi_rpu = rpus.first_mut().unwrap(); + assert_eq!(5, dovi_rpu.dovi_profile); + assert_eq!([130, 214, 190, 85], dovi_rpu.rpu_data_crc32.to_be_bytes()); + + dovi_rpu.convert_with_mode(ConversionMode::To81)?; + dovi_rpu.set_active_area_offsets(0, 0, 69, 69)?; + + let vdr_dm_data = dovi_rpu.vdr_dm_data.as_mut().unwrap(); + vdr_dm_data.replace_metadata_level(ExtMetadataBlock::Level6(ExtMetadataBlockLevel6 { + max_display_mastering_luminance: 4000, + min_display_mastering_luminance: 50, + max_content_light_level: 2095, + max_frame_average_light_level: 46, + }))?; + + assert_eq!(8, dovi_rpu.dovi_profile); + let data = dovi_rpu.write_hevc_unspec62_nalu()?; + + assert_eq!([183, 0, 0, 3, 1, 128], &data[data.len() - 6..]); + + Ok(()) +}