diff options
author | James Dong <jdong@google.com> | 2010-08-10 13:27:09 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-08-10 13:27:09 -0700 |
commit | 10ed3f7438f6ae797bac32476dc61465c6484c85 (patch) | |
tree | 2e512bd10189c25453f020cc8f5342997f5fc46c /media | |
parent | 18f0174ff4eef46f121e77a0dc1d7a8271621f48 (diff) | |
parent | e6daea5940c38267d24a39fc32bffa119132e852 (diff) | |
download | frameworks_base-10ed3f7438f6ae797bac32476dc61465c6484c85.zip frameworks_base-10ed3f7438f6ae797bac32476dc61465c6484c85.tar.gz frameworks_base-10ed3f7438f6ae797bac32476dc61465c6484c85.tar.bz2 |
Merge "Add input buffer size check for software video encoders" into gingerbread
Diffstat (limited to 'media')
-rw-r--r-- | media/libstagefright/codecs/avc/enc/AVCEncoder.cpp | 10 | ||||
-rw-r--r-- | media/libstagefright/codecs/m4v_h263/enc/M4vH263Encoder.cpp | 10 |
2 files changed, 20 insertions, 0 deletions
diff --git a/media/libstagefright/codecs/avc/enc/AVCEncoder.cpp b/media/libstagefright/codecs/avc/enc/AVCEncoder.cpp index 18320cf..6e74279 100644 --- a/media/libstagefright/codecs/avc/enc/AVCEncoder.cpp +++ b/media/libstagefright/codecs/avc/enc/AVCEncoder.cpp @@ -391,8 +391,18 @@ status_t AVCEncoder::read( if (err != OK) { LOGE("Failed to read input video frame: %d", err); outputBuffer->release(); + mInputBuffer->release(); + mInputBuffer = NULL; return err; } + + if (mInputBuffer->size() - ((mVideoWidth * mVideoHeight * 3) >> 1) != 0) { + outputBuffer->release(); + mInputBuffer->release(); + mInputBuffer = NULL; + return UNKNOWN_ERROR; + } + int64_t timeUs; CHECK(mInputBuffer->meta_data()->findInt64(kKeyTime, &timeUs)); outputBuffer->meta_data()->setInt64(kKeyTime, timeUs); diff --git a/media/libstagefright/codecs/m4v_h263/enc/M4vH263Encoder.cpp b/media/libstagefright/codecs/m4v_h263/enc/M4vH263Encoder.cpp index 5002442..1bef0e9 100644 --- a/media/libstagefright/codecs/m4v_h263/enc/M4vH263Encoder.cpp +++ b/media/libstagefright/codecs/m4v_h263/enc/M4vH263Encoder.cpp @@ -292,8 +292,18 @@ status_t M4vH263Encoder::read( if (OK != mSource->read(&mInputBuffer, options)) { LOGE("Failed to read from data source"); outputBuffer->release(); + mInputBuffer->release(); + mInputBuffer = NULL; return UNKNOWN_ERROR; } + + if (mInputBuffer->size() - ((mVideoWidth * mVideoHeight * 3) >> 1) != 0) { + outputBuffer->release(); + mInputBuffer->release(); + mInputBuffer = NULL; + return UNKNOWN_ERROR; + } + int64_t timeUs; CHECK(mInputBuffer->meta_data()->findInt64(kKeyTime, &timeUs)); if (mNextModTimeUs > timeUs) { |