forge
Explore
Log in

Don't you dare go Hollow

Shim tests read deterministic fixtures through ec_testkit::fixture (no silent skip, no gen-fixtures.sh); opus-rs look-ahead expectations follow libopus OPUS_GET_LOOKAHEAD = Fs/400 + Fs/250 per input rate (312 at 48 kHz, 52/78/104/156 at 8/12/16/24 kHz, all 312 at 48 kHz on the pinned ffmpeg 9.0.2 libopus, which encodes at 48 kHz)

Browse files at this commit

f9a61726cb6ef876c5358aff255707ba4ce98526Ahmet Kaan GümüşParent: 0a54b85
shims/opus-rs/src/lib.rsmodified+8 -10
@@ -374,19 +374,17 @@ mod tests {
374374 }
375375
376376 /// Input below 48 kHz, which the shim used to refuse outright, and the
377- /// `look_ahead` that goes with it. 48/24 kHz VoIP at 32 kbps run
378- /// hybrid (SWB/FB), so the delay is CELT's 120-sample overlap, scaled;
379- /// 16 kHz and below cap the bandwidth at WB or narrower, where hybrid
380- /// does not exist, so dispatch takes SILK and the delay is the SILK
381- /// resampler look-ahead (WB 50 / MB 54 / NB 58 at 48 kHz), scaled.
377+ /// `look_ahead` that goes with it: libopus's `OPUS_GET_LOOKAHEAD`,
378+ /// `Fs/400 + Fs/250` (120 + 192 at 48 kHz), in the input rate's samples.
379+ /// ffmpeg's libopus encoder runs at 48 kHz and reports 312 for every rate.
382380 #[test]
383381 fn slower_input_rates_encode_and_report_their_own_delay() {
384382 for &(rate, frame, look) in &[
385- (48_000i32, 960usize, 120usize),
386- (24_000, 480, 60),
387- (16_000, 320, 50 / 3),
388- (12_000, 240, 54 / 4),
389- (8_000, 160, 58 / 6),
383+ (48_000i32, 960usize, 312usize),
384+ (24_000, 480, 156),
385+ (16_000, 320, 104),
386+ (12_000, 240, 78),
387+ (8_000, 160, 52),
390388 ] {
391389 let mut enc = OpusEncoder::new(rate, 1, Application::Voip).unwrap();
392390 enc.bitrate_bps = 32_000;
shims/oxideav-ac3/Cargo.tomlmodified+3 -0
@@ -11,3 +11,6 @@ publish = false
1111 ec-ac3 = { path = "../../crates/ec-ac3", version = "0.1.0" }
1212 ec-core = { path = "../../crates/ec-core", version = "0.1.0" }
1313 oxideav-core = { path = "../oxideav-core", version = "0.1.34" }
14+
15+[dev-dependencies]
16+ec-testkit.workspace = true
shims/oxideav-ac3/tests/edith_surface.rsmodified+4 -18
@@ -2,20 +2,12 @@
22 //! layout out of the first syncframe's headers, ask the registry for a decoder
33 //! folded to that layout, decode, and read the frame back as S16 little-endian
44 //! (`engine/src/audio.rs:1954-2170`).
5-//!
6-//! Missing fixtures skip rather than fail, as the `ec-ac3` matrix does;
7-//! `scripts/gen-fixtures.sh` writes them.
8-
9-use std::path::{Path, PathBuf};
105
116 use oxideav_ac3::{bsi, eac3, register_codecs, syncinfo};
127 use oxideav_core::{CodecId, CodecParameters, CodecRegistry, Decoder, Error, Frame, Packet, TimeBase};
138
14-fn fixture(name: &str) -> Option<Vec<u8>> {
15- let path: PathBuf = Path::new(env!("CARGO_MANIFEST_DIR"))
16- .join("../../fixtures/audio")
17- .join(name);
18- std::fs::read(path).ok()
9+fn fixture(name: &str) -> Vec<u8> {
10+ std::fs::read(ec_testkit::fixture(&format!("audio/{name}"))).expect("fixture")
1911 }
2012
2113 /// `engine/src/audio.rs:2130` — a fresh decoder out of a fresh registry.
@@ -77,10 +69,8 @@ fn the_replicas_open_path_lands_on_audible_pcm() {
7769 ("eac3-5.1-48000.eac3", "eac3", 48_000, 5, 2),
7870 ("eac3-mono-48000.eac3", "eac3", 48_000, 1, 1),
7971 ];
80- let mut ran = 0;
8172 for (name, codec, rate, nfchans_want, channels_want) in cases {
82- let Some(data) = fixture(name) else { continue };
83- ran += 1;
73+ let data = fixture(name);
8474
8575 let (sample_rate, nfchans) = header(codec, &data);
8676 assert_eq!(sample_rate, rate, "{name}: sample rate");
@@ -103,7 +93,6 @@ fn the_replicas_open_path_lands_on_audible_pcm() {
10393 assert_eq!((pcm.len() as u64 / samples.max(1)) as u16, channels_want);
10494 }
10595 }
106- assert!(ran > 0, "no AC-3 fixtures: run scripts/gen-fixtures.sh");
10796 }
10897
10998 /// A packet holding two or three syncframes, handed over the registry's
@@ -115,10 +104,8 @@ fn a_packet_of_two_and_three_syncframes_decodes_to_its_frames() {
115104 ("ac3-5.1-48000.ac3", "ac3", Some(2)),
116105 ("eac3-5.1-48000.eac3", "eac3", Some(2)),
117106 ];
118- let mut ran = 0;
119107 for (name, codec, requested) in cases {
120- let Some(data) = fixture(name) else { continue };
121- ran += 1;
108+ let data = fixture(name);
122109 let mut frames = Vec::new();
123110 let mut pos = 0;
124111 while let Ok(len) = ec_ac3::frame_size(&data[pos..]) {
@@ -147,5 +134,4 @@ fn a_packet_of_two_and_three_syncframes_decodes_to_its_frames() {
147134 assert_eq!(pcm, reference[..pcm.len()], "{name}: {n} frames, PCM");
148135 }
149136 }
150- assert!(ran > 0, "no AC-3 fixtures: run scripts/gen-fixtures.sh");
151137 }
shims/symphonia/Cargo.tomlmodified+1 -0
@@ -14,6 +14,7 @@ ec-probe = { path = "../../crates/ec-probe", version = "0.1.0" }
1414 symphonia-core = { path = "../symphonia-core", version = "0.6.0" }
1515
1616 [dev-dependencies]
17+ec-testkit.workspace = true
1718 symphonia-codec-aac = { path = "../symphonia-codec-aac", version = "0.6.0" }
1819 ec-vorbis = { path = "../../crates/ec-vorbis", version = "0.1.0" }
1920 rusty_vorbis = { path = "../rusty_vorbis", version = "0.1.1" }
shims/symphonia/tests/edith_surface.rsmodified+8 -20
@@ -6,7 +6,7 @@
66 //! shim rather than merely type-checking against it.
77
88 use std::fs::File;
9-use std::path::{Path, PathBuf};
9+use std::path::Path;
1010
1111 use symphonia_codec_aac::AacDecoder;
1212 use symphonia_core::codecs::CodecParameters;
@@ -22,8 +22,8 @@ use symphonia_core::io::MediaSourceStream;
2222 use symphonia_core::meta::MetadataOptions;
2323 use symphonia_core::units::{Time, TimeBase, Timestamp};
2424
25-fn fixtures() -> PathBuf {
26- Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/audio")
25+fn fixture(name: &str) -> std::path::PathBuf {
26+ ec_testkit::fixture(&format!("audio/{name}"))
2727 }
2828
2929 /// edith's `sym_reader`, verbatim in shape.
@@ -138,12 +138,8 @@ fn every_file_opens_describes_and_decodes_through_the_shim() {
138138 ("aac-mka-stereo-48000.mka", "aac", 2),
139139 ("av-h264-aac-stereo-48000.mkv", "aac", 2),
140140 ];
141- let mut checked = 0;
142141 for (name, codec, channels) in files {
143- let path = fixtures().join(name);
144- if !path.exists() {
145- continue;
146- }
142+ let path = fixture(name);
147143 let mut track = SymTrack::open(&path).unwrap_or_else(|| panic!("{name}: no audio track"));
148144 assert_eq!(track.codec, codec, "{name}: codec name");
149145 assert_eq!(track.channels, channels, "{name}: channels");
@@ -170,10 +166,8 @@ fn every_file_opens_describes_and_decodes_through_the_shim() {
170166 frames * 20 > want * 19,
171167 "{name}: decoded {frames} of {want} frames"
172168 );
173- checked += 1;
174169 }
175- assert!(checked > 0, "no fixtures — run scripts/gen-fixtures.sh");
176- eprintln!("edith's symphonia surface: {checked} files opened and decoded");
170+ eprintln!("edith's symphonia surface: {} files opened and decoded", files.len());
177171 }
178172
179173 /// The defect this shim exists to fix: the incumbent's Matroska seek is
@@ -183,10 +177,7 @@ fn every_file_opens_describes_and_decodes_through_the_shim() {
183177 #[test]
184178 fn twenty_seeks_on_one_reader_all_land() {
185179 for name in ["av-h264-aac-stereo-48000.mkv", "aac-mka-stereo-48000.mka"] {
186- let path = fixtures().join(name);
187- if !path.exists() {
188- continue;
189- }
180+ let path = fixture(name);
190181 let mut track = SymTrack::open(&path).expect("track");
191182 let mut decoder = track.decoder();
192183 let mut out = Vec::new();
@@ -221,10 +212,7 @@ fn twenty_seeks_on_one_reader_all_land() {
221212 /// stereo. A 5.1 AAC track decodes here, through the AAC shim, as 6 channels.
222213 #[test]
223214 fn multichannel_aac_decodes_rather_than_being_refused() {
224- let path = fixtures().join("aac-mp4-5.1-44100.mp4");
225- if !path.exists() {
226- return;
227- }
215+ let path = fixture("aac-mp4-5.1-44100.mp4");
228216 let mut track = SymTrack::open(&path).expect("track");
229217 assert_eq!(track.channels, 6);
230218 let mut decoder = track.decoder();
@@ -289,7 +277,7 @@ fn opus_has_a_decoder_in_the_registry() {
289277 /// header and an ID3v1 tail, so this needs no real file on disk.
290278 #[test]
291279 fn cover_art_and_id3v1_tail_do_not_stop_the_probe() {
292- let raw = std::fs::read(fixtures().join("mp3-stereo-48000.mp3")).expect("fixture mp3");
280+ let raw = std::fs::read(fixture("mp3-stereo-48000.mp3")).expect("fixture mp3");
293281 // A 2 MB ID3v2.3 tag: one oversized `APIC` frame of filler bytes. The
294282 // probe only needs to skip past the tag's declared size, so the frame
295283 // body's content does not matter.