Bug 1275853: [mp4] Don't reject boxes that contains padding but can be easily skipped. r?kentuckyfriedtakahe draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Sat, 28 May 2016 10:42:01 +1000
changeset 372875 4b78e5937a5978c77fe5813948836ad0b299410d
parent 372874 98bf4649bf58e9a3f593ab1174d55bf85e443831
child 522260 20e9debd43609e57fb27391863dda4b0068af96e
push id19610
push userbmo:jyavenard@mozilla.com
push dateMon, 30 May 2016 12:02:23 +0000
reviewerskentuckyfriedtakahe
bugs1275853
milestone49.0a1
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)