Bug 1285928: [mp4] Ignore non-supported entries in edit list. r?kentuckyfriedtakahe draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Tue, 12 Jul 2016 15:25:40 +1000
changeset 386516 21eff5f56c0a2bbdc7bcd69ab2d92ca38fd058c1
parent 386010 679118259e91f40d4a8f968f03ec4cff066cdb5b
child 386524 64c89bb3221f656d057ab25f4dd30e8d33c245de
push id22730
push userbmo:jyavenard@mozilla.com
push dateTue, 12 Jul 2016 05:34:57 +0000
reviewerskentuckyfriedtakahe
bugs1285928
milestone50.0a1
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
media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
--- 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;