Skip to content

Commit

Permalink
Per ISO 14496-1 § 7.2.6.7.2, the semantics of decoder specific inform…
Browse files Browse the repository at this point in the history
…ation

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.
  • Loading branch information
Kevin Calhoun committed Jul 4, 2020
1 parent 778d47d commit 89c725e
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions mp4parse/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ pub enum SampleEntry {
#[allow(non_camel_case_types)]
#[derive(Debug, Default)]
pub struct ES_Descriptor {
pub object_profile: u8,
pub audio_codec: CodecType,
pub audio_object_type: Option<u16>,
pub extended_audio_object_type: Option<u16>,
Expand Down Expand Up @@ -2452,7 +2453,16 @@ fn find_descriptor(data: &[u8], esds: &mut ES_Descriptor) -> Result<()> {
read_dc_descriptor(descriptor, esds)?;
}
DECODER_SPECIFIC_TAG => {
read_ds_descriptor(descriptor, esds)?;
match esds.object_profile {
0x69 | 0x6B => {
// Could parse these object types' decoder specific info
// to discover the MPEG audio layer, etc., if needed.
break;
}
_ => {
read_ds_descriptor(descriptor, esds)?;
}
};
}
_ => {
debug!("Unsupported descriptor, tag {}", tag);
Expand Down Expand Up @@ -2647,7 +2657,7 @@ fn read_surround_channel_count(bit_reader: &mut BitReader, channels: u8) -> Resu
/// See ISO 14496-1:2010 § 7.2.6.6
fn read_dc_descriptor(data: &[u8], esds: &mut ES_Descriptor) -> Result<()> {
let des = &mut Cursor::new(data);
let object_profile = des.read_u8()?;
esds.object_profile = des.read_u8()?;

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

esds.audio_codec = match object_profile {
esds.audio_codec = match esds.object_profile {
0x40 | 0x41 => CodecType::AAC,
0x6B => CodecType::MP3,
0x69 | 0x6B => CodecType::MP3,
_ => CodecType::Unknown,
};

Expand Down

0 comments on commit 89c725e

Please # to comment.