aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLang Dai <langx.dai@intel.com>2016-05-25 17:00:58 +0800
committerThe Android Automerger <android-build@android.com>2016-06-03 16:12:51 -0700
commit05f365f4db0916dc81fd6b6fbb5840cb3f689033 (patch)
treef924e2987dd3bfe616fdc412df53f7f0b9dbabcf
parent1aa2377f0cc21cad6d44baf77be410b940a2f30a (diff)
downloadandroid_hardware_intel_common_omx-components-05f365f4db0916dc81fd6b6fbb5840cb3f689033.tar.gz
android_hardware_intel_common_omx-components-05f365f4db0916dc81fd6b6fbb5840cb3f689033.tar.bz2
android_hardware_intel_common_omx-components-05f365f4db0916dc81fd6b6fbb5840cb3f689033.zip
Insert an empty buffer when format change to avoid frame dropping
Bug: 28083088 BZ: 49736 Change-Id: I49a90c23ea955695484e6403d0e759ea739cf1be Signed-off-by: Lily Ouyang <lily.ouyang@intel.com> Signed-off-by: Austin Hu <austin.hu@intel.com>
-rwxr-xr-xvideocodec/OMXVideoDecoderBase.cpp42
-rwxr-xr-xvideocodec/OMXVideoDecoderBase.h1
2 files changed, 34 insertions, 9 deletions
diff --git a/videocodec/OMXVideoDecoderBase.cpp b/videocodec/OMXVideoDecoderBase.cpp
index 31c6a48..323739b 100755
--- a/videocodec/OMXVideoDecoderBase.cpp
+++ b/videocodec/OMXVideoDecoderBase.cpp
@@ -40,6 +40,7 @@ OMXVideoDecoderBase::OMXVideoDecoderBase()
mWorkingMode(RAWDATA_MODE),
mErrorReportEnabled (false),
mAPMode(LEGACY_MODE),
+ mFlushMode(false),
mFormatChanged(false) {
mOMXBufferHeaderTypePtrNum = 0;
mMetaDataBuffersNum = 0;
@@ -352,10 +353,18 @@ OMX_ERRORTYPE OMXVideoDecoderBase::ProcessorProcess(
HandleFormatChange();
}
- // Actually, if mAPMode is set, mWorkingMode should be GRAPHICBUFFER_MODE.
- if (((mAPMode == METADATA_MODE) && (mWorkingMode == GRAPHICBUFFER_MODE)) && mFormatChanged) {
- if (((*pBuffers[OUTPORT_INDEX])->nFlags & OMX_BUFFERFLAG_EOS) || (mVideoDecoder->getOutputQueueLength() == 0)) {
- HandleFormatChange();
+ if (mFlushMode) {
+ LOGI("in mFlushMode, do HandleFormatChange.");
+ HandleFormatChange();
+ } else {
+ // Actually, if mAPMode is set, mWorkingMode should be GRAPHICBUFFER_MODE.
+ if (((mAPMode == METADATA_MODE) && (mWorkingMode == GRAPHICBUFFER_MODE)) && mFormatChanged) {
+ if (((*pBuffers[OUTPORT_INDEX])->nFlags & OMX_BUFFERFLAG_EOS) || (mVideoDecoder->getOutputQueueLength() == 0)) {
+ // Format changed, set mFlushMode, clear eos
+ mFlushMode = true;
+ mFormatChanged = false;
+ (*pBuffers[OUTPORT_INDEX])->nFlags &= ~OMX_BUFFERFLAG_EOS;
+ }
}
}
@@ -436,9 +445,17 @@ OMX_ERRORTYPE OMXVideoDecoderBase::ProcessorProcess(
HandleFormatChange();
}
- if (((mAPMode == METADATA_MODE) && (mWorkingMode == GRAPHICBUFFER_MODE)) && mFormatChanged) {
- if (((*pBuffers[OUTPORT_INDEX])->nFlags & OMX_BUFFERFLAG_EOS) || (mVideoDecoder->getOutputQueueLength() == 0)) {
- HandleFormatChange();
+ if (mFlushMode) {
+ LOGI("in mFlushMode, do HandleFormatChange.");
+ HandleFormatChange();
+ } else {
+ if (((mAPMode == METADATA_MODE) && (mWorkingMode == GRAPHICBUFFER_MODE)) && mFormatChanged) {
+ if (((*pBuffers[OUTPORT_INDEX])->nFlags & OMX_BUFFERFLAG_EOS) || (mVideoDecoder->getOutputQueueLength() == 0)) {
+ // Format changed, set mFlushMode, clear eos.
+ mFlushMode = true;
+ mFormatChanged = false;
+ (*pBuffers[OUTPORT_INDEX])->nFlags &= ~OMX_BUFFERFLAG_EOS;
+ }
}
}
@@ -678,8 +695,15 @@ OMX_ERRORTYPE OMXVideoDecoderBase::FillRenderBuffer(OMX_BUFFERHEADERTYPE **pBuff
bool draining = (inportBufferFlags & OMX_BUFFERFLAG_EOS);
//pthread_mutex_lock(&mSerializationLock);
- const VideoRenderBuffer *renderBuffer;
+ const VideoRenderBuffer *renderBuffer = NULL;
//pthread_mutex_unlock(&mSerializationLock);
+
+ // in mFlushMode, provide empty buffer.
+ if (mFlushMode) {
+ buffer->nFilledLen = 0;
+ return OMX_ErrorNone;
+ }
+
if (((mAPMode == METADATA_MODE) && (mWorkingMode == GRAPHICBUFFER_MODE)) && mFormatChanged) {
renderBuffer = mVideoDecoder->getOutput(true, ErrBufPtr);
} else {
@@ -803,7 +827,7 @@ OMX_ERRORTYPE OMXVideoDecoderBase::HandleFormatChange(void) {
this->ports[OUTPORT_INDEX]->ReportPortSettingsChanged();
- mFormatChanged = false;
+ mFlushMode = false;
return OMX_ErrorNone;
}
diff --git a/videocodec/OMXVideoDecoderBase.h b/videocodec/OMXVideoDecoderBase.h
index 2cd60ad..8df593e 100755
--- a/videocodec/OMXVideoDecoderBase.h
+++ b/videocodec/OMXVideoDecoderBase.h
@@ -145,6 +145,7 @@ protected:
};
AdaptivePlaybackMode mAPMode;
uint32_t mMetaDataBuffersNum;
+ OMX_TICKS mFlushMode;
bool mFormatChanged;
uint32_t getStride(uint32_t width);
};