From e0f55200ee4eb4d3368ac12b15926975290cac13 Mon Sep 17 00:00:00 2001 From: HistidineDwarf Date: Tue, 14 Feb 2023 21:40:46 -0800 Subject: [PATCH] Tested presets --- .DS_Store | Bin 6148 -> 0 bytes note.txt | 1 + src/etcher.rs | 28 +++++++++++++++------------- src/ui.rs | 5 +++-- 4 files changed, 19 insertions(+), 15 deletions(-) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 52ec61e32ed90495f8ad918f18882a696bd244f3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKPfNov6i?iA8AIqn(PO~tzzzQ~yp%e>fE7Kc%yu1Gtj%aQdl-XW^$Yn;{5-yw zq~LG|Pa^I;NPaKxPn!IoNgiX2d()`Pn8O$o&=5H)O9ahJU28VD2FP)ad>ke!gwcCA zw!Xg(xb_;$S;mH8@pb)4oKHHP5588buWvL&L$t)5|ELOo5=^GK7i2d$x>PC&D?JFW z;!!bhw$4;K3F35=>4Z2MLCEcOoJOkf)HIE9o$DKiXo}{**_q8wj(Tl*a6E5IP`ho} z>mJVMO|iYVe|j-^N}f~oYS`pJww6tc6}*9BHxuQQy0W8%7RU#oV zKnxHA#K0;sU~d7@TBS|XUWox>;71JL`5>Vox)w`=`sjd8mjHluFlzxFYYEJe7F~;_ zLGXZZlL}~3xh*lcNe8>MajwPEph;)k79ZSxxhh_`{yNMrbvWa$LF$PCVqlR0tbIWo zy#LSPmswim>k#UQ0b=04GQjJ7zwg2B?A`ippLo|wX!p=iFs?)e1oVYR01WUP+0{, global_index: &mut usize data[local_index+1],//Green data[local_index+2] //Blue ]; - //Increment index so we move along the data - *global_index += 3; - - if *global_index+2 >= data.len() - 1 { - return Err(Error::msg("Index beyond data")); - } etch_pixel(source, rgb, x, y).unwrap(); + + //Increment index so we move along the data + *global_index += 3; + if *global_index+2 >= data.len() { + return Err(Error::msg("Index beyond data")); + } } } @@ -409,17 +409,19 @@ pub fn etch(path: &str, data: Data, settings: Settings) -> anyhow::Result<()> { OutputMode::Color => { let length = data.bytes.len(); - //let frame_data_size = frame_size / settings.size.pow(2) as usize; + //UGLY //Required so that data is continuous between each thread - let chunk_size = (length / settings.threads) + 1; - let frame_size = (settings.width * settings.height) as usize * 3; - let chunk_size = chunk_size / frame_size * frame_size + frame_size; + let frame_size = (settings.width * settings.height) as usize; + let frame_data_size = frame_size / settings.size.pow(2) as usize * 3; + let frame_length = length / frame_data_size; + let chunk_frame_size = (frame_length / settings.threads) + 1; + let chunk_data_size = chunk_frame_size * frame_data_size; //UGLY DUPING - let chunks = data.bytes.chunks(chunk_size); + let chunks = data.bytes.chunks(chunk_data_size); for chunk in chunks { //source of perf loss ? - let chunk_copy = chunk.to_vec(); + let chunk_copy = chunk.to_vec(); let thread = thread::spawn(move || { let mut frames = Vec::new(); @@ -431,7 +433,7 @@ pub fn etch(path: &str, data: Data, settings: Settings) -> anyhow::Result<()> { Ok(_) => frames.push(source), Err(v) => { frames.push(source); - println!("Reached the end of data"); + println!("Embedding thread complete!"); break;}, } } diff --git a/src/ui.rs b/src/ui.rs index dbd676c..f5a87a3 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -65,7 +65,8 @@ fn embed_path() -> anyhow::Result<()> { let bytes = etcher::rip_bytes(&path)?; let data = Data::from_color(bytes); - let settings = Settings::new(1, 8, 30, 1280, 720); + // let settings = Settings::new(1, 8, 1, 640, 360); + let settings = Settings::new(1, 8, 30, 256, 144); etcher::etch("output.avi", data, settings)?; @@ -87,7 +88,7 @@ fn embed_path() -> anyhow::Result<()> { let binary = etcher::rip_binary(bytes)?; let data = Data::from_binary(binary); - let settings = Settings::new(3, 8, 10, 640, 360); + let settings = Settings::new(4, 8, 10, 1280, 720); etcher::etch("output.avi", data, settings)?;