forge
Explore
Log in

Don't you dare go Hollow

The hardware proxy is decoded, not just counted

Browse files at this commit

79f2baca651d027895088e437cbe8a240c620089Ahmet Kaan GümüşParent: 9a188c5
  • test
    • the hardware proxy is decoded, not just counted
Show full message
🧪 test(engine): the hardware proxy is decoded, not just counted

`a_hardware_proxy_is_every_frame_a_starting_point_too` counted `demux::sync_points` and never read a picture, so it stayed green through 150 of 150 access units no decoder would accept. It now decodes every picture back through the engine, refuses an empty one, and lets ffmpeg read the file with `-v error` and say nothing.
crates/engine/tests/export.rsmodified+34 -0
@@ -101,6 +101,20 @@ fn decode_all(path: &Path) -> Vec<Vec<u8>> {
101 frames.into_iter().map(|frame| frame.bgra).collect()101 frames.into_iter().map(|frame| frame.bgra).collect()
102 }102 }
103 103
104+/// What an outside decoder complains about while reading every packet of
105+/// `path`: empty when it read the file clean. `None` where ffmpeg is not
106+/// installed, which is a skip rather than a failure -- the same posture the
107+/// colour tests take.
108+fn ffmpeg_complaints(path: &Path) -> Option<String> {
109+ let said = std::process::Command::new("ffmpeg")
110+ .args(["-v", "error", "-i"])
111+ .arg(path)
112+ .args(["-f", "null", "-"])
113+ .output()
114+ .ok()?;
115+ Some(String::from_utf8_lossy(&said.stderr).trim().to_string())
116+}
117+
104 /// One frame of `path` by absolute index.118 /// One frame of `path` by absolute index.
105 fn frame_at(path: &Path, index: u32) -> Vec<u8> {119 fn frame_at(path: &Path, index: u32) -> Vec<u8> {
106 let (_, frames, _) = DecodeSession::open_at(path, index).expect("open source");120 let (_, frames, _) = DecodeSession::open_at(path, index).expect("open source");
@@ -1042,6 +1056,26 @@ fn a_hardware_proxy_is_every_frame_a_starting_point_too() {
1042 syncs.len(),1056 syncs.len(),
1043 meta.frame_count1057 meta.frame_count
1044 );1058 );
1059+ // Counting starting points is not reading the file: a proxy whose every
1060+ // access unit is garbage counts perfectly. It shipped that way -- the SPS
1061+ // carried a wrapped `log2_max_frame_num_minus4` of 252 and every decoder
1062+ // refused the stream, while this test stayed green. So decode it, all of
1063+ // it, and let an outside decoder say the same.
1064+ let frames = decode_all(&made);
1065+ println!("decoded back {} of {} pictures", frames.len(), meta.frame_count);
1066+ assert_eq!(
1067+ frames.len() as u32,
1068+ meta.frame_count,
1069+ "the proxy demuxes but does not decode"
1070+ );
1071+ assert!(
1072+ frames.iter().all(|f| f.iter().any(|&b| b != 0)),
1073+ "a decoded picture came back empty"
1074+ );
1075+ match ffmpeg_complaints(&made) {
1076+ Some(said) => assert!(said.is_empty(), "ffmpeg read the proxy and said:\n{said}"),
1077+ None => eprintln!("no ffmpeg: skipping the outside decoder's word on the proxy"),
1078+ }
1045 std::fs::remove_file(&out).expect("clean the cache entry up");1079 std::fs::remove_file(&out).expect("clean the cache entry up");
1046 }1080 }
1047 1081