Fixed thread continuity bug
This commit is contained in:
parent
2af75f5a39
commit
6b0cbecd79
15
output.txt
15
output.txt
File diff suppressed because one or more lines are too long
BIN
output.wav
BIN
output.wav
Binary file not shown.
@ -306,6 +306,8 @@ fn etch_instructions(settings: &Settings, data: &Data)
|
|||||||
u8_instructions.push(settings.size as u8);
|
u8_instructions.push(settings.size as u8);
|
||||||
u8_instructions.push(settings.fps as u8);
|
u8_instructions.push(settings.fps as u8);
|
||||||
let mut instruction_data = rip_binary(u8_instructions)?;
|
let mut instruction_data = rip_binary(u8_instructions)?;
|
||||||
|
//Instead of putting entire size of file, add at which frame and pixel file ends
|
||||||
|
//Saves space on instruction frame
|
||||||
instruction_data.extend(last_byte_pointer);
|
instruction_data.extend(last_byte_pointer);
|
||||||
|
|
||||||
//Here to make sure instruction frame and the rest are of the same size
|
//Here to make sure instruction frame and the rest are of the same size
|
||||||
@ -366,12 +368,17 @@ pub fn etch(path: &str, data: Data, settings: Settings) -> anyhow::Result<()> {
|
|||||||
match data.out_mode {
|
match data.out_mode {
|
||||||
OutputMode::Color => {
|
OutputMode::Color => {
|
||||||
let length = data.bytes.len();
|
let length = data.bytes.len();
|
||||||
|
|
||||||
|
//Required so that data is continuous between each thread
|
||||||
let chunk_size = (length / settings.threads) + 1;
|
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;
|
||||||
|
|
||||||
//UGLY DUPING
|
//UGLY DUPING
|
||||||
let chunks = data.bytes.chunks(chunk_size);
|
let chunks = data.bytes.chunks(chunk_size);
|
||||||
for chunk in chunks {
|
for chunk in chunks {
|
||||||
//source of perf loss ?
|
//source of perf loss ?
|
||||||
|
dbg!(chunk.len());
|
||||||
let chunk_copy = chunk.to_vec();
|
let chunk_copy = chunk.to_vec();
|
||||||
|
|
||||||
let thread = thread::spawn(move || {
|
let thread = thread::spawn(move || {
|
||||||
@ -397,7 +404,11 @@ pub fn etch(path: &str, data: Data, settings: Settings) -> anyhow::Result<()> {
|
|||||||
},
|
},
|
||||||
OutputMode::Binary => {
|
OutputMode::Binary => {
|
||||||
let length = data.binary.len();
|
let length = data.binary.len();
|
||||||
|
|
||||||
|
//Required so that data is continuous between each thread
|
||||||
let chunk_size = (length / settings.threads) + 1;
|
let chunk_size = (length / settings.threads) + 1;
|
||||||
|
let frame_size = (settings.width * settings.height) as usize;
|
||||||
|
let chunk_size = chunk_size / frame_size * frame_size + frame_size;
|
||||||
|
|
||||||
//UGLY DUPING
|
//UGLY DUPING
|
||||||
let chunks = data.binary.chunks(chunk_size);
|
let chunks = data.binary.chunks(chunk_size);
|
||||||
@ -494,3 +505,32 @@ pub fn read(path: &str, threads: usize) -> anyhow::Result<Vec<u8>> {
|
|||||||
println!("Video read succesfully");
|
println!("Video read succesfully");
|
||||||
return Ok(byte_data);
|
return Ok(byte_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// pub fn read(path: &str, threads: usize) -> anyhow::Result<Vec<u8>> {
|
||||||
|
// let instruction_size = 5;
|
||||||
|
|
||||||
|
// let mut video = VideoCapture::from_file(&path, CAP_ANY)
|
||||||
|
// .expect("Could not open video path");
|
||||||
|
// let mut frame = Mat::default();
|
||||||
|
|
||||||
|
// //Could probably avoid cloning
|
||||||
|
// video.read(&mut frame)?;
|
||||||
|
// let instruction_source = EmbedSource::from(frame.clone(), instruction_size);
|
||||||
|
// let (out_mode, settings) = read_instructions(&instruction_source, threads)?;
|
||||||
|
|
||||||
|
// let mut frames = Vec::new();
|
||||||
|
// loop {
|
||||||
|
// // let _timer = Timer::new("Reading frame (clone included)");
|
||||||
|
// video.read(&mut frame)?;
|
||||||
|
|
||||||
|
// //If it reads an empty image, the video stopped
|
||||||
|
// if frame.cols() == 0 {
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// frames.push(frame.clone())
|
||||||
|
// }
|
||||||
|
|
||||||
|
// println!("Video read succesfully");
|
||||||
|
// return Ok(Vec::new());
|
||||||
|
// }
|
@ -17,10 +17,10 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
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: original size * 8 * block size^2 = new size)");
|
||||||
println!("3. Upload the video to your YouTube channel. You probably want to keep it up as unlisted");
|
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!("4. Use the download option to get the video back");
|
||||||
println!("5. Use the dislodge option to get your files 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");
|
||||||
|
|
||||||
println!("\nI coudln't figure out a weird bug where if you set the size to something that isn't a factor of the height");
|
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");
|
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?;
|
ui::summon_gooey().await?;
|
||||||
|
@ -79,7 +79,7 @@ fn embed_path() -> anyhow::Result<()> {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let path = Text::new("What is the path to your file ?")
|
let path = Text::new("What is the path to your file ?")
|
||||||
.with_default("src/tests/Baby.wav")
|
.with_default("src/tests/test.txt")
|
||||||
.prompt().unwrap();
|
.prompt().unwrap();
|
||||||
|
|
||||||
let (width, height) = match resolution {
|
let (width, height) = match resolution {
|
||||||
@ -144,7 +144,7 @@ fn dislodge_path() -> anyhow::Result<()> {
|
|||||||
.prompt().unwrap();
|
.prompt().unwrap();
|
||||||
|
|
||||||
let out_path = Text::new("Where should the output go ?")
|
let out_path = Text::new("Where should the output go ?")
|
||||||
.with_default("output.wav")
|
.with_default("output.txt")
|
||||||
.with_help_message("Please include name of file and extension")
|
.with_help_message("Please include name of file and extension")
|
||||||
.prompt().unwrap();
|
.prompt().unwrap();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user