forge
Explore
Log in

Don't you dare go Hollow

ec-ac3 real_library: allow ffmpeg's trailing truncated frame in sample count

Browse files at this commit

65a1e04243907e37732c81c6d4083ca469e5bd58Ahmet Kaan GümüşParent: 0a54b85
monsters_inc_5.1_448_small.ac3 is 100000 bytes: 55 whole 1792-byte frames plus a 1440-byte stub. ffmpeg 9.0.2 reports 'incomplete frame' and still emits 1536 samples/ch for it (516096 f32 total = 86016/ch, 56 frames); the decoder correctly stops at 55 (506880 total). Truncating the first 55 frames gives ffmpeg 506880 exactly. Test now allows at most one extra frame of ffmpeg output, then compares the common prefix.
crates/ec-ac3/tests/it/real_library.rsmodified+7 -1
@@ -98,7 +98,13 @@ fn fate_ac3_and_eac3_match_ffmpeg() {
9898 for path in files {
9999 let name = path.file_name().unwrap().to_string_lossy().into_owned();
100100 let (ours, decoded_channels) = decode(&path);
101- let theirs = reference(&path);
101+ let mut theirs = reference(&path);
102+ let extra = theirs.len().saturating_sub(ours.len());
103+ assert!(
104+ extra <= 1536 * decoded_channels,
105+ "{name}: ffmpeg has {extra} extra samples, more than one truncated frame"
106+ );
107+ theirs.truncate(ours.len());
102108 assert_eq!(ours.len(), theirs.len(), "{name}: sample count vs ffmpeg");
103109 assert!(!ours.is_empty(), "{name}: nothing decoded");
104110