Skip to content

Commit 0f39f07

Browse files
alfredoyangkinetiknz
alfredoyang
authored andcommitted
'chan' box could be exist in other audio entry.
1 parent 17debc7 commit 0f39f07

File tree

3 files changed

+9
-17
lines changed

3 files changed

+9
-17
lines changed

mp4parse/src/boxes.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,5 @@ box_database!(
137137
OriginalFormatBox 0x66726d61, // "frma"
138138
MP3AudioSampleEntry 0x2e6d7033, // ".mp3" - from F4V.
139139
CompositionOffsetBox 0x63747473, // "ctts"
140-
AudioChannelLayoutAtom 0x6368616E, // "chan" - quicktime atom
141140
LPCMAudioSampleEntry 0x6C70636D, // "lpcm" - quicktime atom
142141
);

mp4parse/src/lib.rs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1863,12 +1863,11 @@ fn read_audio_sample_entry<T: Read>(src: &mut BMFFBox<T>) -> Result<(CodecType,
18631863
_ => return Err(Error::Unsupported("unsupported non-isom audio sample entry")),
18641864
}
18651865

1866-
let mut codec_type = CodecType::Unknown;
1867-
let mut codec_specific = None;
1868-
if name == BoxType::MP3AudioSampleEntry {
1869-
codec_type = CodecType::MP3;
1870-
codec_specific = Some(AudioCodecSpecific::MP3);
1871-
}
1866+
let (mut codec_type, mut codec_specific) = match name {
1867+
BoxType::MP3AudioSampleEntry => (CodecType::MP3, Some(AudioCodecSpecific::MP3)),
1868+
BoxType::LPCMAudioSampleEntry => (CodecType::LPCM, Some(AudioCodecSpecific::LPCM)),
1869+
_ => (CodecType::Unknown, None),
1870+
};
18721871
let mut protection_info = Vec::new();
18731872
let mut iter = src.box_iter();
18741873
while let Some(mut b) = iter.next_box()? {
@@ -1916,15 +1915,6 @@ fn read_audio_sample_entry<T: Read>(src: &mut BMFFBox<T>) -> Result<(CodecType,
19161915
codec_type = CodecType::EncryptedAudio;
19171916
vec_push(&mut protection_info, sinf)?;
19181917
}
1919-
BoxType::AudioChannelLayoutAtom => {
1920-
if name != BoxType::LPCMAudioSampleEntry {
1921-
return Err(Error::InvalidData("malformed audio sample entry"));
1922-
}
1923-
// skip 'chan' for now.
1924-
skip_box_content(&mut b)?;
1925-
codec_type = CodecType::LPCM;
1926-
codec_specific = Some(AudioCodecSpecific::LPCM);
1927-
}
19281918
_ => {
19291919
log!("Unsupported audio codec, box {:?} found", b.head.name);
19301920
skip_box_content(&mut b)?;

mp4parse/src/tests.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,9 @@ fn read_qt_wave_atom() {
848848
.B8(0x6b) // mp3
849849
.append_repeated(0, 12)
850850
}).into_inner();
851+
let chan = make_box(BoxSize::Auto, b"chan", |s| {
852+
s.append_repeated(0, 10) // we don't care its data.
853+
}).into_inner();
851854
let wave = make_box(BoxSize::Auto, b"wave", |s| {
852855
s.append_bytes(esds.as_slice())
853856
}).into_inner();
@@ -862,6 +865,7 @@ fn read_qt_wave_atom() {
862865
.B32(48000 << 16)
863866
.append_repeated(0, 16)
864867
.append_bytes(wave.as_slice())
868+
.append_bytes(chan.as_slice())
865869
});
866870

867871
let mut iter = super::BoxIter::new(&mut stream);
@@ -1172,4 +1176,3 @@ fn read_stsd_lpcm() {
11721176
}
11731177

11741178
}
1175-

0 commit comments

Comments
 (0)