diff options
author | Lajos Molnar <lajos@google.com> | 2013-11-13 18:47:48 -0800 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-11-13 18:47:48 -0800 |
commit | 4f3f5e01208a547e8ea6ff6442a5a33e10748162 (patch) | |
tree | ad40b6937ce5f6d6f8a884fee6ab07605e4daa90 /media | |
parent | 4b2ce668f73e714cb1b1f115e3cf3e26bd9122f0 (diff) | |
parent | ec89a75e386c61cf4ace3bc5ab80d064562ebf11 (diff) | |
download | frameworks_av-4f3f5e01208a547e8ea6ff6442a5a33e10748162.zip frameworks_av-4f3f5e01208a547e8ea6ff6442a5a33e10748162.tar.gz frameworks_av-4f3f5e01208a547e8ea6ff6442a5a33e10748162.tar.bz2 |
am ec89a75e: am 92092b39: Merge "stagefright: limit default max-input-size for AVC" into klp-dev
* commit 'ec89a75e386c61cf4ace3bc5ab80d064562ebf11':
stagefright: limit default max-input-size for AVC
Diffstat (limited to 'media')
-rw-r--r-- | media/libstagefright/MPEG4Extractor.cpp | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/media/libstagefright/MPEG4Extractor.cpp b/media/libstagefright/MPEG4Extractor.cpp index cbc169b..8368b39 100644 --- a/media/libstagefright/MPEG4Extractor.cpp +++ b/media/libstagefright/MPEG4Extractor.cpp @@ -1370,6 +1370,9 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { return err; } + const char *mime; + CHECK(mLastTrack->meta->findCString(kKeyMIMEType, &mime)); + if (max_size != 0) { // Assume that a given buffer only contains at most 10 chunks, // each chunk originally prefixed with a 2 byte length will @@ -1379,19 +1382,27 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) { } else { // No size was specified. Pick a conservatively large size. int32_t width, height; - if (mLastTrack->meta->findInt32(kKeyWidth, &width) && - mLastTrack->meta->findInt32(kKeyHeight, &height)) { - mLastTrack->meta->setInt32(kKeyMaxInputSize, width * height * 3 / 2); - } else { + if (!mLastTrack->meta->findInt32(kKeyWidth, &width) || + !mLastTrack->meta->findInt32(kKeyHeight, &height)) { ALOGE("No width or height, assuming worst case 1080p"); - mLastTrack->meta->setInt32(kKeyMaxInputSize, 3110400); + width = 1920; + height = 1080; } + + if (!strcmp(mime, MEDIA_MIMETYPE_VIDEO_AVC)) { + // AVC requires compression ratio of at least 2, and uses + // macroblocks + max_size = ((width + 15) / 16) * ((height + 15) / 16) * 192; + } else { + // For all other formats there is no minimum compression + // ratio. Use compression ratio of 1. + max_size = width * height * 3 / 2; + } + mLastTrack->meta->setInt32(kKeyMaxInputSize, max_size); } *offset += chunk_size; // Calculate average frame rate. - const char *mime; - CHECK(mLastTrack->meta->findCString(kKeyMIMEType, &mime)); if (!strncasecmp("video/", mime, 6)) { size_t nSamples = mLastTrack->sampleTable->countSamples(); int64_t durationUs; |