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

AAC missing channel fix #58

Merged
merged 2 commits into from
Nov 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions symphonia-codec-aac/src/aac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1616,6 +1616,9 @@ impl Decoder for AacDecoder {
m4ainfo.read(extra_data_buf)?;
}
else {
validate!(params.sample_rate.is_some());
validate!(params.channels.is_some());

// Otherwise, assume there is no ASC and use the codec parameters for ADTS.
m4ainfo.srate = params.sample_rate.unwrap();
m4ainfo.otype = M4AType::Lc;
Expand Down
37 changes: 37 additions & 0 deletions symphonia-codec-aac/tests/tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use symphonia_core::codecs::{CodecParameters, Decoder, DecoderOptions};
use symphonia_core::errors;
use symphonia_core::formats::{FormatOptions, FormatReader};

fn test_decode(data: Vec<u8>) -> symphonia_core::errors::Result<()> {
let data = std::io::Cursor::new(data);

let source = symphonia_core::io::MediaSourceStream::new(Box::new(data), Default::default());

let mut reader =
symphonia_codec_aac::AdtsReader::try_new(source, &FormatOptions::default())?;

let mut decoder = symphonia_codec_aac::AacDecoder::try_new(
&CodecParameters::default(),
&DecoderOptions::default(),
)?;

loop {
let packet = reader.next_packet()?;
let _ = decoder.decode(&packet);
}
}

#[test]
fn invalid_channels_aac() {
let file = vec![
0xff, 0xf1, 0xaf, 0xce, 0x02, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xfb,
0xaf,
];

let err = test_decode(file).unwrap_err();

match err {
errors::Error::DecodeError("aac: invalid data") => {}
e => panic!("Unexpected error {:?}", e),
}
}