diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 52ec61e..0000000 Binary files a/.DS_Store and /dev/null differ diff --git a/note.txt b/note.txt index 7457d3f..f7517fc 100644 --- a/note.txt +++ b/note.txt @@ -18,6 +18,7 @@ Add standard loadout Realistic goals: 1.Standard sets of options + Fix weird bug with size 3 and empty bits 2.Test with archives 3.Benchmark 4.Make executable diff --git a/src/etcher.rs b/src/etcher.rs index 88ddef2..a3c8259 100644 --- a/src/etcher.rs +++ b/src/etcher.rs @@ -223,14 +223,14 @@ fn etch_color(source: &mut EmbedSource, data: &Vec, 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)?;