forge
Explore
Log in

Don't you dare go Hollow

Migrate ec-vp8, ec-vp9, ec-vp9-syntax tests to ec-testkit: fixture() and pinned ffmpeg/ffprobe, skip-if-missing branches removed (missing fixture fails), ensure_fixture and scratch_synth dropped, env-driven scratch probes made #[ignore]

Browse files at this commit

2c7500ad264f956a5e94c766ff2799cfb258c736Ahmet Kaan GümüşParent: 155ce74
Cargo.lockmodified+3 -0
@@ -748,6 +748,7 @@ dependencies = [
748 "archmage",748 "archmage",
749 "bytemuck",749 "bytemuck",
750 "ec-core",750 "ec-core",
751+ "ec-testkit",
751 "multiversion",752 "multiversion",
752 ]753 ]
753 754
@@ -756,6 +757,7 @@ name = "ec-vp9"
756 version = "0.1.0"757 version = "0.1.0"
757 dependencies = [758 dependencies = [
758 "ec-core",759 "ec-core",
760+ "ec-testkit",
759 "ec-vp9-syntax",761 "ec-vp9-syntax",
760 ]762 ]
761 763
@@ -764,6 +766,7 @@ name = "ec-vp9-syntax"
764 version = "0.1.0"766 version = "0.1.0"
765 dependencies = [767 dependencies = [
766 "ec-core",768 "ec-core",
769+ "ec-testkit",
767 ]770 ]
768 771
769 [[package]]772 [[package]]
crates/ec-vp8/Cargo.tomlmodified+3 -0
@@ -11,3 +11,6 @@ archmage = "=0.9.31-beta.1"
11 bytemuck = "1"11 bytemuck = "1"
12 ec-core.workspace = true12 ec-core.workspace = true
13 multiversion = "0.9"13 multiversion = "0.9"
14+
15+[dev-dependencies]
16+ec-testkit.workspace = true
crates/ec-vp8/fuzz/seed.shmodified+2 -2
@@ -5,13 +5,13 @@
5 # into corpus/decode_frame/. Whole IVF files up to 256 KiB go into corpus/decode_ivf/, and5 # into corpus/decode_frame/. Whole IVF files up to 256 KiB go into corpus/decode_ivf/, and
6 # a 10-frame prefix of every larger file too. The corpus is generated, not committed.6 # a 10-frame prefix of every larger file too. The corpus is generated, not committed.
7 #7 #
8-# Usage: crates/ec-vp8/fuzz/seed.sh (from any directory; needs python3 and the fixtures/ link)8+# Usage: crates/ec-vp8/fuzz/seed.sh (from any directory; needs python3 and fixtures from scripts/fixtures.sh)
9 set -euo pipefail9 set -euo pipefail
10 here=$(cd -- "$(dirname -- "$0")" && pwd)10 here=$(cd -- "$(dirname -- "$0")" && pwd)
11 repo=$(cd -- "$here/../../.." && pwd)11 repo=$(cd -- "$here/../../.." && pwd)
12 rm -rf "$here/corpus"12 rm -rf "$here/corpus"
13 mkdir -p "$here/corpus/decode_frame" "$here/corpus/decode_ivf"13 mkdir -p "$here/corpus/decode_frame" "$here/corpus/decode_ivf"
14-exec python3 -I - "$here" "decode_ivf" "$repo/fixtures/vp8/*.ivf" <<'PY'14+exec python3 -I - "$here" "decode_ivf" "${EC_FIXTURES:-$repo/fixtures}/vp8/*.ivf" <<'PY'
15 import glob, os, struct, sys15 import glob, os, struct, sys
16 16
17 here, stream_target = sys.argv[1], sys.argv[2]17 here, stream_target = sys.argv[1], sys.argv[2]
crates/ec-vp8/tests/it/common.rsmodified+2 -9
@@ -76,21 +76,14 @@ pub fn webp_vp8_chunk(bytes: &[u8]) -> Vec<u8> {
76 panic!("no VP8 chunk in webp");76 panic!("no VP8 chunk in webp");
77 }77 }
78 78
79-/// Root of the workspace checkout this test runs in (crates/ec-vp8/../..).
80-pub fn fixture_dir() -> Option<std::path::PathBuf> {
81- let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/vp8");
82- if dir.is_dir() { Some(dir) } else { None }
83-}
84-
85 /// ffmpeg's decoded rawvideo byte stream for an IVF file.79 /// ffmpeg's decoded rawvideo byte stream for an IVF file.
86-#[allow(dead_code)] // the malformed-input binary does not compare against ffmpeg
87 pub fn ffmpeg_raw_yuv(path: &std::path::Path) -> Vec<u8> {80 pub fn ffmpeg_raw_yuv(path: &std::path::Path) -> Vec<u8> {
88- let out = std::process::Command::new("ffmpeg")81+ let out = ec_testkit::ffmpeg()
89 .args(["-v", "error", "-i"])82 .args(["-v", "error", "-i"])
90 .arg(path)83 .arg(path)
91 .args(["-f", "rawvideo", "-pix_fmt", "yuv420p", "-"])84 .args(["-f", "rawvideo", "-pix_fmt", "yuv420p", "-"])
92 .output()85 .output()
93- .expect("ffmpeg must be on PATH for the witnesses");86+ .expect("ffmpeg runs");
94 assert!(out.status.success(), "ffmpeg failed on {path:?}");87 assert!(out.status.success(), "ffmpeg failed on {path:?}");
95 out.stdout88 out.stdout
96 }89 }
crates/ec-vp8/tests/it/header_parse.rsmodified+4 -16
@@ -18,11 +18,8 @@ const FIXTURES: &[(&str, u16, u16)] = &[
18 18
19 #[test]19 #[test]
20 fn parses_real_key_frame_headers() {20 fn parses_real_key_frame_headers() {
21- let Some(dir) = common::fixture_dir() else {
22- panic!("fixtures missing; run scripts/gen_vp8_fixtures.sh");
23- };
24 for (name, width, height) in FIXTURES {21 for (name, width, height) in FIXTURES {
25- let bytes = std::fs::read(dir.join(name)).unwrap();22+ let bytes = std::fs::read(ec_testkit::fixture(&format!("vp8/{name}"))).unwrap();
26 let (fourcc, w, h, frames) = common::parse_ivf(&bytes);23 let (fourcc, w, h, frames) = common::parse_ivf(&bytes);
27 assert_eq!(fourcc, "VP80", "{name}");24 assert_eq!(fourcc, "VP80", "{name}");
28 assert_eq!((w, h), (*width, *height), "{name} IVF dimensions");25 assert_eq!((w, h), (*width, *height), "{name} IVF dimensions");
@@ -74,10 +71,7 @@ fn parses_real_key_frame_headers() {
74 71
75 #[test]72 #[test]
76 fn parses_multi_partition_header() {73 fn parses_multi_partition_header() {
77- let Some(dir) = common::fixture_dir() else {74+ let bytes = std::fs::read(ec_testkit::fixture("vp8/mparts-160x96.ivf")).unwrap();
78- panic!("fixtures missing; run scripts/gen_vp8_fixtures.sh");
79- };
80- let bytes = std::fs::read(dir.join("mparts-160x96.ivf")).unwrap();
81 let (_, _, _, frames) = common::parse_ivf(&bytes);75 let (_, _, _, frames) = common::parse_ivf(&bytes);
82 let mut state = PersistedState::default();76 let mut state = PersistedState::default();
83 let (header, _) = FrameHeader::parse(&frames[0].data, &mut state).unwrap();77 let (header, _) = FrameHeader::parse(&frames[0].data, &mut state).unwrap();
@@ -89,10 +83,7 @@ fn parses_multi_partition_header() {
89 83
90 #[test]84 #[test]
91 fn parses_vp8_in_webp_still() {85 fn parses_vp8_in_webp_still() {
92- let Some(dir) = common::fixture_dir() else {86+ let Ok(bytes) = std::fs::read(ec_testkit::fixture("vp8/still.webp")) else {
93- panic!("fixtures missing; run scripts/gen_vp8_fixtures.sh");
94- };
95- let Ok(bytes) = std::fs::read(dir.join("still.webp")) else {
96 panic!("still.webp missing (libwebp encoder unavailable at generation time)");87 panic!("still.webp missing (libwebp encoder unavailable at generation time)");
97 };88 };
98 let vp8 = common::webp_vp8_chunk(&bytes);89 let vp8 = common::webp_vp8_chunk(&bytes);
@@ -107,10 +98,7 @@ fn parses_vp8_in_webp_still() {
107 98
108 #[test]99 #[test]
109 fn gop_key_frame_parses_and_coexists_with_inter() {100 fn gop_key_frame_parses_and_coexists_with_inter() {
110- let Some(dir) = common::fixture_dir() else {101+ let bytes = std::fs::read(ec_testkit::fixture("vp8/gop-160x96.ivf")).unwrap();
111- panic!("fixtures missing; run scripts/gen_vp8_fixtures.sh");
112- };
113- let bytes = std::fs::read(dir.join("gop-160x96.ivf")).unwrap();
114 let (_, _, _, frames) = common::parse_ivf(&bytes);102 let (_, _, _, frames) = common::parse_ivf(&bytes);
115 assert!(frames.len() >= 30);103 assert!(frames.len() >= 30);
116 104
crates/ec-vp8/tests/it/keyframe_exact.rsmodified+9 -19
@@ -13,14 +13,8 @@ fn raw<'a>(pos: &mut usize, data: &'a [u8], len: usize) -> &'a [u8] {
13 /// Decode every frame of an IVF with our decoder and compare each SHOWN13 /// Decode every frame of an IVF with our decoder and compare each SHOWN
14 /// frame's planes against ffmpeg's byte stream (ffmpeg skips hidden14 /// frame's planes against ffmpeg's byte stream (ffmpeg skips hidden
15 /// `show_frame == 0` frames exactly like a player).15 /// `show_frame == 0` frames exactly like a player).
16-fn compare(name: &str, skip_if_missing: bool) {16+fn compare(name: &str) {
17- let Some(dir) = common::fixture_dir() else {17+ let path = ec_testkit::fixture(&format!("vp8/{name}"));
18- panic!("fixtures missing; run scripts/gen_vp8_fixtures.sh");
19- };
20- let path = dir.join(name);
21- if skip_if_missing && !path.exists() {
22- panic!("{name} missing (regenerate fixtures)");
23- }
24 let bytes = std::fs::read(&path).unwrap();18 let bytes = std::fs::read(&path).unwrap();
25 let (_, w, h, frames) = common::parse_ivf(&bytes);19 let (_, w, h, frames) = common::parse_ivf(&bytes);
26 let all = ffmpeg_raw_yuv(&path);20 let all = ffmpeg_raw_yuv(&path);
@@ -73,13 +67,13 @@ fn keyframes_match_ffmpeg() {
73 ("kf-172x144-q25.ivf", 172, 144),67 ("kf-172x144-q25.ivf", 172, 144),
74 ("kf-96x80-q63.ivf", 96, 80),68 ("kf-96x80-q63.ivf", 96, 80),
75 ] {69 ] {
76- compare(name, false);70+ compare(name);
77 }71 }
78 }72 }
79 73
80 #[test]74 #[test]
81 fn multi_partition_keyframe_matches_ffmpeg() {75 fn multi_partition_keyframe_matches_ffmpeg() {
82- compare("mparts-160x96.ivf", false);76+ compare("mparts-160x96.ivf");
83 }77 }
84 78
85 /// M3 witness: full inter-frame streams — simple-filter GOP, multi-token-79 /// M3 witness: full inter-frame streams — simple-filter GOP, multi-token-
@@ -95,8 +89,7 @@ fn interframe_streams_match_ffmpeg() {
95 "altref-160x96.ivf",89 "altref-160x96.ivf",
96 ] {90 ] {
97 if name == "altref-160x96.ivf" {91 if name == "altref-160x96.ivf" {
98- let dir = common::fixture_dir().expect("fixtures dir");92+ let bytes = std::fs::read(ec_testkit::fixture(&format!("vp8/{name}"))).unwrap();
99- let bytes = std::fs::read(dir.join(name)).unwrap();
100 let hidden = census_hidden(&bytes);93 let hidden = census_hidden(&bytes);
101 assert!(94 assert!(
102 hidden >= 6,95 hidden >= 6,
@@ -104,7 +97,7 @@ fn interframe_streams_match_ffmpeg() {
104 scripts/gen_vp8_fixtures.sh (--auto-alt-ref=1 --passes=2)"97 scripts/gen_vp8_fixtures.sh (--auto-alt-ref=1 --passes=2)"
105 );98 );
106 }99 }
107- compare(name, false);100+ compare(name);
108 }101 }
109 }102 }
110 103
@@ -116,14 +109,11 @@ fn census_hidden(bytes: &[u8]) -> usize {
116 109
117 #[test]110 #[test]
118 fn vp8_in_webp_still_matches_ffmpeg() {111 fn vp8_in_webp_still_matches_ffmpeg() {
119- let Some(dir) = common::fixture_dir() else {112+ let bytes = std::fs::read(ec_testkit::fixture("vp8/still.webp")).unwrap();
120- panic!("fixtures missing; run scripts/gen_vp8_fixtures.sh");
121- };
122- let bytes = std::fs::read(dir.join("still.webp")).unwrap();
123 let vp8 = common::webp_vp8_chunk(&bytes);113 let vp8 = common::webp_vp8_chunk(&bytes);
124- let reference = std::process::Command::new("ffmpeg")114+ let reference = ec_testkit::ffmpeg()
125 .args(["-v", "error", "-i"])115 .args(["-v", "error", "-i"])
126- .arg(dir.join("still.webp"))116+ .arg(ec_testkit::fixture("vp8/still.webp"))
127 .args(["-f", "rawvideo", "-pix_fmt", "yuv420p", "-"])117 .args(["-f", "rawvideo", "-pix_fmt", "yuv420p", "-"])
128 .output()118 .output()
129 .unwrap();119 .unwrap();
crates/ec-vp8/tests/it/stream_exact.rsmodified+3 -12
@@ -25,11 +25,8 @@ const FIXTURES: &[&str] = &[
25 25
26 #[test]26 #[test]
27 fn decode_stream_matches_ffmpeg_on_every_fixture() {27 fn decode_stream_matches_ffmpeg_on_every_fixture() {
28- let Some(dir) = common::fixture_dir() else {
29- panic!("fixtures missing; run scripts/gen_vp8_fixtures.sh");
30- };
31 for name in FIXTURES {28 for name in FIXTURES {
32- let path = dir.join(name);29+ let path = ec_testkit::fixture(&format!("vp8/{name}"));
33 let bytes = std::fs::read(&path).unwrap();30 let bytes = std::fs::read(&path).unwrap();
34 let (_, w, h, frames) = common::parse_ivf(&bytes);31 let (_, w, h, frames) = common::parse_ivf(&bytes);
35 let all = ffmpeg_raw_yuv(&path);32 let all = ffmpeg_raw_yuv(&path);
@@ -58,10 +55,7 @@ fn decode_stream_matches_ffmpeg_on_every_fixture() {
58 /// ffmpeg.55 /// ffmpeg.
59 #[test]56 #[test]
60 fn hidden_frames_update_references_and_produce_no_picture() {57 fn hidden_frames_update_references_and_produce_no_picture() {
61- let Some(dir) = common::fixture_dir() else {58+ let path = ec_testkit::fixture("vp8/altref-160x96.ivf");
62- panic!("fixtures missing; run scripts/gen_vp8_fixtures.sh");
63- };
64- let path = dir.join("altref-160x96.ivf");
65 let bytes = std::fs::read(&path).unwrap();59 let bytes = std::fs::read(&path).unwrap();
66 let (_, w, h, frames) = common::parse_ivf(&bytes);60 let (_, w, h, frames) = common::parse_ivf(&bytes);
67 let hidden_at: Vec<usize> = frames61 let hidden_at: Vec<usize> = frames
@@ -105,10 +99,7 @@ fn hidden_frames_update_references_and_produce_no_picture() {
105 99
106 #[test]100 #[test]
107 fn decode_stream_is_error_not_panic_on_bad_containers() {101 fn decode_stream_is_error_not_panic_on_bad_containers() {
108- let Some(dir) = common::fixture_dir() else {102+ let bytes = std::fs::read(ec_testkit::fixture("vp8/gop-160x96.ivf")).unwrap();
109- panic!("fixtures missing; run scripts/gen_vp8_fixtures.sh");
110- };
111- let bytes = std::fs::read(dir.join("gop-160x96.ivf")).unwrap();
112 103
113 // Missing magic.104 // Missing magic.
114 let mut bad = bytes.clone();105 let mut bad = bytes.clone();
crates/ec-vp8/tests/malformed_no_panic.rsmodified+1 -9
@@ -3,11 +3,6 @@
3 //! seeded single-byte corruptions; each decode runs under `catch_unwind` so a3 //! seeded single-byte corruptions; each decode runs under `catch_unwind` so a
4 //! failure names the file and the damage that caused it.4 //! failure names the file and the damage that caused it.
5 5
6-// Only `fixture_dir` is used here; the IVF parser serves the other test crates.
7-#[allow(dead_code)]
8-#[path = "it/common.rs"]
9-mod ivf;
10-
11 use std::panic::{AssertUnwindSafe, catch_unwind};6 use std::panic::{AssertUnwindSafe, catch_unwind};
12 7
13 use ec_vp8::stream::decode_stream;8 use ec_vp8::stream::decode_stream;
@@ -59,9 +54,6 @@ fn decode_must_not_panic(data: &[u8], what: &str) {
59 54
60 #[test]55 #[test]
61 fn truncated_and_corrupted_fixtures_never_panic() {56 fn truncated_and_corrupted_fixtures_never_panic() {
62- let Some(dir) = ivf::fixture_dir() else {
63- panic!("fixtures missing; run scripts/gen_vp8_fixtures.sh");
64- };
65 // Silence the default panic hook while probing; failures are reported57 // Silence the default panic hook while probing; failures are reported
66 // by the assertion above, which names the file and the damage.58 // by the assertion above, which names the file and the damage.
67 let hook = std::panic::take_hook();59 let hook = std::panic::take_hook();
@@ -70,7 +62,7 @@ fn truncated_and_corrupted_fixtures_never_panic() {
70 let mut rng = Rng(SEED);62 let mut rng = Rng(SEED);
71 let mut failures = Vec::new();63 let mut failures = Vec::new();
72 for name in FIXTURES {64 for name in FIXTURES {
73- let bytes = std::fs::read(dir.join(name)).unwrap();65+ let bytes = std::fs::read(ec_testkit::fixture(&format!("vp8/{name}"))).unwrap();
74 assert!(bytes.len() > 32, "{name}: fixture too small");66 assert!(bytes.len() > 32, "{name}: fixture too small");
75 67
76 for k in 1..=TRUNCATIONS {68 for k in 1..=TRUNCATIONS {
crates/ec-vp9-syntax/Cargo.tomlmodified+3 -0
@@ -8,3 +8,6 @@ authors.workspace = true
8 8
9 [dependencies]9 [dependencies]
10 ec-core.workspace = true10 ec-core.workspace = true
11+
12+[dev-dependencies]
13+ec-testkit.workspace = true
crates/ec-vp9-syntax/tests/streams.rsmodified+9 -42
@@ -1,19 +1,13 @@
1 //! Every VP9 fixture stream parsed end to end, field-compared against ffprobe.1 //! Every VP9 fixture stream parsed end to end, field-compared against ffprobe.
2 //!2 //!
3-//! `scripts/gen-bitstream-fixtures.sh` remuxes the container fixtures to IVF and3+//! `scripts/fixtures.sh` builds the `bitstreams/` fixtures (superframes, 4:4:4, tiles);
4-//! encodes the branch cases (superframes, 4:4:4, tiles). Fixtures are gitignored,4+//! a missing fixture fails the test.
5-//! so a checkout without them skips rather than fails.
6 5
7 use std::path::{Path, PathBuf};6 use std::path::{Path, PathBuf};
8-use std::process::Command;
9 7
10 use ec_core::Error;8 use ec_core::Error;
11 use ec_vp9_syntax::{FrameType, Vp9Parser, superframe};9 use ec_vp9_syntax::{FrameType, Vp9Parser, superframe};
12 10
13-fn bitstreams() -> PathBuf {
14- Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/bitstreams")
15-}
16-
17 /// The IVF frames of a file, payload only.11 /// The IVF frames of a file, payload only.
18 fn ivf_frames(data: &[u8]) -> Vec<&[u8]> {12 fn ivf_frames(data: &[u8]) -> Vec<&[u8]> {
19 let mut out = Vec::new();13 let mut out = Vec::new();
@@ -31,7 +25,7 @@ fn ivf_frames(data: &[u8]) -> Vec<&[u8]> {
31 }25 }
32 26
33 fn ffprobe(path: &Path, entries: &str) -> Vec<String> {27 fn ffprobe(path: &Path, entries: &str) -> Vec<String> {
34- let out = Command::new("ffprobe")28+ let out = ec_testkit::ffprobe()
35 .args(["-v", "error", "-select_streams", "v:0", "-show_entries"])29 .args(["-v", "error", "-select_streams", "v:0", "-show_entries"])
36 .arg(entries)30 .arg(entries)
37 .args(["-of", "csv=p=0"])31 .args(["-of", "csv=p=0"])
@@ -84,32 +78,15 @@ fn pix_fmt_geometry(pix_fmt: &str) -> (u8, u8, u8) {
84 }78 }
85 79
86 fn fixtures() -> Vec<PathBuf> {80 fn fixtures() -> Vec<PathBuf> {
87- let dir = bitstreams();81+ ec_testkit::fixtures("bitstreams", "ivf")
88- let Ok(entries) = std::fs::read_dir(&dir) else {82+ .into_iter()
89- return Vec::new();83+ .filter(|p| p.file_name().is_some_and(|n| n.to_string_lossy().starts_with("vp9-")))
90- };84+ .collect()
91- let mut files: Vec<PathBuf> = entries
92- .filter_map(|e| e.ok().map(|e| e.path()))
93- .filter(|p| {
94- p.extension().is_some_and(|e| e == "ivf")
95- && p.file_name()
96- .is_some_and(|n| n.to_string_lossy().starts_with("vp9-"))
97- })
98- .collect();
99- files.sort();
100- files
101 }85 }
102 86
103 #[test]87 #[test]
104 fn every_fixture_matches_ffprobe() {88 fn every_fixture_matches_ffprobe() {
105- let files = fixtures();89+ for path in fixtures() {
106- if files.is_empty() {
107- eprintln!(
108- "skipped: no fixtures/bitstreams/vp9-*.ivf — run scripts/gen-bitstream-fixtures.sh"
109- );
110- return;
111- }
112- for path in files {
113 let name = path.file_name().unwrap().to_string_lossy().to_string();90 let name = path.file_name().unwrap().to_string_lossy().to_string();
114 let (width, height, pix_fmt, profile) = probe_stream(&path);91 let (width, height, pix_fmt, profile) = probe_stream(&path);
115 let (bit_depth, sx, sy) = pix_fmt_geometry(&pix_fmt);92 let (bit_depth, sx, sy) = pix_fmt_geometry(&pix_fmt);
@@ -197,11 +174,7 @@ fn every_fixture_matches_ffprobe() {
197 /// genuine `show_existing_frame` headers; libaom uses them.)174 /// genuine `show_existing_frame` headers; libaom uses them.)
198 #[test]175 #[test]
199 fn altref_fixture_has_superframes_and_hidden_frames() {176 fn altref_fixture_has_superframes_and_hidden_frames() {
200- let path = bitstreams().join("vp9-superframe-altref.ivf");177+ let path = ec_testkit::fixture("bitstreams/vp9-superframe-altref.ivf");
201- if !path.exists() {
202- eprintln!("skipped: no vp9-superframe-altref.ivf");
203- return;
204- }
205 let data = std::fs::read(&path).unwrap();178 let data = std::fs::read(&path).unwrap();
206 let mut parser = Vp9Parser::new();179 let mut parser = Vp9Parser::new();
207 let (mut superframes, mut hidden) = (0, 0);180 let (mut superframes, mut hidden) = (0, 0);
@@ -245,12 +218,6 @@ fn fuzz_10k_mutations_never_panics() {
245 .collect::<Vec<_>>()218 .collect::<Vec<_>>()
246 })219 })
247 .collect();220 .collect();
248- let seeds = if seeds.is_empty() {
249- // No fixtures: still exercise the parser against pure noise.
250- vec![vec![0x82u8; 128]]
251- } else {
252- seeds
253- };
254 221
255 let mut state = 0x2545_f491_4f6c_dd1du64;222 let mut state = 0x2545_f491_4f6c_dd1du64;
256 let mut rng = move || {223 let mut rng = move || {
crates/ec-vp9/Cargo.tomlmodified+3 -0
@@ -9,3 +9,6 @@ authors.workspace = true
9 [dependencies]9 [dependencies]
10 ec-core.workspace = true10 ec-core.workspace = true
11 ec-vp9-syntax.workspace = true11 ec-vp9-syntax.workspace = true
12+
13+[dev-dependencies]
14+ec-testkit.workspace = true
crates/ec-vp9/fuzz/seed.shmodified+2 -2
@@ -5,13 +5,13 @@
5 # into corpus/decode_frame/. Whole IVF files up to 256 KiB go into corpus/decode_stream/, and5 # into corpus/decode_frame/. Whole IVF files up to 256 KiB go into corpus/decode_stream/, and
6 # a 10-frame prefix of every larger file too. The corpus is generated, not committed.6 # a 10-frame prefix of every larger file too. The corpus is generated, not committed.
7 #7 #
8-# Usage: crates/ec-vp9/fuzz/seed.sh (from any directory; needs python3 and the fixtures/ link)8+# Usage: crates/ec-vp9/fuzz/seed.sh (from any directory; needs python3 and fixtures from scripts/fixtures.sh)
9 set -euo pipefail9 set -euo pipefail
10 here=$(cd -- "$(dirname -- "$0")" && pwd)10 here=$(cd -- "$(dirname -- "$0")" && pwd)
11 repo=$(cd -- "$here/../../.." && pwd)11 repo=$(cd -- "$here/../../.." && pwd)
12 rm -rf "$here/corpus"12 rm -rf "$here/corpus"
13 mkdir -p "$here/corpus/decode_frame" "$here/corpus/decode_stream"13 mkdir -p "$here/corpus/decode_frame" "$here/corpus/decode_stream"
14-exec python3 -I - "$here" "decode_stream" "$repo/fixtures/vp9/*.ivf" "$here/../tests/data/*.ivf" <<'PY'14+exec python3 -I - "$here" "decode_stream" "${EC_FIXTURES:-$repo/fixtures}/vp9/*.ivf" "$here/../tests/data/*.ivf" <<'PY'
15 import glob, os, struct, sys15 import glob, os, struct, sys
16 16
17 here, stream_target = sys.argv[1], sys.argv[2]17 here, stream_target = sys.argv[1], sys.argv[2]
crates/ec-vp9/tests/it/common.rsmodified+2 -26
@@ -1,37 +1,13 @@
1 //! Helpers shared by the integration-test modules of the `it` binary.1 //! Helpers shared by the integration-test modules of the `it` binary.
2 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.
13-pub(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`).3 /// ffmpeg's decoded rawvideo byte stream (frame-packed I420, `w`x`h`).
28 pub(crate) fn ffmpeg_raw_yuv(path: &std::path::Path, w: usize, h: usize) -> Vec<u8> {4 pub(crate) fn ffmpeg_raw_yuv(path: &std::path::Path, w: usize, h: usize) -> Vec<u8> {
29- let out = std::process::Command::new("ffmpeg")5+ let out = ec_testkit::ffmpeg()
30 .args(["-v", "error", "-i"])6 .args(["-v", "error", "-i"])
31 .arg(path)7 .arg(path)
32 .args(["-f", "rawvideo", "-pix_fmt", "yuv420p", "-"])8 .args(["-f", "rawvideo", "-pix_fmt", "yuv420p", "-"])
33 .output()9 .output()
34- .expect("ffmpeg on PATH");10+ .expect("ffmpeg runs");
35 assert!(out.status.success(), "ffmpeg decode failed: {out:?}");11 assert!(out.status.success(), "ffmpeg decode failed: {out:?}");
36 let frame = w * h + 2 * (w / 2) * (h / 2);12 let frame = w * h + 2 * (w / 2) * (h / 2);
37 assert_eq!(13 assert_eq!(
crates/ec-vp9/tests/it/dump_probe.rsmodified+3 -4
@@ -2,13 +2,12 @@ use crate::ivf;
2 use ec_vp9::decode::Decoder;2 use ec_vp9::decode::Decoder;
3 #[test]3 #[test]
4 fn diff_stats() {4 fn diff_stats() {
5- let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../..");5+ let bytes = std::fs::read(ec_testkit::fixture("vp9/key-320.ivf")).unwrap();
6- let bytes = std::fs::read(dir.join("fixtures/vp9/key-320.ivf")).unwrap();
7 let (_, _, _, frames) = ivf::parse_ivf(&bytes);6 let (_, _, _, frames) = ivf::parse_ivf(&bytes);
8 let mut d = Decoder::new();7 let mut d = Decoder::new();
9 let pic = d.decode(&frames[0].data).unwrap().unwrap();8 let pic = d.decode(&frames[0].data).unwrap().unwrap();
10- let refout = std::process::Command::new("ffmpeg")9+ let refout = ec_testkit::ffmpeg()
11- .args(["-v","error","-i",dir.join("fixtures/vp9/key-320.ivf").to_str().unwrap(),10+ .args(["-v","error","-i",ec_testkit::fixture("vp9/key-320.ivf").to_str().unwrap(),
12 "-frames:v","1","-f","rawvideo","-pix_fmt","yuv420p","-"])11 "-frames:v","1","-f","rawvideo","-pix_fmt","yuv420p","-"])
13 .output().unwrap().stdout;12 .output().unwrap().stdout;
14 let w = 320usize;13 let w = 320usize;
crates/ec-vp9/tests/it/hbd_exact.rsmodified+6 -20
@@ -3,34 +3,23 @@
3 //! yuv420p10le -`). Pre-fix the decoder refuses `profile 2` by name, so this3 //! yuv420p10le -`). Pre-fix the decoder refuses `profile 2` by name, so this
4 //! test fails at the first frame; post-fix every shown frame matches.4 //! test fails at the first frame; post-fix every shown frame matches.
5 //!5 //!
6-//! Media-gated: the 10-bit corpus streams are gitignored, so the test prints6+//! Needs the `bitstreams/` fixtures from scripts/fixtures.sh. The 4:4:4 and
7-//! SKIP when the fixture is absent (set the fixture tree up per the lane7+//! 12-bit shapes are covered by `subsampling_exact.rs`.
8-//! notes) -- and goes RED instead under `EC_REQUIRE_FIXTURES=1`, so a drifted
9-//! fixture library can never read as a pass. The 4:4:4 and 12-bit shapes are
10-//! covered by `subsampling_exact.rs`.
11 8
12 use crate::ivf;9 use crate::ivf;
13-use crate::common::require_fixture;
14 10
15 use ec_vp9::decode::Decoder;11 use ec_vp9::decode::Decoder;
16-use std::path::{Path, PathBuf};12+use std::path::Path;
17-
18-fn fixture(name: &str) -> PathBuf {
19- let mut p = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
20- p.pop();
21- p.pop();
22- p.join("fixtures/bitstreams").join(name)
23-}
24 13
25 /// ffmpeg's rawvideo `yuv420p10le` bytes (little-endian u16 samples,14 /// ffmpeg's rawvideo `yuv420p10le` bytes (little-endian u16 samples,
26 /// stride == visible width).15 /// stride == visible width).
27 fn ffmpeg_raw_yuv10(path: &Path) -> Vec<u8> {16 fn ffmpeg_raw_yuv10(path: &Path) -> Vec<u8> {
28- let out = std::process::Command::new("ffmpeg")17+ let out = ec_testkit::ffmpeg()
29 .args(["-v", "error", "-i"])18 .args(["-v", "error", "-i"])
30 .arg(path)19 .arg(path)
31 .args(["-f", "rawvideo", "-pix_fmt", "yuv420p10le", "-"])20 .args(["-f", "rawvideo", "-pix_fmt", "yuv420p10le", "-"])
32 .output()21 .output()
33- .expect("ffmpeg must be on PATH for the witnesses");22+ .expect("ffmpeg runs for the witnesses");
34 assert!(out.status.success(), "ffmpeg failed on {path:?}");23 assert!(out.status.success(), "ffmpeg failed on {path:?}");
35 out.stdout24 out.stdout
36 }25 }
@@ -58,10 +47,7 @@ fn decode_all(path: &Path) -> (Vec<Vec<u8>>, u8) {
58 /// produces, sample for sample.47 /// produces, sample for sample.
59 #[test]48 #[test]
60 fn profile2_10bit_is_byte_exact() {49 fn profile2_10bit_is_byte_exact() {
61- let a = fixture("vp9-1080p-23.976-10bit.ivf");50+ let a = ec_testkit::fixture("bitstreams/vp9-1080p-23.976-10bit.ivf");
62- if !require_fixture(&a, "scripts/gen-bitstream-fixtures.sh") {
63- return;
64- }
65 let (ours, bd) = decode_all(&a);51 let (ours, bd) = decode_all(&a);
66 assert_eq!(bd, 10, "the fixture must decode at 10 bits");52 assert_eq!(bd, 10, "the fixture must decode at 10 bits");
67 let want = ffmpeg_raw_yuv10(&a);53 let want = ffmpeg_raw_yuv10(&a);
crates/ec-vp9/tests/it/inter_pixels_exact.rsmodified+7 -13
@@ -7,7 +7,7 @@
7 //! `tests/scratch_pixdump.rs` (env-gated) instead; see `lanes/vp9pix.report.md`.7 //! `tests/scratch_pixdump.rs` (env-gated) instead; see `lanes/vp9pix.report.md`.
8 8
9 use crate::ivf;9 use crate::ivf;
10-use crate::common::{ffmpeg_raw_yuv, require_fixture};10+use crate::common::ffmpeg_raw_yuv;
11 11
12 use ec_vp9::decode::Decoder;12 use ec_vp9::decode::Decoder;
13 /// Generate a GOP fixture with libvpx: 6 frames of testsrc2 at 320x240,13 /// Generate a GOP fixture with libvpx: 6 frames of testsrc2 at 320x240,
@@ -19,7 +19,7 @@ fn ensure_fixture(path: &std::path::Path, tile_columns: u32) {
19 if let Some(dir) = path.parent() {19 if let Some(dir) = path.parent() {
20 std::fs::create_dir_all(dir).unwrap();20 std::fs::create_dir_all(dir).unwrap();
21 }21 }
22- let st = std::process::Command::new("ffmpeg")22+ let st = ec_testkit::ffmpeg()
23 .args([23 .args([
24 "-v",24 "-v",
25 "error",25 "error",
@@ -44,7 +44,7 @@ fn ensure_fixture(path: &std::path::Path, tile_columns: u32) {
44 .args(["-pix_fmt", "yuv420p", "-f", "ivf"])44 .args(["-pix_fmt", "yuv420p", "-f", "ivf"])
45 .arg(path)45 .arg(path)
46 .output()46 .output()
47- .expect("ffmpeg with libvpx-vp9 must be on PATH for the witnesses");47+ .expect("ffmpeg with libvpx-vp9 runs for the witnesses");
48 assert!(st.status.success(), "fixture generation failed: {st:?}");48 assert!(st.status.success(), "fixture generation failed: {st:?}");
49 }49 }
50 50
@@ -98,7 +98,7 @@ fn compare(path: &std::path::Path) -> usize {
98 98
99 #[test]99 #[test]
100 fn inter_gop_matches_ffmpeg() {100 fn inter_gop_matches_ffmpeg() {
101- let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../../target/vp9-witness");101+ let dir = std::env::temp_dir().join("ec-vp9-witness");
102 let path = dir.join("inter-gop.ivf");102 let path = dir.join("inter-gop.ivf");
103 ensure_fixture(&path, 0);103 ensure_fixture(&path, 0);
104 assert!(compare(&path) >= 2);104 assert!(compare(&path) >= 2);
@@ -106,7 +106,7 @@ fn inter_gop_matches_ffmpeg() {
106 106
107 #[test]107 #[test]
108 fn inter_gop_with_tile_columns_matches_ffmpeg() {108 fn inter_gop_with_tile_columns_matches_ffmpeg() {
109- let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../../target/vp9-witness");109+ let dir = std::env::temp_dir().join("ec-vp9-witness");
110 let path = dir.join("inter-gop-tc1.ivf");110 let path = dir.join("inter-gop-tc1.ivf");
111 ensure_fixture(&path, 1);111 ensure_fixture(&path, 1);
112 assert!(compare(&path) >= 2);112 assert!(compare(&path) >= 2);
@@ -119,16 +119,10 @@ fn inter_gop_with_tile_columns_matches_ffmpeg() {
119 /// TAIL slot set (`write_tx_context`), and the next row of blocks read it119 /// TAIL slot set (`write_tx_context`), and the next row of blocks read it
120 /// as an entropy context. Every shown frame must match ffmpeg.120 /// as an entropy context. Every shown frame must match ffmpeg.
121 ///121 ///
122-/// Media-gated: the corpus fixture is not versioned, so the witness prints122+/// Needs the `bitstreams/vp9-1080p-60-8bit.ivf` fixture from scripts/fixtures.sh.
123-/// SKIP when `fixtures/bitstreams/vp9-1080p-60-8bit.ivf` is absent -- and goes
124-/// RED instead under `EC_REQUIRE_FIXTURES=1`.
125 #[test]123 #[test]
126 fn corpus_1080p_60fps_matches_ffmpeg_past_frame_72() {124 fn corpus_1080p_60fps_matches_ffmpeg_past_frame_72() {
127- let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))125+ let path = ec_testkit::fixture("bitstreams/vp9-1080p-60-8bit.ivf");
128- .join("../../fixtures/bitstreams/vp9-1080p-60-8bit.ivf");
129- if !require_fixture(&path, "scripts/gen-bitstream-fixtures.sh") {
130- return;
131- }
132 let shown = compare(&path);126 let shown = compare(&path);
133 assert!(127 assert!(
134 shown >= 73,128 shown >= 73,
crates/ec-vp9/tests/it/ivf.rsmodified+0 -19
@@ -47,22 +47,3 @@ pub fn parse_ivf(bytes: &[u8]) -> (&str, u16, u16, Vec<IvfFrame>) {
47 (fourcc, width, height, frames)47 (fourcc, width, height, frames)
48 }48 }
49 49
50-/// Root of the workspace checkout this test runs in (crates/ec-vp9/../..).
51-#[allow(dead_code)] // shared by the `it` test binary
52-///
53-/// With `EC_REQUIRE_FIXTURES` set, an absent directory is a hard failure, so a
54-/// host without the fixtures cannot pass by skipping.
55-pub fn fixture_dir() -> Option<std::path::PathBuf> {
56- let bitstreams =
57- std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/bitstreams");
58- if bitstreams.is_dir() {
59- Some(bitstreams)
60- } else {
61- assert!(
62- std::env::var_os("EC_REQUIRE_FIXTURES").is_none(),
63- "EC_REQUIRE_FIXTURES=1 but {} is absent",
64- bitstreams.display()
65- );
66- None
67- }
68-}
crates/ec-vp9/tests/it/keyframe_exact.rsmodified+5 -46
@@ -6,49 +6,14 @@ use crate::ivf;
6 6
7 use ec_vp9::decode::Decoder;7 use ec_vp9::decode::Decoder;
8 8
9-/// Generate the small all-keyframe fixture with libvpx if it is absent
10-/// (2 keyframes of 320x240 testsrc2, realtime cpu-used 4).
11-fn ensure_fixture(path: &std::path::Path) {
12- if path.exists() {
13- return;
14- }
15- if let Some(dir) = path.parent() {
16- std::fs::create_dir_all(dir).unwrap();
17- }
18- let st = std::process::Command::new("ffmpeg")
19- .args([
20- "-y",
21- "-f",
22- "lavfi",
23- "-i",
24- "testsrc2=size=320x240:rate=30:duration=1",
25- "-pix_fmt",
26- "yuv420p",
27- "-c:v",
28- "libvpx-vp9",
29- "-g",
30- "1",
31- "-cpu-used",
32- "4",
33- "-deadline",
34- "realtime",
35- "-frames:v",
36- "2",
37- ])
38- .arg(path)
39- .output()
40- .expect("ffmpeg with libvpx-vp9 must be on PATH for the witnesses");
41- assert!(st.status.success(), "fixture generation failed: {st:?}");
42-}
43-
44 /// ffmpeg's decoded rawvideo byte stream for the same file.9 /// ffmpeg's decoded rawvideo byte stream for the same file.
45 fn ffmpeg_raw_yuv(path: &std::path::Path) -> Vec<u8> {10 fn ffmpeg_raw_yuv(path: &std::path::Path) -> Vec<u8> {
46- let out = std::process::Command::new("ffmpeg")11+ let out = ec_testkit::ffmpeg()
47 .args(["-v", "error", "-i"])12 .args(["-v", "error", "-i"])
48 .arg(path)13 .arg(path)
49 .args(["-f", "rawvideo", "-pix_fmt", "yuv420p", "-"])14 .args(["-f", "rawvideo", "-pix_fmt", "yuv420p", "-"])
50 .output()15 .output()
51- .expect("ffmpeg must be on PATH for the witnesses");16+ .expect("ffmpeg runs for the witnesses");
52 assert!(out.status.success(), "ffmpeg failed on {path:?}");17 assert!(out.status.success(), "ffmpeg failed on {path:?}");
53 out.stdout18 out.stdout
54 }19 }
@@ -113,16 +78,13 @@ fn compare(path: &std::path::Path) {
113 78
114 #[test]79 #[test]
115 fn keyframes_match_ffmpeg() {80 fn keyframes_match_ffmpeg() {
116- let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/vp9");81+ let path = ec_testkit::fixture("vp9/key-320.ivf");
117- let path = dir.join("key-320.ivf");
118- ensure_fixture(&path);
119 compare(&path);82 compare(&path);
120 }83 }
121 84
122 #[test]85 #[test]
123 fn lossless_64_matches_ffmpeg() {86 fn lossless_64_matches_ffmpeg() {
124- let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../..");87+ let path = ec_testkit::fixture("vp9/lossless-64.ivf");
125- let path = dir.join("fixtures/vp9/lossless-64.ivf");
126 let bytes = std::fs::read(&path).unwrap();88 let bytes = std::fs::read(&path).unwrap();
127 let (_fourcc, w, h, frames) = ivf::parse_ivf(&bytes);89 let (_fourcc, w, h, frames) = ivf::parse_ivf(&bytes);
128 let reference = ffmpeg_raw_yuv(&path);90 let reference = ffmpeg_raw_yuv(&path);
@@ -157,10 +119,7 @@ fn inter_stream_decodes_and_matches_ffmpeg() {
157 // used to be the "inter is refused by name" witness. Inter frames decode119 // used to be the "inter is refused by name" witness. Inter frames decode
158 // now, so the witness is the pixels: every shown frame must match120 // now, so the witness is the pixels: every shown frame must match
159 // ffmpeg's libvpx output byte for byte.121 // ffmpeg's libvpx output byte for byte.
160- let Some(dir) = ivf::fixture_dir() else {122+ let path = ec_testkit::fixture("bitstreams/vp9-superframe-altref.ivf");
161- return;
162- };
163- let path = dir.join("vp9-superframe-altref.ivf");
164 let bytes = std::fs::read(&path).unwrap();123 let bytes = std::fs::read(&path).unwrap();
165 let (_, w, h, frames) = ivf::parse_ivf(&bytes);124 let (_, w, h, frames) = ivf::parse_ivf(&bytes);
166 let (w, h) = (w as usize, h as usize);125 let (w, h) = (w as usize, h as usize);
crates/ec-vp9/tests/it/libvpx_vectors.rsmodified+3 -22
@@ -9,18 +9,11 @@
9 //! The test decodes every vector, digests every returned picture and compares9 //! The test decodes every vector, digests every returned picture and compares
10 //! the digest with the matching line, in order. Any frame-count or digest10 //! the digest with the matching line, in order. Any frame-count or digest
11 //! difference fails the test and is listed by vector name and frame index.11 //! difference fails the test and is listed by vector name and frame index.
12-//! Vectors are read from the fixture tree (`scripts/fetch-vectors.sh12+//! Vectors come from the fixture tree (`scripts/fixtures.sh`); a missing tree fails.
13-//! vp9-libvpx`). Without the fixtures the test skips, unless
14-//! `EC_REQUIRE_FIXTURES` is set, in which case it fails.
15 13
16 use ec_vp9::decode::{Decoder, Picture};14 use ec_vp9::decode::{Decoder, Picture};
17 use std::path::{Path, PathBuf};15 use std::path::{Path, PathBuf};
18 16
19-/// Directory of the fetched libvpx vectors (crates/ec-vp9/../../fixtures).
20-fn vector_dir() -> PathBuf {
21- Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/vectors/vp9-libvpx")
22-}
23-
24 // ------------------------------------------------------------------ MD5 ----17 // ------------------------------------------------------------------ MD5 ----
25 18
26 /// RFC 1321 MD5 of `data`, as lowercase hex.19 /// RFC 1321 MD5 of `data`, as lowercase hex.
@@ -253,20 +246,8 @@ fn check_vector(name: &str, frames: &[&[u8]], expected: &[String]) -> Vec<String
253 246
254 #[test]247 #[test]
255 fn libvpx_vectors_match_per_frame_md5() {248 fn libvpx_vectors_match_per_frame_md5() {
256- let dir = vector_dir();249+ let dir = ec_testkit::fixture("vectors/vp9-libvpx");
257- let require = std::env::var_os("EC_REQUIRE_FIXTURES").is_some();250+ let entries = std::fs::read_dir(&dir).expect("vector directory");
258- let entries = match std::fs::read_dir(&dir) {
259- Ok(e) => e,
260- Err(_) => {
261- assert!(
262- !require,
263- "EC_REQUIRE_FIXTURES=1 but {} is absent (run scripts/fetch-vectors.sh vp9-libvpx)",
264- dir.display()
265- );
266- eprintln!("skip: {} absent", dir.display());
267- return;
268- }
269- };
270 let mut md5_files: Vec<PathBuf> = entries251 let mut md5_files: Vec<PathBuf> = entries
271 .filter_map(|e| e.ok().map(|e| e.path()))252 .filter_map(|e| e.ok().map(|e| e.path()))
272 .filter(|p| p.extension().is_some_and(|x| x == "md5"))253 .filter(|p| p.extension().is_some_and(|x| x == "md5"))
crates/ec-vp9/tests/it/main.rsmodified+0 -1
@@ -25,7 +25,6 @@ mod scratch_lossless;
25 mod scratch_pixdump10;25 mod scratch_pixdump10;
26 mod scratch_pixdump;26 mod scratch_pixdump;
27 mod scratch_realsweep;27 mod scratch_realsweep;
28-mod scratch_synth;
29 mod scratch_tiledbg;28 mod scratch_tiledbg;
30 mod scratch_tok;29 mod scratch_tok;
31 mod subsampling_exact;30 mod subsampling_exact;
crates/ec-vp9/tests/it/odd_dimensions_exact.rsmodified+5 -5
@@ -27,7 +27,7 @@ fn ensure_even_fixture(path: &Path) {
27 if let Some(dir) = path.parent() {27 if let Some(dir) = path.parent() {
28 std::fs::create_dir_all(dir).unwrap();28 std::fs::create_dir_all(dir).unwrap();
29 }29 }
30- let st = std::process::Command::new("ffmpeg")30+ let st = ec_testkit::ffmpeg()
31 .args([31 .args([
32 "-v",32 "-v",
33 "error",33 "error",
@@ -55,7 +55,7 @@ fn ensure_even_fixture(path: &Path) {
55 ])55 ])
56 .arg(path)56 .arg(path)
57 .output()57 .output()
58- .expect("ffmpeg with libvpx-vp9 must be on PATH for the witnesses");58+ .expect("ffmpeg with libvpx-vp9 runs for the witnesses");
59 assert!(st.status.success(), "fixture generation failed: {st:?}");59 assert!(st.status.success(), "fixture generation failed: {st:?}");
60 }60 }
61 61
@@ -86,12 +86,12 @@ fn patched(ivf: &[u8], nw: u16, nh: u16) -> Vec<u8> {
86 86
87 /// ffmpeg's decoded rawvideo byte stream (frame-packed I420, ceil chroma).87 /// ffmpeg's decoded rawvideo byte stream (frame-packed I420, ceil chroma).
88 fn ffmpeg_raw_yuv(path: &Path) -> Vec<u8> {88 fn ffmpeg_raw_yuv(path: &Path) -> Vec<u8> {
89- let out = std::process::Command::new("ffmpeg")89+ let out = ec_testkit::ffmpeg()
90 .args(["-v", "error", "-i"])90 .args(["-v", "error", "-i"])
91 .arg(path)91 .arg(path)
92 .args(["-f", "rawvideo", "-pix_fmt", "yuv420p", "-"])92 .args(["-f", "rawvideo", "-pix_fmt", "yuv420p", "-"])
93 .output()93 .output()
94- .expect("ffmpeg on PATH");94+ .expect("ffmpeg runs");
95 assert!(out.status.success(), "ffmpeg decode failed: {out:?}");95 assert!(out.status.success(), "ffmpeg decode failed: {out:?}");
96 out.stdout96 out.stdout
97 }97 }
@@ -100,7 +100,7 @@ fn ffmpeg_raw_yuv(path: &Path) -> Vec<u8> {
100 /// every frame must carry the odd coded size (frame 0 sets it, the rest100 /// every frame must carry the odd coded size (frame 0 sets it, the rest
101 /// inherit it), and there must be inter frames.101 /// inherit it), and there must be inter frames.
102 fn check(nw: u16, nh: u16) {102 fn check(nw: u16, nh: u16) {
103- let dir = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../target/vp9-witness");103+ let dir = std::env::temp_dir().join("ec-vp9-witness");
104 let even = dir.join("odd-src-322x242.ivf");104 let even = dir.join("odd-src-322x242.ivf");
105 ensure_even_fixture(&even);105 ensure_even_fixture(&even);
106 let odd = dir.join(format!("odd-{nw}x{nh}.ivf"));106 let odd = dir.join(format!("odd-{nw}x{nh}.ivf"));
crates/ec-vp9/tests/it/scaledref_exact.rsmodified+2 -2
@@ -40,13 +40,13 @@ fn fixture(name: &str) -> std::path::PathBuf {
40 40
41 /// Run ffmpeg over `path` with `args` and return its rawvideo stdout.41 /// Run ffmpeg over `path` with `args` and return its rawvideo stdout.
42 fn ffmpeg_raw(path: &std::path::Path, args: &[&str]) -> Vec<u8> {42 fn ffmpeg_raw(path: &std::path::Path, args: &[&str]) -> Vec<u8> {
43- let out = std::process::Command::new("ffmpeg")43+ let out = ec_testkit::ffmpeg()
44 .args(["-v", "error", "-y", "-i"])44 .args(["-v", "error", "-y", "-i"])
45 .arg(path)45 .arg(path)
46 .args(args)46 .args(args)
47 .args(["-f", "rawvideo", "-pix_fmt", "yuv420p", "-"])47 .args(["-f", "rawvideo", "-pix_fmt", "yuv420p", "-"])
48 .output()48 .output()
49- .expect("ffmpeg on PATH");49+ .expect("ffmpeg runs");
50 assert!(out.status.success(), "ffmpeg decode failed: {out:?}");50 assert!(out.status.success(), "ffmpeg decode failed: {out:?}");
51 out.stdout51 out.stdout
52 }52 }
crates/ec-vp9/tests/it/scratch_bool.rsmodified+1 -2
@@ -3,8 +3,7 @@ use ec_vp9::bool::BoolDecoder;
3 3
4 #[test]4 #[test]
5 fn probe_first_bools() {5 fn probe_first_bools() {
6- let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../..");6+ let bytes = std::fs::read(ec_testkit::fixture("vp9/lossless-64.ivf")).unwrap();
7- let bytes = std::fs::read(dir.join("fixtures/vp9/lossless-64.ivf")).unwrap();
8 let (_, _, _, frames) = ivf::parse_ivf(&bytes);7 let (_, _, _, frames) = ivf::parse_ivf(&bytes);
9 let frame = &frames[0].data;8 let frame = &frames[0].data;
10 println!("slice bytes: {:02x?}", &frame[18..26]);9 println!("slice bytes: {:02x?}", &frame[18..26]);
crates/ec-vp9/tests/it/scratch_err.rsmodified+2 -6
@@ -2,14 +2,10 @@ use crate::ivf;
2 use ec_vp9::decode::Decoder;2 use ec_vp9::decode::Decoder;
3 #[test]3 #[test]
4 fn show_err() {4 fn show_err() {
5- let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../..");5+ let bytes = std::fs::read(ec_testkit::fixture("bitstreams/vp9-superframe-altref.ivf")).unwrap();
6- let bytes = std::fs::read(dir.join("fixtures/bitstreams/vp9-superframe-altref.ivf")).unwrap();
7 let (_, _, _, frames) = ivf::parse_ivf(&bytes);6 let (_, _, _, frames) = ivf::parse_ivf(&bytes);
8 let mut d = Decoder::new();7 let mut d = Decoder::new();
9- let dir2 = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../..");8+ println!("f0 bytes: {:02x?}", &frames[0].data[16..24]);
10- let b2 = std::fs::read(dir2.join("fixtures/bitstreams/vp9-superframe-altref.ivf")).unwrap();
11- let (_, _, _, f2) = ivf::parse_ivf(&b2);
12- println!("f0 bytes: {:02x?}", &f2[0].data[16..24]);
13 match d.decode(&frames[0].data) {9 match d.decode(&frames[0].data) {
14 Ok(_) => println!("OK"),10 Ok(_) => println!("OK"),
15 Err(e) => println!("ERR: {e}"),11 Err(e) => println!("ERR: {e}"),
crates/ec-vp9/tests/it/scratch_hdr.rsmodified+1 -4
@@ -2,10 +2,7 @@ use ec_vp9_syntax::Vp9Parser;
2 #[test]2 #[test]
3 fn hdr_probe() {3 fn hdr_probe() {
4 for name in ["lossless-64.ivf", "key-320.ivf"] {4 for name in ["lossless-64.ivf", "key-320.ivf"] {
5- let mut p = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));5+ let bytes = std::fs::read(ec_testkit::fixture(&format!("vp9/{name}"))).unwrap();
6- p.pop(); p.pop();
7- p = p.join("fixtures/vp9").join(name);
8- let bytes = std::fs::read(&p).unwrap();
9 let fsize = u32::from_le_bytes(bytes[32..36].try_into().unwrap()) as usize;6 let fsize = u32::from_le_bytes(bytes[32..36].try_into().unwrap()) as usize;
10 let frame = &bytes[44..44 + fsize];7 let frame = &bytes[44..44 + fsize];
11 let mut pp = Vp9Parser::new();8 let mut pp = Vp9Parser::new();
crates/ec-vp9/tests/it/scratch_hdr2.rsmodified+1 -2
@@ -2,8 +2,7 @@ use crate::ivf;
2 use ec_vp9_syntax::Vp9Parser;2 use ec_vp9_syntax::Vp9Parser;
3 #[test]3 #[test]
4 fn dump_hdr() {4 fn dump_hdr() {
5- let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../..");5+ let bytes = std::fs::read(ec_testkit::fixture("vp9/lossless-64.ivf")).unwrap();
6- let bytes = std::fs::read(dir.join("fixtures/vp9/lossless-64.ivf")).unwrap();
7 let (_, _, _, frames) = ivf::parse_ivf(&bytes);6 let (_, _, _, frames) = ivf::parse_ivf(&bytes);
8 let mut p = Vp9Parser::new();7 let mut p = Vp9Parser::new();
9 let h = p.parse_frame(&frames[0].data).unwrap();8 let h = p.parse_frame(&frames[0].data).unwrap();
crates/ec-vp9/tests/it/scratch_hdr3.rsmodified+1 -2
@@ -2,8 +2,7 @@ use crate::ivf;
2 use ec_vp9_syntax::Vp9Parser;2 use ec_vp9_syntax::Vp9Parser;
3 #[test]3 #[test]
4 fn dump_hdr() {4 fn dump_hdr() {
5- let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../..");5+ let bytes = std::fs::read(ec_testkit::fixture("bitstreams/vp9-superframe-altref.ivf")).unwrap();
6- let bytes = std::fs::read(dir.join("fixtures/bitstreams/vp9-superframe-altref.ivf")).unwrap();
7 let (_, _, _, frames) = ivf::parse_ivf(&bytes);6 let (_, _, _, frames) = ivf::parse_ivf(&bytes);
8 let subs = ec_vp9_syntax::superframe::split(&frames[0].data).unwrap();7 let subs = ec_vp9_syntax::superframe::split(&frames[0].data).unwrap();
9 println!("subframes: {}", subs.len());8 println!("subframes: {}", subs.len());
crates/ec-vp9/tests/it/scratch_lfdump.rsmodified+9 -9
@@ -6,12 +6,12 @@ use crate::ivf;
6 use ec_vp9::decode::Decoder;6 use ec_vp9::decode::Decoder;
7 7
8 fn ffmpeg_raw_yuv(path: &std::path::Path) -> Vec<u8> {8 fn ffmpeg_raw_yuv(path: &std::path::Path) -> Vec<u8> {
9- let out = std::process::Command::new("ffmpeg")9+ let out = ec_testkit::ffmpeg()
10 .args(["-v", "error", "-i"])10 .args(["-v", "error", "-i"])
11 .arg(path)11 .arg(path)
12 .args(["-f", "rawvideo", "-pix_fmt", "yuv420p", "-"])12 .args(["-f", "rawvideo", "-pix_fmt", "yuv420p", "-"])
13 .output()13 .output()
14- .expect("ffmpeg on PATH");14+ .expect("ffmpeg runs");
15 assert!(out.status.success());15 assert!(out.status.success());
16 out.stdout16 out.stdout
17 }17 }
@@ -19,7 +19,7 @@ fn ffmpeg_raw_yuv(path: &std::path::Path) -> Vec<u8> {
19 #[test]19 #[test]
20 fn dump_lf_diff_map() {20 fn dump_lf_diff_map() {
21 let path =21 let path =
22- std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/vp9/key-320.ivf");22+ ec_testkit::fixture("vp9/key-320.ivf");
23 let bytes = std::fs::read(&path).unwrap();23 let bytes = std::fs::read(&path).unwrap();
24 let (_f, _w, _h, frames) = ivf::parse_ivf(&bytes);24 let (_f, _w, _h, frames) = ivf::parse_ivf(&bytes);
25 let reference = ffmpeg_raw_yuv(&path);25 let reference = ffmpeg_raw_yuv(&path);
@@ -38,9 +38,9 @@ fn dump_lf_diff_map() {
38 dec.decode(&fr.data).expect("decode");38 dec.decode(&fr.data).expect("decode");
39 }39 }
40 let pic_pre = dec.decode(&frames[fi].data).expect("decode").expect("shown");40 let pic_pre = dec.decode(&frames[fi].data).expect("decode").expect("shown");
41- std::fs::write("/tmp/y_pre_ours.raw", pic_pre.y[..ysz].iter().map(|&v| v as u8).collect::<Vec<u8>>()).unwrap();41+ std::fs::write(std::env::temp_dir().join("y_pre_ours.raw"), pic_pre.y[..ysz].iter().map(|&v| v as u8).collect::<Vec<u8>>()).unwrap();
42- std::fs::write("/tmp/u_pre_ours.raw", pic_pre.u.iter().map(|&v| v as u8).collect::<Vec<u8>>()).unwrap();42+ std::fs::write(std::env::temp_dir().join("u_pre_ours.raw"), pic_pre.u.iter().map(|&v| v as u8).collect::<Vec<u8>>()).unwrap();
43- std::fs::write("/tmp/v_pre_ours.raw", pic_pre.v.iter().map(|&v| v as u8).collect::<Vec<u8>>()).unwrap();43+ std::fs::write(std::env::temp_dir().join("v_pre_ours.raw"), pic_pre.v.iter().map(|&v| v as u8).collect::<Vec<u8>>()).unwrap();
44 drop(skip_lf);44 drop(skip_lf);
45 45
46 // Post-LF run (fresh decoder).46 // Post-LF run (fresh decoder).
@@ -49,9 +49,9 @@ fn dump_lf_diff_map() {
49 dec.decode(&fr.data).expect("decode");49 dec.decode(&fr.data).expect("decode");
50 }50 }
51 let pic_post = dec.decode(&frames[fi].data).expect("decode").expect("shown");51 let pic_post = dec.decode(&frames[fi].data).expect("decode").expect("shown");
52- std::fs::write("/tmp/y_post_ours.raw", pic_post.y[..ysz].iter().map(|&v| v as u8).collect::<Vec<u8>>()).unwrap();52+ std::fs::write(std::env::temp_dir().join("y_post_ours.raw"), pic_post.y[..ysz].iter().map(|&v| v as u8).collect::<Vec<u8>>()).unwrap();
53- std::fs::write("/tmp/u_post_ours.raw", pic_post.u.iter().map(|&v| v as u8).collect::<Vec<u8>>()).unwrap();53+ std::fs::write(std::env::temp_dir().join("u_post_ours.raw"), pic_post.u.iter().map(|&v| v as u8).collect::<Vec<u8>>()).unwrap();
54- std::fs::write("/tmp/v_post_ours.raw", pic_post.v.iter().map(|&v| v as u8).collect::<Vec<u8>>()).unwrap();54+ std::fs::write(std::env::temp_dir().join("v_post_ours.raw"), pic_post.v.iter().map(|&v| v as u8).collect::<Vec<u8>>()).unwrap();
55 55
56 let fsz = ysz + 2 * (w / 2) * (h / 2);56 let fsz = ysz + 2 * (w / 2) * (h / 2);
57 let ff = &reference[fi * fsz..fi * fsz + ysz];57 let ff = &reference[fi * fsz..fi * fsz + ysz];
crates/ec-vp9/tests/it/scratch_lossless.rsmodified+2 -3
@@ -2,11 +2,10 @@ use crate::ivf;
2 use ec_vp9::decode::Decoder;2 use ec_vp9::decode::Decoder;
3 #[test]3 #[test]
4 fn lossless_matches() {4 fn lossless_matches() {
5- let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../..");5+ let path = ec_testkit::fixture("vp9/lossless-64.ivf");
6- let path = dir.join("fixtures/vp9/lossless-64.ivf");
7 let bytes = std::fs::read(&path).unwrap();6 let bytes = std::fs::read(&path).unwrap();
8 let (_, w, h, frames) = ivf::parse_ivf(&bytes);7 let (_, w, h, frames) = ivf::parse_ivf(&bytes);
9- let refout = std::process::Command::new("ffmpeg")8+ let refout = ec_testkit::ffmpeg()
10 .args(["-v","error","-i", path.to_str().unwrap(), "-frames:v","1","-f","rawvideo","-pix_fmt","yuv420p","-"])9 .args(["-v","error","-i", path.to_str().unwrap(), "-frames:v","1","-f","rawvideo","-pix_fmt","yuv420p","-"])
11 .output().unwrap().stdout;10 .output().unwrap().stdout;
12 let mut d = Decoder::new();11 let mut d = Decoder::new();
crates/ec-vp9/tests/it/scratch_pixdump.rsmodified+3 -4
@@ -9,11 +9,10 @@
9 use ec_vp9::decode::Decoder;9 use ec_vp9::decode::Decoder;
10 10
11 #[test]11 #[test]
12+#[ignore = "manual dump: set INTER_IVF and EC_VP9_PIXDUMP"]
12 fn pixdump() {13 fn pixdump() {
13- let (Ok(ivf), Ok(out)) = (std::env::var("INTER_IVF"), std::env::var("EC_VP9_PIXDUMP")) else {14+ let ivf = std::env::var("INTER_IVF").expect("set INTER_IVF");
14- eprintln!("SKIP scratch_pixdump: set INTER_IVF and EC_VP9_PIXDUMP");15+ let out = std::env::var("EC_VP9_PIXDUMP").expect("set EC_VP9_PIXDUMP");
15- return;
16- };
17 let bytes = std::fs::read(&ivf).expect("read ivf");16 let bytes = std::fs::read(&ivf).expect("read ivf");
18 let (_, w, h, frames) = parse_ivf(&bytes);17 let (_, w, h, frames) = parse_ivf(&bytes);
19 let mut decoder = Decoder::new();18 let mut decoder = Decoder::new();
crates/ec-vp9/tests/it/scratch_pixdump10.rsmodified+3 -4
@@ -10,11 +10,10 @@
10 use ec_vp9::decode::Decoder;10 use ec_vp9::decode::Decoder;
11 11
12 #[test]12 #[test]
13+#[ignore = "manual dump: set INTER_IVF and EC_VP9_PIXDUMP"]
13 fn pixdump10() {14 fn pixdump10() {
14- let (Ok(ivf), Ok(out)) = (std::env::var("INTER_IVF"), std::env::var("EC_VP9_PIXDUMP")) else {15+ let ivf = std::env::var("INTER_IVF").expect("set INTER_IVF");
15- eprintln!("SKIP scratch_pixdump10: set INTER_IVF and EC_VP9_PIXDUMP");16+ let out = std::env::var("EC_VP9_PIXDUMP").expect("set EC_VP9_PIXDUMP");
16- return;
17- };
18 let bytes = std::fs::read(&ivf).expect("read ivf");17 let bytes = std::fs::read(&ivf).expect("read ivf");
19 let (_, w, h, frames) = parse_ivf(&bytes);18 let (_, w, h, frames) = parse_ivf(&bytes);
20 let mut decoder = Decoder::new();19 let mut decoder = Decoder::new();
crates/ec-vp9/tests/it/scratch_realsweep.rsmodified+4 -4
@@ -17,12 +17,12 @@ use crate::ivf;
17 use ec_vp9::decode::Decoder;17 use ec_vp9::decode::Decoder;
18 18
19 #[test]19 #[test]
20+#[ignore = "manual sweep: set SWEEP_SRC or SWEEP_IVF"]
20 fn real_content_sweep() {21 fn real_content_sweep() {
21 let src = std::env::var("SWEEP_SRC").unwrap_or_default();22 let src = std::env::var("SWEEP_SRC").unwrap_or_default();
22 let prebuilt = std::env::var("SWEEP_IVF").ok();23 let prebuilt = std::env::var("SWEEP_IVF").ok();
23 if src.is_empty() && prebuilt.is_none() {24 if src.is_empty() && prebuilt.is_none() {
24- println!("SKIP: set SWEEP_SRC=<video> [SWEEP_N=<frames>] or SWEEP_IVF=<ivf>");25+ panic!("set SWEEP_SRC=<video> or SWEEP_IVF=<ivf>");
25- return;
26 }26 }
27 let n: usize = std::env::var("SWEEP_N")27 let n: usize = std::env::var("SWEEP_N")
28 .ok()28 .ok()
@@ -34,7 +34,7 @@ fn real_content_sweep() {
34 if let Some(p) = &prebuilt {34 if let Some(p) = &prebuilt {
35 std::fs::copy(p, &ivf_path).unwrap();35 std::fs::copy(p, &ivf_path).unwrap();
36 } else {36 } else {
37- let enc = std::process::Command::new("ffmpeg")37+ let enc = ec_testkit::ffmpeg()
38 .args(["-v", "error", "-y", "-i", &src, "-frames:v"])38 .args(["-v", "error", "-y", "-i", &src, "-frames:v"])
39 .arg(n.to_string())39 .arg(n.to_string())
40 .args([40 .args([
@@ -65,7 +65,7 @@ fn real_content_sweep() {
65 assert!(enc.success(), "ffmpeg encode of {src} failed");65 assert!(enc.success(), "ffmpeg encode of {src} failed");
66 }66 }
67 // Decode list as a human would, to prove our YUV probe is honest.67 // Decode list as a human would, to prove our YUV probe is honest.
68- let raw = std::process::Command::new("ffmpeg")68+ let raw = ec_testkit::ffmpeg()
69 .args(["-v", "error", "-i"])69 .args(["-v", "error", "-i"])
70 .arg(&ivf_path)70 .arg(&ivf_path)
71 .args(["-f", "rawvideo", "-pix_fmt", "yuv420p", "-"])71 .args(["-f", "rawvideo", "-pix_fmt", "yuv420p", "-"])
crates/ec-vp9/tests/it/scratch_synth.rsdeleted+0 -21
@@ -1,21 +0,0 @@
1-//! [scratch] Parse a synthetic keyframe header dump.
2-//!
3-//! The dump was produced ad hoc in an earlier session and lives in tmpfs
4-//! (`/tmp/synth-kf-frame.bin`), so the test skips - loudly - when it is gone:
5-//! a missing tmpfs fixture is not a regression.
6-use ec_vp9_syntax::Vp9Parser;
7-#[test]
8-fn synth() {
9- let Ok(frame) = std::fs::read("/tmp/synth-kf-frame.bin") else {
10- println!("SKIP: /tmp/synth-kf-frame.bin absent (tmpfs fixture)");
11- return;
12- };
13- let mut p = Vp9Parser::new();
14- match p.parse_frame(&frame) {
15- Ok(h) => println!(
16- "w={} h={} uhs={} hsib={}",
17- h.width, h.height, h.uncompressed_header_size, h.header_size_in_bytes
18- ),
19- Err(e) => println!("ERR {e}"),
20- }
21-}
crates/ec-vp9/tests/it/scratch_tiledbg.rsmodified+2 -4
@@ -6,11 +6,9 @@ use crate::ivf;
6 use ec_vp9_syntax::Vp9Parser;6 use ec_vp9_syntax::Vp9Parser;
7 7
8 #[test]8 #[test]
9+#[ignore = "manual: set TILE_SRC=<ivf>"]
9 fn tile_dbg() {10 fn tile_dbg() {
10- let Ok(src) = std::env::var("TILE_SRC") else {11+ let src = std::env::var("TILE_SRC").expect("set TILE_SRC=<ivf>");
11- println!("SKIP: set TILE_SRC=<ivf>");
12- return;
13- };
14 let bytes = std::fs::read(&src).unwrap();12 let bytes = std::fs::read(&src).unwrap();
15 let (_f, w, h, frames) = ivf::parse_ivf(&bytes);13 let (_f, w, h, frames) = ivf::parse_ivf(&bytes);
16 println!("ivf {w}x{h} frames {}", frames.len());14 println!("ivf {w}x{h} frames {}", frames.len());
crates/ec-vp9/tests/it/scratch_tok.rsmodified+1 -1
@@ -8,7 +8,7 @@ use ec_vp9::decode::Decoder;
8 #[test]8 #[test]
9 fn dump_tok_trace() {9 fn dump_tok_trace() {
10 let path =10 let path =
11- std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/vp9/key-320.ivf");11+ ec_testkit::fixture("vp9/key-320.ivf");
12 let bytes = std::fs::read(&path).unwrap();12 let bytes = std::fs::read(&path).unwrap();
13 let (_f, _w, _h, frames) = ivf::parse_ivf(&bytes);13 let (_f, _w, _h, frames) = ivf::parse_ivf(&bytes);
14 let mut dec = Decoder::new();14 let mut dec = Decoder::new();
crates/ec-vp9/tests/it/subsampling_exact.rsmodified+6 -24
@@ -2,12 +2,8 @@
2 //! 4:2:2 / 4:4:0 at 8 and 10 bits) and profile 2/3 12-bit decode byte-exact2 //! 4:2:2 / 4:4:0 at 8 and 10 bits) and profile 2/3 12-bit decode byte-exact
3 //! against ffmpeg's libvpx.3 //! against ffmpeg's libvpx.
4 //!4 //!
5-//! Every fixture under `tests/data/` is committed (see the lane report for5+//! Every fixture under `tests/data/` is committed. The two `corpus_*` cases
6-//! the exact generator commands), so these cases always run; the two6+//! need the `bitstreams/` fixtures from scripts/fixtures.sh.
7-//! `corpus_*` cases additionally cover the media-gated 4:4:4 corpus streams
8-//! and print SKIP when the fixture is absent -- RED instead under
9-//! `EC_REQUIRE_FIXTURES=1`, so a drifted fixture library can never read as a
10-//! pass.
11 //!7 //!
12 //! The comparison is the whole flattened plane stream (u16 samples) against8 //! The comparison is the whole flattened plane stream (u16 samples) against
13 //! ffmpeg's `rawvideo` output for the matching `pix_fmt` — full-resolution9 //! ffmpeg's `rawvideo` output for the matching `pix_fmt` — full-resolution
@@ -15,7 +11,6 @@
15 //! 16-bit LE sample layout for 10/12-bit.11 //! 16-bit LE sample layout for 10/12-bit.
16 12
17 use crate::ivf;13 use crate::ivf;
18-use crate::common::require_fixture;
19 14
20 use ec_vp9::decode::Decoder;15 use ec_vp9::decode::Decoder;
21 use std::path::{Path, PathBuf};16 use std::path::{Path, PathBuf};
@@ -26,22 +21,15 @@ fn data(name: &str) -> PathBuf {
26 .join(name)21 .join(name)
27 }22 }
28 23
29-fn corpus(name: &str) -> PathBuf {
30- let mut p = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
31- p.pop();
32- p.pop();
33- p.join("fixtures/bitstreams").join(name)
34-}
35-
36 /// ffmpeg's decoded samples as a flat u16 stream (8-bit zero-extended,24 /// ffmpeg's decoded samples as a flat u16 stream (8-bit zero-extended,
37 /// 10/12-bit little-endian pairs).25 /// 10/12-bit little-endian pairs).
38 fn ffmpeg_samples(path: &Path, pix_fmt: &str, bd: u8) -> Vec<u16> {26 fn ffmpeg_samples(path: &Path, pix_fmt: &str, bd: u8) -> Vec<u16> {
39- let out = std::process::Command::new("ffmpeg")27+ let out = ec_testkit::ffmpeg()
40 .args(["-v", "error", "-i"])28 .args(["-v", "error", "-i"])
41 .arg(path)29 .arg(path)
42 .args(["-f", "rawvideo", "-pix_fmt", pix_fmt, "-"])30 .args(["-f", "rawvideo", "-pix_fmt", pix_fmt, "-"])
43 .output()31 .output()
44- .expect("ffmpeg must be on PATH for the witnesses");32+ .expect("ffmpeg runs for the witnesses");
45 assert!(out.status.success(), "ffmpeg failed on {path:?}");33 assert!(out.status.success(), "ffmpeg failed on {path:?}");
46 if bd == 8 {34 if bd == 8 {
47 out.stdout.iter().map(|&b| b as u16).collect()35 out.stdout.iter().map(|&b| b as u16).collect()
@@ -121,18 +109,12 @@ fn profile_matrix_is_byte_exact() {
121 109
122 #[test]110 #[test]
123 fn corpus_profile1_444_matches_ffmpeg() {111 fn corpus_profile1_444_matches_ffmpeg() {
124- let p = corpus("vp9-profile1-444.ivf");112+ let p = ec_testkit::fixture("bitstreams/vp9-profile1-444.ivf");
125- if !require_fixture(&p, "scripts/gen-bitstream-fixtures.sh") {
126- return;
127- }
128 check(&p, "yuv444p", 8);113 check(&p, "yuv444p", 8);
129 }114 }
130 115
131 #[test]116 #[test]
132 fn corpus_profile3_444_10bit_matches_ffmpeg() {117 fn corpus_profile3_444_10bit_matches_ffmpeg() {
133- let p = corpus("vp9-profile3-444-10bit.ivf");118+ let p = ec_testkit::fixture("bitstreams/vp9-profile3-444-10bit.ivf");
134- if !require_fixture(&p, "scripts/gen-bitstream-fixtures.sh") {
135- return;
136- }
137 check(&p, "yuv444p10le", 10);119 check(&p, "yuv444p10le", 10);
138 }120 }
crates/ec-vp9/tests/scratch_sweep.rsmodified+2 -4
@@ -4,12 +4,10 @@ use ec_vp9::decode::Decoder;
4 #[test]4 #[test]
5 fn sweep() {5 fn sweep() {
6 std::panic::set_hook(Box::new(|_| {}));6 std::panic::set_hook(Box::new(|_| {}));
7- let mut p = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));7+ let p = ec_testkit::fixture("vp9/lossless-64.ivf");
8- p.pop(); p.pop();
9- p = p.join("fixtures/vp9/lossless-64.ivf");
10 let bytes = std::fs::read(&p).unwrap();8 let bytes = std::fs::read(&p).unwrap();
11 let (_, w, h, frames) = ivf::parse_ivf(&bytes);9 let (_, w, h, frames) = ivf::parse_ivf(&bytes);
12- let refout = std::process::Command::new("ffmpeg")10+ let refout = ec_testkit::ffmpeg()
13 .args(["-v","error","-i", p.to_str().unwrap(), "-frames:v","1","-f","rawvideo","-pix_fmt","yuv420p","-"])11 .args(["-v","error","-i", p.to_str().unwrap(), "-frames:v","1","-f","rawvideo","-pix_fmt","yuv420p","-"])
14 .output().unwrap().stdout;12 .output().unwrap().stdout;
15 let ylen = w as usize * h as usize;13 let ylen = w as usize * h as usize;