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
--- 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)