mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-07 12:13:20 +00:00
craft-audio: review fixes, round 2 (#442)
- check_room docs: FLAC holds at most 2^36 - 1 frames. - The FLAC round trip covers every channel count from 1 to 8. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
7c88c201a5
commit
76df23e86e
@@ -75,7 +75,7 @@ impl<W: Write + Seek> Writer<W> {
|
||||
})
|
||||
}
|
||||
|
||||
/// The frame count after `frames` more, or an error past what FLAC can count (2^36 frames).
|
||||
/// The frame count after `frames` more, or an error past what FLAC can count (2^36 - 1 frames).
|
||||
pub(crate) fn check_room(&self, frames: u64) -> Result<u64> {
|
||||
let total = self.frames.saturating_add(frames);
|
||||
if total >= 1u64 << 36 {
|
||||
|
||||
@@ -175,7 +175,7 @@ impl<W: Write + Seek> FileEncoder<W> {
|
||||
}
|
||||
|
||||
/// Fails, without writing anything, when `frames` more frames would not fit the format (an
|
||||
/// AIFF holds 4 GiB, a FLAC 2^36 frames).
|
||||
/// AIFF holds 4 GiB, a FLAC 2^36 - 1 frames).
|
||||
pub fn check_room(&self, frames: u64) -> Result<()> {
|
||||
match &self.writer {
|
||||
#[cfg(feature = "pcm-encode")]
|
||||
|
||||
@@ -73,7 +73,7 @@ fn wav_and_aiff_roundtrip_all_depths_and_layouts() {
|
||||
#[test]
|
||||
fn flac_roundtrip_is_lossless_vs_wav() {
|
||||
for depth in [BitDepth::Int16, BitDepth::Int24, BitDepth::Int32] {
|
||||
for channels in [1, 2, 6] {
|
||||
for channels in [1, 2, 3, 4, 5, 6, 7, 8] {
|
||||
// Spans several blocks plus a short final block.
|
||||
let src = sine(44_100, channels, 4096 * 2 + 17);
|
||||
let wav = encode(&src, &EncodeOptions::new(EncodeFormat::Wav).with_bit_depth(depth).with_dither(false)).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user