mirror of
https://github.com/storytold/filmcraft.git
synced 2026-10-29 04:27:47 -06:00
Frames are published one superblock row at a time once loop filtered; a post stage per frame (own thread) assembles bands from the tile strips, filters them in raster order and builds the output picture, while the next frame's tile columns decode and wait per band for the reference rows they read. Bit-exact with 1, 3 and all threads. Draft mode skips the loop filter of frames that refresh no reference slot. av1dec / hevcdec bench knobs and VP9 / AV1 4K playback scenarios in the bench. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
49 lines
1.4 KiB
Rust
49 lines
1.4 KiB
Rust
//! Decode speed (ignored by default; run with
|
|
//! `cargo test --release -p filmcraft-vp9 --test perf -- --ignored --nocapture`).
|
|
|
|
mod common;
|
|
|
|
use filmcraft_vp9::Decoder;
|
|
use std::time::Instant;
|
|
|
|
fn bench(frames: &[&[u8]], threads: usize, iters: usize) -> (usize, f64) {
|
|
let mut best = f64::MAX;
|
|
let mut n = 0;
|
|
for _ in 0..iters {
|
|
let mut dec = Decoder::with_threads(threads);
|
|
let t0 = Instant::now();
|
|
n = 0;
|
|
for f in frames {
|
|
n += dec.decode(f, 0).expect("decode").len();
|
|
}
|
|
n += dec.flush().len();
|
|
best = best.min(t0.elapsed().as_secs_f64());
|
|
}
|
|
(n, best)
|
|
}
|
|
|
|
fn run(name: &str, label: &str) {
|
|
let f = common::fixture(name);
|
|
let Some((ivf, _)) = common::ensure(f) else { return };
|
|
common::check_fixture(name).unwrap();
|
|
let data = std::fs::read(ivf).unwrap();
|
|
let frames = common::ivf_frames(&data);
|
|
let cores = std::thread::available_parallelism().map(|n| n.get()).unwrap_or(1);
|
|
for threads in [1, cores.min(16)] {
|
|
let (n, secs) = bench(&frames, threads, 3);
|
|
println!("{label} ({} KB): {threads} thread(s): {n} frames in {secs:.3}s = {:.1} fps", data.len() / 1024, n as f64 / secs);
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
#[ignore]
|
|
fn perf_1080p() {
|
|
run("bench_1080p", "1080p 8-bit, 4 tile columns");
|
|
}
|
|
|
|
#[test]
|
|
#[ignore]
|
|
fn perf_4k() {
|
|
run("bench_4k", "2160p 8-bit, 8 tile columns");
|
|
}
|