diff options
Diffstat (limited to 'lvc/src/bin')
-rw-r--r-- | lvc/src/bin/main.rs | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/lvc/src/bin/main.rs b/lvc/src/bin/main.rs index 7c0d965..6037855 100644 --- a/lvc/src/bin/main.rs +++ b/lvc/src/bin/main.rs @@ -28,12 +28,14 @@ struct Args { enum Action { // Compress video Encode { - #[arg(short, long, default_value_t = 400)] + #[arg(short, long, default_value_t = 800)] max_block_size: usize, + #[arg(short, long, default_value_t = 10_000)] + attention_split: u32, + #[arg(short, long, default_value_t = 10.)] + threshold: f32, #[arg(short, long, default_value_t = 10)] - iters: usize, - #[arg(short, long, default_value_t = 5_000)] - threshold: u32, + keyframe_interval: usize, }, // Decompress video Decode { @@ -53,12 +55,13 @@ fn main() { Action::Encode { max_block_size, threshold, - iters, + attention_split, + keyframe_interval, } => { let config = EncodeConfig { threshold, max_block_size, - iters, + attention_split, }; let mut last_frame = Frame::new(size); @@ -70,6 +73,11 @@ fn main() { for frame_number in 0.. { let mut frame = read_frame(&mut stdin, size); + let mut config = config.clone(); + if frame_number % keyframe_interval != 0 { + config.threshold = std::f32::INFINITY; + } + let t = Instant::now(); let b: Block = encode(&last_frame, &frame, View::all(size), &config); let time_encode = t.elapsed(); @@ -95,12 +103,12 @@ fn main() { time_decode + time_huff + time_encode ); eprintln!( - "\tencode {time_encode:?} ({}%)", - ((bits_raw as f32 / (size.area() * 24) as f32) * 100.0).round() + "\tencode {time_encode:?} ({:.2}%)", + (bits_raw as f32 / (size.area() * 24) as f32) * 100.0 ); eprintln!( - "\thuff {time_huff:?} ({}%)", - ((bits_huff as f32 / bits_raw as f32) * 100.0).round() + "\thuff {time_huff:?} ({:.2}%)", + (bits_huff as f32 / bits_raw as f32) * 100.0 ); eprintln!("\tdecode {time_decode:?}"); } else { @@ -119,7 +127,6 @@ fn main() { let huff = true; loop { - let b = if huff { let mut buf = vec![]; read_huff(&mut stdin, &mut buf).unwrap(); |