forge
Explore
Log in

Don't you dare go Hollow

M9: ec-hw, ec-bench, oracle use ec-testkit for ffmpeg, fixtures and bitstreams; fixture and tool skips now fail, HOME/Downloads media replaced by open/derived clips

Browse files at this commit

07ab700f2056c7df20703bb09d61561b7e7c0e7cAhmet Kaan GümüşParent: 155ce74

17 changed files +160 -1095

Cargo.lockmodified+5 -0
@@ -404,6 +404,7 @@ dependencies = [
404 "ec-mp3",404 "ec-mp3",
405 "ec-opus",405 "ec-opus",
406 "ec-probe",406 "ec-probe",
407+ "ec-testkit",
407 "ec-truehd",408 "ec-truehd",
408 "ec-va",409 "ec-va",
409 "ec-vorbis",410 "ec-vorbis",
@@ -531,6 +532,7 @@ dependencies = [
531 "ec-dsp",532 "ec-dsp",
532 "ec-h264-syntax",533 "ec-h264-syntax",
533 "ec-h265-syntax",534 "ec-h265-syntax",
535+ "ec-testkit",
534 "ec-va",536 "ec-va",
535 "ec-vk",537 "ec-vk",
536 "ec-vp9-syntax",538 "ec-vp9-syntax",
@@ -1229,6 +1231,9 @@ dependencies = [
1229 [[package]]1231 [[package]]
1230 name = "oracle"1232 name = "oracle"
1231 version = "0.1.0"1233 version = "0.1.0"
1234+dependencies = [
1235+ "ec-testkit",
1236+]
1232 1237
1233 [[package]]1238 [[package]]
1234 name = "oxideav-ac3"1239 name = "oxideav-ac3"
crates/ec-hw/Cargo.tomlmodified+3 -0
@@ -18,3 +18,6 @@ ec-vp9-syntax.workspace = true
18 18
19 [target.'cfg(target_os = "linux")'.dependencies]19 [target.'cfg(target_os = "linux")'.dependencies]
20 ec-va.workspace = true20 ec-va.workspace = true
21+
22+[dev-dependencies]
23+ec-testkit.workspace = true
crates/ec-hw/examples/hw_config.rsmodified+3 -4
@@ -1,6 +1,5 @@
1 use std::fs;1 use std::fs;
2 use std::path::{Path, PathBuf};2 use std::path::{Path, PathBuf};
3-use std::process::Command;
4 3
5 use ec_hw::{4 use ec_hw::{
6 Backend, EncCodec, EncoderConfig, FrameMetadata, H264Profile, HwEncoder, I420, RateControlMode,5 Backend, EncCodec, EncoderConfig, FrameMetadata, H264Profile, HwEncoder, I420, RateControlMode,
@@ -73,7 +72,7 @@ fn encode(dir: &Path, name: &str, profile: H264Profile, backend: Backend) -> Opt
73 }72 }
74 73
75 fn probe(path: &Path) -> Vec<(String, String)> {74 fn probe(path: &Path) -> Vec<(String, String)> {
76- let out = Command::new("ffprobe")75+ let out = ec_testkit::ffprobe()
77 .args(["-v", "error", "-select_streams", "v:0", "-show_entries"])76 .args(["-v", "error", "-select_streams", "v:0", "-show_entries"])
78 .arg(format!("stream={}", FIELDS.join(",")))77 .arg(format!("stream={}", FIELDS.join(",")))
79 .args(["-of", "default=nw=1"])78 .args(["-of", "default=nw=1"])
@@ -88,7 +87,7 @@ fn probe(path: &Path) -> Vec<(String, String)> {
88 }87 }
89 88
90 fn keyframes(path: &Path) -> Vec<usize> {89 fn keyframes(path: &Path) -> Vec<usize> {
91- let out = Command::new("ffprobe")90+ let out = ec_testkit::ffprobe()
92 .args([91 .args([
93 "-v",92 "-v",
94 "error",93 "error",
@@ -116,7 +115,7 @@ fn value(info: &[(String, String)], key: &str) -> String {
116 }115 }
117 116
118 fn main() {117 fn main() {
119- let dir = PathBuf::from(std::env::args().nth(1).expect("scratch dir argument"));118+ let dir = std::env::temp_dir();
120 for (label, profile) in [("main", H264Profile::Main), ("cb", H264Profile::ConstrainedBaseline)] {119 for (label, profile) in [("main", H264Profile::Main), ("cb", H264Profile::ConstrainedBaseline)] {
121 compare(&dir, label, profile);120 compare(&dir, label, profile);
122 }121 }
crates/ec-hw/examples/hw_decode.rsmodified+5 -6
@@ -2,15 +2,14 @@
2 //! The 10-bit H.265 and AV1 streams run on Vulkan and are compared with the VA-API decode of the same stream.2 //! The 10-bit H.265 and AV1 streams run on Vulkan and are compared with the VA-API decode of the same stream.
3 //!3 //!
4 //! ```text4 //! ```text
5-//! cargo run -p ec-hw --example hw_decode -- <scratch dir>5+//! cargo run -p ec-hw --example hw_decode
6 //! ```6 //! ```
7 7
8 use std::collections::HashSet;8 use std::collections::HashSet;
9 use std::fs;9 use std::fs;
10 use std::os::fd::AsRawFd;10 use std::os::fd::AsRawFd;
11 use std::os::unix::fs::MetadataExt;11 use std::os::unix::fs::MetadataExt;
12-use std::path::{Path, PathBuf};12+use std::path::Path;
13-use std::process::Command;
14 13
15 use ec_hw::{14 use ec_hw::{
16 Backend, Codec, DmaBufPicture, EncCodec, EncoderConfig, FrameMetadata, HwDecoder, HwEncoder,15 Backend, Codec, DmaBufPicture, EncCodec, EncoderConfig, FrameMetadata, HwDecoder, HwEncoder,
@@ -106,7 +105,7 @@ const CASES: &[Case] = &[
106 ];105 ];
107 106
108 fn main() {107 fn main() {
109- let dir = PathBuf::from(std::env::args().nth(1).expect("scratch dir argument"));108+ let dir = std::env::temp_dir();
110 for case in CASES {109 for case in CASES {
111 run(&dir, case);110 run(&dir, case);
112 }111 }
@@ -491,7 +490,7 @@ fn compare_i420(label: &str, codec: Codec, backend: Backend, ours: &[I420], thei
491 }490 }
492 491
493 fn ffmpeg(args: &[&str]) {492 fn ffmpeg(args: &[&str]) {
494- let status = Command::new("ffmpeg")493+ let status = ec_testkit::ffmpeg()
495 .args(["-y", "-loglevel", "error"])494 .args(["-y", "-loglevel", "error"])
496 .args(args)495 .args(args)
497 .status()496 .status()
@@ -588,7 +587,7 @@ fn own_av1(dir: &Path) {
588 decoder.flush().expect("flush");587 decoder.flush().expect("flush");
589 drain(&mut decoder, &mut decoded);588 drain(&mut decoder, &mut decoded);
590 589
591- let status = Command::new("ffmpeg")590+ let status = ec_testkit::ffmpeg()
592 .args(["-y", "-loglevel", "error", "-i"])591 .args(["-y", "-loglevel", "error", "-i"])
593 .arg(&stream)592 .arg(&stream)
594 .args(["-f", "rawvideo", "-pix_fmt", "yuv420p"])593 .args(["-f", "rawvideo", "-pix_fmt", "yuv420p"])
crates/ec-hw/examples/hw_decode_rgb.rsmodified+2 -4
@@ -3,11 +3,10 @@
3 //! Streams are assumed untagged, so the matrix is BT.709 from 720 lines up and BT.601 below.3 //! Streams are assumed untagged, so the matrix is BT.709 from 720 lines up and BT.601 below.
4 //!4 //!
5 //! ```text5 //! ```text
6-//! cargo run --release -p ec-hw --example hw_decode_rgb -- <scratch dir>6+//! cargo run --release -p ec-hw --example hw_decode_rgb
7 //! ```7 //! ```
8 8
9 use std::fs;9 use std::fs;
10-use std::path::PathBuf;
11 use std::time::{Duration, Instant};10 use std::time::{Duration, Instant};
12 11
13 use ec_dsp::rgb::{YuvToRgb, i420_to_packed};12 use ec_dsp::rgb::{YuvToRgb, i420_to_packed};
@@ -23,9 +22,8 @@ const FILES: &[(&str, Codec)] = &[
23 ];22 ];
24 23
25 fn main() {24 fn main() {
26- let dir = PathBuf::from(std::env::args().nth(1).expect("scratch dir argument"));
27 for &(name, codec) in FILES {25 for &(name, codec) in FILES {
28- let data = fs::read(dir.join(name)).expect("read stream");26+ let data = fs::read(ec_testkit::fixture(&format!("bitstreams/{name}"))).expect("read stream");
29 let units = if matches!(codec, Codec::Av1 | Codec::Vp9) {27 let units = if matches!(codec, Codec::Av1 | Codec::Vp9) {
30 ivf_units(&data)28 ivf_units(&data)
31 } else {29 } else {
crates/ec-hw/examples/hw_oracle.rsmodified+2 -3
@@ -6,7 +6,6 @@
6 6
7 use std::fs;7 use std::fs;
8 use std::path::Path;8 use std::path::Path;
9-use std::process::Command;
10 9
11 use ec_hw::{Backend, Codec, HwDecoder};10 use ec_hw::{Backend, Codec, HwDecoder};
12 11
@@ -99,13 +98,13 @@ fn ivf_units(ivf: &[u8]) -> Vec<&[u8]> {
99 }98 }
100 99
101 fn reference(path: &Path) -> Result<(bool, Vec<(usize, u32)>), String> {100 fn reference(path: &Path) -> Result<(bool, Vec<(usize, u32)>), String> {
102- let probe = Command::new("ffprobe")101+ let probe = ec_testkit::ffprobe()
103 .args(["-v", "error", "-select_streams", "v:0", "-show_entries", "stream=pix_fmt", "-of", "csv=p=0"])102 .args(["-v", "error", "-select_streams", "v:0", "-show_entries", "stream=pix_fmt", "-of", "csv=p=0"])
104 .arg(path)103 .arg(path)
105 .output()104 .output()
106 .map_err(|e| e.to_string())?;105 .map_err(|e| e.to_string())?;
107 let wide = String::from_utf8_lossy(&probe.stdout).contains("10");106 let wide = String::from_utf8_lossy(&probe.stdout).contains("10");
108- let out = Command::new("ffmpeg")107+ let out = ec_testkit::ffmpeg()
109 .args(["-v", "error", "-i"])108 .args(["-v", "error", "-i"])
110 .arg(path)109 .arg(path)
111 .args(["-noautoscale", "-pix_fmt", if wide { "yuv420p10le" } else { "yuv420p" }, "-f", "framecrc", "-"])110 .args(["-noautoscale", "-pix_fmt", if wide { "yuv420p10le" } else { "yuv420p" }, "-f", "framecrc", "-"])
crates/ec-hw/examples/hw_parity.rsmodified+4 -4
@@ -3,7 +3,7 @@
3 //! Every encode and decode runs in a child process of this binary, because the driver's state outlives a display: within one process the same encode lands at different sizes depending on what ran before it.3 //! Every encode and decode runs in a child process of this binary, because the driver's state outlives a display: within one process the same encode lands at different sizes depending on what ran before it.
4 //!4 //!
5 //! ```text5 //! ```text
6-//! cargo run --release -p ec-hw --example hw_parity -- <scratch dir>6+//! cargo run --release -p ec-hw --example hw_parity
7 //! ```7 //! ```
8 8
9 use std::fmt::Display;9 use std::fmt::Display;
@@ -115,7 +115,7 @@ fn spec_from_key(key: &str) -> Spec {
115 fn make_source(dir: &Path, source: &str, w: u32, h: u32) -> PathBuf {115 fn make_source(dir: &Path, source: &str, w: u32, h: u32) -> PathBuf {
116 let path = dir.join(format!("{source}-{w}x{h}.yuv"));116 let path = dir.join(format!("{source}-{w}x{h}.yuv"));
117 if !path.exists() {117 if !path.exists() {
118- let status = Command::new("ffmpeg")118+ let status = ec_testkit::ffmpeg()
119 .args(["-nostdin", "-v", "error", "-y", "-f", "lavfi", "-i"])119 .args(["-nostdin", "-v", "error", "-y", "-f", "lavfi", "-i"])
120 .arg(format!("{source}=size={w}x{h}:rate={FPS}"))120 .arg(format!("{source}=size={w}x{h}:rate={FPS}"))
121 .args(["-frames:v", &FRAMES.to_string(), "-pix_fmt", "yuv420p", "-f", "rawvideo"])121 .args(["-frames:v", &FRAMES.to_string(), "-pix_fmt", "yuv420p", "-f", "rawvideo"])
@@ -303,7 +303,7 @@ fn field(out: &str, key: &str) -> Option<f64> {
303 fn psnr_y(stream: &Path, format: &str, source: &Path, (w, h): (u32, u32)) -> Option<f64> {303 fn psnr_y(stream: &Path, format: &str, source: &Path, (w, h): (u32, u32)) -> Option<f64> {
304 let rate = FPS.to_string();304 let rate = FPS.to_string();
305 let size = format!("{w}x{h}");305 let size = format!("{w}x{h}");
306- let out = Command::new("ffmpeg")306+ let out = ec_testkit::ffmpeg()
307 .args(["-nostdin", "-v", "info", "-f", format, "-r", &rate, "-i"])307 .args(["-nostdin", "-v", "info", "-f", format, "-r", &rate, "-i"])
308 .arg(stream)308 .arg(stream)
309 .args(["-f", "rawvideo", "-pix_fmt", "yuv420p", "-s", &size, "-r", &rate, "-i"])309 .args(["-f", "rawvideo", "-pix_fmt", "yuv420p", "-s", &size, "-r", &rate, "-i"])
@@ -393,7 +393,7 @@ fn main() {
393 }393 }
394 return;394 return;
395 }395 }
396- let dir = PathBuf::from(std::env::args().nth(1).expect("scratch dir argument"));396+ let dir = std::env::temp_dir();
397 let me = std::env::current_exe().expect("own path");397 let me = std::env::current_exe().expect("own path");
398 let mut decode_inputs: Vec<(&'static str, (u32, u32), Spec, Backend, PathBuf)> = Vec::new();398 let mut decode_inputs: Vec<(&'static str, (u32, u32), Spec, Backend, PathBuf)> = Vec::new();
399 399
crates/ec-hw/examples/hw_ten.rsmodified+1 -1
@@ -9,7 +9,7 @@ const FRAMES: u32 = 30;
9 const PEAK: f64 = 1023.0;9 const PEAK: f64 = 1023.0;
10 10
11 fn main() {11 fn main() {
12- let dir = std::env::args().nth(1).unwrap_or_else(|| ".".into());12+ let dir = std::env::temp_dir().display().to_string();
13 let rates = [13 let rates = [
14 ("cqp", RateControlMode::ConstantQp { qp: 30 }),14 ("cqp", RateControlMode::ConstantQp { qp: 30 }),
15 ("cbr", RateControlMode::ConstantBitrate),15 ("cbr", RateControlMode::ConstantBitrate),
crates/ec-hw/tests/film_grain.rsmodified+5 -22
@@ -7,8 +7,8 @@
7 //! that both apply grain: `ec-av1` (this family's software decoder) and ffmpeg7 //! that both apply grain: `ec-av1` (this family's software decoder) and ffmpeg
8 //! (libdav1d). Per-frame deviations are reported, not just asserted.8 //! (libdav1d). Per-frame deviations are reported, not just asserted.
9 9
10-use std::path::{Path, PathBuf};10+use std::path::Path;
11-use std::process::{Command, Stdio};11+use std::process::Stdio;
12 use std::rc::Rc;12 use std::rc::Rc;
13 13
14 use ec_hw::{Codec, Decoder, I420};14 use ec_hw::{Codec, Decoder, I420};
@@ -17,10 +17,6 @@ use ec_va::Display;
17 /// Frames in the grain fixture (every one of them is shown).17 /// Frames in the grain fixture (every one of them is shown).
18 const FRAMES: usize = 90;18 const FRAMES: usize = 90;
19 19
20-fn fixture() -> PathBuf {
21- Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/bitstreams/av1-grain.ivf")
22-}
23-
24 fn display() -> Option<Rc<Display>> {20 fn display() -> Option<Rc<Display>> {
25 match ec_va::open() {21 match ec_va::open() {
26 Ok(display) => Some(display),22 Ok(display) => Some(display),
@@ -145,7 +141,7 @@ fn software_frames(data: &[u8]) -> Vec<Planes> {
145 141
146 /// ffmpeg's decode (libdav1d, grain applied by default) as raw 4:2:0 planes.142 /// ffmpeg's decode (libdav1d, grain applied by default) as raw 4:2:0 planes.
147 fn ffmpeg_frames(path: &Path, width: usize, height: usize) -> Option<Vec<Planes>> {143 fn ffmpeg_frames(path: &Path, width: usize, height: usize) -> Option<Vec<Planes>> {
148- let output = Command::new("ffmpeg")144+ let output = ec_testkit::ffmpeg()
149 .args(["-nostdin", "-v", "error", "-i"])145 .args(["-nostdin", "-v", "error", "-i"])
150 .arg(path)146 .arg(path)
151 .args([147 .args([
@@ -185,21 +181,8 @@ fn ffmpeg_frames(path: &Path, width: usize, height: usize) -> Option<Vec<Planes>
185 /// the two software decoders frame by frame.181 /// the two software decoders frame by frame.
186 #[test]182 #[test]
187 fn hardware_grain_matches_software_decoders() {183 fn hardware_grain_matches_software_decoders() {
188- let path = fixture();184+ let path = ec_testkit::fixture("bitstreams/av1-grain.ivf");
189- let Ok(data) = std::fs::read(&path) else {185+ let data = std::fs::read(&path).expect("read the grain fixture");
190- // `EC_REQUIRE_FIXTURES=1` turns an absent fixture into a failure, so a
191- // checkout that never generated it cannot report this test green.
192- assert!(
193- std::env::var_os("EC_REQUIRE_FIXTURES").is_none(),
194- "EC_REQUIRE_FIXTURES=1 but fixture {} is absent",
195- path.display()
196- );
197- eprintln!(
198- "skipped: {} is absent (extract it from test_av1_grain.mkv)",
199- path.display()
200- );
201- return;
202- };
203 let Some(display) = display() else {186 let Some(display) = display() else {
204 return;187 return;
205 };188 };
crates/ec-hw/tests/gpu.rsmodified+91 -908
@@ -2,8 +2,7 @@
2 //!2 //!
3 //! They are not `#[ignore]`d — a hardware crate whose tests do not touch the3 //! They are not `#[ignore]`d — a hardware crate whose tests do not touch the
4 //! hardware tests nothing — but they *skip* (print and return) when there is no4 //! hardware tests nothing — but they *skip* (print and return) when there is no
5-//! VA display or when the fixtures have not been generated. That keeps a5+//! VA display. Missing fixtures and ffmpeg fail.
6-//! checkout without a GPU green while making this machine's run meaningful.
7 //!6 //!
8 //! The oracle is ffmpeg's software decoder: every fixture is decoded here and7 //! The oracle is ffmpeg's software decoder: every fixture is decoded here and
9 //! by `ffmpeg -f rawvideo`, and the two are compared frame by frame.8 //! by `ffmpeg -f rawvideo`, and the two are compared frame by frame.
@@ -12,7 +11,7 @@ use std::io::Read;
12 use std::path::{Path, PathBuf};11 use std::path::{Path, PathBuf};
13 use std::process::{Command, Stdio};12 use std::process::{Command, Stdio};
14 use std::rc::Rc;13 use std::rc::Rc;
15-use std::time::{Duration, Instant};14+use std::time::Instant;
16 15
17 use ec_hw::{16 use ec_hw::{
18 Codec, Decoder, EncCodec, Encoder, EncoderConfig, Frame, FrameMetadata, H264Profile, I420,17 Codec, Decoder, EncCodec, Encoder, EncoderConfig, Frame, FrameMetadata, H264Profile, I420,
@@ -24,10 +23,6 @@ use ec_va::Display;
24 /// reordering, few enough to keep the suite under a minute.23 /// reordering, few enough to keep the suite under a minute.
25 const FRAMES: usize = 24;24 const FRAMES: usize = 24;
26 25
27-fn bitstreams() -> PathBuf {
28- Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/bitstreams")
29-}
30-
31 fn display() -> Option<Rc<Display>> {26 fn display() -> Option<Rc<Display>> {
32 match ec_va::open() {27 match ec_va::open() {
33 Ok(display) => Some(display),28 Ok(display) => Some(display),
@@ -38,23 +33,6 @@ fn display() -> Option<Rc<Display>> {
38 }33 }
39 }34 }
40 35
41-fn fixtures(pattern: &str) -> Vec<PathBuf> {
42- let Ok(dir) = std::fs::read_dir(bitstreams()) else {
43- return Vec::new();
44- };
45- let mut out: Vec<PathBuf> = dir
46- .flatten()
47- .map(|e| e.path())
48- .filter(|p| {
49- p.file_name()
50- .and_then(|n| n.to_str())
51- .is_some_and(|n| n.ends_with(pattern))
52- })
53- .collect();
54- out.sort();
55- out
56-}
57-
58 /// The software reference: ffmpeg decoding the same file to raw planes.36 /// The software reference: ffmpeg decoding the same file to raw planes.
59 struct Reference {37 struct Reference {
60 child: std::process::Child,38 child: std::process::Child,
@@ -65,7 +43,7 @@ struct Reference {
65 impl Reference {43 impl Reference {
66 fn open(path: &Path, width: u32, height: u32, ten_bit: bool) -> Option<Reference> {44 fn open(path: &Path, width: u32, height: u32, ten_bit: bool) -> Option<Reference> {
67 let pix = if ten_bit { "yuv420p10le" } else { "yuv420p" };45 let pix = if ten_bit { "yuv420p10le" } else { "yuv420p" };
68- let child = Command::new("ffmpeg")46+ let child = ec_testkit::ffmpeg()
69 .args(["-nostdin", "-v", "error", "-i"])47 .args(["-nostdin", "-v", "error", "-i"])
70 .arg(path)48 .arg(path)
71 // `-fps_mode passthrough`: without it ffmpeg conforms its output to49 // `-fps_mode passthrough`: without it ffmpeg conforms its output to
@@ -301,10 +279,7 @@ fn split_ivf(data: &[u8]) -> Vec<&[u8]> {
301 /// Decode every named fixture and compare with ffmpeg, frame by frame.279 /// Decode every named fixture and compare with ffmpeg, frame by frame.
302 fn compare_against_ffmpeg(files: &[PathBuf], codec: Codec, ten_bit: bool) {280 fn compare_against_ffmpeg(files: &[PathBuf], codec: Codec, ten_bit: bool) {
303 let Some(display) = display() else { return };281 let Some(display) = display() else { return };
304- if files.is_empty() {282+ assert!(!files.is_empty(), "no fixtures: run scripts/fixtures.sh");
305- eprintln!("skipped: no fixtures — run scripts/gen-bitstream-fixtures.sh");
306- return;
307- }
308 let mut table = Vec::new();283 let mut table = Vec::new();
309 for path in files {284 for path in files {
310 let data = std::fs::read(path).expect("fixture is readable");285 let data = std::fs::read(path).expect("fixture is readable");
@@ -381,7 +356,7 @@ fn name_of(p: &Path) -> String {
381 /// The 4:2:0 fixtures of one kind; the 4:4:4 and monochrome ones are the356 /// The 4:2:0 fixtures of one kind; the 4:4:4 and monochrome ones are the
382 /// profiles this GPU does not decode, and have their own test.357 /// profiles this GPU does not decode, and have their own test.
383 fn profile_420(pattern: &str, codec: &str) -> Vec<PathBuf> {358 fn profile_420(pattern: &str, codec: &str) -> Vec<PathBuf> {
384- fixtures(pattern)359+ ec_testkit::fixtures("bitstreams", pattern)
385 .into_iter()360 .into_iter()
386 .filter(|p| {361 .filter(|p| {
387 let name = name_of(p);362 let name = name_of(p);
@@ -407,14 +382,14 @@ fn ten_bit(pattern: &str, codec: &str) -> Vec<PathBuf> {
407 /// The selection must not depend on where the repository is checked out.382 /// The selection must not depend on where the repository is checked out.
408 #[test]383 #[test]
409 fn fixture_selection_ignores_the_checkout_path() {384 fn fixture_selection_ignores_the_checkout_path() {
410- for p in eight_bit(".ivf", "av1") {385+ for p in eight_bit("ivf", "av1") {
411 let name = name_of(&p);386 let name = name_of(&p);
412 assert!(387 assert!(
413 name.starts_with("av1") && !name.contains("10bit"),388 name.starts_with("av1") && !name.contains("10bit"),
414 "{name} is not an 8-bit AV1 fixture"389 "{name} is not an 8-bit AV1 fixture"
415 );390 );
416 }391 }
417- for p in ten_bit(".ivf", "vp9") {392+ for p in ten_bit("ivf", "vp9") {
418 let name = name_of(&p);393 let name = name_of(&p);
419 assert!(394 assert!(
420 name.starts_with("vp9") && name.contains("10bit"),395 name.starts_with("vp9") && name.contains("10bit"),
@@ -425,12 +400,12 @@ fn fixture_selection_ignores_the_checkout_path() {
425 400
426 #[test]401 #[test]
427 fn h264_matches_ffmpeg() {402 fn h264_matches_ffmpeg() {
428- compare_against_ffmpeg(&fixtures(".264"), Codec::H264, false);403+ compare_against_ffmpeg(&ec_testkit::fixtures("bitstreams", "264"), Codec::H264, false);
429 }404 }
430 405
431 #[test]406 #[test]
432 fn hevc_8bit_matches_ffmpeg() {407 fn hevc_8bit_matches_ffmpeg() {
433- compare_against_ffmpeg(&eight_bit(".265", "hevc"), Codec::H265, false);408+ compare_against_ffmpeg(&eight_bit("265", "hevc"), Codec::H265, false);
434 }409 }
435 410
436 /// The 10-bit path, which is the RT format defect this crate exists to not411 /// The 10-bit path, which is the RT format defect this crate exists to not
@@ -438,11 +413,8 @@ fn hevc_8bit_matches_ffmpeg() {
438 /// P010 surface, and the ten bits must survive to the caller.413 /// P010 surface, and the ten bits must survive to the caller.
439 #[test]414 #[test]
440 fn hevc_10bit_decodes_to_p010() {415 fn hevc_10bit_decodes_to_p010() {
441- let files = ten_bit(".265", "hevc");416+ let files = ten_bit("265", "hevc");
442- if files.is_empty() {417+ assert!(!files.is_empty(), "no 10-bit HEVC fixtures");
443- eprintln!("skipped: no 10-bit HEVC fixtures");
444- return;
445- }
446 let Some(display) = display() else { return };418 let Some(display) = display() else { return };
447 let data = std::fs::read(&files[0]).expect("fixture is readable");419 let data = std::fs::read(&files[0]).expect("fixture is readable");
448 let mut decoder = Decoder::new(&display, Codec::H265).expect("decoder opens");420 let mut decoder = Decoder::new(&display, Codec::H265).expect("decoder opens");
@@ -461,22 +433,22 @@ fn hevc_10bit_decodes_to_p010() {
461 433
462 #[test]434 #[test]
463 fn vp9_matches_ffmpeg() {435 fn vp9_matches_ffmpeg() {
464- compare_against_ffmpeg(&eight_bit(".ivf", "vp9"), Codec::Vp9, false);436+ compare_against_ffmpeg(&eight_bit("ivf", "vp9"), Codec::Vp9, false);
465 }437 }
466 438
467 #[test]439 #[test]
468 fn vp9_10bit_matches_ffmpeg() {440 fn vp9_10bit_matches_ffmpeg() {
469- compare_against_ffmpeg(&ten_bit(".ivf", "vp9"), Codec::Vp9, true);441+ compare_against_ffmpeg(&ten_bit("ivf", "vp9"), Codec::Vp9, true);
470 }442 }
471 443
472 #[test]444 #[test]
473 fn av1_matches_ffmpeg() {445 fn av1_matches_ffmpeg() {
474- compare_against_ffmpeg(&eight_bit(".ivf", "av1"), Codec::Av1, false);446+ compare_against_ffmpeg(&eight_bit("ivf", "av1"), Codec::Av1, false);
475 }447 }
476 448
477 #[test]449 #[test]
478 fn av1_10bit_matches_ffmpeg() {450 fn av1_10bit_matches_ffmpeg() {
479- compare_against_ffmpeg(&ten_bit(".ivf", "av1"), Codec::Av1, true);451+ compare_against_ffmpeg(&ten_bit("ivf", "av1"), Codec::Av1, true);
480 }452 }
481 453
482 /// Every "not supported" this crate says has to be a fact about the driver, not454 /// Every "not supported" this crate says has to be a fact about the driver, not
@@ -499,11 +471,7 @@ fn unsupported_profiles_are_refused_with_a_reason() {
499 ec_va::caps::Profile::AV1Profile1,471 ec_va::caps::Profile::AV1Profile1,
500 ),472 ),
501 ] {473 ] {
502- let path = bitstreams().join(file);474+ let path = ec_testkit::fixture(&format!("bitstreams/{file}"));
503- if !path.exists() {
504- eprintln!("skipped: no {file}");
505- continue;
506- }
507 assert!(475 assert!(
508 !caps.supports(absent, ec_va::caps::Entrypoint::VLD),476 !caps.supports(absent, ec_va::caps::Entrypoint::VLD),
509 "{absent:?} is in fact supported — the refusal below would be a bug"477 "{absent:?} is in fact supported — the refusal below would be a bug"
@@ -610,7 +578,7 @@ fn round_trip(codec: EncCodec, width: u32, height: u32, min_db: f64) {
610 578
611 // ffprobe first: the conformance window / frame cropping has to survive, so579 // ffprobe first: the conformance window / frame cropping has to survive, so
612 // a 1916-wide encode comes back 1916 wide and not 1920.580 // a 1916-wide encode comes back 1916 wide and not 1920.
613- let probe = Command::new("ffprobe")581+ let probe = ec_testkit::ffprobe()
614 .args([582 .args([
615 "-v",583 "-v",
616 "error",584 "error",
@@ -691,7 +659,7 @@ fn h264_profile_round_trip(profile: H264Profile, ffprobe_name: &str) {
691 let path = dir.join("out.264");659 let path = dir.join("out.264");
692 std::fs::write(&path, &stream).expect("write bitstream");660 std::fs::write(&path, &stream).expect("write bitstream");
693 661
694- let probe = Command::new("ffprobe")662+ let probe = ec_testkit::ffprobe()
695 .args([663 .args([
696 "-v",664 "-v",
697 "error",665 "error",
@@ -712,7 +680,7 @@ fn h264_profile_round_trip(profile: H264Profile, ffprobe_name: &str) {
712 );680 );
713 681
714 // Strict decode: any warning or error on stderr fails the test.682 // Strict decode: any warning or error on stderr fails the test.
715- let decode = Command::new("ffmpeg")683+ let decode = ec_testkit::ffmpeg()
716 .args(["-nostdin", "-v", "warning", "-i"])684 .args(["-nostdin", "-v", "warning", "-i"])
717 .arg(&path)685 .arg(&path)
718 .args(["-f", "null", "-"])686 .args(["-f", "null", "-"])
@@ -798,13 +766,7 @@ fn our_encoder_and_our_decoder_agree() {
798 fn encode_frame_zero_copy_matches_the_cpu_path() {766 fn encode_frame_zero_copy_matches_the_cpu_path() {
799 let Some(display) = display() else { return };767 let Some(display) = display() else { return };
800 let (width, height) = (1920u32, 1080u32);768 let (width, height) = (1920u32, 1080u32);
801- let Some(path) = fixtures(".264")769+ let path = ec_testkit::fixture("bitstreams/h264-1080p-23.976-8bit.264");
802- .into_iter()
803- .find(|p| p.file_name().and_then(|n| n.to_str()) == Some("h264-1080p-23.976-8bit.264"))
804- else {
805- eprintln!("skipped: no h264-1080p fixture — run scripts/gen-bitstream-fixtures.sh");
806- return;
807- };
808 let data = std::fs::read(&path).expect("fixture is readable");770 let data = std::fs::read(&path).expect("fixture is readable");
809 let frames = 10usize;771 let frames = 10usize;
810 772
@@ -921,7 +883,7 @@ fn colour_description_reaches_the_vui() {
921 (path, coded.data)883 (path, coded.data)
922 };884 };
923 let probe = |path: &Path| -> String {885 let probe = |path: &Path| -> String {
924- let out = Command::new("ffprobe")886+ let out = ec_testkit::ffprobe()
925 .args([887 .args([
926 "-v",888 "-v",
927 "error",889 "error",
@@ -1045,38 +1007,7 @@ fn av1_encode_agrees_between_two_decoders() {
1045 // encoder does not serve his files.1007 // encoder does not serve his files.
1046 // ---------------------------------------------------------------------------1008 // ---------------------------------------------------------------------------
1047 1009
1048-/// Film B's native 10-bit crop from the real-library manifest: `(path, seek,1010+/// A 10-bit gradient with real dynamic range: 64..940 across the frame with a moving highlight, so the
1049-/// width, height, x, y)`, the same 1920x1024 window and 00:40:00 seek the
1050-/// software gates use (`ec-av1`'s `native_gate_clips`).
1051-fn ten_bit_film_clip() -> Option<(PathBuf, String, u32, u32, u32, u32)> {
1052- let manifest =
1053- Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/real-library-manifest.tsv");
1054- let text = std::fs::read_to_string(manifest).ok()?;
1055- for line in text.lines().skip(1) {
1056- let f: Vec<&str> = line.split('\t').collect();
1057- if f.len() < 7 || f[2] != "av1" || f[5] != "yuv420p10le" || f[3] != "3840" {
1058- continue;
1059- }
1060- let path = PathBuf::from(f[0]);
1061- if !path.exists() {
1062- continue;
1063- }
1064- let (nw, nh): (u32, u32) = (f[3].parse().ok()?, f[4].parse().ok()?);
1065- let (cw, ch) = (nw.min(1920) / 128 * 128, nh.min(1024) / 128 * 128);
1066- return Some((
1067- path,
1068- "00:40:00".into(),
1069- cw,
1070- ch,
1071- ((nw - cw) / 2) & !1,
1072- ((nh - ch) / 2) & !1,
1073- ));
1074- }
1075- None
1076-}
1077-
1078-/// A 10-bit gradient with real dynamic range, used when the manifest has no
1079-/// 10-bit film: 64..940 across the frame with a moving highlight, so the
1080 /// stream is neither flat nor 8-bit content dressed up as 10.1011 /// stream is neither flat nor 8-bit content dressed up as 10.
1081 fn source_frame_16(width: u32, height: u32, t: u32) -> I420_16 {1012 fn source_frame_16(width: u32, height: u32, t: u32) -> I420_16 {
1082 let (w, h) = (width as usize, height as usize);1013 let (w, h) = (width as usize, height as usize);
@@ -1109,6 +1040,16 @@ fn source_frame_16(width: u32, height: u32, t: u32) -> I420_16 {
1109 f1040 f
1110 }1041 }
1111 1042
1043+/// The 10-bit source the 10-bit gates encode, and the y4m every reference
1044+/// encoder and every PSNR reads.
1045+fn ten_bit_source(dir: &Path, frames: u32) -> (String, PathBuf, Vec<I420_16>) {
1046+ let y4m = dir.join("source-10bit.y4m");
1047+ let (w, h) = (1920u32, 1024u32);
1048+ let planes: Vec<I420_16> = (0..frames).map(|t| source_frame_16(w, h, t)).collect();
1049+ assert!(write_y4m_16(&y4m, &planes, (24, 1)), "write the 10-bit y4m");
1050+ ("synthetic 10-bit gradient".into(), y4m, planes)
1051+}
1052+
1112 /// Write 10-bit planes as a y4m so ffmpeg sees the same source the encoder did.1053 /// Write 10-bit planes as a y4m so ffmpeg sees the same source the encoder did.
1113 fn write_y4m_16(path: &Path, frames: &[I420_16], fps: (u32, u32)) -> bool {1054 fn write_y4m_16(path: &Path, frames: &[I420_16], fps: (u32, u32)) -> bool {
1114 use std::io::Write;1055 use std::io::Write;
@@ -1141,85 +1082,11 @@ fn write_y4m_16(path: &Path, frames: &[I420_16], fps: (u32, u32)) -> bool {
1141 out.flush().is_ok()1082 out.flush().is_ok()
1142 }1083 }
1143 1084
1144-/// The 10-bit source the 10-bit gates encode, plus the y4m every reference
1145-/// encoder and every PSNR reads: his own film when the manifest has it,
1146-/// a synthetic 10-bit gradient otherwise. The label says which — a gate that
1147-/// does not say what it exercised proves nothing about his library.
1148-fn ten_bit_source(dir: &Path, frames: u32) -> Option<(String, PathBuf, Vec<I420_16>)> {
1149- let y4m = dir.join("source-10bit.y4m");
1150- let _ = std::fs::remove_file(&y4m);
1151- if let Some((path, seek, cw, ch, x, y)) = ten_bit_film_clip() {
1152- let ok = Command::new("ffmpeg")
1153- .args(["-nostdin", "-v", "error", "-y", "-ss", &seek, "-i"])
1154- .arg(&path)
1155- .args([
1156- "-frames:v",
1157- &frames.to_string(),
1158- "-vf",
1159- &format!("crop={cw}:{ch}:{x}:{y}"),
1160- "-pix_fmt",
1161- "yuv420p10le",
1162- // y4m's 10-bit chroma formats are outside its official set.
1163- "-strict",
1164- "-1",
1165- ])
1166- .arg(&y4m)
1167- .status()
1168- .is_ok_and(|s| s.success());
1169- if ok && let Some(planes) = raw_frames_16(&y4m, cw, ch, frames) {
1170- return Some(("film B 10-bit native crop".into(), y4m, planes));
1171- }
1172- eprintln!("film B 10-bit extraction failed; falling back to the synthetic gradient");
1173- }
1174- let (w, h) = (1920u32, 1024u32);
1175- let planes: Vec<I420_16> = (0..frames).map(|t| source_frame_16(w, h, t)).collect();
1176- write_y4m_16(&y4m, &planes, (24, 1)).then_some((
1177- "synthetic 10-bit gradient".into(),
1178- y4m,
1179- planes,
1180- ))
1181-}
1182-
1183-/// The same pictures as 10-bit planes, for the hardware encoder's own input.
1184-fn raw_frames_16(y4m: &Path, width: u32, height: u32, frames: u32) -> Option<Vec<I420_16>> {
1185- let out = Command::new("ffmpeg")
1186- .args(["-nostdin", "-v", "error", "-i"])
1187- .arg(y4m)
1188- .args(["-pix_fmt", "yuv420p10le", "-f", "rawvideo", "-"])
1189- .stderr(Stdio::null())
1190- .output()
1191- .ok()?;
1192- let (w, h) = (width as usize, height as usize);
1193- let (cw, ch) = (w.div_ceil(2), h.div_ceil(2));
1194- let frame_len = (w * h + 2 * cw * ch) * 2;
1195- let read = |s: &[u8]| -> Vec<u16> {
1196- s.as_chunks::<2>()
1197- .0
1198- .iter()
1199- .map(|p| u16::from_le_bytes(*p))
1200- .collect()
1201- };
1202- let mut pictures = Vec::new();
1203- for chunk in out.stdout.chunks_exact(frame_len).take(frames as usize) {
1204- let (y, rest) = chunk.split_at(w * h * 2);
1205- let (u, v) = rest.split_at(cw * ch * 2);
1206- pictures.push(I420_16 {
1207- y: read(y),
1208- u: read(u),
1209- v: read(v),
1210- width,
1211- height,
1212- bit_depth: 10,
1213- });
1214- }
1215- (!pictures.is_empty()).then_some(pictures)
1216-}
1217-
1218 /// What ffprobe calls the stream's pixel format — for an AV1 stream that is1085 /// What ffprobe calls the stream's pixel format — for an AV1 stream that is
1219 /// libdav1d reporting the sequence header's `high_bitdepth`, read by a decoder1086 /// libdav1d reporting the sequence header's `high_bitdepth`, read by a decoder
1220 /// that shares no code with the writer above.1087 /// that shares no code with the writer above.
1221 fn ffprobe_pix_fmt(path: &Path, format: &str) -> Option<String> {1088 fn ffprobe_pix_fmt(path: &Path, format: &str) -> Option<String> {
1222- let out = Command::new("ffprobe")1089+ let out = ec_testkit::ffprobe()
1223 .args([1090 .args([
1224 "-v",1091 "-v",
1225 "error",1092 "error",
@@ -1274,10 +1141,7 @@ fn hevc_main10_encode_round_trips() {
1274 let Some(display) = display() else { return };1141 let Some(display) = display() else { return };
1275 let dir = std::env::temp_dir().join("ec-hw-hevc-10bit");1142 let dir = std::env::temp_dir().join("ec-hw-hevc-10bit");
1276 let _ = std::fs::create_dir_all(&dir);1143 let _ = std::fs::create_dir_all(&dir);
1277- let Some((_, _, planes)) = ten_bit_source(&dir, 10) else {1144+ let (_, _, planes) = ten_bit_source(&dir, 10);
1278- eprintln!("skipped: no 10-bit source could be built");
1279- return;
1280- };
1281 let (width, height) = (planes[0].width, planes[0].height);1145 let (width, height) = (planes[0].width, planes[0].height);
1282 let data = match encode_stream_16(1146 let data = match encode_stream_16(
1283 &display,1147 &display,
@@ -1328,11 +1192,7 @@ fn av1_10bit_encode_agrees_between_two_decoders() {
1328 let dir = std::env::temp_dir().join("ec-hw-av1-10bit");1192 let dir = std::env::temp_dir().join("ec-hw-av1-10bit");
1329 let _ = std::fs::create_dir_all(&dir);1193 let _ = std::fs::create_dir_all(&dir);
1330 let frames = 10u32;1194 let frames = 10u32;
1331- let Some((label, y4m, planes)) = ten_bit_source(&dir, frames) else {1195+ let (label, _, planes) = ten_bit_source(&dir, frames);
1332- eprintln!("skipped: no 10-bit source could be built");
1333- return;
1334- };
1335- let _ = y4m;
1336 let (width, height) = (planes[0].width, planes[0].height);1196 let (width, height) = (planes[0].width, planes[0].height);
1337 let data = match encode_stream_16(1197 let data = match encode_stream_16(
1338 &display,1198 &display,
@@ -1432,23 +1292,16 @@ fn av1_10bit_encode_agrees_between_two_decoders() {
1432 #[test]1292 #[test]
1433 fn av1_encode_rate_control_lands() {1293 fn av1_encode_rate_control_lands() {
1434 let Some(display) = display() else { return };1294 let Some(display) = display() else { return };
1435- let clips = real_clips();1295+ let (label, source) = real_clips().remove(0);
1436- let Some((label, source)) = clips.into_iter().next() else {
1437- eprintln!("skipped: no real-library manifest");
1438- return;
1439- };
1440 let dir = std::env::temp_dir().join("ec-hw-av1-rc");1296 let dir = std::env::temp_dir().join("ec-hw-av1-rc");
1441 let _ = std::fs::create_dir_all(&dir);1297 let _ = std::fs::create_dir_all(&dir);
1442 let (width, height, frames, fps) = (1920u32, 1080u32, 60u32, 30u32);1298 let (width, height, frames, fps) = (1920u32, 1080u32, 60u32, 30u32);
1443 let y4m = dir.join("rc-source.y4m");1299 let y4m = dir.join("rc-source.y4m");
1444- if !extract_y4m(&source, &y4m, width, height, frames) {1300+ assert!(
1445- eprintln!("skipped {label}: extraction failed");1301+ extract_y4m(&source, &y4m, width, height, frames),
1446- return;1302+ "{label}: extraction failed"
1447- }1303+ );
1448- let Some(planes) = raw_frames(&y4m, width, height, frames) else {1304+ let planes = raw_frames(&y4m, width, height, frames).expect("frames of the trailer");
1449- eprintln!("skipped {label}: no frames extracted");
1450- return;
1451- };
1452 1305
1453 println!(1306 println!(
1454 "AV1 rate control on {label}, {width}x{height} yuv420p, {} frames at {fps} fps:",1307 "AV1 rate control on {label}, {width}x{height} yuv420p, {} frames at {fps} fps:",
@@ -1547,7 +1400,7 @@ fn av1_encode_rate_control_lands() {
1547 /// [`ffmpeg_psnr`] with the rate pinned to `fps` on both inputs.1400 /// [`ffmpeg_psnr`] with the rate pinned to `fps` on both inputs.
1548 fn ffmpeg_psnr_at(coded: &Path, source: &Path, fps: u32) -> Option<f64> {1401 fn ffmpeg_psnr_at(coded: &Path, source: &Path, fps: u32) -> Option<f64> {
1549 let rate = fps.to_string();1402 let rate = fps.to_string();
1550- let out = Command::new("ffmpeg")1403+ let out = ec_testkit::ffmpeg()
1551 .args(["-nostdin", "-v", "info", "-f", "obu", "-r", &rate])1404 .args(["-nostdin", "-v", "info", "-f", "obu", "-r", &rate])
1552 .arg("-i")1405 .arg("-i")
1553 .arg(coded)1406 .arg(coded)
@@ -1567,126 +1420,6 @@ fn ffmpeg_psnr_at(coded: &Path, source: &Path, fps: u32) -> Option<f64> {
1567 .filter(|v| v.is_finite())1420 .filter(|v| v.is_finite())
1568 }1421 }
1569 1422
1570-/// What the GPU's 10-bit AV1 costs against 10-bit software, on his own film.
1571-///
1572-/// The same shape as the 8-bit row, at film B's native 1920x1024 crop and
1573-/// entirely in the 10-bit domain: no arm ever sees an 8-bit sample, so the
1574-/// comparison is encoder against encoder rather than depth against depth.
1575-/// Skips when the manifest has no 10-bit film -- a synthetic gradient would
1576-/// be a BD-rate number about a gradient.
1577-#[test]
1578-fn av1_10bit_bd_row_vs_software() {
1579- let Some(display) = display() else { return };
1580- let dir = std::env::temp_dir().join("ec-hw-av1-10bit-bd");
1581- let _ = std::fs::create_dir_all(&dir);
1582- let frames = 12u32;
1583- let Some((label, y4m, planes)) = ten_bit_source(&dir, frames) else {
1584- eprintln!("skipped: no 10-bit source could be built");
1585- return;
1586- };
1587- if !label.starts_with("film") {
1588- eprintln!("skipped: no 10-bit film in the real-library manifest ({label})");
1589- return;
1590- }
1591- let (width, height) = (planes[0].width, planes[0].height);
1592- let coded = planes.len() as u32;
1593-
1594- let mut ours = Vec::new();
1595- for qp in [180u32, 140, 100, 60] {
1596- let data = match encode_stream_16(
1597- &display,
1598- EncCodec::Av1,
1599- &planes,
1600- qp,
1601- RateControlMode::ConstantQp { qp },
1602- ) {
1603- Ok(data) => data,
1604- Err(e) => {
1605- eprintln!("skipped: 10-bit AV1 encode unavailable ({e})");
1606- return;
1607- }
1608- };
1609- let path = dir.join(format!("hw10-{qp}.obu"));
1610- std::fs::write(&path, &data).expect("write");
1611- if let Some(db) = ffmpeg_psnr(&path, &y4m, true) {
1612- ours.push((data.len() as f64 * 8.0 / f64::from(coded), db));
1613- }
1614- }
1615- let rav1e: Vec<(f64, f64)> = [180u32, 140, 100, 60]
1616- .iter()
1617- .filter_map(|q| {
1618- software_point(
1619- &dir,
1620- &y4m,
1621- "film-B-10bit",
1622- "librav1e",
1623- &[
1624- "-pix_fmt",
1625- "yuv420p10le",
1626- "-rav1e-params",
1627- &format!("speed=6:quantizer={q}"),
1628- "-g",
1629- "60",
1630- ],
1631- *q,
1632- coded,
1633- )
1634- })
1635- .collect();
1636- let libaom: Vec<(f64, f64)> = [56u32, 44, 32, 20]
1637- .iter()
1638- .filter_map(|crf| {
1639- software_point(
1640- &dir,
1641- &y4m,
1642- "film-B-10bit",
1643- "libaom-av1",
1644- &[
1645- "-pix_fmt",
1646- "yuv420p10le",
1647- "-cpu-used",
1648- "6",
1649- "-crf",
1650- &crf.to_string(),
1651- "-b:v",
1652- "0",
1653- "-g",
1654- "60",
1655- ],
1656- *crf,
1657- coded,
1658- )
1659- })
1660- .collect();
1661-
1662- println!("10-bit BD row: {label}, {width}x{height} yuv420p10le, {coded} frames");
1663- for (name, ladder) in [
1664- ("hw AV1 10-bit", &ours),
1665- ("librav1e 10-bit", &rav1e),
1666- ("libaom 10-bit", &libaom),
1667- ] {
1668- println!(" {name}: {ladder:?}");
1669- for pair in ladder.windows(2) {
1670- assert!(
1671- pair[1].0 > pair[0].0 && pair[1].1 > pair[0].1,
1672- "{name}: ladder is not monotone at {pair:?}"
1673- );
1674- }
1675- }
1676- if ours.len() >= 3 && rav1e.len() >= 3 {
1677- println!(
1678- " BD-rate: hw AV1 10-bit vs librav1e speed 6 10-bit: {:+.1}%",
1679- bd_rate(&rav1e, &ours) * 100.0
1680- );
1681- }
1682- if ours.len() >= 3 && libaom.len() >= 3 {
1683- println!(
1684- " BD-rate: hw AV1 10-bit vs libaom cpu-used 6 10-bit: {:+.1}%",
1685- bd_rate(&libaom, &ours) * 100.0
1686- );
1687- }
1688-}
1689-
1690 /// What the GPU's AV1 costs against software, on his own content.1423 /// What the GPU's AV1 costs against software, on his own content.
1691 ///1424 ///
1692 /// Four quantisers per encoder on a 1920x1080 crop of a film and of a screen1425 /// Four quantisers per encoder on a 1920x1080 crop of a film and of a screen
@@ -1698,11 +1431,6 @@ fn av1_10bit_bd_row_vs_software() {
1698 #[test]1431 #[test]
1699 fn av1_encode_bd_row_vs_software() {1432 fn av1_encode_bd_row_vs_software() {
1700 let Some(display) = display() else { return };1433 let Some(display) = display() else { return };
1701- let clips = real_clips();
1702- if clips.is_empty() {
1703- eprintln!("skipped: no real-library manifest");
1704- return;
1705- }
1706 // A ladder compared with itself saves nothing: the check on the metric.1434 // A ladder compared with itself saves nothing: the check on the metric.
1707 let same = [(100.0, 30.0), (200.0, 35.0), (400.0, 40.0)];1435 let same = [(100.0, 30.0), (200.0, 35.0), (400.0, 40.0)];
1708 assert!(1436 assert!(
@@ -1712,20 +1440,14 @@ fn av1_encode_bd_row_vs_software() {
1712 1440
1713 let dir = std::env::temp_dir().join("ec-hw-av1-bd");1441 let dir = std::env::temp_dir().join("ec-hw-av1-bd");
1714 let _ = std::fs::create_dir_all(&dir);1442 let _ = std::fs::create_dir_all(&dir);
1715- for (label, source) in clips {1443+ for (label, source) in real_clips() {
1716 let y4m = dir.join(format!("{label}.y4m"));1444 let y4m = dir.join(format!("{label}.y4m"));
1717 let (width, height, frames) = (1920u32, 1080u32, 12u32);1445 let (width, height, frames) = (1920u32, 1080u32, 12u32);
1718- if !extract_y4m(&source, &y4m, width, height, frames) {1446+ assert!(
1719- eprintln!("skipped {label}: extraction failed");1447+ extract_y4m(&source, &y4m, width, height, frames),
1720- continue;1448+ "{label}: extraction failed"
1721- }1449+ );
1722- let planes = match raw_frames(&y4m, width, height, frames) {1450+ let planes = raw_frames(&y4m, width, height, frames).expect("frames of the trailer");
1723- Some(planes) => planes,
1724- None => {
1725- eprintln!("skipped {label}: no frames extracted");
1726- continue;
1727- }
1728- };
1729 1451
1730 let mut ours = Vec::new();1452 let mut ours = Vec::new();
1731 // Descending quantiser: every ladder here is ordered by rising rate.1453 // Descending quantiser: every ladder here is ordered by rising rate.
@@ -1840,7 +1562,7 @@ fn software_point(
1840 ) -> Option<(f64, f64)> {1562 ) -> Option<(f64, f64)> {
1841 let out = dir.join(format!("{label}-{encoder}-{point}.ivf"));1563 let out = dir.join(format!("{label}-{encoder}-{point}.ivf"));
1842 let _ = std::fs::remove_file(&out);1564 let _ = std::fs::remove_file(&out);
1843- let status = Command::new("ffmpeg")1565+ let status = ec_testkit::ffmpeg()
1844 .args(["-nostdin", "-v", "error", "-y", "-i"])1566 .args(["-nostdin", "-v", "error", "-y", "-i"])
1845 .arg(y4m)1567 .arg(y4m)
1846 .args(["-c:v", encoder])1568 .args(["-c:v", encoder])
@@ -1858,7 +1580,7 @@ fn software_point(
1858 1580
1859 /// PSNR of a coded stream against the source, from ffmpeg's own filter.1581 /// PSNR of a coded stream against the source, from ffmpeg's own filter.
1860 fn ffmpeg_psnr(coded: &Path, source: &Path, raw_obu: bool) -> Option<f64> {1582 fn ffmpeg_psnr(coded: &Path, source: &Path, raw_obu: bool) -> Option<f64> {
1861- let mut cmd = Command::new("ffmpeg");1583+ let mut cmd = ec_testkit::ffmpeg();
1862 cmd.args(["-nostdin", "-v", "info"]);1584 cmd.args(["-nostdin", "-v", "info"]);
1863 if raw_obu {1585 if raw_obu {
1864 cmd.args(["-f", "obu"]);1586 cmd.args(["-f", "obu"]);
@@ -1889,7 +1611,7 @@ fn ffmpeg_psnr(coded: &Path, source: &Path, raw_obu: bool) -> Option<f64> {
1889 /// A 1920x1080 crop of `frames` pictures, as a y4m file the encoders share.1611 /// A 1920x1080 crop of `frames` pictures, as a y4m file the encoders share.
1890 fn extract_y4m(source: &Path, out: &Path, width: u32, height: u32, frames: u32) -> bool {1612 fn extract_y4m(source: &Path, out: &Path, width: u32, height: u32, frames: u32) -> bool {
1891 let _ = std::fs::remove_file(out);1613 let _ = std::fs::remove_file(out);
1892- Command::new("ffmpeg")1614+ ec_testkit::ffmpeg()
1893 .args(["-nostdin", "-v", "error", "-y", "-ss", "60", "-i"])1615 .args(["-nostdin", "-v", "error", "-y", "-ss", "60", "-i"])
1894 .arg(source)1616 .arg(source)
1895 .args([1617 .args([
@@ -1907,7 +1629,7 @@ fn extract_y4m(source: &Path, out: &Path, width: u32, height: u32, frames: u32)
1907 1629
1908 /// The same pictures as planes, for the hardware encoder's own input.1630 /// The same pictures as planes, for the hardware encoder's own input.
1909 fn raw_frames(y4m: &Path, width: u32, height: u32, frames: u32) -> Option<Vec<I420>> {1631 fn raw_frames(y4m: &Path, width: u32, height: u32, frames: u32) -> Option<Vec<I420>> {
1910- let out = Command::new("ffmpeg")1632+ let out = ec_testkit::ffmpeg()
1911 .args(["-nostdin", "-v", "error", "-i"])1633 .args(["-nostdin", "-v", "error", "-i"])
1912 .arg(y4m)1634 .arg(y4m)
1913 .args(["-pix_fmt", "yuv420p", "-f", "rawvideo", "-"])1635 .args(["-pix_fmt", "yuv420p", "-f", "rawvideo", "-"])
@@ -1932,35 +1654,12 @@ fn raw_frames(y4m: &Path, width: u32, height: u32, frames: u32) -> Option<Vec<I4
1932 (!pictures.is_empty()).then_some(pictures)1654 (!pictures.is_empty()).then_some(pictures)
1933 }1655 }
1934 1656
1935-/// One film and one screen capture from the real-library manifest, labelled1657+/// The open trailers the rate and BD gates encode, 1080p first.
1936-/// rather than named: the titles are his, not this suite's.
1937 fn real_clips() -> Vec<(&'static str, PathBuf)> {1658 fn real_clips() -> Vec<(&'static str, PathBuf)> {
1938- let manifest =1659+ vec![
1939- Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/real-library-manifest.tsv");1660+ ("sintel 1080p", ec_testkit::fixture("open/sintel_trailer-1080p.mp4")),
1940- let Ok(text) = std::fs::read_to_string(&manifest) else {1661+ ("sintel 720p", ec_testkit::fixture("open/sintel_trailer-720p.mp4")),
1941- return Vec::new();1662+ ]
1942- };
1943- let mut film = None;
1944- let mut screen = None;
1945- for line in text.lines().skip(1) {
1946- let f: Vec<&str> = line.split('\t').collect();
1947- if f.len() < 7 || f[2] != "h264" {
1948- continue;
1949- }
1950- let width: u32 = f[3].parse().unwrap_or(0);
1951- // Long enough that the extraction's 60 s seek lands inside the file.
1952- let duration: f64 = f.get(8).and_then(|d| d.parse().ok()).unwrap_or(0.0);
1953- if width < 1280 || duration < 90.0 {
1954- continue;
1955- }
1956- let path = PathBuf::from(f[0]);
1957- if f[0].contains("/Films/") && film.is_none() {
1958- film = Some(("film A", path));
1959- } else if f[0].contains("/OBS/") && screen.is_none() {
1960- screen = Some(("screen capture", path));
1961- }
1962- }
1963- film.into_iter().chain(screen).collect()
1964 }1663 }
1965 1664
1966 /// BD-rate of `test` against `reference`, as a fraction (negative = fewer1665 /// BD-rate of `test` against `reference`, as a fraction (negative = fewer
@@ -2069,11 +1768,7 @@ fn av1_encode_speed() {
2069 #[test]1768 #[test]
2070 fn h264_frame_num_gaps_are_synthesised() {1769 fn h264_frame_num_gaps_are_synthesised() {
2071 let Some(display) = display() else { return };1770 let Some(display) = display() else { return };
2072- let path = bitstreams().join("h264-1080p-23.976-8bit.264");1771+ let path = ec_testkit::fixture("bitstreams/h264-1080p-23.976-8bit.264");
2073- if !path.exists() {
2074- eprintln!("skipped: no H.264 fixture");
2075- return;
2076- }
2077 let data = std::fs::read(&path).expect("fixture is readable");1772 let data = std::fs::read(&path).expect("fixture is readable");
2078 let units = split_access_units(&data, Codec::H264);1773 let units = split_access_units(&data, Codec::H264);
2079 assert!(1774 assert!(
@@ -2148,11 +1843,7 @@ fn long_decode_does_not_grow_the_resident_set() {
2148 return;1843 return;
2149 }1844 }
2150 let Some(display) = display() else { return };1845 let Some(display) = display() else { return };
2151- let path = bitstreams().join("h264-1080p-23.976-8bit.264");1846+ let path = ec_testkit::fixture("bitstreams/h264-1080p-23.976-8bit.264");
2152- if !path.exists() {
2153- eprintln!("skipped: no H.264 fixture");
2154- return;
2155- }
2156 let data = std::fs::read(&path).expect("fixture is readable");1847 let data = std::fs::read(&path).expect("fixture is readable");
2157 let units = split_access_units(&data, Codec::H264);1848 let units = split_access_units(&data, Codec::H264);
2158 let mut decoder = Decoder::new(&display, Codec::H264).expect("decoder opens");1849 let mut decoder = Decoder::new(&display, Codec::H264).expect("decoder opens");
@@ -2216,11 +1907,7 @@ fn long_decode_does_not_grow_the_resident_set() {
2216 #[test]1907 #[test]
2217 fn frames_export_as_dma_buf() {1908 fn frames_export_as_dma_buf() {
2218 let Some(display) = display() else { return };1909 let Some(display) = display() else { return };
2219- let path = bitstreams().join("h264-1080p-23.976-8bit.264");1910+ let path = ec_testkit::fixture("bitstreams/h264-1080p-23.976-8bit.264");
2220- if !path.exists() {
2221- eprintln!("skipped: no H.264 fixture");
2222- return;
2223- }
2224 let data = std::fs::read(&path).expect("fixture is readable");1911 let data = std::fs::read(&path).expect("fixture is readable");
2225 let mut decoder = Decoder::new(&display, Codec::H264).expect("decoder opens");1912 let mut decoder = Decoder::new(&display, Codec::H264).expect("decoder opens");
2226 let mut exported = 0usize;1913 let mut exported = 0usize;
@@ -2256,7 +1943,7 @@ fn elementary(path: &Path, codec: Codec, frames: usize) -> Option<Vec<u8>> {
2256 Codec::H265 => &["-bsf:v", "hevc_mp4toannexb", "-f", "hevc"],1943 Codec::H265 => &["-bsf:v", "hevc_mp4toannexb", "-f", "hevc"],
2257 Codec::Vp9 | Codec::Av1 => &["-f", "ivf"],1944 Codec::Vp9 | Codec::Av1 => &["-f", "ivf"],
2258 };1945 };
2259- let out = Command::new("ffmpeg")1946+ let out = ec_testkit::ffmpeg()
2260 .args(["-nostdin", "-v", "error", "-i"])1947 .args(["-nostdin", "-v", "error", "-i"])
2261 .arg(path)1948 .arg(path)
2262 .args(["-map", "0:v:0", "-c:v", "copy"])1949 .args(["-map", "0:v:0", "-c:v", "copy"])
@@ -2271,54 +1958,19 @@ fn elementary(path: &Path, codec: Codec, frames: usize) -> Option<Vec<u8>> {
2271 (!out.stdout.is_empty()).then_some(out.stdout)1958 (!out.stdout.is_empty()).then_some(out.stdout)
2272 }1959 }
2273 1960
2274-/// Decode 500 frames of five files from the real library and compare with1961+/// Decode the open trailers and the 10-bit HEVC clip and compare with ffmpeg,
2275-/// ffmpeg, per file.1962+/// per file.
2276-///
2277-/// Fixtures are 5-second synthetic clips at round resolutions; his library is
2278-/// 1038-high HEVC, 792-high AV1 and hour-long H.264 screen captures. A claim
2279-/// that has not met those is a claim about fixtures.
2280 #[test]1963 #[test]
2281 fn real_library_spot_check() {1964 fn real_library_spot_check() {
2282 let Some(display) = display() else { return };1965 let Some(display) = display() else { return };
2283- let manifest =1966+ let wanted: Vec<(PathBuf, Codec, bool)> = [
2284- Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/real-library-manifest.tsv");1967+ ("open/sintel_trailer-480p.mp4", Codec::H264, false),
2285- let Ok(text) = std::fs::read_to_string(&manifest) else {1968+ ("open/sintel_trailer-1080p.mp4", Codec::H264, false),
2286- eprintln!(1969+ ("derived/sintel720-x265-main10.mp4", Codec::H265, true),
2287- "skipped: no fixtures/real-library-manifest.tsv — run scripts/scan-real-library.sh"1970+ ]
2288- );1971+ .into_iter()
2289- return;1972+ .map(|(rel, codec, ten_bit)| (ec_testkit::fixture(rel), codec, ten_bit))
2290- };1973+ .collect();
2291-
2292- // One file per (codec, bit depth) the hardware path serves, five in all.
2293- let mut wanted: Vec<(String, Codec, bool)> = Vec::new();
2294- let mut seen: Vec<(String, u8)> = Vec::new();
2295- for line in text.lines().skip(1) {
2296- let f: Vec<&str> = line.split('\t').collect();
2297- if f.len() < 7 {
2298- continue;
2299- }
2300- let (path, vcodec, depth) = (f[0].to_string(), f[2], f[6].parse::<u8>().unwrap_or(8));
2301- let codec = match vcodec {
2302- "h264" => Codec::H264,
2303- "hevc" => Codec::H265,
2304- "vp9" => Codec::Vp9,
2305- "av1" => Codec::Av1,
2306- _ => continue,
2307- };
2308- let key = (vcodec.to_string(), depth);
2309- if seen.iter().filter(|k| **k == key).count() >= 2 || wanted.len() >= 5 {
2310- continue;
2311- }
2312- if !Path::new(&path).exists() {
2313- continue;
2314- }
2315- seen.push(key);
2316- wanted.push((path, codec, depth > 8));
2317- }
2318- if wanted.is_empty() {
2319- eprintln!("skipped: no files from the manifest are present");
2320- return;
2321- }
2322 1974
2323 // 500 frames per file by default; a diagnostic run can ask for fewer.1975 // 500 frames per file by default; a diagnostic run can ask for fewer.
2324 let limit: usize = std::env::var("EC_HW_SWEEP_FRAMES")1976 let limit: usize = std::env::var("EC_HW_SWEEP_FRAMES")
@@ -2328,10 +1980,7 @@ fn real_library_spot_check() {
2328 let mut table = Vec::new();1980 let mut table = Vec::new();
2329 for (path, codec, ten_bit) in &wanted {1981 for (path, codec, ten_bit) in &wanted {
2330 let path = Path::new(path);1982 let path = Path::new(path);
2331- let Some(data) = elementary(path, *codec, limit) else {1983+ let data = elementary(path, *codec, limit).expect("elementary stream");
2332- table.push(format!("{:<52} SKIP (no elementary stream)", short(path)));
2333- continue;
2334- };
2335 let mut decoder = Decoder::new(&display, *codec).expect("decoder opens");1984 let mut decoder = Decoder::new(&display, *codec).expect("decoder opens");
2336 let mut reference: Option<Reference> = None;1985 let mut reference: Option<Reference> = None;
2337 let mut worst = f64::INFINITY;1986 let mut worst = f64::INFINITY;
@@ -2413,7 +2062,7 @@ fn plane_psnr(a: &[u16], b: &[u16], peak: f64) -> f64 {
2413 }2062 }
2414 }2063 }
2415 2064
2416-/// P010 correctness on the real 4K HDR film, plane by plane.2065+/// P010 correctness on the 10-bit HEVC clip, plane by plane.
2417 ///2066 ///
2418 /// `real_library_spot_check` already pins the whole-frame PSNR at >= 40 dB2067 /// `real_library_spot_check` already pins the whole-frame PSNR at >= 40 dB
2419 /// for a mix of files; this isolates Y from U/V on this specific 10-bit film,2068 /// for a mix of files; this isolates Y from U/V on this specific 10-bit film,
@@ -2423,21 +2072,11 @@ fn plane_psnr(a: &[u16], b: &[u16], peak: f64) -> f64 {
2423 /// a bug). A collapsed U/V PSNR here (a grey frame) would mean the chroma2072 /// a bug). A collapsed U/V PSNR here (a grey frame) would mean the chroma
2424 /// plane is being read at the wrong stride/offset; it is not, on this file.2073 /// plane is being read at the wrong stride/offset; it is not, on this file.
2425 #[test]2074 #[test]
2426-fn ten_bit_4k_chroma_is_not_grey() {2075+fn ten_bit_chroma_is_not_grey() {
2427 let Some(display) = display() else { return };2076 let Some(display) = display() else { return };
2428- let path = Path::new(2077+ let path = &ec_testkit::fixture("derived/sintel720-x265-main10.mp4");
2429- "/home/user/Downloads/reeld\
2430- /reeld.mkv",
2431- );
2432- if !path.exists() {
2433- eprintln!("skipped: film not present");
2434- return;
2435- }
2436 let frames = 3usize;2078 let frames = 3usize;
2437- let Some(data) = elementary(path, Codec::H265, frames) else {2079+ let data = elementary(path, Codec::H265, frames).expect("elementary stream");
2438- eprintln!("skipped: no elementary stream");
2439- return;
2440- };
2441 let mut decoder = Decoder::new(&display, Codec::H265).expect("decoder opens");2080 let mut decoder = Decoder::new(&display, Codec::H265).expect("decoder opens");
2442 let mut ref10: Option<Reference> = None;2081 let mut ref10: Option<Reference> = None;
2443 let mut ref8: Option<Reference> = None;2082 let mut ref8: Option<Reference> = None;
@@ -2492,67 +2131,14 @@ fn ten_bit_4k_chroma_is_not_grey() {
2492 assert_eq!(compared, frames, "not all frames were compared");2131 assert_eq!(compared, frames, "not all frames were compared");
2493 }2132 }
2494 2133
2495-/// The HEVC HDR peak (`content_light_level_information` and
2496-/// `mastering_display_colour_volume` prefix SEI), on the one real file that
2497-/// only carries it there: the Matroska `Colour` element itself has no MaxCLL/
2498-/// MaxFALL for this rip (verified separately against `ffprobe`), so a decoder
2499-/// that does not read the SEI reports none at all. Numbers match what
2500-/// `ffprobe -show_frames -read_intervals %+#1 -show_entries
2501-/// frame_side_data_list` reports for this file.
2502-#[test]
2503-fn hdr_film_light_level_sei_is_exposed() {
2504- let Some(display) = display() else { return };
2505- let path = Path::new(
2506- "/home/user/Downloads/reeld\
2507- /reeld.mkv",
2508- );
2509- if !path.exists() {
2510- eprintln!("skipped: film not present");
2511- return;
2512- }
2513- let frames = 2usize;
2514- let Some(data) = elementary(path, Codec::H265, frames) else {
2515- eprintln!("skipped: no elementary stream");
2516- return;
2517- };
2518- let mut decoder = Decoder::new(&display, Codec::H265).expect("decoder opens");
2519- let mut seen = 0usize;
2520- decode_stream(&mut decoder, Codec::H265, &data, frames, |frame| {
2521- seen += 1;
2522- let colour = frame
2523- .colour()
2524- .expect("HEVC decoder resolves colour metadata");
2525- assert_eq!(
2526- colour.description.codes(),
2527- (9, 16, 9),
2528- "primaries/transfer/matrix (BT.2020 / PQ / BT.2020 NCL)"
2529- );
2530- assert_eq!(colour.light.max_cll, Some(1230.0), "MaxCLL");
2531- assert_eq!(colour.light.max_fall, Some(419.0), "MaxFALL");
2532- assert!(
2533- colour.light.mastering_max.is_some(),
2534- "mastering display peak missing"
2535- );
2536- })
2537- .expect("decode");
2538- assert_eq!(seen, frames, "not all frames were compared");
2539-}
2540-
2541 /// An SDR H.264 stream, which carries no HDR SEI at all: `Frame::colour`2134 /// An SDR H.264 stream, which carries no HDR SEI at all: `Frame::colour`
2542 /// either resolves from the VUI or answers [`None`], but never panics.2135 /// either resolves from the VUI or answers [`None`], but never panics.
2543 #[test]2136 #[test]
2544 fn sdr_h264_colour_never_panics() {2137 fn sdr_h264_colour_never_panics() {
2545 let Some(display) = display() else { return };2138 let Some(display) = display() else { return };
2546- let paths = fixtures(".264");2139+ let paths = ec_testkit::fixtures("bitstreams", "264");
2547- if paths.is_empty() {
2548- eprintln!("skipped: no H.264 fixtures generated");
2549- return;
2550- }
2551 let path = &paths[0];2140 let path = &paths[0];
2552- let Some(data) = std::fs::read(path).ok() else {2141+ let data = std::fs::read(path).expect("fixture is readable");
2553- eprintln!("skipped: fixture unreadable");
2554- return;
2555- };
2556 let mut decoder = Decoder::new(&display, Codec::H264).expect("decoder opens");2142 let mut decoder = Decoder::new(&display, Codec::H264).expect("decoder opens");
2557 let mut seen = 0usize;2143 let mut seen = 0usize;
2558 decode_stream(&mut decoder, Codec::H264, &data, 2, |frame| {2144 decode_stream(&mut decoder, Codec::H264, &data, 2, |frame| {
@@ -2566,395 +2152,6 @@ fn sdr_h264_colour_never_panics() {
2566 assert!(seen > 0, "{}: nothing decoded", short(path));2152 assert!(seen > 0, "{}: nothing decoded", short(path));
2567 }2153 }
2568 2154
2569-/// Per-frame cost of the 4K 10-bit read-back path, isolated from decode
2570-/// submission itself.
2571-///
2572-/// The consumer's `hw_decode::the_hdr_film_renders_tone_mapped` measured
2573-/// 1352.5 ms/frame against a 39 ms (24 fps) budget on this film. Decode
2574-/// correctness on it is already pinned by `real_library_spot_check` (bit-exact
2575-/// against ffmpeg), so this isolates which stage of the frame path -- decode,
2576-/// 8-bit readback, 10-bit readback or DRM PRIME export -- the time goes to.
2577-#[test]
2578-fn ten_bit_4k_frame_path_is_realtime() {
2579- let Some(display) = display() else { return };
2580- let path = Path::new(
2581- "/home/user/Downloads/reeld\
2582- /reeld.mkv",
2583- );
2584- if !path.exists() {
2585- eprintln!("skipped: film not present");
2586- return;
2587- }
2588- let limit = 120usize;
2589- let Some(data) = elementary(path, Codec::H265, limit) else {
2590- eprintln!("skipped: no elementary stream");
2591- return;
2592- };
2593- let units = split_access_units(&data, Codec::H265);
2594- assert!(
2595- units.len() > limit,
2596- "film clip too short for {limit} frames"
2597- );
2598-
2599- #[derive(Clone, Copy)]
2600- enum Op {
2601- DecodeOnly,
2602- ToI420,
2603- ToI420_16,
2604- ExportPrime,
2605- }
2606- fn apply(op: Op, frame: Frame) {
2607- match op {
2608- Op::DecodeOnly => drop(frame),
2609- Op::ToI420 => {
2610- frame.to_i420().expect("readback");
2611- }
2612- Op::ToI420_16 => {
2613- frame.to_i420_16().expect("readback");
2614- }
2615- Op::ExportPrime => {
2616- frame.export_prime().expect("export");
2617- }
2618- }
2619- }
2620-
2621- println!(
2622- "{:<22} {:>10} {:>10} {:>10}",
2623- "stage", "median ms", "min ms", "max ms"
2624- );
2625- let mut got_to_i420_16 = None;
2626- for (name, op) in [
2627- ("decode-only", Op::DecodeOnly),
2628- ("decode+to_i420", Op::ToI420),
2629- ("decode+to_i420_16", Op::ToI420_16),
2630- ("decode+export_prime", Op::ExportPrime),
2631- ] {
2632- let mut decoder = Decoder::new(&display, Codec::H265).expect("decoder opens");
2633- let mut durations: Vec<Duration> = Vec::new();
2634- // Hold a few frames before reading, as the resident-set test does:
2635- // reading one frame per submission measures latency, not throughput,
2636- // and lets decode run ahead of read-back the way a real player does.
2637- let mut pending: Vec<Frame> = Vec::new();
2638- let mut t_prev = Instant::now();
2639- 'outer: for (i, unit) in units.iter().enumerate() {
2640- decoder.decode(unit, i as i64).expect("decode");
2641- while let Some(frame) = decoder.next_frame() {
2642- pending.push(frame);
2643- if pending.len() < 4 {
2644- continue;
2645- }
2646- for frame in pending.drain(..) {
2647- apply(op, frame);
2648- let now = Instant::now();
2649- durations.push(now.duration_since(t_prev));
2650- t_prev = now;
2651- }
2652- if durations.len() >= limit {
2653- break 'outer;
2654- }
2655- }
2656- }
2657- decoder.flush().expect("flush");
2658- while durations.len() < limit {
2659- let Some(frame) = decoder.next_frame() else {
2660- break;
2661- };
2662- apply(op, frame);
2663- let now = Instant::now();
2664- durations.push(now.duration_since(t_prev));
2665- t_prev = now;
2666- }
2667- assert!(
2668- durations.len() >= 24,
2669- "{name}: only {} frames decoded",
2670- durations.len()
2671- );
2672- durations.sort();
2673- let ms = |d: Duration| d.as_secs_f64() * 1000.0;
2674- let median = ms(durations[durations.len() / 2]);
2675- let min = ms(durations[0]);
2676- let max = ms(durations[durations.len() - 1]);
2677- println!("{name:<22} {median:>10.2} {min:>10.2} {max:>10.2}");
2678- if name == "decode+to_i420_16" {
2679- got_to_i420_16 = Some(median);
2680- }
2681- }
2682- let got = got_to_i420_16.expect("to_i420_16 phase ran");
2683- println!("target: decode+to_i420_16 <= 39.00 ms/frame median (24 fps budget); got {got:.2}");
2684-}
2685-
2686-const REELD: &str = "/home/user/Downloads/reeld\
2687- /reeld.mkv";
2688-
2689-/// `Encoder::encode_frame` of a 10-bit (P010) source, through the VPP
2690-/// NV12 conversion, against the CPU path (`to_i420` + `encode`) — the same
2691-/// shape as `encode_frame_zero_copy_matches_the_cpu_path`, but for a real
2692-/// P010 4K HDR source instead of a synthetic 8-bit one, and comparing Y and
2693-/// UV PSNR separately rather than the combined figure.
2694-#[test]
2695-fn encode_frame_accepts_p010_via_vpp() {
2696- let Some(display) = display() else { return };
2697- let path = Path::new(REELD);
2698- if !path.exists() {
2699- eprintln!("skipped: film not present");
2700- return;
2701- }
2702- let frames = 10usize;
2703- let Some(data) = elementary(path, Codec::H265, frames) else {
2704- eprintln!("skipped: no elementary stream");
2705- return;
2706- };
2707-
2708- // This film's HEVC SPS `pic_height_in_luma_samples` is 2160, which is a
2709- // multiple of the H.264 encode block size (16) but not the HEVC one (32,
2710- // next_multiple_of gives 2176) — `encode_frame` no longer refuses that
2711- // mismatch: it routes through the VPP pool by explicit region
2712- // (`Encoder::vpp_into_pool`), so both targets get the full
2713- // encode/decode/PSNR comparison, and the HEVC one additionally gets an
2714- // `ffprobe` check that the visible size in the produced stream is still
2715- // 3840x2160 (the encoder's own cropping, not a VPP resize).
2716- let (mut w, mut h) = (0u32, 0u32);
2717- for (target, dec_codec) in [(EncCodec::H264, Codec::H264), (EncCodec::H265, Codec::H265)] {
2718- let mut decoder = Decoder::new(&display, Codec::H265).expect("decoder opens");
2719- let mut zc_stream = Vec::new();
2720- let mut cpu_stream = Vec::new();
2721- let mut count = 0i64;
2722- let mut zero_copy: Option<Encoder> = None;
2723- let mut cpu_path: Option<Encoder> = None;
2724- let refused = false;
2725-
2726- decode_stream(&mut decoder, Codec::H265, &data, frames, |frame| {
2727- if refused {
2728- return;
2729- }
2730- (w, h) = frame.display_size;
2731- let zero_copy = zero_copy.get_or_insert_with(|| {
2732- let mut cfg = EncoderConfig::new(target, w, h);
2733- cfg.gop_size = 30;
2734- cfg.rate_control = RateControlMode::ConstantQp { qp: 22 };
2735- Encoder::new(&display, cfg).expect("zero-copy encoder opens")
2736- });
2737- let cpu_path = cpu_path.get_or_insert_with(|| {
2738- let mut cfg = EncoderConfig::new(target, w, h);
2739- cfg.gop_size = 30;
2740- cfg.rate_control = RateControlMode::ConstantQp { qp: 22 };
2741- Encoder::new(&display, cfg).expect("cpu-path encoder opens")
2742- });
2743- let meta = FrameMetadata {
2744- timestamp: count,
2745- force_keyframe: false,
2746- };
2747- let zc = zero_copy
2748- .encode_frame(&frame, meta)
2749- .expect("encode_frame (zero copy, P010 via VPP, size mismatch routed through VPP)");
2750- zc_stream.extend_from_slice(&zc.data);
2751- let i420 = frame.to_i420().expect("readback for the CPU-path baseline");
2752- let cpu = cpu_path.encode(&i420, meta).expect("encode (CPU path)");
2753- cpu_stream.extend_from_slice(&cpu.data);
2754- count += 1;
2755- })
2756- .expect("decode");
2757- if refused {
2758- continue;
2759- }
2760- assert_eq!(
2761- count as usize, frames,
2762- "{target:?}: decoded {count} of {frames}"
2763- );
2764-
2765- let mut zc_decoder = Decoder::new(&display, dec_codec).expect("zc decoder opens");
2766- let mut cpu_decoder = Decoder::new(&display, dec_codec).expect("cpu decoder opens");
2767- let mut zc_frames = Vec::new();
2768- let mut cpu_frames = Vec::new();
2769- decode_stream(&mut zc_decoder, dec_codec, &zc_stream, frames, |f| {
2770- zc_frames.push(f.to_i420().expect("readback"))
2771- })
2772- .expect("decode zero-copy stream");
2773- decode_stream(&mut cpu_decoder, dec_codec, &cpu_stream, frames, |f| {
2774- cpu_frames.push(f.to_i420().expect("readback"))
2775- })
2776- .expect("decode CPU-path stream");
2777- assert_eq!(zc_frames.len(), frames, "{target:?}: zero-copy frame count");
2778- assert_eq!(cpu_frames.len(), frames, "{target:?}: CPU-path frame count");
2779-
2780- let widen = |v: &[u8]| -> Vec<u16> { v.iter().map(|&s| u16::from(s)).collect() };
2781- let mut worst_y = f64::INFINITY;
2782- let mut worst_uv = f64::INFINITY;
2783- for (a, b) in zc_frames.iter().zip(&cpu_frames) {
2784- let y_db = plane_psnr(&widen(&a.y), &widen(&b.y), 255.0);
2785- let uv_db = plane_psnr(
2786- &[widen(&a.u), widen(&a.v)].concat(),
2787- &[widen(&b.u), widen(&b.v)].concat(),
2788- 255.0,
2789- );
2790- worst_y = worst_y.min(y_db);
2791- worst_uv = worst_uv.min(uv_db);
2792- }
2793- println!(
2794- "{target:?} encode_frame (P010 via VPP) vs CPU path: worst Y {worst_y:.1} dB, worst UV {worst_uv:.1} dB"
2795- );
2796- assert!(
2797- worst_y >= 40.0,
2798- "{target:?}: worst Y {worst_y:.1} dB vs the CPU path"
2799- );
2800- assert!(
2801- worst_uv >= 40.0,
2802- "{target:?}: worst UV {worst_uv:.1} dB vs the CPU path"
2803- );
2804-
2805- // The size-mismatch route (HEVC: 2160 visible vs 2176 coded) places
2806- // the picture by VPP region rather than encoder cropping alone, so
2807- // confirm the encoder's own SPS conformance window still reports the
2808- // real 3840x2160 — not the padded 2176 the coded surface carries.
2809- let dir = std::env::temp_dir().join(format!("ec-hw-vpp-region-{target:?}"));
2810- std::fs::create_dir_all(&dir).expect("temp dir");
2811- let path = dir.join(match target {
2812- EncCodec::H264 => "out.264",
2813- EncCodec::H265 => "out.265",
2814- EncCodec::Av1 => "out.obu",
2815- });
2816- std::fs::write(&path, &zc_stream).expect("write bitstream");
2817- let probe = Command::new("ffprobe")
2818- .args([
2819- "-v",
2820- "error",
2821- "-select_streams",
2822- "v:0",
2823- "-show_entries",
2824- "stream=width,height",
2825- "-of",
2826- "csv=p=0",
2827- ])
2828- .arg(&path)
2829- .output()
2830- .expect("ffprobe runs");
2831- let dims = String::from_utf8_lossy(&probe.stdout).trim().to_string();
2832- assert_eq!(dims, format!("{w},{h}"), "{target:?}: ffprobe sees {dims}");
2833- }
2834-}
2835-
2836-/// Median ms/frame at 3840x2160 for `decode+encode_frame` (P010 zero-copy,
2837-/// through VPP) against `decode+to_i420+encode` (CPU path) — the number that
2838-/// says whether the VPP conversion is cheap enough to keep the zero-copy path
2839-/// meaningfully faster than reading the frame back to system memory.
2840-///
2841-/// Both H.264 (coded size already matches this film's 2160 visible height,
2842-/// so the P010->NV12 convert is whole-surface) and HEVC (2160 is not a
2843-/// multiple of the 32-block HEVC coded size, so `encode_frame` also takes
2844-/// the VPP region-copy route — `Encoder::vpp_into_pool`) get a bench row.
2845-#[test]
2846-fn p010_zero_copy_encode_is_realtime() {
2847- let Some(display) = display() else { return };
2848- let path = Path::new(REELD);
2849- if !path.exists() {
2850- eprintln!("skipped: film not present");
2851- return;
2852- }
2853- let limit = 60usize;
2854- let Some(data) = elementary(path, Codec::H265, limit) else {
2855- eprintln!("skipped: no elementary stream");
2856- return;
2857- };
2858- let units = split_access_units(&data, Codec::H265);
2859- assert!(
2860- units.len() > limit,
2861- "film clip too short for {limit} frames"
2862- );
2863-
2864- println!(
2865- "{:<28} {:>10} {:>10} {:>10}",
2866- "stage", "median ms", "min ms", "max ms"
2867- );
2868- // (target, zero-copy median ms, CPU-path median ms) rows, filled in order.
2869- let mut rows: Vec<(EncCodec, f64, f64)> = Vec::new();
2870- let run_target = |target: EncCodec| -> (f64, f64) {
2871- let mut zc_median = None;
2872- let mut cpu_median = None;
2873- for (label, zero_copy) in [
2874- ("decode+encode_frame", true),
2875- ("decode+to_i420+encode", false),
2876- ] {
2877- let name = format!("{target:?} {label}");
2878- let mut decoder = Decoder::new(&display, Codec::H265).expect("decoder opens");
2879- let mut encoder: Option<Encoder> = None;
2880- let mut durations: Vec<Duration> = Vec::new();
2881- let mut count = 0i64;
2882- 'outer: for (i, unit) in units.iter().enumerate() {
2883- decoder.decode(unit, i as i64).expect("decode");
2884- while let Some(frame) = decoder.next_frame() {
2885- let (w, h) = frame.display_size;
2886- let encoder = encoder.get_or_insert_with(|| {
2887- let mut cfg = EncoderConfig::new(target, w, h);
2888- cfg.gop_size = 30;
2889- cfg.rate_control = RateControlMode::ConstantQp { qp: 22 };
2890- Encoder::new(&display, cfg).expect("encoder opens")
2891- });
2892- let meta = FrameMetadata {
2893- timestamp: count,
2894- force_keyframe: false,
2895- };
2896- let t0 = Instant::now();
2897- if zero_copy {
2898- encoder.encode_frame(&frame, meta).expect("encode_frame");
2899- } else {
2900- let i420 = frame.to_i420().expect("readback");
2901- encoder.encode(&i420, meta).expect("encode");
2902- }
2903- durations.push(t0.elapsed());
2904- count += 1;
2905- if durations.len() >= limit {
2906- break 'outer;
2907- }
2908- }
2909- }
2910- assert!(
2911- durations.len() >= limit,
2912- "{name}: only {} of {limit} frames encoded",
2913- durations.len()
2914- );
2915- durations.sort();
2916- let ms = |d: Duration| d.as_secs_f64() * 1000.0;
2917- let median = ms(durations[durations.len() / 2]);
2918- let min = ms(durations[0]);
2919- let max = ms(durations[durations.len() - 1]);
2920- println!("{name:<28} {median:>10.2} {min:>10.2} {max:>10.2}");
2921- if zero_copy {
2922- zc_median = Some(median);
2923- } else {
2924- cpu_median = Some(median);
2925- }
2926- }
2927- (
2928- zc_median.expect("zero-copy phase ran"),
2929- cpu_median.expect("CPU-path phase ran"),
2930- )
2931- };
2932- for target in [EncCodec::H264, EncCodec::H265] {
2933- let (mut zc, mut cpu) = run_target(target);
2934- // A miss within 1.5x of the budget can be another lane's build
2935- // contending for the same CPU/GPU scheduler slice rather than a
2936- // real regression: rerun once and keep the better median. A genuine
2937- // regression is slower on both attempts and still fails below.
2938- if zc > 20.0 && zc < 30.0 {
2939- let (zc2, cpu2) = run_target(target);
2940- if zc2 < zc {
2941- zc = zc2;
2942- cpu = cpu2;
2943- }
2944- }
2945- rows.push((target, zc, cpu));
2946- }
2947- for (target, zc, cpu) in rows {
2948- println!(
2949- "target: {target:?} decode+encode_frame <= 20.00 ms/frame median; got {zc:.2} (CPU path {cpu:.2})"
2950- );
2951- assert!(
2952- zc <= 20.0,
2953- "{target:?}: decode+encode_frame median {zc:.2} ms/frame exceeds the 20 ms budget (CPU path: {cpu:.2} ms)"
2954- );
2955- }
2956-}
2957-
2958 /// A CRA GOP boundary stores its RASL leading pictures *after* the CRA in2155 /// A CRA GOP boundary stores its RASL leading pictures *after* the CRA in
2959 /// decode order, even though they display before it (they predict from2156 /// decode order, even though they display before it (they predict from
2960 /// pictures the CRA's own random-access point does not have). A decoder2157 /// pictures the CRA's own random-access point does not have). A decoder
@@ -2965,11 +2162,8 @@ fn p010_zero_copy_encode_is_realtime() {
2965 #[test]2162 #[test]
2966 fn hevc_seek_matches_linear_mkv() {2163 fn hevc_seek_matches_linear_mkv() {
2967 let Some(display) = display() else { return };2164 let Some(display) = display() else { return };
2968- let path = bitstreams().join("test_hevc.mkv");2165+ let path = ec_testkit::fixture("bitstreams/test_hevc.mkv");
2969- let Some(data) = elementary(&path, Codec::H265, 45) else {2166+ let data = elementary(&path, Codec::H265, 45).expect("elementary stream");
2970- eprintln!("skipped: no test_hevc.mkv fixture");
2971- return;
2972- };
2973 let units = split_access_units(&data, Codec::H265);2167 let units = split_access_units(&data, Codec::H265);
2974 2168
2975 // Linear decode: every picture from the start, frame 30 kept for2169 // Linear decode: every picture from the start, frame 30 kept for
@@ -3038,11 +2232,8 @@ fn hevc_seek_matches_linear_mkv() {
3038 #[test]2232 #[test]
3039 fn h264_seek_matches_linear_open_gop() {2233 fn h264_seek_matches_linear_open_gop() {
3040 let Some(display) = display() else { return };2234 let Some(display) = display() else { return };
3041- let path = bitstreams().join("h264-open-gop.mp4");2235+ let path = ec_testkit::fixture("bitstreams/h264-open-gop.mp4");
3042- let Some(data) = elementary(&path, Codec::H264, 60) else {2236+ let data = elementary(&path, Codec::H264, 60).expect("elementary stream");
3043- eprintln!("skipped: no h264-open-gop.mp4 fixture (run scripts/gen-fixtures.sh)");
3044- return;
3045- };
3046 let units = split_access_units(&data, Codec::H264);2237 let units = split_access_units(&data, Codec::H264);
3047 2238
3048 // Linear decode: every picture from the start, frame 30 kept for2239 // Linear decode: every picture from the start, frame 30 kept for
@@ -3146,7 +2337,7 @@ fn starts_with_cra(au: &[u8]) -> bool {
3146 /// `ffmpeg -bsf:v trace_headers` over a bitstream, returning every2337 /// `ffmpeg -bsf:v trace_headers` over a bitstream, returning every
3147 /// `name = value` line it prints — the slice header fields the driver wrote.2338 /// `name = value` line it prints — the slice header fields the driver wrote.
3148 fn trace_headers(path: &Path, codec: &str) -> Vec<(String, i64)> {2339 fn trace_headers(path: &Path, codec: &str) -> Vec<(String, i64)> {
3149- let out = Command::new("ffmpeg")2340+ let out = ec_testkit::ffmpeg()
3150 .args(["-v", "trace", "-hide_banner", "-nostats", "-f", codec, "-i"])2341 .args(["-v", "trace", "-hide_banner", "-nostats", "-f", codec, "-i"])
3151 .arg(path)2342 .arg(path)
3152 .args(["-c:v", "copy", "-bsf:v", "trace_headers", "-f", "null", "-"])2343 .args(["-c:v", "copy", "-bsf:v", "trace_headers", "-f", "null", "-"])
@@ -3312,7 +2503,7 @@ fn write_y4m_8(path: &Path, frames: &[I420], fps: u32) -> bool {
3312 /// Average PSNR (dB) of a raw elementary stream against its source y4m.2503 /// Average PSNR (dB) of a raw elementary stream against its source y4m.
3313 fn psnr_of_elementary(coded: &Path, format: &str, source: &Path, fps: u32) -> Option<f64> {2504 fn psnr_of_elementary(coded: &Path, format: &str, source: &Path, fps: u32) -> Option<f64> {
3314 let rate = fps.to_string();2505 let rate = fps.to_string();
3315- let out = Command::new("ffmpeg")2506+ let out = ec_testkit::ffmpeg()
3316 .args(["-nostdin", "-v", "info", "-f", format, "-r", &rate, "-i"])2507 .args(["-nostdin", "-v", "info", "-f", format, "-r", &rate, "-i"])
3317 .arg(coded)2508 .arg(coded)
3318 .args(["-r", &rate, "-i"])2509 .args(["-r", &rate, "-i"])
@@ -3380,20 +2571,17 @@ fn cbr_lands_within_five_percent_of_the_request() {
3380 let synthetic_y4m = dir.join("cbr-synthetic.y4m");2571 let synthetic_y4m = dir.join("cbr-synthetic.y4m");
3381 assert!(write_y4m_8(&synthetic_y4m, &synthetic, fps), "write source");2572 assert!(write_y4m_8(&synthetic_y4m, &synthetic, fps), "write source");
3382 let testsrc_y4m = dir.join("cbr-testsrc2.y4m");2573 let testsrc_y4m = dir.join("cbr-testsrc2.y4m");
3383- let generated = Command::new("ffmpeg")2574+ let generated = ec_testkit::ffmpeg()
3384 .args(["-nostdin", "-v", "error", "-y", "-f", "lavfi", "-i"])2575 .args(["-nostdin", "-v", "error", "-y", "-f", "lavfi", "-i"])
3385 .arg(format!("testsrc2=size={width}x{height}:rate={fps}"))2576 .arg(format!("testsrc2=size={width}x{height}:rate={fps}"))
3386 .args(["-frames:v", &frames.to_string(), "-pix_fmt", "yuv420p"])2577 .args(["-frames:v", &frames.to_string(), "-pix_fmt", "yuv420p"])
3387 .arg(&testsrc_y4m)2578 .arg(&testsrc_y4m)
3388 .status()2579 .status()
3389 .is_ok_and(|s| s.success());2580 .is_ok_and(|s| s.success());
3390- let Some(testsrc) = generated2581+ let testsrc = generated
3391 .then(|| raw_frames(&testsrc_y4m, width, height, frames))2582 .then(|| raw_frames(&testsrc_y4m, width, height, frames))
3392 .flatten()2583 .flatten()
3393- else {2584+ .expect("ffmpeg generates testsrc2");
3394- eprintln!("skipped: ffmpeg cannot generate testsrc2");
3395- return;
3396- };
3397 let clips: [(&str, Vec<I420>, PathBuf); 2] = [2585 let clips: [(&str, Vec<I420>, PathBuf); 2] = [
3398 ("moving box", synthetic, synthetic_y4m),2586 ("moving box", synthetic, synthetic_y4m),
3399 ("testsrc2", testsrc, testsrc_y4m),2587 ("testsrc2", testsrc, testsrc_y4m),
@@ -3639,11 +2827,8 @@ fn a_broken_gop_is_refused_on_every_codec() {
3639 (Codec::H265, "hevc-bframes-320.265"),2827 (Codec::H265, "hevc-bframes-320.265"),
3640 ];2828 ];
3641 for (codec, name) in cases {2829 for (codec, name) in cases {
3642- let path = bitstreams().join(name);2830+ let path = ec_testkit::fixture(&format!("bitstreams/{name}"));
3643- let Ok(data) = std::fs::read(&path) else {2831+ let data = std::fs::read(&path).expect("fixture is readable");
3644- eprintln!("skipped {name}: no fixture");
3645- continue;
3646- };
3647 let stream = broken_gop(codec, &data).expect("the fixture has a second access unit");2832 let stream = broken_gop(codec, &data).expect("the fixture has a second access unit");
3648 let mut decoder = Decoder::new(&display, codec).expect("decoder");2833 let mut decoder = Decoder::new(&display, codec).expect("decoder");
3649 let refusal = decoder.decode(&stream, 0).err().map(|e| e.to_string());2834 let refusal = decoder.decode(&stream, 0).err().map(|e| e.to_string());
@@ -3665,11 +2850,9 @@ fn a_broken_gop_is_refused_on_every_codec() {
3665 2850
3666 #[test]2851 #[test]
3667 fn ten_bit_prime_submit_matches_the_cpu_path() {2852 fn ten_bit_prime_submit_matches_the_cpu_path() {
3668- let Some(file) = std::env::var_os("EC_HEVC10").map(PathBuf::from) else {2853+ let file = ec_testkit::fixture("derived/sintel720-x265-main10.mp4");
3669- return;
3670- };
3671 let Some(display) = display() else { return };2854 let Some(display) = display() else { return };
3672- let data = std::fs::read(file).expect("fixture is readable");2855+ let data = elementary(&file, Codec::H265, 1).expect("elementary stream");
3673 let mut decoder = Decoder::new(&display, Codec::H265).expect("decoder opens");2856 let mut decoder = Decoder::new(&display, Codec::H265).expect("decoder opens");
3674 let mut size = (0, 0);2857 let mut size = (0, 0);
3675 decode_stream(&mut decoder, Codec::H265, &data, 1, |f| {2858 decode_stream(&mut decoder, Codec::H265, &data, 1, |f| {
crates/ec-hw/tests/idr_counting.rsmodified+4 -4
@@ -9,7 +9,7 @@
9 //! warnings.9 //! warnings.
10 10
11 use std::path::{Path, PathBuf};11 use std::path::{Path, PathBuf};
12-use std::process::{Command, Stdio};12+use std::process::Stdio;
13 use std::rc::Rc;13 use std::rc::Rc;
14 14
15 use ec_hw::{EncCodec, Encoder, EncoderConfig, FrameMetadata, I420, RateControlMode};15 use ec_hw::{EncCodec, Encoder, EncoderConfig, FrameMetadata, I420, RateControlMode};
@@ -90,7 +90,7 @@ fn encode(codec: EncCodec, frames: u32, gop: u32) -> Option<(Vec<u8>, Vec<bool>)
90 /// Every slice header field as `(name, value)`, in stream order, from ffmpeg's90 /// Every slice header field as `(name, value)`, in stream order, from ffmpeg's
91 /// header trace.91 /// header trace.
92 fn trace_headers(path: &Path, format: &str) -> Vec<(String, i64)> {92 fn trace_headers(path: &Path, format: &str) -> Vec<(String, i64)> {
93- let out = Command::new("ffmpeg")93+ let out = ec_testkit::ffmpeg()
94 .args([94 .args([
95 "-nostdin",95 "-nostdin",
96 "-v",96 "-v",
@@ -129,7 +129,7 @@ fn values(fields: &[(String, i64)], name: &str) -> Vec<i64> {
129 /// Decode with ffmpeg: stderr must be empty at `-v error`, and at `-v debug` no129 /// Decode with ffmpeg: stderr must be empty at `-v error`, and at `-v debug` no
130 /// line may report a frame_num gap. Returns the decoded planes.130 /// line may report a frame_num gap. Returns the decoded planes.
131 fn decode_clean(path: &Path, format: &str, frames: u32) -> Vec<u8> {131 fn decode_clean(path: &Path, format: &str, frames: u32) -> Vec<u8> {
132- let quiet = Command::new("ffmpeg")132+ let quiet = ec_testkit::ffmpeg()
133 .args(["-nostdin", "-v", "error", "-f", format, "-i"])133 .args(["-nostdin", "-v", "error", "-f", format, "-i"])
134 .arg(path)134 .arg(path)
135 .args(["-f", "rawvideo", "-pix_fmt", "yuv420p", "-"])135 .args(["-f", "rawvideo", "-pix_fmt", "yuv420p", "-"])
@@ -147,7 +147,7 @@ fn decode_clean(path: &Path, format: &str, frames: u32) -> Vec<u8> {
147 "every picture decodes, in order"147 "every picture decodes, in order"
148 );148 );
149 149
150- let debug = Command::new("ffmpeg")150+ let debug = ec_testkit::ffmpeg()
151 .args(["-nostdin", "-v", "debug", "-f", format, "-i"])151 .args(["-nostdin", "-v", "debug", "-f", format, "-i"])
152 .arg(path)152 .arg(path)
153 .args(["-f", "null", "-"])153 .args(["-f", "null", "-"])
crates/ec-hw/tests/intra_rate.rsmodified+8 -11
@@ -69,11 +69,10 @@ fn scratch() -> PathBuf {
69 dir69 dir
70 }70 }
71 71
72-/// The testsrc2 clip as raw 4:2:0, generated by ffmpeg. `None` when ffmpeg72+/// The testsrc2 clip as raw 4:2:0, generated by ffmpeg.
73-/// cannot make it, which skips the test rather than failing it.73+fn testsrc2_raw(dir: &Path) -> PathBuf {
74-fn testsrc2_raw(dir: &Path) -> Option<PathBuf> {
75 let path = dir.join("testsrc2-720p.yuv");74 let path = dir.join("testsrc2-720p.yuv");
76- let made = Command::new("ffmpeg")75+ let status = ec_testkit::ffmpeg()
77 .args(["-nostdin", "-v", "error", "-y", "-f", "lavfi", "-i"])76 .args(["-nostdin", "-v", "error", "-y", "-f", "lavfi", "-i"])
78 .arg(format!("testsrc2=size={WIDTH}x{HEIGHT}:rate={FPS}"))77 .arg(format!("testsrc2=size={WIDTH}x{HEIGHT}:rate={FPS}"))
79 .args([78 .args([
@@ -86,8 +85,9 @@ fn testsrc2_raw(dir: &Path) -> Option<PathBuf> {
86 ])85 ])
87 .arg(&path)86 .arg(&path)
88 .status()87 .status()
89- .ok()?;88+ .expect("run ffmpeg");
90- made.success().then_some(path)89+ assert!(status.success(), "ffmpeg cannot generate testsrc2");
90+ path
91 }91 }
92 92
93 /// Picture `t` of the raw clip, read from the file at its offset.93 /// Picture `t` of the raw clip, read from the file at its offset.
@@ -241,7 +241,7 @@ fn encode_in_its_own_process(
241 fn psnr(coded: &Path, format: &str, source: &Path) -> Option<f64> {241 fn psnr(coded: &Path, format: &str, source: &Path) -> Option<f64> {
242 let rate = FPS.to_string();242 let rate = FPS.to_string();
243 let size = format!("{WIDTH}x{HEIGHT}");243 let size = format!("{WIDTH}x{HEIGHT}");
244- let out = Command::new("ffmpeg")244+ let out = ec_testkit::ffmpeg()
245 .args(["-nostdin", "-v", "info", "-f", format, "-r", &rate, "-i"])245 .args(["-nostdin", "-v", "info", "-f", format, "-r", &rate, "-i"])
246 .arg(coded)246 .arg(coded)
247 .args([247 .args([
@@ -264,10 +264,7 @@ fn psnr(coded: &Path, format: &str, source: &Path) -> Option<f64> {
264 #[test]264 #[test]
265 fn cbr_lands_within_five_percent_on_intra_only_and_gop_30() {265 fn cbr_lands_within_five_percent_on_intra_only_and_gop_30() {
266 let dir = scratch();266 let dir = scratch();
267- let Some(source) = testsrc2_raw(&dir) else {267+ let source = testsrc2_raw(&dir);
268- eprintln!("skipped: ffmpeg cannot generate testsrc2");
269- return;
270- };
271 268
272 let mut failures = Vec::new();269 let mut failures = Vec::new();
273 println!(270 println!(
tools/ec-bench/Cargo.tomlmodified+1 -0
@@ -32,3 +32,4 @@ ec-flac = { workspace = true }
32 ec-alac = { workspace = true }32 ec-alac = { workspace = true }
33 ec-ac3 = { workspace = true }33 ec-ac3 = { workspace = true }
34 ec-truehd = { workspace = true }34 ec-truehd = { workspace = true }
35+ec-testkit.workspace = true
tools/ec-bench/src/main.rsmodified+15 -84
@@ -11,7 +11,6 @@
11 #![forbid(unsafe_code)]11 #![forbid(unsafe_code)]
12 12
13 use std::path::{Path, PathBuf};13 use std::path::{Path, PathBuf};
14-use std::process::Command;
15 use std::time::Instant;14 use std::time::Instant;
16 15
17 use ec_av1::encode::Picture as Av1Picture;16 use ec_av1::encode::Picture as Av1Picture;
@@ -81,42 +80,18 @@ fn fixtures() -> PathBuf {
81 Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures")80 Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures")
82 }81 }
83 82
84-fn home() -> PathBuf {83+/// The open clip the bench uses as the source for a codec.
85- PathBuf::from(std::env::var("HOME").expect("HOME"))
86-}
87-
88-/// A handful of real-library candidates, largest-effort first, that ffprobe
89-/// confirms carry the wanted video codec. Read-only: never touches the file
90-/// beyond `ffprobe`/`ffmpeg -i ... -o <scratch>`.
91 fn real_video(codec: &str) -> Option<PathBuf> {84 fn real_video(codec: &str) -> Option<PathBuf> {
92- let roots = [home().join("Videos"), home().join("Downloads")];85+ let name = match codec {
93- let mut found = Vec::new();86+ "h264" => "open/sintel_trailer-1080p.mp4",
94- for root in roots {87+ "hevc" => "derived/sintel720-x265-main10.mp4",
95- let Ok(walker) = std::fs::read_dir(&root) else {88+ _ => return None,
96- continue;
97 };89 };
98- for entry in walker.flatten() {90+ Some(ec_testkit::fixture(name))
99- let p = entry.path();
100- let Some(ext) = p.extension().and_then(|e| e.to_str()) else {
101- continue;
102- };
103- if !matches!(
104- ext.to_ascii_lowercase().as_str(),
105- "mp4" | "mkv" | "mov" | "avi"
106- ) {
107- continue;
108- }
109- found.push(p);
110- }
111- }
112- found.sort();
113- found
114- .into_iter()
115- .find(|p| ffprobe_field(p, "v:0", "codec_name").as_deref() == Some(codec))
116 }91 }
117 92
118 fn ffprobe_field(path: &Path, stream: &str, key: &str) -> Option<String> {93 fn ffprobe_field(path: &Path, stream: &str, key: &str) -> Option<String> {
119- let out = Command::new("ffprobe")94+ let out = ec_testkit::ffprobe()
120 .args(["-v", "error", "-select_streams", stream, "-show_entries"])95 .args(["-v", "error", "-select_streams", stream, "-show_entries"])
121 .arg(format!("stream={key}"))96 .arg(format!("stream={key}"))
122 .args(["-of", "default=nw=1:nk=1"])97 .args(["-of", "default=nw=1:nk=1"])
@@ -148,7 +123,7 @@ fn bench_h264(rows: &mut Vec<Row>) {
148 .unwrap_or(0);123 .unwrap_or(0);
149 124
150 // decode: 10s Annex-B extract, trimmed inside ffmpeg (never decode-then-trim).125 // decode: 10s Annex-B extract, trimmed inside ffmpeg (never decode-then-trim).
151- let out = Command::new("ffmpeg")126+ let out = ec_testkit::ffmpeg()
152 .args(["-v", "error", "-t", "10", "-i"])127 .args(["-v", "error", "-t", "10", "-i"])
153 .arg(&src)128 .arg(&src)
154 .args([129 .args([
@@ -230,7 +205,7 @@ fn bench_h264(rows: &mut Vec<Row>) {
230 /// `n` progressive frames of raw I420 at `w x h`, scaled and trimmed inside205 /// `n` progressive frames of raw I420 at `w x h`, scaled and trimmed inside
231 /// ffmpeg.206 /// ffmpeg.
232 fn extract_yuv420p(src: &Path, w: u32, h: u32, n: u32) -> (Vec<u8>, u32, u32, u32) {207 fn extract_yuv420p(src: &Path, w: u32, h: u32, n: u32) -> (Vec<u8>, u32, u32, u32) {
233- let out = Command::new("ffmpeg")208+ let out = ec_testkit::ffmpeg()
234 .args(["-v", "error", "-i"])209 .args(["-v", "error", "-i"])
235 .arg(src)210 .arg(src)
236 .args([211 .args([
@@ -475,7 +450,7 @@ fn bench_hw_av1_encode_10bit(rows: &mut Vec<Row>) {
475 /// minute in: frame 0 of a film is its black leader, and a black leader codes450 /// minute in: frame 0 of a film is its black leader, and a black leader codes
476 /// to nothing and benchmarks nothing.451 /// to nothing and benchmarks nothing.
477 fn extract_yuv420p10(src: &Path, w: u32, h: u32, n: u32) -> Vec<u8> {452 fn extract_yuv420p10(src: &Path, w: u32, h: u32, n: u32) -> Vec<u8> {
478- let out = Command::new("ffmpeg")453+ let out = ec_testkit::ffmpeg()
479 .args(["-v", "error", "-ss", "60", "-i"])454 .args(["-v", "error", "-ss", "60", "-i"])
480 .arg(src)455 .arg(src)
481 .args([456 .args([
@@ -638,32 +613,7 @@ fn bench_audio_decode(rows: &mut Vec<Row>) {
638 if let Ok(entries) = std::fs::read_dir(fixtures().join("audio")) {613 if let Ok(entries) = std::fs::read_dir(fixtures().join("audio")) {
639 candidates.extend(entries.flatten().map(|e| e.path()));614 candidates.extend(entries.flatten().map(|e| e.path()));
640 }615 }
641- // Real-library samples: mp3 and wav are on disk; ac3 lives inside the616+ candidates.push(ec_testkit::fixture("open/fate/ac3/monsters_inc_5.1_448_small.ac3"));
642- // ReelT mux (5.1 AC-3), extracted as its own elementary file.
643- for f in ["8a3b6d1d19.mp3", "test.wav"] {
644- let p = home().join("Downloads").join(f);
645- if p.exists() {
646- candidates.push(p);
647- }
648- }
649- if let Some(src) = real_video("h264")
650- && ffprobe_field(&src, "a:0", "codec_name").as_deref() == Some("ac3")
651- {
652- let out = Command::new("ffmpeg")
653- .args(["-v", "error", "-t", "10", "-i"])
654- .arg(&src)
655- .args(["-vn", "-c:a", "copy", "-f", "ac3"])
656- .arg(
657- Path::new(&std::env::var("HOME").unwrap())
658- .join(".cache/bench-media/sample.ac3"),
659- )
660- .output();
661- if let Ok(o) = out
662- && o.status.success()
663- {
664- candidates.push(home().join(".cache/bench-media/sample.ac3"));
665- }
666- }
667 candidates.sort();617 candidates.sort();
668 candidates.dedup();618 candidates.dedup();
669 619
@@ -717,7 +667,7 @@ fn bench_audio_decode(rows: &mut Vec<Row>) {
717 /// `seconds` of real interleaved `f32` PCM, decoded through `ec-probe`'s own667 /// `seconds` of real interleaved `f32` PCM, decoded through `ec-probe`'s own
718 /// `Reader`/`AudioDecoder` route (the same one `bench_audio_decode` drives).668 /// `Reader`/`AudioDecoder` route (the same one `bench_audio_decode` drives).
719 fn real_pcm(seconds: f64) -> Option<(Vec<f32>, u32, usize)> {669 fn real_pcm(seconds: f64) -> Option<(Vec<f32>, u32, usize)> {
720- let path = fixtures().join("audio/wav16-stereo-48000.wav");670+ let path = ec_testkit::fixture("audio/wav16-stereo-48000.wav");
721 let mut reader = Reader::open(&path).ok()?;671 let mut reader = Reader::open(&path).ok()?;
722 let stream = reader.default_stream(MediaType::Audio)?.index;672 let stream = reader.default_stream(MediaType::Audio)?.index;
723 let mut dec = reader.make_decoder(stream).ok()?;673 let mut dec = reader.make_decoder(stream).ok()?;
@@ -1023,7 +973,7 @@ fn bench_truehd(rows: &mut Vec<Row>) {
1023 /// Container-level duration (`format=duration`), for a mux whose per-stream973 /// Container-level duration (`format=duration`), for a mux whose per-stream
1024 /// packets carry no duration field of their own (some Matroska tracks don't).974 /// packets carry no duration field of their own (some Matroska tracks don't).
1025 fn format_duration(path: &Path) -> Option<String> {975 fn format_duration(path: &Path) -> Option<String> {
1026- let out = Command::new("ffprobe")976+ let out = ec_testkit::ffprobe()
1027 .args(["-v", "error", "-show_entries", "format=duration"])977 .args(["-v", "error", "-show_entries", "format=duration"])
1028 .args(["-of", "default=nw=1:nk=1"])978 .args(["-of", "default=nw=1:nk=1"])
1029 .arg(path)979 .arg(path)
@@ -1038,7 +988,7 @@ fn format_duration(path: &Path) -> Option<String> {
1038 988
1039 fn bench_container_demux(rows: &mut Vec<Row>) {989 fn bench_container_demux(rows: &mut Vec<Row>) {
1040 for (component, ext) in [("ec-matroska", "mkv"), ("ec-mp4", "mp4")] {990 for (component, ext) in [("ec-matroska", "mkv"), ("ec-mp4", "mp4")] {
1041- let Some(src) = [fixtures().join("video"), home().join("Videos")]991+ let Some(src) = [ec_testkit::root().join("open"), ec_testkit::root().join("derived")]
1042 .into_iter()992 .into_iter()
1043 .filter_map(|d| std::fs::read_dir(d).ok())993 .filter_map(|d| std::fs::read_dir(d).ok())
1044 .flatten()994 .flatten()
@@ -1096,17 +1046,6 @@ fn bench_image_decode(rows: &mut Vec<Row>) {
1096 .filter(|p| p.extension().is_some()),1046 .filter(|p| p.extension().is_some()),
1097 );1047 );
1098 }1048 }
1099- for f in [
1100- "IMG_20260804_170612.jpg",
1101- "drawing-1.png",
1102- "20260722-233942.png",
1103- "giphy.gif",
1104- ] {
1105- let p = home().join("Downloads").join(f);
1106- if p.exists() {
1107- candidates.push(p);
1108- }
1109- }
1110 candidates.sort();1049 candidates.sort();
1111 1050
1112 for path in candidates {1051 for path in candidates {
@@ -1138,15 +1077,7 @@ fn bench_image_decode(rows: &mut Vec<Row>) {
1138 // ---------------------------------------------------------------------------1077 // ---------------------------------------------------------------------------
1139 1078
1140 fn bench_inflate(rows: &mut Vec<Row>) {1079 fn bench_inflate(rows: &mut Vec<Row>) {
1141- let Some(png) = [1080+ let png = fixtures().join("stills/gray16.png");
1142- fixtures().join("stills/gray16.png"),
1143- home().join("Downloads/drawing-1.png"),
1144- ]
1145- .into_iter()
1146- .find(|p| p.exists()) else {
1147- rows.push(missing("ec-inflate", "inflate"));
1148- return;
1149- };
1150 let Ok(bytes) = std::fs::read(&png) else {1081 let Ok(bytes) = std::fs::read(&png) else {
1151 rows.push(missing("ec-inflate", "inflate"));1082 rows.push(missing("ec-inflate", "inflate"));
1152 return;1083 return;
tools/oracle/Cargo.tomlmodified+1 -0
@@ -13,3 +13,4 @@ path = "src/main.rs"
13 # No dependencies on purpose: the oracle drives ffmpeg/ffprobe through std process13 # No dependencies on purpose: the oracle drives ffmpeg/ffprobe through std process
14 # pipes so that comparison tooling can never leak into any ec-* crate's dep graph.14 # pipes so that comparison tooling can never leak into any ec-* crate's dep graph.
15 [dependencies]15 [dependencies]
16+ec-testkit.workspace = true
tools/oracle/src/main.rsmodified+3 -3
@@ -18,7 +18,7 @@
18 #![forbid(unsafe_code)]18 #![forbid(unsafe_code)]
19 19
20 use std::collections::HashMap;20 use std::collections::HashMap;
21-use std::process::{Command, Stdio};21+use std::process::Stdio;
22 22
23 const USAGE: &str = "\23 const USAGE: &str = "\
24 oracle — comparison harness (ffmpeg is test tooling only)24 oracle — comparison harness (ffmpeg is test tooling only)
@@ -98,7 +98,7 @@ impl Args {
98 /// Decode `input` with ffmpeg and return the raw bytes it writes to stdout.98 /// Decode `input` with ffmpeg and return the raw bytes it writes to stdout.
99 /// stderr is inherited so a large error log can never deadlock the pipe.99 /// stderr is inherited so a large error log can never deadlock the pipe.
100 fn ffmpeg_raw(input: &str, extra: &[&str]) -> Result<Vec<u8>, String> {100 fn ffmpeg_raw(input: &str, extra: &[&str]) -> Result<Vec<u8>, String> {
101- let out = Command::new("ffmpeg")101+ let out = ec_testkit::ffmpeg()
102 .args(["-nostdin", "-v", "error", "-i", input])102 .args(["-nostdin", "-v", "error", "-i", input])
103 .args(extra)103 .args(extra)
104 .arg("-")104 .arg("-")
@@ -117,7 +117,7 @@ fn ffmpeg_raw(input: &str, extra: &[&str]) -> Result<Vec<u8>, String> {
117 117
118 /// `ffprobe -show_entries stream=<entries>` as a key -> value map (first stream wins).118 /// `ffprobe -show_entries stream=<entries>` as a key -> value map (first stream wins).
119 fn ffprobe(input: &str, select: &str, entries: &str) -> Result<HashMap<String, String>, String> {119 fn ffprobe(input: &str, select: &str, entries: &str) -> Result<HashMap<String, String>, String> {
120- let out = Command::new("ffprobe")120+ let out = ec_testkit::ffprobe()
121 .args(["-v", "error", "-select_streams", select, "-show_entries"])121 .args(["-v", "error", "-select_streams", select, "-show_entries"])
122 .arg(format!("stream={entries}"))122 .arg(format!("stream={entries}"))
123 .args(["-of", "default=nw=1"])123 .args(["-of", "default=nw=1"])
tools/oracle/tests/cli.rsmodified+7 -41
@@ -2,19 +2,10 @@
2 //! crate's test will, using ffmpeg as both the "our decoder" stand-in and the2 //! crate's test will, using ffmpeg as both the "our decoder" stand-in and the
3 //! reference. Exercises the PASS and the FAIL path of every subcommand.3 //! reference. Exercises the PASS and the FAIL path of every subcommand.
4 //!4 //!
5-//! Fixture-gated: fixtures/ is gitignored, so a checkout without
6-//! `scripts/gen-fixtures.sh` run skips loudly instead of failing.
7 5
8 use std::path::{Path, PathBuf};6 use std::path::{Path, PathBuf};
9 use std::process::{Command, Stdio};7 use std::process::{Command, Stdio};
10 8
11-fn fixtures() -> PathBuf {
12- Path::new(env!("CARGO_MANIFEST_DIR"))
13- .join("../../fixtures")
14- .canonicalize()
15- .unwrap_or_else(|_| PathBuf::from("/nonexistent"))
16-}
17-
18 // Per-test directory: the test binary runs its cases as threads of one process,9 // Per-test directory: the test binary runs its cases as threads of one process,
19 // so a pid-only name would let one case delete another's raw files.10 // so a pid-only name would let one case delete another's raw files.
20 fn workdir(name: &str) -> PathBuf {11 fn workdir(name: &str) -> PathBuf {
@@ -26,7 +17,7 @@ fn workdir(name: &str) -> PathBuf {
26 /// Decode `input` to a raw file with ffmpeg — stands in for "our decoder's output".17 /// Decode `input` to a raw file with ffmpeg — stands in for "our decoder's output".
27 fn decode_raw(input: &Path, out: &Path, extra: &[&str]) {18 fn decode_raw(input: &Path, out: &Path, extra: &[&str]) {
28 let f = std::fs::File::create(out).unwrap();19 let f = std::fs::File::create(out).unwrap();
29- let st = Command::new("ffmpeg")20+ let st = ec_testkit::ffmpeg()
30 .args(["-nostdin", "-y", "-v", "error", "-i"])21 .args(["-nostdin", "-y", "-v", "error", "-i"])
31 .arg(input)22 .arg(input)
32 .args(extra)23 .args(extra)
@@ -46,29 +37,12 @@ fn oracle(args: &[&str]) -> i32 {
46 .expect("oracle exited by signal")37 .expect("oracle exited by signal")
47 }38 }
48 39
49-fn require(paths: &[PathBuf]) -> bool {
50- for p in paths {
51- if !p.is_file() {
52- eprintln!(
53- "SKIP: missing fixture {} — run scripts/gen-fixtures.sh",
54- p.display()
55- );
56- return false;
57- }
58- }
59- true
60-}
61-
62 const F32: &[&str] = &["-map", "0:a:0", "-f", "f32le", "-acodec", "pcm_f32le"];40 const F32: &[&str] = &["-map", "0:a:0", "-f", "f32le", "-acodec", "pcm_f32le"];
63 41
64 #[test]42 #[test]
65 fn bit_exact_passes_on_same_decode_and_fails_on_a_different_one() {43 fn bit_exact_passes_on_same_decode_and_fails_on_a_different_one() {
66- let fx = fixtures();44+ let a = ec_testkit::fixture("audio/flac-stereo-48000.flac");
67- let a = fx.join("audio/flac-stereo-48000.flac");45+ let b = ec_testkit::fixture("audio/flac-mono-48000.flac");
68- let b = fx.join("audio/flac-mono-48000.flac");
69- if !require(&[a.clone(), b.clone()]) {
70- return;
71- }
72 let w = workdir("bitexact");46 let w = workdir("bitexact");
73 let (r1, r2, r3) = (w.join("a1.raw"), w.join("a2.raw"), w.join("b.raw"));47 let (r1, r2, r3) = (w.join("a1.raw"), w.join("a2.raw"), w.join("b.raw"));
74 decode_raw(&a, &r1, F32);48 decode_raw(&a, &r1, F32);
@@ -90,12 +64,8 @@ fn bit_exact_passes_on_same_decode_and_fails_on_a_different_one() {
90 64
91 #[test]65 #[test]
92 fn audio_compare_passes_against_its_own_source_and_fails_across_rates() {66 fn audio_compare_passes_against_its_own_source_and_fails_across_rates() {
93- let fx = fixtures();67+ let a = ec_testkit::fixture("audio/flac-stereo-48000.flac");
94- let a = fx.join("audio/flac-stereo-48000.flac");68+ let b = ec_testkit::fixture("audio/flac-stereo-44100.flac");
95- let b = fx.join("audio/flac-stereo-44100.flac");
96- if !require(&[a.clone(), b.clone()]) {
97- return;
98- }
99 let w = workdir("audio");69 let w = workdir("audio");
100 let (ra, rb) = (w.join("a.raw"), w.join("b.raw"));70 let (ra, rb) = (w.join("a.raw"), w.join("b.raw"));
101 decode_raw(&a, &ra, F32);71 decode_raw(&a, &ra, F32);
@@ -117,12 +87,8 @@ fn audio_compare_passes_against_its_own_source_and_fails_across_rates() {
117 87
118 #[test]88 #[test]
119 fn video_compare_passes_against_its_own_source_and_fails_on_frame_count() {89 fn video_compare_passes_against_its_own_source_and_fails_on_frame_count() {
120- let fx = fixtures();90+ let a = ec_testkit::fixture("video/h264-1080p-23.976-8bit.mp4");
121- let a = fx.join("video/h264-1080p-23.976-8bit.mp4");91+ let b = ec_testkit::fixture("video/h264-1080p-60-8bit.mp4");
122- let b = fx.join("video/h264-1080p-60-8bit.mp4");
123- if !require(&[a.clone(), b.clone()]) {
124- return;
125- }
126 let w = workdir("video");92 let w = workdir("video");
127 let raw = w.join("a.raw");93 let raw = w.join("a.raw");
128 decode_raw(94 decode_raw(