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"
384 version = "0.1.0"384 version = "0.1.0"
385 dependencies = [385 dependencies = [
386 "ec-core",386 "ec-core",
387+ "ec-testkit",
387 ]388 ]
388 389
389 [[package]]390 [[package]]
crates/ec-av1-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-av1-syntax/tests/streams.rsmodified+8 -38
@@ -1,19 +1,13 @@
1 //! Every AV1 fixture stream parsed end to end, field-compared against ffprobe.1 //! Every AV1 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/gen-bitstream-fixtures.sh` remuxes the container fixtures to IVF and
4-//! encodes the branch cases (4:4:4, monochrome, tiles, hidden ALTREF). Fixtures4+//! encodes the branch cases (4:4:4, monochrome, tiles, hidden ALTREF).
5-//! are gitignored, 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_av1_syntax::{Av1Parser, FrameType, ObuKind};8 use ec_av1_syntax::{Av1Parser, FrameType, ObuKind};
11 use ec_core::Error;9 use ec_core::Error;
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 — for AV1, each is one temporal unit.11 /// The IVF frames of a file — for AV1, each is one temporal unit.
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"])
@@ -89,19 +83,13 @@ fn pix_fmt_geometry(pix_fmt: &str) -> (u8, bool, u8, u8) {
89 }83 }
90 84
91 fn fixtures() -> Vec<PathBuf> {85 fn fixtures() -> Vec<PathBuf> {
92- let Ok(entries) = std::fs::read_dir(bitstreams()) else {86+ ec_testkit::fixtures("bitstreams", "ivf")
93- return Vec::new();87+ .into_iter()
94- };
95- let mut files: Vec<PathBuf> = entries
96- .filter_map(|e| e.ok().map(|e| e.path()))
97 .filter(|p| {88 .filter(|p| {
98- p.extension().is_some_and(|e| e == "ivf")89+ p.file_name()
99- && p.file_name()
100 .is_some_and(|n| n.to_string_lossy().starts_with("av1-"))90 .is_some_and(|n| n.to_string_lossy().starts_with("av1-"))
101 })91 })
102- .collect();92+ .collect()
103- files.sort();
104- files
105 }93 }
106 94
107 /// One pass over a stream: what the parser saw.95 /// One pass over a stream: what the parser saw.
@@ -117,14 +105,7 @@ struct Tally {
117 105
118 #[test]106 #[test]
119 fn every_fixture_matches_ffprobe() {107 fn every_fixture_matches_ffprobe() {
120- let files = fixtures();108+ for path in 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 {
128 let name = path.file_name().unwrap().to_string_lossy().to_string();109 let name = path.file_name().unwrap().to_string_lossy().to_string();
129 let (width, height, pix_fmt, profile) = probe_stream(&path);110 let (width, height, pix_fmt, profile) = probe_stream(&path);
130 let (bit_depth, mono, sx, sy) = pix_fmt_geometry(&pix_fmt);111 let (bit_depth, mono, sx, sy) = pix_fmt_geometry(&pix_fmt);
@@ -236,11 +217,7 @@ fn every_fixture_matches_ffprobe() {
236 /// cannot prove.217 /// cannot prove.
237 #[test]218 #[test]
238 fn altref_fixture_has_hidden_frames_and_show_existing() {219 fn altref_fixture_has_hidden_frames_and_show_existing() {
239- let path = bitstreams().join("av1-altref.ivf");220+ let path = ec_testkit::fixture("bitstreams/av1-altref.ivf");
240- if !path.exists() {
241- eprintln!("skipped: no av1-altref.ivf");
242- return;
243- }
244 let data = std::fs::read(&path).unwrap();221 let data = std::fs::read(&path).unwrap();
245 let mut parser = Av1Parser::new();222 let mut parser = Av1Parser::new();
246 let (mut hidden, mut show_existing, mut showable) = (0usize, 0usize, 0usize);223 let (mut hidden, mut show_existing, mut showable) = (0usize, 0usize, 0usize);
@@ -287,13 +264,6 @@ fn fuzz_10k_mutations_never_panics() {
287 .collect::<Vec<_>>()264 .collect::<Vec<_>>()
288 })265 })
289 .collect();266 .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- };
297 267
298 let mut state = 0x9e37_79b9_7f4a_7c15u64;268 let mut state = 0x9e37_79b9_7f4a_7c15u64;
299 let mut rng = move || {269 let mut rng = move || {