forge
Explore
Log in

Don't you dare go Hollow

U5: drop ec-vp8 debug examples dbg_first, dump_frame, throughput

Browse files at this commit

db2cc7578b31ca0e9283d50d34df940b6f5291d5Ahmet Kaan GümüşParent: 41510f0
Diagnostic probes with no test or caller; the examples are not part of the decoder.
crates/ec-vp8/examples/dbg_first.rsdeleted+0 -18
@@ -1,18 +0,0 @@
1-// Decode frame 0 of an IVF with decision tracing (EC_VP8_TRACE=1).
2-use ec_vp8::decode::Decoder;
3-
4-fn main() {
5- let path = std::env::args().nth(1).expect("ivf path");
6- let bytes = std::fs::read(path).unwrap();
7- let sz = u32::from_le_bytes([bytes[32], bytes[33], bytes[34], bytes[35]]) as usize;
8- let frame = &bytes[44..44 + sz];
9- let mut dec = Decoder::new();
10- match dec.decode(frame) {
11- Ok(Some(pic)) => println!(
12- "OUT {}x{} y[0..8]={:?}",
13- pic.width, pic.height, &pic.y[..8]
14- ),
15- Ok(None) => println!("OUT hidden"),
16- Err(e) => println!("OUT ERR {e}"),
17- }
18-}
crates/ec-vp8/examples/dump_frame.rsdeleted+0 -58
@@ -1,58 +0,0 @@
1-//! Dump decoded frame N of an IVF as raw yuv420p (ffmpeg-comparable:
2-//! `ffmpeg -i in.ivf -f rawvideo -pix_fmt yuv420p -` streams the same
3-//! layout, frame after frame). Usage: `dump_frame <ivf> <frame-index>
4-//! <out.yuv>`. Decoding stops at the first frame the crate cannot yet
5-//! decode (e.g. inter frames before M3), reporting it on stderr.
6-
7-use ec_vp8::decode::Decoder;
8-
9-fn main() {
10- let args: Vec<String> = std::env::args().collect();
11- assert_eq!(args.len(), 4, "usage: dump_frame <ivf> <frame-index> <out.yuv>");
12- let want: usize = args[2].parse().expect("frame index");
13- let bytes = std::fs::read(&args[1]).unwrap();
14-
15- // IVF: 32-byte file header, then (4-byte LE size, 8-byte pts, data).
16- let mut frames = Vec::new();
17- let mut pos = 32;
18- while pos + 12 <= bytes.len() {
19- let sz = u32::from_le_bytes(bytes[pos..pos + 4].try_into().unwrap()) as usize;
20- frames.push(&bytes[pos + 12..pos + 12 + sz]);
21- pos += 12 + sz;
22- }
23-
24- let mut dec = Decoder::new();
25- for (i, f) in frames.iter().enumerate() {
26- match dec.decode(f) {
27- Ok(Some(pic)) if i == want => {
28- let mut out = Vec::with_capacity(
29- pic.y.len() + pic.u.len() + pic.v.len(),
30- );
31- for row in 0..usize::from(pic.height) {
32- let s = row * pic.stride;
33- out.extend_from_slice(&pic.y[s..s + usize::from(pic.width)]);
34- }
35- let (cw, ch) = (
36- usize::from(pic.width + 1) / 2,
37- usize::from(pic.height + 1) / 2,
38- );
39- for plane in [&pic.u, &pic.v] {
40- for row in 0..ch {
41- let s = row * pic.uv_stride;
42- out.extend_from_slice(&plane[s..s + cw]);
43- }
44- }
45- std::fs::write(&args[3], out).unwrap();
46- return;
47- }
48- Ok(Some(_)) => {}
49- Ok(None) => {}
50- Err(e) => {
51- eprintln!("frame {i}: {e}");
52- std::process::exit(1);
53- }
54- }
55- }
56- eprintln!("no frame {want} decoded");
57- std::process::exit(1);
58-}
crates/ec-vp8/examples/throughput.rsdeleted+0 -38
@@ -1,38 +0,0 @@
1-//! Perf-lane probe: decode an IVF repeatedly, report MP/s and fps.
2-//! Dims come from the IVF header; usage: `throughput <ivf> [rounds]`.
3-use ec_vp8::decode::Decoder;
4-use std::time::Instant;
5-
6-fn main() {
7- let args: Vec<String> = std::env::args().collect();
8- let bytes = std::fs::read(&args[1]).unwrap();
9- let w = u16::from_le_bytes([bytes[12], bytes[13]]) as u64;
10- let h = u16::from_le_bytes([bytes[14], bytes[15]]) as u64;
11- let rounds: u64 = args.get(2).map(|s| s.parse().unwrap()).unwrap_or(20);
12- let mut frames = Vec::new();
13- let mut pos = 32;
14- while pos + 12 <= bytes.len() {
15- let sz = u32::from_le_bytes(bytes[pos..pos + 4].try_into().unwrap()) as usize;
16- frames.push(bytes[pos + 12..pos + 12 + sz].to_vec());
17- pos += 12 + sz;
18- }
19- let nframes = frames.len();
20- let shown = frames.iter().filter(|f| (f[0] >> 4) & 1 == 1).count() as u64;
21- let t = Instant::now();
22- for _ in 0..rounds {
23- let mut dec = Decoder::new();
24- for f in &frames {
25- dec.decode(f).unwrap();
26- }
27- }
28- let dt = t.elapsed().as_secs_f64();
29- let dec_mpx = rounds as f64 * nframes as f64 * w as f64 * h as f64 / 1e6 / dt;
30- let out_mpx = rounds as f64 * shown as f64 * w as f64 * h as f64 / 1e6 / dt;
31- println!(
32- "{}x{rounds} frames ({shown} shown/round) in {dt:.3}s: \
33- decode {dec_mpx:.1} MP/s, output {out_mpx:.1} MP/s \
34- ({:.1} shown fps @ {w}x{h})",
35- nframes,
36- rounds as f64 * shown as f64 / dt
37- );
38-}