Skip to content

Commit ec15987

Browse files
Zaggy1024kinetiknz
authored andcommitted
Read the looping flag when elst box is empty.
The test file with no `pitm` and no `iloc` boxes should have had a loop count of 0 due to their `elst` box flags being set to 0, but the looping field that was read was being skipped due to the empty edit list. Note: these test files had to be modified manually using MP4Box in gpac, libavif will not write files with no edits.
1 parent 9768879 commit ec15987

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

mp4parse/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4402,6 +4402,7 @@ fn read_edts<T: Read>(f: &mut BMFFBox<T>, track: &mut Track) -> Result<()> {
44024402
match b.head.name {
44034403
BoxType::EditListBox => {
44044404
let elst = read_elst(&mut b)?;
4405+
track.looped = Some(elst.looped);
44054406
if elst.edits.is_empty() {
44064407
debug!("empty edit list");
44074408
continue;
@@ -4421,7 +4422,6 @@ fn read_edts<T: Read>(f: &mut BMFFBox<T>, track: &mut Track) -> Result<()> {
44214422
if media_time < 0 {
44224423
debug!("unexpected negative media time in edit");
44234424
}
4424-
track.looped = Some(elst.looped);
44254425
track.edited_duration = Some(MediaScaledTime(elst.edits[idx].segment_duration));
44264426
track.media_time = Some(TrackScaledTime::<u64>(
44274427
std::cmp::max(0, media_time) as u64,

mp4parse/tests/public.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,19 @@ fn public_avif_avis_major_no_moov() {
12451245
#[test]
12461246
fn public_avif_avis_with_no_pitm_no_iloc() {
12471247
let input = &mut File::open(AVIF_AVIS_WITH_NO_PITM_NO_ILOC).expect("Unknown file");
1248-
assert!(mp4::read_avif(input, ParseStrictness::Normal).is_ok());
1248+
match mp4::read_avif(input, ParseStrictness::Normal) {
1249+
Ok(context) => {
1250+
assert_eq!(context.major_brand, mp4::AVIS_BRAND);
1251+
match context.sequence {
1252+
Some(sequence) => {
1253+
assert!(!sequence.tracks.is_empty());
1254+
assert_eq!(sequence.tracks[0].looped, Some(false));
1255+
}
1256+
None => panic!("Expected sequence"),
1257+
}
1258+
}
1259+
Err(e) => panic!("Expected Ok(_), found {:?}", e),
1260+
}
12491261
}
12501262

12511263
#[test]

0 commit comments

Comments
 (0)