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 commitf9a61726cb6ef876c5358aff255707ba4ce98526Parent: 0a54b855 changed files +24 -48
- shims/opus-rs/src/lib.rs +8 -10
- shims/oxideav-ac3/Cargo.toml +3 -0
- shims/oxideav-ac3/tests/edith_surface.rs +4 -18
- shims/symphonia/Cargo.toml +1 -0
- shims/symphonia/tests/edith_surface.rs +8 -20
shims/opus-rs/src/lib.rsmodified+8 -10
| @@ -374,19 +374,17 @@ mod tests { | ||
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | /// 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. | |
| 382 | 380 | #[test] |
| 383 | 381 | fn slower_input_rates_encode_and_report_their_own_delay() { |
| 384 | 382 | 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), | |
| 390 | 388 | ] { |
| 391 | 389 | let mut enc = OpusEncoder::new(rate, 1, Application::Voip).unwrap(); |
| 392 | 390 | enc.bitrate_bps = 32_000; |
shims/oxideav-ac3/Cargo.tomlmodified+3 -0
| @@ -11,3 +11,6 @@ publish = false | ||
| 11 | 11 | ec-ac3 = { path = "../../crates/ec-ac3", version = "0.1.0" } |
| 12 | 12 | ec-core = { path = "../../crates/ec-core", version = "0.1.0" } |
| 13 | 13 | 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 @@ | ||
| 2 | 2 | //! layout out of the first syncframe's headers, ask the registry for a decoder |
| 3 | 3 | //! folded to that layout, decode, and read the frame back as S16 little-endian |
| 4 | 4 | //! (`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}; | |
| 10 | 5 | |
| 11 | 6 | use oxideav_ac3::{bsi, eac3, register_codecs, syncinfo}; |
| 12 | 7 | use oxideav_core::{CodecId, CodecParameters, CodecRegistry, Decoder, Error, Frame, Packet, TimeBase}; |
| 13 | 8 | |
| 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") | |
| 19 | 11 | } |
| 20 | 12 | |
| 21 | 13 | /// `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() { | ||
| 77 | 69 | ("eac3-5.1-48000.eac3", "eac3", 48_000, 5, 2), |
| 78 | 70 | ("eac3-mono-48000.eac3", "eac3", 48_000, 1, 1), |
| 79 | 71 | ]; |
| 80 | - let mut ran = 0; | |
| 81 | 72 | 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); | |
| 84 | 74 | |
| 85 | 75 | let (sample_rate, nfchans) = header(codec, &data); |
| 86 | 76 | assert_eq!(sample_rate, rate, "{name}: sample rate"); |
| @@ -103,7 +93,6 @@ fn the_replicas_open_path_lands_on_audible_pcm() { | ||
| 103 | 93 | assert_eq!((pcm.len() as u64 / samples.max(1)) as u16, channels_want); |
| 104 | 94 | } |
| 105 | 95 | } |
| 106 | - assert!(ran > 0, "no AC-3 fixtures: run scripts/gen-fixtures.sh"); | |
| 107 | 96 | } |
| 108 | 97 | |
| 109 | 98 | /// 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() { | ||
| 115 | 104 | ("ac3-5.1-48000.ac3", "ac3", Some(2)), |
| 116 | 105 | ("eac3-5.1-48000.eac3", "eac3", Some(2)), |
| 117 | 106 | ]; |
| 118 | - let mut ran = 0; | |
| 119 | 107 | for (name, codec, requested) in cases { |
| 120 | - let Some(data) = fixture(name) else { continue }; | |
| 121 | - ran += 1; | |
| 108 | + let data = fixture(name); | |
| 122 | 109 | let mut frames = Vec::new(); |
| 123 | 110 | let mut pos = 0; |
| 124 | 111 | 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() { | ||
| 147 | 134 | assert_eq!(pcm, reference[..pcm.len()], "{name}: {n} frames, PCM"); |
| 148 | 135 | } |
| 149 | 136 | } |
| 150 | - assert!(ran > 0, "no AC-3 fixtures: run scripts/gen-fixtures.sh"); | |
| 151 | 137 | } |
shims/symphonia/Cargo.tomlmodified+1 -0
| @@ -14,6 +14,7 @@ ec-probe = { path = "../../crates/ec-probe", version = "0.1.0" } | ||
| 14 | 14 | symphonia-core = { path = "../symphonia-core", version = "0.6.0" } |
| 15 | 15 | |
| 16 | 16 | [dev-dependencies] |
| 17 | +ec-testkit.workspace = true | |
| 17 | 18 | symphonia-codec-aac = { path = "../symphonia-codec-aac", version = "0.6.0" } |
| 18 | 19 | ec-vorbis = { path = "../../crates/ec-vorbis", version = "0.1.0" } |
| 19 | 20 | rusty_vorbis = { path = "../rusty_vorbis", version = "0.1.1" } |
shims/symphonia/tests/edith_surface.rsmodified+8 -20
| @@ -6,7 +6,7 @@ | ||
| 6 | 6 | //! shim rather than merely type-checking against it. |
| 7 | 7 | |
| 8 | 8 | use std::fs::File; |
| 9 | -use std::path::{Path, PathBuf}; | |
| 9 | +use std::path::Path; | |
| 10 | 10 | |
| 11 | 11 | use symphonia_codec_aac::AacDecoder; |
| 12 | 12 | use symphonia_core::codecs::CodecParameters; |
| @@ -22,8 +22,8 @@ use symphonia_core::io::MediaSourceStream; | ||
| 22 | 22 | use symphonia_core::meta::MetadataOptions; |
| 23 | 23 | use symphonia_core::units::{Time, TimeBase, Timestamp}; |
| 24 | 24 | |
| 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}")) | |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /// edith's `sym_reader`, verbatim in shape. |
| @@ -138,12 +138,8 @@ fn every_file_opens_describes_and_decodes_through_the_shim() { | ||
| 138 | 138 | ("aac-mka-stereo-48000.mka", "aac", 2), |
| 139 | 139 | ("av-h264-aac-stereo-48000.mkv", "aac", 2), |
| 140 | 140 | ]; |
| 141 | - let mut checked = 0; | |
| 142 | 141 | for (name, codec, channels) in files { |
| 143 | - let path = fixtures().join(name); | |
| 144 | - if !path.exists() { | |
| 145 | - continue; | |
| 146 | - } | |
| 142 | + let path = fixture(name); | |
| 147 | 143 | let mut track = SymTrack::open(&path).unwrap_or_else(|| panic!("{name}: no audio track")); |
| 148 | 144 | assert_eq!(track.codec, codec, "{name}: codec name"); |
| 149 | 145 | assert_eq!(track.channels, channels, "{name}: channels"); |
| @@ -170,10 +166,8 @@ fn every_file_opens_describes_and_decodes_through_the_shim() { | ||
| 170 | 166 | frames * 20 > want * 19, |
| 171 | 167 | "{name}: decoded {frames} of {want} frames" |
| 172 | 168 | ); |
| 173 | - checked += 1; | |
| 174 | 169 | } |
| 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()); | |
| 177 | 171 | } |
| 178 | 172 | |
| 179 | 173 | /// 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() { | ||
| 183 | 177 | #[test] |
| 184 | 178 | fn twenty_seeks_on_one_reader_all_land() { |
| 185 | 179 | 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); | |
| 190 | 181 | let mut track = SymTrack::open(&path).expect("track"); |
| 191 | 182 | let mut decoder = track.decoder(); |
| 192 | 183 | let mut out = Vec::new(); |
| @@ -221,10 +212,7 @@ fn twenty_seeks_on_one_reader_all_land() { | ||
| 221 | 212 | /// stereo. A 5.1 AAC track decodes here, through the AAC shim, as 6 channels. |
| 222 | 213 | #[test] |
| 223 | 214 | 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"); | |
| 228 | 216 | let mut track = SymTrack::open(&path).expect("track"); |
| 229 | 217 | assert_eq!(track.channels, 6); |
| 230 | 218 | let mut decoder = track.decoder(); |
| @@ -289,7 +277,7 @@ fn opus_has_a_decoder_in_the_registry() { | ||
| 289 | 277 | /// header and an ID3v1 tail, so this needs no real file on disk. |
| 290 | 278 | #[test] |
| 291 | 279 | 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"); | |
| 293 | 281 | // A 2 MB ID3v2.3 tag: one oversized `APIC` frame of filler bytes. The |
| 294 | 282 | // probe only needs to skip past the tag's declared size, so the frame |
| 295 | 283 | // body's content does not matter. |