aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGu, Wangyi <wangyi.gu@intel.com>2015-06-17 10:56:05 +0800
committerPatrick Tjin <pattjin@google.com>2015-06-30 22:42:52 -0700
commit94dc18063f6f0f60d99feaa0ffb1fc103d49c2c8 (patch)
tree5b7a8937a8b5db0a0aa95b4f57462cc9512bf38f
parentb673023ba30b7526d71576b55f46d036533408cb (diff)
downloadandroid_hardware_intel_common_omx-components-94dc18063f6f0f60d99feaa0ffb1fc103d49c2c8.tar.gz
android_hardware_intel_common_omx-components-94dc18063f6f0f60d99feaa0ffb1fc103d49c2c8.tar.bz2
android_hardware_intel_common_omx-components-94dc18063f6f0f60d99feaa0ffb1fc103d49c2c8.zip
enable meta data for VP9 hybrid
Bug: 19197299 Change-Id: I5ee078332ae04f847ef6d8858aaf4faff12de3b9 Signed-off-by: Gu, Wangyi <wangyi.gu@intel.com>
-rw-r--r--videocodec/Android.mk1
-rw-r--r--videocodec/OMXVideoDecoderBase.cpp3
-rw-r--r--videocodec/OMXVideoDecoderVP9Hybrid.cpp152
-rw-r--r--videocodec/OMXVideoDecoderVP9Hybrid.h4
4 files changed, 125 insertions, 35 deletions
diff --git a/videocodec/Android.mk b/videocodec/Android.mk
index 58ab43a..d868dcf 100644
--- a/videocodec/Android.mk
+++ b/videocodec/Android.mk
@@ -238,6 +238,7 @@ endif
ifeq ($(TARGET_BOARD_PLATFORM),moorefield)
LOCAL_CFLAGS += -DVED_TILING
+LOCAL_CFLAGS += -DUSE_META_DATA
endif
ifeq ($(TARGET_BOARD_PLATFORM),baytrail)
diff --git a/videocodec/OMXVideoDecoderBase.cpp b/videocodec/OMXVideoDecoderBase.cpp
index 144575e..5d10668 100644
--- a/videocodec/OMXVideoDecoderBase.cpp
+++ b/videocodec/OMXVideoDecoderBase.cpp
@@ -1037,6 +1037,7 @@ OMX_ERRORTYPE OMXVideoDecoderBase::GetStoreMetaDataMode(OMX_PTR) {
}
OMX_ERRORTYPE OMXVideoDecoderBase::SetStoreMetaDataMode(OMX_PTR pStructure) {
+#ifndef USE_META_DATA
OMX_PARAM_PORTDEFINITIONTYPE defInput;
memcpy(&defInput,
this->ports[INPORT_INDEX]->GetPortDefinition(),
@@ -1045,7 +1046,7 @@ OMX_ERRORTYPE OMXVideoDecoderBase::SetStoreMetaDataMode(OMX_PTR pStructure) {
ALOGE("SetMetaDataMode for VP9 is not implemented");
return OMX_ErrorNotImplemented;
}
-
+#endif
OMX_ERRORTYPE ret;
StoreMetaDataInBuffersParams *param = (StoreMetaDataInBuffersParams*)pStructure;
diff --git a/videocodec/OMXVideoDecoderVP9Hybrid.cpp b/videocodec/OMXVideoDecoderVP9Hybrid.cpp
index db400ca..b717e66 100644
--- a/videocodec/OMXVideoDecoderVP9Hybrid.cpp
+++ b/videocodec/OMXVideoDecoderVP9Hybrid.cpp
@@ -82,19 +82,35 @@ OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::ProcessorInit(void) {
bufferHeight = 1088;
bufferCount = 12;
} else {
+ if (mAPMode == METADATA_MODE) {
+ const OMX_PARAM_PORTDEFINITIONTYPE *def_output = this->ports[OUTPORT_INDEX]->GetPortDefinition();
+ if (def_output == NULL) {
+ return OMX_ErrorBadParameter;
+ }
+ bufferCount = mMetaDataBuffersNum = def_output->nBufferCountActual;
+ mOMXBufferHeaderTypePtrNum = 0;
+
+ mGraphicBufferParam.graphicBufferColorFormat = def_output->format.video.eColorFormat;
+ mGraphicBufferParam.graphicBufferStride = (def_output->format.video.nFrameWidth + 0x7f) & ~0x7f;
+ mGraphicBufferParam.graphicBufferWidth = def_output->format.video.nFrameWidth;
+ mGraphicBufferParam.graphicBufferHeight = (def_output->format.video.nFrameHeight + 0x1f) & ~0x1f;
+ mDecodedImageWidth = def_output->format.video.nFrameWidth;
+ mDecodedImageHeight = def_output->format.video.nFrameHeight;
+ } else{
+ bufferCount = mOMXBufferHeaderTypePtrNum;
+
+ for (i = 0; i < bufferCount; i++ ) {
+ OMX_BUFFERHEADERTYPE *buf_hdr = mOMXBufferHeaderTypePtrArray[i];
+ buff[i] = (uint32_t)(buf_hdr->pBuffer);
+ }
+ }
+
bufferSize = mGraphicBufferParam.graphicBufferStride *
mGraphicBufferParam.graphicBufferHeight * 1.5;
bufferStride = mGraphicBufferParam.graphicBufferStride;
- bufferCount = mOMXBufferHeaderTypePtrNum;
bufferHeight = mGraphicBufferParam.graphicBufferHeight;
bufferWidth = mGraphicBufferParam.graphicBufferWidth;
-
- for (i = 0; i < bufferCount; i++ ) {
- OMX_BUFFERHEADERTYPE *buf_hdr = mOMXBufferHeaderTypePtrArray[i];
- buff[i] = (uint32_t)(buf_hdr->pBuffer);
- }
}
-
mLibHandle = dlopen("libDecoderVP9Hybrid.so", RTLD_NOW);
if (mLibHandle == NULL) {
LOGE("dlopen libDecoderVP9Hybrid.so fail\n");
@@ -125,7 +141,7 @@ OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::ProcessorInit(void) {
return OMX_ErrorBadParameter;
}
- mInitDecoder(mHybridCtx,bufferSize,bufferStride,bufferWidth, bufferHeight,bufferCount,gralloc_mode, buff);
+ mInitDecoder(mHybridCtx,bufferSize,bufferStride,bufferWidth, bufferHeight,bufferCount,gralloc_mode, buff, (uint32_t)mAPMode);
return OMX_ErrorNone;
}
@@ -142,20 +158,35 @@ OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::ProcessorReset(void)
bufferHeight = mDecodedImageHeight;
bufferCount = 12;
} else {
+ if (mAPMode == METADATA_MODE) {
+ const OMX_PARAM_PORTDEFINITIONTYPE *def_output = this->ports[OUTPORT_INDEX]->GetPortDefinition();
+ if (def_output == NULL) {
+ return OMX_ErrorBadParameter;
+ }
+ bufferCount = mMetaDataBuffersNum = def_output->nBufferCountActual;
+ mOMXBufferHeaderTypePtrNum = 0;
+
+ mGraphicBufferParam.graphicBufferColorFormat = def_output->format.video.eColorFormat;
+ mGraphicBufferParam.graphicBufferStride = (def_output->format.video.nFrameWidth + 0x7f) & ~0x7f;
+ mGraphicBufferParam.graphicBufferWidth = def_output->format.video.nFrameWidth;
+ mGraphicBufferParam.graphicBufferHeight = (def_output->format.video.nFrameHeight + 0x1f) & ~0x1f;
+ } else{
+ bufferCount = mOMXBufferHeaderTypePtrNum;
+
+ for (i = 0; i < bufferCount; i++ ) {
+ OMX_BUFFERHEADERTYPE *buf_hdr = mOMXBufferHeaderTypePtrArray[i];
+ buff[i] = (uint32_t)(buf_hdr->pBuffer);
+ }
+ }
bufferSize = mGraphicBufferParam.graphicBufferStride *
mGraphicBufferParam.graphicBufferHeight * 1.5;
bufferStride = mGraphicBufferParam.graphicBufferStride;
- bufferWidth = mGraphicBufferParam.graphicBufferWidth;
- bufferCount = mOMXBufferHeaderTypePtrNum;
bufferHeight = mGraphicBufferParam.graphicBufferHeight;
-
- for (i = 0; i < bufferCount; i++ ) {
- OMX_BUFFERHEADERTYPE *buf_hdr = mOMXBufferHeaderTypePtrArray[i];
- buff[i] = (uint32_t)(buf_hdr->pBuffer);
- }
+ bufferWidth = mGraphicBufferParam.graphicBufferWidth;
}
- mInitDecoder(mHybridCtx,bufferSize,bufferStride,bufferWidth,bufferHeight,bufferCount,gralloc_mode, buff);
+ mInitDecoder(mHybridCtx,bufferSize,bufferStride,bufferWidth,bufferHeight,bufferCount,gralloc_mode, buff, (uint32_t)mAPMode);
+ mFormatChanged = false;
return OMX_ErrorNone;
}
@@ -167,8 +198,13 @@ bool OMXVideoDecoderVP9Hybrid::isReallocateNeeded(const uint8_t * data,uint32_t
if (gralloc_mode) {
ret = mGetFrameResolution(data,data_sz, &width, &height);
if (ret) {
- ret = width > mGraphicBufferParam.graphicBufferWidth
- || height > mGraphicBufferParam.graphicBufferHeight;
+ if (mAPMode == METADATA_MODE) {
+ ret = (width != mDecodedImageWidth)
+ || (height != mDecodedImageHeight);
+ } else {
+ ret = width > mGraphicBufferParam.graphicBufferWidth
+ || height > mGraphicBufferParam.graphicBufferHeight;
+ }
if (ret) {
mDecodedImageNewWidth = width;
mDecodedImageNewHeight = height;
@@ -176,6 +212,7 @@ bool OMXVideoDecoderVP9Hybrid::isReallocateNeeded(const uint8_t * data,uint32_t
}
}
}
+
return ret;
}
@@ -205,10 +242,32 @@ OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::ProcessorFlush(OMX_U32 portIndex) {
}
OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::ProcessorPreFillBuffer(OMX_BUFFERHEADERTYPE* buffer) {
- unsigned int handle = (unsigned int)buffer->pBuffer;
-
if (buffer->nOutputPortIndex == OUTPORT_INDEX){
- mSingalRenderDone(mHybridCtx,handle);
+ unsigned int handle;
+ if (mAPMode == METADATA_MODE) {
+ bool found = false;
+ if (mOMXBufferHeaderTypePtrNum < mMetaDataBuffersNum) {
+ for (uint32_t i = 0; i < mOMXBufferHeaderTypePtrNum; i++) {
+ if (mOMXBufferHeaderTypePtrArray[i] == buffer) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ mOMXBufferHeaderTypePtrArray[mOMXBufferHeaderTypePtrNum] = buffer;
+ mOMXBufferHeaderTypePtrNum++;
+ }
+ } else {
+ found = true;
+ }
+
+ android::VideoGrallocMetadata *metadata = (android::VideoGrallocMetadata *)(buffer->pBuffer);
+ handle = (unsigned int)metadata->pHandle;
+ mSingalRenderDone(mHybridCtx, handle, !found);
+ } else {
+ handle = (unsigned int)buffer->pBuffer;
+ mSingalRenderDone(mHybridCtx, handle, false);
+ }
}
return OMX_ErrorNone;
}
@@ -223,7 +282,7 @@ OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::ProcessorProcess(
OMX_BUFFERHEADERTYPE *outBuffer = *pBuffers[OUTPORT_INDEX];
bool eos = (inBuffer->nFlags & OMX_BUFFERFLAG_EOS)? true:false;
OMX_BOOL isResolutionChange = OMX_FALSE;
-
+ bool formatChange = false;
eos = eos && (inBuffer->nFilledLen == 0);
if (inBuffer->pBuffer == NULL) {
@@ -248,9 +307,13 @@ OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::ProcessorProcess(
if (res != 0) {
if (res == -2) {
if (isReallocateNeeded(inBuffer->pBuffer + inBuffer->nOffset,inBuffer->nFilledLen)) {
- retains[INPORT_INDEX] = BUFFER_RETAIN_GETAGAIN;
- HandleFormatChange();
- return OMX_ErrorNone;
+ if (mAPMode == METADATA_MODE) {
+ mFormatChanged = true;
+ } else {
+ retains[INPORT_INDEX] = BUFFER_RETAIN_GETAGAIN;
+ HandleFormatChange();
+ return OMX_ErrorNone;
+ }
}
// drain the last frame, keep the current input buffer
res = mDecoderDecode(mCtx,mHybridCtx,NULL,0,true);
@@ -337,8 +400,17 @@ OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::FillRenderBuffer(OMX_BUFFERHEADERTYPE **
return OMX_ErrorNone;
}
- fb_index = mGetOutput(mCtx,mHybridCtx, &mDecodedImageNewWidth, &mDecodedImageNewHeight);
+ if (mFormatChanged && mAPMode == METADATA_MODE) {
+ fb_index = mGetOutput(mCtx,mHybridCtx, &mDecodedImageWidth, &mDecodedImageHeight);
+ } else {
+ fb_index = mGetOutput(mCtx,mHybridCtx, &mDecodedImageNewWidth, &mDecodedImageNewHeight);
+ }
if (fb_index == -1) {
+ if (mFormatChanged && mAPMode == METADATA_MODE) {
+ *isResolutionChange = OMX_TRUE;
+ return OMX_ErrorNone;
+ }
+
if (inportBufferFlags & OMX_BUFFERFLAG_EOS) {
// eos frame is no-shown frame
buffer->nFlags = OMX_BUFFERFLAG_EOS;
@@ -352,13 +424,19 @@ OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::FillRenderBuffer(OMX_BUFFERHEADERTYPE **
if (mDecodedImageHeight == 0 && mDecodedImageWidth == 0) {
mDecodedImageWidth = mDecodedImageNewWidth;
mDecodedImageHeight = mDecodedImageNewHeight;
- *isResolutionChange = OMX_TRUE;
+ if (mAPMode == LEGACY_MODE)
+ *isResolutionChange = OMX_TRUE;
}
+
+ if (mAPMode == LEGACY_MODE) {
if ((mDecodedImageNewWidth != mDecodedImageWidth)
- || (mDecodedImageNewHeight!= mDecodedImageHeight)) {
+ || (mDecodedImageNewHeight!= mDecodedImageHeight))
*isResolutionChange = OMX_TRUE;
+ } else {
+ if (mFormatChanged && ((mDecodedImageNewWidth != mDecodedImageWidth)
+ || (mDecodedImageNewHeight!= mDecodedImageHeight)))
+ *isResolutionChange = OMX_TRUE;
}
-
buffer = *pBuffer = mOMXBufferHeaderTypePtrArray[fb_index];
buffer->nOffset = 0;
buffer->nFilledLen = sizeof(OMX_U8*);
@@ -434,6 +512,10 @@ OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::HandleFormatChange(void)
}
}
+ if (mAPMode == METADATA_MODE) {
+ paramPortDefinitionOutput.nBufferCountActual = mNativeBufferCount;
+ paramPortDefinitionOutput.nBufferCountMin = mNativeBufferCount - 4;
+ }
paramPortDefinitionInput.format.video.nFrameWidth = width;
paramPortDefinitionInput.format.video.nFrameHeight = height;
paramPortDefinitionInput.format.video.nStride = stride;
@@ -447,20 +529,25 @@ OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::HandleFormatChange(void)
} else if (mWorkingMode == GRAPHICBUFFER_MODE) {
// when the width and height ES parse are not larger than allocated graphic buffer in outport,
// there is no need to reallocate graphic buffer,just report the crop info to omx client
- if (width <= mGraphicBufferParam.graphicBufferWidth &&
+ if (mAPMode == LEGACY_MODE &&
+ width <= mGraphicBufferParam.graphicBufferWidth &&
height <= mGraphicBufferParam.graphicBufferHeight) {
this->ports[INPORT_INDEX]->SetPortDefinition(&paramPortDefinitionInput, true);
this->ports[OUTPORT_INDEX]->ReportOutputCrop();
return OMX_ErrorNone;
}
- if (width > mGraphicBufferParam.graphicBufferWidth ||
+ if (mAPMode == METADATA_MODE ||
+ width > mGraphicBufferParam.graphicBufferWidth ||
height > mGraphicBufferParam.graphicBufferHeight) {
// update the real decoded resolution to outport instead of display resolution
// for graphic buffer reallocation
// when the width and height parsed from ES are larger than allocated graphic buffer in outport,
paramPortDefinitionOutput.format.video.nFrameWidth = width;
- paramPortDefinitionOutput.format.video.nFrameHeight = (height + 0x1f) & ~0x1f;
+ if (mAPMode == METADATA_MODE)
+ paramPortDefinitionOutput.format.video.nFrameHeight = (height + 0x1f) & ~0x1f;
+ else
+ paramPortDefinitionOutput.format.video.nFrameHeight = (height + 0x1f) & ~0x1f;
paramPortDefinitionOutput.format.video.eColorFormat = GetOutputColorFormat(
paramPortDefinitionOutput.format.video.nFrameWidth);
paramPortDefinitionOutput.format.video.nStride = stride;
@@ -470,6 +557,7 @@ OMX_ERRORTYPE OMXVideoDecoderVP9Hybrid::HandleFormatChange(void)
paramPortDefinitionOutput.bEnabled = (OMX_BOOL)false;
mOMXBufferHeaderTypePtrNum = 0;
+ mMetaDataBuffersNum = 0;
memset(&mGraphicBufferParam, 0, sizeof(mGraphicBufferParam));
mDeinitDecoder(mHybridCtx);
diff --git a/videocodec/OMXVideoDecoderVP9Hybrid.h b/videocodec/OMXVideoDecoderVP9Hybrid.h
index ad44cc5..bee14da 100644
--- a/videocodec/OMXVideoDecoderVP9Hybrid.h
+++ b/videocodec/OMXVideoDecoderVP9Hybrid.h
@@ -68,9 +68,9 @@ private:
uint32_t mDecodedImageNewWidth;
uint32_t mDecodedImageNewHeight;
typedef bool (*OpenFunc)(void ** , void **);
- typedef bool (*InitFunc)(void *,uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, bool, uint32_t *);
+ typedef bool (*InitFunc)(void *,uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, bool, uint32_t *, bool);
typedef bool (*CloseFunc)(void *, void *);
- typedef bool (*SingalRenderDoneFunc)(void *, unsigned int);
+ typedef bool (*SingalRenderDoneFunc)(void *, unsigned int, bool);
typedef int (*DecodeFunc)(void *, void *, unsigned char *, unsigned int, bool);
typedef bool (*IsBufferAvailableFunc)(void *);
typedef int (*GetOutputFunc)(void*, void *, unsigned int *, unsigned int *);