DEBT #64 — prove AC-3 opens out of a standalone .mka
Browse files at this commitba541e90b2a6a5f1a985f54368427394e94b61eaParent: 9dc7454- test
- DEBT #64 — prove AC-3 opens out of a standalone .mka
2 changed files +30 -0
crates/engine/tests/audio_files.rsmodified+23 -0
| @@ -110,6 +110,29 @@ fn every_container_decodes_the_same_three_second_tone() { | |||
| 110 | } | 110 | } |
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | +/// DEBT #64: an AC-3 soundtrack ripped to its own `.mka`, with no video track | ||
| 114 | +/// at all. `crate::demux::is_matroska` already admits `.mka` (it has since | ||
| 115 | +/// 810ded2, 2026-08-12), so `Track::open` already takes this file down the | ||
| 116 | +/// same [`MkvAc3Track`] door `test_ac3.mkv` uses -- the debt's routing gap was | ||
| 117 | +/// already closed, this was just never proven by a fixture. If `is_matroska` | ||
| 118 | +/// ever lost `.mka` again, this file would fall through to `SymTrack`, whose | ||
| 119 | +/// `mkv` reader has no AC-3 decoder, and `decode` below would panic on "the | ||
| 120 | +/// fixture has audio". 2 s of 440 Hz at 44.1k stereo, unpulsed (a plain sine, | ||
| 121 | +/// not the CONTAINERS envelope), so a non-silent sample anywhere in the | ||
| 122 | +/// middle is enough. | ||
| 123 | +#[test] | ||
| 124 | +fn an_ac3_track_with_no_picture_opens_out_of_an_mka() { | ||
| 125 | + let (rate, channels, samples) = decode(&asset("test_ac3.mka")); | ||
| 126 | + assert_eq!((rate, channels), (44100, 2), "test_ac3.mka"); | ||
| 127 | + let secs = samples.len() as f64 / f64::from(rate) / f64::from(channels); | ||
| 128 | + assert!((secs - 2.0).abs() < 0.2, "test_ac3.mka: {secs:.3} s, want 2.0"); | ||
| 129 | + let mid = samples.len() / 2; | ||
| 130 | + let peak = samples[mid..][..channels as usize * 64] | ||
| 131 | + .iter() | ||
| 132 | + .fold(0.0f32, |peak, s| peak.max(s.abs())); | ||
| 133 | + assert!(peak > 0.01, "test_ac3.mka: decoded to silence, peak {peak}"); | ||
| 134 | +} | ||
| 135 | + | ||
| 113 | /// The length a placement is built from, which is the only frame count a file | 136 | /// The length a placement is built from, which is the only frame count a file |
| 114 | /// with no picture has. | 137 | /// with no picture has. |
| 115 | #[test] | 138 | #[test] |
scripts/gen_fixtures.shmodified+7 -0
| @@ -489,6 +489,13 @@ ffmpeg -y -f lavfi -i "sine=frequency=440:duration=3:sample_rate=48000" \ | |||
| 489 | -f lavfi -i "anullsrc=r=48000:cl=quad:d=3" \ | 489 | -f lavfi -i "anullsrc=r=48000:cl=quad:d=3" \ |
| 490 | -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]" \ | 490 | -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]" \ |
| 491 | -map "[a]" -c:a libopus -b:a 320k assets/test_opus_71.mka | 491 | -map "[a]" -c:a libopus -b:a 320k assets/test_opus_71.mka |
| 492 | +# ...and standalone AC-3 in an `.mka`: the same syntax `test_ac3.mkv` carries, | ||
| 493 | +# with no picture at all, which is DEBT #64's shape -- an AC-3 soundtrack | ||
| 494 | +# ripped to its own Matroska file rather than left beside a video track. Read | ||
| 495 | +# through the same [`MkvAc3Track`] door `.mkv` uses (`crate::demux::is_matroska` | ||
| 496 | +# admits `.mka`), not symphonia, which has no AC-3 decoder. | ||
| 497 | +ffmpeg -y -f lavfi -i "sine=frequency=440:duration=2:sample_rate=44100" \ | ||
| 498 | + -c:a ac3 -b:a 192k -ac 2 assets/test_ac3.mka | ||
| 492 | # Still-image fixture: the source with a picture and no timeline in it. Two | 499 | # Still-image fixture: the source with a picture and no timeline in it. Two |
| 493 | # bands rather than one colour, so a test can tell top from bottom (a flipped | 500 | # bands rather than one colour, so a test can tell top from bottom (a flipped |
| 494 | # decode) and red from blue (a swapped channel order); 640x360, which is 16:9 | 501 | # decode) and red from blue (a swapped channel order); 640x360, which is 16:9 |