forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits

common.rs43 lines, 1.7 KiBHistoryRawDownload
1//! Helpers shared by the integration-test modules of the `it` binary.
2
3/// Fixture-presence probe for the committed-or-media-gated fixtures a test
4/// decodes. Returns whether the fixture is present, but never silently: under
5/// `EC_REQUIRE_FIXTURES=1` an absent fixture is a hard failure naming the path
6/// and the script that regenerates it, so a host whose fixture library drifted
7/// reports RED instead of a green SKIP (class: gate-skips-on-its-own-failure;
8/// model `have_ffmpeg` in crates/ec-av1/src/stream.rs, which was silently
9/// short-circuited because the probe ran first in a compound `if`).
10///
11/// Order is load-bearing: probe, assert, return. Never merge the probe into
12/// the same `if` as the escape.
13pub(crate) fn require_fixture(path: &std::path::Path, generator: &str) -> bool {
14 let present = path.exists();
15 assert!(
16 present || std::env::var_os("EC_REQUIRE_FIXTURES").is_none(),
17 "EC_REQUIRE_FIXTURES=1 but fixture {} is absent -- regenerate with: {}",
18 path.display(),
19 generator
20 );
21 if !present {
22 eprintln!("SKIP: fixture {} absent", path.display());
23 }
24 present
25}
26
27/// ffmpeg's decoded rawvideo byte stream (frame-packed I420, `w`x`h`).
28pub(crate) fn ffmpeg_raw_yuv(path: &std::path::Path, w: usize, h: usize) -> Vec<u8> {
29 let out = std::process::Command::new("ffmpeg")
30 .args(["-v", "error", "-i"])
31 .arg(path)
32 .args(["-f", "rawvideo", "-pix_fmt", "yuv420p", "-"])
33 .output()
34 .expect("ffmpeg on PATH");
35 assert!(out.status.success(), "ffmpeg decode failed: {out:?}");
36 let frame = w * h + 2 * (w / 2) * (h / 2);
37 assert_eq!(
38 out.stdout.len() % frame,
39 0,
40 "ffmpeg output is not frame-aligned"
41 );
42 out.stdout
43}