Bug 1285928: [mp4] Ignore non-supported entries in edit list. r?kentuckyfriedtakahe
Only the first entry in the edit list is supported (or the 2nd if the first entry is empty)
MozReview-Commit-ID: 5Ab28yhRKPV
--- a/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
+++ b/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
@@ -830,16 +830,17 @@ status_t MPEG4Extractor::parseChunk(off6
}
uint32_t entry_count;
if (!mDataSource->getUInt32(data_offset + 4, &entry_count)) {
return ERROR_IO;
}
off64_t entriesoffset = data_offset + 8;
+ uint32_t nonEmptyCount = 0;
for (uint32_t i = 0; i < entry_count; i++) {
if (mHeaderTimescale == 0) {
ALOGW("ignoring edit list because timescale is 0");
break;
}
if (entriesoffset - data_offset > chunk_size) {
ALOGW("invalid edit list size");
break;
@@ -871,21 +872,24 @@ status_t MPEG4Extractor::parseChunk(off6
break;
} else if (media_time == -1) {
// Starting offsets for tracks (streams) are represented by an initial empty edit.
if (!mLastTrack) {
return ERROR_MALFORMED;
}
mLastTrack->empty_duration = segment_duration;
continue;
- } else if (i > 1) {
+ } else if (nonEmptyCount >= 1) {
// we only support a single non-empty entry at the moment, for gapless playback
ALOGW("multiple edit list entries, A/V sync will be wrong");
break;
+ } else {
+ nonEmptyCount++;
}
+
if (!mLastTrack) {
return ERROR_MALFORMED;
}
mLastTrack->segment_duration = segment_duration;
mLastTrack->media_time = media_time;
}
storeEditList();
*offset += chunk_size;