mirror of
https://github.com/storytold/filmcraft.git
synced 2026-10-24 01:58:19 -06:00
* Tests: one integration-test binary per crate Each crate with several tests/*.rs files keeps them as modules of tests/it/, so cargo links one test executable per crate instead of one per file. Files that change process-wide state or time a workload stay binaries of their own. * Profiles: line tables for workspace crates, no debug info for dependencies * Windows ARM64: nightly and on release pushes instead of every push to main * xtask ci: clippy and tests in the dev profile The release profile's thin LTO and single codegen unit made linking the test binaries take most of the gate. The codec and audio crates stay at opt-level 3 in the dev profile, so their tests run at release speed. * xtask ci: nextest, doctests, no examples, one wasm check Tests run with cargo nextest when it is installed (cargo test otherwise) and build with --lib --bins --tests, so examples aren't linked; doctests run separately. The wasm check keeps going past the first failing crate. VP8 fixture generation locks across processes, since nextest runs each test in its own. * VP9 synthetic fixtures: write aside and rename A test in another process could read a fixture ffmpeg was still writing. * Fuzz tests: a third of each sweep by default, all of it with FILMCRAFT_FUZZ_ITERS Every seed, mutation kind and thread count still runs. Header bytes each get one overwrite value and two bit flips in rotation, so every value and bit index still occurs across the region. FILMCRAFT_FUZZ_ITERS=N runs the whole sweep plus N random rounds per seed, as before. * Platform fallback tests: one failure point per hybrid path The failure-anywhere test injected a failure at four points around every restart point; the hybrid's paths differ only in the first GOP, around the second and last restart points, at the end and never. The replay test needs the first two GOPs. * Export tests: shorter ranges with the same checks The bitrate test measures 0.5–1.5 s, where each preset reaches its own target (on 0–3 s the simple demo left two presets at the same rate). The every-preset test exports three frames per preset. * Audio tests: effects in parallel, a table-driven FFT for the Opus quality metric The extreme-settings test keeps both settings and the 40 s tail for every effect, one thread each. The Opus quality metric's FFT builds its twiddles once and allocates nothing per transform (same algorithm and summation order). * CI: dev-profile gate with nextest xtask ci no longer builds with --release, so the release-profile overrides go; nextest is installed for the test step. * CI: apt packages through the cached install-apt-packages action * Review fixes: fuzz tests with a panic hook in their own binaries, loud fixture lock The fuzz tests of av1, h264, hevc, mpeg2v, vp8 and vp9 count panics through a process-wide hook, so a panic in another test of the same process would fail them; they are binaries of their own again. The VP8 fixture lock fails the test instead of skipping it silently, and the full-sweep doc comments say how many truncation points the full run samples. * Fuzz tests: rotate the default subset per run (FILMCRAFT_FUZZ_SEED replays one) * platform tests: decode-switch tests in their own binaries, one NVENC lock
145 lines
4.6 KiB
Rust
145 lines
4.6 KiB
Rust
//! Bit-exactness against ffmpeg's decoder on libx265 / VideoToolbox fixtures (skipped when ffmpeg is
|
|
//! absent).
|
|
|
|
use crate::common;
|
|
|
|
macro_rules! fixture_tests {
|
|
($($name:ident),* $(,)?) => {
|
|
$(
|
|
#[test]
|
|
fn $name() {
|
|
match common::check_fixture(stringify!($name)) {
|
|
Ok(true) => {}
|
|
Ok(false) => eprintln!("skipped {}", stringify!($name)),
|
|
Err(e) => panic!("{e}"),
|
|
}
|
|
}
|
|
)*
|
|
};
|
|
}
|
|
|
|
fixture_tests!(
|
|
intra_main,
|
|
intra_main10,
|
|
intra_nosao_nodbk,
|
|
ultrafast,
|
|
veryfast,
|
|
medium,
|
|
slow,
|
|
medium_main10,
|
|
slow_main10,
|
|
p_only,
|
|
bframes,
|
|
no_sao,
|
|
no_deblock,
|
|
deblock_m3_3,
|
|
no_wpp,
|
|
rect_amp,
|
|
tskip,
|
|
weightp,
|
|
weightp_main10,
|
|
crf0,
|
|
crf51,
|
|
qp1_main10,
|
|
lossless,
|
|
cu_lossless,
|
|
slices4,
|
|
scaling_list,
|
|
ctu16,
|
|
ctu32_tu4,
|
|
min_cu16,
|
|
no_signhide,
|
|
constrained_intra,
|
|
no_tmvp,
|
|
no_strong_intra,
|
|
max_merge1,
|
|
open_gop,
|
|
keyint5_idr,
|
|
odd_1918x1078,
|
|
hd_1080p,
|
|
uhd_4k_main10,
|
|
vt_main,
|
|
vt_main10,
|
|
);
|
|
|
|
/// Draft mode: sub-layer non-reference pictures skip deblocking and SAO and are flagged; every
|
|
/// other picture stays bit-exact, single-threaded and frame-threaded.
|
|
#[test]
|
|
fn draft_mode_changes_only_flagged_non_reference_pictures() {
|
|
let mut checked = 0;
|
|
for name in ["bframes", "medium", "slow", "weightp_main10"] {
|
|
let f = common::fixture(name);
|
|
let Some((hevc, yuv)) = common::ensure(f) else {
|
|
eprintln!("skipped {name}");
|
|
continue;
|
|
};
|
|
let reference = std::fs::read(&yuv).unwrap();
|
|
let (w, h) = (f.width as usize, f.height as usize);
|
|
let bps = if f.bit_depth > 8 { 2 } else { 1 };
|
|
let fsize = (w * h + 2 * w.div_ceil(2) * h.div_ceil(2)) * bps;
|
|
for threads in [1, 3] {
|
|
let pics = common::decode_file_opts(&hevc, threads, true).unwrap_or_else(|(au, e, _)| panic!("{name}: error at {au}: {e}"));
|
|
common::check_pts(&pics).unwrap_or_else(|e| panic!("{name}: {e}"));
|
|
assert_eq!(pics.len() * fsize, reference.len(), "{name}: picture count");
|
|
let (mut draft, mut changed) = (0, 0);
|
|
for (i, p) in pics.iter().enumerate() {
|
|
let bytes: Vec<u8> = [&p.y, &p.u, &p.v].iter().flat_map(|pl| pl.to_le_bytes()).collect();
|
|
let same = bytes == reference[i * fsize..(i + 1) * fsize];
|
|
if p.draft {
|
|
draft += 1;
|
|
changed += !same as usize;
|
|
} else {
|
|
assert!(same, "{name} (threads {threads}): picture {i} (not draft) differs from the reference");
|
|
}
|
|
}
|
|
assert!(draft > 0, "{name}: has non-reference pictures");
|
|
assert!(changed > 0, "{name}: skipping the in-loop filters changes some draft picture");
|
|
checked += 1;
|
|
}
|
|
}
|
|
if checked == 0 {
|
|
eprintln!("skipped: no fixtures");
|
|
}
|
|
}
|
|
|
|
/// Print which coding tools each fixture exercises (run with `-- --ignored --nocapture`).
|
|
#[test]
|
|
#[ignore]
|
|
fn coverage_report() {
|
|
for f in common::FIXTURES {
|
|
let Some((hevc, _)) = common::ensure(f) else { continue };
|
|
let data = std::fs::read(hevc).unwrap();
|
|
let mut dec = filmcraft_hevc::Decoder::new();
|
|
for au in common::split_access_units(&data) {
|
|
let _ = dec.decode(au, 0);
|
|
}
|
|
dec.flush();
|
|
println!("{:<20} {:?}", f.name, dec.stats());
|
|
}
|
|
}
|
|
|
|
/// The comparison must report a single flipped sample (guards against a vacuous harness).
|
|
#[test]
|
|
fn compare_detects_mismatch() {
|
|
let f = common::fixture("intra_main10");
|
|
let Some((hevc, yuv)) = common::ensure(f) else { return };
|
|
let pics = common::decode_file_threads(&hevc, 1).map_err(|e| e.1).unwrap();
|
|
let mut reference = std::fs::read(yuv).unwrap();
|
|
common::compare(&pics, &reference, f.width as usize, f.height as usize, f.bit_depth).unwrap();
|
|
let pos = reference.len() - 7;
|
|
reference[pos] ^= 1;
|
|
let err = common::compare(&pics, &reference, f.width as usize, f.height as usize, f.bit_depth).unwrap_err();
|
|
assert!(err.contains("plane V"), "{err}");
|
|
}
|
|
|
|
/// Pre-generate every fixture and its reference decode (`cargo xtask fixtures`).
|
|
#[test]
|
|
#[ignore]
|
|
fn generate_fixtures() {
|
|
let dir = common::fixtures_dir();
|
|
for f in common::FIXTURES {
|
|
let outs = [dir.join(format!("{}.hevc", f.name)), dir.join(format!("{}.yuv", f.name))];
|
|
filmcraft_testkit::fixtures::generate_and_report(&format!("hevc/{}", f.name), &outs, || common::ensure(f));
|
|
}
|
|
}
|