forge
Explore
Log in

Don't you dare go Hollow

ec-av1-syntax: streams test reads ec_testkit bitstreams fixtures and ffprobe; missing fixtures fail instead of skipping

Browse files at this commit

92bd1ce2e0450bb314f796fea5511a1dfaed6e8fAhmet Kaan GümüşParent: 6f9d280
Cargo.lockmodified+1 -0
@@ -384,6 +384,7 @@ name = "ec-av1-syntax"
384384 version = "0.1.0"
385385 dependencies = [
386386 "ec-core",
387+ "ec-testkit",
387388 ]
388389
389390 [[package]]
crates/ec-av1-syntax/Cargo.tomlmodified+3 -0
@@ -8,3 +8,6 @@ authors.workspace = true
88
99 [dependencies]
1010 ec-core.workspace = true
11+
12+[dev-dependencies]
13+ec-testkit.workspace = true
crates/ec-av1-syntax/tests/streams.rsmodified+9 -39
@@ -1,19 +1,13 @@
11 //! Every AV1 fixture stream parsed end to end, field-compared against ffprobe.
22 //!
33 //! `scripts/gen-bitstream-fixtures.sh` remuxes the container fixtures to IVF and
4-//! encodes the branch cases (4:4:4, monochrome, tiles, hidden ALTREF). Fixtures
5-//! are gitignored, so a checkout without them skips rather than fails.
4+//! encodes the branch cases (4:4:4, monochrome, tiles, hidden ALTREF).
65
76 use std::path::{Path, PathBuf};
8-use std::process::Command;
97
108 use ec_av1_syntax::{Av1Parser, FrameType, ObuKind};
119 use ec_core::Error;
1210
13-fn bitstreams() -> PathBuf {
14- Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/bitstreams")
15-}
16-
1711 /// The IVF frames of a file — for AV1, each is one temporal unit.
1812 fn ivf_frames(data: &[u8]) -> Vec<&[u8]> {
1913 let mut out = Vec::new();
@@ -31,7 +25,7 @@ fn ivf_frames(data: &[u8]) -> Vec<&[u8]> {
3125 }
3226
3327 fn ffprobe(path: &Path, entries: &str) -> Vec<String> {
34- let out = Command::new("ffprobe")
28+ let out = ec_testkit::ffprobe()
3529 .args(["-v", "error", "-select_streams", "v:0", "-show_entries"])
3630 .arg(entries)
3731 .args(["-of", "csv=p=0"])
@@ -89,19 +83,13 @@ fn pix_fmt_geometry(pix_fmt: &str) -> (u8, bool, u8, u8) {
8983 }
9084
9185 fn fixtures() -> Vec<PathBuf> {
92- let Ok(entries) = std::fs::read_dir(bitstreams()) else {
93- return Vec::new();
94- };
95- let mut files: Vec<PathBuf> = entries
96- .filter_map(|e| e.ok().map(|e| e.path()))
86+ ec_testkit::fixtures("bitstreams", "ivf")
87+ .into_iter()
9788 .filter(|p| {
98- p.extension().is_some_and(|e| e == "ivf")
99- && p.file_name()
100- .is_some_and(|n| n.to_string_lossy().starts_with("av1-"))
89+ p.file_name()
90+ .is_some_and(|n| n.to_string_lossy().starts_with("av1-"))
10191 })
102- .collect();
103- files.sort();
104- files
92+ .collect()
10593 }
10694
10795 /// One pass over a stream: what the parser saw.
@@ -117,14 +105,7 @@ struct Tally {
117105
118106 #[test]
119107 fn every_fixture_matches_ffprobe() {
120- let files = fixtures();
121- if files.is_empty() {
122- eprintln!(
123- "skipped: no fixtures/bitstreams/av1-*.ivf — run scripts/gen-bitstream-fixtures.sh"
124- );
125- return;
126- }
127- for path in files {
108+ for path in fixtures() {
128109 let name = path.file_name().unwrap().to_string_lossy().to_string();
129110 let (width, height, pix_fmt, profile) = probe_stream(&path);
130111 let (bit_depth, mono, sx, sy) = pix_fmt_geometry(&pix_fmt);
@@ -236,11 +217,7 @@ fn every_fixture_matches_ffprobe() {
236217 /// cannot prove.
237218 #[test]
238219 fn altref_fixture_has_hidden_frames_and_show_existing() {
239- let path = bitstreams().join("av1-altref.ivf");
240- if !path.exists() {
241- eprintln!("skipped: no av1-altref.ivf");
242- return;
243- }
220+ let path = ec_testkit::fixture("bitstreams/av1-altref.ivf");
244221 let data = std::fs::read(&path).unwrap();
245222 let mut parser = Av1Parser::new();
246223 let (mut hidden, mut show_existing, mut showable) = (0usize, 0usize, 0usize);
@@ -287,13 +264,6 @@ fn fuzz_10k_mutations_never_panics() {
287264 .collect::<Vec<_>>()
288265 })
289266 .collect();
290- let seeds = if seeds.is_empty() {
291- vec![vec![
292- 0x0au8, 0x0b, 0x00, 0x00, 0x00, 0x24, 0xcf, 0x7f, 0x0d, 0xbf, 0xff, 0x30, 0x08,
293- ]]
294- } else {
295- seeds
296- };
297267
298268 let mut state = 0x9e37_79b9_7f4a_7c15u64;
299269 let mut rng = move || {