Skip to content

Commit

Permalink
wav: add ambisonic bformat subtypes
Browse files Browse the repository at this point in the history
  • Loading branch information
aentity committed Feb 18, 2024
1 parent 8f89962 commit efe9b0f
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions symphonia-format-wav/src/chunks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ fn fix_channel_mask(mut channel_mask: u32, n_channels: u16) -> u32 {
// Too few ones in mask so add extra ones above the most significant one
let shift = 32 - (!channel_mask).leading_ones();
channel_mask |= ((1 << channel_diff) - 1) << shift;
}
else {
} else {
// Too many ones in mask so remove the most significant extra ones
while channel_mask.count_ones() != n_channels as u32 {
let highest_one = 31 - (!channel_mask).leading_ones();
Expand Down Expand Up @@ -475,10 +474,20 @@ impl WaveFormatChunk {
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71,
];
#[rustfmt::skip]
const KSDATAFORMAT_SUBTYPE_AMBISONIC_B_FORMAT_PCM: [u8; 16] = [
0x01, 0x00, 0x00, 0x00, 0x21, 0x07, 0xd3, 0x11,
0x86, 0x44, 0xc8, 0xc1, 0xca, 0x00, 0x00, 0x00,
];
#[rustfmt::skip]
const KSDATAFORMAT_SUBTYPE_AMBISONIC_B_FORMAT_IEE_FLOAT: [u8; 16] = [
0x03, 0x00, 0x00, 0x00, 0x21, 0x07, 0xd3, 0x11,
0x86, 0x44, 0xc8, 0xc1, 0xca, 0x00, 0x00, 0x00,
];

// Verify support based on the format GUID.
let codec = match sub_format_guid {
KSDATAFORMAT_SUBTYPE_PCM => {
KSDATAFORMAT_SUBTYPE_PCM | KSDATAFORMAT_SUBTYPE_AMBISONIC_B_FORMAT_PCM => {
// Only support up-to 32-bit integer samples.
if bits_per_coded_sample > 32 {
return decode_error(
Expand All @@ -496,7 +505,7 @@ impl WaveFormatChunk {
_ => unreachable!(),
}
}
KSDATAFORMAT_SUBTYPE_IEEE_FLOAT => {
KSDATAFORMAT_SUBTYPE_IEEE_FLOAT | KSDATAFORMAT_SUBTYPE_AMBISONIC_B_FORMAT_IEE_FLOAT => {
// IEEE floating formats do not support truncated sample widths.
if bits_per_sample != bits_per_coded_sample {
return decode_error(
Expand Down

0 comments on commit efe9b0f

Please sign in to comment.