From 138d2a4d5573379b5dde93a79e5e80c858cfe23a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Fri, 14 Aug 2026 13:15:05 +0300 Subject: [PATCH] test(h265): let ffmpeg check the encoder's own picture hash -err_detect crccheck makes the decoder verify the MD5 SEI against what it decoded, plane by plane. It is the one oracle in this suite that does not depend on any other part of this crate being right. --- crates/ec-h265/tests/conformance.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/crates/ec-h265/tests/conformance.rs b/crates/ec-h265/tests/conformance.rs index da01955d..c83fa4f3 100644 --- a/crates/ec-h265/tests/conformance.rs +++ b/crates/ec-h265/tests/conformance.rs @@ -131,6 +131,35 @@ fn ffmpeg_decodes_bit_exactly_at_every_shape() { } } +#[test] +fn ffmpeg_verifies_the_decoded_picture_hash() { + // The MD5 SEI is the encoder's claim about its own reconstruction; ffmpeg's + // decoder checks that claim against what it decoded when asked to. This is + // the one oracle that does not depend on this crate being right about + // anything except the hash itself. + if !have_ffmpeg() { + eprintln!("skipping: ffmpeg not installed"); + return; + } + let (_, coded) = encode(352, 288, 30); + let path = write_au("hash-352x288", &coded); + let output = Command::new("ffmpeg") + .args(["-v", "debug", "-err_detect", "crccheck", "-y", "-i"]) + .arg(&path) + .args(["-f", "null", "-"]) + .output() + .expect("run ffmpeg"); + let log = String::from_utf8_lossy(&output.stderr).to_string(); + let checks: Vec<&str> = log + .lines() + .filter(|line| line.contains("Verifying checksum")) + .collect(); + assert!(!checks.is_empty(), "ffmpeg checked no picture hash: {log}"); + for line in checks { + assert_eq!(line.matches("correct").count(), 3, "hash mismatch: {line}"); + } +} + #[test] fn vaapi_hardware_decodes_the_stream() { // The other half of "it decodes": a GPU decoder is a different