Skip to content

Avc1Box ignore non-AvcC boxes #105

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

Open
wants to merge 2 commits 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
37 changes: 27 additions & 10 deletions src/mp4box/avc1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,35 @@ impl<R: Read + Seek> ReadBox<&mut R> for Avc1Box {
let depth = reader.read_u16::<BigEndian>()?;
reader.read_i16::<BigEndian>()?; // pre-defined

let header = BoxHeader::read(reader)?;
let BoxHeader { name, size: s } = header;
if s > size {
return Err(Error::InvalidData(
"avc1 box contains a box with a larger size than it",
));
let mut current = reader.stream_position()?;
let end = start + size;

let mut avcc = None;

while current < end {
// Get box header.
let header = BoxHeader::read(reader)?;
let BoxHeader { name, size: s } = header;
if s > size {
return Err(Error::InvalidData(
"avc1 box contains a box with a larger size than it",
));
}

match name {
BoxType::AvcCBox => {
avcc = Some(AvcCBox::read_box(reader, s)?);
}
_ => {
// XXX warn!()
skip_box(reader, s)?;
}
}

current = reader.stream_position()?;
}
if name == BoxType::AvcCBox {
let avcc = AvcCBox::read_box(reader, s)?;

skip_bytes_to(reader, start + size)?;

if let Some(avcc) = avcc {
Ok(Avc1Box {
data_reference_index,
width,
Expand Down