summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorJames Dong <jdong@google.com>2010-08-10 13:32:40 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2010-08-10 13:32:40 -0700
commitc3f20251ebd6fa609ef8faf17e45838679c15df6 (patch)
tree2aca2677d6ff808e9dd1172411c1ddf24f43751b /media
parent3965148396c1dbd70c12ade2cb21c495d99f1ea7 (diff)
parentb9ddd779ae547b020764b89a0cbd96d589717609 (diff)
downloadframeworks_base-c3f20251ebd6fa609ef8faf17e45838679c15df6.zip
frameworks_base-c3f20251ebd6fa609ef8faf17e45838679c15df6.tar.gz
frameworks_base-c3f20251ebd6fa609ef8faf17e45838679c15df6.tar.bz2
am b9ddd779: am 10ed3f74: Merge "Add input buffer size check for software video encoders" into gingerbread
Merge commit 'b9ddd779ae547b020764b89a0cbd96d589717609' * commit 'b9ddd779ae547b020764b89a0cbd96d589717609': Add input buffer size check for software video encoders
Diffstat (limited to 'media')
-rw-r--r--media/libstagefright/codecs/avc/enc/AVCEncoder.cpp10
-rw-r--r--media/libstagefright/codecs/m4v_h263/enc/M4vH263Encoder.cpp10
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) {