Skip to content

Commit a257137

Browse files
authored
Merge pull request #326 from kinetiknz/bmo1722497
Recognize ISO 13818-7 MPEG-2 object types for AAC.
2 parents df0591f + f5e43c4 commit a257137

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

mp4parse/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4290,7 +4290,7 @@ fn read_dc_descriptor(data: &[u8], esds: &mut ES_Descriptor) -> Result<()> {
42904290
}
42914291

42924292
esds.audio_codec = match object_profile {
4293-
0x40 | 0x41 => CodecType::AAC,
4293+
0x40 | 0x66 | 0x67 => CodecType::AAC,
42944294
0x69 | 0x6B => CodecType::MP3,
42954295
_ => CodecType::Unknown,
42964296
};

mp4parse/src/tests.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,6 +1078,35 @@ fn read_esds_aac_type5() {
10781078
assert_eq!(es.decoder_specific_data, aac_dc_descriptor);
10791079
}
10801080

1081+
#[test]
1082+
fn read_esds_mpeg2_aac_lc() {
1083+
// Recognize MPEG-2 AAC LC (ISO 13818-7) object type as AAC.
1084+
// Extracted from BMO #1722497 sdasdasdasd_001.mp4 using Bento4.
1085+
// "mp4extract --payload-only moov/trak[1]/mdia/minf/stbl/stsd/mp4a/esds sdasdasdasd_001.mp4 /dev/stdout | xxd -i -c 15"
1086+
let aac_esds = vec![
1087+
0x03, 0x19, 0x00, 0x00, 0x00, 0x04, 0x11, 0x67, 0x15, 0x00, 0x02, 0x38, 0x00, 0x01, 0x0f,
1088+
0xd0, 0x00, 0x00, 0xf5, 0x48, 0x05, 0x02, 0x13, 0x90, 0x06, 0x01, 0x02,
1089+
];
1090+
let aac_dc_descriptor = &aac_esds[22..24];
1091+
1092+
let mut stream = make_box(BoxSize::Auto, b"esds", |s| {
1093+
s.B32(0) // reserved
1094+
.append_bytes(aac_esds.as_slice())
1095+
});
1096+
let mut iter = super::BoxIter::new(&mut stream);
1097+
let mut stream = iter.next_box().unwrap().unwrap();
1098+
1099+
let es = super::read_esds(&mut stream).unwrap();
1100+
1101+
assert_eq!(es.audio_codec, super::CodecType::AAC);
1102+
assert_eq!(es.audio_object_type, Some(2));
1103+
assert_eq!(es.extended_audio_object_type, None);
1104+
assert_eq!(es.audio_sample_rate, Some(22050));
1105+
assert_eq!(es.audio_channel_count, Some(2));
1106+
assert_eq!(es.codec_esds, aac_esds);
1107+
assert_eq!(es.decoder_specific_data, aac_dc_descriptor);
1108+
}
1109+
10811110
#[test]
10821111
fn read_stsd_mp4v() {
10831112
let mp4v = vec![

0 commit comments

Comments
 (0)