forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits

synth_parity.rs52 lines, 1.9 KiBHistoryRawDownload
1#![allow(clippy::needless_range_loop, clippy::field_reassign_with_default, clippy::too_many_arguments, clippy::type_complexity)]
2//! Differential test: random-syntax MPEG-2 streams (field pictures, dual
3//! prime, 16x8, ...) decoded by us and by ffmpeg must agree byte for byte.
4
5mod common;
6use common::synth::{SynthCfg, generate};
7use common::*;
8
9fn run_one(tag: &str, cfg: &SynthCfg, pix: &str) -> Result<usize, String> {
10 let dir = scratch(tag);
11 let es = generate(cfg);
12 let path = dir.join("syn.m2v");
13 std::fs::write(&path, &es).map_err(|e| e.to_string())?;
14 compare(tag, &path, pix, &[])
15}
16
17#[test]
18fn 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);
25 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();
27 let mut failures = Vec::new();
28 for i in 0..n {
29 let seed = base + i;
30 let cfg = SynthCfg {
31 mb_w: 3 + (seed % 3) as usize,
32 mb_h: 2 + 2 * ((seed / 3) % 2) as usize,
33 chroma422: seed % 5 == 4,
34 progressive_sequence: seed % 7 == 6,
35 frames: 6,
36 seed,
37 fields: heavy || std::env::var_os("EC_SYNTH_FIELDS").is_some(),
38 heavy,
39 load_matrices: seed.is_multiple_of(2),
40 };
41 let pix = if cfg.chroma422 { "yuv422p" } else { "yuv420p" };
42 let tag = format!("syn{seed}");
43 match run_one(&tag, &cfg, pix) {
44 Ok(n) => eprintln!("OK {tag} ({n} frames)"),
45 Err(e) => {
46 eprintln!("FAIL {tag}: {e}");
47 failures.push(seed);
48 }
49 }
50 }
51 assert!(failures.is_empty(), "mismatching seeds: {failures:?}");
52}