From ba541e90b2a6a5f1a985f54368427394e94b61ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Thu, 27 Aug 2026 02:41:30 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20test(engine):=20DEBT=20#64=20?= =?UTF-8?q?=E2=80=94=20prove=20AC-3=20opens=20out=20of=20a=20standalone=20?= =?UTF-8?q?.mka?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit crate::demux::is_matroska already admits .mka (since 810ded2), so Track::open already routes an AC-3/E-AC-3 .mka through the same MkvAc3Track door test_ac3.mkv uses -- the debt's routing gap was already closed in code, just never proven by a fixture or a test. Adds test_ac3.mka (2s 440Hz sine, ac3, 2ch 44100) to gen_fixtures.sh and a test in audio_files.rs asserting it decodes non-silent stereo audio at the right rate. --- crates/engine/tests/audio_files.rs | 23 +++++++++++++++++++++++ scripts/gen_fixtures.sh | 7 +++++++ 2 files changed, 30 insertions(+) diff --git a/crates/engine/tests/audio_files.rs b/crates/engine/tests/audio_files.rs index 2484850..2c2403e 100644 --- a/crates/engine/tests/audio_files.rs +++ b/crates/engine/tests/audio_files.rs @@ -110,6 +110,29 @@ fn every_container_decodes_the_same_three_second_tone() { } } +/// DEBT #64: an AC-3 soundtrack ripped to its own `.mka`, with no video track +/// at all. `crate::demux::is_matroska` already admits `.mka` (it has since +/// 810ded2, 2026-08-12), so `Track::open` already takes this file down the +/// same [`MkvAc3Track`] door `test_ac3.mkv` uses -- the debt's routing gap was +/// already closed, this was just never proven by a fixture. If `is_matroska` +/// ever lost `.mka` again, this file would fall through to `SymTrack`, whose +/// `mkv` reader has no AC-3 decoder, and `decode` below would panic on "the +/// fixture has audio". 2 s of 440 Hz at 44.1k stereo, unpulsed (a plain sine, +/// not the CONTAINERS envelope), so a non-silent sample anywhere in the +/// middle is enough. +#[test] +fn an_ac3_track_with_no_picture_opens_out_of_an_mka() { + let (rate, channels, samples) = decode(&asset("test_ac3.mka")); + assert_eq!((rate, channels), (44100, 2), "test_ac3.mka"); + let secs = samples.len() as f64 / f64::from(rate) / f64::from(channels); + assert!((secs - 2.0).abs() < 0.2, "test_ac3.mka: {secs:.3} s, want 2.0"); + let mid = samples.len() / 2; + let peak = samples[mid..][..channels as usize * 64] + .iter() + .fold(0.0f32, |peak, s| peak.max(s.abs())); + assert!(peak > 0.01, "test_ac3.mka: decoded to silence, peak {peak}"); +} + /// The length a placement is built from, which is the only frame count a file /// with no picture has. #[test] diff --git a/scripts/gen_fixtures.sh b/scripts/gen_fixtures.sh index 1b4c5a2..f5048f9 100755 --- a/scripts/gen_fixtures.sh +++ b/scripts/gen_fixtures.sh @@ -489,6 +489,13 @@ ffmpeg -y -f lavfi -i "sine=frequency=440:duration=3:sample_rate=48000" \ -f lavfi -i "anullsrc=r=48000:cl=quad:d=3" \ -filter_complex "[0:a][1:a][2:a][3:a][4:a]join=inputs=5:channel_layout=7.1:map=0.0-FL|4.0-FR|1.0-FC|2.0-LFE|4.1-BL|4.2-BR|4.3-SL|3.0-SR[a]" \ -map "[a]" -c:a libopus -b:a 320k assets/test_opus_71.mka +# ...and standalone AC-3 in an `.mka`: the same syntax `test_ac3.mkv` carries, +# with no picture at all, which is DEBT #64's shape -- an AC-3 soundtrack +# ripped to its own Matroska file rather than left beside a video track. Read +# through the same [`MkvAc3Track`] door `.mkv` uses (`crate::demux::is_matroska` +# admits `.mka`), not symphonia, which has no AC-3 decoder. +ffmpeg -y -f lavfi -i "sine=frequency=440:duration=2:sample_rate=44100" \ + -c:a ac3 -b:a 192k -ac 2 assets/test_ac3.mka # Still-image fixture: the source with a picture and no timeline in it. Two # bands rather than one colour, so a test can tell top from bottom (a flipped # decode) and red from blue (a swapped channel order); 640x360, which is 16:9