summaryrefslogtreecommitdiffstats
path: root/media/libstagefright
diff options
context:
space:
mode:
authorLajos Molnar <lajos@google.com>2013-11-13 23:53:42 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-11-13 23:53:42 +0000
commit92092b395d59e8943a461d344f617f1dc85375a3 (patch)
tree342448369839a8b9e50a4fda465a2764459808dc /media/libstagefright
parent069bcc5084c3d8c6f9373a2890d40a0d1a36a94e (diff)
parentf40cde132d14a260f4f7e08ae2bf29d8c55848ae (diff)
downloadframeworks_av-92092b395d59e8943a461d344f617f1dc85375a3.zip
frameworks_av-92092b395d59e8943a461d344f617f1dc85375a3.tar.gz
frameworks_av-92092b395d59e8943a461d344f617f1dc85375a3.tar.bz2
Merge "stagefright: limit default max-input-size for AVC" into klp-dev
Diffstat (limited to 'media/libstagefright')
-rw-r--r--media/libstagefright/MPEG4Extractor.cpp25
1 files changed, 18 insertions, 7 deletions
diff --git a/media/libstagefright/MPEG4Extractor.cpp b/media/libstagefright/MPEG4Extractor.cpp
index ad985ee..b8988e6 100644
--- a/media/libstagefright/MPEG4Extractor.cpp
+++ b/media/libstagefright/MPEG4Extractor.cpp
@@ -1368,6 +1368,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
@@ -1377,19 +1380,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;