forge
Explore
Log in

Don't you dare go Hollow

edith

Clone
★ 0

0 watching0 forksRust18.3 MiBff99ad6Tahinli6 days ago1055 commits

probe_refusal.rs57 lines, 2.2 KiBHistoryRawDownload
1//! The chroma and depth edith does not decode are refused at probe, by name, before
2//! anything is exported: `Demuxer::open` (what the probe and import read) and
3//! `decode::probe` (what a front-end asks for the decoder) say the same words.
4//!
5//! One case per format, each with the conversion that makes the file usable.
6//! AV1 4:2:2, 4:4:4 and 12-bit, and HEVC 4:2:2 at 10-bit, are carried now, so
7//! they probe clean.
8//!
9//! ```text
10//! cargo test -p engine --release --test probe_refusal
11//! ```
12
13use std::path::PathBuf;
14use std::process::Command;
15
16use engine::decode::probe;
17use engine::demux::Demuxer;
18use engine::scratch::Scratch;
19
20fn asset(name: &str) -> PathBuf {
21 PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../assets").join(name)
22}
23
24/// A 10-bit RExt 4:2:2 HEVC clip (`hvcC` chroma 2, depth 10), encoded with ffmpeg's
25/// libx265 into a scratch directory. `assets/` is gitignored, so the fixture the
26/// gen script writes is not on every checkout; the test must not depend on it.
27fn hevc_422_10_clip() -> Scratch {
28 let clip = Scratch::file("probe_hevc422_10", "mp4");
29 let out = Command::new("ffmpeg")
30 .args(["-v", "error", "-y", "-f", "lavfi", "-i"])
31 .arg("testsrc2=size=64x64:rate=30:duration=0.1")
32 .args(["-frames:v", "3", "-c:v", "libx265", "-pix_fmt", "yuv422p10le"])
33 .args(["-x265-params", "log-level=error"])
34 .arg(&*clip)
35 .output()
36 .expect("ffmpeg runs");
37 assert!(out.status.success(), "ffmpeg: {}", String::from_utf8_lossy(&out.stderr));
38 clip
39}
40
41#[test]
42fn av1_422_444_and_12_bit_open_at_probe() {
43 // Carried since the software seat averages their chroma to 4:2:0 and
44 // narrows 12 bits, so the probe finds nothing to refuse.
45 for name in ["test_av1_422.mkv", "test_av1_444.mkv", "test_av1_12bit.mkv"] {
46 probe(&asset(name)).unwrap_or_else(|e| panic!("{name}: {e}"));
47 }
48}
49
50#[test]
51fn hevc_422_10_bit_opens_at_probe() {
52 // Carried since the seat takes 4:2:2 (chroma averaged to 4:2:0 on the way in),
53 // so the probe finds nothing to refuse and names the software seat.
54 let clip = hevc_422_10_clip();
55 Demuxer::open(&clip).expect("a 10-bit 4:2:2 HEVC file opens");
56 probe(&clip).expect("and probes");
57}