mirror of
https://github.com/alfg/mp4-rust.git
synced 2025-04-23 04:04:14 +00:00
Merge 8553c71f51
into 18f1718b70
This commit is contained in:
commit
0b4127b3e8
1 changed files with 27 additions and 10 deletions
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue