зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1455701 - Update mp4parse-rust to upstream. r=padenot
MozReview-Commit-ID: AJXc5W4Rt0t --HG-- extra : rebase_source : c15d6d1a3ec0564623252416cd1435da087401c0
This commit is contained in:
Родитель
bb64c024ae
Коммит
bbd46b9784
|
@ -835,24 +835,30 @@ fn read_edts<T: Read>(f: &mut BMFFBox<T>, track: &mut Track) -> Result<()> {
|
|||
match b.head.name {
|
||||
BoxType::EditListBox => {
|
||||
let elst = read_elst(&mut b)?;
|
||||
if elst.edits.len() < 1 {
|
||||
debug!("empty edit list");
|
||||
continue;
|
||||
}
|
||||
let mut empty_duration = 0;
|
||||
let mut idx = 0;
|
||||
if elst.edits.len() > 2 {
|
||||
return Err(Error::Unsupported("more than two edits"));
|
||||
}
|
||||
if elst.edits[idx].media_time == -1 {
|
||||
empty_duration = elst.edits[idx].segment_duration;
|
||||
if elst.edits.len() < 2 {
|
||||
return Err(Error::InvalidData("expected additional edit"));
|
||||
debug!("expected additional edit, ignoring edit list");
|
||||
continue;
|
||||
}
|
||||
empty_duration = elst.edits[idx].segment_duration;
|
||||
idx += 1;
|
||||
}
|
||||
track.empty_duration = Some(MediaScaledTime(empty_duration));
|
||||
if elst.edits[idx].media_time < 0 {
|
||||
return Err(Error::InvalidData("unexpected negative media time in edit"));
|
||||
let media_time = elst.edits[idx].media_time;
|
||||
if media_time < 0 {
|
||||
debug!("unexpected negative media time in edit");
|
||||
}
|
||||
track.media_time = Some(TrackScaledTime::<u64>(elst.edits[idx].media_time as u64,
|
||||
track.media_time = Some(TrackScaledTime::<u64>(std::cmp::max(0, media_time) as u64,
|
||||
track.id));
|
||||
if elst.edits.len() > 2 {
|
||||
debug!("ignoring edit list with {} entries", elst.edits.len());
|
||||
}
|
||||
debug!("{:?}", elst);
|
||||
}
|
||||
_ => skip_box_content(&mut b)?,
|
||||
|
@ -1068,9 +1074,6 @@ fn read_tkhd<T: Read>(src: &mut BMFFBox<T>) -> Result<TrackHeaderBox> {
|
|||
fn read_elst<T: Read>(src: &mut BMFFBox<T>) -> Result<EditListBox> {
|
||||
let (version, _) = read_fullbox_extra(src)?;
|
||||
let edit_count = be_u32_with_limit(src)?;
|
||||
if edit_count == 0 {
|
||||
return Err(Error::InvalidData("invalid edit count"));
|
||||
}
|
||||
let mut edits = Vec::new();
|
||||
for _ in 0..edit_count {
|
||||
let (segment_duration, media_time) = match version {
|
||||
|
@ -1094,6 +1097,9 @@ fn read_elst<T: Read>(src: &mut BMFFBox<T>) -> Result<EditListBox> {
|
|||
})?;
|
||||
}
|
||||
|
||||
// Padding could be added in some contents.
|
||||
skip_box_remain(src)?;
|
||||
|
||||
Ok(EditListBox {
|
||||
edits: edits,
|
||||
})
|
||||
|
|
|
@ -759,9 +759,8 @@ fn read_elst_zero_entries() {
|
|||
let mut iter = super::BoxIter::new(&mut stream);
|
||||
let mut stream = iter.next_box().unwrap().unwrap();
|
||||
match super::read_elst(&mut stream) {
|
||||
Err(Error::InvalidData(s)) => assert_eq!(s, "invalid edit count"),
|
||||
Ok(_) => panic!("expected an error result"),
|
||||
_ => panic!("expected a different error result"),
|
||||
Ok(elst) => assert_eq!(elst.edits.len(), 0),
|
||||
_ => panic!("expected no error"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -780,6 +779,7 @@ fn make_elst() -> Cursor<Vec<u8>> {
|
|||
fn read_edts_bogus() {
|
||||
// First edit list entry has a media_time of -1, so we expect a second
|
||||
// edit list entry to be present to provide a valid media_time.
|
||||
// Bogus edts are ignored.
|
||||
let mut stream = make_box(BoxSize::Auto, b"edts", |s| {
|
||||
s.append_bytes(&make_elst().into_inner())
|
||||
});
|
||||
|
@ -787,9 +787,11 @@ fn read_edts_bogus() {
|
|||
let mut stream = iter.next_box().unwrap().unwrap();
|
||||
let mut track = super::Track::new(0);
|
||||
match super::read_edts(&mut stream, &mut track) {
|
||||
Err(Error::InvalidData(s)) => assert_eq!(s, "expected additional edit"),
|
||||
Ok(_) => panic!("expected an error result"),
|
||||
_ => panic!("expected a different error result"),
|
||||
Ok(_) => {
|
||||
assert_eq!(track.media_time, None);
|
||||
assert_eq!(track.empty_duration, None);
|
||||
}
|
||||
_ => panic!("expected no error"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# Script to update mp4parse-rust sources to latest upstream
|
||||
|
||||
# Default version.
|
||||
VER="9e70cb418401c152cd3183aab06b084c0ce3f3e6"
|
||||
VER="2dc5127a69bc9bf891972e269e3abde0b77612f5"
|
||||
|
||||
# Accept version or commit from the command line.
|
||||
if test -n "$1"; then
|
||||
|
|
Загрузка…
Ссылка в новой задаче