Merge "Fix crash in Opus and Vorbis decoders" into oc-dev
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
index 9f1be22..9d6dad3 100644
--- a/media/libstagefright/ACodec.cpp
+++ b/media/libstagefright/ACodec.cpp
@@ -1039,7 +1039,10 @@
array[i] = {mBuffers[portIndex][i].mData, mBuffers[portIndex][i].mBufferID};
}
if (portIndex == kPortIndexInput) {
- mBufferChannel->setInputBufferArray(array);
+ err = mBufferChannel->setInputBufferArray(array);
+ if (err != OK) {
+ return err;
+ }
} else if (portIndex == kPortIndexOutput) {
mBufferChannel->setOutputBufferArray(array);
} else {
diff --git a/media/libstagefright/ACodecBufferChannel.cpp b/media/libstagefright/ACodecBufferChannel.cpp
index 0d9696f..796d3dc 100644
--- a/media/libstagefright/ACodecBufferChannel.cpp
+++ b/media/libstagefright/ACodecBufferChannel.cpp
@@ -284,7 +284,7 @@
return dealer;
}
-void ACodecBufferChannel::setInputBufferArray(const std::vector<BufferAndId> &array) {
+status_t ACodecBufferChannel::setInputBufferArray(const std::vector<BufferAndId> &array) {
if (hasCryptoOrDescrambler()) {
size_t totalSize = std::accumulate(
array.begin(), array.end(), 0u,
@@ -311,11 +311,15 @@
if (hasCryptoOrDescrambler()) {
sharedEncryptedBuffer = mDealer->allocate(elem.mBuffer->capacity());
}
+ if (elem.mBuffer->data() == NULL && sharedEncryptedBuffer == NULL) {
+ return BAD_VALUE;
+ }
inputBuffers.emplace_back(elem.mBuffer, elem.mBufferId, sharedEncryptedBuffer);
}
std::atomic_store(
&mInputBuffers,
std::make_shared<const std::vector<const BufferInfo>>(inputBuffers));
+ return OK;
}
void ACodecBufferChannel::setOutputBufferArray(const std::vector<BufferAndId> &array) {
diff --git a/media/libstagefright/MediaCodec.cpp b/media/libstagefright/MediaCodec.cpp
index f695717..280dd95 100644
--- a/media/libstagefright/MediaCodec.cpp
+++ b/media/libstagefright/MediaCodec.cpp
@@ -734,6 +734,9 @@
// XXX: save indication that it's crypto in some way...
mAnalyticsItem->setInt32(kCodecCrypto, 1);
}
+ } else if (mFlags & kFlagIsSecure) {
+ ALOGE("Crypto or descrambler should be given for secure codec");
+ return BAD_VALUE;
}
// save msg for reset
diff --git a/media/libstagefright/codecs/on2/enc/SoftVPXEncoder.cpp b/media/libstagefright/codecs/on2/enc/SoftVPXEncoder.cpp
index 8d69bd5..a5666da 100644
--- a/media/libstagefright/codecs/on2/enc/SoftVPXEncoder.cpp
+++ b/media/libstagefright/codecs/on2/enc/SoftVPXEncoder.cpp
@@ -137,6 +137,8 @@
mCodecConfiguration->rc_end_usage = mBitrateControlMode;
// Disable frame drop - not allowed in MediaCodec now.
mCodecConfiguration->rc_dropframe_thresh = 0;
+ // Disable lagged encoding.
+ mCodecConfiguration->g_lag_in_frames = 0;
if (mBitrateControlMode == VPX_CBR) {
// Disable spatial resizing.
mCodecConfiguration->rc_resize_allowed = 0;
@@ -157,8 +159,6 @@
mCodecConfiguration->rc_buf_sz = 1000;
// Enable error resilience - needed for packet loss.
mCodecConfiguration->g_error_resilient = 1;
- // Disable lagged encoding.
- mCodecConfiguration->g_lag_in_frames = 0;
// Maximum key frame interval - for CBR boost to 3000
mCodecConfiguration->kf_max_dist = 3000;
// Encoder determines optimal key frame placement automatically.
diff --git a/media/libstagefright/include/ACodecBufferChannel.h b/media/libstagefright/include/ACodecBufferChannel.h
index 0da2e81..349f1f8 100644
--- a/media/libstagefright/include/ACodecBufferChannel.h
+++ b/media/libstagefright/include/ACodecBufferChannel.h
@@ -87,8 +87,9 @@
*
* @param array Newly allocated buffers. Empty if buffers are
* deallocated.
+ * @return OK if no error.
*/
- void setInputBufferArray(const std::vector<BufferAndId> &array);
+ status_t setInputBufferArray(const std::vector<BufferAndId> &array);
/**
* Set output buffer array.
*
diff --git a/media/libstagefright/omx/GraphicBufferSource.cpp b/media/libstagefright/omx/GraphicBufferSource.cpp
index 103a3e9..47d80bb 100644
--- a/media/libstagefright/omx/GraphicBufferSource.cpp
+++ b/media/libstagefright/omx/GraphicBufferSource.cpp
@@ -827,6 +827,10 @@
ssize_t cbix = mSubmittedCodecBuffers.add(codecBufferId, nullptr);
ALOGV("submitEndOfInputStream_l: buffer submitted, bufferId=%u@%zd", codecBufferId, cbix);
mEndOfStreamSent = true;
+
+ // no need to hold onto any buffers for frame repeating
+ ++mRepeatLastFrameGeneration;
+ mLatestBuffer.mBuffer.reset();
}
}