Bug 1076719 - Skip styp box at beginning of new fragment. r=kentuckyfriedtakahe
authorJean-Yves Avenard <jyavenard@mozilla.com>
Thu, 02 Oct 2014 20:27:07 +1000
changeset 232139 314fd7709123e77ae8fd22faae5530c108535a21
parent 232138 5f13639d2f126da7e774723b94f537ce30529f11
child 232140 70af7ba3c01058433897bae0d95c9f5281df5a0b
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskentuckyfriedtakahe
bugs1076719
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1076719 - Skip styp box at beginning of new fragment. r=kentuckyfriedtakahe
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
@@ -3564,26 +3564,31 @@ status_t MPEG4Source::fragmentedRead(
     bool newBuffer = false;
     if (mBuffer == NULL) {
         newBuffer = true;
 
         if (mCurrentSampleIndex >= mCurrentSamples.size()) {
             // move to next fragment
             off64_t nextMoof = mNextMoofOffset; // lastSample.offset + lastSample.size;
 
-            // If we're pointing to a sidx box then we skip it.
+            // If we're pointing to a segment type or sidx box then we skip them.
             uint32_t hdr[2];
-            if (mDataSource->readAt(nextMoof, hdr, 8) < 8) {
-                return ERROR_END_OF_STREAM;
-            }
-            uint64_t chunk_size = ntohl(hdr[0]);
-            uint32_t chunk_type = ntohl(hdr[1]);
-            if (chunk_type == FOURCC('s', 'i', 'd', 'x')) {
+            do {
+                if (mDataSource->readAt(nextMoof, hdr, 8) < 8) {
+                    return ERROR_END_OF_STREAM;
+                }
+                uint64_t chunk_size = ntohl(hdr[0]);
+                uint32_t chunk_type = ntohl(hdr[1]);
+
+                if (chunk_type != FOURCC('s', 't', 'y', 'p') &&
+                    chunk_type != FOURCC('s', 'i', 'd', 'x')) {
+                    break;
+                }
                 nextMoof += chunk_size;
-            }
+            } while(true);
 
             mCurrentMoofOffset = nextMoof;
             mCurrentSamples.clear();
             mCurrentSampleIndex = 0;
             mTrackFragmentData.mPresent = false;
             parseChunk(&nextMoof);
             if (mCurrentSampleIndex >= mCurrentSamples.size()) {
                 return ERROR_END_OF_STREAM;