Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/12 bit aiff #218

Draft
wants to merge 32 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
b9c74dd
setup of riff module, support for PCM aiff
Mar 5, 2023
2316cc4
CommonChunk parse now errors if reading samplerate data fails
Mar 26, 2023
0da1f52
CommonChunk::parse now uses shorthand for creating array
Mar 26, 2023
e3bbe1e
Added dedobbin as author of symphonia-format-riff
Mar 26, 2023
d09f474
updated comment for AIFF_MAX_FRAMES_PER_PACKET
Mar 26, 2023
30c7bb9
renamed riff reader to aiffreader, will make seperate readers for oth…
Apr 22, 2023
5ad5a2b
moved reusable riff logic from aiff to its own file
Apr 23, 2023
9263e8b
allow deadcode for logic in aiff module that will/can be used by wav
Apr 23, 2023
5953c47
used proper formatting
Apr 25, 2023
cfa85e5
replaced todo! with unsupported error + removed double comment
Apr 25, 2023
3684e06
aifc support
Apr 26, 2023
090b332
added wav to riff - unexported
Apr 28, 2023
60d99c3
changed implementation of reading aifc pascal string
Apr 29, 2023
c278ced
Can read aifc with no compression
Apr 29, 2023
3ad8de8
can play mulaw compressed aifc
May 2, 2023
6336429
Merge branch 'feature/riff' into feature/aifc
May 3, 2023
14a8fda
can play float aiff
May 3, 2023
db01e59
can read ieee float 64bit aifc
May 3, 2023
771fbb8
implement missing formats for aiff CommonChunk fmt::Display
May 4, 2023
50a5b91
can read alaw aifc
May 7, 2023
10566f7
Removed comment
May 7, 2023
ae9db60
aiff: support for capitalized compression_type
May 7, 2023
cffad2d
aiff: correctly refer to sound chunk
May 7, 2023
c17a6d7
support for riff with samplesize non divisible by 8
May 13, 2023
c27a05f
Merge branch 'master' into feature/12-bit-aiff
Jun 14, 2023
bc2ca53
correctly set bits in read_pcm_unsigned_be and read_pcm_signed_be
Jun 16, 2023
9f72a21
Merge branch 'master' into feature/12-bit-aiff
Jun 16, 2023
0dbd586
aiff: CommonChunk uses range in match statement
Jun 16, 2023
22dac31
Merge branch 'master' into feature/12-bit-aiff
Jul 23, 2023
ebb5ea4
corrected error message regarding aiff bits per sample support
Jul 23, 2023
8c8b1c4
wav: support more sample sizes
Jul 23, 2023
5375843
codec-pcm: properly mask out right most bits when BE encoded file has…
Aug 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 42 additions & 6 deletions symphonia-codec-pcm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,21 @@ macro_rules! read_pcm_signed {
};
}

macro_rules! read_pcm_signed_be {
($buf:expr, $fmt:tt, $read:expr, $width:expr, $coded_width:expr) => {{
let mask = !((1 << ($width - $coded_width)) - 1);
match $buf {
GenericAudioBuffer::$fmt(ref mut buf) => buf.fill(|audio_planes, idx| -> Result<()> {
for plane in audio_planes.planes() {
plane[idx] = ($read & mask).into_sample();
}
Ok(())
}),
_ => unreachable!(),
}
}};
}

macro_rules! read_pcm_unsigned {
($buf:expr, $fmt:tt, $read:expr, $width:expr, $coded_width:expr) => {
// Get buffer of the correct sample format.
Expand All @@ -136,6 +151,21 @@ macro_rules! read_pcm_unsigned {
};
}

macro_rules! read_pcm_unsigned_be {
($buf:expr, $fmt:tt, $read:expr, $width:expr, $coded_width:expr) => {{
let mask = !((1 << ($width - $coded_width)) - 1);
match $buf {
GenericAudioBuffer::$fmt(ref mut buf) => buf.fill(|audio_planes, idx| -> Result<()> {
for plane in audio_planes.planes() {
plane[idx] = ($read & mask).into_sample();
}
Ok(())
}),
_ => unreachable!(),
}
}};
}

macro_rules! read_pcm_floating {
($buf:expr, $fmt:tt, $read:expr) => {
// Get buffer of the correct sample format.
Expand Down Expand Up @@ -259,19 +289,19 @@ impl PcmDecoder {
read_pcm_signed!(self.buf, S32, reader.read_i32()?, 32, self.coded_width)
}
CODEC_TYPE_PCM_S32BE => {
read_pcm_signed!(self.buf, S32, reader.read_be_i32()?, 32, self.coded_width)
read_pcm_signed_be!(self.buf, S32, reader.read_be_i32()?, 32, self.coded_width)
}
CODEC_TYPE_PCM_S24LE => {
read_pcm_signed!(self.buf, S24, reader.read_i24()? << 8, 24, self.coded_width)
}
CODEC_TYPE_PCM_S24BE => {
read_pcm_signed!(self.buf, S24, reader.read_be_i24()? << 8, 24, self.coded_width)
read_pcm_signed_be!(self.buf, S24, reader.read_be_i24()? << 8, 24, self.coded_width)
}
CODEC_TYPE_PCM_S16LE => {
read_pcm_signed!(self.buf, S16, reader.read_i16()?, 16, self.coded_width)
}
CODEC_TYPE_PCM_S16BE => {
read_pcm_signed!(self.buf, S16, reader.read_be_i16()?, 16, self.coded_width)
read_pcm_signed_be!(self.buf, S16, reader.read_be_i16()?, 16, self.coded_width)
}
CODEC_TYPE_PCM_S8 => {
read_pcm_signed!(self.buf, S8, reader.read_i8()?, 8, self.coded_width)
Expand All @@ -280,19 +310,25 @@ impl PcmDecoder {
read_pcm_unsigned!(self.buf, U32, reader.read_u32()?, 32, self.coded_width)
}
CODEC_TYPE_PCM_U32BE => {
read_pcm_unsigned!(self.buf, U32, reader.read_be_u32()?, 32, self.coded_width)
read_pcm_unsigned_be!(self.buf, U32, reader.read_be_u32()?, 32, self.coded_width)
}
CODEC_TYPE_PCM_U24LE => {
read_pcm_unsigned!(self.buf, U24, reader.read_u24()? << 8, 24, self.coded_width)
}
CODEC_TYPE_PCM_U24BE => {
read_pcm_unsigned!(self.buf, U24, reader.read_be_u24()? << 8, 24, self.coded_width)
read_pcm_unsigned_be!(
self.buf,
U24,
reader.read_be_u24()? << 8,
24,
self.coded_width
)
}
CODEC_TYPE_PCM_U16LE => {
read_pcm_unsigned!(self.buf, U16, reader.read_u16()?, 16, self.coded_width)
}
CODEC_TYPE_PCM_U16BE => {
read_pcm_unsigned!(self.buf, U16, reader.read_be_u16()?, 16, self.coded_width)
read_pcm_unsigned_be!(self.buf, U16, reader.read_be_u16()?, 16, self.coded_width)
}
CODEC_TYPE_PCM_U8 => {
read_pcm_unsigned!(self.buf, U8, reader.read_u8()?, 8, self.coded_width)
Expand Down
12 changes: 6 additions & 6 deletions symphonia-format-riff/src/aiff/chunks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ impl CommonChunk {
// error if not a multiple of 8 or greater than 32-bits.
//
// It is possible though for AIFF to have a sample size not divisible by 8.
// Data is left justified, with the remaining bits zeroed. Currently not supported.
// Data is left justified, with the remaining bits zeroed.
//
// Select the appropriate codec using bits per sample. Samples are always interleaved and
// little-endian encoded for the PCM format.
let codec = match bits_per_sample {
8 => CODEC_TYPE_PCM_S8,
16 => CODEC_TYPE_PCM_S16BE,
24 => CODEC_TYPE_PCM_S24BE,
32 => CODEC_TYPE_PCM_S32BE,
_ => return decode_error("aiff: bits per sample for pcm must be 8, 16, 24 or 32 bits"),
1..=8 => CODEC_TYPE_PCM_S8,
9..=16 => CODEC_TYPE_PCM_S16BE,
17..=24 => CODEC_TYPE_PCM_S24BE,
25..=32 => CODEC_TYPE_PCM_S32BE,
_ => return decode_error("aiff: bits per sample unsupported for pcm"),
};

let channels = try_channel_count_to_mask(n_channels)?;
Expand Down
14 changes: 5 additions & 9 deletions symphonia-format-riff/src/wave/chunks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,11 @@ impl WaveFormatChunk {
// Select the appropriate codec using bits per sample. Samples are always interleaved and
// little-endian encoded for the PCM format.
let codec = match bits_per_sample {
8 => CODEC_TYPE_PCM_U8,
16 => CODEC_TYPE_PCM_S16LE,
24 => CODEC_TYPE_PCM_S24LE,
32 => CODEC_TYPE_PCM_S32LE,
_ => {
return decode_error(
"wav: bits per sample for fmt_pcm must be 8, 16, 24 or 32 bits",
)
}
1..=8 => CODEC_TYPE_PCM_U8,
9..=16 => CODEC_TYPE_PCM_S16LE,
17..=24 => CODEC_TYPE_PCM_S24LE,
25..=32 => CODEC_TYPE_PCM_S32LE,
_ => return decode_error("wav: bits per sample unsupported for pcm"),
};

let channels = try_channel_count_to_mask(n_channels)?;
Expand Down
Loading