forge
Explore
Log in

Don't you dare go Hollow

Let ffmpeg check the encoder's own picture hash

Browse files at this commit

138d2a4d5573379b5dde93a79e5e80c858cfe23aAhmet Kaan GümüşParent: 4d59579
  • test
    • let ffmpeg check the encoder's own picture hash
Show full message
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.rsmodified+29 -0
@@ -131,6 +131,35 @@ fn ffmpeg_decodes_bit_exactly_at_every_shape() {
131131 }
132132 }
133133
134+#[test]
135+fn ffmpeg_verifies_the_decoded_picture_hash() {
136+ // The MD5 SEI is the encoder's claim about its own reconstruction; ffmpeg's
137+ // decoder checks that claim against what it decoded when asked to. This is
138+ // the one oracle that does not depend on this crate being right about
139+ // anything except the hash itself.
140+ if !have_ffmpeg() {
141+ eprintln!("skipping: ffmpeg not installed");
142+ return;
143+ }
144+ let (_, coded) = encode(352, 288, 30);
145+ let path = write_au("hash-352x288", &coded);
146+ let output = Command::new("ffmpeg")
147+ .args(["-v", "debug", "-err_detect", "crccheck", "-y", "-i"])
148+ .arg(&path)
149+ .args(["-f", "null", "-"])
150+ .output()
151+ .expect("run ffmpeg");
152+ let log = String::from_utf8_lossy(&output.stderr).to_string();
153+ let checks: Vec<&str> = log
154+ .lines()
155+ .filter(|line| line.contains("Verifying checksum"))
156+ .collect();
157+ assert!(!checks.is_empty(), "ffmpeg checked no picture hash: {log}");
158+ for line in checks {
159+ assert_eq!(line.matches("correct").count(), 3, "hash mismatch: {line}");
160+ }
161+}
162+
134163 #[test]
135164 fn vaapi_hardware_decodes_the_stream() {
136165 // The other half of "it decodes": a GPU decoder is a different