Skip to content

FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust

M2 tests: Apple VideoToolbox encoded fixtures (bit-exact)

Brandon Thomas3903d2909ab0
diff --git a/crates/h264/README.md b/crates/h264/README.md
index 44f97dadd..8b76198e9 100644
--- a/crates/h264/README.md
+++ b/crates/h264/README.md
@@ -89,6 +89,9 @@ with ffmpeg + libx264; tests print a message and skip when `/opt/homebrew/bin/ff
### Fixture matrix (all bit-exact, single- and multi-threaded)
+libx264 fixtures unless noted; the VideoToolbox (hardware encoder) fixtures are skipped where that
+encoder is unavailable.
+
| fixture | source / size | configuration |
|---|---|---|
| intra_cavlc | testsrc2 176x144 | Baseline, keyint=1, no deblock |
@@ -124,6 +127,10 @@ with ffmpeg + libx264; tests print a message and skip when `/opt/homebrew/bin/ff
| qp50 | testsrc2+noise 352x288 | QP 50 |
| qp1 | mandelbrot+noise 352x288 | QP 1 |
| bench_1080p | testsrc2+noise 1920x1080, 120 frames | preset medium, CRF 20 (8.8 Mbit/s) |
+| vt_baseline | testsrc2+noise 320x240 | Apple VideoToolbox, Baseline (macOS only) |
+| vt_main | mandelbrot+noise 640x360 | VideoToolbox, Main |
+| vt_high | testsrc2+noise 640x360 | VideoToolbox, High |
+| vt_high_1080p | testsrc2 1920x1080 | VideoToolbox, High 8 Mbit/s |
`cargo test --release -p filmcraft-h264 --test conformance coverage_report -- --ignored --nocapture`
prints which coding tools each fixture exercises.
diff --git a/crates/h264/tests/common/mod.rs b/crates/h264/tests/common/mod.rs
index eddc2dddb..dc7263000 100644
--- a/crates/h264/tests/common/mod.rs
+++ b/crates/h264/tests/common/mod.rs
@@ -22,6 +22,43 @@ pub struct Fixture {
const NOISE: &str = "noise=alls=12:allf=t+u";
pub const FIXTURES: &[Fixture] = &[
+ // Apple VideoToolbox (hardware) encoder streams: different encoder design, generated on macOS only
+ Fixture {
+ name: "vt_high",
+ source: "testsrc2",
+ width: 640,
+ height: 360,
+ frames: 30,
+ filter: NOISE,
+ args: &["-c:v", "h264_videotoolbox", "-profile:v", "high", "-b:v", "3M"],
+ },
+ Fixture {
+ name: "vt_main",
+ source: "mandelbrot",
+ width: 640,
+ height: 360,
+ frames: 30,
+ filter: NOISE,
+ args: &["-c:v", "h264_videotoolbox", "-profile:v", "main", "-b:v", "2M"],
+ },
+ Fixture {
+ name: "vt_baseline",
+ source: "testsrc2",
+ width: 320,
+ height: 240,
+ frames: 30,
+ filter: NOISE,
+ args: &["-c:v", "h264_videotoolbox", "-profile:v", "baseline", "-b:v", "1M"],
+ },
+ Fixture {
+ name: "vt_high_1080p",
+ source: "testsrc2",
+ width: 1920,
+ height: 1080,
+ frames: 10,
+ filter: "",
+ args: &["-c:v", "h264_videotoolbox", "-profile:v", "high", "-b:v", "8M"],
+ },
// performance reference stream (see tests/perf.rs)
Fixture {
name: "bench_1080p",
@@ -318,10 +355,18 @@ pub fn ensure(f: &Fixture) -> Option<(PathBuf, PathBuf)> {
}
let mut c = Command::new(&ff);
c.args(["-hide_banner", "-loglevel", "error", "-y", "-f", "lavfi", "-i", &vf]);
- c.args(["-frames:v", &f.frames.to_string(), "-c:v", "libx264"]);
+ c.args(["-frames:v", &f.frames.to_string()]);
+ if !f.args.contains(&"-c:v") {
+ c.args(["-c:v", "libx264"]);
+ }
c.args(f.args);
c.args(["-f", "h264"]).arg(&tmp);
- assert!(run(&mut c), "fixture generation failed for {}", f.name);
+ if !run(&mut c) {
+ // Platform encoders (VideoToolbox) are optional; libx264 fixtures must generate.
+ assert!(f.args.contains(&"-c:v"), "fixture generation failed for {}", f.name);
+ eprintln!("SKIP {}: encoder unavailable", f.name);
+ return None;
+ }
std::fs::rename(&tmp, &h264).unwrap();
}
if !yuv.exists() {
diff --git a/crates/h264/tests/conformance.rs b/crates/h264/tests/conformance.rs
index 1663b7096..dc4ddaea5 100644
--- a/crates/h264/tests/conformance.rs
+++ b/crates/h264/tests/conformance.rs
@@ -50,6 +50,10 @@ fixture_tests!(
no8x8dct,
qp50,
qp1,
+ vt_high,
+ vt_main,
+ vt_baseline,
+ vt_high_1080p,
);
/// Print which coding tools each fixture exercises (run with `-- --ignored --nocapture`).