Fix a bug that happend when frame size changed between inter frames.
Bug: 24270716
Change-Id: I39b133dbeba569acca9b3d733ed6a409d7f6d5e2
diff --git a/media/libstagefright/codecs/on2/dec/SoftVPX.cpp b/media/libstagefright/codecs/on2/dec/SoftVPX.cpp
index cd6c3b1..7fafb6f 100644
--- a/media/libstagefright/codecs/on2/dec/SoftVPX.cpp
+++ b/media/libstagefright/codecs/on2/dec/SoftVPX.cpp
@@ -209,6 +209,8 @@
mEOSStatus == INPUT_EOS_SEEN) {
return;
}
+ // Continue as outQueue may be empty now.
+ continue;
}
BufferInfo *inInfo = *inQueue.begin();
@@ -220,15 +222,23 @@
EOSseen = true;
}
- if (inHeader->nFilledLen > 0 &&
- vpx_codec_decode((vpx_codec_ctx_t *)mCtx,
- inHeader->pBuffer + inHeader->nOffset,
- inHeader->nFilledLen,
- &mTimeStamps[mTimeStampIdx], 0)) {
- ALOGE("on2 decoder failed to decode frame.");
- notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL);
- return;
+ if (inHeader->nFilledLen > 0) {
+ vpx_codec_err_t err = vpx_codec_decode(
+ (vpx_codec_ctx_t *)mCtx, inHeader->pBuffer + inHeader->nOffset,
+ inHeader->nFilledLen, &mTimeStamps[mTimeStampIdx], 0);
+ if (err == VPX_CODEC_OK) {
+ inInfo->mOwnedByUs = false;
+ inQueue.erase(inQueue.begin());
+ inInfo = NULL;
+ notifyEmptyBufferDone(inHeader);
+ inHeader = NULL;
+ } else {
+ ALOGE("on2 decoder failed to decode frame.");
+ notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL);
+ return;
+ }
}
+
mTimeStampIdx = (mTimeStampIdx + 1) % kNumBuffers;
if (!outputBuffers(
@@ -240,12 +250,6 @@
if (portWillReset) {
return;
}
-
- inInfo->mOwnedByUs = false;
- inQueue.erase(inQueue.begin());
- inInfo = NULL;
- notifyEmptyBufferDone(inHeader);
- inHeader = NULL;
}
}