From c9962283fdf96670474b9eefb07ac2cbce7badae Mon Sep 17 00:00:00 2001 From: quietvoid <39477805+quietvoid@users.noreply.github.com> Date: Fri, 11 Nov 2022 23:51:25 -0500 Subject: [PATCH] Add `source_rpu` and `rpu_levels` to edit config Fixes #188 --- Cargo.lock | 159 +++++++----------- Cargo.toml | 12 +- assets/editor_examples/source_rpu.json | 4 + assets/tests/source_rpu_replaced_fel_orig.bin | Bin 0 -> 385 bytes docs/editor.md | 13 +- dolby_vision/CHANGELOG.md | 3 + dolby_vision/Cargo.toml | 2 +- dolby_vision/src/rpu/dovi_rpu.rs | 17 ++ dolby_vision/src/rpu/vdr_dm_data.rs | 12 ++ src/dovi/editor.rs | 32 ++++ src/dovi/generator.rs | 2 + tests/rpu/editor.rs | 29 ++++ 12 files changed, 179 insertions(+), 106 deletions(-) create mode 100644 assets/editor_examples/source_rpu.json create mode 100644 assets/tests/source_rpu_replaced_fel_orig.bin diff --git a/Cargo.lock b/Cargo.lock index f4a936e..99e802c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,11 +19,11 @@ checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6" [[package]] name = "assert_cmd" -version = "2.0.5" +version = "2.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5c2ca00549910ec251e3bd15f87aeeb206c9456b9a77b43ff6c97c54042a472" +checksum = "ba45b8163c49ab5f972e59a8a5a03b6d2972619d486e19ec9fe744f7c2753d3c" dependencies = [ - "bstr", + "bstr 1.0.1", "doc-comment", "predicates", "predicates-core", @@ -33,9 +33,9 @@ dependencies = [ [[package]] name = "assert_fs" -version = "1.0.7" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf09bb72e00da477c2596865e8873227e2196d263cca35414048875dbbeea1be" +checksum = "1429b32ede0cb31afd9f6cb1e8f06f1e32a4c75ed9290f9f4d3cda0c5981e061" dependencies = [ "doc-comment", "globwalk", @@ -97,9 +97,19 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" dependencies = [ - "lazy_static", "memchr", +] + +[[package]] +name = "bstr" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fca0852af221f458706eb0725c03e4ed6c46af9ac98e6a689d5e634215d594dd" +dependencies = [ + "memchr", + "once_cell", "regex-automata", + "serde", ] [[package]] @@ -110,9 +120,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "cc" -version = "1.0.74" +version = "1.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "581f5dba903aac52ea3feb5ec4810848460ee833876f1f9b0fdeab1f19091574" +checksum = "76a284da2e6fe2092f2353e51713435363112dfd60030e22add80be333fb928f" dependencies = [ "jobserver", ] @@ -125,9 +135,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.0.18" +version = "4.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "335867764ed2de42325fafe6d18b8af74ba97ee0c590fa016f157535b42ab04b" +checksum = "0eb41c13df48950b20eb4cd0eefa618819469df1bffc49d11e8487c4ba0037e5" dependencies = [ "atty", "bitflags", @@ -136,14 +146,14 @@ dependencies = [ "once_cell", "strsim", "termcolor", - "terminal_size 0.2.1", + "terminal_size 0.2.2", ] [[package]] name = "clap_derive" -version = "4.0.18" +version = "4.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16a1b0f6422af32d5da0c58e2703320f379216ee70198241c84173a8c5ac28f3" +checksum = "0177313f9f02afc995627906bbd8967e2be069f5261954222dac78290c2b9014" dependencies = [ "heck", "proc-macro-error", @@ -213,7 +223,7 @@ checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" [[package]] name = "dolby_vision" -version = "2.0.0" +version = "2.0.1" dependencies = [ "anyhow", "bitvec", @@ -371,7 +381,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0a1e17342619edbc21a964c2afbeb6c820c6a2560032872f397bb97ea127bd0a" dependencies = [ "aho-corasick", - "bstr", + "bstr 0.2.17", "fnv", "log", "regex", @@ -461,12 +471,13 @@ dependencies = [ [[package]] name = "indicatif" -version = "0.17.1" +version = "0.17.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfddc9561e8baf264e0e45e197fd7696320026eb10a8180340debc27b18f535b" +checksum = "4295cbb7573c16d310e99e713cf9e75101eb190ab31fccd35f2d2691b4352b19" dependencies = [ "console", "number_prefix", + "portable-atomic", "unicode-width", ] @@ -607,15 +618,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "num_threads" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44" -dependencies = [ - "libc", -] - [[package]] name = "number_prefix" version = "0.4.0" @@ -630,9 +632,9 @@ checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" [[package]] name = "os_str_bytes" -version = "6.3.1" +version = "6.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3baf96e39c5359d2eb0dd6ccb42c62b91d9678aa68160d261b9e0ccbf9e9dea9" +checksum = "7b5bf27447411e9ee3ff51186bf7a08e16c341efdde93f4d823e8844429bed7e" [[package]] name = "percent-encoding" @@ -646,11 +648,17 @@ version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" +[[package]] +name = "portable-atomic" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15eb2c6e362923af47e13c23ca5afb859e83d54452c55b0b9ac763b8f7c1ac16" + [[package]] name = "predicates" -version = "2.1.1" +version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5aab5be6e4732b473071984b3164dbbfb7a3674d30ea5ff44410b6bcd960c3c" +checksum = "ab68289ded120dcbf9d571afcf70163233229052aec9b08ab09532f698d0e1e6" dependencies = [ "difflib", "float-cmp", @@ -662,15 +670,15 @@ dependencies = [ [[package]] name = "predicates-core" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da1c2388b1513e1b605fcec39a95e0a9e8ef088f71443ef37099fa9ae6673fcb" +checksum = "a6e7125585d872860e9955ca571650b27a4979c5823084168c5ed5bbfb016b56" [[package]] name = "predicates-tree" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d86de6de25020a36c6d3643a86d9a6a9f552107c0559c60ea03551b5e16c032" +checksum = "ad3f7fa8d61e139cbc7c3edfebf3b6678883a53f5ffac65d1259329a93ee43a5" dependencies = [ "predicates-core", "termtree", @@ -735,9 +743,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" +checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a" dependencies = [ "aho-corasick", "memchr", @@ -752,9 +760,9 @@ checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" [[package]] name = "regex-syntax" -version = "0.6.27" +version = "0.6.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" +checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" [[package]] name = "remove_dir_all" @@ -785,7 +793,7 @@ dependencies = [ "io-lifetimes", "libc", "linux-raw-sys", - "windows-sys 0.42.0", + "windows-sys", ] [[package]] @@ -899,19 +907,19 @@ dependencies = [ [[package]] name = "terminal_size" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8440c860cf79def6164e4a0a983bcc2305d82419177a0e0c71930d049e3ac5a1" +checksum = "40ca90c434fd12083d1a6bdcbe9f92a14f96c8a1ba600ba451734ac334521f7a" dependencies = [ "rustix", - "windows-sys 0.36.1", + "windows-sys", ] [[package]] name = "termtree" -version = "0.2.4" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "507e9898683b6c43a9aa55b64259b721b52ba226e0f3779137e50ad114a4c90b" +checksum = "95059e91184749cb66be6dc994f67f182b6d897cb3df74a5bf66b5e709295fd8" [[package]] name = "thiserror" @@ -944,13 +952,11 @@ dependencies = [ [[package]] name = "time" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fab5c8b9980850e06d92ddbe3ab839c062c801f3927c0fb8abd6fc8e918fbca" +checksum = "a561bf4617eebd33bca6434b988f39ed798e527f51a1e797d0ee4f61c0a38376" dependencies = [ "itoa", - "libc", - "num_threads", "serde", "time-core", "time-macros", @@ -964,9 +970,9 @@ checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" [[package]] name = "time-macros" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65bb801831d812c562ae7d2bfb531f26e66e4e1f6b17307ba4149c5064710e5b" +checksum = "d967f99f534ca7e495c575c62638eebc2898a8c84c119b89e250477bc4ba16b2" dependencies = [ "time-core", ] @@ -1103,19 +1109,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows-sys" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" -dependencies = [ - "windows_aarch64_msvc 0.36.1", - "windows_i686_gnu 0.36.1", - "windows_i686_msvc 0.36.1", - "windows_x86_64_gnu 0.36.1", - "windows_x86_64_msvc 0.36.1", -] - [[package]] name = "windows-sys" version = "0.42.0" @@ -1123,12 +1116,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" dependencies = [ "windows_aarch64_gnullvm", - "windows_aarch64_msvc 0.42.0", - "windows_i686_gnu 0.42.0", - "windows_i686_msvc 0.42.0", - "windows_x86_64_gnu 0.42.0", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", "windows_x86_64_gnullvm", - "windows_x86_64_msvc 0.42.0", + "windows_x86_64_msvc", ] [[package]] @@ -1137,48 +1130,24 @@ version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" -[[package]] -name = "windows_aarch64_msvc" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" - [[package]] name = "windows_aarch64_msvc" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" -[[package]] -name = "windows_i686_gnu" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" - [[package]] name = "windows_i686_gnu" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" -[[package]] -name = "windows_i686_msvc" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" - [[package]] name = "windows_i686_msvc" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" -[[package]] -name = "windows_x86_64_gnu" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" - [[package]] name = "windows_x86_64_gnu" version = "0.42.0" @@ -1191,12 +1160,6 @@ version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" -[[package]] -name = "windows_x86_64_msvc" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" - [[package]] name = "windows_x86_64_msvc" version = "0.42.0" diff --git a/Cargo.toml b/Cargo.toml index 9db1728..49d46e8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,18 +14,18 @@ dolby_vision = { path = "dolby_vision", "features" = ["xml", "serde_feature"] } madvr_parse = "1.0.1" anyhow = "1.0.66" -clap = { version = "4.0.18", features = ["derive", "wrap_help", "deprecated"] } -indicatif = "0.17.1" -regex = "1.6.0" +clap = { version = "4.0.23", features = ["derive", "wrap_help", "deprecated"] } +indicatif = "0.17.2" +regex = "1.7.0" bitvec = "1.0.1" serde = { version = "1.0.147", features = ["derive"] } serde_json = { version = "1.0.87", features = ["preserve_order"] } itertools = "0.10.5" [dev-dependencies] -assert_cmd = "2.0.5" -assert_fs = "1.0.7" -predicates = "2.1.1" +assert_cmd = "2.0.6" +assert_fs = "1.0.9" +predicates = "2.1.2" [build-dependencies] vergen = { version = "7.4.2", default-features = false, features = ["build", "git", "cargo"] } diff --git a/assets/editor_examples/source_rpu.json b/assets/editor_examples/source_rpu.json new file mode 100644 index 0000000..b9d0fd2 --- /dev/null +++ b/assets/editor_examples/source_rpu.json @@ -0,0 +1,4 @@ +{ + "source_rpu": "assets/tests/cmv40_full_rpu.bin", + "rpu_levels": [1, 4, 6] +} diff --git a/assets/tests/source_rpu_replaced_fel_orig.bin b/assets/tests/source_rpu_replaced_fel_orig.bin new file mode 100644 index 0000000000000000000000000000000000000000..c17aaa6bdf2821d62a38553d62a2a0947a9470eb GIT binary patch literal 385 zcmZQzU|^Kw;N);fGz(a#z@Wgv#LxgD>Ko+$F#JEj`2QCJ12ZEKGhAR`;9y{2YhYk- zU|=u-iZFp>7BDafFfj0f6aZy17#LW9OlF`81qKGLwwuqY_1o?xFcs-CBH+wv(NS$eDhcid;YcFUU%qh?Bj**SA4ki8j{4km}bXD z2Jl_(k2sR!chE{CLg&AMa&T_=?rl#5J*+29OA*fOKbL)2`kKP8yAIL&zN8o?Z2Tbo z>D}*7OCNncvt{+?GnUQe^GY)er5QYc&Sn9*+(8KFVn&do1y~w@t_6xRu&bsqFqpnl zP5b%hwTx<-%PEl0KwbiR7)r>PDLFH?am5+*v5J6Xm)S-A{|}Odq67v0hKGR-1{@5I voHH8^XejpnP;KB~NOWLe0)-O;2P=qV(hv*~;$gqQz{GxmSs}f6-t`6m^t5kb literal 0 HcmV?d00001 diff --git a/docs/editor.md b/docs/editor.md index 110821b..306fd26 100644 --- a/docs/editor.md +++ b/docs/editor.md @@ -6,6 +6,7 @@ When doing HEVC operations, some capabilities are not supported: - Editing the active area for specific ranges of frames. Only `"all"` edit is supported. - Removing or duplicating RPUs. - Editing scene cuts. +- Replacing metadata from a second RPU file.   @@ -120,6 +121,16 @@ The editor expects a JSON config like the example below: }, // Level 255 extension block structure - "level255": ExtMetadataBlockLevel255 + "level255": ExtMetadataBlockLevel255, + + // Source RPU file to use metadata from + // The RPUs must have the same length, after the `remove` pass. + // + // Path must be absolute. + "source_rpu": string, + + // Levels to replace using metadata from `source_rpu` + // List of integers representing block levels + "rpu_levels": int[], } ``` diff --git a/dolby_vision/CHANGELOG.md b/dolby_vision/CHANGELOG.md index e3fb85b..a307326 100644 --- a/dolby_vision/CHANGELOG.md +++ b/dolby_vision/CHANGELOG.md @@ -1,5 +1,8 @@ ## ?? +## 2.0.1 +- Added `replace_levels_from_rpu` function to `DoviRpu`. + ## 2.0.0 - Modified `extension_metadata::blocks` parsing functions to return a `Result`. diff --git a/dolby_vision/Cargo.toml b/dolby_vision/Cargo.toml index 586415a..db1806d 100644 --- a/dolby_vision/Cargo.toml +++ b/dolby_vision/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dolby_vision" -version = "2.0.0" +version = "2.0.1" authors = ["quietvoid"] edition = "2021" rust-version = "1.60.0" diff --git a/dolby_vision/src/rpu/dovi_rpu.rs b/dolby_vision/src/rpu/dovi_rpu.rs index e8fca06..351d1ca 100644 --- a/dolby_vision/src/rpu/dovi_rpu.rs +++ b/dolby_vision/src/rpu/dovi_rpu.rs @@ -546,4 +546,21 @@ impl DoviRpu { Ok(()) } + + pub fn replace_levels_from_rpu(&mut self, src_rpu: &Self, levels: &Vec) -> Result<()> { + ensure!(!levels.is_empty(), "Must have levels to replace"); + + if let (Some(dst_vdr_dm_data), Some(src_vdr_dm_data)) = + (self.vdr_dm_data.as_mut(), src_rpu.vdr_dm_data.as_ref()) + { + self.modified = true; + + for level in levels { + dst_vdr_dm_data + .replace_metadata_blocks(src_vdr_dm_data.level_blocks_iter(*level))?; + } + } + + Ok(()) + } } diff --git a/dolby_vision/src/rpu/vdr_dm_data.rs b/dolby_vision/src/rpu/vdr_dm_data.rs index cb11222..24e0b65 100644 --- a/dolby_vision/src/rpu/vdr_dm_data.rs +++ b/dolby_vision/src/rpu/vdr_dm_data.rs @@ -394,6 +394,18 @@ impl VdrDmData { } } + /// Clones every block to replace + pub fn replace_metadata_blocks<'a, I>(&mut self, blocks: I) -> Result<()> + where + I: Iterator, + { + for block in blocks { + self.replace_metadata_block(block.clone())?; + } + + Ok(()) + } + pub fn set_p81_coeffs(&mut self) { self.ycc_to_rgb_coef0 = 9574; self.ycc_to_rgb_coef1 = 0; diff --git a/src/dovi/editor.rs b/src/dovi/editor.rs index e635896..ac42a84 100644 --- a/src/dovi/editor.rs +++ b/src/dovi/editor.rs @@ -60,6 +60,11 @@ pub struct EditConfig { level11: Option, #[serde(skip_serializing_if = "Option::is_none")] level255: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + source_rpu: Option, + #[serde(skip_serializing_if = "Option::is_none")] + rpu_levels: Option>, } #[derive(Serialize, Deserialize, Default, Debug, Clone)] @@ -213,6 +218,11 @@ impl EditConfig { active_area.execute(rpus)?; } + if let Some(source_rpu_path) = &self.source_rpu { + let source_rpus = parse_rpu_file(source_rpu_path)?; + self.replace_from_rpus(rpus, &source_rpus)?; + } + Ok(()) } @@ -450,6 +460,28 @@ impl EditConfig { Ok(()) } + + fn replace_from_rpus( + &self, + rpus: &mut [Option], + source_rpus: &Vec, + ) -> Result<()> { + println!("Replacing metadata levels from second RPU..."); + ensure!(rpus.len() == source_rpus.len()); + + let zip_iter = rpus.iter_mut().filter_map(|e| e.as_mut()).zip(source_rpus); + + let levels = self + .rpu_levels + .as_ref() + .expect("Levels to replace must be present"); + + for (dst_rpu, src_rpu) in zip_iter { + dst_rpu.replace_levels_from_rpu(src_rpu, levels)?; + } + + Ok(()) + } } impl ActiveArea { diff --git a/src/dovi/generator.rs b/src/dovi/generator.rs index 9487800..33c2a52 100644 --- a/src/dovi/generator.rs +++ b/src/dovi/generator.rs @@ -84,6 +84,8 @@ impl Generator { pub fn execute(&mut self) -> Result<()> { let mut config = if let Some(json_path) = &self.json_path { let json_file = File::open(json_path)?; + + println!("Reading generator config file..."); let mut config: GenerateConfig = serde_json::from_reader(&json_file)?; if let Some(hdr10plus_path) = &self.hdr10plus_path { diff --git a/tests/rpu/editor.rs b/tests/rpu/editor.rs index f5d0863..68cfccb 100644 --- a/tests/rpu/editor.rs +++ b/tests/rpu/editor.rs @@ -270,3 +270,32 @@ fn add_l9_l11() -> Result<()> { Ok(()) } + +#[test] +fn source_rpu() -> Result<()> { + let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME"))?; + let temp = assert_fs::TempDir::new().unwrap(); + + let input_rpu = Path::new("assets/tests/fel_orig.bin"); + let edit_config = Path::new("assets/editor_examples/source_rpu.json"); + + let output_rpu = temp.child("RPU.bin"); + let expected_rpu = Path::new("assets/tests/source_rpu_replaced_fel_orig.bin"); + + let assert = cmd + .arg(SUBCOMMAND) + .arg(input_rpu) + .arg("--json") + .arg(edit_config) + .arg("--rpu-out") + .arg(output_rpu.as_ref()) + .assert(); + + assert.success().stderr(predicate::str::is_empty()); + + output_rpu + .assert(predicate::path::is_file()) + .assert(predicate::path::eq_file(expected_rpu)); + + Ok(()) +}