Merge branch 'simplify/w0-m6' into simplify/w0
Browse files at this commit27 changed files +55 -346
- Cargo.lock +6 -0
- crates/ec-dnxhd/Cargo.toml +1 -0
- crates/ec-dnxhd/tests/common/mod.rs +1 -24
- crates/ec-dnxhd/tests/ffmpeg_parity.rs +0 -15
- crates/ec-dnxhd/tests/refusals.rs +8 -11
- crates/ec-dv/Cargo.toml +1 -0
- crates/ec-dv/tests/common/mod.rs +1 -20
- crates/ec-dv/tests/containers.rs +10 -29
- crates/ec-dv/tests/ffmpeg_parity.rs +0 -9
- crates/ec-dv/tests/perf.rs +0 -3
- crates/ec-mjpeg/Cargo.toml +1 -0
- crates/ec-mjpeg/tests/ffmpeg_parity.rs +2 -46
- crates/ec-mpeg2/Cargo.toml +3 -0
- crates/ec-mpeg2/tests/common/mod.rs +1 -14
- crates/ec-mpeg2/tests/ffmpeg_parity.rs +1 -10
- crates/ec-mpeg2/tests/synth_parity.rs +0 -5
- crates/ec-mpeg4/Cargo.toml +1 -0
- crates/ec-mpeg4/tests/common/mod.rs +1 -40
- crates/ec-mpeg4/tests/containers.rs +2 -23
- crates/ec-mpeg4/tests/ffmpeg_parity.rs +1 -21
- crates/ec-mpeg4/tests/msmpeg4.rs +0 -8
- crates/ec-prores/Cargo.toml +1 -0
- crates/ec-prores/tests/common/mod.rs +1 -24
- crates/ec-prores/tests/encode.rs +4 -27
- crates/ec-prores/tests/ffmpeg_parity.rs +0 -3
- crates/ec-prores/tests/perf.rs +0 -3
- crates/ec-prores/tests/robust.rs +8 -11
Cargo.lockmodified+6 -0
| @@ -437,6 +437,7 @@ dependencies = [ | |||
| 437 | "ec-matroska", | 437 | "ec-matroska", |
| 438 | "ec-mp4", | 438 | "ec-mp4", |
| 439 | "ec-riff", | 439 | "ec-riff", |
| 440 | + "ec-testkit", | ||
| 440 | ] | 441 | ] |
| 441 | 442 | ||
| 442 | [[package]] | 443 | [[package]] |
| @@ -462,6 +463,7 @@ dependencies = [ | |||
| 462 | "ec-core", | 463 | "ec-core", |
| 463 | "ec-mp4", | 464 | "ec-mp4", |
| 464 | "ec-riff", | 465 | "ec-riff", |
| 466 | + "ec-testkit", | ||
| 465 | ] | 467 | ] |
| 466 | 468 | ||
| 467 | [[package]] | 469 | [[package]] |
| @@ -584,6 +586,7 @@ dependencies = [ | |||
| 584 | "ec-image", | 586 | "ec-image", |
| 585 | "ec-matroska", | 587 | "ec-matroska", |
| 586 | "ec-mp4", | 588 | "ec-mp4", |
| 589 | + "ec-testkit", | ||
| 587 | ] | 590 | ] |
| 588 | 591 | ||
| 589 | [[package]] | 592 | [[package]] |
| @@ -608,6 +611,7 @@ name = "ec-mpeg2" | |||
| 608 | version = "0.1.0" | 611 | version = "0.1.0" |
| 609 | dependencies = [ | 612 | dependencies = [ |
| 610 | "ec-core", | 613 | "ec-core", |
| 614 | + "ec-testkit", | ||
| 611 | ] | 615 | ] |
| 612 | 616 | ||
| 613 | [[package]] | 617 | [[package]] |
| @@ -618,6 +622,7 @@ dependencies = [ | |||
| 618 | "ec-matroska", | 622 | "ec-matroska", |
| 619 | "ec-mp4", | 623 | "ec-mp4", |
| 620 | "ec-riff", | 624 | "ec-riff", |
| 625 | + "ec-testkit", | ||
| 621 | ] | 626 | ] |
| 622 | 627 | ||
| 623 | [[package]] | 628 | [[package]] |
| @@ -698,6 +703,7 @@ dependencies = [ | |||
| 698 | "bytemuck", | 703 | "bytemuck", |
| 699 | "ec-core", | 704 | "ec-core", |
| 700 | "ec-mp4", | 705 | "ec-mp4", |
| 706 | + "ec-testkit", | ||
| 701 | "wide", | 707 | "wide", |
| 702 | ] | 708 | ] |
| 703 | 709 | ||
crates/ec-dnxhd/Cargo.tomlmodified+1 -0
| @@ -10,6 +10,7 @@ authors.workspace = true | |||
| 10 | ec-core = { workspace = true } | 10 | ec-core = { workspace = true } |
| 11 | 11 | ||
| 12 | [dev-dependencies] | 12 | [dev-dependencies] |
| 13 | +ec-testkit.workspace = true | ||
| 13 | ec-mp4 = { workspace = true } | 14 | ec-mp4 = { workspace = true } |
| 14 | ec-matroska = { workspace = true } | 15 | ec-matroska = { workspace = true } |
| 15 | ec-riff = { workspace = true } | 16 | ec-riff = { workspace = true } |
crates/ec-dnxhd/tests/common/mod.rsmodified+1 -24
| @@ -2,33 +2,10 @@ | |||
| 2 | #![allow(dead_code)] | 2 | #![allow(dead_code)] |
| 3 | 3 | ||
| 4 | use std::path::{Path, PathBuf}; | 4 | use std::path::{Path, PathBuf}; |
| 5 | -use std::process::Command; | ||
| 6 | 5 | ||
| 7 | use ec_core::Demuxer; | 6 | use ec_core::Demuxer; |
| 8 | use ec_core::frame::VideoFrame; | 7 | use ec_core::frame::VideoFrame; |
| 9 | 8 | ||
| 10 | -pub fn require() -> bool { | ||
| 11 | - std::env::var_os("EC_REQUIRE_FIXTURES").is_some() | ||
| 12 | -} | ||
| 13 | - | ||
| 14 | -pub fn have_ffmpeg() -> bool { | ||
| 15 | - Command::new("ffmpeg") | ||
| 16 | - .arg("-version") | ||
| 17 | - .output() | ||
| 18 | - .map(|o| o.status.success()) | ||
| 19 | - .unwrap_or(false) | ||
| 20 | -} | ||
| 21 | - | ||
| 22 | -/// True when the test may run; panics instead of skipping when fixtures are required. | ||
| 23 | -pub fn can_run() -> bool { | ||
| 24 | - if have_ffmpeg() { | ||
| 25 | - return true; | ||
| 26 | - } | ||
| 27 | - assert!(!require(), "ffmpeg is required (EC_REQUIRE_FIXTURES set)"); | ||
| 28 | - eprintln!("skipping: no ffmpeg"); | ||
| 29 | - false | ||
| 30 | -} | ||
| 31 | - | ||
| 32 | pub fn scratch(tag: &str) -> PathBuf { | 9 | pub fn scratch(tag: &str) -> PathBuf { |
| 33 | let base = std::env::var_os("TMPDIR") | 10 | let base = std::env::var_os("TMPDIR") |
| 34 | .map(PathBuf::from) | 11 | .map(PathBuf::from) |
| @@ -39,7 +16,7 @@ pub fn scratch(tag: &str) -> PathBuf { | |||
| 39 | } | 16 | } |
| 40 | 17 | ||
| 41 | pub fn ffmpeg(args: &[&str]) -> bool { | 18 | pub fn ffmpeg(args: &[&str]) -> bool { |
| 42 | - let out = Command::new("ffmpeg") | 19 | + let out = ec_testkit::ffmpeg() |
| 43 | .args(["-v", "error", "-y", "-nostdin"]) | 20 | .args(["-v", "error", "-y", "-nostdin"]) |
| 44 | .args(args) | 21 | .args(args) |
| 45 | .output(); | 22 | .output(); |
crates/ec-dnxhd/tests/ffmpeg_parity.rsmodified+0 -15
| @@ -160,9 +160,6 @@ fn compare(tag: &str, frames: &[Vec<u8>], threads: usize) -> Result<Picture, Str | |||
| 160 | } | 160 | } |
| 161 | 161 | ||
| 162 | fn run_cases(tag: &str, cases: &[Case]) { | 162 | fn run_cases(tag: &str, cases: &[Case]) { |
| 163 | - if !can_run() { | ||
| 164 | - return; | ||
| 165 | - } | ||
| 166 | let dir = scratch(tag); | 163 | let dir = scratch(tag); |
| 167 | let mut failures = Vec::new(); | 164 | let mut failures = Vec::new(); |
| 168 | for case in cases { | 165 | for case in cases { |
| @@ -283,9 +280,6 @@ fn patched(frames: &[Vec<u8>], f: impl Fn(&mut [u8])) -> Vec<Vec<u8>> { | |||
| 283 | 280 | ||
| 284 | #[test] | 281 | #[test] |
| 285 | fn twelve_bit_streams_by_patching_the_depth_field() { | 282 | fn twelve_bit_streams_by_patching_the_depth_field() { |
| 286 | - if !can_run() { | ||
| 287 | - return; | ||
| 288 | - } | ||
| 289 | let dir = scratch("p12"); | 283 | let dir = scratch("p12"); |
| 290 | let mut failures = Vec::new(); | 284 | let mut failures = Vec::new(); |
| 291 | for (tag, size, pix, prof, src) in [ | 285 | for (tag, size, pix, prof, src) in [ |
| @@ -311,9 +305,6 @@ fn twelve_bit_streams_by_patching_the_depth_field() { | |||
| 311 | 305 | ||
| 312 | #[test] | 306 | #[test] |
| 313 | fn mbaff_cid_1260_by_patching_the_header() { | 307 | fn mbaff_cid_1260_by_patching_the_header() { |
| 314 | - if !can_run() { | ||
| 315 | - return; | ||
| 316 | - } | ||
| 317 | let dir = scratch("mbaff"); | 308 | let dir = scratch("mbaff"); |
| 318 | let mut failures = Vec::new(); | 309 | let mut failures = Vec::new(); |
| 319 | for (tag, src) in [("mbaff_t", T), ("mbaff_n", N)] { | 310 | for (tag, src) in [("mbaff_t", T), ("mbaff_n", N)] { |
| @@ -358,9 +349,6 @@ fn mbaff_cid_1260_by_patching_the_header() { | |||
| 358 | 349 | ||
| 359 | #[test] | 350 | #[test] |
| 360 | fn video_frame_output_formats_and_interlace_flag() { | 351 | fn video_frame_output_formats_and_interlace_flag() { |
| 361 | - if !can_run() { | ||
| 362 | - return; | ||
| 363 | - } | ||
| 364 | use ec_core::frame::{Interlace, PixelFormat}; | 352 | use ec_core::frame::{Interlace, PixelFormat}; |
| 365 | let dir = scratch("vf"); | 353 | let dir = scratch("vf"); |
| 366 | let mut dec = DnxhdDecoder::new(CodecParameters::new(CodecId::Dnxhd)).unwrap(); | 354 | let mut dec = DnxhdDecoder::new(CodecParameters::new(CodecId::Dnxhd)).unwrap(); |
| @@ -382,9 +370,6 @@ fn video_frame_output_formats_and_interlace_flag() { | |||
| 382 | 370 | ||
| 383 | #[test] | 371 | #[test] |
| 384 | fn matroska_carries_dnxhd_too() { | 372 | fn matroska_carries_dnxhd_too() { |
| 385 | - if !can_run() { | ||
| 386 | - return; | ||
| 387 | - } | ||
| 388 | let dir = scratch("mkv"); | 373 | let dir = scratch("mkv"); |
| 389 | let mkv = dir.join("a.mkv"); | 374 | let mkv = dir.join("a.mkv"); |
| 390 | let mov = dir.join("a.mov"); | 375 | let mov = dir.join("a.mov"); |
crates/ec-dnxhd/tests/refusals.rsmodified+8 -11
| @@ -11,10 +11,7 @@ fn decoder() -> DnxhdDecoder { | |||
| 11 | DnxhdDecoder::new(CodecParameters::new(CodecId::Dnxhd)).unwrap() | 11 | DnxhdDecoder::new(CodecParameters::new(CodecId::Dnxhd)).unwrap() |
| 12 | } | 12 | } |
| 13 | 13 | ||
| 14 | -fn encode_one(tag: &str, pix: &str, enc: &[&str]) -> Option<Vec<u8>> { | 14 | +fn encode_one(tag: &str, pix: &str, enc: &[&str]) -> Vec<u8> { |
| 15 | - if !can_run() { | ||
| 16 | - return None; | ||
| 17 | - } | ||
| 18 | let dir = scratch(tag); | 15 | let dir = scratch(tag); |
| 19 | let out = dir.join("a.mov"); | 16 | let out = dir.join("a.mov"); |
| 20 | let lavfi = format!("testsrc2=size=320x176:rate=25,format={pix}"); | 17 | let lavfi = format!("testsrc2=size=320x176:rate=25,format={pix}"); |
| @@ -24,7 +21,7 @@ fn encode_one(tag: &str, pix: &str, enc: &[&str]) -> Option<Vec<u8>> { | |||
| 24 | assert!(ffmpeg(&args)); | 21 | assert!(ffmpeg(&args)); |
| 25 | let f = mov_frames(&out).remove(0); | 22 | let f = mov_frames(&out).remove(0); |
| 26 | let _ = std::fs::remove_dir_all(&dir); | 23 | let _ = std::fs::remove_dir_all(&dir); |
| 27 | - Some(f) | 24 | + f |
| 28 | } | 25 | } |
| 29 | 26 | ||
| 30 | fn refused(r: Result<ec_core::frame::VideoFrame, Error>, what: &str) { | 27 | fn refused(r: Result<ec_core::frame::VideoFrame, Error>, what: &str) { |
| @@ -38,7 +35,7 @@ fn refused(r: Result<ec_core::frame::VideoFrame, Error>, what: &str) { | |||
| 38 | 35 | ||
| 39 | #[test] | 36 | #[test] |
| 40 | fn alpha_rgb_and_act_variants_are_refused_by_name() { | 37 | fn alpha_rgb_and_act_variants_are_refused_by_name() { |
| 41 | - let Some(sq) = encode_one("ref-sq", "yuv422p", &["-profile:v", "dnxhr_sq"]) else { return }; | 38 | + let sq = encode_one("ref-sq", "yuv422p", &["-profile:v", "dnxhr_sq"]); |
| 42 | assert!(decoder().decode_bytes(&sq).is_ok()); | 39 | assert!(decoder().decode_bytes(&sq).is_ok()); |
| 43 | 40 | ||
| 44 | let mut alpha = sq.clone(); | 41 | let mut alpha = sq.clone(); |
| @@ -50,16 +47,16 @@ fn alpha_rgb_and_act_variants_are_refused_by_name() { | |||
| 50 | refused(decoder().decode_bytes(&act), "adaptive colour transform"); | 47 | refused(decoder().decode_bytes(&act), "adaptive colour transform"); |
| 51 | 48 | ||
| 52 | // GBR (RGB) 4:4:4: ffmpeg writes it with the ACT flag clear. | 49 | // GBR (RGB) 4:4:4: ffmpeg writes it with the ACT flag clear. |
| 53 | - let rgb = encode_one("ref-rgb", "gbrp10le", &["-profile:v", "dnxhr_444"]).unwrap(); | 50 | + let rgb = encode_one("ref-rgb", "gbrp10le", &["-profile:v", "dnxhr_444"]); |
| 54 | refused(decoder().decode_bytes(&rgb), "RGB"); | 51 | refused(decoder().decode_bytes(&rgb), "RGB"); |
| 55 | // The same encoder's YCbCr 4:4:4 is accepted. | 52 | // The same encoder's YCbCr 4:4:4 is accepted. |
| 56 | - let yuv = encode_one("ref-444", "yuv444p10le", &["-profile:v", "dnxhr_444"]).unwrap(); | 53 | + let yuv = encode_one("ref-444", "yuv444p10le", &["-profile:v", "dnxhr_444"]); |
| 57 | assert!(decoder().decode_bytes(&yuv).is_ok()); | 54 | assert!(decoder().decode_bytes(&yuv).is_ok()); |
| 58 | } | 55 | } |
| 59 | 56 | ||
| 60 | #[test] | 57 | #[test] |
| 61 | fn unknown_cids_and_bad_headers_are_errors() { | 58 | fn unknown_cids_and_bad_headers_are_errors() { |
| 62 | - let Some(sq) = encode_one("ref-bad", "yuv422p", &["-profile:v", "dnxhr_sq"]) else { return }; | 59 | + let sq = encode_one("ref-bad", "yuv422p", &["-profile:v", "dnxhr_sq"]); |
| 63 | let mut bad = sq.clone(); | 60 | let mut bad = sq.clone(); |
| 64 | bad[0x28..0x2c].copy_from_slice(&1239u32.to_be_bytes()); | 61 | bad[0x28..0x2c].copy_from_slice(&1239u32.to_be_bytes()); |
| 65 | assert!(matches!(decoder().decode_bytes(&bad), Err(Error::Unsupported { .. }))); | 62 | assert!(matches!(decoder().decode_bytes(&bad), Err(Error::Unsupported { .. }))); |
| @@ -76,7 +73,7 @@ fn unknown_cids_and_bad_headers_are_errors() { | |||
| 76 | 73 | ||
| 77 | #[test] | 74 | #[test] |
| 78 | fn damaged_frames_never_panic() { | 75 | fn damaged_frames_never_panic() { |
| 79 | - let Some(hq) = encode_one("ref-dmg", "yuv422p10le", &["-profile:v", "dnxhr_hqx"]) else { return }; | 76 | + let hq = encode_one("ref-dmg", "yuv422p10le", &["-profile:v", "dnxhr_hqx"]); |
| 80 | let mut dec = decoder(); | 77 | let mut dec = decoder(); |
| 81 | let mut s = 0x9E37_79B9_7F4A_7C15u64; | 78 | let mut s = 0x9E37_79B9_7F4A_7C15u64; |
| 82 | let mut next = move || { | 79 | let mut next = move || { |
| @@ -119,7 +116,7 @@ fn damaged_frames_never_panic() { | |||
| 119 | #[test] | 116 | #[test] |
| 120 | fn registry_decoder_path_returns_a_frame() { | 117 | fn registry_decoder_path_returns_a_frame() { |
| 121 | use ec_core::registry::Decoder; | 118 | use ec_core::registry::Decoder; |
| 122 | - let Some(hq) = encode_one("ref-reg", "yuv422p", &["-profile:v", "dnxhr_hq"]) else { return }; | 119 | + let hq = encode_one("ref-reg", "yuv422p", &["-profile:v", "dnxhr_hq"]); |
| 123 | let mut d = decoder(); | 120 | let mut d = decoder(); |
| 124 | let pkt = ec_core::packet::Packet::new(0, ec_core::timebase::TimeBase::new(1, 25), hq); | 121 | let pkt = ec_core::packet::Packet::new(0, ec_core::timebase::TimeBase::new(1, 25), hq); |
| 125 | d.send_packet(&pkt).unwrap(); | 122 | d.send_packet(&pkt).unwrap(); |
crates/ec-dv/Cargo.tomlmodified+1 -0
| @@ -10,5 +10,6 @@ authors.workspace = true | |||
| 10 | ec-core = { workspace = true } | 10 | ec-core = { workspace = true } |
| 11 | 11 | ||
| 12 | [dev-dependencies] | 12 | [dev-dependencies] |
| 13 | +ec-testkit.workspace = true | ||
| 13 | ec-mp4 = { workspace = true } | 14 | ec-mp4 = { workspace = true } |
| 14 | ec-riff = { workspace = true } | 15 | ec-riff = { workspace = true } |
crates/ec-dv/tests/common/mod.rsmodified+1 -20
| @@ -2,25 +2,6 @@ | |||
| 2 | #![allow(dead_code)] | 2 | #![allow(dead_code)] |
| 3 | 3 | ||
| 4 | use std::path::{Path, PathBuf}; | 4 | use std::path::{Path, PathBuf}; |
| 5 | -use std::process::Command; | ||
| 6 | - | ||
| 7 | -pub fn require() -> bool { | ||
| 8 | - std::env::var_os("EC_REQUIRE_FIXTURES").is_some() | ||
| 9 | -} | ||
| 10 | - | ||
| 11 | -pub fn have_ffmpeg() -> bool { | ||
| 12 | - Command::new("ffmpeg").arg("-version").output().map(|o| o.status.success()).unwrap_or(false) | ||
| 13 | -} | ||
| 14 | - | ||
| 15 | -/// Skip (or fail under EC_REQUIRE_FIXTURES) when ffmpeg is missing. | ||
| 16 | -pub fn ffmpeg_or_skip() -> bool { | ||
| 17 | - if have_ffmpeg() { | ||
| 18 | - return true; | ||
| 19 | - } | ||
| 20 | - assert!(!require(), "EC_REQUIRE_FIXTURES set but ffmpeg is not available"); | ||
| 21 | - eprintln!("skipping: no ffmpeg"); | ||
| 22 | - false | ||
| 23 | -} | ||
| 24 | 5 | ||
| 25 | pub fn scratch(tag: &str) -> PathBuf { | 6 | pub fn scratch(tag: &str) -> PathBuf { |
| 26 | let base = std::env::var_os("TMPDIR").map(PathBuf::from).unwrap_or_else(std::env::temp_dir); | 7 | let base = std::env::var_os("TMPDIR").map(PathBuf::from).unwrap_or_else(std::env::temp_dir); |
| @@ -30,7 +11,7 @@ pub fn scratch(tag: &str) -> PathBuf { | |||
| 30 | } | 11 | } |
| 31 | 12 | ||
| 32 | pub fn run(args: &[&str]) -> bool { | 13 | pub fn run(args: &[&str]) -> bool { |
| 33 | - let out = Command::new("ffmpeg").args(["-v", "error", "-y", "-nostdin"]).args(args).output(); | 14 | + let out = ec_testkit::ffmpeg().args(["-v", "error", "-y", "-nostdin"]).args(args).output(); |
| 34 | match out { | 15 | match out { |
| 35 | Ok(o) => { | 16 | Ok(o) => { |
| 36 | if !o.status.success() { | 17 | if !o.status.success() { |
crates/ec-dv/tests/containers.rsmodified+10 -29
| @@ -35,9 +35,6 @@ fn native(frames: &[Vec<u8>]) -> Vec<u8> { | |||
| 35 | 35 | ||
| 36 | #[test] | 36 | #[test] |
| 37 | fn avi_and_mov_carry_dv() { | 37 | fn avi_and_mov_carry_dv() { |
| 38 | - if !ffmpeg_or_skip() { | ||
| 39 | - return; | ||
| 40 | - } | ||
| 41 | for f in [&FLAVOURS[0], &FLAVOURS[1], &FLAVOURS[3], &FLAVOURS[5]] { | 38 | for f in [&FLAVOURS[0], &FLAVOURS[1], &FLAVOURS[3], &FLAVOURS[5]] { |
| 42 | for ext in ["avi", "mov"] { | 39 | for ext in ["avi", "mov"] { |
| 43 | let Some(path) = make(f, "c", ext, true, 8) else { | 40 | let Some(path) = make(f, "c", ext, true, 8) else { |
| @@ -65,9 +62,6 @@ fn avi_and_mov_carry_dv() { | |||
| 65 | 62 | ||
| 66 | #[test] | 63 | #[test] |
| 67 | fn decoder_trait_output_formats() { | 64 | fn decoder_trait_output_formats() { |
| 68 | - if !ffmpeg_or_skip() { | ||
| 69 | - return; | ||
| 70 | - } | ||
| 71 | use ec_core::frame::{Frame, Interlace, PixelFormat}; | 65 | use ec_core::frame::{Frame, Interlace, PixelFormat}; |
| 72 | use ec_core::registry::CodecParameters; | 66 | use ec_core::registry::CodecParameters; |
| 73 | let cases = [(0usize, PixelFormat::I422), (1, PixelFormat::I420), (3, PixelFormat::I422), (5, PixelFormat::I422)]; | 67 | let cases = [(0usize, PixelFormat::I422), (1, PixelFormat::I420), (3, PixelFormat::I422), (5, PixelFormat::I422)]; |
| @@ -110,9 +104,6 @@ fn decoder_trait_output_formats() { | |||
| 110 | 104 | ||
| 111 | #[test] | 105 | #[test] |
| 112 | fn field_order_matches_ffprobe_view() { | 106 | fn field_order_matches_ffprobe_view() { |
| 113 | - if !ffmpeg_or_skip() { | ||
| 114 | - return; | ||
| 115 | - } | ||
| 116 | use ec_core::frame::Interlace; | 107 | use ec_core::frame::Interlace; |
| 117 | // ffmpeg's encoder: +ilme marks the stream interlaced; SD output is bottom-field-first | 108 | // ffmpeg's encoder: +ilme marks the stream interlaced; SD output is bottom-field-first |
| 118 | // unless the (top-field-first) flag is requested. | 109 | // unless the (top-field-first) flag is requested. |
| @@ -125,27 +116,23 @@ fn field_order_matches_ffprobe_view() { | |||
| 125 | }; | 116 | }; |
| 126 | let a = first(&ilme); | 117 | let a = first(&ilme); |
| 127 | let b = first(&prog); | 118 | let b = first(&prog); |
| 128 | - let out = std::process::Command::new("ffprobe") | 119 | + let out = ec_testkit::ffprobe() |
| 129 | .args(["-v", "error", "-select_streams", "v:0", "-show_frames", "-read_intervals", "%+#1", "-show_entries", "frame=interlaced_frame,top_field_first,flags", "-of", "default=nw=1"]) | 120 | .args(["-v", "error", "-select_streams", "v:0", "-show_frames", "-read_intervals", "%+#1", "-show_entries", "frame=interlaced_frame,top_field_first,flags", "-of", "default=nw=1"]) |
| 130 | .arg(&ilme) | 121 | .arg(&ilme) |
| 131 | - .output(); | 122 | + .output() |
| 132 | - if let Ok(o) = out { | 123 | + .unwrap(); |
| 133 | - let txt = String::from_utf8_lossy(&o.stdout).to_string(); | 124 | + let txt = String::from_utf8_lossy(&out.stdout).to_string(); |
| 134 | - let interlaced = txt.contains("interlaced_frame=1") || txt.contains("interlaced"); | 125 | + let interlaced = txt.contains("interlaced_frame=1") || txt.contains("interlaced"); |
| 135 | - let tff = txt.contains("top_field_first=1") || txt.contains("top_first"); | 126 | + let tff = txt.contains("top_field_first=1") || txt.contains("top_first"); |
| 136 | - assert_eq!(a.is_interlaced(), interlaced, "ffprobe says: {txt}"); | 127 | + assert_eq!(a.is_interlaced(), interlaced, "ffprobe says: {txt}"); |
| 137 | - if interlaced { | 128 | + if interlaced { |
| 138 | - assert_eq!(a == Interlace::TopFieldFirst, tff, "ffprobe says: {txt}"); | 129 | + assert_eq!(a == Interlace::TopFieldFirst, tff, "ffprobe says: {txt}"); |
| 139 | - } | ||
| 140 | } | 130 | } |
| 141 | assert!(!b.is_interlaced() || a.is_interlaced()); | 131 | assert!(!b.is_interlaced() || a.is_interlaced()); |
| 142 | } | 132 | } |
| 143 | 133 | ||
| 144 | #[test] | 134 | #[test] |
| 145 | fn raw_demuxer_sniff_seek_and_junk() { | 135 | fn raw_demuxer_sniff_seek_and_junk() { |
| 146 | - if !ffmpeg_or_skip() { | ||
| 147 | - return; | ||
| 148 | - } | ||
| 149 | let f = &FLAVOURS[0]; | 136 | let f = &FLAVOURS[0]; |
| 150 | let path = make(f, "s", "dv", true, 8).unwrap(); | 137 | let path = make(f, "s", "dv", true, 8).unwrap(); |
| 151 | let data = std::fs::read(&path).unwrap(); | 138 | let data = std::fs::read(&path).unwrap(); |
| @@ -178,19 +165,13 @@ fn raw_demuxer_sniff_seek_and_junk() { | |||
| 178 | 165 | ||
| 179 | #[test] | 166 | #[test] |
| 180 | fn audio_rates_and_12bit_match_ffmpeg() { | 167 | fn audio_rates_and_12bit_match_ffmpeg() { |
| 181 | - if !ffmpeg_or_skip() { | ||
| 182 | - return; | ||
| 183 | - } | ||
| 184 | let f = &FLAVOURS[1]; // PAL | 168 | let f = &FLAVOURS[1]; // PAL |
| 185 | for ar in ["44100", "32000"] { | 169 | for ar in ["44100", "32000"] { |
| 186 | let dir = scratch("ar"); | 170 | let dir = scratch("ar"); |
| 187 | let p = dir.join(format!("a{ar}.dv")); | 171 | let p = dir.join(format!("a{ar}.dv")); |
| 188 | let vsrc = "testsrc2=size=720x576:rate=25:duration=2,noise=alls=8:allf=t"; | 172 | let vsrc = "testsrc2=size=720x576:rate=25:duration=2,noise=alls=8:allf=t"; |
| 189 | let asrc = format!("sine=frequency=1000:sample_rate={ar}:duration=2"); | 173 | let asrc = format!("sine=frequency=1000:sample_rate={ar}:duration=2"); |
| 190 | - if !run(&["-f", "lavfi", "-i", vsrc, "-f", "lavfi", "-i", &asrc, "-ac", "2", "-frames:v", "6", "-c:v", "dvvideo", "-pix_fmt", f.pix_fmt, "-c:a", "pcm_s16le", "-ar", ar, "-shortest", "-f", "dv", p.to_str().unwrap()]) { | 174 | + assert!(run(&["-f", "lavfi", "-i", vsrc, "-f", "lavfi", "-i", &asrc, "-ac", "2", "-frames:v", "6", "-c:v", "dvvideo", "-pix_fmt", f.pix_fmt, "-c:a", "pcm_s16le", "-ar", ar, "-shortest", "-f", "dv", p.to_str().unwrap()]), "ffmpeg could not write {ar} Hz DV"); |
| 191 | - assert!(!require(), "ffmpeg could not write {ar} Hz DV"); | ||
| 192 | - continue; | ||
| 193 | - } | ||
| 194 | compare_audio(&p, ar.parse().unwrap()); | 175 | compare_audio(&p, ar.parse().unwrap()); |
| 195 | // flip the audio source pack to 12-bit non-linear and compare again | 176 | // flip the audio source pack to 12-bit non-linear and compare again |
| 196 | let mut data = std::fs::read(&p).unwrap(); | 177 | let mut data = std::fs::read(&p).unwrap(); |
crates/ec-dv/tests/ffmpeg_parity.rsmodified+0 -9
| @@ -67,9 +67,6 @@ macro_rules! flavour_test { | |||
| 67 | ($name:ident, $idx:expr) => { | 67 | ($name:ident, $idx:expr) => { |
| 68 | #[test] | 68 | #[test] |
| 69 | fn $name() { | 69 | fn $name() { |
| 70 | - if !ffmpeg_or_skip() { | ||
| 71 | - return; | ||
| 72 | - } | ||
| 73 | let f = &FLAVOURS[$idx]; | 70 | let f = &FLAVOURS[$idx]; |
| 74 | for (ilme, noise) in [(false, 0), (true, 6), (true, 25), (false, 40)] { | 71 | for (ilme, noise) in [(false, 0), (true, 6), (true, 25), (false, 40)] { |
| 75 | check_flavour(f, ilme, noise); | 72 | check_flavour(f, ilme, noise); |
| @@ -90,9 +87,6 @@ flavour_test!(hd_720p60, 8); | |||
| 90 | 87 | ||
| 91 | #[test] | 88 | #[test] |
| 92 | fn native_formats() { | 89 | fn native_formats() { |
| 93 | - if !ffmpeg_or_skip() { | ||
| 94 | - return; | ||
| 95 | - } | ||
| 96 | for (i, want) in [Chroma::Yuv411, Chroma::Yuv420, Chroma::Yuv411, Chroma::Yuv422, Chroma::Yuv422].into_iter().enumerate() { | 90 | for (i, want) in [Chroma::Yuv411, Chroma::Yuv420, Chroma::Yuv411, Chroma::Yuv422, Chroma::Yuv422].into_iter().enumerate() { |
| 97 | let f = &FLAVOURS[i]; | 91 | let f = &FLAVOURS[i]; |
| 98 | let path = make(f, "fmt", "dv", false, 5).unwrap(); | 92 | let path = make(f, "fmt", "dv", false, 5).unwrap(); |
| @@ -187,9 +181,6 @@ fn check_mutated(f: &Flavour, mode: u32, seed: u64) { | |||
| 187 | 181 | ||
| 188 | #[test] | 182 | #[test] |
| 189 | fn mutated_streams_match_ffmpeg() { | 183 | fn mutated_streams_match_ffmpeg() { |
| 190 | - if !ffmpeg_or_skip() { | ||
| 191 | - return; | ||
| 192 | - } | ||
| 193 | for f in FLAVOURS { | 184 | for f in FLAVOURS { |
| 194 | for mode in 0..5 { | 185 | for mode in 0..5 { |
| 195 | for seed in [1u64, 2, 3] { | 186 | for seed in [1u64, 2, 3] { |
crates/ec-dv/tests/perf.rsmodified+0 -3
| @@ -37,9 +37,6 @@ fn machine_is_busy() -> bool { | |||
| 37 | 37 | ||
| 38 | #[test] | 38 | #[test] |
| 39 | fn decode_speed() { | 39 | fn decode_speed() { |
| 40 | - if !ffmpeg_or_skip() { | ||
| 41 | - return; | ||
| 42 | - } | ||
| 43 | let mut bad = Vec::new(); | 40 | let mut bad = Vec::new(); |
| 44 | for f in FLAVOURS { | 41 | for f in FLAVOURS { |
| 45 | let hd = f.size.starts_with("1440") || f.size.starts_with("1280") || f.size.starts_with("960"); | 42 | let hd = f.size.starts_with("1440") || f.size.starts_with("1280") || f.size.starts_with("960"); |
crates/ec-mjpeg/Cargo.tomlmodified+1 -0
| @@ -11,5 +11,6 @@ ec-core = { workspace = true } | |||
| 11 | ec-image = { workspace = true } | 11 | ec-image = { workspace = true } |
| 12 | 12 | ||
| 13 | [dev-dependencies] | 13 | [dev-dependencies] |
| 14 | +ec-testkit.workspace = true | ||
| 14 | ec-mp4 = { workspace = true } | 15 | ec-mp4 = { workspace = true } |
| 15 | ec-matroska = { workspace = true } | 16 | ec-matroska = { workspace = true } |
crates/ec-mjpeg/tests/ffmpeg_parity.rsmodified+2 -46
| @@ -3,39 +3,16 @@ | |||
| 3 | //! | 3 | //! |
| 4 | //! All sources are synthetic: lavfi test patterns encoded by ffmpeg, and the Pillow-made JPEGs in | 4 | //! All sources are synthetic: lavfi test patterns encoded by ffmpeg, and the Pillow-made JPEGs in |
| 5 | //! `tests/data` (restart markers, progressive). Expected pixels are never stored; ffmpeg is the | 5 | //! `tests/data` (restart markers, progressive). Expected pixels are never stored; ffmpeg is the |
| 6 | -//! oracle at run time. Without ffmpeg the tests skip, unless `EC_REQUIRE_FIXTURES` is set. | 6 | +//! oracle at run time. |
| 7 | 7 | ||
| 8 | use std::io::BufReader; | 8 | use std::io::BufReader; |
| 9 | use std::path::{Path, PathBuf}; | 9 | use std::path::{Path, PathBuf}; |
| 10 | -use std::process::Command; | ||
| 11 | 10 | ||
| 12 | use ec_core::frame::{Interlace, PixelFormat, VideoFrame}; | 11 | use ec_core::frame::{Interlace, PixelFormat, VideoFrame}; |
| 13 | use ec_core::registry::{CodecId, CodecParameters, Demuxer, MediaParameters}; | 12 | use ec_core::registry::{CodecId, CodecParameters, Demuxer, MediaParameters}; |
| 14 | use ec_image::Limits; | 13 | use ec_image::Limits; |
| 15 | use ec_mjpeg::MjpegDecoder; | 14 | use ec_mjpeg::MjpegDecoder; |
| 16 | 15 | ||
| 17 | -fn require() -> bool { | ||
| 18 | - std::env::var_os("EC_REQUIRE_FIXTURES").is_some() | ||
| 19 | -} | ||
| 20 | - | ||
| 21 | -fn have_ffmpeg() -> bool { | ||
| 22 | - Command::new("ffmpeg") | ||
| 23 | - .arg("-version") | ||
| 24 | - .output() | ||
| 25 | - .map(|o| o.status.success()) | ||
| 26 | - .unwrap_or(false) | ||
| 27 | -} | ||
| 28 | - | ||
| 29 | -/// False (after saying so) when the oracle is missing and fixtures are optional. | ||
| 30 | -fn oracle() -> bool { | ||
| 31 | - if have_ffmpeg() { | ||
| 32 | - return true; | ||
| 33 | - } | ||
| 34 | - assert!(!require(), "ffmpeg missing and EC_REQUIRE_FIXTURES is set"); | ||
| 35 | - eprintln!("SKIP: no ffmpeg"); | ||
| 36 | - false | ||
| 37 | -} | ||
| 38 | - | ||
| 39 | fn scratch(tag: &str) -> PathBuf { | 16 | fn scratch(tag: &str) -> PathBuf { |
| 40 | let base = std::env::var_os("TMPDIR") | 17 | let base = std::env::var_os("TMPDIR") |
| 41 | .map(PathBuf::from) | 18 | .map(PathBuf::from) |
| @@ -46,7 +23,7 @@ fn scratch(tag: &str) -> PathBuf { | |||
| 46 | } | 23 | } |
| 47 | 24 | ||
| 48 | fn ffmpeg(args: &[&str]) { | 25 | fn ffmpeg(args: &[&str]) { |
| 49 | - let ok = Command::new("ffmpeg") | 26 | + let ok = ec_testkit::ffmpeg() |
| 50 | .args(["-v", "error", "-y", "-nostdin"]) | 27 | .args(["-v", "error", "-y", "-nostdin"]) |
| 51 | .args(args) | 28 | .args(args) |
| 52 | .status() | 29 | .status() |
| @@ -155,9 +132,6 @@ fn format_name(f: PixelFormat) -> &'static str { | |||
| 155 | 132 | ||
| 156 | #[test] | 133 | #[test] |
| 157 | fn still_fixtures_match_ffmpeg() { | 134 | fn still_fixtures_match_ffmpeg() { |
| 158 | - if !oracle() { | ||
| 159 | - return; | ||
| 160 | - } | ||
| 161 | let dir = Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/data"); | 135 | let dir = Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/data"); |
| 162 | let work = scratch("stills"); | 136 | let work = scratch("stills"); |
| 163 | let mut n = 0; | 137 | let mut n = 0; |
| @@ -186,9 +160,6 @@ fn still_fixtures_match_ffmpeg() { | |||
| 186 | /// into mov and mkv by a stream copy. | 160 | /// into mov and mkv by a stream copy. |
| 187 | #[test] | 161 | #[test] |
| 188 | fn gray_video_matches_ffmpeg() { | 162 | fn gray_video_matches_ffmpeg() { |
| 189 | - if !oracle() { | ||
| 190 | - return; | ||
| 191 | - } | ||
| 192 | let work = scratch("gray"); | 163 | let work = scratch("gray"); |
| 193 | for name in ["basegray", "rstgray", "proggray"] { | 164 | for name in ["basegray", "rstgray", "proggray"] { |
| 194 | let jpg = Path::new(env!("CARGO_MANIFEST_DIR")).join(format!("tests/data/{name}.jpg")); | 165 | let jpg = Path::new(env!("CARGO_MANIFEST_DIR")).join(format!("tests/data/{name}.jpg")); |
| @@ -215,9 +186,6 @@ fn gray_video_matches_ffmpeg() { | |||
| 215 | 186 | ||
| 216 | #[test] | 187 | #[test] |
| 217 | fn video_matrix_matches_ffmpeg() { | 188 | fn video_matrix_matches_ffmpeg() { |
| 218 | - if !oracle() { | ||
| 219 | - return; | ||
| 220 | - } | ||
| 221 | let work = scratch("matrix"); | 189 | let work = scratch("matrix"); |
| 222 | let mut cases = 0; | 190 | let mut cases = 0; |
| 223 | for (pix, expect) in [ | 191 | for (pix, expect) in [ |
| @@ -372,9 +340,6 @@ fn write_avi(path: &Path, w: u32, h: u32, packets: &[Vec<u8>]) { | |||
| 372 | 340 | ||
| 373 | #[test] | 341 | #[test] |
| 374 | fn avi1_packets_without_dht_use_the_default_tables() { | 342 | fn avi1_packets_without_dht_use_the_default_tables() { |
| 375 | - if !oracle() { | ||
| 376 | - return; | ||
| 377 | - } | ||
| 378 | let work = scratch("nodht"); | 343 | let work = scratch("nodht"); |
| 379 | for (pix, size) in [ | 344 | for (pix, size) in [ |
| 380 | ("yuvj420p", "64x48"), | 345 | ("yuvj420p", "64x48"), |
| @@ -430,9 +395,6 @@ fn avi1_packets_without_dht_use_the_default_tables() { | |||
| 430 | 395 | ||
| 431 | #[test] | 396 | #[test] |
| 432 | fn two_field_packets_weave_like_ffmpeg() { | 397 | fn two_field_packets_weave_like_ffmpeg() { |
| 433 | - if !oracle() { | ||
| 434 | - return; | ||
| 435 | - } | ||
| 436 | let work = scratch("fields"); | 398 | let work = scratch("fields"); |
| 437 | // ffmpeg's mjpeg encoder refuses `-flags +ildct` ("interlacing not supported by codec"), | 399 | // ffmpeg's mjpeg encoder refuses `-flags +ildct` ("interlacing not supported by codec"), |
| 438 | // so the interlaced material is built from separated fields, one JPEG per field. | 400 | // so the interlaced material is built from separated fields, one JPEG per field. |
| @@ -755,9 +717,6 @@ fn mjpeg_stream_packets(path: &Path) -> Vec<Vec<u8>> { | |||
| 755 | 717 | ||
| 756 | #[test] | 718 | #[test] |
| 757 | fn mjpegb_matches_ffmpeg() { | 719 | fn mjpegb_matches_ffmpeg() { |
| 758 | - if !oracle() { | ||
| 759 | - return; | ||
| 760 | - } | ||
| 761 | let work = scratch("mjpegb"); | 720 | let work = scratch("mjpegb"); |
| 762 | // Progressive: one field per packet, all three layouts, odd sizes. | 721 | // Progressive: one field per packet, all three layouts, odd sizes. |
| 763 | for (pix, size, w, h, q) in [ | 722 | for (pix, size, w, h, q) in [ |
| @@ -805,9 +764,6 @@ fn mjpegb_matches_ffmpeg() { | |||
| 805 | 764 | ||
| 806 | #[test] | 765 | #[test] |
| 807 | fn mjpegb_two_fields_match_ffmpeg() { | 766 | fn mjpegb_two_fields_match_ffmpeg() { |
| 808 | - if !oracle() { | ||
| 809 | - return; | ||
| 810 | - } | ||
| 811 | let work = scratch("mjpegb2"); | 767 | let work = scratch("mjpegb2"); |
| 812 | for (pix, size, w, h) in [ | 768 | for (pix, size, w, h) in [ |
| 813 | ("yuvj420p", "64x48", 64u16, 48u16), | 769 | ("yuvj420p", "64x48", 64u16, 48u16), |
crates/ec-mpeg2/Cargo.tomlmodified+3 -0
| @@ -8,3 +8,6 @@ authors.workspace = true | |||
| 8 | 8 | ||
| 9 | [dependencies] | 9 | [dependencies] |
| 10 | ec-core = { workspace = true } | 10 | ec-core = { workspace = true } |
| 11 | + | ||
| 12 | +[dev-dependencies] | ||
| 13 | +ec-testkit.workspace = true | ||
crates/ec-mpeg2/tests/common/mod.rsmodified+1 -14
| @@ -4,23 +4,10 @@ | |||
| 4 | pub mod synth; | 4 | pub mod synth; |
| 5 | 5 | ||
| 6 | use std::path::{Path, PathBuf}; | 6 | use std::path::{Path, PathBuf}; |
| 7 | -use std::process::Command; | ||
| 8 | 7 | ||
| 9 | use ec_core::frame::VideoFrame; | 8 | use ec_core::frame::VideoFrame; |
| 10 | use ec_mpeg2::Mpeg2Decoder; | 9 | use ec_mpeg2::Mpeg2Decoder; |
| 11 | 10 | ||
| 12 | -pub fn require() -> bool { | ||
| 13 | - std::env::var_os("EC_REQUIRE_FIXTURES").is_some() | ||
| 14 | -} | ||
| 15 | - | ||
| 16 | -pub fn have_ffmpeg() -> bool { | ||
| 17 | - Command::new("ffmpeg") | ||
| 18 | - .arg("-version") | ||
| 19 | - .output() | ||
| 20 | - .map(|o| o.status.success()) | ||
| 21 | - .unwrap_or(false) | ||
| 22 | -} | ||
| 23 | - | ||
| 24 | pub fn scratch(tag: &str) -> PathBuf { | 11 | pub fn scratch(tag: &str) -> PathBuf { |
| 25 | let base = std::env::var_os("TMPDIR") | 12 | let base = std::env::var_os("TMPDIR") |
| 26 | .map(PathBuf::from) | 13 | .map(PathBuf::from) |
| @@ -31,7 +18,7 @@ pub fn scratch(tag: &str) -> PathBuf { | |||
| 31 | } | 18 | } |
| 32 | 19 | ||
| 33 | pub fn run(args: &[&str]) -> bool { | 20 | pub fn run(args: &[&str]) -> bool { |
| 34 | - Command::new("ffmpeg") | 21 | + ec_testkit::ffmpeg() |
| 35 | .args(["-v", "error", "-y", "-nostdin"]) | 22 | .args(["-v", "error", "-y", "-nostdin"]) |
| 36 | .args(args) | 23 | .args(args) |
| 37 | .status() | 24 | .status() |
crates/ec-mpeg2/tests/ffmpeg_parity.rsmodified+1 -10
| @@ -65,22 +65,13 @@ fn generate(c: &Case) -> Option<std::path::PathBuf> { | |||
| 65 | 65 | ||
| 66 | #[test] | 66 | #[test] |
| 67 | fn parity_matrix() { | 67 | fn parity_matrix() { |
| 68 | - if !have_ffmpeg() { | ||
| 69 | - assert!(!require(), "ffmpeg missing"); | ||
| 70 | - eprintln!("SKIP: no ffmpeg"); | ||
| 71 | - return; | ||
| 72 | - } | ||
| 73 | let only = std::env::var("EC_MPEG2_CASE").ok(); | 68 | let only = std::env::var("EC_MPEG2_CASE").ok(); |
| 74 | let mut failures = Vec::new(); | 69 | let mut failures = Vec::new(); |
| 75 | for c in CASES { | 70 | for c in CASES { |
| 76 | if only.as_deref().is_some_and(|o| o != c.tag) { | 71 | if only.as_deref().is_some_and(|o| o != c.tag) { |
| 77 | continue; | 72 | continue; |
| 78 | } | 73 | } |
| 79 | - let Some(es) = generate(c) else { | 74 | + let es = generate(c).unwrap_or_else(|| panic!("{}: ffmpeg cannot encode", c.tag)); |
| 80 | - assert!(!require(), "{}: ffmpeg cannot encode", c.tag); | ||
| 81 | - eprintln!("SKIP {}", c.tag); | ||
| 82 | - continue; | ||
| 83 | - }; | ||
| 84 | match compare(c.tag, &es, c.pix, &[]) { | 75 | match compare(c.tag, &es, c.pix, &[]) { |
| 85 | Ok(n) => eprintln!("OK {} ({n} frames)", c.tag), | 76 | Ok(n) => eprintln!("OK {} ({n} frames)", c.tag), |
| 86 | Err(e) => { | 77 | Err(e) => { |
crates/ec-mpeg2/tests/synth_parity.rsmodified+0 -5
| @@ -16,11 +16,6 @@ fn run_one(tag: &str, cfg: &SynthCfg, pix: &str) -> Result<usize, String> { | |||
| 16 | 16 | ||
| 17 | #[test] | 17 | #[test] |
| 18 | fn synthetic_streams_match_ffmpeg() { | 18 | fn synthetic_streams_match_ffmpeg() { |
| 19 | - if !have_ffmpeg() { | ||
| 20 | - assert!(!require(), "ffmpeg missing"); | ||
| 21 | - eprintln!("SKIP: no ffmpeg"); | ||
| 22 | - return; | ||
| 23 | - } | ||
| 24 | let n: u64 = std::env::var("EC_SYNTH_N").ok().and_then(|v| v.parse().ok()).unwrap_or(24); | 19 | let n: u64 = std::env::var("EC_SYNTH_N").ok().and_then(|v| v.parse().ok()).unwrap_or(24); |
| 25 | let base: u64 = std::env::var("EC_SYNTH_SEED").ok().and_then(|v| v.parse().ok()).unwrap_or(1); | 20 | let base: u64 = std::env::var("EC_SYNTH_SEED").ok().and_then(|v| v.parse().ok()).unwrap_or(1); |
| 26 | let heavy = std::env::var_os("EC_SYNTH_LIGHT").is_none(); | 21 | let heavy = std::env::var_os("EC_SYNTH_LIGHT").is_none(); |
crates/ec-mpeg4/Cargo.tomlmodified+1 -0
| @@ -10,6 +10,7 @@ authors.workspace = true | |||
| 10 | ec-core = { workspace = true } | 10 | ec-core = { workspace = true } |
| 11 | 11 | ||
| 12 | [dev-dependencies] | 12 | [dev-dependencies] |
| 13 | +ec-testkit.workspace = true | ||
| 13 | ec-mp4 = { workspace = true } | 14 | ec-mp4 = { workspace = true } |
| 14 | ec-riff = { workspace = true } | 15 | ec-riff = { workspace = true } |
| 15 | ec-matroska = { workspace = true } | 16 | ec-matroska = { workspace = true } |
crates/ec-mpeg4/tests/common/mod.rsmodified+1 -40
| @@ -8,50 +8,11 @@ | |||
| 8 | #![allow(dead_code)] | 8 | #![allow(dead_code)] |
| 9 | 9 | ||
| 10 | use std::path::{Path, PathBuf}; | 10 | use std::path::{Path, PathBuf}; |
| 11 | -use std::process::Command; | ||
| 12 | 11 | ||
| 13 | use ec_core::frame::VideoFrame; | 12 | use ec_core::frame::VideoFrame; |
| 14 | use ec_core::registry::{CodecId, CodecParameters}; | 13 | use ec_core::registry::{CodecId, CodecParameters}; |
| 15 | use ec_mpeg4::{Mpeg4Decoder, PictureInfo}; | 14 | use ec_mpeg4::{Mpeg4Decoder, PictureInfo}; |
| 16 | 15 | ||
| 17 | -pub fn require() -> bool { | ||
| 18 | - std::env::var_os("EC_REQUIRE_FIXTURES").is_some() | ||
| 19 | -} | ||
| 20 | - | ||
| 21 | -pub fn have_ffmpeg() -> bool { | ||
| 22 | - Command::new("ffmpeg") | ||
| 23 | - .arg("-version") | ||
| 24 | - .output() | ||
| 25 | - .map(|o| o.status.success()) | ||
| 26 | - .unwrap_or(false) | ||
| 27 | -} | ||
| 28 | - | ||
| 29 | -/// Whether the local ffmpeg lists `name` as an encoder. | ||
| 30 | -pub fn have_encoder(name: &str) -> bool { | ||
| 31 | - Command::new("ffmpeg") | ||
| 32 | - .args(["-hide_banner", "-encoders"]) | ||
| 33 | - .output() | ||
| 34 | - .map(|o| { | ||
| 35 | - String::from_utf8_lossy(&o.stdout) | ||
| 36 | - .lines() | ||
| 37 | - .any(|l| l.split_whitespace().nth(1) == Some(name)) | ||
| 38 | - }) | ||
| 39 | - .unwrap_or(false) | ||
| 40 | -} | ||
| 41 | - | ||
| 42 | -/// `true` when the test may run; under `EC_REQUIRE_FIXTURES` a missing ffmpeg is a failure. | ||
| 43 | -pub fn gate() -> bool { | ||
| 44 | - if have_ffmpeg() { | ||
| 45 | - return true; | ||
| 46 | - } | ||
| 47 | - assert!( | ||
| 48 | - !require(), | ||
| 49 | - "ffmpeg is required (EC_REQUIRE_FIXTURES is set)" | ||
| 50 | - ); | ||
| 51 | - eprintln!("skipped: no ffmpeg"); | ||
| 52 | - false | ||
| 53 | -} | ||
| 54 | - | ||
| 55 | pub fn scratch(tag: &str) -> PathBuf { | 16 | pub fn scratch(tag: &str) -> PathBuf { |
| 56 | let base = std::env::var_os("TMPDIR") | 17 | let base = std::env::var_os("TMPDIR") |
| 57 | .map(PathBuf::from) | 18 | .map(PathBuf::from) |
| @@ -62,7 +23,7 @@ pub fn scratch(tag: &str) -> PathBuf { | |||
| 62 | } | 23 | } |
| 63 | 24 | ||
| 64 | pub fn run(args: &[&str]) -> bool { | 25 | pub fn run(args: &[&str]) -> bool { |
| 65 | - Command::new("ffmpeg") | 26 | + ec_testkit::ffmpeg() |
| 66 | .args(["-v", "error", "-y", "-nostdin"]) | 27 | .args(["-v", "error", "-y", "-nostdin"]) |
| 67 | .args(args) | 28 | .args(args) |
| 68 | .status() | 29 | .status() |
crates/ec-mpeg4/tests/containers.rsmodified+2 -23
| @@ -69,9 +69,6 @@ fn decode_registry(params: ec_core::registry::CodecParameters, pk: &[Packet]) -> | |||
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | fn check(tag: &str, file: &str, enc: &[&str]) { | 71 | fn check(tag: &str, file: &str, enc: &[&str]) { |
| 72 | - if !gate() { | ||
| 73 | - return; | ||
| 74 | - } | ||
| 75 | let dir = scratch(tag); | 72 | let dir = scratch(tag); |
| 76 | let path = dir.join(file); | 73 | let path = dir.join(file); |
| 77 | assert!(encode("176x144", 30, enc, &path), "encode"); | 74 | assert!(encode("176x144", 30, enc, &path), "encode"); |
| @@ -179,9 +176,6 @@ fn mkv_asp() { | |||
| 179 | } | 176 | } |
| 180 | #[test] | 177 | #[test] |
| 181 | fn gp3_h263() { | 178 | fn gp3_h263() { |
| 182 | - if !gate() { | ||
| 183 | - return; | ||
| 184 | - } | ||
| 185 | let dir = scratch("3gp"); | 179 | let dir = scratch("3gp"); |
| 186 | let path = dir.join("a.3gp"); | 180 | let path = dir.join("a.3gp"); |
| 187 | assert!(encode( | 181 | assert!(encode( |
| @@ -205,9 +199,6 @@ fn gp3_h263() { | |||
| 205 | /// where it was. | 199 | /// where it was. |
| 206 | #[test] | 200 | #[test] |
| 207 | fn packed_bitstream_matches_unpacked() { | 201 | fn packed_bitstream_matches_unpacked() { |
| 208 | - if !gate() { | ||
| 209 | - return; | ||
| 210 | - } | ||
| 211 | let dir = scratch("packed"); | 202 | let dir = scratch("packed"); |
| 212 | let path = dir.join("a.avi"); | 203 | let path = dir.join("a.avi"); |
| 213 | assert!(encode( | 204 | assert!(encode( |
| @@ -246,12 +237,9 @@ fn packed_bitstream_matches_unpacked() { | |||
| 246 | 237 | ||
| 247 | #[test] | 238 | #[test] |
| 248 | fn data_partitioning_is_refused_by_name() { | 239 | fn data_partitioning_is_refused_by_name() { |
| 249 | - if !gate() { | ||
| 250 | - return; | ||
| 251 | - } | ||
| 252 | let dir = scratch("dp"); | 240 | let dir = scratch("dp"); |
| 253 | let path = dir.join("a.m4v"); | 241 | let path = dir.join("a.m4v"); |
| 254 | - if !encode( | 242 | + assert!(encode( |
| 255 | "176x144", | 243 | "176x144", |
| 256 | 4, | 244 | 4, |
| 257 | &[ | 245 | &[ |
| @@ -265,10 +253,7 @@ fn data_partitioning_is_refused_by_name() { | |||
| 265 | "m4v", | 253 | "m4v", |
| 266 | ], | 254 | ], |
| 267 | &path, | 255 | &path, |
| 268 | - ) { | 256 | + ), "encoder rejects data partitioning"); |
| 269 | - eprintln!("SKIP: encoder rejects data partitioning"); | ||
| 270 | - return; | ||
| 271 | - } | ||
| 272 | let es = std::fs::read(&path).unwrap(); | 257 | let es = std::fs::read(&path).unwrap(); |
| 273 | let mut dec = new_decoder(); | 258 | let mut dec = new_decoder(); |
| 274 | let mut err = None; | 259 | let mut err = None; |
| @@ -288,9 +273,6 @@ fn data_partitioning_is_refused_by_name() { | |||
| 288 | 273 | ||
| 289 | #[test] | 274 | #[test] |
| 290 | fn corrupt_input_does_not_panic() { | 275 | fn corrupt_input_does_not_panic() { |
| 291 | - if !gate() { | ||
| 292 | - return; | ||
| 293 | - } | ||
| 294 | let dir = scratch("corrupt"); | 276 | let dir = scratch("corrupt"); |
| 295 | let path = dir.join("a.m4v"); | 277 | let path = dir.join("a.m4v"); |
| 296 | assert!(encode( | 278 | assert!(encode( |
| @@ -349,9 +331,6 @@ fn corrupt_input_does_not_panic() { | |||
| 349 | #[test] | 331 | #[test] |
| 350 | #[ignore] | 332 | #[ignore] |
| 351 | fn speed_720p_at_least_120_fps() { | 333 | fn speed_720p_at_least_120_fps() { |
| 352 | - if !gate() { | ||
| 353 | - return; | ||
| 354 | - } | ||
| 355 | let dir = scratch("speed"); | 334 | let dir = scratch("speed"); |
| 356 | let path = dir.join("hd.m4v"); | 335 | let path = dir.join("hd.m4v"); |
| 357 | assert!(encode( | 336 | assert!(encode( |
crates/ec-mpeg4/tests/ffmpeg_parity.rsmodified+1 -21
| @@ -1,6 +1,5 @@ | |||
| 1 | //! Byte-exact parity with ffmpeg's MPEG-4 Part 2 / H.263 decoder on streams ffmpeg encodes at test | 1 | //! Byte-exact parity with ffmpeg's MPEG-4 Part 2 / H.263 decoder on streams ffmpeg encodes at test |
| 2 | -//! time (`ffmpeg -c:v mpeg4`, `libxvid`, `h263`). Skipped without ffmpeg unless `EC_REQUIRE_FIXTURES` | 2 | +//! time (`ffmpeg -c:v mpeg4`, `libxvid`, `h263`). |
| 3 | -//! is set; the libxvid cases (GMC, N-VOPs, XviD IDCT) also skip when the encoder is not built in. | ||
| 4 | 3 | ||
| 5 | mod common; | 4 | mod common; |
| 6 | 5 | ||
| @@ -10,9 +9,6 @@ macro_rules! parity { | |||
| 10 | ($name:ident, $size:expr, $frames:expr, [$($arg:expr),* $(,)?]) => { | 9 | ($name:ident, $size:expr, $frames:expr, [$($arg:expr),* $(,)?]) => { |
| 11 | #[test] | 10 | #[test] |
| 12 | fn $name() { | 11 | fn $name() { |
| 13 | - if !gate() { | ||
| 14 | - return; | ||
| 15 | - } | ||
| 16 | let n = parity_es(stringify!($name), $size, $frames, &[$($arg),*], "m4v").unwrap(); | 12 | let n = parity_es(stringify!($name), $size, $frames, &[$($arg),*], "m4v").unwrap(); |
| 17 | assert!(n >= $frames - 2, "decoded only {n} of {} pictures", $frames); | 13 | assert!(n >= $frames - 2, "decoded only {n} of {} pictures", $frames); |
| 18 | } | 14 | } |
| @@ -295,9 +291,6 @@ parity!( | |||
| 295 | 291 | ||
| 296 | #[test] | 292 | #[test] |
| 297 | fn hd_720p_with_everything() { | 293 | fn hd_720p_with_everything() { |
| 298 | - if !gate() { | ||
| 299 | - return; | ||
| 300 | - } | ||
| 301 | let n = parity_es( | 294 | let n = parity_es( |
| 302 | "hd720", | 295 | "hd720", |
| 303 | "1280x720", | 296 | "1280x720", |
| @@ -321,9 +314,6 @@ fn hd_720p_with_everything() { | |||
| 321 | // H.263 baseline (short video header). | 314 | // H.263 baseline (short video header). |
| 322 | #[test] | 315 | #[test] |
| 323 | fn h263_formats() { | 316 | fn h263_formats() { |
| 324 | - if !gate() { | ||
| 325 | - return; | ||
| 326 | - } | ||
| 327 | for (size, q, gop) in [ | 317 | for (size, q, gop) in [ |
| 328 | ("128x96", "4", "8"), | 318 | ("128x96", "4", "8"), |
| 329 | ("176x144", "4", "10"), | 319 | ("176x144", "4", "10"), |
| @@ -346,9 +336,6 @@ fn h263_formats() { | |||
| 346 | 336 | ||
| 347 | #[test] | 337 | #[test] |
| 348 | fn h263_with_gob_headers() { | 338 | fn h263_with_gob_headers() { |
| 349 | - if !gate() { | ||
| 350 | - return; | ||
| 351 | - } | ||
| 352 | // `-ps` makes ffmpeg's H.263 encoder start a GOB (with its header) every n macroblocks. | 339 | // `-ps` makes ffmpeg's H.263 encoder start a GOB (with its header) every n macroblocks. |
| 353 | let n = parity_es( | 340 | let n = parity_es( |
| 354 | "h263_gob", | 341 | "h263_gob", |
| @@ -363,13 +350,6 @@ fn h263_with_gob_headers() { | |||
| 363 | 350 | ||
| 364 | // libxvid: GMC with warp points, N-VOPs, the XviD IDCT and XviD's qpel/bframe habits. | 351 | // libxvid: GMC with warp points, N-VOPs, the XviD IDCT and XviD's qpel/bframe habits. |
| 365 | fn libxvid(tag: &str, size: &str, frames: u32, extra: &[&str]) { | 352 | fn libxvid(tag: &str, size: &str, frames: u32, extra: &[&str]) { |
| 366 | - if !gate() { | ||
| 367 | - return; | ||
| 368 | - } | ||
| 369 | - if !have_encoder("libxvid") { | ||
| 370 | - eprintln!("skipped {tag}: ffmpeg has no libxvid encoder"); | ||
| 371 | - return; | ||
| 372 | - } | ||
| 373 | let mut enc = vec!["-c:v", "libxvid"]; | 353 | let mut enc = vec!["-c:v", "libxvid"]; |
| 374 | enc.extend_from_slice(extra); | 354 | enc.extend_from_slice(extra); |
| 375 | let n = parity_es(tag, size, frames, &enc, "m4v").unwrap_or_else(|e| panic!("{tag}: {e}")); | 355 | let n = parity_es(tag, size, frames, &enc, "m4v").unwrap_or_else(|e| panic!("{tag}: {e}")); |
crates/ec-mpeg4/tests/msmpeg4.rsmodified+0 -8
| @@ -12,14 +12,6 @@ use ec_mpeg4::Mpeg4Decoder; | |||
| 12 | 12 | ||
| 13 | #[allow(clippy::too_many_arguments)] | 13 | #[allow(clippy::too_many_arguments)] |
| 14 | fn check(tag: &str, vtag: &str, codec: &str, id: CodecId, lavfi: &str, size: &str, frames: u32, enc: &[&str]) { | 14 | fn check(tag: &str, vtag: &str, codec: &str, id: CodecId, lavfi: &str, size: &str, frames: u32, enc: &[&str]) { |
| 15 | - if !gate() { | ||
| 16 | - return; | ||
| 17 | - } | ||
| 18 | - if !have_encoder(codec) { | ||
| 19 | - assert!(!require(), "ffmpeg encoder {codec} missing"); | ||
| 20 | - eprintln!("skipped: no {codec} encoder"); | ||
| 21 | - return; | ||
| 22 | - } | ||
| 23 | let dir = scratch(tag); | 15 | let dir = scratch(tag); |
| 24 | let path = dir.join(format!("{tag}.avi")); | 16 | let path = dir.join(format!("{tag}.avi")); |
| 25 | let input = format!("{lavfi}=size={size}:rate=25"); | 17 | let input = format!("{lavfi}=size={size}:rate=25"); |
crates/ec-prores/Cargo.tomlmodified+1 -0
| @@ -13,4 +13,5 @@ bytemuck = "1" | |||
| 13 | wide = { workspace = true } | 13 | wide = { workspace = true } |
| 14 | 14 | ||
| 15 | [dev-dependencies] | 15 | [dev-dependencies] |
| 16 | +ec-testkit.workspace = true | ||
| 16 | ec-mp4 = { workspace = true } | 17 | ec-mp4 = { workspace = true } |
crates/ec-prores/tests/common/mod.rsmodified+1 -24
| @@ -3,34 +3,11 @@ | |||
| 3 | 3 | ||
| 4 | use std::io::Cursor; | 4 | use std::io::Cursor; |
| 5 | use std::path::PathBuf; | 5 | use std::path::PathBuf; |
| 6 | -use std::process::Command; | ||
| 7 | 6 | ||
| 8 | use ec_core::registry::{CodecId, CodecParameters, Demuxer}; | 7 | use ec_core::registry::{CodecId, CodecParameters, Demuxer}; |
| 9 | use ec_mp4::Mp4Demuxer; | 8 | use ec_mp4::Mp4Demuxer; |
| 10 | use ec_prores::{DecodedFrame, ProResDecoder}; | 9 | use ec_prores::{DecodedFrame, ProResDecoder}; |
| 11 | 10 | ||
| 12 | -pub fn require() -> bool { | ||
| 13 | - std::env::var_os("EC_REQUIRE_FIXTURES").is_some() | ||
| 14 | -} | ||
| 15 | - | ||
| 16 | -pub fn have_ffmpeg() -> bool { | ||
| 17 | - Command::new("ffmpeg") | ||
| 18 | - .arg("-version") | ||
| 19 | - .output() | ||
| 20 | - .map(|o| o.status.success()) | ||
| 21 | - .unwrap_or(false) | ||
| 22 | -} | ||
| 23 | - | ||
| 24 | -/// Skip (or fail under EC_REQUIRE_FIXTURES) when ffmpeg is missing. | ||
| 25 | -pub fn ffmpeg_or_skip() -> bool { | ||
| 26 | - if have_ffmpeg() { | ||
| 27 | - return true; | ||
| 28 | - } | ||
| 29 | - assert!(!require(), "EC_REQUIRE_FIXTURES set but ffmpeg is not available"); | ||
| 30 | - eprintln!("skipping: no ffmpeg"); | ||
| 31 | - false | ||
| 32 | -} | ||
| 33 | - | ||
| 34 | pub fn scratch(tag: &str) -> PathBuf { | 11 | pub fn scratch(tag: &str) -> PathBuf { |
| 35 | let base = std::env::var_os("TMPDIR").map(PathBuf::from).unwrap_or_else(std::env::temp_dir); | 12 | let base = std::env::var_os("TMPDIR").map(PathBuf::from).unwrap_or_else(std::env::temp_dir); |
| 36 | let dir = base.join(format!("ec-prores-{}-{}", std::process::id(), tag)); | 13 | let dir = base.join(format!("ec-prores-{}-{}", std::process::id(), tag)); |
| @@ -39,7 +16,7 @@ pub fn scratch(tag: &str) -> PathBuf { | |||
| 39 | } | 16 | } |
| 40 | 17 | ||
| 41 | pub fn run(args: &[&str]) -> bool { | 18 | pub fn run(args: &[&str]) -> bool { |
| 42 | - Command::new("ffmpeg") | 19 | + ec_testkit::ffmpeg() |
| 43 | .args(["-v", "error", "-y", "-nostdin"]) | 20 | .args(["-v", "error", "-y", "-nostdin"]) |
| 44 | .args(args) | 21 | .args(args) |
| 45 | .status() | 22 | .status() |
crates/ec-prores/tests/encode.rsmodified+4 -27
| @@ -1,11 +1,9 @@ | |||
| 1 | //! The ProRes encoder: ffmpeg decodes what we write exactly as ec-prores does, frame sizes sit on | 1 | //! The ProRes encoder: ffmpeg decodes what we write exactly as ec-prores does, frame sizes sit on |
| 2 | //! Apple's rates, quality matches or beats ffmpeg's `prores_ks`, the .mov probes right. | 2 | //! Apple's rates, quality matches or beats ffmpeg's `prores_ks`, the .mov probes right. |
| 3 | -//! All media is synthetic; ffmpeg-dependent tests skip (or fail under `EC_REQUIRE_FIXTURES`) | 3 | +//! All media is synthetic. |
| 4 | -//! when ffmpeg is missing. | ||
| 5 | 4 | ||
| 6 | mod common; | 5 | mod common; |
| 7 | use std::io::Cursor; | 6 | use std::io::Cursor; |
| 8 | -use std::process::Command; | ||
| 9 | 7 | ||
| 10 | use common::*; | 8 | use common::*; |
| 11 | use ec_core::frame::{ColorInfo, PixelFormat, Plane, VideoFrame}; | 9 | use ec_core::frame::{ColorInfo, PixelFormat, Plane, VideoFrame}; |
| @@ -135,9 +133,6 @@ fn pix(p: Profile) -> &'static str { | |||
| 135 | 133 | ||
| 136 | #[test] | 134 | #[test] |
| 137 | fn ffmpeg_and_ec_prores_decode_every_profile_identically() { | 135 | fn ffmpeg_and_ec_prores_decode_every_profile_identically() { |
| 138 | - if !ffmpeg_or_skip() { | ||
| 139 | - return; | ||
| 140 | - } | ||
| 141 | let dir = scratch("enc-rt"); | 136 | let dir = scratch("enc-rt"); |
| 142 | for (i, p) in ALL.into_iter().enumerate() { | 137 | for (i, p) in ALL.into_iter().enumerate() { |
| 143 | // Odd size: padding macroblocks on both axes, 3 slice widths in a row. | 138 | // Odd size: padding macroblocks on both axes, 3 slice widths in a row. |
| @@ -223,9 +218,6 @@ fn frame_sizes_sit_on_apples_rates() { | |||
| 223 | 218 | ||
| 224 | #[test] | 219 | #[test] |
| 225 | fn encoder_trait_and_mov_probe() { | 220 | fn encoder_trait_and_mov_probe() { |
| 226 | - if !ffmpeg_or_skip() { | ||
| 227 | - return; | ||
| 228 | - } | ||
| 229 | let dir = scratch("enc-probe"); | 221 | let dir = scratch("enc-probe"); |
| 230 | let (w, h) = (192, 108); | 222 | let (w, h) = (192, 108); |
| 231 | for p in ALL { | 223 | for p in ALL { |
| @@ -249,7 +241,7 @@ fn encoder_trait_and_mov_probe() { | |||
| 249 | assert!(!mov.windows(4).any(|x| x == b"avcC" || x == b"esds"), "{p:?}: a config box"); | 241 | assert!(!mov.windows(4).any(|x| x == b"avcC" || x == b"esds"), "{p:?}: a config box"); |
| 250 | let path = dir.join(format!("{}.mov", String::from_utf8_lossy(&p.fourcc()))); | 242 | let path = dir.join(format!("{}.mov", String::from_utf8_lossy(&p.fourcc()))); |
| 251 | std::fs::write(&path, &mov).unwrap(); | 243 | std::fs::write(&path, &mov).unwrap(); |
| 252 | - let out = Command::new("ffprobe") | 244 | + let out = ec_testkit::ffprobe() |
| 253 | .args(["-v", "error", "-select_streams", "v:0", "-show_entries"]) | 245 | .args(["-v", "error", "-select_streams", "v:0", "-show_entries"]) |
| 254 | .arg("stream=codec_name,profile,pix_fmt,field_order,color_space,color_transfer,color_primaries,codec_tag_string,width,height,nb_frames") | 246 | .arg("stream=codec_name,profile,pix_fmt,field_order,color_space,color_transfer,color_primaries,codec_tag_string,width,height,nb_frames") |
| 255 | .args(["-of", "default=nw=1"]) | 247 | .args(["-of", "default=nw=1"]) |
| @@ -336,25 +328,16 @@ fn psnr_vs_prores_ks(generator: &str, post: &str, tag: &str) { | |||
| 336 | 328 | ||
| 337 | #[test] | 329 | #[test] |
| 338 | fn quality_matches_prores_ks_testsrc2() { | 330 | fn quality_matches_prores_ks_testsrc2() { |
| 339 | - if !ffmpeg_or_skip() { | ||
| 340 | - return; | ||
| 341 | - } | ||
| 342 | psnr_vs_prores_ks("testsrc2", "", "q-testsrc2"); | 331 | psnr_vs_prores_ks("testsrc2", "", "q-testsrc2"); |
| 343 | } | 332 | } |
| 344 | 333 | ||
| 345 | #[test] | 334 | #[test] |
| 346 | fn quality_matches_prores_ks_mandelbrot() { | 335 | fn quality_matches_prores_ks_mandelbrot() { |
| 347 | - if !ffmpeg_or_skip() { | ||
| 348 | - return; | ||
| 349 | - } | ||
| 350 | psnr_vs_prores_ks("mandelbrot", "", "q-mandel"); | 336 | psnr_vs_prores_ks("mandelbrot", "", "q-mandel"); |
| 351 | } | 337 | } |
| 352 | 338 | ||
| 353 | #[test] | 339 | #[test] |
| 354 | fn quality_matches_prores_ks_noisy() { | 340 | fn quality_matches_prores_ks_noisy() { |
| 355 | - if !ffmpeg_or_skip() { | ||
| 356 | - return; | ||
| 357 | - } | ||
| 358 | psnr_vs_prores_ks("testsrc2", ",noise=alls=12:allf=t", "q-noisy"); | 341 | psnr_vs_prores_ks("testsrc2", ",noise=alls=12:allf=t", "q-noisy"); |
| 359 | } | 342 | } |
| 360 | 343 | ||
| @@ -404,7 +387,7 @@ fn encode_speed_1080p_hq() { | |||
| 404 | } | 387 | } |
| 405 | 388 | ||
| 406 | fn probe(path: &std::path::Path, entry: &str) -> String { | 389 | fn probe(path: &std::path::Path, entry: &str) -> String { |
| 407 | - let out = Command::new("ffprobe") | 390 | + let out = ec_testkit::ffprobe() |
| 408 | .args(["-v", "error", "-select_streams", "v:0", "-show_entries", &format!("stream={entry}"), "-of", "default=nw=1:nk=1"]) | 391 | .args(["-v", "error", "-select_streams", "v:0", "-show_entries", &format!("stream={entry}"), "-of", "default=nw=1:nk=1"]) |
| 409 | .arg(path) | 392 | .arg(path) |
| 410 | .output() | 393 | .output() |
| @@ -413,7 +396,7 @@ fn probe(path: &std::path::Path, entry: &str) -> String { | |||
| 413 | } | 396 | } |
| 414 | 397 | ||
| 415 | fn probe_frame(path: &std::path::Path, entry: &str) -> String { | 398 | fn probe_frame(path: &std::path::Path, entry: &str) -> String { |
| 416 | - let out = Command::new("ffprobe") | 399 | + let out = ec_testkit::ffprobe() |
| 417 | .args(["-v", "error", "-select_streams", "v:0", "-show_frames", "-read_intervals", "%+#1", "-show_entries", &format!("frame={entry}"), "-of", "default=nw=1:nk=1"]) | 400 | .args(["-v", "error", "-select_streams", "v:0", "-show_frames", "-read_intervals", "%+#1", "-show_entries", &format!("frame={entry}"), "-of", "default=nw=1:nk=1"]) |
| 418 | .arg(path) | 401 | .arg(path) |
| 419 | .output() | 402 | .output() |
| @@ -424,9 +407,6 @@ fn probe_frame(path: &std::path::Path, entry: &str) -> String { | |||
| 424 | #[test] | 407 | #[test] |
| 425 | fn interlaced_every_profile_ffmpeg_and_ours_agree() { | 408 | fn interlaced_every_profile_ffmpeg_and_ours_agree() { |
| 426 | use ec_core::frame::Interlace; | 409 | use ec_core::frame::Interlace; |
| 427 | - if !ffmpeg_or_skip() { | ||
| 428 | - return; | ||
| 429 | - } | ||
| 430 | let dir = scratch("enc-field"); | 410 | let dir = scratch("enc-field"); |
| 431 | for (i, p) in ALL.into_iter().enumerate() { | 411 | for (i, p) in ALL.into_iter().enumerate() { |
| 432 | for (order, field_order) in [(Interlace::TopFieldFirst, "tt"), (Interlace::BottomFieldFirst, "bb")] { | 412 | for (order, field_order) in [(Interlace::TopFieldFirst, "tt"), (Interlace::BottomFieldFirst, "bb")] { |
| @@ -508,9 +488,6 @@ fn alpha_pattern(w: usize, h: usize, seed: u64) -> Vec<u16> { | |||
| 508 | fn alpha_4444_round_trips_and_ffmpeg_agrees() { | 488 | fn alpha_4444_round_trips_and_ffmpeg_agrees() { |
| 509 | use ec_core::frame::Interlace; | 489 | use ec_core::frame::Interlace; |
| 510 | use ec_prores::AlphaPlane; | 490 | use ec_prores::AlphaPlane; |
| 511 | - if !ffmpeg_or_skip() { | ||
| 512 | - return; | ||
| 513 | - } | ||
| 514 | let dir = scratch("enc-alpha"); | 491 | let dir = scratch("enc-alpha"); |
| 515 | let mut n = 0; | 492 | let mut n = 0; |
| 516 | for p in [Profile::P4444, Profile::P4444Xq] { | 493 | for p in [Profile::P4444, Profile::P4444Xq] { |
crates/ec-prores/tests/ffmpeg_parity.rsmodified+0 -3
| @@ -112,9 +112,6 @@ fn generate(c: &Case) -> std::path::PathBuf { | |||
| 112 | 112 | ||
| 113 | #[test] | 113 | #[test] |
| 114 | fn matches_ffmpeg() { | 114 | fn matches_ffmpeg() { |
| 115 | - if !ffmpeg_or_skip() { | ||
| 116 | - return; | ||
| 117 | - } | ||
| 118 | let mut bad = Vec::new(); | 115 | let mut bad = Vec::new(); |
| 119 | for c in CASES { | 116 | for c in CASES { |
| 120 | let mov = generate(c); | 117 | let mov = generate(c); |
crates/ec-prores/tests/perf.rsmodified+0 -3
| @@ -6,9 +6,6 @@ use common::*; | |||
| 6 | 6 | ||
| 7 | #[test] | 7 | #[test] |
| 8 | fn hd_hq_throughput() { | 8 | fn hd_hq_throughput() { |
| 9 | - if !ffmpeg_or_skip() { | ||
| 10 | - return; | ||
| 11 | - } | ||
| 12 | let dir = scratch("perf"); | 9 | let dir = scratch("perf"); |
| 13 | let mov = dir.join("hd.mov"); | 10 | let mov = dir.join("hd.mov"); |
| 14 | assert!(run(&[ | 11 | assert!(run(&[ |
crates/ec-prores/tests/robust.rsmodified+8 -11
| @@ -19,15 +19,12 @@ impl Rng { | |||
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | /// Small frames: progressive 422, interlaced 422, 4444 with alpha. | 21 | /// Small frames: progressive 422, interlaced 422, 4444 with alpha. |
| 22 | -fn frames() -> Option<Vec<Vec<u8>>> { | 22 | +fn frames() -> Vec<Vec<u8>> { |
| 23 | - static CACHE: std::sync::OnceLock<Option<Vec<Vec<u8>>>> = std::sync::OnceLock::new(); | 23 | + static CACHE: std::sync::OnceLock<Vec<Vec<u8>>> = std::sync::OnceLock::new(); |
| 24 | CACHE.get_or_init(make_frames).clone() | 24 | CACHE.get_or_init(make_frames).clone() |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | -fn make_frames() -> Option<Vec<Vec<u8>>> { | 27 | +fn make_frames() -> Vec<Vec<u8>> { |
| 28 | - if !ffmpeg_or_skip() { | ||
| 29 | - return None; | ||
| 30 | - } | ||
| 31 | let dir = scratch("robust"); | 28 | let dir = scratch("robust"); |
| 32 | let mut out = Vec::new(); | 29 | let mut out = Vec::new(); |
| 33 | for (i, (prof, fmt, extra)) in [ | 30 | for (i, (prof, fmt, extra)) in [ |
| @@ -51,12 +48,12 @@ fn make_frames() -> Option<Vec<Vec<u8>>> { | |||
| 51 | out.push(packets(&std::fs::read(&mov).unwrap()).remove(0)); | 48 | out.push(packets(&std::fs::read(&mov).unwrap()).remove(0)); |
| 52 | } | 49 | } |
| 53 | let _ = std::fs::remove_dir_all(dir); | 50 | let _ = std::fs::remove_dir_all(dir); |
| 54 | - Some(out) | 51 | + out |
| 55 | } | 52 | } |
| 56 | 53 | ||
| 57 | #[test] | 54 | #[test] |
| 58 | fn truncations_never_panic() { | 55 | fn truncations_never_panic() { |
| 59 | - let Some(fs) = frames() else { return }; | 56 | + let fs = frames(); |
| 60 | for f in &fs { | 57 | for f in &fs { |
| 61 | let mut d = decoder(2); | 58 | let mut d = decoder(2); |
| 62 | assert!(d.decode(f).is_ok()); | 59 | assert!(d.decode(f).is_ok()); |
| @@ -68,7 +65,7 @@ fn truncations_never_panic() { | |||
| 68 | 65 | ||
| 69 | #[test] | 66 | #[test] |
| 70 | fn corruptions_never_panic() { | 67 | fn corruptions_never_panic() { |
| 71 | - let Some(fs) = frames() else { return }; | 68 | + let fs = frames(); |
| 72 | let mut rng = Rng(0x9E3779B97F4A7C15); | 69 | let mut rng = Rng(0x9E3779B97F4A7C15); |
| 73 | for f in &fs { | 70 | for f in &fs { |
| 74 | let mut d = decoder(3); | 71 | let mut d = decoder(3); |
| @@ -105,7 +102,7 @@ fn garbage_is_refused_by_name() { | |||
| 105 | 102 | ||
| 106 | #[test] | 103 | #[test] |
| 107 | fn hostile_dimensions_are_bounded() { | 104 | fn hostile_dimensions_are_bounded() { |
| 108 | - let Some(fs) = frames() else { return }; | 105 | + let fs = frames(); |
| 109 | let mut g = fs[0].clone(); | 106 | let mut g = fs[0].clone(); |
| 110 | // width/height at frame-header bytes 8..12 (after size+icpf: offset 8+8). | 107 | // width/height at frame-header bytes 8..12 (after size+icpf: offset 8+8). |
| 111 | g[16..20].copy_from_slice(&[0xFF, 0xFF, 0xFF, 0xFF]); | 108 | g[16..20].copy_from_slice(&[0xFF, 0xFF, 0xFF, 0xFF]); |
| @@ -131,7 +128,7 @@ fn wrong_codec_is_unsupported() { | |||
| 131 | fn dump_seeds() { | 128 | fn dump_seeds() { |
| 132 | let dir = std::env::var("EC_SEED_DIR").expect("EC_SEED_DIR"); | 129 | let dir = std::env::var("EC_SEED_DIR").expect("EC_SEED_DIR"); |
| 133 | std::fs::create_dir_all(&dir).unwrap(); | 130 | std::fs::create_dir_all(&dir).unwrap(); |
| 134 | - let Some(fs) = frames() else { return }; | 131 | + let fs = frames(); |
| 135 | for (i, f) in fs.iter().enumerate() { | 132 | for (i, f) in fs.iter().enumerate() { |
| 136 | std::fs::write(format!("{dir}/seed{i}.bin"), f).unwrap(); | 133 | std::fs::write(format!("{dir}/seed{i}.bin"), f).unwrap(); |
| 137 | } | 134 | } |