Skip to content

Recognize ISO 13818-7 MPEG-2 object types for AAC. #326

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

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
2 changes: 1 addition & 1 deletion mp4parse/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4068,7 +4068,7 @@ fn read_dc_descriptor(data: &[u8], esds: &mut ES_Descriptor) -> Result<()> {
}

esds.audio_codec = match object_profile {
0x40 | 0x41 => CodecType::AAC,
0x40 | 0x66 | 0x67 => CodecType::AAC,
0x69 | 0x6B => CodecType::MP3,
_ => CodecType::Unknown,
};
Expand Down
29 changes: 29 additions & 0 deletions mp4parse/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,35 @@ fn read_esds_aac_type5() {
assert_eq!(es.decoder_specific_data, aac_dc_descriptor);
}

#[test]
fn read_esds_mpeg2_aac_lc() {
// Recognize MPEG-2 AAC LC (ISO 13818-7) object type as AAC.
// Extracted from BMO #1722497 sdasdasdasd_001.mp4 using Bento4.
// "mp4extract --payload-only moov/trak[1]/mdia/minf/stbl/stsd/mp4a/esds sdasdasdasd_001.mp4 /dev/stdout | xxd -i -c 15"
let aac_esds = vec![
0x03, 0x19, 0x00, 0x00, 0x00, 0x04, 0x11, 0x67, 0x15, 0x00, 0x02, 0x38, 0x00, 0x01, 0x0f,
0xd0, 0x00, 0x00, 0xf5, 0x48, 0x05, 0x02, 0x13, 0x90, 0x06, 0x01, 0x02,
];
let aac_dc_descriptor = &aac_esds[22..24];

let mut stream = make_box(BoxSize::Auto, b"esds", |s| {
s.B32(0) // reserved
.append_bytes(aac_esds.as_slice())
});
let mut iter = super::BoxIter::new(&mut stream);
let mut stream = iter.next_box().unwrap().unwrap();

let es = super::read_esds(&mut stream).unwrap();

assert_eq!(es.audio_codec, super::CodecType::AAC);
assert_eq!(es.audio_object_type, Some(2));
assert_eq!(es.extended_audio_object_type, None);
assert_eq!(es.audio_sample_rate, Some(22050));
assert_eq!(es.audio_channel_count, Some(2));
assert_eq!(es.codec_esds, aac_esds);
assert_eq!(es.decoder_specific_data, aac_dc_descriptor);
}

#[test]
fn read_stsd_mp4v() {
let mp4v = vec![
Expand Down