diff options
author | Andreas Huber <andih@google.com> | 2010-02-25 15:59:24 -0800 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2010-02-25 16:24:32 -0800 |
commit | ea5ea10a036f79c86bf5f204cb81804bf2bacdc7 (patch) | |
tree | cf45494fb6ddb89568a043d3e4525b7ee4377d5d /media/libstagefright | |
parent | d2d947bc8717697e983062147b51b5a0e307b84f (diff) | |
download | frameworks_av-ea5ea10a036f79c86bf5f204cb81804bf2bacdc7.zip frameworks_av-ea5ea10a036f79c86bf5f204cb81804bf2bacdc7.tar.gz frameworks_av-ea5ea10a036f79c86bf5f204cb81804bf2bacdc7.tar.bz2 |
Support vendor MPEG4 test content with apparently malformed chunks in them.
related-to-bug: 2472211
Diffstat (limited to 'media/libstagefright')
-rw-r--r-- | media/libstagefright/MPEG4Extractor.cpp | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/media/libstagefright/MPEG4Extractor.cpp b/media/libstagefright/MPEG4Extractor.cpp index 165ac09..f1c3f0f 100644 --- a/media/libstagefright/MPEG4Extractor.cpp +++ b/media/libstagefright/MPEG4Extractor.cpp @@ -439,14 +439,16 @@ status_t MPEG4Extractor::parseChunk(off_t *offset, int depth) { printf("%sfound chunk '%s' of size %lld\n", indent, chunk, chunk_size); char buffer[256]; - if (chunk_size <= sizeof(buffer)) { - if (mDataSource->readAt(*offset, buffer, chunk_size) - < (ssize_t)chunk_size) { - return ERROR_IO; - } - - hexdump(buffer, chunk_size); + size_t n = chunk_size; + if (n > sizeof(buffer)) { + n = sizeof(buffer); + } + if (mDataSource->readAt(*offset, buffer, n) + < (ssize_t)n) { + return ERROR_IO; } + + hexdump(buffer, n); #endif PathAdder autoAdder(&mPath, chunk_type); @@ -981,7 +983,13 @@ status_t MPEG4Extractor::parseChunk(off_t *offset, int depth) { if (U32_AT(buffer) != 0) { // Should be version 0, flags 0. - return ERROR_MALFORMED; + + // If it's not, let's assume this is one of those + // apparently malformed chunks that don't have flags + // and completely different semantics than what's + // in the MPEG4 specs and skip it. + *offset += chunk_size; + return OK; } off_t stop_offset = *offset + chunk_size; @@ -1626,7 +1634,8 @@ bool SniffMPEG4( if (!memcmp(header, "ftyp3gp", 7) || !memcmp(header, "ftypmp42", 8) || !memcmp(header, "ftypisom", 8) || !memcmp(header, "ftypM4V ", 8) - || !memcmp(header, "ftypM4A ", 8) || !memcmp(header, "ftypf4v ", 8)) { + || !memcmp(header, "ftypM4A ", 8) || !memcmp(header, "ftypf4v ", 8) + || !memcmp(header, "ftypkddi", 8)) { *mimeType = MEDIA_MIMETYPE_CONTAINER_MPEG4; *confidence = 0.1; |