Bug 1275853: [mp4] Don't reject boxes that contains padding but can be easily skipped. r=kentuckyfriedtakahe
authorJean-Yves Avenard <jyavenard@mozilla.com>
Sat, 28 May 2016 10:42:01 +1000
changeset 338572 38c9fa1d2e59966341e024e27059ee3354446d4a
parent 338571 5c383b2162f7e7c3641598344f201dafae9d1d6b
child 338573 c46e0dfad282f738981fd62bb91f5b5161c160e1
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskentuckyfriedtakahe
bugs1275853
milestone49.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 1275853: [mp4] Don't reject boxes that contains padding but can be easily skipped. r=kentuckyfriedtakahe My guess is that the application generating those files, does a very rough estimate on what the sample table size is going to be, which allows to perform the conversion in a single pass. This allows to place the moov box at the beginning. MozReview-Commit-ID: IGzxTho4Akk
media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
media/libstagefright/frameworks/av/media/libstagefright/SampleTable.cpp
--- a/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
+++ b/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
@@ -1166,19 +1166,18 @@ status_t MPEG4Extractor::parseChunk(off6
             *offset = data_offset + 8;
             for (uint32_t i = 0; i < entry_count; ++i) {
                 status_t err = parseChunk(offset, depth + 1);
                 if (err != OK) {
                     return err;
                 }
             }
 
-            if (*offset != stop_offset) {
-                return ERROR_MALFORMED;
-            }
+            // Some muxers add some padding after the stsd content. Skip it.
+            *offset = stop_offset;
             break;
         }
 
         case FOURCC('m', 'p', '4', 'a'):
         case FOURCC('.', 'm', 'p', '3'):
         case FOURCC('e', 'n', 'c', 'a'):
         case FOURCC('s', 'a', 'm', 'r'):
         case FOURCC('s', 'a', 'w', 'b'):
--- a/media/libstagefright/frameworks/av/media/libstagefright/SampleTable.cpp
+++ b/media/libstagefright/frameworks/av/media/libstagefright/SampleTable.cpp
@@ -390,17 +390,17 @@ status_t SampleTable::setCompositionTime
 
     uint32_t numEntries = U32_AT(&header[4]);
 
     if (U32_AT(header) != 0 && numEntries) {
         // Expected version = 0, flags = 0.
         return ERROR_MALFORMED;
     }
 
-    if (data_size != ((uint64_t)numEntries + 1) * 8) {
+    if (data_size < ((uint64_t)numEntries + 1) * 8) {
         return ERROR_MALFORMED;
     }
 
     mNumCompositionTimeDeltaEntries = numEntries;
     mCompositionTimeDeltaEntries = new uint32_t[2 * numEntries];
 
     if (mDataSource->readAt(
                 data_offset + 8, mCompositionTimeDeltaEntries, numEntries * 8)