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

Ignore decoder specific info for object types 0x69 and 0x6B #227

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
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