Skip to content

Commit 89c725e

Browse files
author
Kevin Calhoun
committed
Per ISO 14496-1 § 7.2.6.7.2, the semantics of decoder specific information
depend on the value of DecoderConfigDescriptor.objectTypeIndication. But for audio, mp4parse treats all decoder specific information as if it has the bit syntax defined for object type indication 0x40. This is not the case for object type indications 0x69 and 0x6B, which now have more recently defined decoder specific information with a distinct bit syntax, which Mozilla code can disregard. This allows tracks carrying MP3 audio to be parsed correctly when the new decoder specific info is present.
1 parent 778d47d commit 89c725e

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

mp4parse/src/lib.rs

+14-4
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ pub enum SampleEntry {
379379
#[allow(non_camel_case_types)]
380380
#[derive(Debug, Default)]
381381
pub struct ES_Descriptor {
382+
pub object_profile: u8,
382383
pub audio_codec: CodecType,
383384
pub audio_object_type: Option<u16>,
384385
pub extended_audio_object_type: Option<u16>,
@@ -2452,7 +2453,16 @@ fn find_descriptor(data: &[u8], esds: &mut ES_Descriptor) -> Result<()> {
24522453
read_dc_descriptor(descriptor, esds)?;
24532454
}
24542455
DECODER_SPECIFIC_TAG => {
2455-
read_ds_descriptor(descriptor, esds)?;
2456+
match esds.object_profile {
2457+
0x69 | 0x6B => {
2458+
// Could parse these object types' decoder specific info
2459+
// to discover the MPEG audio layer, etc., if needed.
2460+
break;
2461+
}
2462+
_ => {
2463+
read_ds_descriptor(descriptor, esds)?;
2464+
}
2465+
};
24562466
}
24572467
_ => {
24582468
debug!("Unsupported descriptor, tag {}", tag);
@@ -2647,7 +2657,7 @@ fn read_surround_channel_count(bit_reader: &mut BitReader, channels: u8) -> Resu
26472657
/// See ISO 14496-1:2010 § 7.2.6.6
26482658
fn read_dc_descriptor(data: &[u8], esds: &mut ES_Descriptor) -> Result<()> {
26492659
let des = &mut Cursor::new(data);
2650-
let object_profile = des.read_u8()?;
2660+
esds.object_profile = des.read_u8()?;
26512661

26522662
// Skip uninteresting fields.
26532663
skip(des, 12)?;
@@ -2656,9 +2666,9 @@ fn read_dc_descriptor(data: &[u8], esds: &mut ES_Descriptor) -> Result<()> {
26562666
find_descriptor(&data[des.position().try_into()?..data.len()], esds)?;
26572667
}
26582668

2659-
esds.audio_codec = match object_profile {
2669+
esds.audio_codec = match esds.object_profile {
26602670
0x40 | 0x41 => CodecType::AAC,
2661-
0x6B => CodecType::MP3,
2671+
0x69 | 0x6B => CodecType::MP3,
26622672
_ => CodecType::Unknown,
26632673
};
26642674

0 commit comments

Comments
 (0)