mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-27 04:38:49 +00:00
Merge pull request #2365 from storytold/perf/2218-video
video: consolidate integration test binaries
This commit is contained in:
@@ -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]]
|
||||
|
||||
+3
-74
@@ -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"
|
||||
|
||||
@@ -56,7 +56,7 @@ let apvc: Vec<u8> = 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<u8> = 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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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`).
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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::*;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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]
|
||||
+1
-1
@@ -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).
|
||||
+1
-1
@@ -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<Spec> {
|
||||
+1
-1
@@ -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";
|
||||
@@ -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;
|
||||
+1
-1
@@ -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};
|
||||
|
||||
+1
-1
@@ -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};
|
||||
|
||||
+1
-1
@@ -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};
|
||||
|
||||
+1
-1
@@ -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),* $(,)?) => {
|
||||
+1
-1
@@ -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};
|
||||
+1
-1
@@ -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};
|
||||
@@ -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;
|
||||
+1
-1
@@ -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;
|
||||
+1
-1
@@ -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::*;
|
||||
+1
-1
@@ -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::*;
|
||||
+1
-1
@@ -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::*;
|
||||
+1
-1
@@ -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`.
|
||||
+1
-1
@@ -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<u8> {
|
||||
+1
-1
@@ -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};
|
||||
+1
-1
@@ -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),* $(,)?) => {
|
||||
+1
-1
@@ -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};
|
||||
@@ -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;
|
||||
+1
-1
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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<u8> {
|
||||
+1
-1
@@ -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};
|
||||
|
||||
@@ -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::*;
|
||||
|
||||
@@ -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::*;
|
||||
|
||||
@@ -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);
|
||||
+1
-1
@@ -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};
|
||||
|
||||
+1
-1
@@ -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};
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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::*;
|
||||
|
||||
@@ -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.
|
||||
@@ -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<u8>,
|
||||
@@ -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<Fixture> {
|
||||
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<Fi
|
||||
.arg(&tmp);
|
||||
craft_media_testkit::run_generator(&mut cmd, &tmp, &raw, required)?;
|
||||
}
|
||||
Some(Fixture { reference: std::fs::read(&raw).unwrap(), file: file.clone(), max_diff: 0 })
|
||||
})
|
||||
Some(Fixture { reference: std::fs::read(&raw).unwrap(), file: file.clone(), max_diff: 0, dir: dir.clone() })
|
||||
});
|
||||
if result.is_none() {
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
/// Whether ffmpeg has `encoder`, without skipping.
|
||||
@@ -1,7 +1,7 @@
|
||||
//! H.264 in MP4 (an `avcC` record, length-prefixed packets), MPEG-TS (Annex B, no configuration)
|
||||
//! and AVI with the parameter sets in the stream header only (an Annex B configuration).
|
||||
|
||||
use crate::common;
|
||||
use super::common;
|
||||
use craft_media::CodecId;
|
||||
use craft_video::{TrackDecoder, VideoError};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! HEVC in MP4 (an `hvcC` record, length-prefixed packets) and MPEG-TS (Annex B, no
|
||||
//! configuration), 8-bit and 10-bit.
|
||||
|
||||
use crate::common;
|
||||
use super::common;
|
||||
use craft_media::CodecId;
|
||||
|
||||
/// Closed GOPs every 12 frames with B-frames, so decoding from a key packet gives every frame
|
||||
@@ -1,7 +1,7 @@
|
||||
//! MPEG-2 video in MPEG-TS (no configuration), and with its sequence header moved from the
|
||||
//! packets into `extradata`.
|
||||
|
||||
use crate::common;
|
||||
use super::common;
|
||||
use craft_media::CodecId;
|
||||
|
||||
/// Closed GOPs every 12 frames with B-frames (ffmpeg's encoder needs scene change detection off
|
||||
@@ -1,6 +1,6 @@
|
||||
//! VP9 in MP4 (a `vpcC` record, which the decoder does not need).
|
||||
|
||||
use crate::common;
|
||||
use super::common;
|
||||
use craft_media::CodecId;
|
||||
|
||||
#[test]
|
||||
@@ -1,7 +1,7 @@
|
||||
//! Bit-exactness against libvpx (through ffmpeg) on generated fixtures covering every coding
|
||||
//! tool: skipped when ffmpeg or its libvpx encoder is absent.
|
||||
|
||||
use crate::common;
|
||||
use super::common;
|
||||
|
||||
fn check(name: &str) {
|
||||
let f = common::fixture(name);
|
||||
@@ -1,6 +1,6 @@
|
||||
//! Damaged, truncated, reordered and random input must never panic (errors are fine).
|
||||
|
||||
use crate::common;
|
||||
use super::common;
|
||||
|
||||
use craft_video::vp8::{Decoder, Error};
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
//! downloaded by the tests; fetch them from
|
||||
//! `https://storage.googleapis.com/downloads.webmproject.org/test_data/libvpx/<name>`.
|
||||
|
||||
use crate::common;
|
||||
use super::common;
|
||||
|
||||
/// MD5 (RFC 1321), for comparing with the vectors' checksums.
|
||||
fn md5(data: &[u8]) -> String {
|
||||
+1
-1
@@ -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),* $(,)?) => {
|
||||
@@ -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
|
||||
@@ -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;
|
||||
+1
-1
@@ -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};
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user