FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust
Fuzz seeds that test what they claim: VP8 -slices 8 (8 partitions), VP9 two tile columns at 512 px, HEVC 2x2 tiles via kvazaar; hang test ignores the timeout override
Logan Jennings18cad0b0cef7
diff --git a/crates/hevc/tests/fuzz_hostile.rs b/crates/hevc/tests/fuzz_hostile.rsindex 9f5e2feae..ac6829315 100644--- a/crates/hevc/tests/fuzz_hostile.rs+++ b/crates/hevc/tests/fuzz_hostile.rs@@ -21,22 +21,23 @@ impl Rng {}}-/// (name, extra x264 args, pix_fmt)-const SEEDS: &[(&str, &str, &str)] = &[- ("hevc_fz_main_b", "-x265-params log-level=error:bframes=2:keyint=8:min-keyint=8:sao=1:amp=1", "yuv420p"),- ("hevc_fz_main10", "-x265-params log-level=error:bframes=1:keyint=6:min-keyint=6", "yuv420p10le"),- ("hevc_fz_wpp_slices", "-x265-params log-level=error:keyint=6:min-keyint=6:wpp=1:slices=3", "yuv420p"),- ("hevc_fz_tiles", "-x265-params log-level=error:keyint=6:min-keyint=6:tiles=2x2", "yuv420p"),- ("hevc_fz_422_10", "-x265-params log-level=error:keyint=6:min-keyint=6", "yuv422p10le"),+/// (name, encoder, extra encoder args, pix_fmt)+const SEEDS: &[(&str, &str, &str, &str)] = &[+ ("hevc_fz_main_b", "libx265", "-x265-params log-level=error:bframes=2:keyint=8:min-keyint=8:sao=1:amp=1", "yuv420p"),+ ("hevc_fz_main10", "libx265", "-x265-params log-level=error:bframes=1:keyint=6:min-keyint=6", "yuv420p10le"),+ ("hevc_fz_wpp_slices", "libx265", "-x265-params log-level=error:keyint=6:min-keyint=6:wpp=1:slices=3", "yuv420p"),+ // x265 cannot encode tiles; kvazaar can, at 256 x 64 luma per tile at least (Main profile)+ ("hevc_fz_tiles_kvazaar", "libkvazaar", "-s 512x128 -kvazaar-params tiles=2x2,gop=0,period=6,qp=40", "yuv420p"),+ ("hevc_fz_422_10", "libx265", "-x265-params log-level=error:keyint=6:min-keyint=6", "yuv422p10le"),];-fn make(ff: &std::path::Path, name: &str, args: &str, pix: &str) -> Option<Vec<u8>> {+fn make(ff: &std::path::Path, name: &str, enc: &str, args: &str, pix: &str) -> Option<Vec<u8>> {let out = filmcraft_testkit::fixtures_dir("hevc").join(format!("{name}.hevc"));let p = filmcraft_testkit::fixtures::generate(&out, |tmp| {let a: Vec<&str> = args.split_whitespace().collect();matches!(Command::new(ff)- .args(["-hide_banner", "-loglevel", "error", "-y", "-f", "lavfi", "-i", "testsrc2=size=64x48:rate=25", "-frames:v", "7", "-pix_fmt", pix, "-c:v", "libx265"])+ .args(["-hide_banner", "-loglevel", "error", "-y", "-f", "lavfi", "-i", "testsrc2=size=64x48:rate=25", "-frames:v", "7", "-pix_fmt", pix, "-c:v", enc]).args(a).args(["-f", "hevc"]).arg(tmp)@@ -89,13 +90,13 @@ fn hostile_streams_never_panic() {fn sweep() {let Some(ff) = filmcraft_testkit::ffmpeg_or_skip("hevc fuzz") else { return };- for &(name, args, pix) in SEEDS {- if !filmcraft_testkit::ffmpeg_has_encoder(&ff, "libx265") {- filmcraft_testkit::skip("hevc fuzz", &format!("this ffmpeg has no libx265 encoder (seed {name})"));+ for &(name, enc, args, pix) in SEEDS {+ if !filmcraft_testkit::ffmpeg_has_encoder(&ff, enc) {+ filmcraft_testkit::skip("hevc fuzz", &format!("this ffmpeg has no {enc} encoder (seed {name})"));continue;}- let Some(seed) = make(&ff, name, args, pix) else {- panic!("ffmpeg has libx265 but could not encode the {name} seed");+ let Some(seed) = make(&ff, name, enc, args, pix) else {+ panic!("ffmpeg has {enc} but could not encode the {name} seed");};let stride = (seed.len() / 300).max(1);for n in (0..seed.len()).step_by(stride) {diff --git a/crates/testkit/src/deadline.rs b/crates/testkit/src/deadline.rsindex 97a5b138b..befb6508a 100644--- a/crates/testkit/src/deadline.rs+++ b/crates/testkit/src/deadline.rs@@ -21,6 +21,10 @@ pub fn set_progress(label: &str) {/// worker is abandoned (the failing test process exits anyway).pub fn with_deadline(secs: u64, f: impl FnOnce() + Send + 'static) {let secs = std::env::var("FILMCRAFT_HOSTILE_TIMEOUT_SECS").ok().and_then(|v| v.parse::<u64>().ok()).filter(|&n| n > 0).unwrap_or(secs);+ run_with_deadline(secs, f);+}++fn run_with_deadline(secs: u64, f: impl FnOnce() + Send + 'static) {let (tx, rx) = mpsc::channel();// a failed spawn shows up as "worker gone" belowlet _ = std::thread::Builder::new().name("hostile deadline".into()).spawn(move || {@@ -55,8 +59,8 @@ mod tests {#[test]#[should_panic(expected = "last input: seed 7 byte 3")]fn a_hang_fails_and_names_the_input() {- // a body that outlives the 1 s budget (the env override is unset in tests)+ // a body that outlives the 1 s budget; the inner fn, so FILMCRAFT_HOSTILE_TIMEOUT_SECS cannot lengthen itset_progress("seed 7 byte 3");- with_deadline(1, || std::thread::sleep(Duration::from_secs(30)));+ run_with_deadline(1, || std::thread::sleep(Duration::from_secs(30)));}}diff --git a/crates/vp8/tests/fuzz_hostile.rs b/crates/vp8/tests/fuzz_hostile.rsindex be36a3e9e..e72e61bc7 100644--- a/crates/vp8/tests/fuzz_hostile.rs+++ b/crates/vp8/tests/fuzz_hostile.rs@@ -23,7 +23,7 @@ impl Rng {/// (name, encoder args, pix_fmt)const SEEDS: &[(&str, &str, &str)] = &[("vp8_fz_default", "-c:v libvpx -g 4 -b:v 300k", "yuv420p"),- ("vp8_fz_partitions", "-c:v libvpx -g 6 -b:v 300k -token-parts 3 -auto-alt-ref 0 -lag-in-frames 0 -error-resilient 1", "yuv420p"),+ ("vp8_fz_partitions", "-c:v libvpx -g 6 -b:v 300k -slices 8 -auto-alt-ref 0 -lag-in-frames 0 -error-resilient 1", "yuv420p"),];fn ivf_frames(data: &[u8]) -> Vec<Vec<u8>> {diff --git a/crates/vp9/tests/fuzz_hostile.rs b/crates/vp9/tests/fuzz_hostile.rsindex 5f7189442..70f884ec0 100644--- a/crates/vp9/tests/fuzz_hostile.rs+++ b/crates/vp9/tests/fuzz_hostile.rs@@ -23,7 +23,8 @@ impl Rng {/// (name, encoder args, pix_fmt)const SEEDS: &[(&str, &str, &str)] = &[("vp9_fz_default", "-c:v libvpx-vp9 -g 4 -b:v 300k -lag-in-frames 0", "yuv420p"),- ("vp9_fz_tiles_10bit", "-c:v libvpx-vp9 -g 6 -b:v 300k -lag-in-frames 0 -tile-columns 1 -profile:v 2", "yuv420p10le"),+ // libvpx needs 256 px per tile column, so two columns need 512 px+ ("vp9_fz_2tiles_10bit", "-c:v libvpx-vp9 -g 6 -b:v 300k -lag-in-frames 0 -tile-columns 1 -profile:v 2 -s 512x48", "yuv420p10le"),("vp9_fz_444", "-c:v libvpx-vp9 -g 6 -b:v 300k -lag-in-frames 0 -profile:v 1", "yuv444p"),("vp9_fz_altref", "-c:v libvpx-vp9 -g 6 -b:v 300k -auto-alt-ref 1 -lag-in-frames 5", "yuv420p"),];