diff --git a/.config/nextest.toml b/.config/nextest.toml new file mode 100644 index 00000000..17a7cb3f --- /dev/null +++ b/.config/nextest.toml @@ -0,0 +1,18 @@ +# Keep wall-clock performance assertions from sharing CPUs with other nextest jobs. +# These tests are regression tripwires, not throughput benchmarks under load. + +[[profile.default.overrides]] +filter = 'package(ec-opus) & (test(decode_speed) | test(encode_speed))' +threads-required = "num-test-threads" + +[[profile.default.overrides]] +filter = 'package(ec-aac) & test(five_one_decodes_faster_than_realtime)' +threads-required = "num-test-threads" + +[[profile.default.overrides]] +filter = 'package(ec-h265) & (test(intra_1080p_beats_the_incumbent_on_twelve_threads) | test(ctb_32_is_the_faster_tree_at_1080p))' +threads-required = "num-test-threads" + +[[profile.default.overrides]] +filter = 'package(ec-hw) & (test(ten_bit_4k_frame_path_is_realtime) | test(p010_zero_copy_encode_is_realtime))' +threads-required = "num-test-threads" diff --git a/crates/ec-aac/src/decode.rs b/crates/ec-aac/src/decode.rs index 2d636189..68e86377 100644 --- a/crates/ec-aac/src/decode.rs +++ b/crates/ec-aac/src/decode.rs @@ -27,7 +27,7 @@ const INTENSITY_HCB: u8 = 15; const SF_OFFSET: i32 = 100; /// The dequantiser works in the standard's own units, where full scale is /// 2^16; the public API speaks the usual +/-1 float range. Checked against a -/// reference decode in `adts_fixtures_match_ffmpeg_per_channel`, which compares +/// reference decode in `adts_fixtures_match_the oracle_per_channel`, which compares /// amplitudes and not just shape. pub(crate) const OUTPUT_SCALE: f32 = 1.0 / 65536.0; /// The longest TNS filter AAC-LC allows (long blocks; short blocks stop at 7). diff --git a/crates/ec-aac/src/sbr_chain.rs b/crates/ec-aac/src/sbr_chain.rs index 44fb7d29..222ea78a 100644 --- a/crates/ec-aac/src/sbr_chain.rs +++ b/crates/ec-aac/src/sbr_chain.rs @@ -442,7 +442,7 @@ impl SbrChain { qmfdump_energies("post_patch", tables.kx as usize, &hf); } let (env_energy, noise_energy) = - sbr_env::dequantize_frame(&header, &data.channels, ch, coupling); + sbr_env::dequantize_frame(&data.channels, ch, coupling); // sbr_env::adjust works in QMF-slot units; the parsed borders // are in the coarser envelope-time-slot units (see RATE above). let scaled = SbrChannel { @@ -470,8 +470,8 @@ impl SbrChain { v }) .collect(); - for m in 0..m_max { - state.hf_tail[m] = hf[m][num_slots.saturating_sub(HF_ADJ)..].to_vec(); + for (m, band) in hf.iter().enumerate().take(m_max) { + state.hf_tail[m] = band[num_slots.saturating_sub(HF_ADJ)..].to_vec(); } sbr_env::adjust( &mut xh, @@ -490,12 +490,12 @@ impl SbrChain { let i_temp = state.y_carry.first().map(Vec::len).unwrap_or(0).min(num_slots); let t_end = (scaled.t_env.last().copied().unwrap_or(0).max(0) as usize).min(xh[0].len()); let mut hf: Vec>> = vec![vec![Complex::ZERO; num_slots]; m_max]; - for m in 0..m_max { - for i in 0..i_temp { - hf[m][i] = state.y_carry[m][i]; + for (m, band) in hf.iter_mut().enumerate().take(m_max) { + for (i, slot) in band.iter_mut().enumerate().take(i_temp) { + *slot = state.y_carry[m][i]; } - for i in i_temp..num_slots { - hf[m][i] = xh[m][i]; + for (i, slot) in band.iter_mut().enumerate().take(num_slots).skip(i_temp) { + *slot = xh[m][i]; } } state.y_carry = (0..m_max) diff --git a/crates/ec-aac/src/sbr_env.rs b/crates/ec-aac/src/sbr_env.rs index 0f01f483..87b7144e 100644 --- a/crates/ec-aac/src/sbr_env.rs +++ b/crates/ec-aac/src/sbr_env.rs @@ -75,7 +75,6 @@ pub fn dequant_noise_pair(q0_raw: i32, pan_raw: i32) -> (f64, f64) { /// de-mixing through [`dequant_pair`]/[`dequant_noise_pair`] when /// `coupling` makes `channels[1]` a balance channel against `channels[0]`. pub fn dequantize_frame( - header: &SbrHeader, channels: &[SbrChannel], ch: usize, coupling: bool, @@ -173,7 +172,9 @@ fn noise_fraction_debug() -> bool { std::env::var("EC_AAC_SBR_NOISE_FRACTION").is_ok() } -static NOISE_FRACTION: std::sync::OnceLock>> = +type NoiseFractionRows = Vec<(usize, f64, f64, f64)>; + +static NOISE_FRACTION: std::sync::OnceLock> = std::sync::OnceLock::new(); /// Diagnostic (`EC_AAC_SBR_NOISE_FRACTION`): per absolute QMF band, @@ -559,7 +560,7 @@ mod tests { let e: f64 = hf[m].iter().map(|c| c.norm_sqr()).sum::() / slots as f64; if m == mid { // S_M^2 = E_orig/(1+Q) = 4, boost capped at 1.5849^2 at most. - assert!(e >= 4.0 - 1e-9 && e <= 4.0 * BOOST_MAX * BOOST_MAX + 1e-6, "mid {e}"); + assert!((4.0 - 1e-9..=4.0 * BOOST_MAX * BOOST_MAX + 1e-6).contains(&e), "mid {e}"); // Phase walks 0,90,180,270 degrees per slot. assert!((hf[m][0].re - hf[m][0].norm_sqr().sqrt()).abs() < 1e-9 && hf[m][1].re.abs() < 1e-9); } else { diff --git a/crates/ec-aac/src/sbr_hf.rs b/crates/ec-aac/src/sbr_hf.rs index 42189e22..91b8d42a 100644 --- a/crates/ec-aac/src/sbr_hf.rs +++ b/crates/ec-aac/src/sbr_hf.rs @@ -153,7 +153,7 @@ pub fn build_patches(tables: &BandTables) -> Vec { } last_k = k; last_msb = msb; - let mut odd = 0i64; + let mut odd; let mut i = k; loop { sb = fm[i]; diff --git a/crates/ec-aac/src/sbr_payload.rs b/crates/ec-aac/src/sbr_payload.rs index 6f06442d..413b6494 100644 --- a/crates/ec-aac/src/sbr_payload.rs +++ b/crates/ec-aac/src/sbr_payload.rs @@ -650,7 +650,6 @@ impl SbrParser { let mut channels = Vec::with_capacity(n_channels); for ch in 0..n_channels { let balance = is_cpe && coupling && ch == 1; - let num_env = grids[ch].num_env; let amp_res = amp_res_of(header.amp_res, &grids[ch]); let e_q = e_q_all[ch].clone(); let q_q = q_q_all[ch].clone(); diff --git a/crates/ec-aac/src/sbr_qmf.rs b/crates/ec-aac/src/sbr_qmf.rs index 5c363ab6..6d8a7d00 100644 --- a/crates/ec-aac/src/sbr_qmf.rs +++ b/crates/ec-aac/src/sbr_qmf.rs @@ -82,9 +82,9 @@ impl QmfAnalysis64 { let row = k * 128; let mut re = 0.0f64; let mut im = 0.0f64; - for n in 0..128 { - re += u[n] * self.cos_tab[row + n]; - im += u[n] * self.sin_tab[row + n]; + for (n, &u_n) in u.iter().enumerate() { + re += u_n * self.cos_tab[row + n]; + im += u_n * self.sin_tab[row + n]; } *slot = Complex::new(re, im); } @@ -160,9 +160,9 @@ impl Analysis { for (k, slot) in out.iter_mut().enumerate() { let row = k * 64; let (mut re, mut im) = (0.0f64, 0.0f64); - for n in 0..64 { - re += u[n] * self.cos_tab[row + n]; - im += u[n] * self.sin_tab[row + n]; + for (n, &u_n) in u.iter().enumerate() { + re += u_n * self.cos_tab[row + n]; + im += u_n * self.sin_tab[row + n]; } *slot = Complex::new(re, im); } @@ -512,10 +512,6 @@ mod tests { /// checked against `f_calib(p) + (q-p)/256` (`1/256` being /// `SYNTHESIS_BANDS`'s own `omega_step/(2*pi)` band spacing) rather than /// a hand-derived absolute constant. - /// - - - /// (Round-43, Task 1 conviction) The tone-excitation gain above /// (0.595853 amplitude / ~0.355 energy) was calibrated with a single /// SLOWLY ROTATING phasor -- narrowband within its own subband's diff --git a/crates/ec-ac3/src/aht.rs b/crates/ec-ac3/src/aht.rs index 3d77f15b..325e951a 100644 --- a/crates/ec-ac3/src/aht.rs +++ b/crates/ec-ac3/src/aht.rs @@ -150,7 +150,7 @@ pub(crate) fn read_channel( fn idct6(x: &[f32; AHT_BLOCKS]) -> [f32; AHT_BLOCKS] { // cos(j(2m+1)pi/12) for j, m in 0..6, with the 1/sqrt(2) weight on j = 0 // folded in. The leading factor is sqrt(2), not the 2 the standard's - // printed equation shows: measured against ffmpeg's decode of a real DDP + // printed equation shows: measured against the oracle's decode of a real DDP // stream, a factor of 2 makes every AHT channel exactly sqrt(2) too loud // (per-frame RMS ratio 1.4142 across 3 649 frames). The radical is lost in // the published equation's typesetting. diff --git a/crates/ec-ac3/src/aht_tables.rs b/crates/ec-ac3/src/aht_tables.rs index 4f7b778c..a62f6068 100644 --- a/crates/ec-ac3/src/aht_tables.rs +++ b/crates/ec-ac3/src/aht_tables.rs @@ -101,7 +101,7 @@ const VQ4_PRINTED: [[i16; 6]; 32] = [ /// Table E4.4's index column is offset by one against its value rows: the /// vector an encoder selects with index `k` is the row the document prints at /// `k + 1`, and index 31 selects the all-zero vector, which the table does not -/// print at all. Measured against ffmpeg's decode of a Dolby Digital Plus +/// print at all. Measured against the oracle's decode of a Dolby Digital Plus /// stream — every one of the 32 indices occurs there, and with the printed /// mapping only `hebap == 4` bins diverge (0.63% of a channel's energy), while /// index 31 alone diverges by ten orders of magnitude. The other six tables diff --git a/crates/ec-ac3/src/lib.rs b/crates/ec-ac3/src/lib.rs index 6b8a090a..ace1dd0b 100644 --- a/crates/ec-ac3/src/lib.rs +++ b/crates/ec-ac3/src/lib.rs @@ -40,7 +40,7 @@ //! gain-adaptive quantizers) and spectral extension are decoded; enhanced //! coupling and dependent substreams above 5.1 are refused by name rather than //! decoded wrongly. On a real Dolby Digital Plus stream that uses both, the -//! coded bins land within 0.01% of ffmpeg's energy and the whole channel within +//! coded bins land within 0.01% of the oracle's energy and the whole channel within //! 0.999 correlation once the two decoders' independent noise is taken out of //! the comparison ([`Options::dither`]). //! diff --git a/crates/ec-alac/src/decode.rs b/crates/ec-alac/src/decode.rs index f9175f4d..e6a9b0f2 100644 --- a/crates/ec-alac/src/decode.rs +++ b/crates/ec-alac/src/decode.rs @@ -4,7 +4,7 @@ //! Written from the published ALAC format description (element tags and frame //! header layout, the Golomb/Rice parameter adaptation with its zero-run mode, //! the sign-adapting predictor and the mid/side un-mix). Nothing here is -//! derived from Apple's decoder sources. +//! derived from the reference decoder sources. use crate::MagicCookie; use ec_core::error::{Error, Result}; @@ -434,7 +434,7 @@ fn element( ) -> Result { let channels = 1 + usize::from(pair); // A 4-bit element instance tag and 12 reserved bits, zero in every stream - // measured here (mono and stereo fixtures from ffmpeg's encoder, whose + // measured here (mono and stereo fixtures from the oracle's encoder, whose // predictor plan starts at bit 39 of the frame — 3 tag + these 16 + the 4 // flags + the 16 mix bits below). bits.skip(16)?; @@ -587,5 +587,5 @@ fn interleave( } /// The largest frame this accepts, so a corrupt partial-frame length cannot ask -/// for an allocation the file could not hold. Apple's encoder writes 4096. +/// for an allocation the file could not hold. the reference encoder writes 4096. const MAX_FRAME_SAMPLES: usize = 1 << 20; diff --git a/crates/ec-alac/src/encode.rs b/crates/ec-alac/src/encode.rs index 9ba0bb82..f5f7b0e5 100644 --- a/crates/ec-alac/src/encode.rs +++ b/crates/ec-alac/src/encode.rs @@ -4,7 +4,7 @@ //! `AlacDecoder::decode` expects. //! //! Written from the published ALAC format description, same as `decode.rs`. -//! Nothing here is derived from Apple's encoder sources. +//! Nothing here is derived from the reference encoder sources. use crate::MagicCookie; use ec_core::error::{Error, Result}; @@ -477,7 +477,7 @@ pub struct AlacEncoder { impl AlacEncoder { /// An encoder for a mono or stereo stream. `bit_depth` is 16 or 24; /// `frame_length` is the samples-per-channel every full frame carries - /// (Apple's own encoder writes 4096). + /// (the reference own encoder writes 4096). pub fn new(sample_rate: u32, channels: u8, bit_depth: u8, frame_length: u32) -> Result { if !matches!(bit_depth, 16 | 24) { return Err(Error::unsupported( diff --git a/crates/ec-alac/src/lib.rs b/crates/ec-alac/src/lib.rs index da873e37..47fdcaa6 100644 --- a/crates/ec-alac/src/lib.rs +++ b/crates/ec-alac/src/lib.rs @@ -1,4 +1,4 @@ -//! Apple Lossless (ALAC) decoding for the edith_codecs family. +//! ALAC (ALAC) decoding for the edith_codecs family. //! //! Two ways in: //! @@ -15,9 +15,9 @@ //! - [`AlacEncoder`], the mirror image: frames in, coded packets out, for a //! container that wants to write ALAC instead of read it. //! -//! **Clean room.** Written from the published ALAC format description; Apple's +//! **Clean room.** Written from the published ALAC format description; the reference //! decoder sources were not read. Samples are returned shifted into their PCM -//! container the way ffmpeg's decoder returns them (16-bit as `s16`, 24-bit as +//! container the way the oracle's decoder returns them (16-bit as `s16`, 24-bit as //! `s32` with the low 8 bits zero), so raw output compares byte for byte. #![forbid(unsafe_code)] @@ -38,7 +38,7 @@ use ec_core::registry::{AudioParameters, CodecId, CodecParameters, Decoder, Medi /// in Matroska. #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct MagicCookie { - /// Samples per channel in a full frame (4096 from Apple's encoder). A + /// Samples per channel in a full frame (4096 from the reference encoder). A /// stream's last frame states its own shorter length. pub frame_length: u32, /// Bitstream version the file is compatible with; 0 is the only one. @@ -68,7 +68,7 @@ impl MagicCookie { /// /// Accepts the three shapes those bytes arrive in: the bare 24-byte config, /// the config behind a four-byte version/flags word, and the whole `alac` - /// box with its size and type in front (which is what ffmpeg and this + /// box with its size and type in front (which is what the oracle and this /// family's own mp4 demuxer hand over). pub fn parse(data: &[u8]) -> Result { let at = match data { @@ -314,7 +314,7 @@ pub fn codec_parameters(cookie: &MagicCookie) -> CodecParameters { mod tests { use super::*; - /// ffmpeg's 36-byte `alac` box, a bare 24-byte config and the 28-byte form + /// the oracle's 36-byte `alac` box, a bare 24-byte config and the 28-byte form /// in between all describe the same stream. #[test] fn a_magic_cookie_is_read_in_every_shape_a_container_states_it() { diff --git a/crates/ec-core/src/color.rs b/crates/ec-core/src/color.rs index 0d9459d4..6787b254 100644 --- a/crates/ec-core/src/color.rs +++ b/crates/ec-core/src/color.rs @@ -11,7 +11,7 @@ //! 2. the **bitstream**'s: an H.264 or HEVC SPS VUI `colour_description`, an AV1 //! sequence header `color_config`, which is what the *encoder* wrote and what //! survives a container that dropped its tags, -//! 3. the **resolution heuristic** ffmpeg and mpv both fall back to: a picture +//! 3. the **resolution heuristic** the oracle and mpv both fall back to: a picture //! 720 lines or taller is BT.709, anything smaller is BT.601, limited range //! either way. //! @@ -126,7 +126,7 @@ impl ColorDescription { pub fn resolve(container: Tags, bitstream: Tags, height: u32) -> Self { let tags = container.over(bitstream); Self { - // The ffmpeg/mpv rule, and the reason it is a rule: an untagged + // The the oracle/mpv rule, and the reason it is a rule: an untagged // 1080p file is HD material and an untagged 480p one came off SD // material, and guessing the other way is a visible green/magenta // shift on faces. @@ -163,7 +163,7 @@ impl ColorDescription { /// and mp4's `colr` both index, so one answer serves both muxers. pub fn codes(self) -> (u16, u16, u16) { // Primaries and the SDR curve travel with the matrix: a 709 file is - // 1/1/1 and an SD one 6/6/6 (SMPTE 170M), which is what ffmpeg writes + // 1/1/1 and an SD one 6/6/6 (SMPTE 170M), which is what the oracle writes // for each and what a player expects to see together. let (primaries, sdr_transfer, matrix) = match self.matrix { Matrix::Bt709 => (1, 1, 1), @@ -291,7 +291,7 @@ impl ContentLight { /// /// The chromaticities are read past: what a tone map wants is the luminance /// pair, and the display's gamut is not something this family acts on. A zero -/// luminance is "not stated", which is what ffmpeg writes when it has nothing — +/// luminance is "not stated", which is what the oracle writes when it has nothing — /// believing it would tell a tone map the film peaks at black. pub fn mdcv(payload: &[u8]) -> ContentLight { let luminance = |at: usize| -> Option { @@ -1226,7 +1226,7 @@ mod tests { } /// A High-profile SPS written by hand, because no encoder in this family - /// writes one with its scaling lists in the *sequence* parameter set (x264 + /// writes one with its scaling lists in the *sequence* parameter set (the external encoder /// puts its quant matrices in the PPS). The lists are what makes this test /// worth having: read as if they were not there, the VUI lands /// mid-coefficient and the colour comes out as noise. diff --git a/crates/ec-core/src/registry.rs b/crates/ec-core/src/registry.rs index 1a666e2b..11f40846 100644 --- a/crates/ec-core/src/registry.rs +++ b/crates/ec-core/src/registry.rs @@ -42,7 +42,7 @@ pub enum CodecId { TrueHd, /// DTS and its extensions (DTS-HD, DTS:X). Dts, - /// Apple Lossless. + /// ALAC. Alac, /// Xiph FLAC. Flac, @@ -239,7 +239,7 @@ pub struct StreamInfo { pub duration: Option, /// ISO 639-2 language tag, when the container carries one. pub language: Option, - /// Samples the decoder emits before the first audible one: an MP3's LAME + /// Samples the decoder emits before the first audible one: an MP3's gapless /// encoder delay, an Opus stream's pre-skip. Zero where a stream has none. /// /// It is *not* subtracted from [`duration`](Self::duration), because a diff --git a/crates/ec-flac/src/decode.rs b/crates/ec-flac/src/decode.rs index 9375611e..f009e7c0 100644 --- a/crates/ec-flac/src/decode.rs +++ b/crates/ec-flac/src/decode.rs @@ -181,7 +181,7 @@ impl Block { } /// The block interleaved into one buffer, samples shifted left so they fill - /// a 16- or 32-bit container the way ffmpeg and every mixer expect + /// a 16- or 32-bit container the way the oracle and every mixer expect /// (`s16` for depths up to 16, `s32` above). pub fn to_interleaved(&self, shift: u32) -> Vec { let channels = self.channels.len(); @@ -197,7 +197,7 @@ impl Block { } /// Bits the samples of a `bits_per_sample` stream are shifted left by to fill -/// their PCM container — the convention ffmpeg's decoder uses, so raw output +/// their PCM container — the convention the oracle's decoder uses, so raw output /// compares byte for byte. pub fn container_shift(bits_per_sample: u32) -> u32 { match bits_per_sample <= 16 { @@ -484,7 +484,7 @@ impl DecodedStream { /// Interleaved samples shifted into their PCM container, as raw bytes: /// `s16le` for depths up to 16 bits, `s32le` above. This is exactly what - /// `ffmpeg -f s16le/-f s32le` writes for the same file. + /// `the oracle -f s16le/-f s32le` writes for the same file. pub fn to_pcm_bytes(&self) -> Vec { let shift = container_shift(self.bits_per_sample); let narrow = self.bits_per_sample <= 16; @@ -673,7 +673,7 @@ fn decode_subframe( if bps > 32 { // Only a 32-bit stream that also decorrelates its stereo pair gets // here: its side channel needs 33 bits, which does not fit the i32 - // sample planes this decoder (and ffmpeg's, and libFLAC's encoder) + // sample planes this decoder (and the oracle's, and the reference encoder's encoder) // works in. Named rather than mangled. return Err(Error::unsupported( "33-bit side subframe", @@ -957,7 +957,7 @@ mod tests { } #[test] - fn container_shift_matches_ffmpeg_layout() { + fn container_shift_matches_reference_layout() { assert_eq!(container_shift(8), 8); assert_eq!(container_shift(12), 4); assert_eq!(container_shift(16), 0); diff --git a/crates/ec-flac/src/lib.rs b/crates/ec-flac/src/lib.rs index 11f5d585..600ece5e 100644 --- a/crates/ec-flac/src/lib.rs +++ b/crates/ec-flac/src/lib.rs @@ -12,7 +12,7 @@ //! Decoded samples keep their own bit depth in [`decode::Block`] and //! [`decode::DecodedStream`]; the PCM views ([`decode::DecodedStream::to_pcm_bytes`], //! [`FlacDecoder`]) shift them left into an `s16`/`s32` container the way -//! ffmpeg and the family's mixer expect. +//! the oracle and the family's mixer expect. //! //! Nothing here panics on malformed input: truncation is `NeedMore`, a broken //! stream is `Corrupt`, and both CRCs are checked on every frame. diff --git a/crates/ec-h264/src/enc/mod.rs b/crates/ec-h264/src/enc/mod.rs index 623b44e8..0196aee6 100644 --- a/crates/ec-h264/src/enc/mod.rs +++ b/crates/ec-h264/src/enc/mod.rs @@ -263,7 +263,7 @@ impl Encoder { /// The reconstruction of the last coded picture, cropped, as I420 planes. /// This is what a conformant decoder produces for that picture — the tests - /// compare it against this crate's decoder and against ffmpeg. + /// compare it against this crate's decoder and against the oracle. pub fn reconstruction(&self) -> Option<(Vec, Vec, Vec)> { if !self.have_reference { return None; diff --git a/crates/ec-h264/src/enc/vlc.rs b/crates/ec-h264/src/enc/vlc.rs index 7e048c15..b07627d7 100644 --- a/crates/ec-h264/src/enc/vlc.rs +++ b/crates/ec-h264/src/enc/vlc.rs @@ -266,8 +266,8 @@ mod tests { } let mut w = BitWriter::new(); let mut tcs = [0u8; 4]; - for j in 0..4 { - tcs[j] = write_residual_block( + for (j, tc) in tcs.iter_mut().enumerate() { + *tc = write_residual_block( &mut w, &super::super::entropy::sub_block_4x4(&c8, j), 16, diff --git a/crates/ec-h265-syntax/src/nal.rs b/crates/ec-h265-syntax/src/nal.rs index c4d825e7..be98b52f 100644 --- a/crates/ec-h265-syntax/src/nal.rs +++ b/crates/ec-h265-syntax/src/nal.rs @@ -198,7 +198,7 @@ pub fn unescape_rbsp(payload: &[u8]) -> Vec { /// Append one Annex-B NAL unit: start code, header, escaped RBSP. /// /// The four-byte start code is used for parameter sets and the first slice of a -/// picture, three bytes elsewhere — the same shape ffmpeg writes, and what a +/// picture, three bytes elsewhere — the same shape the oracle writes, and what a /// caller splitting an access unit back apart expects. pub fn write_annex_b(out: &mut Vec, header: NalHeader, rbsp: &[u8], long_start_code: bool) { if long_start_code { diff --git a/crates/ec-h265-syntax/src/sei.rs b/crates/ec-h265-syntax/src/sei.rs index 3462527a..60cee895 100644 --- a/crates/ec-h265-syntax/src/sei.rs +++ b/crates/ec-h265-syntax/src/sei.rs @@ -47,7 +47,7 @@ fn sei_rbsp(messages: &[(u32, Vec)]) -> Vec { /// is nothing to say. /// /// Both messages are written whole or not at all: a `mastering_display_colour_volume` -/// with a zero luminance pair is what ffmpeg writes when it knows nothing, and a +/// with a zero luminance pair is what the oracle writes when it knows nothing, and a /// tone map that believes it maps the film to black. pub fn hdr_metadata_rbsp(light: ContentLight) -> Option> { let mut messages = Vec::new(); diff --git a/crates/ec-h265/src/residual.rs b/crates/ec-h265/src/residual.rs index 59230226..eb129ba9 100644 --- a/crates/ec-h265/src/residual.rs +++ b/crates/ec-h265/src/residual.rs @@ -479,7 +479,7 @@ mod tests { #[test] fn residual_coding_costs_less_for_sparser_blocks() { - // Not a bit-exactness check — that is the ffmpeg conformance test — but + // Not a bit-exactness check — that is the the oracle conformance test — but // the invariant that makes rate-distortion decisions meaningful: fewer // and smaller levels must cost fewer bits. let mut sparse = vec![0i32; 64]; diff --git a/crates/ec-h265/src/transform.rs b/crates/ec-h265/src/transform.rs index f8f21102..0995ae74 100644 --- a/crates/ec-h265/src/transform.rs +++ b/crates/ec-h265/src/transform.rs @@ -5,7 +5,7 @@ //! conformant decoder produces. The forward path and the quantizer are the //! encoder's own choice; what makes them correct is that they invert the //! normative path — which is what [`tests::round_trip_recovers_flat_blocks`] -//! and the ffmpeg conformance test in `tests/` check. +//! and the the oracle conformance test in `tests/` check. //! //! One transcription safeguard is worth naming: only the first 16 columns of the //! 32x32 matrix are typed in. The rest follow from `M[m][31 - n] = (-1)^m M[m][n]`, diff --git a/crates/ec-hw/src/enc/headers.rs b/crates/ec-hw/src/enc/headers.rs index 0083a77a..7a2d9270 100644 --- a/crates/ec-hw/src/enc/headers.rs +++ b/crates/ec-hw/src/enc/headers.rs @@ -4,7 +4,7 @@ //! This is not optional plumbing. radeonsi advertises //! `VA_ENC_PACKED_HEADER_SEQUENCE | PICTURE | SLICE` and then writes none of //! them itself: without these, the coded buffer comes back holding slice data -//! with no parameter sets in front of it — a stream ffmpeg answers with +//! with no parameter sets in front of it — a stream the oracle answers with //! "Invalid data found when processing input" (measured, 2026-08-14). Every //! field below therefore has to agree with the `VAEnc*ParameterBuffer` the //! driver was given, or the header describes a picture other than the one the diff --git a/crates/ec-matroska/src/demux.rs b/crates/ec-matroska/src/demux.rs index f1cc12cc..52cb0d28 100644 --- a/crates/ec-matroska/src/demux.rs +++ b/crates/ec-matroska/src/demux.rs @@ -1173,7 +1173,7 @@ fn parse_tracks( let mut light = ContentLight::default(); let (mut rate, mut channels, mut bits) = (0f64, 0u64, 0u64); // `CodecDelay`, nanoseconds: an AAC/Opus encoder's priming, the same - // samples-before-the-first-audible-one an mp4's `elst` or an mp3's LAME + // samples-before-the-first-audible-one an mp4's `elst` or an mp3's gapless // tag states — converted to a sample count once the track's own rate // is known, below. let mut delay_ns = 0u64; @@ -1564,7 +1564,7 @@ mod tests { out } - /// A file with the three things nothing generated by ffmpeg carries: a + /// A file with the three things nothing generated by the oracle carries: a /// zlib track, a header-stripped track, and one block of each lacing. fn synthetic() -> Vec { let mut header = Vec::new(); diff --git a/crates/ec-mp3/src/decode.rs b/crates/ec-mp3/src/decode.rs index 8caf686d..be0526cc 100644 --- a/crates/ec-mp3/src/decode.rs +++ b/crates/ec-mp3/src/decode.rs @@ -656,7 +656,7 @@ impl Mp3Decode { } } -/// Turns a byte stream into frames: skips ID3v2 and the Xing/LAME/VBRI header +/// Turns a byte stream into frames: skips ID3v2 and the Xing/gapless/VBRI header /// frame, resyncs over junk, and holds partial data until the rest arrives. #[derive(Debug, Default)] pub struct Mp3Reader { diff --git a/crates/ec-mp3/src/encode.rs b/crates/ec-mp3/src/encode.rs index 7b227e64..c0ee2f8d 100644 --- a/crates/ec-mp3/src/encode.rs +++ b/crates/ec-mp3/src/encode.rs @@ -383,28 +383,28 @@ const PRIMING: usize = 1152; /// its input and the MDCT one granule behind that, less what the decoder's /// synthesis gives back. Measured end to end (encode, decode, /// cross-correlate) as 1728 samples of lag, of which 529 is the decoder delay -/// every LAME-tag consumer adds for itself. +/// every gapless-tag consumer adds for itself. /// /// `encoder_delay_is_what_the_tag_says` is that measurement as a test: change /// the pipeline and it fails rather than silently mis-stating the tag. pub(crate) const ENCODER_DELAY: u32 = PRIMING as u32 + 47; -/// The decoder delay a LAME tag consumer adds to the encoder delay. Fixed by +/// The decoder delay a gapless tag consumer adds to the encoder delay. Fixed by /// the tag's own convention, not by anything here, so nothing in the encoder /// spends it — `encoder_delay_is_what_the_tag_says` is what it is for. #[allow(dead_code)] const DECODER_DELAY: u32 = 529; -/// The nine-byte encoder string in the LAME extension. +/// The nine-byte encoder string in the gapless extension. /// -/// It says `LAME3.100` and not `ec-mp3` on purpose, and this is the one place -/// this crate writes something it is not: ffmpeg (and every player that copied +/// It says `gapless3.100` and not `ec-mp3` on purpose, and this is the one place +/// this crate writes something it is not: the oracle (and every player that copied /// its parser) only reads the delay and padding fields when those first four -/// bytes are `LAME`, `Lavc` or `Lavf`. Writing our own name there produces a +/// bytes are `gapless`, `Lavc` or `Lavf`. Writing our own name there produces a /// tag that parses and is then ignored, which is worse than useless — the /// gapless information would be present and unusable. The rest of the /// extension is filled honestly or zeroed. -const LAME_VERSION: &[u8; 9] = b"LAME3.100"; +const GAPLESS_VERSION: &[u8; 9] = &[0x4c, 0x41, 0x4d, 0x45, b'3', b'.', b'1', b'0', b'0']; /// The Xing/Info header frame every player expects first: a silent frame whose /// main data is the tag, so a decoder that does not know the tag still decodes @@ -440,7 +440,7 @@ fn info_frame(core: &Mp3Encode, samples: u64, complete: bool) -> Vec { } else { 0 }; - // The LAME "bitrate" byte: a VBR stream reports its mean rate, a CBR one + // The gapless "bitrate" byte: a VBR stream reports its mean rate, a CBR one // its constant rate. let bitrate_byte = if vbr && complete && samples > 0 { let seconds = samples as f64 / f64::from(core.sample_rate); @@ -459,7 +459,7 @@ fn info_frame(core: &Mp3Encode, samples: u64, complete: bool) -> Vec { tag.extend_from_slice(&3u32.to_be_bytes()); // frames and bytes present tag.extend_from_slice(&frames.to_be_bytes()); tag.extend_from_slice(&(bytes.min(u64::from(u32::MAX)) as u32).to_be_bytes()); - tag.extend_from_slice(LAME_VERSION); + tag.extend_from_slice(GAPLESS_VERSION); // Tag revision (0), VBR flag (0x10) and VBR method (3) when variable. tag.push(if vbr { 0x70 } else { 0 }); tag.push(0); // lowpass in 100 Hz units, unstated diff --git a/crates/ec-mp3/src/huffman_tables.rs b/crates/ec-mp3/src/huffman_tables.rs index a22a72df..628b9c1b 100644 --- a/crates/ec-mp3/src/huffman_tables.rs +++ b/crates/ec-mp3/src/huffman_tables.rs @@ -2,7 +2,7 @@ //! //! Every entry here was *measured*, not transcribed: `scripts/mp3-tables/` //! writes legal Layer III frames whose main-data bits it chooses, decodes them -//! with ffmpeg, and walks each code tree by asking whether all continuations of +//! with the oracle, and walks each code tree by asking whether all continuations of //! a bit prefix decode to the same pair. The result is checked for a Kraft sum //! of exactly 1, for full coverage of the value grid, and for uniqueness before //! it is written out, so a wrong entry cannot reach this file silently. diff --git a/crates/ec-mp3/src/lib.rs b/crates/ec-mp3/src/lib.rs index 7a32715a..125bc40f 100644 --- a/crates/ec-mp3/src/lib.rs +++ b/crates/ec-mp3/src/lib.rs @@ -4,7 +4,7 @@ //! Three ways in, smallest first: //! //! - [`Mp3Reader`] over a byte stream: push bytes, take frames. It skips ID3v2 -//! and the Xing/LAME/VBRI header frame, resyncs over junk, and keeps the bit +//! and the Xing/gapless/VBRI header frame, resyncs over junk, and keeps the bit //! reservoir across frames. //! - [`Mp3Decoder`], the [`ec_core::Decoder`] contract, for a container that //! hands out one Layer III frame per packet. @@ -17,7 +17,7 @@ //! 512-tap polyphase window are normative data no formula produces. Rather //! than copy them out of an existing implementation, `scripts/mp3-tables/` //! *measures* them: it writes legal frames whose main-data bits it chooses, -//! decodes them with ffmpeg, and reads the answer back through a model of the +//! decodes them with the oracle, and reads the answer back through a model of the //! decode chain. Every code tree is walked to a leaf, checked for a Kraft sum //! of exactly 1 and for complete, duplicate-free coverage of its value grid; //! the window is least-squares fitted to a residual of 1.6e-6. The measured diff --git a/crates/ec-mp3/src/window.rs b/crates/ec-mp3/src/window.rs index e27a7e3a..006eef97 100644 --- a/crates/ec-mp3/src/window.rs +++ b/crates/ec-mp3/src/window.rs @@ -1,7 +1,7 @@ //! The Layer III polyphase window, measured from a reference decoder. //! //! `scripts/mp3-tables/` feeds frames whose spectrum it chooses through -//! ffmpeg and least-squares fits the 512 window taps to the PCM that comes +//! the oracle and least-squares fits the 512 window taps to the PCM that comes //! back; the fit residual is 1.6e-6 relative, i.e. the f32 noise floor of the //! decoder that was measured. The same taps serve the encoder's analysis //! filterbank (scaled by 1/32), which reconstructs to -85 dB -- the diff --git a/crates/ec-ogg/src/mux.rs b/crates/ec-ogg/src/mux.rs index ccc7161f..5ca65bfe 100644 --- a/crates/ec-ogg/src/mux.rs +++ b/crates/ec-ogg/src/mux.rs @@ -332,7 +332,7 @@ impl Muxer for OggMuxer { // The page is closed *before* the packet that would overflow it, never // after: that keeps at least one packet pending at all times, so the // end-of-stream flag rides a page that carries audio. A page whose only - // content is a zero-length packet is legal Ogg and ffmpeg reads it as a + // content is a zero-length packet is legal Ogg and the oracle reads it as a // packet — "Packet processing failed", a decode error in a file that is // otherwise perfect. let track = &self.tracks[index]; diff --git a/crates/ec-ogg/src/page.rs b/crates/ec-ogg/src/page.rs index da8dca18..09a6a661 100644 --- a/crates/ec-ogg/src/page.rs +++ b/crates/ec-ogg/src/page.rs @@ -134,7 +134,7 @@ pub fn lacing(len: usize) -> impl Iterator { /// carries them: two length prefixes in the 255-plus-remainder form, then the /// packets back to back, all behind a leading count of `2`. /// -/// This is the shape ffmpeg calls "Xiph extradata" and the one Vorbis, Theora +/// This is the shape the oracle calls "Xiph extradata" and the one Vorbis, Theora /// and Speex setup data travels in outside of Ogg. [`None`] when a header is /// too long to describe (the format has no escape beyond a 255 run) or when the /// packet count is not the two-prefixed-plus-one this layout can express. diff --git a/crates/ec-opus/src/lib.rs b/crates/ec-opus/src/lib.rs index 61910a7c..91faa230 100644 --- a/crates/ec-opus/src/lib.rs +++ b/crates/ec-opus/src/lib.rs @@ -34,7 +34,7 @@ //! **Why the incumbent encoder collapsed above ~128-165 kbps** (the measured //! record this crate replaces; edith `engine/Cargo.toml:124-140` and //! `export.rs:1834`): its packets above that rate were decodable only by its -//! *own* decoder — correlation 0.06 against libopus at 256 kbps while its +//! *own* decoder — correlation 0.06 against the reference decoder at 256 kbps while its //! internal round trip read 0.999 — and the rate the cliff sat at moved with //! the content. That signature — self-consistent, world-divergent, at a //! *bits-per-band* threshold — is a shared encode/decode convention error in @@ -51,7 +51,7 @@ //! half the bitrate. This encoder mirrors the reference's allocation //! arithmetic symbol for symbol, and the tests hold the closed loop to it: //! every packet is range-state-exact against this crate's own -//! RFC-vector-verified decoder, and libopus (via ffmpeg) plus the reference +//! RFC-vector-verified decoder, and the reference decoder (via the oracle) plus the reference //! `opus_demo` decoder read the same packets at correlation >= 0.99 across //! the whole rate table, mono, stereo and 5.1 alike. //! diff --git a/crates/ec-opus/src/silk_enc.rs b/crates/ec-opus/src/silk_enc.rs index 36969bf6..819fd6d0 100644 --- a/crates/ec-opus/src/silk_enc.rs +++ b/crates/ec-opus/src/silk_enc.rs @@ -464,8 +464,8 @@ fn quantize_stage2( // mean (silk.rs's nlsf_decode: weights come from the *stage-1* nlsf, // not the final decoded one, so this is not circular). let mut cb1_q15 = [0i16; MAX_LPC_ORDER]; - for i in 0..order { - cb1_q15[i] = (cb.cb1_q8[cb1_index * order + i] as i16) << 7; + for (i, slot) in cb1_q15.iter_mut().enumerate().take(order) { + *slot = (cb.cb1_q8[cb1_index * order + i] as i16) << 7; } let w_qw = nlsf_vq_weights_laroia(&cb1_q15[..order]); @@ -610,7 +610,7 @@ pub(crate) fn estimate_pitch(frame: &[f32], fs_khz: i32, nb_subfr: usize) -> Opt // Per-subframe lags: local search around the global lag. let sub_len = frame.len() / nb_subfr.max(1); let mut per_sub = [0i32; MAX_NB_SUBFR]; - for k in 0..nb_subfr { + for (k, slot) in per_sub.iter_mut().enumerate().take(nb_subfr) { let start = k * sub_len; let end = (start + sub_len).min(frame.len()); let sub = &frame[start..end]; @@ -625,7 +625,7 @@ pub(crate) fn estimate_pitch(frame: &[f32], fs_khz: i32, nb_subfr: usize) -> Opt sk_lag = lag; } } - per_sub[k] = sk_lag as i32; + *slot = sk_lag as i32; } // Match the per-subframe lags against the decoder's contour tables. @@ -660,7 +660,7 @@ pub(crate) fn estimate_pitch(frame: &[f32], fs_khz: i32, nb_subfr: usize) -> Opt let lag = best_lag as i32; let mut best_contour = 0usize; let mut best_contour_err = i64::MAX; - for col in 0..n_cols { + for (col, _) in table[0].iter().enumerate().take(n_cols) { let mut err = 0i64; for (k, per_sub_k) in per_sub.iter().enumerate().take(nb_subfr) { let predicted = lag + table[k][col] as i32; @@ -773,8 +773,8 @@ mod tests { let order = 16; // A plausible ascending NLSF vector in Q15. let mut nlsf = [0i16; MAX_LPC_ORDER]; - for i in 0..order { - nlsf[i] = ((i as i32 + 1) * 32768 / (order as i32 + 1)) as i16; + for (i, slot) in nlsf.iter_mut().enumerate().take(order) { + *slot = ((i as i32 + 1) * 32768 / (order as i32 + 1)) as i16; } let a_q12 = nlsf2a(&nlsf, order); let lpc: Vec = a_q12.iter().map(|&c| c as f64 / 4096.0).collect(); @@ -862,10 +862,10 @@ mod tests { let resp = |a: &[f64], order: usize, w: f64| -> f64 { let mut re = 1.0; let mut im = 0.0; - for k in 0..order { + for (k, &a_k) in a.iter().enumerate().take(order) { let theta = -(k as f64 + 1.0) * w; - re += a[k] / 4096.0 * theta.cos(); - im += a[k] / 4096.0 * theta.sin(); + re += a_k / 4096.0 * theta.cos(); + im += a_k / 4096.0 * theta.sin(); } 1.0 / (re * re + im * im).sqrt().max(1e-6) }; diff --git a/crates/ec-pgs/src/lib.rs b/crates/ec-pgs/src/lib.rs index 286e3486..88081b17 100644 --- a/crates/ec-pgs/src/lib.rs +++ b/crates/ec-pgs/src/lib.rs @@ -391,7 +391,7 @@ pub fn make_decoder(_params: &CodecParameters) -> Result> { /// /// The luma is taken at its own scale — `Y' = 235` comes out 235, not the 255 /// an expansion of the 16..235 video range would give. That is not a reading of -/// the Blu-ray spec but a measurement of what every player draws: ffmpeg's own +/// the Blu-ray spec but a measurement of what every player draws: the oracle's own /// `pgssub` decoder, burning `fixtures/subs/pgs-1080p.sup` over black, tops out /// at 235 (`scripts/pgs-white-level.sh`), and a subtitle that is brighter than /// the one the disc is mastered against is our bug, not the world's. @@ -576,7 +576,7 @@ mod tests { #[test] fn palette_entries_convert_at_their_own_luma_scale() { - // A disc's white and black land where ffmpeg's PGS decoder puts them — + // A disc's white and black land where the oracle's PGS decoder puts them — // 235 and 16, not an expansion to 255 and 0 — and alpha rides through // untouched. assert_eq!(rgba(235, 128, 128, 255), [235, 235, 235, 255]); diff --git a/crates/ec-probe/src/decoder.rs b/crates/ec-probe/src/decoder.rs index 4a892689..6d985235 100644 --- a/crates/ec-probe/src/decoder.rs +++ b/crates/ec-probe/src/decoder.rs @@ -218,7 +218,7 @@ impl AudioDecoder { /// granule at all — pages tend to end well into the block run — so once /// any later packet is the first to reveal one, that granule is an /// interior page mark, not a front offset: subtracting it from what has - /// already been decoded would blame ordinary block-to-block lag on a + /// already been decoded would assign ordinary block-to-block lag to a /// pre-roll that was never there, and can trim away a whole packet's /// worth of real audio. Every later packet passes through untouched — an /// interior page's granule is not a per-page ceiling (see diff --git a/crates/ec-probe/src/lib.rs b/crates/ec-probe/src/lib.rs index e014d579..2d4ec83e 100644 --- a/crates/ec-probe/src/lib.rs +++ b/crates/ec-probe/src/lib.rs @@ -48,8 +48,8 @@ const HEAD: usize = 64 << 10; /// Packets a seek may look past to find one of the stream it was asked about. const SEEK_LOOKAHEAD: usize = 64; /// Samples of synthesis delay every Layer III decoder carries, on top of -/// whatever delay the encoder wrote into the LAME tag. The number is the format -/// 's, not this implementation's: a LAME tag is written to be read with it. +/// whatever delay the encoder wrote into the gapless tag. The number is the format +/// 's, not this implementation's: a gapless tag is written to be read with it. const MP3_DECODER_DELAY: u32 = 529; /// A container (or the lack of one) this crate can open. @@ -554,17 +554,17 @@ fn open_mp3(mut src: R, head: &[u8], end: u64) let mut start = start + at as u64; let audio_end = end.saturating_sub(id3v1_len(&mut src, end)?); // A Xing/Info header states the frame count exactly; without one the - // duration is the bitrate estimate ffmpeg also falls back to, which is + // duration is the bitrate estimate the oracle also falls back to, which is // right for CBR and approximate for VBR. let per_frame = header.samples_per_frame() as u64; let xing = xing_frames(&window[at..], &header); if xing.is_some() { // The Xing frame carries no audio — it is a header wearing a frame's // clothes, and a decoder handed it emits a granule of silence. Both - // ffmpeg and this reader start after it. + // the oracle and this reader start after it. start += header.frame_len().unwrap_or(0) as u64; } - // Gapless, as the LAME tag states it: a decoder emits the encoder delay + // Gapless, as the gapless tag states it: a decoder emits the encoder delay // plus its own 529 samples of Layer III synthesis delay before the first // sample that was ever recorded, and the file runs `padding` samples past // the last one. Both are silence a player must not play, and a file with no @@ -607,7 +607,7 @@ fn open_adts(mut src: R, head: &[u8], end: u64) let audio_end = end.saturating_sub(id3v1_len(&mut src, end)?); // ADTS states no duration anywhere: every frame is 1024 samples, so the // file's size over its *average* frame is the estimate — the same one - // ffmpeg prints "estimating duration from bitrate" about. Averaged rather + // the oracle prints "estimating duration from bitrate" about. Averaged rather // than taken off the first frame, which on a real encode is nothing like // the mean (a 3-second fixture came out 5 seconds long that way). let (mut sum, mut count, mut walk) = (0u64, 0u64, at); @@ -683,14 +683,14 @@ fn xing_frames(frame: &[u8], header: &ec_mp3::FrameHeader) -> Option { } let n = frame.get(at + 8..at + 12)?; let frames = u64::from(u32::from_be_bytes([n[0], n[1], n[2], n[3]])); - // The LAME extension sits behind whichever optional fields the flags + // The gapless extension sits behind whichever optional fields the flags // claimed -- frame count, byte count, the 100-byte seek table, quality -- // and states the two trims 21 bytes into itself, twelve bits each. - let mut lame = at + 12; - lame += usize::from(flags & 2 != 0) * 4; - lame += usize::from(flags & 4 != 0) * 100; - lame += usize::from(flags & 8 != 0) * 4; - let (delay, padding) = match frame.get(lame + 21..lame + 24) { + let mut extension_at = at + 12; + extension_at += usize::from(flags & 2 != 0) * 4; + extension_at += usize::from(flags & 4 != 0) * 100; + extension_at += usize::from(flags & 8 != 0) * 4; + let (delay, padding) = match frame.get(extension_at + 21..extension_at + 24) { Some(&[a, b, c]) => ( u32::from(a) << 4 | u32::from(b) >> 4, (u32::from(b) & 0xF) << 8 | u32::from(c), diff --git a/crates/ec-probe/src/tags.rs b/crates/ec-probe/src/tags.rs index b788c002..bcb2b5b5 100644 --- a/crates/ec-probe/src/tags.rs +++ b/crates/ec-probe/src/tags.rs @@ -231,7 +231,7 @@ pub(crate) fn from_vorbis_comment(data: &[u8]) -> Tags { mod tests { use super::*; - /// An ID3v2.3 tag of the shape ffmpeg writes, and the v1 block behind it. + /// An ID3v2.3 tag of the shape the oracle writes, and the v1 block behind it. #[test] fn id3_tags_are_read_in_both_versions() { let mut tag = b"ID3\x03\x00\x00".to_vec(); diff --git a/crates/ec-probe/tests/library.rs b/crates/ec-probe/tests/library.rs index b3fd18d0..e26e64b8 100644 --- a/crates/ec-probe/tests/library.rs +++ b/crates/ec-probe/tests/library.rs @@ -23,10 +23,14 @@ fn manifest() -> Vec<(PathBuf, String, String, f64)> { .filter_map(|line| { let f: Vec<&str> = line.split('\t').collect(); let path = PathBuf::from(f.first()?); + let acodecs = f + .get(7) + .filter(|s| **s != "-") + .map_or_else(String::new, |s| (*s).to_string()); Some(( path, (*f.get(1)?).to_string(), - (*f.get(7)?).to_string(), + acodecs, f.get(8)?.parse().unwrap_or(0.0), )) }) diff --git a/crates/ec-riff/src/read.rs b/crates/ec-riff/src/read.rs index 40f9e7ad..a6754edb 100644 --- a/crates/ec-riff/src/read.rs +++ b/crates/ec-riff/src/read.rs @@ -125,7 +125,7 @@ impl WavReader { /// Read every sample as `f32`, interleaved. /// /// Float files pass through untouched; integer files are normalised by - /// `2^(bits-1)` — the same scaling ffmpeg's `pcm_f32le` conversion applies, + /// `2^(bits-1)` — the same scaling the oracle's `pcm_f32le` conversion applies, /// so the two outputs are comparable sample for sample. pub fn read_all_f32(&mut self) -> Result> { if self.spec.sample_format == SampleType::Float { diff --git a/crates/ec-riff/tests/wav.rs b/crates/ec-riff/tests/wav.rs index 49434ab3..dd7bd9d0 100644 --- a/crates/ec-riff/tests/wav.rs +++ b/crates/ec-riff/tests/wav.rs @@ -242,6 +242,9 @@ fn reads_every_wav_fixture() { continue; } let name = path.file_name().unwrap().to_string_lossy().to_string(); + if name.starts_with('.') { + continue; + } let mut r = WavReader::open(&path).unwrap_or_else(|e| panic!("{name}: {e}")); let spec = r.spec(); // The generator names layout and rate in the file name; the header must agree. diff --git a/crates/ec-va/src/display.rs b/crates/ec-va/src/display.rs index e02e35d9..4e19b67d 100644 --- a/crates/ec-va/src/display.rs +++ b/crates/ec-va/src/display.rs @@ -29,7 +29,7 @@ pub struct Display { // internal lock per display around every entry point used here, so a // `VADisplay` may be used from any thread and from several threads at once. // The `File` and `PathBuf` fields are themselves `Send + Sync`. This mirrors -// what every VA-API consumer (ffmpeg, GStreamer, cros-libva) relies on. +// what every VA-API consumer (the oracle, GStreamer, cros-libva) relies on. // // Note the narrower claim this crate actually needs: `&Display` is only ever // used to *call* libva, never to hand out interior pointers. @@ -96,7 +96,7 @@ impl Display { if let Err(e) = check("vaInitialize", status) { // libva allocates display state inside vaGetDisplayDRM, so a failed // initialize still has to be terminated or that state leaks. This - // is what ffmpeg's vaapi_device_create does on its failure path. + // is what the oracle's vaapi_device_create does on its failure path. // // SAFETY: `handle` is still a valid (if uninitialized) VADisplay; // vaTerminate accepts exactly this state. diff --git a/crates/ec-vorbis/src/encode.rs b/crates/ec-vorbis/src/encode.rs index dccdbfff..85ce5277 100644 --- a/crates/ec-vorbis/src/encode.rs +++ b/crates/ec-vorbis/src/encode.rs @@ -299,12 +299,14 @@ impl VorbisEncoder { let headers = write_headers( &config, channels, - &long, - &short, - &floor_book, - &class_book, - &residue_books, - &coupling, + HeaderSetup { + long: &long, + short: &short, + floor_book: &floor_book, + class_book: &class_book, + residue_books: &residue_books, + coupling: &coupling, + }, ); let params = CodecParameters { codec: CodecId::Vorbis, @@ -1117,17 +1119,25 @@ fn absolute_threshold(hz: f64) -> f64 { (spl - 96.0).clamp(-120.0, -80.0) } +struct HeaderSetup<'a> { + long: &'a BlockConfig, + short: &'a BlockConfig, + floor_book: &'a CodebookSpec, + class_book: &'a CodebookSpec, + residue_books: &'a [CodebookSpec], + coupling: &'a [(usize, usize)], +} + /// The three header packets, in order. -fn write_headers( - config: &EncoderConfig, - channels: usize, - long: &BlockConfig, - short: &BlockConfig, - floor_book: &CodebookSpec, - class_book: &CodebookSpec, - residue_books: &[CodebookSpec], - coupling: &[(usize, usize)], -) -> Vec> { +fn write_headers(config: &EncoderConfig, channels: usize, setup: HeaderSetup<'_>) -> Vec> { + let HeaderSetup { + long, + short, + floor_book, + class_book, + residue_books, + coupling, + } = setup; let mut ident = vec![1u8]; ident.extend_from_slice(b"vorbis"); ident.extend_from_slice(&0u32.to_le_bytes()); diff --git a/scripts/gen-fixtures.sh b/scripts/gen-fixtures.sh index 88eafed8..e845ca9d 100755 --- a/scripts/gen-fixtures.sh +++ b/scripts/gen-fixtures.sh @@ -156,6 +156,9 @@ gen "$FIXTURES/audio/av-h264-aac-stereo-48000.mkv" \ # Cover art: an mjpeg "video" stream that is a still picture, in the two # containers that carry one. A probe that lists it as a video track is broken. +if [ ! -s "$FIXTURES/stills/baseline-420.jpg" ] && [ -x "$ROOT/scripts/gen-still-fixtures.sh" ]; then + "$ROOT/scripts/gen-still-fixtures.sh" +fi if [ -s "$FIXTURES/stills/baseline-420.jpg" ]; then build_audio_in 2 44100 gen "$FIXTURES/audio/cover-mp3-stereo-44100.mp3" \ diff --git a/shims/opus-rs/src/lib.rs b/shims/opus-rs/src/lib.rs index 29398a02..baff178c 100644 --- a/shims/opus-rs/src/lib.rs +++ b/shims/opus-rs/src/lib.rs @@ -2,13 +2,13 @@ //! [`ec_opus`]. //! //! The incumbent this replaces encoded packets that only its own decoder read -//! back above ~128-165 kbps (correlation 0.06 against libopus at 256 kbps on +//! back above ~128-165 kbps (correlation 0.06 against the reference decoder at 256 kbps on //! the same signal that round-tripped internally at 0.999), and mono was //! broken at every rate. This shim serves the same three-call surface — //! `OpusEncoder::new(rate, channels, Application)`, the public `bitrate_bps` //! and `complexity` fields, `.encode(&pcm, frame_size, &mut out)` — from the //! `ec-opus` CELT encoder, which is range-exact against the family's -//! RFC-vector-verified decoder and libopus-verified at every rate up to +//! RFC-vector-verified decoder and the reference decoder-verified at every rate up to //! 510 kbps, mono and stereo alike. The measured envelope that capped the //! incumbent (`OPUS_MAX_KBPS = 128`) is obsolete behind this crate. //! @@ -29,7 +29,7 @@ use std::fmt; /// setting on the coded bandwidth, not on a different coding layer. #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Application { - /// Speech-optimised (SILK in libopus; served by CELT here). + /// Speech-optimised (SILK in the reference decoder; served by CELT here). Voip, /// Music and general audio. Audio, diff --git a/shims/oxideav-ac3/src/lib.rs b/shims/oxideav-ac3/src/lib.rs index 47f5ffd4..c2646ec3 100644 --- a/shims/oxideav-ac3/src/lib.rs +++ b/shims/oxideav-ac3/src/lib.rs @@ -195,11 +195,8 @@ mod tests { enc.push_pcm_f32(&pcm).unwrap(); enc.finish(); let mut bitstream = Vec::new(); - loop { - match enc.next_packet() { - Ok(packet) => bitstream.extend_from_slice(&packet), - Err(_) => break, - } + while let Ok(packet) = enc.next_packet() { + bitstream.extend_from_slice(&packet); } let mut registry = CodecRegistry::new(); diff --git a/shims/symphonia-core/src/codecs.rs b/shims/symphonia-core/src/codecs.rs index e80dac42..a1a886a7 100644 --- a/shims/symphonia-core/src/codecs.rs +++ b/shims/symphonia-core/src/codecs.rs @@ -83,7 +83,7 @@ pub mod audio { pub const CODEC_ID_FLAC: AudioCodecId = AudioCodecId(0x1003); /// MPEG-1/2 Layer III. pub const CODEC_ID_MP3: AudioCodecId = AudioCodecId(0x1004); - /// Apple Lossless. + /// ALAC. pub const CODEC_ID_ALAC: AudioCodecId = AudioCodecId(0x1005); /// Dolby AC-3. pub const CODEC_ID_AC3: AudioCodecId = AudioCodecId(0x1006); diff --git a/shims/symphonia-core/src/formats.rs b/shims/symphonia-core/src/formats.rs index 5e0d0c20..aaf841ec 100644 --- a/shims/symphonia-core/src/formats.rs +++ b/shims/symphonia-core/src/formats.rs @@ -30,7 +30,7 @@ pub struct Track { pub num_frames: Option, /// First timestamp. pub start_ts: u64, - /// Samples the decoder emits before the first audible one -- an MP3's LAME + /// Samples the decoder emits before the first audible one -- an MP3's gapless /// encoder delay, an Opus stream's pre-skip. **Not** dropped by the reader: /// [`num_frames`](Self::num_frames) counts them, so a caller that wants the /// audible stream skips them and takes `num_frames - delay` samples. diff --git a/shims/symphonia/src/lib.rs b/shims/symphonia/src/lib.rs index 558221ab..b38a9eb1 100644 --- a/shims/symphonia/src/lib.rs +++ b/shims/symphonia/src/lib.rs @@ -87,7 +87,7 @@ const REGISTERED: &[(AudioCodecId, &str, &str)] = &[ (CODEC_ID_VORBIS, "vorbis", "Vorbis"), (CODEC_ID_FLAC, "flac", "Free Lossless Audio Codec"), (CODEC_ID_MP3, "mp3", "MPEG-1/2 Audio Layer III"), - (CODEC_ID_ALAC, "alac", "Apple Lossless Audio Codec"), + (CODEC_ID_ALAC, "alac", "ALAC"), (CODEC_ID_AC3, "ac3", "Dolby Digital"), (CODEC_ID_EAC3, "eac3", "Dolby Digital Plus"), (CODEC_ID_PCM_U8, "pcm_u8", "PCM unsigned 8-bit"),