diff --git a/crates/ec-mp4/src/mux.rs b/crates/ec-mp4/src/mux.rs index b047d19e..f1d9a0af 100644 --- a/crates/ec-mp4/src/mux.rs +++ b/crates/ec-mp4/src/mux.rs @@ -1431,9 +1431,6 @@ fn sample_entry( let at = open(out, name); out.extend_from_slice(&[0; 6]); out.extend_from_slice(&1u16.to_be_bytes()); // data_reference_index - // QuickTime PCM wider than 16 bits: sound description version 1 with a - // `wave`/`enda` up to two channels, and version 2 (`lpcm`) beyond that, - // as ffmpeg writes them in a .mov. let qt = qt_pcm(codec); let channels = audio.layout.channel_count() as u32; let v2 = qt.is_some() && channels > 2; @@ -1447,8 +1444,8 @@ fn sample_entry( }; out.extend_from_slice(&(bits as u16).to_be_bytes()); let pre_defined: u16 = if v2 { 0xFFFE } else { 0 }; - out.extend_from_slice(&pre_defined.to_be_bytes()); // compression id -2 in version 2 - out.extend_from_slice(&0u16.to_be_bytes()); // reserved: packet size + out.extend_from_slice(&pre_defined.to_be_bytes()); + out.extend_from_slice(&0u16.to_be_bytes()); // 16.16, so a rate over 65535 is stated as its low half — which is what // every writer does and what the `mdhd` timescale says exactly anyway. let rate: u32 = if v2 { @@ -1463,14 +1460,14 @@ fn sample_entry( let kind: u32 = if float { 1 } else { 4 }; let order: u32 = if little { 0 } else { 2 }; let flags = kind | order | 8; - out.extend_from_slice(&72u32.to_be_bytes()); // size of this description + out.extend_from_slice(&72u32.to_be_bytes()); out.extend_from_slice(&f64::from(audio.sample_rate).to_be_bytes()); out.extend_from_slice(&channels.to_be_bytes()); out.extend_from_slice(&0x7f00_0000u32.to_be_bytes()); - out.extend_from_slice(&(bytes * 8).to_be_bytes()); // bits per channel + out.extend_from_slice(&(bytes * 8).to_be_bytes()); out.extend_from_slice(&flags.to_be_bytes()); - out.extend_from_slice(&(bytes * channels).to_be_bytes()); // bytes per packet - out.extend_from_slice(&1u32.to_be_bytes()); // frames per packet + out.extend_from_slice(&(bytes * channels).to_be_bytes()); + out.extend_from_slice(&1u32.to_be_bytes()); } Some((bytes, little)) => { out.extend_from_slice(&1u32.to_be_bytes()); // samples per packet diff --git a/crates/ec-ogg/tests/ogg.rs b/crates/ec-ogg/tests/ogg.rs index b006678f..c9350c0b 100644 --- a/crates/ec-ogg/tests/ogg.rs +++ b/crates/ec-ogg/tests/ogg.rs @@ -341,9 +341,6 @@ fn damage_costs_one_page_and_no_more() { let (_, clean, _) = demux_all(path); let bytes = std::fs::read(path).unwrap(); - // Flip a bit three quarters in: past the header pages and inside an audio - // page with audio on both sides, so the page's checksum fails and its - // packets are lost — and nothing else is. let mut damaged = bytes.clone(); let at = damaged.len() * 3 / 4; damaged[at] ^= 0x40; diff --git a/crates/ec-riff/tests/it/wav.rs b/crates/ec-riff/tests/it/wav.rs index 4077063f..7687f265 100644 --- a/crates/ec-riff/tests/it/wav.rs +++ b/crates/ec-riff/tests/it/wav.rs @@ -438,25 +438,26 @@ fn reads_every_wav_fixture() { continue; } let name = path.file_name().unwrap().to_string_lossy().to_string(); - if name.starts_with('.') || name == "mp3src.wav" { + 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. - let channels = if name.contains("mono") { - 1 - } else if name.contains("stereo") { - 2 - } else { - 6 - }; - assert_eq!(spec.channels, channels, "{name}"); - assert!(name.contains(&spec.sample_rate.to_string()), "{name}"); + if name != "mp3src.wav" { + let channels = if name.contains("mono") { + 1 + } else if name.contains("stereo") { + 2 + } else { + 6 + }; + assert_eq!(spec.channels, channels, "{name}"); + assert!(name.contains(&spec.sample_rate.to_string()), "{name}"); + } assert_eq!(spec.sample_format, SampleType::Int, "{name}"); let samples = r.read_all_i32().unwrap(); assert!(!samples.is_empty(), "{name} decoded nothing"); - assert_eq!(samples.len() % usize::from(channels), 0, "{name}"); + assert_eq!(samples.len() % usize::from(spec.channels), 0, "{name}"); assert!( samples.iter().any(|&v| v != 0), "{name} is silence — the fixture or the reader is wrong"