From eb07109be80231ffa5a222b7d33ff78e17c187ac Mon Sep 17 00:00:00 2001 From: HistidineDwarf Date: Wed, 15 Feb 2023 08:11:29 -0800 Subject: [PATCH 1/3] Changed order of UI --- src/main.rs | 3 --- src/ui.rs | 5 ++++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 7c31703..3562e92 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,9 +20,6 @@ async fn main() -> anyhow::Result<()> { println!("5. Use the dislodge option to get your files back from the downloaded video"); println!("6. PROFIT. Enjoy being a leech on a huge corporation's servers"); - println!("\nI coudln't figure out a weird bug that happens if you set the size to something that isn't a factor of the height"); - println!("If you don't want the files you put in to come out as the audio/visual equivalent of a pipe bomb, account for the above bug\n"); - ui::summon_gooey().await?; // let bytes = etcher::rip_bytes("src/tests/Baby.wav")?; // let binary = etcher::rip_binary(bytes)?; diff --git a/src/ui.rs b/src/ui.rs index f5a87a3..6d6c74b 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -32,9 +32,9 @@ fn embed_path() -> anyhow::Result<()> { //Should use enums let presets = vec![ - "Maximum efficiency", "Optimal compression resistance", "Paranoid compression resistance", + "Maximum efficiency", "Custom" ]; @@ -102,6 +102,9 @@ fn embed_path() -> anyhow::Result<()> { .prompt() .unwrap(); + println!("\nI coudln't figure out a weird bug that happens if you set the size to something that isn't a factor of the height"); + println!("If you don't want the files you put in to come out as the audio/visual equivalent of a pipe bomb, account for the above bug\n"); + let size = CustomType::::new("What size should the blocks be ?") .with_error_message("Please type a valid number") .with_help_message("Bigger blocks are more resistant to compression, I recommend 2-5.") From 85d5984369442ac6e2652cad73559290023cb76c Mon Sep 17 00:00:00 2001 From: HistidineDwarf Date: Wed, 15 Feb 2023 10:30:45 -0800 Subject: [PATCH 2/3] Did benchmarking --- .gitignore | 3 ++- note.txt | 12 ++++++++++++ src/.DS_Store | Bin 6148 -> 6148 bytes src/etcher.rs | 5 ++++- src/main.rs | 2 +- src/timer.rs | 4 ++-- src/ui.rs | 2 +- 7 files changed, 22 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index b58d83e..3e2402f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ /src/out /output.avi /setting_tests -/output.txt \ No newline at end of file +/output.txt +/src/tests/morbius.webm \ No newline at end of file diff --git a/note.txt b/note.txt index f7517fc..8cc3a1e 100644 --- a/note.txt +++ b/note.txt @@ -30,6 +30,18 @@ After-project: Fix weird bug Code clean-up +Benchmark notes: +430 kb/s average, 4x size, optimal resistance +320 kb/s average, 11x-12x size, paranoid resistance +31.9 mb/s average, 1x size, maximum efficiency +(A lot of this time is just creating the file after the frames are made) + +~8.5ms per frame, optimal resistance +~5.8ms per frame, paranoid resistance +~0.16ms per frame, maximum efficiency + +Probably faster on paranoid because it has to read less ? + diff --git a/src/.DS_Store b/src/.DS_Store index 5694a67206553fcc096096fbfa219b329f489b1f..35935be03f927adc25edc965827a215ef1adcd8c 100644 GIT binary patch delta 76 zcmZoMXfc=|#>B)qu~2NHo+2aj#DLw41(+BanJ4ow-semyPR>cn&(C4le3wy}bu&8$ eKL=3lW=5v(%#-;=EIAk%7=Va@VRL}U7G?kjUJ_0K delta 68 zcmZoMXfc=|#>B`mu~2NHo+2aD#DLwC4MbQb^E2Jq%*4#fy0Jl=aWgvyKL=3FW)+c7G?ldEf0hM diff --git a/src/etcher.rs b/src/etcher.rs index a3c8259..5732464 100644 --- a/src/etcher.rs +++ b/src/etcher.rs @@ -171,7 +171,7 @@ fn etch_pixel(frame: &mut EmbedSource, rgb: Vec, x: i32, y: i32) -> anyhow:: fn etch_bw(source: &mut EmbedSource, data: &Vec, global_index: &mut usize) -> anyhow::Result<()> { - // let _timer = Timer::new("Etching frame"); + let _timer = Timer::new("Etching frame"); let width = source.actual_size.width; let height = source.actual_size.height; @@ -208,6 +208,7 @@ fn etch_bw(source: &mut EmbedSource, data: &Vec, global_index: &mut usize) fn etch_color(source: &mut EmbedSource, data: &Vec, global_index: &mut usize) -> anyhow::Result<()>{ + let _timer = Timer::new("Etching frame"); let width = source.actual_size.width; let height = source.actual_size.height; @@ -335,6 +336,7 @@ fn etch_instructions(settings: &Settings, data: &Data) final_frame += 1; } + dbg!(final_frame); u32_instructions.push(final_frame as u32); u32_instructions.push(final_byte as u32); }, @@ -350,6 +352,7 @@ fn etch_instructions(settings: &Settings, data: &Data) final_frame += 1; } + dbg!(final_frame); u32_instructions.push(final_frame as u32); u32_instructions.push(final_byte as u32); }, diff --git a/src/main.rs b/src/main.rs index 3562e92..217be88 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,7 +18,7 @@ async fn main() -> anyhow::Result<()> { println!("3. Upload the video to your YouTube channel. You probably want to keep it up as unlisted"); println!("4. Use the download option to get the video back"); println!("5. Use the dislodge option to get your files back from the downloaded video"); - println!("6. PROFIT. Enjoy being a leech on a huge corporation's servers"); + println!("6. PROFIT. Enjoy being a leech on a huge corporation's servers\n"); ui::summon_gooey().await?; // let bytes = etcher::rip_bytes("src/tests/Baby.wav")?; diff --git a/src/timer.rs b/src/timer.rs index 6206f8d..dab85c7 100644 --- a/src/timer.rs +++ b/src/timer.rs @@ -12,9 +12,9 @@ impl Drop for Timer { let millis = self.time.elapsed().as_millis(); if micros < 10000 { - println!("{} ended in {}us", self.title, self.time.elapsed().as_micros()); + println!("{} ended in {}us", self.title, micros); } else { - println!("{} ended in {}ms", self.title, self.time.elapsed().as_millis()); + println!("{} ended in {}ms", self.title, millis); } } diff --git a/src/ui.rs b/src/ui.rs index 6d6c74b..8ba6d8f 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -88,7 +88,7 @@ fn embed_path() -> anyhow::Result<()> { let binary = etcher::rip_binary(bytes)?; let data = Data::from_binary(binary); - let settings = Settings::new(4, 8, 10, 1280, 720); + let settings = Settings::new(4, 8, 30, 1280, 720); etcher::etch("output.avi", data, settings)?; From 9ab75f281f8088d9cb53d03b32f90c546c810d2e Mon Sep 17 00:00:00 2001 From: HistidineDwarf Date: Wed, 15 Feb 2023 16:12:06 -0800 Subject: [PATCH 3/3] Reading benchmark start --- src/.DS_Store | Bin 6148 -> 6148 bytes src/etcher.rs | 5 +++++ src/main.rs | 13 +------------ src/ui.rs | 4 ++-- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/.DS_Store b/src/.DS_Store index 35935be03f927adc25edc965827a215ef1adcd8c..82859caadea0436fbcedbcf5b884515e67de3a08 100644 GIT binary patch delta 14 VcmZoMXffFEnTe5c^A{!oQ2;3j1l|Au delta 14 VcmZoMXffFEnTe5M^A{!oQ2;3d1l<4t diff --git a/src/etcher.rs b/src/etcher.rs index 5732464..8d17f20 100644 --- a/src/etcher.rs +++ b/src/etcher.rs @@ -239,6 +239,8 @@ fn etch_color(source: &mut EmbedSource, data: &Vec, global_index: &mut usize } fn read_bw(source: &EmbedSource, current_frame: i32, final_frame: i32, final_bit: i32) -> anyhow::Result>{ + let _timer = Timer::new("Dislodging frame"); + let width = source.actual_size.width; let height = source.actual_size.height; let size = source.size as usize; @@ -271,6 +273,8 @@ fn read_bw(source: &EmbedSource, current_frame: i32, final_frame: i32, final_bit } fn read_color(source: &EmbedSource, current_frame: i32, final_frame: i32, final_byte: i32) -> anyhow::Result>{ + let _timer = Timer::new("Dislodging frame"); + let width = source.actual_size.width; let height = source.actual_size.height; let size = source.size as usize; @@ -520,6 +524,7 @@ pub fn etch(path: &str, data: Data, settings: Settings) -> anyhow::Result<()> { } pub fn read(path: &str, threads: usize) -> anyhow::Result> { + let _timer = Timer::new("Dislodging frame"); let instruction_size = 5; let mut video = VideoCapture::from_file(&path, CAP_ANY) diff --git a/src/main.rs b/src/main.rs index 217be88..421d2a1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,24 +14,13 @@ async fn main() -> anyhow::Result<()> { println!("This tool allows you to turn any file into a compression-resistant video that can be uploaded to YouTube for Infinite Storage:tm:"); println!("\nHow to use:"); println!("1. Zip all the files you will be uploading"); - println!("2. Use the embed option on the archive (THE VIDEO WILL BE SEVERAL TIMES LARGER THAN THE FILE: original size * 8 * block size^2 = new size)"); + println!("2. Use the embed option on the archive (THE VIDEO WILL BE SEVERAL TIMES LARGER THAN THE FILE, 4x in case of optimal compression resistance preset)"); println!("3. Upload the video to your YouTube channel. You probably want to keep it up as unlisted"); println!("4. Use the download option to get the video back"); println!("5. Use the dislodge option to get your files back from the downloaded video"); println!("6. PROFIT. Enjoy being a leech on a huge corporation's servers\n"); ui::summon_gooey().await?; - // let bytes = etcher::rip_bytes("src/tests/Baby.wav")?; - // let binary = etcher::rip_binary(bytes)?; - - // let data = Data::from_binary(binary); - // let settings = Settings::new(1, 30, 640, 360); - - // etcher::etch("src/out/output.avi", data, settings)?; - - // let out_data = etcher::read("src/out/output.avi")?; - - // etcher::write_bytes("src/out/Baby2.wav", out_data)?; return Ok(()); } diff --git a/src/ui.rs b/src/ui.rs index 8ba6d8f..722591c 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -114,7 +114,7 @@ fn embed_path() -> anyhow::Result<()> { let threads = CustomType::::new("How many threads to dedicate for processing ?") .with_error_message("Please type a valid number") .with_help_message("The more threads, the merrier") - .with_default(4) + .with_default(8) .prompt()?; let out_mode = match out_mode { @@ -205,7 +205,7 @@ fn dislodge_path() -> anyhow::Result<()> { let threads = CustomType::::new("How many threads to dedicate for processing ?") .with_error_message("Please type a valid number") .with_help_message("The more threads, the merrier") - .with_default(4) + .with_default(8) .prompt()?; let out_data = etcher::read(&in_path, threads)?;