Remove comments added in the fix round; wav fixture test keeps decode checks for mp3src.wav and skips only its name-based layout check (its name carries no layout or rate)
Browse files at this commite13f1153c642f1f877831bd72e0c1c81bd3afd10Parent: 12627803 changed files +19 -24
- crates/ec-mp4/src/mux.rs +6 -9
- crates/ec-ogg/tests/ogg.rs +0 -3
- crates/ec-riff/tests/it/wav.rs +13 -12
crates/ec-mp4/src/mux.rsmodified+6 -9
| @@ -1431,9 +1431,6 @@ fn sample_entry( | |||
| 1431 | let at = open(out, name); | 1431 | let at = open(out, name); |
| 1432 | out.extend_from_slice(&[0; 6]); | 1432 | out.extend_from_slice(&[0; 6]); |
| 1433 | out.extend_from_slice(&1u16.to_be_bytes()); // data_reference_index | 1433 | out.extend_from_slice(&1u16.to_be_bytes()); // data_reference_index |
| 1434 | - // QuickTime PCM wider than 16 bits: sound description version 1 with a | ||
| 1435 | - // `wave`/`enda` up to two channels, and version 2 (`lpcm`) beyond that, | ||
| 1436 | - // as ffmpeg writes them in a .mov. | ||
| 1437 | let qt = qt_pcm(codec); | 1434 | let qt = qt_pcm(codec); |
| 1438 | let channels = audio.layout.channel_count() as u32; | 1435 | let channels = audio.layout.channel_count() as u32; |
| 1439 | let v2 = qt.is_some() && channels > 2; | 1436 | let v2 = qt.is_some() && channels > 2; |
| @@ -1447,8 +1444,8 @@ fn sample_entry( | |||
| 1447 | }; | 1444 | }; |
| 1448 | out.extend_from_slice(&(bits as u16).to_be_bytes()); | 1445 | out.extend_from_slice(&(bits as u16).to_be_bytes()); |
| 1449 | let pre_defined: u16 = if v2 { 0xFFFE } else { 0 }; | 1446 | let pre_defined: u16 = if v2 { 0xFFFE } else { 0 }; |
| 1450 | - out.extend_from_slice(&pre_defined.to_be_bytes()); // compression id -2 in version 2 | 1447 | + out.extend_from_slice(&pre_defined.to_be_bytes()); |
| 1451 | - out.extend_from_slice(&0u16.to_be_bytes()); // reserved: packet size | 1448 | + out.extend_from_slice(&0u16.to_be_bytes()); |
| 1452 | // 16.16, so a rate over 65535 is stated as its low half — which is what | 1449 | // 16.16, so a rate over 65535 is stated as its low half — which is what |
| 1453 | // every writer does and what the `mdhd` timescale says exactly anyway. | 1450 | // every writer does and what the `mdhd` timescale says exactly anyway. |
| 1454 | let rate: u32 = if v2 { | 1451 | let rate: u32 = if v2 { |
| @@ -1463,14 +1460,14 @@ fn sample_entry( | |||
| 1463 | let kind: u32 = if float { 1 } else { 4 }; | 1460 | let kind: u32 = if float { 1 } else { 4 }; |
| 1464 | let order: u32 = if little { 0 } else { 2 }; | 1461 | let order: u32 = if little { 0 } else { 2 }; |
| 1465 | let flags = kind | order | 8; | 1462 | let flags = kind | order | 8; |
| 1466 | - out.extend_from_slice(&72u32.to_be_bytes()); // size of this description | 1463 | + out.extend_from_slice(&72u32.to_be_bytes()); |
| 1467 | out.extend_from_slice(&f64::from(audio.sample_rate).to_be_bytes()); | 1464 | out.extend_from_slice(&f64::from(audio.sample_rate).to_be_bytes()); |
| 1468 | out.extend_from_slice(&channels.to_be_bytes()); | 1465 | out.extend_from_slice(&channels.to_be_bytes()); |
| 1469 | out.extend_from_slice(&0x7f00_0000u32.to_be_bytes()); | 1466 | out.extend_from_slice(&0x7f00_0000u32.to_be_bytes()); |
| 1470 | - out.extend_from_slice(&(bytes * 8).to_be_bytes()); // bits per channel | 1467 | + out.extend_from_slice(&(bytes * 8).to_be_bytes()); |
| 1471 | out.extend_from_slice(&flags.to_be_bytes()); | 1468 | out.extend_from_slice(&flags.to_be_bytes()); |
| 1472 | - out.extend_from_slice(&(bytes * channels).to_be_bytes()); // bytes per packet | 1469 | + out.extend_from_slice(&(bytes * channels).to_be_bytes()); |
| 1473 | - out.extend_from_slice(&1u32.to_be_bytes()); // frames per packet | 1470 | + out.extend_from_slice(&1u32.to_be_bytes()); |
| 1474 | } | 1471 | } |
| 1475 | Some((bytes, little)) => { | 1472 | Some((bytes, little)) => { |
| 1476 | out.extend_from_slice(&1u32.to_be_bytes()); // samples per packet | 1473 | out.extend_from_slice(&1u32.to_be_bytes()); // samples per packet |
crates/ec-ogg/tests/ogg.rsmodified+0 -3
| @@ -341,9 +341,6 @@ fn damage_costs_one_page_and_no_more() { | |||
| 341 | let (_, clean, _) = demux_all(path); | 341 | let (_, clean, _) = demux_all(path); |
| 342 | let bytes = std::fs::read(path).unwrap(); | 342 | let bytes = std::fs::read(path).unwrap(); |
| 343 | 343 | ||
| 344 | - // Flip a bit three quarters in: past the header pages and inside an audio | ||
| 345 | - // page with audio on both sides, so the page's checksum fails and its | ||
| 346 | - // packets are lost — and nothing else is. | ||
| 347 | let mut damaged = bytes.clone(); | 344 | let mut damaged = bytes.clone(); |
| 348 | let at = damaged.len() * 3 / 4; | 345 | let at = damaged.len() * 3 / 4; |
| 349 | damaged[at] ^= 0x40; | 346 | damaged[at] ^= 0x40; |
crates/ec-riff/tests/it/wav.rsmodified+13 -12
| @@ -438,25 +438,26 @@ fn reads_every_wav_fixture() { | |||
| 438 | continue; | 438 | continue; |
| 439 | } | 439 | } |
| 440 | let name = path.file_name().unwrap().to_string_lossy().to_string(); | 440 | let name = path.file_name().unwrap().to_string_lossy().to_string(); |
| 441 | - if name.starts_with('.') || name == "mp3src.wav" { | 441 | + if name.starts_with('.') { |
| 442 | continue; | 442 | continue; |
| 443 | } | 443 | } |
| 444 | let mut r = WavReader::open(&path).unwrap_or_else(|e| panic!("{name}: {e}")); | 444 | let mut r = WavReader::open(&path).unwrap_or_else(|e| panic!("{name}: {e}")); |
| 445 | let spec = r.spec(); | 445 | let spec = r.spec(); |
| 446 | - // The generator names layout and rate in the file name; the header must agree. | 446 | + if name != "mp3src.wav" { |
| 447 | - let channels = if name.contains("mono") { | 447 | + let channels = if name.contains("mono") { |
| 448 | - 1 | 448 | + 1 |
| 449 | - } else if name.contains("stereo") { | 449 | + } else if name.contains("stereo") { |
| 450 | - 2 | 450 | + 2 |
| 451 | - } else { | 451 | + } else { |
| 452 | - 6 | 452 | + 6 |
| 453 | - }; | 453 | + }; |
| 454 | - assert_eq!(spec.channels, channels, "{name}"); | 454 | + assert_eq!(spec.channels, channels, "{name}"); |
| 455 | - assert!(name.contains(&spec.sample_rate.to_string()), "{name}"); | 455 | + assert!(name.contains(&spec.sample_rate.to_string()), "{name}"); |
| 456 | + } | ||
| 456 | assert_eq!(spec.sample_format, SampleType::Int, "{name}"); | 457 | assert_eq!(spec.sample_format, SampleType::Int, "{name}"); |
| 457 | let samples = r.read_all_i32().unwrap(); | 458 | let samples = r.read_all_i32().unwrap(); |
| 458 | assert!(!samples.is_empty(), "{name} decoded nothing"); | 459 | assert!(!samples.is_empty(), "{name} decoded nothing"); |
| 459 | - assert_eq!(samples.len() % usize::from(channels), 0, "{name}"); | 460 | + assert_eq!(samples.len() % usize::from(spec.channels), 0, "{name}"); |
| 460 | assert!( | 461 | assert!( |
| 461 | samples.iter().any(|&v| v != 0), | 462 | samples.iter().any(|&v| v != 0), |
| 462 | "{name} is silence — the fixture or the reader is wrong" | 463 | "{name} is silence — the fixture or the reader is wrong" |