aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2023-11-18 17:37:57 +0100
committermetamuffin <metamuffin@disroot.org>2023-11-18 17:37:57 +0100
commit754ebf34cbb6280ef77421e1ca54d35d727dc6f7 (patch)
tree00548d19aafdcf34bda914b0c8c15654b720ac7a
parentcdb9a3afabe7a239a08c640b19242ff9b1e3b051 (diff)
downloadvideo-codec-experiments-754ebf34cbb6280ef77421e1ca54d35d727dc6f7.tar
video-codec-experiments-754ebf34cbb6280ef77421e1ca54d35d727dc6f7.tar.bz2
video-codec-experiments-754ebf34cbb6280ef77421e1ca54d35d727dc6f7.tar.zst
debug and better search
-rw-r--r--flowy/src/main.rs16
-rw-r--r--flowy/src/motion/debug.wgsl2
-rw-r--r--flowy/src/motion/enc.rs2
-rw-r--r--flowy/src/motion/enc.wgsl31
4 files changed, 35 insertions, 16 deletions
diff --git a/flowy/src/main.rs b/flowy/src/main.rs
index 6620ed8..8529f2c 100644
--- a/flowy/src/main.rs
+++ b/flowy/src/main.rs
@@ -5,7 +5,8 @@ use log::{debug, info};
use motion::{dec::MotionDecoder, enc::MotionEncoder, CommonBuffers, Params};
use pollster::FutureExt;
use std::{
- io::{stdin, stdout, Read, Write},
+ io::{stdin, stdout, ErrorKind, Read, Write},
+ process::exit,
time::Instant,
};
use wgpu::{
@@ -86,9 +87,16 @@ fn main() {
debug: fparams.debug == 2,
preview: fparams.debug > 0,
};
- eprintln!("{params:?} {rp:?}");
+ debug!("{params:?} {rp:?}");
debug!("read");
- stdin().read_exact(&mut buffer).unwrap();
+ match stdin().read_exact(&mut buffer) {
+ Ok(_) => (),
+ Err(e) if e.kind() == ErrorKind::UnexpectedEof => {
+ break;
+ }
+ Err(e) => Err(e).unwrap(),
+ }
+
framework.next_frame_manual();
debug!("upload");
@@ -120,4 +128,6 @@ fn main() {
stdout().write_all(&buffer).unwrap();
i += 1;
}
+ eprintln!("done");
+ exit(0);
}
diff --git a/flowy/src/motion/debug.wgsl b/flowy/src/motion/debug.wgsl
index 3e740f6..7da5c57 100644
--- a/flowy/src/motion/debug.wgsl
+++ b/flowy/src/motion/debug.wgsl
@@ -25,7 +25,7 @@ struct BlockOffset {
for (var x = 0; x < params.block_size.x; x++) {
for (var y = 0; y < params.block_size.y; y++) {
let base = uv + vec2(x, y);
- let col = vec4(colormap_vec(vec2<f32>(bl.offset) * 0.05),1.);
+ let col = vec4(colormap_vec(vec2<f32>(bl.offset) * 0.08),1.);
textureStore(out, base, col);
}
}
diff --git a/flowy/src/motion/enc.rs b/flowy/src/motion/enc.rs
index 56b459b..d3e8a81 100644
--- a/flowy/src/motion/enc.rs
+++ b/flowy/src/motion/enc.rs
@@ -38,7 +38,7 @@ impl MotionEncoder {
block_size: [params.block_width as i32, params.block_height as i32],
output_stride: (params.width / params.block_width) as u32,
search_radius: 16,
- skip_threshold: 0.07,
+ skip_threshold: 0.1,
..Default::default()
};
diff --git a/flowy/src/motion/enc.wgsl b/flowy/src/motion/enc.wgsl
index 6ba3081..80618b7 100644
--- a/flowy/src/motion/enc.wgsl
+++ b/flowy/src/motion/enc.wgsl
@@ -24,19 +24,28 @@ var<private> best_tint: vec3<f32> = vec3(0.);
@compute @workgroup_size(1)fn main(@builtin(global_invocation_id) global_id: vec3<u32>) {
let uv = vec2<i32>(global_id.xy) * params.block_size;
- test_offset(uv, vec2(0, 0));
+ loop {
+ test_offset(uv, vec2(0, 0));
+ if best_error < params.skip_threshold { break; }
+ apply_tint(uv);
+ if best_error < params.skip_threshold { break; }
+ best_tint = vec3(0.);
- do_dist(uv, 32);
- do_dist(uv, 16);
- do_dist(uv, 10);
- do_dist(uv, 8);
- do_dist(uv, 6);
- do_dist(uv, 3);
- do_dist(uv, 4);
- do_dist(uv, 2);
- do_dist(uv, 1);
+ do_dist(uv, 32);
+ do_dist(uv, 16);
+ do_dist(uv, 10);
+ do_dist(uv, 8);
+ if best_error < params.skip_threshold { break; }
+ do_dist(uv, 6);
+ do_dist(uv, 3);
+ do_dist(uv, 4);
+ do_dist(uv, 2);
+ do_dist(uv, 1);
+ if best_error < params.skip_threshold { break; }
- apply_tint(uv);
+ apply_tint(uv);
+ break;
+ }
offsets[global_id.x + global_id.y * params.offsets_stride] = BlockOffset(best_error, best_offset, best_tint);
}