diff --git a/.config/nextest.toml b/.config/nextest.toml index fd2a372236..17eb6c07b6 100644 --- a/.config/nextest.toml +++ b/.config/nextest.toml @@ -26,7 +26,7 @@ print = { max-threads = 1 } video-integration = { max-threads = 1 } [[profile.default.overrides]] -filter = 'package(craft-video) & binary(h264_decode)' +filter = 'package(craft-video) & binary(it) & test(/^h264_decode::/)' test-group = 'video-fixtures' [[profile.default.overrides]] diff --git a/crates/video/Cargo.toml b/crates/video/Cargo.toml index 4ef66a5e19..30cee4a92c 100644 --- a/crates/video/Cargo.toml +++ b/crates/video/Cargo.toml @@ -1,4 +1,5 @@ [package] +autotests = false name = "craft-video" description = "Clean-room pure-Rust video codecs, one feature per codec: DNxHD/DNxHR, VP8, ProRes, H.264, HEVC, VP9, AV1, MPEG-4 Part 2, Sierra VMD." version.workspace = true @@ -84,34 +85,6 @@ craft-media-testkit = { workspace = true } # demuxers, for the track decoder's tests; the VMD demuxer, for the VMD decoder's. craft-media = { workspace = true, features = ["avi", "isobmff", "mpegts", "vmd"] } -# Built with any decoder feature; each codec's tests need its own. -[[test]] -name = "track" - -[[test]] -name = "vmd" -required-features = ["vmd-decode"] - -[[test]] -name = "hap" -required-features = ["hap"] - -[[test]] -name = "mjpeg" -required-features = ["mjpeg"] - -[[test]] -name = "dnx" -required-features = ["dnx"] - -[[test]] -name = "apv" -required-features = ["apv"] - -[[test]] -name = "vp8" -required-features = ["vp8-decode"] - [[example]] name = "vp8_fuzz" required-features = ["vp8-decode"] @@ -120,22 +93,10 @@ required-features = ["vp8-decode"] name = "vp8_vp8dec" required-features = ["vp8-decode"] -[[test]] -name = "av1_decode" -required-features = ["av1-decode"] - [[example]] name = "av1_av1dec" required-features = ["av1-decode"] -[[test]] -name = "h264_decode" -required-features = ["h264-decode"] - -[[test]] -name = "h264_encode" -required-features = ["h264-encode"] - [[example]] name = "h264_h264dec" required-features = ["h264-decode"] @@ -145,46 +106,14 @@ name = "h264_h264enc_bench" required-features = ["h264-encode"] test = true -[[test]] -name = "hevc_decode" -required-features = ["hevc-decode"] - [[example]] name = "hevc_hevcdec" required-features = ["hevc-decode"] -[[test]] -name = "vp8_encode" -required-features = ["vp8"] - -[[test]] -name = "vp9_decode" -required-features = ["vp9-decode"] - [[example]] name = "vp9_vp9dec" required-features = ["vp9-decode"] [[test]] -name = "mpeg4_encode" -required-features = ["mpeg4-encode"] - -[[test]] -name = "mpeg2" -required-features = ["mpeg2-decode"] - -[[test]] -name = "ffv1" -required-features = ["ffv1"] - -[[test]] -name = "prores" -required-features = ["prores"] - -[[test]] -name = "hevc" -required-features = ["hevc-encode"] - -[[test]] -name = "av1" -required-features = ["av1"] +name = "it" +path = "tests/it/main.rs" diff --git a/crates/video/src/apv/README.md b/crates/video/src/apv/README.md index 380660c2e6..7f7b8af645 100644 --- a/crates/video/src/apv/README.md +++ b/crates/video/src/apv/README.md @@ -56,7 +56,7 @@ let apvc: Vec = enc.decoder_config_record(); // APVDecoderConfigurationReco - **Metadata (§8)**: Parses `metadata_mdcv` (`payloadType == 5`, Mastering Display Color Volume) and `metadata_cll` (`payloadType == 6`, Content Light-Level Information). - **Robustness (§10)**: All size fields, tile coordinates, VLC codeword lengths, and coefficient - ranges (`-32768..=32767`) are checked before allocation or shift. Verified by `tests/apv/fuzz.rs` + ranges (`-32768..=32767`) are checked before allocation or shift. Verified by `tests/it/apv/fuzz.rs` across thousands of mutated and random inputs. - **Memory budget**: the samples of one access unit (the decoded tiles and the frame assembled from them, plus the same for an auxiliary alpha frame) must fit `DecodeOptions::memory_budget` @@ -74,7 +74,7 @@ let apvc: Vec = enc.decoder_config_record(); // APVDecoderConfigurationReco ## Accuracy (vs FFmpeg as an External Oracle) -`tests/apv/oracle.rs` encodes synthetic test patterns across all 7 profiles, odd dimensions, multiple +`tests/it/apv/oracle.rs` encodes synthetic test patterns across all 7 profiles, odd dimensions, multiple tiles, custom asymmetric quantization matrices, and HDR metadata PBUs, then decodes the resulting `.apv` streams with `ffmpeg -v error -xerror -f apv` and compares against `craft_video::apv::decode_frame`. Because APV specifies an exact integer inverse transform, **the decoder is 100% bit-exact diff --git a/crates/video/src/dnx/README.md b/crates/video/src/dnx/README.md index a7a4c152cd..78072b1db1 100644 --- a/crates/video/src/dnx/README.md +++ b/crates/video/src/dnx/README.md @@ -70,7 +70,7 @@ first frame header to label the stream. 12-bit coefficient domain is ¼ of the orthonormal DCT, as Table 14's 13-bit IDCT input range for 12-bit samples implies) and 1 otherwise. - Robustness: every offset and size is validated, run lengths past coefficient 63 are rejected, - and corrupted or truncated streams return `Err` without panicking ([`fuzz_hostile.rs`](../../tests/dnx/fuzz_hostile.rs)). + and corrupted or truncated streams return `Err` without panicking ([`fuzz_hostile.rs`](../../tests/it/dnx/fuzz_hostile.rs)). ### Where we follow ffmpeg rather than the letter of the standard @@ -111,7 +111,7 @@ the prose of §7.3.1.2; we follow the prose (normative text takes precedence). ## Accuracy (vs ffmpeg as an external oracle) -[`oracle_decode.rs`](../../tests/dnx/oracle_decode.rs) decodes 22 fixtures made by ffmpeg's VC-3 encoder: CIDs 1235, 1237, +[`oracle_decode.rs`](../../tests/it/dnx/oracle_decode.rs) decodes 22 fixtures made by ffmpeg's VC-3 encoder: CIDs 1235, 1237, 1238, 1241, 1242, 1243, 1244, 1250, 1251, 1252, 1253, 1258, 1259 and DNxHR LB/SQ/HQ/HQX/444 (Y′CbCr and RGB), with testsrc2, mandelbrot and heavy noise, at 1920×1080, 1280×720, 960×720, 1440×1080 (thin raster, interlaced), 1000×562, 640×360, 256×120 and 3840×2160. Compared with @@ -122,7 +122,7 @@ decoder evaluates the exact IDCT of equation 8.3, so decode is **not bit-exact, precision** of ffmpeg. (ffmpeg wraps rather than clips 10-bit reconstructions that overflow 1023, so the noise fixtures keep their samples inside 24…231 before encoding.) -[`oracle_encode.rs`](../../tests/dnx/oracle_encode.rs) encodes 1920×1080 frames with every profile and writes them into a +[`oracle_encode.rs`](../../tests/it/dnx/oracle_encode.rs) encodes 1920×1080 frames with every profile and writes them into a minimal test-only MOV. ffmpeg decodes them with `-xerror`, without errors, and agrees with our decoder within ±2 (90–99% identical). Luma PSNR against the source: HQ 58.8 dB (mandelbrot) and 66.3 dB (testsrc2), SQ 57.5 dB, LB 56.1 dB, HQX 10-bit 67.5 dB, HQX 12-bit 80.2 dB, 444 10-bit diff --git a/crates/video/src/ffv1/README.md b/crates/video/src/ffv1/README.md index 90312dbe53..0a7b5a8e3d 100644 --- a/crates/video/src/ffv1/README.md +++ b/crates/video/src/ffv1/README.md @@ -47,6 +47,6 @@ let frame = dec.decode(&packet)?; ## Verification -`tests/ffv1.rs`: round trips over every shape, hostile input (every truncation and bit flip), +`tests/it/ffv1.rs`: round trips over every shape, hostile input (every truncation and bit flip), and ffmpeg as the oracle in both directions (skipped without ffmpeg, a failure with `CRAFT_MEDIA_REQUIRE_ORACLES=1`). diff --git a/crates/video/src/mpeg2/README.md b/crates/video/src/mpeg2/README.md index bddcae9042..06dd01a893 100644 --- a/crates/video/src/mpeg2/README.md +++ b/crates/video/src/mpeg2/README.md @@ -169,7 +169,7 @@ are compared within a tolerance: **per frame max |Δ| ≤ 4 and PSNR ≥ 58 dB, samples differing**. Frame count, display order, picture types, interlacing and field order are exact (ffprobe). -`tests/mpeg2/oracle.rs` (FFmpeg-encoded elementary streams): +`tests/it/mpeg2/oracle.rs` (FFmpeg-encoded elementary streams): | Fixture | Content | Max Δ | Differing | PSNR | |---|---|---|---|---| @@ -218,7 +218,7 @@ fell to 77–150 fps). These are lower bounds. rounding, field addressing, edge clamping. - `tests.rs`: a hand-built intra picture decodes to its DC; truncation at every byte and 3000 random mutations never panic. -- `synth_tests.rs`, `tests/mpeg2/oracle.rs`: see above (single-threaded decode identical to the +- `synth_tests.rs`, `tests/it/mpeg2/oracle.rs`: see above (single-threaded decode identical to the threaded one). - `encode/`: every encoder code decodes to its value with the decoder's tables; motion vector deltas survive the decoder's wrap for f_code 1-4; forward/inverse DCT and quantiser round trips; @@ -245,7 +245,7 @@ fell to 77–150 fps). These are lower bounds. bitrate, for two picture intervals) are refused, and the lowest bitrate accepted for CIF meets the buffer with noise. The `vbv.rs` model itself: both bounds of a constant bitrate buffer, a full variable bitrate buffer stops filling, 29.97 fps does not drift. -- `tests/mpeg2/encode.rs`: FFmpeg decodes our streams of `testsrc2` (CIF and 576-line 4:2:2; +- `tests/it/mpeg2/encode.rs`: FFmpeg decodes our streams of `testsrc2` (CIF and 576-line 4:2:2; without B pictures, with 2 and 4, closed and open GOPs) without errors and within the decoder suite's tolerance of our reconstruction, ffprobe reports the profile, level, pixel format and picture types in display order, and average bitrate lands within 10 % of 800 and 2500 kbit/s diff --git a/crates/video/src/mpeg2/encode/tests.rs b/crates/video/src/mpeg2/encode/tests.rs index 06b2c20fe3..60f9bbfb3d 100644 --- a/crates/video/src/mpeg2/encode/tests.rs +++ b/crates/video/src/mpeg2/encode/tests.rs @@ -1,6 +1,6 @@ //! Encoder tests against this crate's decoder: the decoded pictures must equal the encoder's //! reconstruction exactly (any difference would drift along a GOP of P pictures). The ffmpeg -//! comparison is in `tests/mpeg2/encode.rs`. +//! comparison is in `tests/it/mpeg2/encode.rs`. use super::*; use crate::mpeg2::{Decoder, probe}; diff --git a/crates/video/src/mpeg2/synth_tests.rs b/crates/video/src/mpeg2/synth_tests.rs index f3c8648ebf..61020a0a9b 100644 --- a/crates/video/src/mpeg2/synth_tests.rs +++ b/crates/video/src/mpeg2/synth_tests.rs @@ -756,7 +756,7 @@ fn check(cfg: Cfg) { } let psnr = 10.0 * (255f64 * 255.0 * n as f64 / sse.max(1e-9)).log10(); println!("{}: {} frames, max diff {worst}, {:.3}% differ, PSNR {psnr:.2} dB", cfg.name, pics.len(), 100.0 * differ as f64 / n as f64); - // the same criteria as the ffmpeg-encoded fixtures (tests/mpeg2/oracle.rs) + // the same criteria as the ffmpeg-encoded fixtures (tests/it/mpeg2/oracle.rs) assert!(worst <= 4 && psnr >= 58.0, "{} (seed {:#x}): max diff {worst}, PSNR {psnr:.2}, first at {first_bad:?}", cfg.name, cfg.seed); } @@ -857,7 +857,7 @@ fn frame_pictures_field_mc_and_dual_prime() { } /// ffmpeg's encoder writes no field pictures, 16x8 or dual-prime prediction, so the hostile sweep -/// over its streams (`tests/mpeg2/fuzz_hostile.rs`) never reaches that code. Mutate and truncate +/// over its streams (`tests/it/mpeg2/fuzz_hostile.rs`) never reaches that code. Mutate and truncate /// the synthetic streams instead; needs no ffmpeg. #[test] fn mutated_field_and_dual_prime_streams_never_panic() { diff --git a/crates/video/src/mpeg2/tests.rs b/crates/video/src/mpeg2/tests.rs index 864472e05f..25ead35e37 100644 --- a/crates/video/src/mpeg2/tests.rs +++ b/crates/video/src/mpeg2/tests.rs @@ -1,5 +1,5 @@ //! Unit tests over hand-built streams (headers, robustness). Decoding accuracy against ffmpeg is -//! in `tests/mpeg2/oracle.rs`. +//! in `tests/it/mpeg2/oracle.rs`. use super::*; diff --git a/crates/video/src/prores/README.md b/crates/video/src/prores/README.md index 731bc92809..ae83e3d9a8 100644 --- a/crates/video/src/prores/README.md +++ b/crates/video/src/prores/README.md @@ -68,7 +68,7 @@ does), so the decoder doesn't need to know. rayon task directly into the output planes. - Robustness: every size field is validated before allocation, codewords longer than 56 bits are rejected, and arithmetic is overflow-safe. Mutated streams return `Err`, never panic (see - [`tests/prores/fuzz_hostile.rs`](../../tests/prores/fuzz_hostile.rs)). + [`tests/it/prores/fuzz_hostile.rs`](../../tests/it/prores/fuzz_hostile.rs)). ## Encoder diff --git a/crates/video/tests/apv/alpha.rs b/crates/video/tests/it/apv/alpha.rs similarity index 100% rename from crates/video/tests/apv/alpha.rs rename to crates/video/tests/it/apv/alpha.rs diff --git a/crates/video/tests/apv/budget.rs b/crates/video/tests/it/apv/budget.rs similarity index 100% rename from crates/video/tests/apv/budget.rs rename to crates/video/tests/it/apv/budget.rs diff --git a/crates/video/tests/apv/fuzz.rs b/crates/video/tests/it/apv/fuzz.rs similarity index 100% rename from crates/video/tests/apv/fuzz.rs rename to crates/video/tests/it/apv/fuzz.rs diff --git a/crates/video/tests/apv/fuzz_hostile.rs b/crates/video/tests/it/apv/fuzz_hostile.rs similarity index 100% rename from crates/video/tests/apv/fuzz_hostile.rs rename to crates/video/tests/it/apv/fuzz_hostile.rs diff --git a/crates/video/tests/apv/hostile_args.rs b/crates/video/tests/it/apv/hostile_args.rs similarity index 100% rename from crates/video/tests/apv/hostile_args.rs rename to crates/video/tests/it/apv/hostile_args.rs diff --git a/crates/video/tests/apv/main.rs b/crates/video/tests/it/apv/main.rs similarity index 100% rename from crates/video/tests/apv/main.rs rename to crates/video/tests/it/apv/main.rs diff --git a/crates/video/tests/apv/oracle.rs b/crates/video/tests/it/apv/oracle.rs similarity index 100% rename from crates/video/tests/apv/oracle.rs rename to crates/video/tests/it/apv/oracle.rs diff --git a/crates/video/tests/av1/main.rs b/crates/video/tests/it/av1/main.rs similarity index 100% rename from crates/video/tests/av1/main.rs rename to crates/video/tests/it/av1/main.rs diff --git a/crates/video/tests/av1_decode/adhoc.rs b/crates/video/tests/it/av1_decode/adhoc.rs similarity index 98% rename from crates/video/tests/av1_decode/adhoc.rs rename to crates/video/tests/it/av1_decode/adhoc.rs index 46172ce0dd..d586d95df3 100644 --- a/crates/video/tests/av1_decode/adhoc.rs +++ b/crates/video/tests/it/av1_decode/adhoc.rs @@ -1,7 +1,7 @@ //! Compare an arbitrary IVF file with libdav1d: //! `AV1_IVF=/path/x.ivf AV1_PIX=yuv420p cargo test -p craft-video --features av1-decode,threads --test av1_decode adhoc:: -- --ignored --nocapture` -use crate::common; +use super::common; use common::*; #[test] diff --git a/crates/video/tests/av1_decode/common/mod.rs b/crates/video/tests/it/av1_decode/common/mod.rs similarity index 100% rename from crates/video/tests/av1_decode/common/mod.rs rename to crates/video/tests/it/av1_decode/common/mod.rs diff --git a/crates/video/tests/av1_decode/conformance.rs b/crates/video/tests/it/av1_decode/conformance.rs similarity index 99% rename from crates/video/tests/av1_decode/conformance.rs rename to crates/video/tests/it/av1_decode/conformance.rs index b2060bfd1a..e528385c6f 100644 --- a/crates/video/tests/av1_decode/conformance.rs +++ b/crates/video/tests/it/av1_decode/conformance.rs @@ -1,6 +1,6 @@ //! libaom conformance test vectors (downloaded on first use), compared with libdav1d. -use crate::common; +use super::common; use common::*; /// Vectors the decoder handles today (more are added as stages land). diff --git a/crates/video/tests/av1_decode/fuzz_hostile.rs b/crates/video/tests/it/av1_decode/fuzz_hostile.rs similarity index 100% rename from crates/video/tests/av1_decode/fuzz_hostile.rs rename to crates/video/tests/it/av1_decode/fuzz_hostile.rs diff --git a/crates/video/tests/av1_decode/hostile_dims.rs b/crates/video/tests/it/av1_decode/hostile_dims.rs similarity index 100% rename from crates/video/tests/av1_decode/hostile_dims.rs rename to crates/video/tests/it/av1_decode/hostile_dims.rs diff --git a/crates/video/tests/av1_decode/main.rs b/crates/video/tests/it/av1_decode/main.rs similarity index 100% rename from crates/video/tests/av1_decode/main.rs rename to crates/video/tests/it/av1_decode/main.rs diff --git a/crates/video/tests/av1_decode/oracle_inter.rs b/crates/video/tests/it/av1_decode/oracle_inter.rs similarity index 99% rename from crates/video/tests/av1_decode/oracle_inter.rs rename to crates/video/tests/it/av1_decode/oracle_inter.rs index 65a229752b..20ff3b1fb0 100644 --- a/crates/video/tests/av1_decode/oracle_inter.rs +++ b/crates/video/tests/it/av1_decode/oracle_inter.rs @@ -2,7 +2,7 @@ //! GOPs with hierarchical references, compound prediction, OBMC / warped motion, global motion, //! motion-field projection and all loop filters. -use crate::common; +use super::common; use common::*; fn specs() -> Vec { diff --git a/crates/video/tests/av1_decode/oracle_intra.rs b/crates/video/tests/it/av1_decode/oracle_intra.rs similarity index 99% rename from crates/video/tests/av1_decode/oracle_intra.rs rename to crates/video/tests/it/av1_decode/oracle_intra.rs index 98bfbfa73a..faf5fdea4a 100644 --- a/crates/video/tests/av1_decode/oracle_intra.rs +++ b/crates/video/tests/it/av1_decode/oracle_intra.rs @@ -1,6 +1,6 @@ //! Intra-frame bit-exactness against libdav1d (run as an external ffmpeg process). -use crate::common; +use super::common; use common::*; const NO_FILTERS: &str = "enable-cdef=0:enable-restoration=0:enable-dlf=0:keyint=1"; diff --git a/crates/video/tests/av1_decode/perf.rs b/crates/video/tests/it/av1_decode/perf.rs similarity index 99% rename from crates/video/tests/av1_decode/perf.rs rename to crates/video/tests/it/av1_decode/perf.rs index 3f25a32896..e356cf3ea0 100644 --- a/crates/video/tests/av1_decode/perf.rs +++ b/crates/video/tests/it/av1_decode/perf.rs @@ -5,7 +5,7 @@ //! thread CPU clock, which is robust to load; wall-clock figures are printed next to the load //! average. -use crate::common; +use super::common; use common::*; use craft_video::av1::decode::{DecodeStats, Decoder, Stage}; use std::time::Instant; diff --git a/crates/video/tests/av1_decode/wavefront.rs b/crates/video/tests/it/av1_decode/wavefront.rs similarity index 99% rename from crates/video/tests/av1_decode/wavefront.rs rename to crates/video/tests/it/av1_decode/wavefront.rs index 725b02544b..9a93681467 100644 --- a/crates/video/tests/av1_decode/wavefront.rs +++ b/crates/video/tests/it/av1_decode/wavefront.rs @@ -2,7 +2,7 @@ //! frames): every thread count gives the single-thread pictures, run after run, and dropping //! or flushing a busy decoder never hangs. A hang fails the test through the deadline. -use crate::common; +use super::common; use common::*; use craft_video::av1::decode::{Decoder, Picture}; diff --git a/crates/video/tests/dnx/common/mod.rs b/crates/video/tests/it/dnx/common/mod.rs similarity index 100% rename from crates/video/tests/dnx/common/mod.rs rename to crates/video/tests/it/dnx/common/mod.rs diff --git a/crates/video/tests/dnx/fuzz_hostile.rs b/crates/video/tests/it/dnx/fuzz_hostile.rs similarity index 100% rename from crates/video/tests/dnx/fuzz_hostile.rs rename to crates/video/tests/it/dnx/fuzz_hostile.rs diff --git a/crates/video/tests/dnx/main.rs b/crates/video/tests/it/dnx/main.rs similarity index 100% rename from crates/video/tests/dnx/main.rs rename to crates/video/tests/it/dnx/main.rs diff --git a/crates/video/tests/dnx/oracle_decode.rs b/crates/video/tests/it/dnx/oracle_decode.rs similarity index 99% rename from crates/video/tests/dnx/oracle_decode.rs rename to crates/video/tests/it/dnx/oracle_decode.rs index b6bf90de41..dd8fb41781 100644 --- a/crates/video/tests/dnx/oracle_decode.rs +++ b/crates/video/tests/it/dnx/oracle_decode.rs @@ -1,6 +1,6 @@ //! Decode ffmpeg-made DNxHD / DNxHR fixtures and compare with ffmpeg's own decode. -use crate::common; +use super::common; use common::*; use craft_video::dnx::{DecodeOptions, decode_frame_with}; diff --git a/crates/video/tests/dnx/oracle_encode.rs b/crates/video/tests/it/dnx/oracle_encode.rs similarity index 99% rename from crates/video/tests/dnx/oracle_encode.rs rename to crates/video/tests/it/dnx/oracle_encode.rs index 003a9f3cb4..52b8290c67 100644 --- a/crates/video/tests/dnx/oracle_encode.rs +++ b/crates/video/tests/it/dnx/oracle_encode.rs @@ -1,6 +1,6 @@ //! Encode DNxHR with our encoder, decode with ffmpeg (`-xerror`) and with our decoder. -use crate::common; +use super::common; use common::*; use craft_video::dnx::{ChromaFormat, Encoder, EncoderConfig, Profile, decode_frame}; diff --git a/crates/video/tests/dnx/perf.rs b/crates/video/tests/it/dnx/perf.rs similarity index 100% rename from crates/video/tests/dnx/perf.rs rename to crates/video/tests/it/dnx/perf.rs diff --git a/crates/video/tests/dnx/roundtrip.rs b/crates/video/tests/it/dnx/roundtrip.rs similarity index 100% rename from crates/video/tests/dnx/roundtrip.rs rename to crates/video/tests/it/dnx/roundtrip.rs diff --git a/crates/video/tests/ffv1.rs b/crates/video/tests/it/ffv1.rs similarity index 100% rename from crates/video/tests/ffv1.rs rename to crates/video/tests/it/ffv1.rs diff --git a/crates/video/tests/h264_decode/common/mod.rs b/crates/video/tests/it/h264_decode/common/mod.rs similarity index 100% rename from crates/video/tests/h264_decode/common/mod.rs rename to crates/video/tests/it/h264_decode/common/mod.rs diff --git a/crates/video/tests/h264_decode/conformance.rs b/crates/video/tests/it/h264_decode/conformance.rs similarity index 99% rename from crates/video/tests/h264_decode/conformance.rs rename to crates/video/tests/it/h264_decode/conformance.rs index 2af075508b..53a59ef1a7 100644 --- a/crates/video/tests/h264_decode/conformance.rs +++ b/crates/video/tests/it/h264_decode/conformance.rs @@ -1,6 +1,6 @@ //! Bit-exactness against ffmpeg's decoder on libx264-generated fixtures (skipped when ffmpeg is absent). -use crate::common; +use super::common; macro_rules! fixture_tests { ($($name:ident),* $(,)?) => { diff --git a/crates/video/tests/h264_decode/fuzz_hostile.rs b/crates/video/tests/it/h264_decode/fuzz_hostile.rs similarity index 99% rename from crates/video/tests/h264_decode/fuzz_hostile.rs rename to crates/video/tests/it/h264_decode/fuzz_hostile.rs index 4c2dd4f127..e918a2672c 100644 --- a/crates/video/tests/h264_decode/fuzz_hostile.rs +++ b/crates/video/tests/it/h264_decode/fuzz_hostile.rs @@ -1,7 +1,7 @@ //! Hostile-input robustness: header-region sweeps (SPS/PPS/first slice headers), truncation and //! random mutation of small libx264 streams must never panic or run away. Skips without ffmpeg. -use crate::common; +use super::common; use std::panic::{AssertUnwindSafe, catch_unwind}; use std::process::{Command, Stdio}; diff --git a/crates/video/tests/h264_decode/headers.rs b/crates/video/tests/it/h264_decode/headers.rs similarity index 99% rename from crates/video/tests/h264_decode/headers.rs rename to crates/video/tests/it/h264_decode/headers.rs index 25f1268797..926075f4a9 100644 --- a/crates/video/tests/h264_decode/headers.rs +++ b/crates/video/tests/it/h264_decode/headers.rs @@ -1,6 +1,6 @@ //! Parameter set / slice header / POC parsing over the fixture streams. -use crate::common; +use super::common; use craft_media::bitstream::{annexb_nals, unescape_rbsp}; use craft_video::h264::decode::params::{Pps, Sps}; diff --git a/crates/video/tests/h264_decode/main.rs b/crates/video/tests/it/h264_decode/main.rs similarity index 100% rename from crates/video/tests/h264_decode/main.rs rename to crates/video/tests/it/h264_decode/main.rs diff --git a/crates/video/tests/h264_decode/perf.rs b/crates/video/tests/it/h264_decode/perf.rs similarity index 98% rename from crates/video/tests/h264_decode/perf.rs rename to crates/video/tests/it/h264_decode/perf.rs index 1993338a5d..6bdfefc703 100644 --- a/crates/video/tests/h264_decode/perf.rs +++ b/crates/video/tests/it/h264_decode/perf.rs @@ -1,7 +1,7 @@ //! Decode speed on a 1080p High-profile stream (ignored by default; run with //! `cargo test --release -p craft-video --features h264-decode,threads --test h264_decode perf:: -- --ignored --nocapture`). -use crate::common; +use super::common; use craft_video::h264::decode::Decoder; use std::time::Instant; diff --git a/crates/video/tests/h264_decode/pps_validation.rs b/crates/video/tests/it/h264_decode/pps_validation.rs similarity index 100% rename from crates/video/tests/h264_decode/pps_validation.rs rename to crates/video/tests/it/h264_decode/pps_validation.rs diff --git a/crates/video/tests/h264_decode/robustness.rs b/crates/video/tests/it/h264_decode/robustness.rs similarity index 99% rename from crates/video/tests/h264_decode/robustness.rs rename to crates/video/tests/it/h264_decode/robustness.rs index 63320bad86..d2287f0b5c 100644 --- a/crates/video/tests/h264_decode/robustness.rs +++ b/crates/video/tests/it/h264_decode/robustness.rs @@ -1,6 +1,6 @@ //! avcC / length-prefixed input and resilience against damaged streams. -use crate::common; +use super::common; use craft_media::bitstream::annexb_nals; use craft_video::h264::decode::Decoder; diff --git a/crates/video/tests/h264_encode/common/mod.rs b/crates/video/tests/it/h264_encode/common/mod.rs similarity index 100% rename from crates/video/tests/h264_encode/common/mod.rs rename to crates/video/tests/it/h264_encode/common/mod.rs diff --git a/crates/video/tests/h264_encode/crf_level_and_note.rs b/crates/video/tests/it/h264_encode/crf_level_and_note.rs similarity index 99% rename from crates/video/tests/h264_encode/crf_level_and_note.rs rename to crates/video/tests/it/h264_encode/crf_level_and_note.rs index f984e6bf34..4490b07482 100644 --- a/crates/video/tests/h264_encode/crf_level_and_note.rs +++ b/crates/video/tests/it/h264_encode/crf_level_and_note.rs @@ -1,7 +1,7 @@ //! Constant quality has no bitrate cap, so the level must allow what low factors spend; and every //! stream says which settings made it. -use crate::common; +use super::common; use common::synth; use craft_video::h264::*; diff --git a/crates/video/tests/h264_encode/ffmpeg_oracle.rs b/crates/video/tests/it/h264_encode/ffmpeg_oracle.rs similarity index 99% rename from crates/video/tests/h264_encode/ffmpeg_oracle.rs rename to crates/video/tests/it/h264_encode/ffmpeg_oracle.rs index f6d13e4656..d0c4fc06eb 100644 --- a/crates/video/tests/h264_encode/ffmpeg_oracle.rs +++ b/crates/video/tests/it/h264_encode/ffmpeg_oracle.rs @@ -3,7 +3,7 @@ //! Every stream must decode with zero errors, with the exact frame count, and the decoder's output must be //! bit-identical to the encoder's own reconstruction (catches prediction/transform/deblocking mismatches). -use crate::common; +use super::common; use common::{Yuv, annexb_nals, ffmpeg, ffmpeg_decode, ffmpeg_source, ffprobe, out_dir, psnr, synth}; use craft_video::h264::*; diff --git a/crates/video/tests/h264_encode/high10_oracle.rs b/crates/video/tests/it/h264_encode/high10_oracle.rs similarity index 99% rename from crates/video/tests/h264_encode/high10_oracle.rs rename to crates/video/tests/it/h264_encode/high10_oracle.rs index 33033f06ab..8849d924f4 100644 --- a/crates/video/tests/h264_encode/high10_oracle.rs +++ b/crates/video/tests/it/h264_encode/high10_oracle.rs @@ -2,7 +2,7 @@ //! external oracle (skipped when absent): every stream decodes without a message, with the exact frame //! count, bit-identical to the encoder's reconstruction (#1221). -use crate::common; +use super::common; use common::{Yuv16, ffmpeg, ffmpeg_decode_as, ffprobe, le16, out_dir, psnr10, synth, synth10}; use craft_video::h264::*; diff --git a/crates/video/tests/h264_encode/main.rs b/crates/video/tests/it/h264_encode/main.rs similarity index 100% rename from crates/video/tests/h264_encode/main.rs rename to crates/video/tests/it/h264_encode/main.rs diff --git a/crates/video/tests/h264_encode/pinned_decisions.rs b/crates/video/tests/it/h264_encode/pinned_decisions.rs similarity index 98% rename from crates/video/tests/h264_encode/pinned_decisions.rs rename to crates/video/tests/it/h264_encode/pinned_decisions.rs index c547b54fff..c07c889310 100644 --- a/crates/video/tests/h264_encode/pinned_decisions.rs +++ b/crates/video/tests/it/h264_encode/pinned_decisions.rs @@ -2,7 +2,7 @@ //! so a change that alters any decision (a mode, a motion vector, a quantiser), and not only one //! that breaks decoding, fails here. Only slice NAL units are hashed: the SEI names the version. -use crate::common::{annexb_nals, synth}; +use super::common::{annexb_nals, synth}; use craft_video::h264::*; /// FNV-1a over the slice NAL units of `n` frames of [`synth`] encoded with `c`. diff --git a/crates/video/tests/h264_encode/thread_count.rs b/crates/video/tests/it/h264_encode/thread_count.rs similarity index 98% rename from crates/video/tests/h264_encode/thread_count.rs rename to crates/video/tests/it/h264_encode/thread_count.rs index 36d0d762aa..03d7d3ebf3 100644 --- a/crates/video/tests/h264_encode/thread_count.rs +++ b/crates/video/tests/it/h264_encode/thread_count.rs @@ -1,7 +1,7 @@ //! The worker-thread count only changes scheduling: with the slice count fixed, 1, 2 and several threads //! must produce byte-identical streams (also across the reuse of the per-picture buffers over many frames). -use crate::common::synth; +use super::common::synth; use craft_video::h264::*; fn encode(rate: RateControl, bframes: u8, threads: usize) -> Vec { diff --git a/crates/video/tests/h264_encode/vbr_overshoot.rs b/crates/video/tests/it/h264_encode/vbr_overshoot.rs similarity index 99% rename from crates/video/tests/h264_encode/vbr_overshoot.rs rename to crates/video/tests/it/h264_encode/vbr_overshoot.rs index eba9ff648c..4ee9282c07 100644 --- a/crates/video/tests/h264_encode/vbr_overshoot.rs +++ b/crates/video/tests/it/h264_encode/vbr_overshoot.rs @@ -1,6 +1,6 @@ //! Single-pass VBR must land near its target bitrate even on a short, high-motion clip. -use crate::common::{self, Yuv}; +use super::common::{self, Yuv}; use craft_video::h264::*; use std::io::Read; use std::process::{Command, Stdio}; diff --git a/crates/video/tests/hap.rs b/crates/video/tests/it/hap.rs similarity index 100% rename from crates/video/tests/hap.rs rename to crates/video/tests/it/hap.rs diff --git a/crates/video/tests/hevc/main.rs b/crates/video/tests/it/hevc/main.rs similarity index 100% rename from crates/video/tests/hevc/main.rs rename to crates/video/tests/it/hevc/main.rs diff --git a/crates/video/tests/hevc_decode/common/mod.rs b/crates/video/tests/it/hevc_decode/common/mod.rs similarity index 100% rename from crates/video/tests/hevc_decode/common/mod.rs rename to crates/video/tests/it/hevc_decode/common/mod.rs diff --git a/crates/video/tests/hevc_decode/conformance.rs b/crates/video/tests/it/hevc_decode/conformance.rs similarity index 99% rename from crates/video/tests/hevc_decode/conformance.rs rename to crates/video/tests/it/hevc_decode/conformance.rs index 08602d079c..11b31df327 100644 --- a/crates/video/tests/hevc_decode/conformance.rs +++ b/crates/video/tests/it/hevc_decode/conformance.rs @@ -1,7 +1,7 @@ //! Bit-exactness against ffmpeg's decoder on libx265 / VideoToolbox fixtures (skipped when ffmpeg is //! absent). -use crate::common; +use super::common; macro_rules! fixture_tests { ($($name:ident),* $(,)?) => { diff --git a/crates/video/tests/hevc_decode/fuzz_hostile.rs b/crates/video/tests/it/hevc_decode/fuzz_hostile.rs similarity index 99% rename from crates/video/tests/hevc_decode/fuzz_hostile.rs rename to crates/video/tests/it/hevc_decode/fuzz_hostile.rs index 29249b8561..f6e4c5dc8a 100644 --- a/crates/video/tests/hevc_decode/fuzz_hostile.rs +++ b/crates/video/tests/it/hevc_decode/fuzz_hostile.rs @@ -1,7 +1,7 @@ //! Hostile-input robustness: header-region sweeps (SPS/PPS/first slice headers), truncation and //! random mutation of small libx265 streams must never panic or run away. Skips without ffmpeg. -use crate::common; +use super::common; use std::panic::{AssertUnwindSafe, catch_unwind}; use std::process::{Command, Stdio}; diff --git a/crates/video/tests/hevc_decode/main.rs b/crates/video/tests/it/hevc_decode/main.rs similarity index 100% rename from crates/video/tests/hevc_decode/main.rs rename to crates/video/tests/it/hevc_decode/main.rs diff --git a/crates/video/tests/hevc_decode/perf.rs b/crates/video/tests/it/hevc_decode/perf.rs similarity index 98% rename from crates/video/tests/hevc_decode/perf.rs rename to crates/video/tests/it/hevc_decode/perf.rs index 7962ff7038..badc437a8a 100644 --- a/crates/video/tests/hevc_decode/perf.rs +++ b/crates/video/tests/it/hevc_decode/perf.rs @@ -1,7 +1,7 @@ //! Decode speed (ignored by default; run with //! `cargo test --release -p craft-video --features hevc-decode,threads --test hevc_decode perf:: -- --ignored --nocapture`). -use crate::common; +use super::common; use craft_video::hevc::decode::Decoder; use std::time::Instant; diff --git a/crates/video/tests/hevc_decode/robustness.rs b/crates/video/tests/it/hevc_decode/robustness.rs similarity index 99% rename from crates/video/tests/hevc_decode/robustness.rs rename to crates/video/tests/it/hevc_decode/robustness.rs index a6c50ef410..328ba9029b 100644 --- a/crates/video/tests/hevc_decode/robustness.rs +++ b/crates/video/tests/it/hevc_decode/robustness.rs @@ -1,6 +1,6 @@ //! hvcC / length-prefixed input and resilience against damaged streams. -use crate::common; +use super::common; use craft_media::bitstream::annexb_nals; use craft_video::hevc::decode::Decoder; diff --git a/crates/video/tests/it/main.rs b/crates/video/tests/it/main.rs new file mode 100644 index 0000000000..9c4dd414fd --- /dev/null +++ b/crates/video/tests/it/main.rs @@ -0,0 +1,76 @@ +//! Integration tests grouped by codec, retaining each former binary's feature gate. + +#[cfg(feature = "vmd-decode")] +#[path = "vmd/main.rs"] +mod vmd; + +#[cfg(feature = "hap")] +#[path = "hap.rs"] +mod hap; + +#[cfg(feature = "mjpeg")] +#[path = "mjpeg.rs"] +mod mjpeg; + +#[cfg(feature = "dnx")] +#[path = "dnx/main.rs"] +mod dnx; + +#[cfg(feature = "apv")] +#[path = "apv/main.rs"] +mod apv; + +#[cfg(feature = "vp8-decode")] +#[path = "vp8/main.rs"] +mod vp8; + +#[cfg(feature = "av1-decode")] +#[path = "av1_decode/main.rs"] +mod av1_decode; + +#[cfg(feature = "h264-decode")] +#[path = "h264_decode/main.rs"] +mod h264_decode; + +#[cfg(feature = "h264-encode")] +#[path = "h264_encode/main.rs"] +mod h264_encode; + +#[cfg(feature = "hevc-decode")] +#[path = "hevc_decode/main.rs"] +mod hevc_decode; + +#[cfg(feature = "vp8")] +#[path = "vp8_encode/main.rs"] +mod vp8_encode; + +#[cfg(feature = "vp9-decode")] +#[path = "vp9_decode/main.rs"] +mod vp9_decode; + +#[cfg(feature = "mpeg4-encode")] +#[path = "mpeg4_encode/main.rs"] +mod mpeg4_encode; + +#[cfg(feature = "mpeg2-decode")] +#[path = "mpeg2/main.rs"] +mod mpeg2; + +#[cfg(feature = "ffv1")] +#[path = "ffv1.rs"] +mod ffv1; + +#[cfg(feature = "prores")] +#[path = "prores/main.rs"] +mod prores; + +#[cfg(feature = "hevc-encode")] +#[path = "hevc/main.rs"] +mod hevc; + +#[cfg(feature = "av1")] +#[path = "av1/main.rs"] +mod av1; + +#[path = "track/main.rs"] +mod track; diff --git a/crates/video/tests/mjpeg.rs b/crates/video/tests/it/mjpeg.rs similarity index 100% rename from crates/video/tests/mjpeg.rs rename to crates/video/tests/it/mjpeg.rs diff --git a/crates/video/tests/mpeg2/common/mod.rs b/crates/video/tests/it/mpeg2/common/mod.rs similarity index 100% rename from crates/video/tests/mpeg2/common/mod.rs rename to crates/video/tests/it/mpeg2/common/mod.rs diff --git a/crates/video/tests/mpeg2/encode.rs b/crates/video/tests/it/mpeg2/encode.rs similarity index 99% rename from crates/video/tests/mpeg2/encode.rs rename to crates/video/tests/it/mpeg2/encode.rs index 1f13d9c863..d57633f4bd 100644 --- a/crates/video/tests/mpeg2/encode.rs +++ b/crates/video/tests/it/mpeg2/encode.rs @@ -8,8 +8,8 @@ use std::process::{Command, Stdio}; use craft_video::mpeg2::{ChromaFormat, Encoder, EncoderConfig, Packet, RateControl, ReconFrame, YuvFrame}; -use crate::common::{Stats, fixture_dir, pix_fmt_of}; -use crate::oracle::{MAX_DIFFERING, MIN_PSNR, TOL_MAX}; +use super::common::{Stats, fixture_dir, pix_fmt_of}; +use super::oracle::{MAX_DIFFERING, MIN_PSNR, TOL_MAX}; /// Raw source frames from ffmpeg's `testsrc2`. fn source(ff: &Path, w: u32, h: u32, frames: usize, pix_fmt: &str) -> Vec { diff --git a/crates/video/tests/mpeg2/fuzz_hostile.rs b/crates/video/tests/it/mpeg2/fuzz_hostile.rs similarity index 99% rename from crates/video/tests/mpeg2/fuzz_hostile.rs rename to crates/video/tests/it/mpeg2/fuzz_hostile.rs index 5985657843..1217be6310 100644 --- a/crates/video/tests/mpeg2/fuzz_hostile.rs +++ b/crates/video/tests/it/mpeg2/fuzz_hostile.rs @@ -2,7 +2,7 @@ //! sweeps over a small ffmpeg-generated stream must never panic or run away (errors are fine). //! Skips when ffmpeg is missing. -use crate::common; +use super::common; use std::panic::{AssertUnwindSafe, catch_unwind}; diff --git a/crates/video/tests/mpeg2/hostile_dims.rs b/crates/video/tests/it/mpeg2/hostile_dims.rs similarity index 100% rename from crates/video/tests/mpeg2/hostile_dims.rs rename to crates/video/tests/it/mpeg2/hostile_dims.rs diff --git a/crates/video/tests/mpeg2/main.rs b/crates/video/tests/it/mpeg2/main.rs similarity index 100% rename from crates/video/tests/mpeg2/main.rs rename to crates/video/tests/it/mpeg2/main.rs diff --git a/crates/video/tests/mpeg2/oracle.rs b/crates/video/tests/it/mpeg2/oracle.rs similarity index 99% rename from crates/video/tests/mpeg2/oracle.rs rename to crates/video/tests/it/mpeg2/oracle.rs index 14993660c7..bb4e54bc5b 100644 --- a/crates/video/tests/mpeg2/oracle.rs +++ b/crates/video/tests/it/mpeg2/oracle.rs @@ -3,7 +3,7 @@ //! definition (any IEEE 1180-accurate IDCT conforms), so frames are compared within a tolerance; //! frame count and display order are exact. -use crate::common; +use super::common; use common::*; diff --git a/crates/video/tests/mpeg2/perf.rs b/crates/video/tests/it/mpeg2/perf.rs similarity index 90% rename from crates/video/tests/mpeg2/perf.rs rename to crates/video/tests/it/mpeg2/perf.rs index bc53724153..e01bd60103 100644 --- a/crates/video/tests/mpeg2/perf.rs +++ b/crates/video/tests/it/mpeg2/perf.rs @@ -1,7 +1,7 @@ //! Decode speed (ignored; run with `cargo test --release -p craft-video --features mpeg2,threads --test mpeg2 perf:: -- -//! --ignored --nocapture`). Uses the 1080i fixture of `tests/mpeg2/oracle.rs` (ffmpeg-encoded, 25 Mb/s). +//! --ignored --nocapture`). Uses the 1080i fixture of `tests/it/mpeg2/oracle.rs` (ffmpeg-encoded, 25 Mb/s). -use crate::common; +use super::common; use common::*; diff --git a/crates/video/tests/mpeg4_encode/main.rs b/crates/video/tests/it/mpeg4_encode/main.rs similarity index 100% rename from crates/video/tests/mpeg4_encode/main.rs rename to crates/video/tests/it/mpeg4_encode/main.rs diff --git a/crates/video/tests/prores/common/mod.rs b/crates/video/tests/it/prores/common/mod.rs similarity index 100% rename from crates/video/tests/prores/common/mod.rs rename to crates/video/tests/it/prores/common/mod.rs diff --git a/crates/video/tests/prores/fuzz.rs b/crates/video/tests/it/prores/fuzz.rs similarity index 99% rename from crates/video/tests/prores/fuzz.rs rename to crates/video/tests/it/prores/fuzz.rs index b533c1e0ec..90221ae2b8 100644 --- a/crates/video/tests/prores/fuzz.rs +++ b/crates/video/tests/it/prores/fuzz.rs @@ -1,6 +1,6 @@ //! Robustness: mutated and random inputs must never panic (errors are fine). -use crate::common; +use super::common; use craft_video::prores::*; struct Rng(u64); diff --git a/crates/video/tests/prores/fuzz_hostile.rs b/crates/video/tests/it/prores/fuzz_hostile.rs similarity index 100% rename from crates/video/tests/prores/fuzz_hostile.rs rename to crates/video/tests/it/prores/fuzz_hostile.rs diff --git a/crates/video/tests/prores/main.rs b/crates/video/tests/it/prores/main.rs similarity index 100% rename from crates/video/tests/prores/main.rs rename to crates/video/tests/it/prores/main.rs diff --git a/crates/video/tests/prores/oracle_decode.rs b/crates/video/tests/it/prores/oracle_decode.rs similarity index 99% rename from crates/video/tests/prores/oracle_decode.rs rename to crates/video/tests/it/prores/oracle_decode.rs index 1c8c535db6..f9cff81147 100644 --- a/crates/video/tests/prores/oracle_decode.rs +++ b/crates/video/tests/it/prores/oracle_decode.rs @@ -1,6 +1,6 @@ //! Decoder accuracy against ffmpeg's ProRes decoder (oracle only; skipped without ffmpeg). -use crate::common; +use super::common; use common::*; use craft_video::prores::{AlphaType, ChromaFormat, DecodeOptions, Interlace, decode_frame, decode_frame_with, probe}; diff --git a/crates/video/tests/prores/oracle_encode.rs b/crates/video/tests/it/prores/oracle_encode.rs similarity index 99% rename from crates/video/tests/prores/oracle_encode.rs rename to crates/video/tests/it/prores/oracle_encode.rs index 024e4524f7..b9323d3d92 100644 --- a/crates/video/tests/prores/oracle_encode.rs +++ b/crates/video/tests/it/prores/oracle_encode.rs @@ -1,6 +1,6 @@ //! Encoder conformance and quality against ffmpeg's ProRes decoder (oracle only). -use crate::common; +use super::common; use common::*; use craft_video::prores::{ChromaFormat, DecodeOptions, Encoder, Frame, Profile, decode_frame, decode_frame_with}; diff --git a/crates/video/tests/prores/perf.rs b/crates/video/tests/it/prores/perf.rs similarity index 99% rename from crates/video/tests/prores/perf.rs rename to crates/video/tests/it/prores/perf.rs index aac69664d3..2a8c5f6235 100644 --- a/crates/video/tests/prores/perf.rs +++ b/crates/video/tests/it/prores/perf.rs @@ -1,7 +1,7 @@ //! Decode/encode throughput. Run with //! `cargo test --release -p craft-video --features prores --test prores perf:: -- --ignored --nocapture`. -use crate::common; +use super::common; use craft_video::prores::*; use std::time::Instant; diff --git a/crates/video/tests/prores/roundtrip.rs b/crates/video/tests/it/prores/roundtrip.rs similarity index 99% rename from crates/video/tests/prores/roundtrip.rs rename to crates/video/tests/it/prores/roundtrip.rs index 873e788407..e0bd0ed1bc 100644 --- a/crates/video/tests/prores/roundtrip.rs +++ b/crates/video/tests/it/prores/roundtrip.rs @@ -1,6 +1,6 @@ //! Encoder → decoder round trips on synthetic content (no external tools needed). -use crate::common; +use super::common; use common::psnr; use craft_video::prores::*; diff --git a/crates/video/tests/track/av1.rs b/crates/video/tests/it/track/av1.rs similarity index 99% rename from crates/video/tests/track/av1.rs rename to crates/video/tests/it/track/av1.rs index cef856f2bc..a282a80df5 100644 --- a/crates/video/tests/track/av1.rs +++ b/crates/video/tests/it/track/av1.rs @@ -1,6 +1,6 @@ //! AV1 in MP4 (an `av1C` record whose config OBUs hold the sequence header). -use crate::common; +use super::common; use craft_media::CodecId; /// libaom when ffmpeg has it, else SVT-AV1: a fixture name and the encoder arguments. diff --git a/crates/video/tests/track/common/mod.rs b/crates/video/tests/it/track/common/mod.rs similarity index 92% rename from crates/video/tests/track/common/mod.rs rename to crates/video/tests/it/track/common/mod.rs index bd3f144615..87bc5438f9 100644 --- a/crates/video/tests/track/common/mod.rs +++ b/crates/video/tests/it/track/common/mod.rs @@ -29,6 +29,8 @@ pub struct Track { /// A fixture and ffmpeg's decode of it. pub struct Fixture { + /// This test's private fixture directory, removed when the fixture is dropped. + dir: PathBuf, pub file: PathBuf, /// Raw frames in display order, planes one after another, 16-bit samples little-endian. pub reference: Vec, @@ -36,6 +38,12 @@ pub struct Fixture { pub max_diff: u8, } +impl Drop for Fixture { + fn drop(&mut self) { + let _ = std::fs::remove_dir_all(&self.dir); + } +} + /// Lowest PSNR of a frame decoded within a tolerance, as the MPEG-2 oracle tests require. const MIN_PSNR: f64 = 58.0; @@ -44,11 +52,13 @@ const MIN_PSNR: f64 = 58.0; /// the encoder; a failure with `CRAFT_MEDIA_REQUIRE_ORACLES=1`. pub fn fixture(name: &str, ext: &str, args: &[&str], pix_fmt: &str) -> Option { let ff = craft_media_testkit::ffmpeg()?; - let dir = craft_media_testkit::fixture_subdir("video-track"); + // Tests can generate the same fixture concurrently in separate nextest processes. Give each + // one a private directory so it cannot replace a file another process is reading on Windows. + let dir = craft_media_testkit::private_dir("video-track"); let required = craft_media_testkit::oracles_required(); let file = dir.join(format!("{name}.{ext}")); let raw = dir.join(format!("{name}.{ext}.{pix_fmt}.raw")); - craft_media_testkit::generate_and_report(name, &[file.clone(), raw.clone()], || { + let result = craft_media_testkit::generate_and_report(name, &[file.clone(), raw.clone()], || { if !file.exists() { let tmp = craft_media_testkit::temp_path(&file); let mut cmd = Command::new(&ff); @@ -68,8 +78,12 @@ pub fn fixture(name: &str, ext: &str, args: &[&str], pix_fmt: &str) -> Option`. -use crate::common; +use super::common; /// MD5 (RFC 1321), for comparing with the vectors' checksums. fn md5(data: &[u8]) -> String { diff --git a/crates/video/tests/vp8_encode/main.rs b/crates/video/tests/it/vp8_encode/main.rs similarity index 100% rename from crates/video/tests/vp8_encode/main.rs rename to crates/video/tests/it/vp8_encode/main.rs diff --git a/crates/video/tests/vp9_decode/common/mod.rs b/crates/video/tests/it/vp9_decode/common/mod.rs similarity index 100% rename from crates/video/tests/vp9_decode/common/mod.rs rename to crates/video/tests/it/vp9_decode/common/mod.rs diff --git a/crates/video/tests/vp9_decode/conformance.rs b/crates/video/tests/it/vp9_decode/conformance.rs similarity index 99% rename from crates/video/tests/vp9_decode/conformance.rs rename to crates/video/tests/it/vp9_decode/conformance.rs index cfa42b17b2..84299206cc 100644 --- a/crates/video/tests/vp9_decode/conformance.rs +++ b/crates/video/tests/it/vp9_decode/conformance.rs @@ -1,7 +1,7 @@ //! Bit-exactness against ffmpeg's VP9 decoder on libvpx-vp9 fixtures (skipped when ffmpeg or //! libvpx is absent). -use crate::common; +use super::common; macro_rules! fixture_tests { ($($name:ident),* $(,)?) => { diff --git a/crates/video/tests/vp9_decode/frame.rs b/crates/video/tests/it/vp9_decode/frame.rs similarity index 99% rename from crates/video/tests/vp9_decode/frame.rs rename to crates/video/tests/it/vp9_decode/frame.rs index c8e94db574..fe146c56e3 100644 --- a/crates/video/tests/vp9_decode/frame.rs +++ b/crates/video/tests/it/vp9_decode/frame.rs @@ -1,6 +1,6 @@ //! Conversion of decoded VP9 pictures into `craft_video::frame::VideoFrame`. -use crate::common; +use super::common; use craft_video::frame::{ColorFamily, Samples, VideoFrame}; /// An RGB stream converts to R, G, B. The reference decode is ffmpeg's `gbrp` (G, B, R), so the diff --git a/crates/video/tests/vp9_decode/fuzz_hostile.rs b/crates/video/tests/it/vp9_decode/fuzz_hostile.rs similarity index 100% rename from crates/video/tests/vp9_decode/fuzz_hostile.rs rename to crates/video/tests/it/vp9_decode/fuzz_hostile.rs diff --git a/crates/video/tests/vp9_decode/main.rs b/crates/video/tests/it/vp9_decode/main.rs similarity index 100% rename from crates/video/tests/vp9_decode/main.rs rename to crates/video/tests/it/vp9_decode/main.rs diff --git a/crates/video/tests/vp9_decode/perf.rs b/crates/video/tests/it/vp9_decode/perf.rs similarity index 98% rename from crates/video/tests/vp9_decode/perf.rs rename to crates/video/tests/it/vp9_decode/perf.rs index ac891f8da7..3af94bee6c 100644 --- a/crates/video/tests/vp9_decode/perf.rs +++ b/crates/video/tests/it/vp9_decode/perf.rs @@ -1,7 +1,7 @@ //! Decode speed (ignored by default; run with //! `cargo test --release -p craft-video --features vp9-decode,threads --test vp9_decode perf:: -- --ignored --nocapture`). -use crate::common; +use super::common; use craft_video::vp9::decode::Decoder; use std::time::Instant; diff --git a/crates/video/tests/vp9_decode/robustness.rs b/crates/video/tests/it/vp9_decode/robustness.rs similarity index 99% rename from crates/video/tests/vp9_decode/robustness.rs rename to crates/video/tests/it/vp9_decode/robustness.rs index 27f5bbb342..1cb703c09b 100644 --- a/crates/video/tests/vp9_decode/robustness.rs +++ b/crates/video/tests/it/vp9_decode/robustness.rs @@ -1,6 +1,6 @@ //! Damaged, truncated and random input must never panic or hang (errors are fine). -use crate::common; +use super::common; use craft_video::vp9::decode::Decoder; use std::time::{Duration, Instant}; diff --git a/crates/video/tests/vp9_decode/synthetic.rs b/crates/video/tests/it/vp9_decode/synthetic.rs similarity index 99% rename from crates/video/tests/vp9_decode/synthetic.rs rename to crates/video/tests/it/vp9_decode/synthetic.rs index 5f267ad6ab..5a95a31dcf 100644 --- a/crates/video/tests/vp9_decode/synthetic.rs +++ b/crates/video/tests/it/vp9_decode/synthetic.rs @@ -7,7 +7,7 @@ //! show_existing_frame; //! - show_existing_frame of hidden alt-ref frames and of arbitrary slots. -use crate::common; +use super::common; use std::path::Path;