summaryrefslogtreecommitdiffstats
path: root/exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec
diff options
context:
space:
mode:
Diffstat (limited to 'exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec')
-rw-r--r--exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/Android.mk20
-rw-r--r--exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/SEC_OMX_Vdec.c1389
-rw-r--r--exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/SEC_OMX_Vdec.h129
-rw-r--r--exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/Android.mk30
-rw-r--r--exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/SEC_OMX_H264dec.c1479
-rw-r--r--exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/SEC_OMX_H264dec.h73
-rw-r--r--exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/library_register.c55
-rw-r--r--exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/library_register.h55
-rw-r--r--exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/Android.mk30
-rw-r--r--exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/SEC_OMX_Mpeg4dec.c1652
-rw-r--r--exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/SEC_OMX_Mpeg4dec.h98
-rw-r--r--exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/library_register.c63
-rw-r--r--exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/library_register.h59
13 files changed, 5132 insertions, 0 deletions
diff --git a/exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/Android.mk b/exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/Android.mk
new file mode 100644
index 0000000..772c477
--- /dev/null
+++ b/exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/Android.mk
@@ -0,0 +1,20 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ SEC_OMX_Vdec.c
+
+LOCAL_MODULE := libSEC_OMX_Vdec
+LOCAL_ARM_MODE := arm
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_C_INCLUDES := $(SEC_OMX_INC)/khronos \
+ $(SEC_OMX_INC)/sec \
+ $(SEC_OMX_TOP)/sec_osal \
+ $(SEC_OMX_TOP)/sec_omx_core \
+ $(SEC_OMX_COMPONENT)/common \
+ $(SEC_OMX_COMPONENT)/video/dec
+
+LOCAL_C_INCLUDES += $(SEC_OMX_TOP)/sec_codecs/video/mfc_c110/include
+
+include $(BUILD_STATIC_LIBRARY)
diff --git a/exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/SEC_OMX_Vdec.c b/exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/SEC_OMX_Vdec.c
new file mode 100644
index 0000000..30a1acb
--- /dev/null
+++ b/exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/SEC_OMX_Vdec.c
@@ -0,0 +1,1389 @@
+/*
+ *
+ * Copyright 2010 Samsung Electronics S.LSI Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file SEC_OMX_Vdec.c
+ * @brief
+ * @author SeungBeom Kim (sbcrux.kim@samsung.com)
+ * HyeYeon Chung (hyeon.chung@samsung.com)
+ * Yunji Kim (yunji.kim@samsung.com)
+ * @version 1.0
+ * @history
+ * 2010.7.15 : Create
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "SEC_OMX_Macros.h"
+#include "SEC_OSAL_Event.h"
+#include "SEC_OMX_Vdec.h"
+#include "SEC_OMX_Basecomponent.h"
+#include "SEC_OSAL_Thread.h"
+#include "color_space_convertor.h"
+
+#undef SEC_LOG_TAG
+#define SEC_LOG_TAG "SEC_VIDEO_DEC"
+#define SEC_LOG_OFF
+#include "SEC_OSAL_Log.h"
+
+
+inline void SEC_UpdateFrameSize(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ SEC_OMX_BASEPORT *secInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ SEC_OMX_BASEPORT *secOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+
+ if ((secOutputPort->portDefinition.format.video.nFrameWidth !=
+ secInputPort->portDefinition.format.video.nFrameWidth) ||
+ (secOutputPort->portDefinition.format.video.nFrameHeight !=
+ secInputPort->portDefinition.format.video.nFrameHeight)) {
+ OMX_U32 width = 0, height = 0;
+
+ secOutputPort->portDefinition.format.video.nFrameWidth =
+ secInputPort->portDefinition.format.video.nFrameWidth;
+ secOutputPort->portDefinition.format.video.nFrameHeight =
+ secInputPort->portDefinition.format.video.nFrameHeight;
+ width = secOutputPort->portDefinition.format.video.nStride =
+ secInputPort->portDefinition.format.video.nStride;
+ height = secOutputPort->portDefinition.format.video.nSliceHeight =
+ secInputPort->portDefinition.format.video.nSliceHeight;
+
+ switch(secOutputPort->portDefinition.format.video.eColorFormat) {
+ case OMX_COLOR_FormatYUV420Planar:
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ case OMX_SEC_COLOR_FormatANBYUV420SemiPlanar:
+ if (width && height)
+ secOutputPort->portDefinition.nBufferSize = (width * height * 3) / 2;
+ break;
+ default:
+ if (width && height)
+ secOutputPort->portDefinition.nBufferSize = width * height * 2;
+ break;
+ }
+ }
+
+ return ;
+}
+
+OMX_ERRORTYPE SEC_OMX_UseBuffer(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_INOUT OMX_BUFFERHEADERTYPE **ppBufferHdr,
+ OMX_IN OMX_U32 nPortIndex,
+ OMX_IN OMX_PTR pAppPrivate,
+ OMX_IN OMX_U32 nSizeBytes,
+ OMX_IN OMX_U8 *pBuffer)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+ OMX_BUFFERHEADERTYPE *temp_bufferHeader = NULL;
+ int i = 0;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ pSECPort = &pSECComponent->pSECPort[nPortIndex];
+ if (nPortIndex >= pSECComponent->portParam.nPorts) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+ if (pSECPort->portState != OMX_StateIdle) {
+ ret = OMX_ErrorIncorrectStateOperation;
+ goto EXIT;
+ }
+
+ if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ temp_bufferHeader = (OMX_BUFFERHEADERTYPE *)SEC_OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE));
+ if (temp_bufferHeader == NULL) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ SEC_OSAL_Memset(temp_bufferHeader, 0, sizeof(OMX_BUFFERHEADERTYPE));
+
+ for (i = 0; i < pSECPort->portDefinition.nBufferCountActual; i++) {
+ if (pSECPort->bufferStateAllocate[i] == BUFFER_STATE_FREE) {
+ pSECPort->bufferHeader[i] = temp_bufferHeader;
+ pSECPort->bufferStateAllocate[i] = (BUFFER_STATE_ASSIGNED | HEADER_STATE_ALLOCATED);
+ INIT_SET_SIZE_VERSION(temp_bufferHeader, OMX_BUFFERHEADERTYPE);
+ temp_bufferHeader->pBuffer = pBuffer;
+ temp_bufferHeader->nAllocLen = nSizeBytes;
+ temp_bufferHeader->pAppPrivate = pAppPrivate;
+ if ( nPortIndex == INPUT_PORT_INDEX)
+ temp_bufferHeader->nInputPortIndex = INPUT_PORT_INDEX;
+ else
+ temp_bufferHeader->nOutputPortIndex = OUTPUT_PORT_INDEX;
+
+ pSECPort->assignedBufferNum++;
+ if (pSECPort->assignedBufferNum == pSECPort->portDefinition.nBufferCountActual) {
+ pSECPort->portDefinition.bPopulated = OMX_TRUE;
+ /* SEC_OSAL_MutexLock(pSECComponent->compMutex); */
+ SEC_OSAL_SemaphorePost(pSECPort->loadedResource);
+ /* SEC_OSAL_MutexUnlock(pSECComponent->compMutex); */
+ }
+ *ppBufferHdr = temp_bufferHeader;
+ ret = OMX_ErrorNone;
+ goto EXIT;
+ }
+ }
+
+ SEC_OSAL_Free(temp_bufferHeader);
+ ret = OMX_ErrorInsufficientResources;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_OMX_AllocateBuffer(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_INOUT OMX_BUFFERHEADERTYPE **ppBuffer,
+ OMX_IN OMX_U32 nPortIndex,
+ OMX_IN OMX_PTR pAppPrivate,
+ OMX_IN OMX_U32 nSizeBytes)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+ OMX_BUFFERHEADERTYPE *temp_bufferHeader = NULL;
+ OMX_U8 *temp_buffer = NULL;
+ int i = 0;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ pSECPort = &pSECComponent->pSECPort[nPortIndex];
+ if (nPortIndex >= pSECComponent->portParam.nPorts) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+/*
+ if (pSECPort->portState != OMX_StateIdle ) {
+ ret = OMX_ErrorIncorrectStateOperation;
+ goto EXIT;
+ }
+*/
+ if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ temp_buffer = SEC_OSAL_Malloc(sizeof(OMX_U8) * nSizeBytes);
+ if (temp_buffer == NULL) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+
+ temp_bufferHeader = (OMX_BUFFERHEADERTYPE *)SEC_OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE));
+ if (temp_bufferHeader == NULL) {
+ SEC_OSAL_Free(temp_buffer);
+ temp_buffer = NULL;
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ SEC_OSAL_Memset(temp_bufferHeader, 0, sizeof(OMX_BUFFERHEADERTYPE));
+
+ for (i = 0; i < pSECPort->portDefinition.nBufferCountActual; i++) {
+ if (pSECPort->bufferStateAllocate[i] == BUFFER_STATE_FREE) {
+ pSECPort->bufferHeader[i] = temp_bufferHeader;
+ pSECPort->bufferStateAllocate[i] = (BUFFER_STATE_ALLOCATED | HEADER_STATE_ALLOCATED);
+ INIT_SET_SIZE_VERSION(temp_bufferHeader, OMX_BUFFERHEADERTYPE);
+ temp_bufferHeader->pBuffer = temp_buffer;
+ temp_bufferHeader->nAllocLen = nSizeBytes;
+ temp_bufferHeader->pAppPrivate = pAppPrivate;
+ if ( nPortIndex == INPUT_PORT_INDEX)
+ temp_bufferHeader->nInputPortIndex = INPUT_PORT_INDEX;
+ else
+ temp_bufferHeader->nOutputPortIndex = OUTPUT_PORT_INDEX;
+ pSECPort->assignedBufferNum++;
+ if (pSECPort->assignedBufferNum == pSECPort->portDefinition.nBufferCountActual) {
+ pSECPort->portDefinition.bPopulated = OMX_TRUE;
+ /* SEC_OSAL_MutexLock(pSECComponent->compMutex); */
+ SEC_OSAL_SemaphorePost(pSECPort->loadedResource);
+ /* SEC_OSAL_MutexUnlock(pSECComponent->compMutex); */
+ }
+ *ppBuffer = temp_bufferHeader;
+ ret = OMX_ErrorNone;
+ goto EXIT;
+ }
+ }
+
+ SEC_OSAL_Free(temp_bufferHeader);
+ SEC_OSAL_Free(temp_buffer);
+ ret = OMX_ErrorInsufficientResources;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_OMX_FreeBuffer(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_U32 nPortIndex,
+ OMX_IN OMX_BUFFERHEADERTYPE *pBufferHdr)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+ OMX_BUFFERHEADERTYPE *temp_bufferHeader = NULL;
+ OMX_U8 *temp_buffer = NULL;
+ int i = 0;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ pSECPort = &pSECComponent->pSECPort[nPortIndex];
+
+ if (CHECK_PORT_TUNNELED(pSECPort) && CHECK_PORT_BUFFER_SUPPLIER(pSECPort)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ if ((pSECPort->portState != OMX_StateLoaded) && (pSECPort->portState != OMX_StateInvalid)) {
+ (*(pSECComponent->pCallbacks->EventHandler)) (pOMXComponent,
+ pSECComponent->callbackData,
+ (OMX_U32)OMX_EventError,
+ (OMX_U32)OMX_ErrorPortUnpopulated,
+ nPortIndex, NULL);
+ }
+
+ for (i = 0; i < pSECPort->portDefinition.nBufferCountActual; i++) {
+ if (((pSECPort->bufferStateAllocate[i] | BUFFER_STATE_FREE) != 0) && (pSECPort->bufferHeader[i] != NULL)) {
+ if (pSECPort->bufferHeader[i]->pBuffer == pBufferHdr->pBuffer) {
+ if (pSECPort->bufferStateAllocate[i] & BUFFER_STATE_ALLOCATED) {
+ SEC_OSAL_Free(pSECPort->bufferHeader[i]->pBuffer);
+ pSECPort->bufferHeader[i]->pBuffer = NULL;
+ pBufferHdr->pBuffer = NULL;
+ } else if (pSECPort->bufferStateAllocate[i] & BUFFER_STATE_ASSIGNED) {
+ ; /* None*/
+ }
+ pSECPort->assignedBufferNum--;
+ if (pSECPort->bufferStateAllocate[i] & HEADER_STATE_ALLOCATED) {
+ SEC_OSAL_Free(pSECPort->bufferHeader[i]);
+ pSECPort->bufferHeader[i] = NULL;
+ pBufferHdr = NULL;
+ }
+ pSECPort->bufferStateAllocate[i] = BUFFER_STATE_FREE;
+ ret = OMX_ErrorNone;
+ goto EXIT;
+ }
+ }
+ }
+
+EXIT:
+ if (ret == OMX_ErrorNone) {
+ if ( pSECPort->assignedBufferNum == 0 ) {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "pSECPort->unloadedResource signal set");
+ /* SEC_OSAL_MutexLock(pSECComponent->compMutex); */
+ SEC_OSAL_SemaphorePost(pSECPort->unloadedResource);
+ /* SEC_OSAL_MutexUnlock(pSECComponent->compMutex); */
+ pSECPort->portDefinition.bPopulated = OMX_FALSE;
+ }
+ }
+
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_OMX_AllocateTunnelBuffer(SEC_OMX_BASEPORT *pOMXBasePort, OMX_U32 nPortIndex)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+ OMX_BUFFERHEADERTYPE *temp_bufferHeader = NULL;
+ OMX_U8 *temp_buffer = NULL;
+ OMX_U32 bufferSize = 0;
+ OMX_PARAM_PORTDEFINITIONTYPE portDefinition;
+
+ ret = OMX_ErrorTunnelingUnsupported;
+EXIT:
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_OMX_FreeTunnelBuffer(SEC_OMX_BASEPORT *pOMXBasePort, OMX_U32 nPortIndex)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ SEC_OMX_BASEPORT* pSECPort = NULL;
+ OMX_BUFFERHEADERTYPE* temp_bufferHeader = NULL;
+ OMX_U8 *temp_buffer = NULL;
+ OMX_U32 bufferSize = 0;
+
+ ret = OMX_ErrorTunnelingUnsupported;
+EXIT:
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_OMX_ComponentTunnelRequest(
+ OMX_IN OMX_HANDLETYPE hComp,
+ OMX_IN OMX_U32 nPort,
+ OMX_IN OMX_HANDLETYPE hTunneledComp,
+ OMX_IN OMX_U32 nTunneledPort,
+ OMX_INOUT OMX_TUNNELSETUPTYPE *pTunnelSetup)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+
+ ret = OMX_ErrorTunnelingUnsupported;
+EXIT:
+ return ret;
+}
+
+OMX_BOOL SEC_Check_BufferProcess_State(SEC_OMX_BASECOMPONENT *pSECComponent)
+{
+ if ((pSECComponent->currentState == OMX_StateExecuting) &&
+ (pSECComponent->pSECPort[INPUT_PORT_INDEX].portState == OMX_StateIdle) &&
+ (pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portState == OMX_StateIdle) &&
+ (pSECComponent->transientState != SEC_OMX_TransStateExecutingToIdle) &&
+ (pSECComponent->transientState != SEC_OMX_TransStateIdleToExecuting)) {
+ return OMX_TRUE;
+ } else {
+ return OMX_FALSE;
+ }
+}
+
+static OMX_ERRORTYPE SEC_InputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ SEC_OMX_BASEPORT *secOMXInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ SEC_OMX_BASEPORT *secOMXOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+ SEC_OMX_DATABUFFER *dataBuffer = &pSECComponent->secDataBuffer[INPUT_PORT_INDEX];
+ OMX_BUFFERHEADERTYPE *bufferHeader = dataBuffer->bufferHeader;
+
+ FunctionIn();
+
+ if (bufferHeader != NULL) {
+ if (secOMXInputPort->markType.hMarkTargetComponent != NULL ) {
+ bufferHeader->hMarkTargetComponent = secOMXInputPort->markType.hMarkTargetComponent;
+ bufferHeader->pMarkData = secOMXInputPort->markType.pMarkData;
+ secOMXInputPort->markType.hMarkTargetComponent = NULL;
+ secOMXInputPort->markType.pMarkData = NULL;
+ }
+
+ if (bufferHeader->hMarkTargetComponent != NULL) {
+ if (bufferHeader->hMarkTargetComponent == pOMXComponent) {
+ pSECComponent->pCallbacks->EventHandler(pOMXComponent,
+ pSECComponent->callbackData,
+ OMX_EventMark,
+ 0, 0, bufferHeader->pMarkData);
+ } else {
+ pSECComponent->propagateMarkType.hMarkTargetComponent = bufferHeader->hMarkTargetComponent;
+ pSECComponent->propagateMarkType.pMarkData = bufferHeader->pMarkData;
+ }
+ }
+
+ if (CHECK_PORT_TUNNELED(secOMXInputPort)) {
+ OMX_FillThisBuffer(secOMXInputPort->tunneledComponent, bufferHeader);
+ } else {
+ bufferHeader->nFilledLen = 0;
+ pSECComponent->pCallbacks->EmptyBufferDone(pOMXComponent, pSECComponent->callbackData, bufferHeader);
+ }
+ }
+
+ if ((pSECComponent->currentState == OMX_StatePause) &&
+ ((!CHECK_PORT_BEING_FLUSHED(secOMXInputPort) && !CHECK_PORT_BEING_FLUSHED(secOMXOutputPort)))) {
+ SEC_OSAL_SignalReset(pSECComponent->pauseEvent);
+ SEC_OSAL_SignalWait(pSECComponent->pauseEvent, DEF_MAX_WAIT_TIME);
+ }
+
+ dataBuffer->dataValid = OMX_FALSE;
+ dataBuffer->dataLen = 0;
+ dataBuffer->remainDataLen = 0;
+ dataBuffer->usedDataLen = 0;
+ dataBuffer->bufferHeader = NULL;
+ dataBuffer->nFlags = 0;
+ dataBuffer->timeStamp = 0;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_InputBufferGetQueue(SEC_OMX_BASECOMPONENT *pSECComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+ SEC_OMX_DATABUFFER *dataBuffer = NULL;
+ SEC_OMX_MESSAGE* message = NULL;
+ SEC_OMX_DATABUFFER *inputUseBuffer = &pSECComponent->secDataBuffer[INPUT_PORT_INDEX];
+
+ FunctionIn();
+
+ pSECPort= &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ dataBuffer = &pSECComponent->secDataBuffer[INPUT_PORT_INDEX];
+
+ if (pSECComponent->currentState != OMX_StateExecuting) {
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ } else {
+ SEC_OSAL_SemaphoreWait(pSECPort->bufferSemID);
+ SEC_OSAL_MutexLock(inputUseBuffer->bufferMutex);
+ if (dataBuffer->dataValid != OMX_TRUE) {
+ message = (SEC_OMX_MESSAGE *)SEC_OSAL_Dequeue(&pSECPort->bufferQ);
+ if (message == NULL) {
+ ret = OMX_ErrorUndefined;
+ SEC_OSAL_MutexUnlock(inputUseBuffer->bufferMutex);
+ goto EXIT;
+ }
+
+ dataBuffer->bufferHeader = (OMX_BUFFERHEADERTYPE *)(message->pCmdData);
+ dataBuffer->allocSize = dataBuffer->bufferHeader->nAllocLen;
+ dataBuffer->dataLen = dataBuffer->bufferHeader->nFilledLen;
+ dataBuffer->remainDataLen = dataBuffer->dataLen;
+ dataBuffer->usedDataLen = 0;
+ dataBuffer->dataValid = OMX_TRUE;
+ dataBuffer->nFlags = dataBuffer->bufferHeader->nFlags;
+ dataBuffer->timeStamp = dataBuffer->bufferHeader->nTimeStamp;
+
+ SEC_OSAL_Free(message);
+
+ if (dataBuffer->allocSize <= dataBuffer->dataLen)
+ SEC_OSAL_Log(SEC_LOG_WARNING, "Input Buffer Full, Check input buffer size! allocSize:%d, dataLen:%d", dataBuffer->allocSize, dataBuffer->dataLen);
+ }
+ SEC_OSAL_MutexUnlock(inputUseBuffer->bufferMutex);
+ ret = OMX_ErrorNone;
+ }
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+static OMX_ERRORTYPE SEC_OutputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ SEC_OMX_BASEPORT *secOMXInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ SEC_OMX_BASEPORT *secOMXOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+ SEC_OMX_DATABUFFER *dataBuffer = &pSECComponent->secDataBuffer[OUTPUT_PORT_INDEX];
+ OMX_BUFFERHEADERTYPE *bufferHeader = dataBuffer->bufferHeader;
+
+ FunctionIn();
+
+ if (bufferHeader != NULL) {
+ bufferHeader->nFilledLen = dataBuffer->remainDataLen;
+ bufferHeader->nOffset = 0;
+ bufferHeader->nFlags = dataBuffer->nFlags;
+ bufferHeader->nTimeStamp = dataBuffer->timeStamp;
+
+ if (pSECComponent->propagateMarkType.hMarkTargetComponent != NULL) {
+ bufferHeader->hMarkTargetComponent = pSECComponent->propagateMarkType.hMarkTargetComponent;
+ bufferHeader->pMarkData = pSECComponent->propagateMarkType.pMarkData;
+ pSECComponent->propagateMarkType.hMarkTargetComponent = NULL;
+ pSECComponent->propagateMarkType.pMarkData = NULL;
+ }
+
+ if (bufferHeader->nFlags & OMX_BUFFERFLAG_EOS) {
+ pSECComponent->pCallbacks->EventHandler(pOMXComponent,
+ pSECComponent->callbackData,
+ OMX_EventBufferFlag,
+ OUTPUT_PORT_INDEX,
+ bufferHeader->nFlags, NULL);
+ }
+
+ if (CHECK_PORT_TUNNELED(secOMXOutputPort)) {
+ OMX_EmptyThisBuffer(secOMXOutputPort->tunneledComponent, bufferHeader);
+ } else {
+ pSECComponent->pCallbacks->FillBufferDone(pOMXComponent, pSECComponent->callbackData, bufferHeader);
+ }
+ }
+
+ if ((pSECComponent->currentState == OMX_StatePause) &&
+ ((!CHECK_PORT_BEING_FLUSHED(secOMXInputPort) && !CHECK_PORT_BEING_FLUSHED(secOMXOutputPort)))) {
+ SEC_OSAL_SignalReset(pSECComponent->pauseEvent);
+ SEC_OSAL_SignalWait(pSECComponent->pauseEvent, DEF_MAX_WAIT_TIME);
+ }
+
+ /* reset dataBuffer */
+ dataBuffer->dataValid = OMX_FALSE;
+ dataBuffer->dataLen = 0;
+ dataBuffer->remainDataLen = 0;
+ dataBuffer->usedDataLen = 0;
+ dataBuffer->bufferHeader = NULL;
+ dataBuffer->nFlags = 0;
+ dataBuffer->timeStamp = 0;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_OutputBufferGetQueue(SEC_OMX_BASECOMPONENT *pSECComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+ SEC_OMX_DATABUFFER *dataBuffer = NULL;
+ SEC_OMX_MESSAGE *message = NULL;
+ SEC_OMX_DATABUFFER *outputUseBuffer = &pSECComponent->secDataBuffer[OUTPUT_PORT_INDEX];
+
+ FunctionIn();
+
+ pSECPort= &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+ dataBuffer = &pSECComponent->secDataBuffer[OUTPUT_PORT_INDEX];
+
+ if (pSECComponent->currentState != OMX_StateExecuting) {
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ } else {
+ SEC_OSAL_SemaphoreWait(pSECPort->bufferSemID);
+ SEC_OSAL_MutexLock(outputUseBuffer->bufferMutex);
+ if (dataBuffer->dataValid != OMX_TRUE) {
+ message = (SEC_OMX_MESSAGE *)SEC_OSAL_Dequeue(&pSECPort->bufferQ);
+ if (message == NULL) {
+ ret = OMX_ErrorUndefined;
+ SEC_OSAL_MutexUnlock(outputUseBuffer->bufferMutex);
+ goto EXIT;
+ }
+
+ dataBuffer->bufferHeader = (OMX_BUFFERHEADERTYPE *)(message->pCmdData);
+ dataBuffer->allocSize = dataBuffer->bufferHeader->nAllocLen;
+ dataBuffer->dataLen = 0; //dataBuffer->bufferHeader->nFilledLen;
+ dataBuffer->remainDataLen = dataBuffer->dataLen;
+ dataBuffer->usedDataLen = 0; //dataBuffer->bufferHeader->nOffset;
+ dataBuffer->dataValid =OMX_TRUE;
+ /* dataBuffer->nFlags = dataBuffer->bufferHeader->nFlags; */
+ /* dataBuffer->nTimeStamp = dataBuffer->bufferHeader->nTimeStamp; */
+ pSECComponent->processData[OUTPUT_PORT_INDEX].dataBuffer = dataBuffer->bufferHeader->pBuffer;
+ pSECComponent->processData[OUTPUT_PORT_INDEX].allocSize = dataBuffer->bufferHeader->nAllocLen;
+
+ SEC_OSAL_Free(message);
+ }
+ SEC_OSAL_MutexUnlock(outputUseBuffer->bufferMutex);
+ ret = OMX_ErrorNone;
+ }
+EXIT:
+ FunctionOut();
+
+ return ret;
+
+}
+
+static OMX_ERRORTYPE SEC_BufferReset(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 portIndex)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ /* SEC_OMX_BASEPORT *pSECPort = &pSECComponent->pSECPort[portIndex]; */
+ SEC_OMX_DATABUFFER *dataBuffer = &pSECComponent->secDataBuffer[portIndex];
+ /* OMX_BUFFERHEADERTYPE *bufferHeader = dataBuffer->bufferHeader; */
+
+ dataBuffer->dataValid = OMX_FALSE;
+ dataBuffer->dataLen = 0;
+ dataBuffer->remainDataLen = 0;
+ dataBuffer->usedDataLen = 0;
+ dataBuffer->bufferHeader = NULL;
+ dataBuffer->nFlags = 0;
+ dataBuffer->timeStamp = 0;
+
+ return ret;
+}
+
+static OMX_ERRORTYPE SEC_DataReset(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 portIndex)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ /* SEC_OMX_BASEPORT *pSECPort = &pSECComponent->pSECPort[portIndex]; */
+ /* SEC_OMX_DATABUFFER *dataBuffer = &pSECComponent->secDataBuffer[portIndex]; */
+ /* OMX_BUFFERHEADERTYPE *bufferHeader = dataBuffer->bufferHeader; */
+ SEC_OMX_DATA *processData = &pSECComponent->processData[portIndex];
+
+ processData->dataLen = 0;
+ processData->remainDataLen = 0;
+ processData->usedDataLen = 0;
+ processData->nFlags = 0;
+ processData->timeStamp = 0;
+
+ return ret;
+}
+
+OMX_BOOL SEC_Preprocessor_InputData(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ OMX_BOOL ret = OMX_FALSE;
+ SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ SEC_OMX_DATABUFFER *inputUseBuffer = &pSECComponent->secDataBuffer[INPUT_PORT_INDEX];
+ SEC_OMX_DATA *inputData = &pSECComponent->processData[INPUT_PORT_INDEX];
+ OMX_U32 copySize = 0;
+ OMX_BYTE checkInputStream = NULL;
+ OMX_U32 checkInputStreamLen = 0;
+ OMX_U32 checkedSize = 0;
+ OMX_BOOL flagEOF = OMX_FALSE;
+ OMX_BOOL previousFrameEOF = OMX_FALSE;
+
+ FunctionIn();
+
+ if (inputUseBuffer->dataValid == OMX_TRUE) {
+ checkInputStream = inputUseBuffer->bufferHeader->pBuffer + inputUseBuffer->usedDataLen;
+ checkInputStreamLen = inputUseBuffer->remainDataLen;
+
+ if (inputData->dataLen == 0) {
+ previousFrameEOF = OMX_TRUE;
+ } else {
+ previousFrameEOF = OMX_FALSE;
+ }
+ if ((pSECComponent->bUseFlagEOF == OMX_TRUE) &&
+ !(inputUseBuffer->nFlags & OMX_BUFFERFLAG_CODECCONFIG)) {
+ flagEOF = OMX_TRUE;
+ checkedSize = checkInputStreamLen;
+ } else {
+ pSECComponent->bUseFlagEOF = OMX_FALSE;
+ checkedSize = pSECComponent->sec_checkInputFrame(checkInputStream, checkInputStreamLen, inputUseBuffer->nFlags, previousFrameEOF, &flagEOF);
+ }
+
+ if (flagEOF == OMX_TRUE) {
+ copySize = checkedSize;
+ SEC_OSAL_Log(SEC_LOG_TRACE, "sec_checkInputFrame : OMX_TRUE");
+ } else {
+ copySize = checkInputStreamLen;
+ SEC_OSAL_Log(SEC_LOG_TRACE, "sec_checkInputFrame : OMX_FALSE");
+ }
+
+ if (inputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS)
+ pSECComponent->bSaveFlagEOS = OMX_TRUE;
+
+ if (((inputData->allocSize) - (inputData->dataLen)) >= copySize) {
+ if (copySize > 0)
+ SEC_OSAL_Memcpy(inputData->dataBuffer + inputData->dataLen, checkInputStream, copySize);
+
+ inputUseBuffer->dataLen -= copySize;
+ inputUseBuffer->remainDataLen -= copySize;
+ inputUseBuffer->usedDataLen += copySize;
+
+ inputData->dataLen += copySize;
+ inputData->remainDataLen += copySize;
+
+ if (previousFrameEOF == OMX_TRUE) {
+ inputData->timeStamp = inputUseBuffer->timeStamp;
+ inputData->nFlags = inputUseBuffer->nFlags;
+ }
+
+ if (pSECComponent->bUseFlagEOF == OMX_TRUE) {
+ if (pSECComponent->bSaveFlagEOS == OMX_TRUE) {
+ inputData->nFlags |= OMX_BUFFERFLAG_EOS;
+ flagEOF = OMX_TRUE;
+ pSECComponent->bSaveFlagEOS = OMX_FALSE;
+ } else {
+ inputData->nFlags = (inputData->nFlags & (~OMX_BUFFERFLAG_EOS));
+ }
+ } else {
+ if ((checkedSize == checkInputStreamLen) && (pSECComponent->bSaveFlagEOS == OMX_TRUE)) {
+ if ((inputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS) &&
+ ((inputData->nFlags & OMX_BUFFERFLAG_CODECCONFIG) ||
+ (inputData->dataLen == 0))) {
+ inputData->nFlags |= OMX_BUFFERFLAG_EOS;
+ flagEOF = OMX_TRUE;
+ pSECComponent->bSaveFlagEOS = OMX_FALSE;
+ } else if ((inputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS) &&
+ (!(inputData->nFlags & OMX_BUFFERFLAG_CODECCONFIG)) &&
+ (inputData->dataLen != 0)) {
+ inputData->nFlags = (inputData->nFlags & (~OMX_BUFFERFLAG_EOS));
+ flagEOF = OMX_TRUE;
+ pSECComponent->bSaveFlagEOS = OMX_TRUE;
+ }
+ } else {
+ inputData->nFlags = (inputUseBuffer->nFlags & (~OMX_BUFFERFLAG_EOS));
+ }
+ }
+
+ if(((inputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) &&
+ (inputData->dataLen <= 0) && (flagEOF == OMX_TRUE)) {
+ inputData->dataLen = inputData->previousDataLen;
+ inputData->remainDataLen = inputData->previousDataLen;
+ }
+ } else {
+ /*????????????????????????????????? Error ?????????????????????????????????*/
+ SEC_DataReset(pOMXComponent, INPUT_PORT_INDEX);
+ flagEOF = OMX_FALSE;
+ }
+
+ if (inputUseBuffer->remainDataLen == 0)
+ SEC_InputBufferReturn(pOMXComponent);
+ else
+ inputUseBuffer->dataValid = OMX_TRUE;
+ }
+
+ if (flagEOF == OMX_TRUE) {
+ if (pSECComponent->checkTimeStamp.needSetStartTimeStamp == OMX_TRUE) {
+ pSECComponent->checkTimeStamp.needCheckStartTimeStamp = OMX_TRUE;
+ pSECComponent->checkTimeStamp.startTimeStamp = inputData->timeStamp;
+ pSECComponent->checkTimeStamp.nStartFlags = inputData->nFlags;
+ pSECComponent->checkTimeStamp.needSetStartTimeStamp = OMX_FALSE;
+ }
+
+ ret = OMX_TRUE;
+ } else {
+ ret = OMX_FALSE;
+ }
+
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_BOOL SEC_Postprocess_OutputData(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ OMX_BOOL ret = OMX_FALSE;
+ SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ SEC_OMX_DATABUFFER *outputUseBuffer = &pSECComponent->secDataBuffer[OUTPUT_PORT_INDEX];
+ SEC_OMX_DATA *outputData = &pSECComponent->processData[OUTPUT_PORT_INDEX];
+ OMX_U32 copySize = 0;
+
+ FunctionIn();
+
+ if (outputUseBuffer->dataValid == OMX_TRUE) {
+ if (pSECComponent->checkTimeStamp.needCheckStartTimeStamp == OMX_TRUE) {
+ if ((pSECComponent->checkTimeStamp.startTimeStamp == outputData->timeStamp) &&
+ (pSECComponent->checkTimeStamp.nStartFlags == outputData->nFlags)){
+ pSECComponent->checkTimeStamp.startTimeStamp = -19761123;
+ pSECComponent->checkTimeStamp.nStartFlags = 0x0;
+ pSECComponent->checkTimeStamp.needSetStartTimeStamp = OMX_FALSE;
+ pSECComponent->checkTimeStamp.needCheckStartTimeStamp = OMX_FALSE;
+ } else {
+ SEC_DataReset(pOMXComponent, OUTPUT_PORT_INDEX);
+
+ ret = OMX_TRUE;
+ goto EXIT;
+ }
+ } else if (pSECComponent->checkTimeStamp.needSetStartTimeStamp == OMX_TRUE) {
+ SEC_DataReset(pOMXComponent, OUTPUT_PORT_INDEX);
+
+ ret = OMX_TRUE;
+ goto EXIT;
+ }
+
+ if (outputData->remainDataLen <= (outputUseBuffer->allocSize - outputUseBuffer->dataLen)) {
+ copySize = outputData->remainDataLen;
+ outputUseBuffer->dataLen += copySize;
+ outputUseBuffer->remainDataLen += copySize;
+ outputUseBuffer->nFlags = outputData->nFlags;
+ outputUseBuffer->timeStamp = outputData->timeStamp;
+
+ ret = OMX_TRUE;
+
+ /* reset outputData */
+ SEC_DataReset(pOMXComponent, OUTPUT_PORT_INDEX);
+
+ if ((outputUseBuffer->remainDataLen > 0) ||
+ (outputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS))
+ SEC_OutputBufferReturn(pOMXComponent);
+ } else {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "output buffer is smaller than decoded data size Out Length");
+
+ copySize = outputUseBuffer->allocSize - outputUseBuffer->dataLen;
+ outputUseBuffer->dataLen += copySize;
+ outputUseBuffer->remainDataLen += copySize;
+ outputUseBuffer->nFlags = 0;
+ outputUseBuffer->timeStamp = outputData->timeStamp;
+
+ ret = OMX_FALSE;
+
+ outputData->remainDataLen -= copySize;
+ outputData->usedDataLen += copySize;
+
+ SEC_OutputBufferReturn(pOMXComponent);
+ }
+ } else {
+ ret = OMX_FALSE;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_OMX_BufferProcess(OMX_HANDLETYPE hComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ SEC_OMX_BASEPORT *secInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ SEC_OMX_BASEPORT *secOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+ SEC_OMX_DATABUFFER *inputUseBuffer = &pSECComponent->secDataBuffer[INPUT_PORT_INDEX];
+ SEC_OMX_DATABUFFER *outputUseBuffer = &pSECComponent->secDataBuffer[OUTPUT_PORT_INDEX];
+ SEC_OMX_DATA *inputData = &pSECComponent->processData[INPUT_PORT_INDEX];
+ SEC_OMX_DATA *outputData = &pSECComponent->processData[OUTPUT_PORT_INDEX];
+ OMX_U32 copySize = 0;
+
+ pSECComponent->remainOutputData = OMX_FALSE;
+ pSECComponent->reInputData = OMX_FALSE;
+
+ FunctionIn();
+
+ while (!pSECComponent->bExitBufferProcessThread) {
+ SEC_OSAL_SleepMillisec(0);
+
+ if (((pSECComponent->currentState == OMX_StatePause) ||
+ (pSECComponent->currentState == OMX_StateIdle) ||
+ (pSECComponent->transientState == SEC_OMX_TransStateLoadedToIdle) ||
+ (pSECComponent->transientState == SEC_OMX_TransStateExecutingToIdle)) &&
+ (pSECComponent->transientState != SEC_OMX_TransStateIdleToLoaded)&&
+ ((!CHECK_PORT_BEING_FLUSHED(secInputPort) && !CHECK_PORT_BEING_FLUSHED(secOutputPort)))) {
+ SEC_OSAL_SignalReset(pSECComponent->pauseEvent);
+ SEC_OSAL_SignalWait(pSECComponent->pauseEvent, DEF_MAX_WAIT_TIME);
+ }
+
+ while (SEC_Check_BufferProcess_State(pSECComponent) && !pSECComponent->bExitBufferProcessThread) {
+ SEC_OSAL_SleepMillisec(0);
+
+ SEC_OSAL_MutexLock(outputUseBuffer->bufferMutex);
+ if ((outputUseBuffer->dataValid != OMX_TRUE) &&
+ (!CHECK_PORT_BEING_FLUSHED(secOutputPort))) {
+ SEC_OSAL_MutexUnlock(outputUseBuffer->bufferMutex);
+ ret = SEC_OutputBufferGetQueue(pSECComponent);
+ if ((ret == OMX_ErrorUndefined) ||
+ (secInputPort->portState != OMX_StateIdle) ||
+ (secOutputPort->portState != OMX_StateIdle)) {
+ break;
+ }
+ } else {
+ SEC_OSAL_MutexUnlock(outputUseBuffer->bufferMutex);
+ }
+
+ if (pSECComponent->remainOutputData == OMX_FALSE) {
+ if (pSECComponent->reInputData == OMX_FALSE) {
+ SEC_OSAL_MutexLock(inputUseBuffer->bufferMutex);
+ if ((SEC_Preprocessor_InputData(pOMXComponent) == OMX_FALSE) &&
+ (!CHECK_PORT_BEING_FLUSHED(secInputPort))) {
+ SEC_OSAL_MutexUnlock(inputUseBuffer->bufferMutex);
+ ret = SEC_InputBufferGetQueue(pSECComponent);
+ break;
+ }
+
+ SEC_OSAL_MutexUnlock(inputUseBuffer->bufferMutex);
+ }
+
+ SEC_OSAL_MutexLock(inputUseBuffer->bufferMutex);
+ SEC_OSAL_MutexLock(outputUseBuffer->bufferMutex);
+ ret = pSECComponent->sec_mfc_bufferProcess(pOMXComponent, inputData, outputData);
+ SEC_OSAL_MutexUnlock(outputUseBuffer->bufferMutex);
+ SEC_OSAL_MutexUnlock(inputUseBuffer->bufferMutex);
+
+ if (ret == OMX_ErrorInputDataDecodeYet)
+ pSECComponent->reInputData = OMX_TRUE;
+ else
+ pSECComponent->reInputData = OMX_FALSE;
+ }
+
+ SEC_OSAL_MutexLock(outputUseBuffer->bufferMutex);
+
+ if (SEC_Postprocess_OutputData(pOMXComponent) == OMX_FALSE)
+ pSECComponent->remainOutputData = OMX_TRUE;
+ else
+ pSECComponent->remainOutputData = OMX_FALSE;
+
+ SEC_OSAL_MutexUnlock(outputUseBuffer->bufferMutex);
+ }
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_OMX_VideoDecodeGetParameter(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_INDEXTYPE nParamIndex,
+ OMX_INOUT OMX_PTR ComponentParameterStructure)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ if (pSECComponent->currentState == OMX_StateInvalid ) {
+ ret = OMX_StateInvalid;
+ goto EXIT;
+ }
+
+ if (ComponentParameterStructure == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ switch (nParamIndex) {
+ case OMX_IndexParamVideoInit:
+ {
+ OMX_PORT_PARAM_TYPE *portParam = (OMX_PORT_PARAM_TYPE *)ComponentParameterStructure;
+ ret = SEC_OMX_Check_SizeVersion(portParam, sizeof(OMX_PORT_PARAM_TYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ portParam->nPorts = pSECComponent->portParam.nPorts;
+ portParam->nStartPortNumber = pSECComponent->portParam.nStartPortNumber;
+ ret = OMX_ErrorNone;
+ }
+ break;
+ case OMX_IndexParamVideoPortFormat:
+ {
+ OMX_VIDEO_PARAM_PORTFORMATTYPE *portFormat = (OMX_VIDEO_PARAM_PORTFORMATTYPE *)ComponentParameterStructure;
+ OMX_U32 portIndex = portFormat->nPortIndex;
+ OMX_U32 index = portFormat->nIndex;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+ OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL;
+ OMX_U32 supportFormatNum = 0; /* supportFormatNum = N-1 */
+
+ ret = SEC_OMX_Check_SizeVersion(portFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if ((portIndex >= pSECComponent->portParam.nPorts)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+
+ if (portIndex == INPUT_PORT_INDEX) {
+ supportFormatNum = INPUT_PORT_SUPPORTFORMAT_NUM_MAX - 1;
+ if (index > supportFormatNum) {
+ ret = OMX_ErrorNoMore;
+ goto EXIT;
+ }
+
+ pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ portDefinition = &pSECPort->portDefinition;
+
+ portFormat->eCompressionFormat = portDefinition->format.video.eCompressionFormat;
+ portFormat->eColorFormat = portDefinition->format.video.eColorFormat;
+ portFormat->xFramerate = portDefinition->format.video.xFramerate;
+ } else if (portIndex == OUTPUT_PORT_INDEX) {
+ supportFormatNum = OUTPUT_PORT_SUPPORTFORMAT_NUM_MAX - 1;
+ if (index > supportFormatNum) {
+ ret = OMX_ErrorNoMore;
+ goto EXIT;
+ }
+
+ pSECPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+ portDefinition = &pSECPort->portDefinition;
+
+ switch (index) {
+ case supportFormat_0:
+ portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
+ portFormat->eColorFormat = OMX_COLOR_FormatYUV420Planar;//OMX_COLOR_FormatYUV420SemiPlanar;
+ portFormat->xFramerate = portDefinition->format.video.xFramerate;
+ break;
+ case supportFormat_1:
+ portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
+ portFormat->eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;//OMX_COLOR_FormatYUV420Planar;
+ portFormat->xFramerate = portDefinition->format.video.xFramerate;
+ break;
+ case supportFormat_2:
+ portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
+ portFormat->eColorFormat = OMX_SEC_COLOR_FormatNV12TPhysicalAddress;
+ portFormat->xFramerate = portDefinition->format.video.xFramerate;
+ break;
+ }
+ }
+ ret = OMX_ErrorNone;
+ }
+ break;
+ case OMX_IndexParamVideoBitrate:
+ {
+ OMX_VIDEO_PARAM_BITRATETYPE *videoRateControl = (OMX_VIDEO_PARAM_BITRATETYPE *)ComponentParameterStructure;
+ OMX_U32 portIndex = videoRateControl->nPortIndex;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+ OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL;
+
+ if ((portIndex != INPUT_PORT_INDEX)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ } else {
+ pSECPort = &pSECComponent->pSECPort[portIndex];
+ portDefinition = &pSECPort->portDefinition;
+
+ videoRateControl->eControlRate = pSECPort->eControlRate;
+ videoRateControl->nTargetBitrate = portDefinition->format.video.nBitrate;
+ }
+ ret = OMX_ErrorNone;
+ }
+ break;
+#ifdef USE_ANDROID_EXTENSION
+ case OMX_IndexParamGetAndroidNativeBuffer:
+ {
+ if (OMX_ErrorNone != checkVersionANB(ComponentParameterStructure))
+ goto EXIT;
+
+ if (OUTPUT_PORT_INDEX != checkPortIndexANB(ComponentParameterStructure)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+ ret = getAndroidNativeBuffer(hComponent, ComponentParameterStructure);
+ }
+ break;
+#endif
+ default:
+ {
+ ret = SEC_OMX_GetParameter(hComponent, nParamIndex, ComponentParameterStructure);
+ }
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+OMX_ERRORTYPE SEC_OMX_VideoDecodeSetParameter(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_INDEXTYPE nIndex,
+ OMX_IN OMX_PTR ComponentParameterStructure)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ if (pSECComponent->currentState == OMX_StateInvalid ) {
+ ret = OMX_StateInvalid;
+ goto EXIT;
+ }
+
+ if (ComponentParameterStructure == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ switch (nIndex) {
+ case OMX_IndexParamVideoPortFormat:
+ {
+ OMX_VIDEO_PARAM_PORTFORMATTYPE *portFormat = (OMX_VIDEO_PARAM_PORTFORMATTYPE *)ComponentParameterStructure;
+ OMX_U32 portIndex = portFormat->nPortIndex;
+ OMX_U32 index = portFormat->nIndex;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+ OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL;
+ OMX_U32 supportFormatNum = 0;
+
+ ret = SEC_OMX_Check_SizeVersion(portFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if ((portIndex >= pSECComponent->portParam.nPorts)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ } else {
+ pSECPort = &pSECComponent->pSECPort[portIndex];
+ portDefinition = &pSECPort->portDefinition;
+
+ portDefinition->format.video.eColorFormat = portFormat->eColorFormat;
+ portDefinition->format.video.eCompressionFormat = portFormat->eCompressionFormat;
+ portDefinition->format.video.xFramerate = portFormat->xFramerate;
+ }
+ }
+ break;
+ case OMX_IndexParamVideoBitrate:
+ {
+ OMX_VIDEO_PARAM_BITRATETYPE *videoRateControl = (OMX_VIDEO_PARAM_BITRATETYPE *)ComponentParameterStructure;
+ OMX_U32 portIndex = videoRateControl->nPortIndex;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+ OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL;
+
+ if ((portIndex != INPUT_PORT_INDEX)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ } else {
+ pSECPort = &pSECComponent->pSECPort[portIndex];
+ portDefinition = &pSECPort->portDefinition;
+
+ pSECPort->eControlRate = videoRateControl->eControlRate;
+ portDefinition->format.video.nBitrate = videoRateControl->nTargetBitrate;
+ }
+ ret = OMX_ErrorNone;
+ }
+ break;
+#ifdef USE_ANDROID_EXTENSION
+ case OMX_IndexParamEnableAndroidBuffers:
+ {
+ if (OMX_ErrorNone != checkVersionANB(ComponentParameterStructure))
+ goto EXIT;
+
+ if (OUTPUT_PORT_INDEX != checkPortIndexANB(ComponentParameterStructure)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ ret = enableAndroidNativeBuffer(hComponent, ComponentParameterStructure);
+ if (ret == OMX_ErrorNone) {
+ SEC_OMX_BASECOMPONENT *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ SEC_OMX_BASEPORT *pSECPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+ if (pSECPort->bUseAndroidNativeBuffer) {
+ pSECPort->portDefinition.nBufferCountActual = ANDROID_MAX_VIDEO_OUTPUTBUFFER_NUM;
+ pSECPort->portDefinition.nBufferCountMin = ANDROID_MAX_VIDEO_OUTPUTBUFFER_NUM;
+ } else {
+ pSECPort->portDefinition.nBufferCountActual = MAX_VIDEO_OUTPUTBUFFER_NUM;
+ pSECPort->portDefinition.nBufferCountMin = MAX_VIDEO_OUTPUTBUFFER_NUM;
+ }
+ }
+ }
+ break;
+ case OMX_IndexParamUseAndroidNativeBuffer:
+ {
+ if (OMX_ErrorNone != checkVersionANB(ComponentParameterStructure))
+ goto EXIT;
+
+ if (OUTPUT_PORT_INDEX != checkPortIndexANB(ComponentParameterStructure)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ ret = useAndroidNativeBuffer(hComponent, ComponentParameterStructure);
+ }
+ break;
+#endif
+ default:
+ {
+ ret = SEC_OMX_SetParameter(hComponent, nIndex, ComponentParameterStructure);
+ }
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_OMX_VideoDecodeComponentInit(OMX_IN OMX_HANDLETYPE hComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_Error, Line:%d", __LINE__);
+ goto EXIT;
+ }
+
+ ret = SEC_OMX_BaseComponent_Constructor(pOMXComponent);
+ if (ret != OMX_ErrorNone) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_Error, Line:%d", __LINE__);
+ goto EXIT;
+ }
+
+ ret = SEC_OMX_Port_Constructor(pOMXComponent);
+ if (ret != OMX_ErrorNone) {
+ SEC_OMX_BaseComponent_Destructor(pOMXComponent);
+ SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_Error, Line:%d", __LINE__);
+ goto EXIT;
+ }
+
+ pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ pSECComponent->bSaveFlagEOS = OMX_FALSE;
+
+ /* Input port */
+ pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ pSECPort->portDefinition.nBufferCountActual = MAX_VIDEO_INPUTBUFFER_NUM;
+ pSECPort->portDefinition.nBufferCountMin = MAX_VIDEO_INPUTBUFFER_NUM;
+ pSECPort->portDefinition.nBufferSize = 0;
+ pSECPort->portDefinition.eDomain = OMX_PortDomainVideo;
+
+ pSECPort->portDefinition.format.video.cMIMEType = SEC_OSAL_Malloc(MAX_OMX_MIMETYPE_SIZE);
+ SEC_OSAL_Strcpy(pSECPort->portDefinition.format.video.cMIMEType, "raw/video");
+ pSECPort->portDefinition.format.video.pNativeRender = 0;
+ pSECPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE;
+ pSECPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
+
+ pSECPort->portDefinition.format.video.nFrameWidth = 0;
+ pSECPort->portDefinition.format.video.nFrameHeight= 0;
+ pSECPort->portDefinition.format.video.nStride = 0;
+ pSECPort->portDefinition.format.video.nSliceHeight = 0;
+ pSECPort->portDefinition.format.video.nBitrate = 64000;
+ pSECPort->portDefinition.format.video.xFramerate = (15 << 16);
+ pSECPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatUnused;
+ pSECPort->portDefinition.format.video.pNativeWindow = NULL;
+
+ /* Output port */
+ pSECPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+ pSECPort->portDefinition.nBufferCountActual = MAX_VIDEO_OUTPUTBUFFER_NUM;
+ pSECPort->portDefinition.nBufferCountMin = MAX_VIDEO_OUTPUTBUFFER_NUM;
+ pSECPort->portDefinition.nBufferSize = DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE;
+ pSECPort->portDefinition.eDomain = OMX_PortDomainVideo;
+
+ pSECPort->portDefinition.format.video.cMIMEType = SEC_OSAL_Malloc(MAX_OMX_MIMETYPE_SIZE);
+ SEC_OSAL_Strcpy(pSECPort->portDefinition.format.video.cMIMEType, "raw/video");
+ pSECPort->portDefinition.format.video.pNativeRender = 0;
+ pSECPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE;
+ pSECPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
+
+ pSECPort->portDefinition.format.video.nFrameWidth = 0;
+ pSECPort->portDefinition.format.video.nFrameHeight= 0;
+ pSECPort->portDefinition.format.video.nStride = 0;
+ pSECPort->portDefinition.format.video.nSliceHeight = 0;
+ pSECPort->portDefinition.format.video.nBitrate = 64000;
+ pSECPort->portDefinition.format.video.xFramerate = (15 << 16);
+ pSECPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatUnused;
+ pSECPort->portDefinition.format.video.pNativeWindow = NULL;
+
+ pOMXComponent->UseBuffer = &SEC_OMX_UseBuffer;
+ pOMXComponent->AllocateBuffer = &SEC_OMX_AllocateBuffer;
+ pOMXComponent->FreeBuffer = &SEC_OMX_FreeBuffer;
+ pOMXComponent->ComponentTunnelRequest = &SEC_OMX_ComponentTunnelRequest;
+
+ pSECComponent->sec_AllocateTunnelBuffer = &SEC_OMX_AllocateTunnelBuffer;
+ pSECComponent->sec_FreeTunnelBuffer = &SEC_OMX_FreeTunnelBuffer;
+ pSECComponent->sec_BufferProcess = &SEC_OMX_BufferProcess;
+ pSECComponent->sec_BufferReset = &SEC_BufferReset;
+ pSECComponent->sec_InputBufferReturn = &SEC_InputBufferReturn;
+ pSECComponent->sec_OutputBufferReturn = &SEC_OutputBufferReturn;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_OMX_VideoDecodeComponentDeinit(OMX_IN OMX_HANDLETYPE hComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+ int i = 0;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ for(i = 0; i < ALL_PORT_NUM; i++) {
+ pSECPort = &pSECComponent->pSECPort[i];
+ SEC_OSAL_Free(pSECPort->portDefinition.format.video.cMIMEType);
+ pSECPort->portDefinition.format.video.cMIMEType = NULL;
+ }
+
+ ret = SEC_OMX_Port_Destructor(pOMXComponent);
+
+ ret = SEC_OMX_BaseComponent_Destructor(hComponent);
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
diff --git a/exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/SEC_OMX_Vdec.h b/exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/SEC_OMX_Vdec.h
new file mode 100644
index 0000000..52130f0
--- /dev/null
+++ b/exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/SEC_OMX_Vdec.h
@@ -0,0 +1,129 @@
+/*
+ *
+ * Copyright 2010 Samsung Electronics S.LSI Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file SEC_OMX_Vdec.h
+ * @brief
+ * @author SeungBeom Kim (sbcrux.kim@samsung.com)
+ * HyeYeon Chung (hyeon.chung@samsung.com)
+ * Yunji Kim (yunji.kim@samsung.com)
+ * @version 1.0
+ * @history
+ * 2010.7.15 : Create
+ */
+
+#ifndef SEC_OMX_VIDEO_DECODE
+#define SEC_OMX_VIDEO_DECODE
+
+#include "OMX_Component.h"
+#include "SEC_OMX_Def.h"
+#include "SEC_OSAL_Queue.h"
+#include "SEC_OMX_Baseport.h"
+
+#define MAX_VIDEO_INPUTBUFFER_NUM 5
+#define MAX_VIDEO_OUTPUTBUFFER_NUM 2
+
+#define DEFAULT_FRAME_WIDTH 176
+#define DEFAULT_FRAME_HEIGHT 144
+
+#define DEFAULT_VIDEO_INPUT_BUFFER_SIZE ((DEFAULT_FRAME_WIDTH * DEFAULT_FRAME_HEIGHT) * 2)
+#define DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE ((DEFAULT_FRAME_WIDTH * DEFAULT_FRAME_HEIGHT * 3) / 2)
+
+#define MFC_INPUT_BUFFER_NUM_MAX 2
+#define DEFAULT_MFC_INPUT_BUFFER_SIZE ((1280 * 720 * 3) / 2)
+
+#define INPUT_PORT_SUPPORTFORMAT_NUM_MAX 1
+#define OUTPUT_PORT_SUPPORTFORMAT_NUM_MAX 3
+
+#ifdef USE_ANDROID_EXTENSION
+#define ANDROID_MAX_VIDEO_OUTPUTBUFFER_NUM 1
+#endif
+
+typedef struct
+{
+ void *pAddrY;
+ void *pAddrC;
+} MFC_DEC_ADDR_INFO;
+
+typedef struct _SEC_MFC_NBDEC_THREAD
+{
+ OMX_HANDLETYPE hNBDecodeThread;
+ OMX_HANDLETYPE hDecFrameStart;
+ OMX_HANDLETYPE hDecFrameEnd;
+ OMX_BOOL bExitDecodeThread;
+ OMX_BOOL bDecoderRun;
+
+ OMX_U32 oneFrameSize;
+} SEC_MFC_NBDEC_THREAD;
+
+typedef struct _MFC_DEC_INPUT_BUFFER
+{
+ void *PhyAddr; // physical address
+ void *VirAddr; // virtual address
+ int bufferSize; // input buffer alloc size
+ int dataSize; // Data length
+} MFC_DEC_INPUT_BUFFER;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+OMX_ERRORTYPE SEC_OMX_UseBuffer(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_INOUT OMX_BUFFERHEADERTYPE **ppBufferHdr,
+ OMX_IN OMX_U32 nPortIndex,
+ OMX_IN OMX_PTR pAppPrivate,
+ OMX_IN OMX_U32 nSizeBytes,
+ OMX_IN OMX_U8 *pBuffer);
+OMX_ERRORTYPE SEC_OMX_AllocateBuffer(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_INOUT OMX_BUFFERHEADERTYPE **ppBuffer,
+ OMX_IN OMX_U32 nPortIndex,
+ OMX_IN OMX_PTR pAppPrivate,
+ OMX_IN OMX_U32 nSizeBytes);
+OMX_ERRORTYPE SEC_OMX_FreeBuffer(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_U32 nPortIndex,
+ OMX_IN OMX_BUFFERHEADERTYPE *pBufferHdr);
+OMX_ERRORTYPE SEC_OMX_AllocateTunnelBuffer(
+ SEC_OMX_BASEPORT *pOMXBasePort,
+ OMX_U32 nPortIndex);
+OMX_ERRORTYPE SEC_OMX_FreeTunnelBuffer(
+ SEC_OMX_BASEPORT *pOMXBasePort,
+ OMX_U32 nPortIndex);
+OMX_ERRORTYPE SEC_OMX_ComponentTunnelRequest(
+ OMX_IN OMX_HANDLETYPE hComp,
+ OMX_IN OMX_U32 nPort,
+ OMX_IN OMX_HANDLETYPE hTunneledComp,
+ OMX_IN OMX_U32 nTunneledPort,
+ OMX_INOUT OMX_TUNNELSETUPTYPE *pTunnelSetup);
+OMX_ERRORTYPE SEC_OMX_BufferProcess(OMX_HANDLETYPE hComponent);
+OMX_ERRORTYPE SEC_OMX_VideoDecodeGetParameter(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_INDEXTYPE nParamIndex,
+ OMX_INOUT OMX_PTR ComponentParameterStructure);
+OMX_ERRORTYPE SEC_OMX_VideoDecodeSetParameter(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_INDEXTYPE nIndex,
+ OMX_IN OMX_PTR ComponentParameterStructure);
+OMX_ERRORTYPE SEC_OMX_VideoDecodeComponentDeinit(OMX_IN OMX_HANDLETYPE hComponent);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/Android.mk b/exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/Android.mk
new file mode 100644
index 0000000..1248e5e
--- /dev/null
+++ b/exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/Android.mk
@@ -0,0 +1,30 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := \
+ SEC_OMX_H264dec.c \
+ library_register.c
+
+
+LOCAL_MODULE := libOMX.SEC.AVC.Decoder
+
+LOCAL_CFLAGS :=
+
+LOCAL_ARM_MODE := arm
+
+LOCAL_STATIC_LIBRARIES := libSEC_OMX_Vdec libsecosal libsecbasecomponent \
+ libsecmfcdecapi libseccsc
+LOCAL_SHARED_LIBRARIES := libc libdl libcutils libutils libui libhardware
+
+LOCAL_C_INCLUDES := $(SEC_OMX_INC)/khronos \
+ $(SEC_OMX_INC)/sec \
+ $(SEC_OMX_TOP)/sec_osal \
+ $(SEC_OMX_TOP)/sec_omx_core \
+ $(SEC_OMX_COMPONENT)/common \
+ $(SEC_OMX_COMPONENT)/video/dec
+
+LOCAL_C_INCLUDES += $(SEC_OMX_TOP)/sec_codecs/video/mfc_c110/include
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/SEC_OMX_H264dec.c b/exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/SEC_OMX_H264dec.c
new file mode 100644
index 0000000..64ac7eb
--- /dev/null
+++ b/exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/SEC_OMX_H264dec.c
@@ -0,0 +1,1479 @@
+/*
+ *
+ * Copyright 2010 Samsung Electronics S.LSI Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file SEC_OMX_H264dec.c
+ * @brief
+ * @author SeungBeom Kim (sbcrux.kim@samsung.com)
+ * @version 1.0
+ * @history
+ * 2010.7.15 : Create
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "SEC_OMX_Macros.h"
+#include "SEC_OMX_Basecomponent.h"
+#include "SEC_OMX_Baseport.h"
+#include "SEC_OMX_Vdec.h"
+#include "library_register.h"
+#include "SEC_OMX_H264dec.h"
+#include "SsbSipMfcApi.h"
+#include "color_space_convertor.h"
+
+#undef SEC_LOG_TAG
+#define SEC_LOG_TAG "SEC_H264_DEC"
+#define SEC_LOG_OFF
+#include "SEC_OSAL_Log.h"
+
+//#define ADD_SPS_PPS_I_FRAME
+//#define FULL_FRAME_SEARCH
+
+/* H.264 Decoder Supported Levels & profiles */
+SEC_OMX_VIDEO_PROFILELEVEL supportedAVCProfileLevels[] ={
+ {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel1},
+ {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel1b},
+ {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel11},
+ {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel12},
+ {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel13},
+ {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel2},
+ {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel21},
+ {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel22},
+ {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel3},
+ {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel31},
+
+ {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel1},
+ {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel1b},
+ {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel11},
+ {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel12},
+ {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel13},
+ {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel2},
+ {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel21},
+ {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel22},
+ {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel3},
+ {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel31},
+
+ {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel1},
+ {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel1b},
+ {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel11},
+ {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel12},
+ {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel13},
+ {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel2},
+ {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel21},
+ {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel22},
+ {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel3},
+ {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel31}};
+
+
+static int Check_H264_Frame(OMX_U8 *pInputStream, int buffSize, OMX_U32 flag, OMX_BOOL bPreviousFrameEOF, OMX_BOOL *pbEndOfFrame)
+{
+ OMX_U32 preFourByte = (OMX_U32)-1;
+ int accessUnitSize = 0;
+ int frameTypeBoundary = 0;
+ int nextNaluSize = 0;
+ int naluStart = 0;
+
+ if (bPreviousFrameEOF == OMX_TRUE)
+ naluStart = 0;
+ else
+ naluStart = 1;
+
+ while (1) {
+ int inputOneByte = 0;
+
+ if (accessUnitSize == buffSize)
+ goto EXIT;
+
+ inputOneByte = *(pInputStream++);
+ accessUnitSize += 1;
+
+ if (preFourByte == 0x00000001 || (preFourByte << 8) == 0x00000100) {
+ int naluType = inputOneByte & 0x1F;
+
+ SEC_OSAL_Log(SEC_LOG_TRACE, "NaluType : %d", naluType);
+ if (naluStart == 0) {
+#ifdef ADD_SPS_PPS_I_FRAME
+ if (naluType == 1 || naluType == 5)
+#else
+ if (naluType == 1 || naluType == 5 || naluType == 7 || naluType == 8)
+#endif
+ naluStart = 1;
+ } else {
+#ifdef OLD_DETECT
+ frameTypeBoundary = (8 - naluType) & (naluType - 10); //AUD(9)
+#else
+ if (naluType == 9)
+ frameTypeBoundary = -2;
+#endif
+ if (naluType == 1 || naluType == 5) {
+ if (accessUnitSize == buffSize) {
+ accessUnitSize--;
+ goto EXIT;
+ }
+ inputOneByte = *pInputStream++;
+ accessUnitSize += 1;
+
+ if (inputOneByte >= 0x80)
+ frameTypeBoundary = -1;
+ }
+ if (frameTypeBoundary < 0) {
+ break;
+ }
+ }
+
+ }
+ preFourByte = (preFourByte << 8) + inputOneByte;
+ }
+
+ *pbEndOfFrame = OMX_TRUE;
+ nextNaluSize = -5;
+ if (frameTypeBoundary == -1)
+ nextNaluSize = -6;
+ if (preFourByte != 0x00000001)
+ nextNaluSize++;
+ return (accessUnitSize + nextNaluSize);
+
+EXIT:
+ *pbEndOfFrame = OMX_FALSE;
+
+ return accessUnitSize;
+}
+
+OMX_BOOL Check_H264_StartCode(OMX_U8 *pInputStream, OMX_U32 streamSize)
+{
+ if (streamSize < 4) {
+ return OMX_FALSE;
+ } else if ((pInputStream[0] == 0x00) &&
+ (pInputStream[1] == 0x00) &&
+ (pInputStream[2] == 0x00) &&
+ (pInputStream[3] != 0x00) &&
+ ((pInputStream[3] >> 3) == 0x00)) {
+ return OMX_TRUE;
+ } else if ((pInputStream[0] == 0x00) &&
+ (pInputStream[1] == 0x00) &&
+ (pInputStream[2] != 0x00) &&
+ ((pInputStream[2] >> 3) == 0x00)) {
+ return OMX_TRUE;
+ } else {
+ return OMX_FALSE;
+ }
+}
+
+OMX_ERRORTYPE SEC_MFC_H264Dec_GetParameter(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_INDEXTYPE nParamIndex,
+ OMX_INOUT OMX_PTR pComponentParameterStructure)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL || pComponentParameterStructure == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ if (pSECComponent->currentState == OMX_StateInvalid ) {
+ ret = OMX_StateInvalid;
+ goto EXIT;
+ }
+
+ switch (nParamIndex) {
+ case OMX_IndexParamVideoAvc:
+ {
+ OMX_VIDEO_PARAM_AVCTYPE *pDstAVCComponent = (OMX_VIDEO_PARAM_AVCTYPE *)pComponentParameterStructure;
+ OMX_VIDEO_PARAM_AVCTYPE *pSrcAVCComponent = NULL;
+ SEC_H264DEC_HANDLE *pH264Dec = NULL;
+
+ ret = SEC_OMX_Check_SizeVersion(pDstAVCComponent, sizeof(OMX_VIDEO_PARAM_AVCTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pDstAVCComponent->nPortIndex >= ALL_PORT_NUM) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle;
+ pSrcAVCComponent = &pH264Dec->AVCComponent[pDstAVCComponent->nPortIndex];
+
+ SEC_OSAL_Memcpy(pDstAVCComponent, pSrcAVCComponent, sizeof(OMX_VIDEO_PARAM_AVCTYPE));
+ }
+ break;
+ case OMX_IndexParamStandardComponentRole:
+ {
+ OMX_PARAM_COMPONENTROLETYPE *pComponentRole = (OMX_PARAM_COMPONENTROLETYPE *)pComponentParameterStructure;
+ ret = SEC_OMX_Check_SizeVersion(pComponentRole, sizeof(OMX_PARAM_COMPONENTROLETYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ SEC_OSAL_Strcpy((char *)pComponentRole->cRole, SEC_OMX_COMPONENT_H264_DEC_ROLE);
+ }
+ break;
+ case OMX_IndexParamVideoProfileLevelQuerySupported:
+ {
+ OMX_VIDEO_PARAM_PROFILELEVELTYPE *pDstProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE*)pComponentParameterStructure;
+ SEC_OMX_VIDEO_PROFILELEVEL *pProfileLevel = NULL;
+ OMX_U32 maxProfileLevelNum = 0;
+
+ ret = SEC_OMX_Check_SizeVersion(pDstProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pDstProfileLevel->nPortIndex >= ALL_PORT_NUM) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ pProfileLevel = supportedAVCProfileLevels;
+ maxProfileLevelNum = sizeof(supportedAVCProfileLevels) / sizeof(SEC_OMX_VIDEO_PROFILELEVEL);
+
+ if (pDstProfileLevel->nProfileIndex >= maxProfileLevelNum) {
+ ret = OMX_ErrorNoMore;
+ goto EXIT;
+ }
+
+ pProfileLevel += pDstProfileLevel->nProfileIndex;
+ pDstProfileLevel->eProfile = pProfileLevel->profile;
+ pDstProfileLevel->eLevel = pProfileLevel->level;
+ }
+ break;
+ case OMX_IndexParamVideoProfileLevelCurrent:
+ {
+ OMX_VIDEO_PARAM_PROFILELEVELTYPE *pDstProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE*)pComponentParameterStructure;
+ OMX_VIDEO_PARAM_AVCTYPE *pSrcAVCComponent = NULL;
+ SEC_H264DEC_HANDLE *pH264Dec = NULL;
+
+ ret = SEC_OMX_Check_SizeVersion(pDstProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pDstProfileLevel->nPortIndex >= ALL_PORT_NUM) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle;
+ pSrcAVCComponent = &pH264Dec->AVCComponent[pDstProfileLevel->nPortIndex];
+
+ pDstProfileLevel->eProfile = pSrcAVCComponent->eProfile;
+ pDstProfileLevel->eLevel = pSrcAVCComponent->eLevel;
+ }
+ break;
+ case OMX_IndexParamVideoErrorCorrection:
+ {
+ OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pDstErrorCorrectionType = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *)pComponentParameterStructure;
+ OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pSrcErrorCorrectionType = NULL;
+ SEC_H264DEC_HANDLE *pH264Dec = NULL;
+
+ ret = SEC_OMX_Check_SizeVersion(pDstErrorCorrectionType, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pDstErrorCorrectionType->nPortIndex != INPUT_PORT_INDEX) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle;
+ pSrcErrorCorrectionType = &pH264Dec->errorCorrectionType[INPUT_PORT_INDEX];
+
+ pDstErrorCorrectionType->bEnableHEC = pSrcErrorCorrectionType->bEnableHEC;
+ pDstErrorCorrectionType->bEnableResync = pSrcErrorCorrectionType->bEnableResync;
+ pDstErrorCorrectionType->nResynchMarkerSpacing = pSrcErrorCorrectionType->nResynchMarkerSpacing;
+ pDstErrorCorrectionType->bEnableDataPartitioning = pSrcErrorCorrectionType->bEnableDataPartitioning;
+ pDstErrorCorrectionType->bEnableRVLC = pSrcErrorCorrectionType->bEnableRVLC;
+ }
+ break;
+ default:
+ ret = SEC_OMX_VideoDecodeGetParameter(hComponent, nParamIndex, pComponentParameterStructure);
+ break;
+ }
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_H264Dec_SetParameter(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_INDEXTYPE nIndex,
+ OMX_IN OMX_PTR pComponentParameterStructure)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL || pComponentParameterStructure == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ if (pSECComponent->currentState == OMX_StateInvalid ) {
+ ret = OMX_StateInvalid;
+ goto EXIT;
+ }
+
+ switch (nIndex) {
+ case OMX_IndexParamVideoAvc:
+ {
+ OMX_VIDEO_PARAM_AVCTYPE *pDstAVCComponent = NULL;
+ OMX_VIDEO_PARAM_AVCTYPE *pSrcAVCComponent = (OMX_VIDEO_PARAM_AVCTYPE *)pComponentParameterStructure;
+ SEC_H264DEC_HANDLE *pH264Dec = NULL;
+
+ ret = SEC_OMX_Check_SizeVersion(pSrcAVCComponent, sizeof(OMX_VIDEO_PARAM_AVCTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pSrcAVCComponent->nPortIndex >= ALL_PORT_NUM) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle;
+ pDstAVCComponent = &pH264Dec->AVCComponent[pSrcAVCComponent->nPortIndex];
+
+ SEC_OSAL_Memcpy(pDstAVCComponent, pSrcAVCComponent, sizeof(OMX_VIDEO_PARAM_AVCTYPE));
+ }
+ break;
+ case OMX_IndexParamStandardComponentRole:
+ {
+ OMX_PARAM_COMPONENTROLETYPE *pComponentRole = (OMX_PARAM_COMPONENTROLETYPE*)pComponentParameterStructure;
+
+ ret = SEC_OMX_Check_SizeVersion(pComponentRole, sizeof(OMX_PARAM_COMPONENTROLETYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if ((pSECComponent->currentState != OMX_StateLoaded) && (pSECComponent->currentState != OMX_StateWaitForResources)) {
+ ret = OMX_ErrorIncorrectStateOperation;
+ goto EXIT;
+ }
+
+ if (!SEC_OSAL_Strcmp((char*)pComponentRole->cRole, SEC_OMX_COMPONENT_H264_DEC_ROLE)) {
+ pSECComponent->pSECPort[INPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingAVC;
+ } else {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ }
+ break;
+ case OMX_IndexParamPortDefinition:
+ {
+ OMX_PARAM_PORTDEFINITIONTYPE *pPortDefinition = (OMX_PARAM_PORTDEFINITIONTYPE *)pComponentParameterStructure;
+ OMX_U32 portIndex = pPortDefinition->nPortIndex;
+ SEC_OMX_BASEPORT *pSECPort;
+ OMX_U32 width, height, size;
+
+ if (portIndex >= pSECComponent->portParam.nPorts) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+ ret = SEC_OMX_Check_SizeVersion(pPortDefinition, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ pSECPort = &pSECComponent->pSECPort[portIndex];
+
+ if ((pSECComponent->currentState != OMX_StateLoaded) && (pSECComponent->currentState != OMX_StateWaitForResources)) {
+ if (pSECPort->portDefinition.bEnabled == OMX_TRUE) {
+ ret = OMX_ErrorIncorrectStateOperation;
+ goto EXIT;
+ }
+ }
+ if(pPortDefinition->nBufferCountActual < pSECPort->portDefinition.nBufferCountMin) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ SEC_OSAL_Memcpy(&pSECPort->portDefinition, pPortDefinition, pPortDefinition->nSize);
+
+ width = ((pSECPort->portDefinition.format.video.nFrameWidth + 15) & (~15));
+ height = ((pSECPort->portDefinition.format.video.nFrameHeight + 15) & (~15));
+ size = (width * height * 3) / 2;
+ pSECPort->portDefinition.format.video.nStride = width;
+ pSECPort->portDefinition.format.video.nSliceHeight = height;
+ pSECPort->portDefinition.nBufferSize = (size > pSECPort->portDefinition.nBufferSize) ? size : pSECPort->portDefinition.nBufferSize;
+
+ if (portIndex == INPUT_PORT_INDEX) {
+ SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+ pSECOutputPort->portDefinition.format.video.nFrameWidth = pSECPort->portDefinition.format.video.nFrameWidth;
+ pSECOutputPort->portDefinition.format.video.nFrameHeight = pSECPort->portDefinition.format.video.nFrameHeight;
+ pSECOutputPort->portDefinition.format.video.nStride = width;
+ pSECOutputPort->portDefinition.format.video.nSliceHeight = height;
+
+ switch (pSECOutputPort->portDefinition.format.video.eColorFormat) {
+ case OMX_COLOR_FormatYUV420Planar:
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ case OMX_SEC_COLOR_FormatNV12TPhysicalAddress:
+ case OMX_SEC_COLOR_FormatANBYUV420SemiPlanar:
+ pSECOutputPort->portDefinition.nBufferSize = (width * height * 3) / 2;
+ break;
+ default:
+ SEC_OSAL_Log(SEC_LOG_ERROR, "Color format is not support!! use default YUV size!!");
+ ret = OMX_ErrorUnsupportedSetting;
+ break;
+ }
+ }
+ }
+ break;
+ case OMX_IndexParamVideoProfileLevelCurrent:
+ {
+ OMX_VIDEO_PARAM_PROFILELEVELTYPE *pSrcProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pComponentParameterStructure;
+ OMX_VIDEO_PARAM_AVCTYPE *pDstAVCComponent = NULL;
+ SEC_H264DEC_HANDLE *pH264Dec = NULL;
+
+ ret = SEC_OMX_Check_SizeVersion(pSrcProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE));
+ if (ret != OMX_ErrorNone)
+ goto EXIT;
+
+ if (pSrcProfileLevel->nPortIndex >= ALL_PORT_NUM) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle;
+
+ pDstAVCComponent = &pH264Dec->AVCComponent[pSrcProfileLevel->nPortIndex];
+ pDstAVCComponent->eProfile = pSrcProfileLevel->eProfile;
+ pDstAVCComponent->eLevel = pSrcProfileLevel->eLevel;
+ }
+ break;
+ case OMX_IndexParamVideoErrorCorrection:
+ {
+ OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pSrcErrorCorrectionType = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *)pComponentParameterStructure;
+ OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pDstErrorCorrectionType = NULL;
+ SEC_H264DEC_HANDLE *pH264Dec = NULL;
+
+ ret = SEC_OMX_Check_SizeVersion(pSrcErrorCorrectionType, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pSrcErrorCorrectionType->nPortIndex != INPUT_PORT_INDEX) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle;
+ pDstErrorCorrectionType = &pH264Dec->errorCorrectionType[INPUT_PORT_INDEX];
+
+ pDstErrorCorrectionType->bEnableHEC = pSrcErrorCorrectionType->bEnableHEC;
+ pDstErrorCorrectionType->bEnableResync = pSrcErrorCorrectionType->bEnableResync;
+ pDstErrorCorrectionType->nResynchMarkerSpacing = pSrcErrorCorrectionType->nResynchMarkerSpacing;
+ pDstErrorCorrectionType->bEnableDataPartitioning = pSrcErrorCorrectionType->bEnableDataPartitioning;
+ pDstErrorCorrectionType->bEnableRVLC = pSrcErrorCorrectionType->bEnableRVLC;
+ }
+ break;
+ default:
+ ret = SEC_OMX_VideoDecodeSetParameter(hComponent, nIndex, pComponentParameterStructure);
+ break;
+ }
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_H264Dec_GetConfig(
+ OMX_HANDLETYPE hComponent,
+ OMX_INDEXTYPE nIndex,
+ OMX_PTR pComponentConfigStructure)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ if (pComponentConfigStructure == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ if (pSECComponent->currentState == OMX_StateInvalid) {
+ ret = OMX_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ switch (nIndex) {
+ case OMX_IndexConfigCommonOutputCrop:
+ {
+ SEC_H264DEC_HANDLE *pH264Dec = NULL;
+ OMX_CONFIG_RECTTYPE *pSrcRectType = NULL;
+ OMX_CONFIG_RECTTYPE *pDstRectType = NULL;
+ pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle;
+
+ if (pH264Dec->hMFCH264Handle.bConfiguredMFC == OMX_FALSE) {
+ ret = OMX_ErrorNotReady;
+ break;
+ }
+
+ pDstRectType = (OMX_CONFIG_RECTTYPE *)pComponentConfigStructure;
+
+ if ((pDstRectType->nPortIndex != INPUT_PORT_INDEX) &&
+ (pDstRectType->nPortIndex != OUTPUT_PORT_INDEX)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ SEC_OMX_BASEPORT *pSECPort = &pSECComponent->pSECPort[pDstRectType->nPortIndex];
+
+ pSrcRectType = &(pSECPort->cropRectangle);
+
+ pDstRectType->nTop = pSrcRectType->nTop;
+ pDstRectType->nLeft = pSrcRectType->nLeft;
+ pDstRectType->nHeight = pSrcRectType->nHeight;
+ pDstRectType->nWidth = pSrcRectType->nWidth;
+ }
+ break;
+ default:
+ ret = SEC_OMX_GetConfig(hComponent, nIndex, pComponentConfigStructure);
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_H264Dec_SetConfig(
+ OMX_HANDLETYPE hComponent,
+ OMX_INDEXTYPE nIndex,
+ OMX_PTR pComponentConfigStructure)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ if (pComponentConfigStructure == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ if (pSECComponent->currentState == OMX_StateInvalid) {
+ ret = OMX_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ switch (nIndex) {
+ case OMX_IndexVendorThumbnailMode:
+ {
+ SEC_H264DEC_HANDLE *pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle;
+
+ pH264Dec->hMFCH264Handle.bThumbnailMode = *((OMX_BOOL *)pComponentConfigStructure);
+
+ ret = OMX_ErrorNone;
+ }
+ break;
+ default:
+ ret = SEC_OMX_SetConfig(hComponent, nIndex, pComponentConfigStructure);
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_H264Dec_GetExtensionIndex(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_STRING cParameterName,
+ OMX_OUT OMX_INDEXTYPE *pIndexType)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ if ((cParameterName == NULL) || (pIndexType == NULL)) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ if (pSECComponent->currentState == OMX_StateInvalid) {
+ ret = OMX_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ if (SEC_OSAL_Strcmp(cParameterName, SEC_INDEX_PARAM_ENABLE_THUMBNAIL) == 0) {
+ SEC_H264DEC_HANDLE *pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle;
+ *pIndexType = OMX_IndexVendorThumbnailMode;
+ ret = OMX_ErrorNone;
+#ifdef USE_ANDROID_EXTENSION
+ } else if (SEC_OSAL_Strcmp(cParameterName, SEC_INDEX_PARAM_ENABLE_ANB) == 0) {
+ if (isTvOutEnabled()) {
+ // Samsung normally pushes HW-decoded frames to the TV Out driver
+ // but it's hard for us to do that without source, so return an error
+ // and let Android fallback to software decoding
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+
+ *pIndexType = OMX_IndexParamEnableAndroidBuffers;
+ ret = OMX_ErrorNone;
+ } else if (SEC_OSAL_Strcmp(cParameterName, SEC_INDEX_PARAM_GET_ANB) == 0) {
+ *pIndexType = OMX_IndexParamGetAndroidNativeBuffer;
+ ret = OMX_ErrorNone;
+ } else if (SEC_OSAL_Strcmp(cParameterName, SEC_INDEX_PARAM_USE_ANB) == 0) {
+ *pIndexType = OMX_IndexParamUseAndroidNativeBuffer;
+ ret = OMX_ErrorNone;
+#endif
+ } else {
+ ret = SEC_OMX_GetExtensionIndex(hComponent, cParameterName, pIndexType);
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_H264Dec_ComponentRoleEnum(OMX_HANDLETYPE hComponent, OMX_U8 *cRole, OMX_U32 nIndex)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+
+ FunctionIn();
+
+ if ((hComponent == NULL) || (cRole == NULL)) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ if (nIndex == (MAX_COMPONENT_ROLE_NUM-1)) {
+ SEC_OSAL_Strcpy((char *)cRole, SEC_OMX_COMPONENT_H264_DEC_ROLE);
+ ret = OMX_ErrorNone;
+ } else {
+ ret = OMX_ErrorNoMore;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_DecodeThread(OMX_HANDLETYPE hComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+ SEC_H264DEC_HANDLE *pH264Dec = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle;
+
+ while (pH264Dec->NBDecThread.bExitDecodeThread == OMX_FALSE) {
+ SEC_OSAL_SemaphoreWait(pH264Dec->NBDecThread.hDecFrameStart);
+
+ if (pH264Dec->NBDecThread.bExitDecodeThread == OMX_FALSE) {
+ pH264Dec->hMFCH264Handle.returnCodec = SsbSipMfcDecExe(pH264Dec->hMFCH264Handle.hMFCHandle, pH264Dec->NBDecThread.oneFrameSize);
+ SEC_OSAL_SemaphorePost(pH264Dec->NBDecThread.hDecFrameEnd);
+ }
+ }
+
+EXIT:
+ SEC_OSAL_ThreadExit(NULL);
+ FunctionOut();
+
+ return ret;
+}
+
+/* MFC Init */
+OMX_ERRORTYPE SEC_MFC_H264Dec_Init(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ SEC_H264DEC_HANDLE *pH264Dec = NULL;
+
+ OMX_PTR hMFCHandle = NULL;
+ OMX_PTR pStreamBuffer = NULL;
+ OMX_PTR pStreamPhyBuffer = NULL;
+
+ pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle;
+ pH264Dec->hMFCH264Handle.bConfiguredMFC = OMX_FALSE;
+ pSECComponent->bUseFlagEOF = OMX_FALSE;
+ pSECComponent->bSaveFlagEOS = OMX_FALSE;
+
+ /* MFC(Multi Function Codec) decoder and CMM(Codec Memory Management) driver open */
+ SSBIP_MFC_BUFFER_TYPE buf_type = CACHE;
+ hMFCHandle = (OMX_PTR)SsbSipMfcDecOpen(&buf_type);
+ if (hMFCHandle == NULL) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ pH264Dec->hMFCH264Handle.hMFCHandle = hMFCHandle;
+
+ /* Allocate decoder's input buffer */
+ pStreamBuffer = SsbSipMfcDecGetInBuf(hMFCHandle, &pStreamPhyBuffer, DEFAULT_MFC_INPUT_BUFFER_SIZE * MFC_INPUT_BUFFER_NUM_MAX);
+ if (pStreamBuffer == NULL) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+
+ pH264Dec->MFCDecInputBuffer[0].VirAddr = pStreamBuffer;
+ pH264Dec->MFCDecInputBuffer[0].PhyAddr = pStreamPhyBuffer;
+ pH264Dec->MFCDecInputBuffer[0].bufferSize = DEFAULT_MFC_INPUT_BUFFER_SIZE;
+ pH264Dec->MFCDecInputBuffer[0].dataSize = 0;
+ pH264Dec->MFCDecInputBuffer[1].VirAddr = (unsigned char *)pStreamBuffer + pH264Dec->MFCDecInputBuffer[0].bufferSize;
+ pH264Dec->MFCDecInputBuffer[1].PhyAddr = (unsigned char *)pStreamPhyBuffer + pH264Dec->MFCDecInputBuffer[0].bufferSize;
+ pH264Dec->MFCDecInputBuffer[1].bufferSize = DEFAULT_MFC_INPUT_BUFFER_SIZE;
+ pH264Dec->MFCDecInputBuffer[1].dataSize = 0;
+ pH264Dec->indexInputBuffer = 0;
+
+ pH264Dec->bFirstFrame = OMX_TRUE;
+
+ pH264Dec->NBDecThread.bExitDecodeThread = OMX_FALSE;
+ pH264Dec->NBDecThread.bDecoderRun = OMX_FALSE;
+ pH264Dec->NBDecThread.oneFrameSize = 0;
+ SEC_OSAL_SemaphoreCreate(&(pH264Dec->NBDecThread.hDecFrameStart));
+ SEC_OSAL_SemaphoreCreate(&(pH264Dec->NBDecThread.hDecFrameEnd));
+ if (OMX_ErrorNone == SEC_OSAL_ThreadCreate(&pH264Dec->NBDecThread.hNBDecodeThread,
+ SEC_MFC_DecodeThread,
+ pOMXComponent)) {
+ pH264Dec->hMFCH264Handle.returnCodec = MFC_RET_OK;
+ }
+
+ pH264Dec->hMFCH264Handle.pMFCStreamBuffer = pH264Dec->MFCDecInputBuffer[0].VirAddr;
+ pH264Dec->hMFCH264Handle.pMFCStreamPhyBuffer = pH264Dec->MFCDecInputBuffer[0].PhyAddr;
+ pSECComponent->processData[INPUT_PORT_INDEX].dataBuffer = pH264Dec->MFCDecInputBuffer[0].VirAddr;
+ pSECComponent->processData[INPUT_PORT_INDEX].allocSize = pH264Dec->MFCDecInputBuffer[0].bufferSize;
+
+ SEC_OSAL_Memset(pSECComponent->timeStamp, -19771003, sizeof(OMX_TICKS) * MAX_TIMESTAMP);
+ SEC_OSAL_Memset(pSECComponent->nFlags, 0, sizeof(OMX_U32) * MAX_FLAGS);
+ pH264Dec->hMFCH264Handle.indexTimestamp = 0;
+ pSECComponent->getAllDelayBuffer = OMX_FALSE;
+
+EXIT:
+ return ret;
+}
+
+/* MFC Terminate */
+OMX_ERRORTYPE SEC_MFC_H264Dec_Terminate(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ SEC_H264DEC_HANDLE *pH264Dec = NULL;
+ OMX_PTR hMFCHandle = NULL;
+
+ FunctionIn();
+
+ pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle;
+ hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle;
+
+ pH264Dec->hMFCH264Handle.pMFCStreamBuffer = NULL;
+ pH264Dec->hMFCH264Handle.pMFCStreamPhyBuffer = NULL;
+ pSECComponent->processData[INPUT_PORT_INDEX].dataBuffer = NULL;
+ pSECComponent->processData[INPUT_PORT_INDEX].allocSize = 0;
+
+ if (pH264Dec->NBDecThread.hNBDecodeThread != NULL) {
+ pH264Dec->NBDecThread.bExitDecodeThread = OMX_TRUE;
+ SEC_OSAL_SemaphorePost(pH264Dec->NBDecThread.hDecFrameStart);
+ SEC_OSAL_ThreadTerminate(pH264Dec->NBDecThread.hNBDecodeThread);
+ pH264Dec->NBDecThread.hNBDecodeThread = NULL;
+ }
+
+ if(pH264Dec->NBDecThread.hDecFrameEnd != NULL) {
+ SEC_OSAL_SemaphoreTerminate(pH264Dec->NBDecThread.hDecFrameEnd);
+ pH264Dec->NBDecThread.hDecFrameEnd = NULL;
+ }
+
+ if(pH264Dec->NBDecThread.hDecFrameStart != NULL) {
+ SEC_OSAL_SemaphoreTerminate(pH264Dec->NBDecThread.hDecFrameStart);
+ pH264Dec->NBDecThread.hDecFrameStart = NULL;
+ }
+
+ if (hMFCHandle != NULL) {
+ SsbSipMfcDecClose(hMFCHandle);
+ hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle = NULL;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_H264_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA *pInputData, SEC_OMX_DATA *pOutputData)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ SEC_H264DEC_HANDLE *pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle;
+ OMX_U32 oneFrameSize = pInputData->dataLen;
+ SSBSIP_MFC_DEC_OUTPUT_INFO outputInfo;
+ OMX_S32 setConfVal = 0;
+ int bufWidth = 0;
+ int bufHeight = 0;
+ OMX_BOOL outputDataValid = OMX_FALSE;
+
+ FunctionIn();
+
+ if (pH264Dec->hMFCH264Handle.bConfiguredMFC == OMX_FALSE) {
+ SSBSIP_MFC_CODEC_TYPE eCodecType = H264_DEC;
+
+ if ((oneFrameSize <= 0) && (pInputData->nFlags & OMX_BUFFERFLAG_EOS)) {
+ pOutputData->timeStamp = pInputData->timeStamp;
+ pOutputData->nFlags = pInputData->nFlags;
+ ret = OMX_ErrorNone;
+ goto EXIT;
+ }
+
+ setConfVal = 0;
+ SsbSipMfcDecSetConfig(pH264Dec->hMFCH264Handle.hMFCHandle, MFC_DEC_SETCONF_EXTRA_BUFFER_NUM, &setConfVal);
+
+ /* Default number in the driver is optimized */
+ if (pH264Dec->hMFCH264Handle.bThumbnailMode == OMX_TRUE) {
+ setConfVal = 1;
+ SsbSipMfcDecSetConfig(pH264Dec->hMFCH264Handle.hMFCHandle, MFC_DEC_SETCONF_DISPLAY_DELAY, &setConfVal);
+ } else {
+ setConfVal = 8;
+ SsbSipMfcDecSetConfig(pH264Dec->hMFCH264Handle.hMFCHandle, MFC_DEC_SETCONF_DISPLAY_DELAY, &setConfVal);
+ }
+
+ pH264Dec->hMFCH264Handle.returnCodec = SsbSipMfcDecInit(pH264Dec->hMFCH264Handle.hMFCHandle, eCodecType, oneFrameSize);
+ if (pH264Dec->hMFCH264Handle.returnCodec == MFC_RET_OK) {
+ SSBSIP_MFC_IMG_RESOLUTION imgResol;
+ SSBSIP_MFC_CROP_INFORMATION cropInfo;
+ SEC_OMX_BASEPORT *secInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ SEC_OMX_BASEPORT *secOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+
+ SsbSipMfcDecGetConfig(pH264Dec->hMFCH264Handle.hMFCHandle, MFC_DEC_GETCONF_BUF_WIDTH_HEIGHT, &imgResol);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "set width height information : %d, %d",
+ secInputPort->portDefinition.format.video.nFrameWidth,
+ secInputPort->portDefinition.format.video.nFrameHeight);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "mfc width height information : %d, %d",
+ imgResol.width, imgResol.height);
+
+ SsbSipMfcDecGetConfig(pH264Dec->hMFCH264Handle.hMFCHandle, MFC_DEC_GETCONF_CROP_INFO, &cropInfo);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "mfc crop_top crop_bottom crop_left crop_right : %d, %d, %d, %d",
+ cropInfo.crop_top_offset , cropInfo.crop_bottom_offset ,
+ cropInfo.crop_left_offset , cropInfo.crop_right_offset);
+
+ secOutputPort->cropRectangle.nTop = cropInfo.crop_top_offset;
+ secOutputPort->cropRectangle.nLeft = cropInfo.crop_left_offset;
+ secOutputPort->cropRectangle.nWidth = imgResol.width - cropInfo.crop_left_offset - cropInfo.crop_right_offset;
+ secOutputPort->cropRectangle.nHeight = imgResol.height - cropInfo.crop_top_offset - cropInfo.crop_bottom_offset;
+
+ pH264Dec->hMFCH264Handle.bConfiguredMFC = OMX_TRUE;
+
+ /** Update Frame Size **/
+ if ((cropInfo.crop_left_offset != 0) || (cropInfo.crop_right_offset != 0) ||
+ (cropInfo.crop_top_offset != 0) || (cropInfo.crop_bottom_offset != 0)) {
+ /* change width and height information */
+ secInputPort->portDefinition.format.video.nFrameWidth = imgResol.width;
+ secInputPort->portDefinition.format.video.nFrameHeight = imgResol.height;
+ secInputPort->portDefinition.format.video.nStride = ((imgResol.width + 15) & (~15));
+ secInputPort->portDefinition.format.video.nSliceHeight = ((imgResol.height + 15) & (~15));
+
+ SEC_UpdateFrameSize(pOMXComponent);
+
+ /** Send crop info call back */
+ (*(pSECComponent->pCallbacks->EventHandler))
+ (pOMXComponent,
+ pSECComponent->callbackData,
+ OMX_EventPortSettingsChanged, /* The command was completed */
+ OMX_DirOutput, /* This is the port index */
+ OMX_IndexConfigCommonOutputCrop,
+ NULL);
+ } else if((secInputPort->portDefinition.format.video.nFrameWidth != imgResol.width) ||
+ (secInputPort->portDefinition.format.video.nFrameHeight != imgResol.height)) {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "change width height information : OMX_EventPortSettingsChanged");
+ /* change width and height information */
+ secInputPort->portDefinition.format.video.nFrameWidth = imgResol.width;
+ secInputPort->portDefinition.format.video.nFrameHeight = imgResol.height;
+ secInputPort->portDefinition.format.video.nStride = ((imgResol.width + 15) & (~15));
+ secInputPort->portDefinition.format.video.nSliceHeight = ((imgResol.height + 15) & (~15));
+
+ SEC_UpdateFrameSize(pOMXComponent);
+
+ /** Send Port Settings changed call back */
+ (*(pSECComponent->pCallbacks->EventHandler))
+ (pOMXComponent,
+ pSECComponent->callbackData,
+ OMX_EventPortSettingsChanged, /* The command was completed */
+ OMX_DirOutput, /* This is the port index */
+ 0,
+ NULL);
+ }
+
+#ifdef ADD_SPS_PPS_I_FRAME
+ ret = OMX_ErrorInputDataDecodeYet;
+#else
+ pOutputData->timeStamp = pInputData->timeStamp;
+ pOutputData->nFlags = pInputData->nFlags;
+
+ ret = OMX_ErrorNone;
+#endif
+ goto EXIT;
+ } else {
+ ret = OMX_ErrorMFCInit;
+ goto EXIT;
+ }
+ }
+
+#ifndef FULL_FRAME_SEARCH
+ if ((pInputData->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) &&
+ (pSECComponent->bUseFlagEOF == OMX_FALSE))
+ pSECComponent->bUseFlagEOF = OMX_TRUE;
+#endif
+
+ pSECComponent->timeStamp[pH264Dec->hMFCH264Handle.indexTimestamp] = pInputData->timeStamp;
+ pSECComponent->nFlags[pH264Dec->hMFCH264Handle.indexTimestamp] = pInputData->nFlags;
+
+ if ((pH264Dec->hMFCH264Handle.returnCodec == MFC_RET_OK) &&
+ (pH264Dec->bFirstFrame == OMX_FALSE)) {
+ SSBSIP_MFC_DEC_OUTBUF_STATUS status;
+ OMX_S32 indexTimestamp = 0;
+
+ /* wait for mfc decode done */
+ if (pH264Dec->NBDecThread.bDecoderRun == OMX_TRUE) {
+ SEC_OSAL_SemaphoreWait(pH264Dec->NBDecThread.hDecFrameEnd);
+ pH264Dec->NBDecThread.bDecoderRun = OMX_FALSE;
+ }
+
+ status = SsbSipMfcDecGetOutBuf(pH264Dec->hMFCH264Handle.hMFCHandle, &outputInfo);
+ bufWidth = (outputInfo.img_width + 15) & (~15);
+ bufHeight = (outputInfo.img_height + 15) & (~15);
+
+ if ((SsbSipMfcDecGetConfig(pH264Dec->hMFCH264Handle.hMFCHandle, MFC_DEC_GETCONF_FRAME_TAG, &indexTimestamp) != MFC_RET_OK) ||
+ (((indexTimestamp < 0) || (indexTimestamp >= MAX_TIMESTAMP)))) {
+ pOutputData->timeStamp = pInputData->timeStamp;
+ pOutputData->nFlags = (pInputData->nFlags & (~OMX_BUFFERFLAG_EOS));
+ } else {
+ pOutputData->timeStamp = pSECComponent->timeStamp[indexTimestamp];
+ pOutputData->nFlags = pSECComponent->nFlags[indexTimestamp];
+ }
+ SEC_OSAL_Log(SEC_LOG_TRACE, "timestamp %lld us (%.2f secs)", pOutputData->timeStamp, pOutputData->timeStamp / 1E6);
+
+ if ((status == MFC_GETOUTBUF_DISPLAY_DECODING) ||
+ (status == MFC_GETOUTBUF_DISPLAY_ONLY)) {
+ outputDataValid = OMX_TRUE;
+ }
+ if (pOutputData->nFlags & OMX_BUFFERFLAG_EOS)
+ outputDataValid = OMX_FALSE;
+
+ if ((status == MFC_GETOUTBUF_DISPLAY_ONLY) ||
+ (pSECComponent->getAllDelayBuffer == OMX_TRUE))
+ ret = OMX_ErrorInputDataDecodeYet;
+
+ if(status == MFC_GETOUTBUF_DECODING_ONLY) {
+ if (((pInputData->nFlags & OMX_BUFFERFLAG_EOS) != OMX_BUFFERFLAG_EOS) &&
+ ((pSECComponent->bSaveFlagEOS == OMX_TRUE) || (pSECComponent->getAllDelayBuffer == OMX_TRUE))) {
+ pInputData->nFlags |= OMX_BUFFERFLAG_EOS;
+ pSECComponent->getAllDelayBuffer = OMX_TRUE;
+ ret = OMX_ErrorInputDataDecodeYet;
+ } else {
+ ret = OMX_ErrorNone;
+ }
+ outputDataValid = OMX_FALSE;
+ }
+
+#ifdef FULL_FRAME_SEARCH
+ if (((pInputData->nFlags & OMX_BUFFERFLAG_EOS) != OMX_BUFFERFLAG_EOS) &&
+ (pSECComponent->bSaveFlagEOS == OMX_TRUE)) {
+ pInputData->nFlags |= OMX_BUFFERFLAG_EOS;
+ pSECComponent->getAllDelayBuffer = OMX_TRUE;
+ ret = OMX_ErrorInputDataDecodeYet;
+ } else
+#endif
+ if ((pInputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) {
+ //setConfVal = 1;
+ //SsbSipMfcDecSetConfig(pH264Dec->hMFCH264Handle.hMFCHandle, MFC_DEC_SETCONF_IS_LAST_FRAME, &setConfVal);
+ pInputData->nFlags = (pOutputData->nFlags & (~OMX_BUFFERFLAG_EOS));
+ pSECComponent->getAllDelayBuffer = OMX_TRUE;
+ ret = OMX_ErrorInputDataDecodeYet;
+ } else if ((pOutputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) {
+ pSECComponent->getAllDelayBuffer = OMX_FALSE;
+ ret = OMX_ErrorNone;
+ }
+ } else {
+ pOutputData->timeStamp = pInputData->timeStamp;
+ pOutputData->nFlags = pInputData->nFlags;
+
+ if ((pSECComponent->bSaveFlagEOS == OMX_TRUE) ||
+ (pSECComponent->getAllDelayBuffer == OMX_TRUE) ||
+ (pInputData->nFlags & OMX_BUFFERFLAG_EOS)) {
+ pOutputData->nFlags |= OMX_BUFFERFLAG_EOS;
+ pSECComponent->getAllDelayBuffer = OMX_FALSE;
+ }
+ if ((pH264Dec->bFirstFrame == OMX_TRUE) &&
+ ((pOutputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS)) {
+ pInputData->nFlags = (pInputData->nFlags | OMX_BUFFERFLAG_EOS);
+ pOutputData->nFlags = (pOutputData->nFlags & (~OMX_BUFFERFLAG_EOS));
+ }
+
+ outputDataValid = OMX_FALSE;
+
+ /* ret = OMX_ErrorUndefined; */
+ ret = OMX_ErrorNone;
+ }
+
+ if (ret == OMX_ErrorInputDataDecodeYet) {
+ pH264Dec->MFCDecInputBuffer[pH264Dec->indexInputBuffer].dataSize = oneFrameSize;
+ pH264Dec->indexInputBuffer++;
+ pH264Dec->indexInputBuffer %= MFC_INPUT_BUFFER_NUM_MAX;
+ pH264Dec->hMFCH264Handle.pMFCStreamBuffer = pH264Dec->MFCDecInputBuffer[pH264Dec->indexInputBuffer].VirAddr;
+ pH264Dec->hMFCH264Handle.pMFCStreamPhyBuffer = pH264Dec->MFCDecInputBuffer[pH264Dec->indexInputBuffer].PhyAddr;
+ pSECComponent->processData[INPUT_PORT_INDEX].dataBuffer = pH264Dec->MFCDecInputBuffer[pH264Dec->indexInputBuffer].VirAddr;
+ pSECComponent->processData[INPUT_PORT_INDEX].allocSize = pH264Dec->MFCDecInputBuffer[pH264Dec->indexInputBuffer].bufferSize;
+ oneFrameSize = pH264Dec->MFCDecInputBuffer[pH264Dec->indexInputBuffer].dataSize;
+ //pInputData->dataLen = oneFrameSize;
+ //pInputData->remainDataLen = oneFrameSize;
+ }
+
+ if ((Check_H264_StartCode(pInputData->dataBuffer, pInputData->dataLen) == OMX_TRUE) &&
+ ((pOutputData->nFlags & OMX_BUFFERFLAG_EOS) != OMX_BUFFERFLAG_EOS)) {
+ SsbSipMfcDecSetConfig(pH264Dec->hMFCH264Handle.hMFCHandle, MFC_DEC_SETCONF_FRAME_TAG, &(pH264Dec->hMFCH264Handle.indexTimestamp));
+ pH264Dec->hMFCH264Handle.indexTimestamp++;
+ pH264Dec->hMFCH264Handle.indexTimestamp %= MAX_TIMESTAMP;
+
+ SsbSipMfcDecSetInBuf(pH264Dec->hMFCH264Handle.hMFCHandle,
+ pH264Dec->hMFCH264Handle.pMFCStreamPhyBuffer,
+ pH264Dec->hMFCH264Handle.pMFCStreamBuffer,
+ pSECComponent->processData[INPUT_PORT_INDEX].allocSize);
+
+ pH264Dec->MFCDecInputBuffer[pH264Dec->indexInputBuffer].dataSize = oneFrameSize;
+ pH264Dec->NBDecThread.oneFrameSize = oneFrameSize;
+
+ /* mfc decode start */
+ SEC_OSAL_SemaphorePost(pH264Dec->NBDecThread.hDecFrameStart);
+ pH264Dec->NBDecThread.bDecoderRun = OMX_TRUE;
+ pH264Dec->hMFCH264Handle.returnCodec = MFC_RET_OK;
+
+ pH264Dec->indexInputBuffer++;
+ pH264Dec->indexInputBuffer %= MFC_INPUT_BUFFER_NUM_MAX;
+ pH264Dec->hMFCH264Handle.pMFCStreamBuffer = pH264Dec->MFCDecInputBuffer[pH264Dec->indexInputBuffer].VirAddr;
+ pH264Dec->hMFCH264Handle.pMFCStreamPhyBuffer = pH264Dec->MFCDecInputBuffer[pH264Dec->indexInputBuffer].PhyAddr;
+ pSECComponent->processData[INPUT_PORT_INDEX].dataBuffer = pH264Dec->MFCDecInputBuffer[pH264Dec->indexInputBuffer].VirAddr;
+ pSECComponent->processData[INPUT_PORT_INDEX].allocSize = pH264Dec->MFCDecInputBuffer[pH264Dec->indexInputBuffer].bufferSize;
+ if (((pH264Dec->hMFCH264Handle.bThumbnailMode == OMX_TRUE) || (pSECComponent->bSaveFlagEOS == OMX_TRUE)) &&
+ (pH264Dec->bFirstFrame == OMX_TRUE) &&
+ (outputDataValid == OMX_FALSE)) {
+ ret = OMX_ErrorInputDataDecodeYet;
+ }
+ pH264Dec->bFirstFrame = OMX_FALSE;
+ }
+
+ /** Fill Output Buffer **/
+ if (outputDataValid == OMX_TRUE) {
+ SEC_OMX_BASEPORT *pSECInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+ void *pOutputBuf[3];
+
+ int frameSize = bufWidth * bufHeight;
+ int imageSize = outputInfo.img_width * outputInfo.img_height;
+
+ int actualWidth = outputInfo.img_width;
+ int actualHeight = outputInfo.img_height;
+ int actualImageSize = imageSize;
+
+ pOutputBuf[0] = (void *)pOutputData->dataBuffer;
+ pOutputBuf[1] = (void *)pOutputData->dataBuffer + actualImageSize;
+ pOutputBuf[2] = (void *)pOutputData->dataBuffer + ((actualImageSize * 5) / 4);
+
+#ifdef USE_ANDROID_EXTENSION
+ if (pSECOutputPort->bUseAndroidNativeBuffer == OMX_TRUE) {
+ OMX_U32 retANB = 0;
+ void *pVirAddrs[2];
+ actualWidth = (outputInfo.img_width + 15) & (~15);
+ actualImageSize = actualWidth * actualHeight;
+
+ retANB = getVADDRfromANB (pOutputData->dataBuffer,
+ (OMX_U32)pSECInputPort->portDefinition.format.video.nFrameWidth,
+ (OMX_U32)pSECInputPort->portDefinition.format.video.nFrameHeight,
+ pVirAddrs);
+ if (retANB != 0) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "Error getVADDRfromANB, Error code:%d", retANB);
+ ret = OMX_ErrorOverflow;
+ goto EXIT;
+ }
+ pOutputBuf[0] = pVirAddrs[0];
+ pOutputBuf[1] = pVirAddrs[1];
+ }
+#endif
+ if ((pH264Dec->hMFCH264Handle.bThumbnailMode == OMX_FALSE) &&
+ (pSECOutputPort->portDefinition.format.video.eColorFormat == OMX_SEC_COLOR_FormatNV12TPhysicalAddress))
+ {
+ /* if use Post copy address structure */
+ SEC_OSAL_Memcpy(pOutputBuf[0], &frameSize, sizeof(frameSize));
+ SEC_OSAL_Memcpy(pOutputBuf[0] + sizeof(frameSize), &(outputInfo.YPhyAddr), sizeof(outputInfo.YPhyAddr));
+ SEC_OSAL_Memcpy(pOutputBuf[0] + sizeof(frameSize) + (sizeof(void *) * 1), &(outputInfo.CPhyAddr), sizeof(outputInfo.CPhyAddr));
+ SEC_OSAL_Memcpy(pOutputBuf[0] + sizeof(frameSize) + (sizeof(void *) * 2), &(outputInfo.YVirAddr), sizeof(outputInfo.YVirAddr));
+ SEC_OSAL_Memcpy(pOutputBuf[0] + sizeof(frameSize) + (sizeof(void *) * 3), &(outputInfo.CVirAddr), sizeof(outputInfo.CVirAddr));
+ pOutputData->dataLen = (bufWidth * bufHeight * 3) / 2;
+ } else {
+ switch (pSECOutputPort->portDefinition.format.video.eColorFormat) {
+ case OMX_COLOR_FormatYUV420Planar:
+ {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "YUV420P out");
+ csc_tiled_to_linear(
+ (unsigned char *)pOutputBuf[0],
+ (unsigned char *)outputInfo.YVirAddr,
+ actualWidth,
+ actualHeight);
+ csc_tiled_to_linear_deinterleave(
+ (unsigned char *)pOutputBuf[1],
+ (unsigned char *)pOutputBuf[2],
+ (unsigned char *)outputInfo.CVirAddr,
+ actualWidth,
+ actualHeight >> 1);
+ pOutputData->dataLen = actualImageSize * 3 / 2;
+ }
+ break;
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ case OMX_SEC_COLOR_FormatANBYUV420SemiPlanar:
+ default:
+ {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "YUV420SP out");
+ csc_tiled_to_linear(
+ (unsigned char *)pOutputBuf[0],
+ (unsigned char *)outputInfo.YVirAddr,
+ actualWidth,
+ actualHeight);
+ csc_tiled_to_linear(
+ (unsigned char *)pOutputBuf[1],
+ (unsigned char *)outputInfo.CVirAddr,
+ actualWidth,
+ actualHeight >> 1);
+ pOutputData->dataLen = actualImageSize * 3 / 2;
+ }
+ break;
+ }
+ }
+#ifdef USE_ANDROID_EXTENSION
+ if (pSECOutputPort->bUseAndroidNativeBuffer == OMX_TRUE)
+ putVADDRtoANB(pOutputData->dataBuffer);
+#endif
+ } else {
+ pOutputData->dataLen = 0;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+/* MFC Decode */
+OMX_ERRORTYPE SEC_MFC_H264Dec_bufferProcess(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA *pInputData, SEC_OMX_DATA *pOutputData)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ SEC_H264DEC_HANDLE *pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle;
+ SEC_OMX_BASEPORT *pSECInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+ OMX_BOOL endOfFrame = OMX_FALSE;
+
+ FunctionIn();
+
+ if ((!CHECK_PORT_ENABLED(pSECInputPort)) || (!CHECK_PORT_ENABLED(pSECOutputPort)) ||
+ (!CHECK_PORT_POPULATED(pSECInputPort)) || (!CHECK_PORT_POPULATED(pSECOutputPort))) {
+ ret = OMX_ErrorNone;
+ goto EXIT;
+ }
+ if (OMX_FALSE == SEC_Check_BufferProcess_State(pSECComponent)) {
+ ret = OMX_ErrorNone;
+ goto EXIT;
+ }
+
+ ret = SEC_MFC_H264_Decode(pOMXComponent, pInputData, pOutputData);
+ if (ret != OMX_ErrorNone) {
+ if (ret == OMX_ErrorInputDataDecodeYet) {
+ pOutputData->usedDataLen = 0;
+ pOutputData->remainDataLen = pOutputData->dataLen;
+ } else {
+ pSECComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent,
+ pSECComponent->callbackData,
+ OMX_EventError, ret, 0, NULL);
+ }
+ } else {
+ pInputData->previousDataLen = pInputData->dataLen;
+ pInputData->usedDataLen += pInputData->dataLen;
+ pInputData->remainDataLen = pInputData->dataLen - pInputData->usedDataLen;
+ pInputData->dataLen -= pInputData->usedDataLen;
+ pInputData->usedDataLen = 0;
+
+ pOutputData->usedDataLen = 0;
+ pOutputData->remainDataLen = pOutputData->dataLen;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, OMX_STRING componentName)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+ SEC_H264DEC_HANDLE *pH264Dec = NULL;
+ int i = 0;
+
+ FunctionIn();
+
+ if ((hComponent == NULL) || (componentName == NULL)) {
+ ret = OMX_ErrorBadParameter;
+ SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorBadParameter, Line:%d", __LINE__);
+ goto EXIT;
+ }
+ if (SEC_OSAL_Strcmp(SEC_OMX_COMPONENT_H264_DEC, componentName) != 0) {
+ ret = OMX_ErrorBadParameter;
+ SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorBadParameter, componentName:%s, Line:%d", componentName, __LINE__);
+ goto EXIT;
+ }
+
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = SEC_OMX_VideoDecodeComponentInit(pOMXComponent);
+ if (ret != OMX_ErrorNone) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_Error, Line:%d", __LINE__);
+ goto EXIT;
+ }
+ pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ pSECComponent->codecType = HW_VIDEO_CODEC;
+
+ pSECComponent->componentName = (OMX_STRING)SEC_OSAL_Malloc(MAX_OMX_COMPONENT_NAME_SIZE);
+ if (pSECComponent->componentName == NULL) {
+ SEC_OMX_VideoDecodeComponentDeinit(pOMXComponent);
+ ret = OMX_ErrorInsufficientResources;
+ SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__);
+ goto EXIT;
+ }
+ SEC_OSAL_Memset(pSECComponent->componentName, 0, MAX_OMX_COMPONENT_NAME_SIZE);
+
+ pH264Dec = SEC_OSAL_Malloc(sizeof(SEC_H264DEC_HANDLE));
+ if (pH264Dec == NULL) {
+ SEC_OMX_VideoDecodeComponentDeinit(pOMXComponent);
+ ret = OMX_ErrorInsufficientResources;
+ SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__);
+ goto EXIT;
+ }
+ SEC_OSAL_Memset(pH264Dec, 0, sizeof(SEC_H264DEC_HANDLE));
+ pSECComponent->hCodecHandle = (OMX_HANDLETYPE)pH264Dec;
+
+ SEC_OSAL_Strcpy(pSECComponent->componentName, SEC_OMX_COMPONENT_H264_DEC);
+ /* Set componentVersion */
+ pSECComponent->componentVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER;
+ pSECComponent->componentVersion.s.nVersionMinor = VERSIONMINOR_NUMBER;
+ pSECComponent->componentVersion.s.nRevision = REVISION_NUMBER;
+ pSECComponent->componentVersion.s.nStep = STEP_NUMBER;
+ /* Set specVersion */
+ pSECComponent->specVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER;
+ pSECComponent->specVersion.s.nVersionMinor = VERSIONMINOR_NUMBER;
+ pSECComponent->specVersion.s.nRevision = REVISION_NUMBER;
+ pSECComponent->specVersion.s.nStep = STEP_NUMBER;
+
+ /* Android CapabilityFlags */
+ pSECComponent->capabilityFlags.iIsOMXComponentMultiThreaded = OMX_TRUE;
+ pSECComponent->capabilityFlags.iOMXComponentSupportsExternalInputBufferAlloc = OMX_TRUE;
+ pSECComponent->capabilityFlags.iOMXComponentSupportsExternalOutputBufferAlloc = OMX_TRUE;
+ pSECComponent->capabilityFlags.iOMXComponentSupportsMovableInputBuffers = OMX_FALSE;
+ pSECComponent->capabilityFlags.iOMXComponentSupportsPartialFrames = OMX_FALSE;
+ pSECComponent->capabilityFlags.iOMXComponentUsesNALStartCodes = OMX_TRUE;
+ pSECComponent->capabilityFlags.iOMXComponentCanHandleIncompleteFrames = OMX_TRUE;
+ pSECComponent->capabilityFlags.iOMXComponentUsesFullAVCFrames = OMX_TRUE;
+
+ /* Input port */
+ pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ pSECPort->portDefinition.format.video.nFrameWidth = DEFAULT_FRAME_WIDTH;
+ pSECPort->portDefinition.format.video.nFrameHeight= DEFAULT_FRAME_HEIGHT;
+ pSECPort->portDefinition.format.video.nStride = 0; /*DEFAULT_FRAME_WIDTH;*/
+ pSECPort->portDefinition.format.video.nSliceHeight = 0;
+ pSECPort->portDefinition.nBufferSize = DEFAULT_VIDEO_INPUT_BUFFER_SIZE;
+ pSECPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingAVC;
+ SEC_OSAL_Memset(pSECPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE);
+ SEC_OSAL_Strcpy(pSECPort->portDefinition.format.video.cMIMEType, "video/avc");
+ pSECPort->portDefinition.format.video.pNativeRender = 0;
+ pSECPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE;
+ pSECPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatUnused;
+ pSECPort->portDefinition.bEnabled = OMX_TRUE;
+
+ /* Output port */
+ pSECPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+ pSECPort->portDefinition.format.video.nFrameWidth = DEFAULT_FRAME_WIDTH;
+ pSECPort->portDefinition.format.video.nFrameHeight= DEFAULT_FRAME_HEIGHT;
+ pSECPort->portDefinition.format.video.nStride = 0; /*DEFAULT_FRAME_WIDTH;*/
+ pSECPort->portDefinition.format.video.nSliceHeight = 0;
+ pSECPort->portDefinition.nBufferSize = DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE;
+ pSECPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
+ SEC_OSAL_Memset(pSECPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE);
+ SEC_OSAL_Strcpy(pSECPort->portDefinition.format.video.cMIMEType, "raw/video");
+ pSECPort->portDefinition.format.video.pNativeRender = 0;
+ pSECPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE;
+ pSECPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
+ pSECPort->portDefinition.bEnabled = OMX_TRUE;
+
+ for(i = 0; i < ALL_PORT_NUM; i++) {
+ INIT_SET_SIZE_VERSION(&pH264Dec->AVCComponent[i], OMX_VIDEO_PARAM_AVCTYPE);
+ pH264Dec->AVCComponent[i].nPortIndex = i;
+ pH264Dec->AVCComponent[i].eProfile = OMX_VIDEO_AVCProfileBaseline;
+ pH264Dec->AVCComponent[i].eLevel = OMX_VIDEO_AVCLevel4;
+ }
+
+ pOMXComponent->GetParameter = &SEC_MFC_H264Dec_GetParameter;
+ pOMXComponent->SetParameter = &SEC_MFC_H264Dec_SetParameter;
+ pOMXComponent->GetConfig = &SEC_MFC_H264Dec_GetConfig;
+ pOMXComponent->SetConfig = &SEC_MFC_H264Dec_SetConfig;
+ pOMXComponent->GetExtensionIndex = &SEC_MFC_H264Dec_GetExtensionIndex;
+ pOMXComponent->ComponentRoleEnum = &SEC_MFC_H264Dec_ComponentRoleEnum;
+ pOMXComponent->ComponentDeInit = &SEC_OMX_ComponentDeinit;
+
+ pSECComponent->sec_mfc_componentInit = &SEC_MFC_H264Dec_Init;
+ pSECComponent->sec_mfc_componentTerminate = &SEC_MFC_H264Dec_Terminate;
+ pSECComponent->sec_mfc_bufferProcess = &SEC_MFC_H264Dec_bufferProcess;
+ pSECComponent->sec_checkInputFrame = &Check_H264_Frame;
+
+ pSECComponent->currentState = OMX_StateLoaded;
+
+ ret = OMX_ErrorNone;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_OMX_ComponentDeinit(OMX_HANDLETYPE hComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+ SEC_H264DEC_HANDLE *pH264Dec = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ SEC_OSAL_Free(pSECComponent->componentName);
+ pSECComponent->componentName = NULL;
+
+ pH264Dec = (SEC_H264DEC_HANDLE *)pSECComponent->hCodecHandle;
+ if (pH264Dec != NULL) {
+ SEC_OSAL_Free(pH264Dec);
+ pH264Dec = pSECComponent->hCodecHandle = NULL;
+ }
+
+ ret = SEC_OMX_VideoDecodeComponentDeinit(pOMXComponent);
+ if(ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ ret = OMX_ErrorNone;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
diff --git a/exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/SEC_OMX_H264dec.h b/exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/SEC_OMX_H264dec.h
new file mode 100644
index 0000000..d3f8ac8
--- /dev/null
+++ b/exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/SEC_OMX_H264dec.h
@@ -0,0 +1,73 @@
+/*
+ *
+ * Copyright 2010 Samsung Electronics S.LSI Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file SEC_OMX_H264dec.h
+ * @brief
+ * @author SeungBeom Kim (sbcrux.kim@samsung.com)
+ * @version 1.0
+ * @history
+ * 2010.7.15 : Create
+ */
+
+#ifndef SEC_OMX_H264_DEC_COMPONENT
+#define SEC_OMX_H264_DEC_COMPONENT
+
+#include "SEC_OMX_Def.h"
+#include "OMX_Component.h"
+#include "OMX_Video.h"
+
+
+typedef struct _SEC_MFC_H264DEC_HANDLE
+{
+ OMX_HANDLETYPE hMFCHandle;
+ OMX_PTR pMFCStreamBuffer;
+ OMX_PTR pMFCStreamPhyBuffer;
+ OMX_U32 indexTimestamp;
+ OMX_BOOL bConfiguredMFC;
+ OMX_BOOL bThumbnailMode;
+ OMX_S32 returnCodec;
+} SEC_MFC_H264DEC_HANDLE;
+
+typedef struct _SEC_H264DEC_HANDLE
+{
+ /* OMX Codec specific */
+ OMX_VIDEO_PARAM_AVCTYPE AVCComponent[ALL_PORT_NUM];
+ OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE errorCorrectionType[ALL_PORT_NUM];
+
+ /* SEC MFC Codec specific */
+ SEC_MFC_H264DEC_HANDLE hMFCH264Handle;
+
+ /* For Non-Block mode */
+ SEC_MFC_NBDEC_THREAD NBDecThread;
+ OMX_BOOL bFirstFrame;
+ MFC_DEC_INPUT_BUFFER MFCDecInputBuffer[MFC_INPUT_BUFFER_NUM_MAX];
+ OMX_U32 indexInputBuffer;
+} SEC_H264DEC_HANDLE;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, OMX_STRING componentName);
+OMX_ERRORTYPE SEC_OMX_ComponentDeinit(OMX_HANDLETYPE hComponent);
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif
diff --git a/exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/library_register.c b/exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/library_register.c
new file mode 100644
index 0000000..ef3d672
--- /dev/null
+++ b/exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/library_register.c
@@ -0,0 +1,55 @@
+/*
+ *
+ * Copyright 2010 Samsung Electronics S.LSI Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file library_register.c
+ * @brief
+ * @author SeungBeom Kim (sbcrux.kim@samsung.com)
+ * @version 1.0
+ * @history
+ * 2010.7.15 : Create
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dlfcn.h>
+
+#include "SEC_OSAL_Memory.h"
+#include "SEC_OSAL_ETC.h"
+#include "library_register.h"
+#include "SEC_OSAL_Log.h"
+
+
+OSCL_EXPORT_REF int SEC_OMX_COMPONENT_Library_Register(SECRegisterComponentType **secComponents)
+{
+ FunctionIn();
+
+ if (secComponents == NULL)
+ goto EXIT;
+
+ /* component 1 - video decoder H.264 */
+ SEC_OSAL_Strcpy(secComponents[0]->componentName, SEC_OMX_COMPONENT_H264_DEC);
+ SEC_OSAL_Strcpy(secComponents[0]->roles[0], SEC_OMX_COMPONENT_H264_DEC_ROLE);
+ secComponents[0]->totalRoleNum = MAX_COMPONENT_ROLE_NUM;
+
+EXIT:
+ FunctionOut();
+
+ return MAX_COMPONENT_NUM;
+}
+
diff --git a/exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/library_register.h b/exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/library_register.h
new file mode 100644
index 0000000..7a6f7a1
--- /dev/null
+++ b/exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/h264dec/library_register.h
@@ -0,0 +1,55 @@
+/*
+ *
+ * Copyright 2010 Samsung Electronics S.LSI Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file library_register.h
+ * @brief
+ * @author SeungBeom Kim (sbcrux.kim@samsung.com)
+ * @version 1.0
+ * @history
+ * 2010.7.15 : Create
+ */
+
+#ifndef SEC_OMX_H264_REG
+#define SEC_OMX_H264_REG
+
+#include "SEC_OMX_Def.h"
+#include "OMX_Component.h"
+#include "SEC_OMX_Component_Register.h"
+
+
+#define OSCL_EXPORT_REF __attribute__((visibility("default")))
+#define MAX_COMPONENT_NUM 1
+#define MAX_COMPONENT_ROLE_NUM 1
+
+/* H.264 */
+#define SEC_OMX_COMPONENT_H264_DEC "OMX.SEC.AVC.Decoder"
+#define SEC_OMX_COMPONENT_H264_DEC_ROLE "video_decoder.avc"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+OSCL_EXPORT_REF int SEC_OMX_COMPONENT_Library_Register(SECRegisterComponentType **secComponents);
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif
+
diff --git a/exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/Android.mk b/exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/Android.mk
new file mode 100644
index 0000000..1e7d1e5
--- /dev/null
+++ b/exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/Android.mk
@@ -0,0 +1,30 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := \
+ SEC_OMX_Mpeg4dec.c \
+ library_register.c
+
+
+LOCAL_MODULE := libOMX.SEC.M4V.Decoder
+
+LOCAL_CFLAGS :=
+
+LOCAL_ARM_MODE := arm
+
+LOCAL_STATIC_LIBRARIES := libSEC_OMX_Vdec libsecosal libsecbasecomponent \
+ libsecmfcdecapi libseccsc
+LOCAL_SHARED_LIBRARIES := libc libdl libcutils libutils libui libhardware
+
+LOCAL_C_INCLUDES := $(SEC_OMX_INC)/khronos \
+ $(SEC_OMX_INC)/sec \
+ $(SEC_OMX_TOP)/sec_osal \
+ $(SEC_OMX_TOP)/sec_omx_core \
+ $(SEC_OMX_COMPONENT)/common \
+ $(SEC_OMX_COMPONENT)/video/dec
+
+LOCAL_C_INCLUDES += $(SEC_OMX_TOP)/sec_codecs/video/mfc_c110/include
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/SEC_OMX_Mpeg4dec.c b/exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/SEC_OMX_Mpeg4dec.c
new file mode 100644
index 0000000..fb679da
--- /dev/null
+++ b/exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/SEC_OMX_Mpeg4dec.c
@@ -0,0 +1,1652 @@
+/*
+ *
+ * Copyright 2010 Samsung Electronics S.LSI Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file SEC_OMX_Mpeg4dec.c
+ * @brief
+ * @author Yunji Kim (yunji.kim@samsung.com)
+ * @version 1.0
+ * @history
+ * 2010.7.15 : Create
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "SEC_OMX_Macros.h"
+#include "SEC_OMX_Basecomponent.h"
+#include "SEC_OMX_Baseport.h"
+#include "SEC_OMX_Vdec.h"
+#include "library_register.h"
+#include "SEC_OMX_Mpeg4dec.h"
+#include "SsbSipMfcApi.h"
+#include "color_space_convertor.h"
+
+#undef SEC_LOG_TAG
+#define SEC_LOG_TAG "SEC_MPEG4_DEC"
+#define SEC_LOG_OFF
+#include "SEC_OSAL_Log.h"
+
+//#define FULL_FRAME_SEARCH
+
+/* MPEG4 Decoder Supported Levels & profiles */
+SEC_OMX_VIDEO_PROFILELEVEL supportedMPEG4ProfileLevels[] ={
+ {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level0},
+ {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level0b},
+ {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level1},
+ {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level2},
+ {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level3},
+ {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level4},
+ {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level4a},
+ {OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level5},
+ {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level0},
+ {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level0b},
+ {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level1},
+ {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level2},
+ {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level3},
+ {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level4},
+ {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level4a},
+ {OMX_VIDEO_MPEG4ProfileAdvancedSimple, OMX_VIDEO_MPEG4Level5}};
+
+/* H.263 Decoder Supported Levels & profiles */
+SEC_OMX_VIDEO_PROFILELEVEL supportedH263ProfileLevels[] = {
+ /* Baseline (Profile 0) */
+ {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level10},
+ {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level20},
+ {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level30},
+ {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level40},
+ {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level45},
+ {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level50},
+ {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level60},
+ {OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level70},
+ /* Profile 1 */
+ {OMX_VIDEO_H263ProfileH320Coding, OMX_VIDEO_H263Level10},
+ {OMX_VIDEO_H263ProfileH320Coding, OMX_VIDEO_H263Level20},
+ {OMX_VIDEO_H263ProfileH320Coding, OMX_VIDEO_H263Level30},
+ {OMX_VIDEO_H263ProfileH320Coding, OMX_VIDEO_H263Level40},
+ {OMX_VIDEO_H263ProfileH320Coding, OMX_VIDEO_H263Level45},
+ {OMX_VIDEO_H263ProfileH320Coding, OMX_VIDEO_H263Level50},
+ {OMX_VIDEO_H263ProfileH320Coding, OMX_VIDEO_H263Level60},
+ {OMX_VIDEO_H263ProfileH320Coding, OMX_VIDEO_H263Level70},
+ /* Profile 2 */
+ {OMX_VIDEO_H263ProfileBackwardCompatible, OMX_VIDEO_H263Level10},
+ {OMX_VIDEO_H263ProfileBackwardCompatible, OMX_VIDEO_H263Level20},
+ {OMX_VIDEO_H263ProfileBackwardCompatible, OMX_VIDEO_H263Level30},
+ {OMX_VIDEO_H263ProfileBackwardCompatible, OMX_VIDEO_H263Level40},
+ {OMX_VIDEO_H263ProfileBackwardCompatible, OMX_VIDEO_H263Level45},
+ {OMX_VIDEO_H263ProfileBackwardCompatible, OMX_VIDEO_H263Level50},
+ {OMX_VIDEO_H263ProfileBackwardCompatible, OMX_VIDEO_H263Level60},
+ {OMX_VIDEO_H263ProfileBackwardCompatible, OMX_VIDEO_H263Level70},
+ /* Profile 3, restricted up to SD resolution */
+ {OMX_VIDEO_H263ProfileISWV2, OMX_VIDEO_H263Level10},
+ {OMX_VIDEO_H263ProfileISWV2, OMX_VIDEO_H263Level20},
+ {OMX_VIDEO_H263ProfileISWV2, OMX_VIDEO_H263Level30},
+ {OMX_VIDEO_H263ProfileISWV2, OMX_VIDEO_H263Level40},
+ {OMX_VIDEO_H263ProfileISWV2, OMX_VIDEO_H263Level45},
+ {OMX_VIDEO_H263ProfileISWV2, OMX_VIDEO_H263Level50},
+ {OMX_VIDEO_H263ProfileISWV2, OMX_VIDEO_H263Level60},
+ {OMX_VIDEO_H263ProfileISWV2, OMX_VIDEO_H263Level70}};
+
+static OMX_HANDLETYPE ghMFCHandle = NULL;
+static OMX_BOOL gbFIMV1 = OMX_FALSE;
+
+static int Check_Mpeg4_Frame(OMX_U8 *pInputStream, OMX_U32 buffSize, OMX_U32 flag, OMX_BOOL bPreviousFrameEOF, OMX_BOOL *pbEndOfFrame)
+{
+ int len, readStream;
+ unsigned startCode;
+ OMX_BOOL bFrameStart;
+
+ len = 0;
+ bFrameStart = OMX_FALSE;
+
+ if (flag & OMX_BUFFERFLAG_CODECCONFIG) {
+ if (*pInputStream == 0x03) { /* FIMV1 */
+ if (ghMFCHandle != NULL) {
+ BitmapInfoHhr *pInfoHeader;
+ SSBSIP_MFC_IMG_RESOLUTION imgResolution;
+
+ pInfoHeader = (BitmapInfoHhr *)(pInputStream + 1);
+ imgResolution.width = pInfoHeader->BiWidth;
+ imgResolution.height = pInfoHeader->BiHeight;
+ SsbSipMfcDecSetConfig(ghMFCHandle, MFC_DEC_SETCONF_FIMV1_WIDTH_HEIGHT, &imgResolution);
+
+ SEC_OSAL_Log(SEC_LOG_TRACE, "width(%d), height(%d)", imgResolution.width, imgResolution.height);
+ gbFIMV1 = OMX_TRUE;
+ *pbEndOfFrame = OMX_TRUE;
+ return buffSize;
+ }
+ }
+ }
+
+ if (gbFIMV1) {
+ *pbEndOfFrame = OMX_TRUE;
+ return buffSize;
+ }
+
+ if (bPreviousFrameEOF == OMX_FALSE)
+ bFrameStart = OMX_TRUE;
+
+ startCode = 0xFFFFFFFF;
+ if (bFrameStart == OMX_FALSE) {
+ /* find VOP start code */
+ while(startCode != 0x1B6) {
+ readStream = *(pInputStream + len);
+ startCode = (startCode << 8) | readStream;
+ len++;
+ if (len > buffSize)
+ goto EXIT;
+ }
+ }
+
+ /* find next VOP start code */
+ startCode = 0xFFFFFFFF;
+ while ((startCode != 0x1B6)) {
+ readStream = *(pInputStream + len);
+ startCode = (startCode << 8) | readStream;
+ len++;
+ if (len > buffSize)
+ goto EXIT;
+ }
+
+ *pbEndOfFrame = OMX_TRUE;
+
+ SEC_OSAL_Log(SEC_LOG_TRACE, "1. Check_Mpeg4_Frame returned EOF = %d, len = %d, buffSize = %d", *pbEndOfFrame, len - 4, buffSize);
+
+ return len - 4;
+
+EXIT :
+ *pbEndOfFrame = OMX_FALSE;
+
+ SEC_OSAL_Log(SEC_LOG_TRACE, "2. Check_Mpeg4_Frame returned EOF = %d, len = %d, buffSize = %d", *pbEndOfFrame, len - 1, buffSize);
+
+ return --len;
+}
+
+static int Check_H263_Frame(OMX_U8 *pInputStream, OMX_U32 buffSize, OMX_U32 flag, OMX_BOOL bPreviousFrameEOF, OMX_BOOL *pbEndOfFrame)
+{
+ int len, readStream;
+ unsigned startCode;
+ OMX_BOOL bFrameStart = 0;
+ unsigned pTypeMask = 0x03;
+ unsigned pType = 0;
+
+ len = 0;
+ bFrameStart = OMX_FALSE;
+
+ if (bPreviousFrameEOF == OMX_FALSE)
+ bFrameStart = OMX_TRUE;
+
+ startCode = 0xFFFFFFFF;
+ if (bFrameStart == OMX_FALSE) {
+ /* find PSC(Picture Start Code) : 0000 0000 0000 0000 1000 00 */
+ while (((startCode << 8 >> 10) != 0x20) || (pType != 0x02)) {
+ readStream = *(pInputStream + len);
+ startCode = (startCode << 8) | readStream;
+
+ readStream = *(pInputStream + len + 1);
+ pType = readStream & pTypeMask;
+
+ len++;
+ if (len > buffSize)
+ goto EXIT;
+ }
+ }
+
+ /* find next PSC */
+ startCode = 0xFFFFFFFF;
+ pType = 0;
+ while (((startCode << 8 >> 10) != 0x20) || (pType != 0x02)) {
+ readStream = *(pInputStream + len);
+ startCode = (startCode << 8) | readStream;
+
+ readStream = *(pInputStream + len + 1);
+ pType = readStream & pTypeMask;
+
+ len++;
+ if (len > buffSize)
+ goto EXIT;
+ }
+
+ *pbEndOfFrame = OMX_TRUE;
+
+ SEC_OSAL_Log(SEC_LOG_TRACE, "1. Check_H263_Frame returned EOF = %d, len = %d, iBuffSize = %d", *pbEndOfFrame, len - 3, buffSize);
+
+ return len - 3;
+
+EXIT :
+
+ *pbEndOfFrame = OMX_FALSE;
+
+ SEC_OSAL_Log(SEC_LOG_TRACE, "2. Check_H263_Frame returned EOF = %d, len = %d, iBuffSize = %d", *pbEndOfFrame, len - 1, buffSize);
+
+ return --len;
+}
+
+OMX_BOOL Check_Stream_PrefixCode(OMX_U8 *pInputStream, OMX_U32 streamSize, CODEC_TYPE codecType)
+{
+ switch (codecType) {
+ case CODEC_TYPE_MPEG4:
+ if (gbFIMV1) {
+ return OMX_TRUE;
+ } else {
+ if (streamSize < 3) {
+ return OMX_FALSE;
+ } else if ((pInputStream[0] == 0x00) &&
+ (pInputStream[1] == 0x00) &&
+ (pInputStream[2] == 0x01)) {
+ return OMX_TRUE;
+ } else {
+ return OMX_FALSE;
+ }
+ }
+ break;
+ case CODEC_TYPE_H263:
+ if (streamSize > 0)
+ return OMX_TRUE;
+ else
+ return OMX_FALSE;
+ default:
+ SEC_OSAL_Log(SEC_LOG_WARNING, "%s: undefined codec type (%d)", __FUNCTION__, codecType);
+ return OMX_FALSE;
+ }
+}
+
+OMX_ERRORTYPE SEC_MFC_Mpeg4Dec_GetParameter(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_INDEXTYPE nParamIndex,
+ OMX_INOUT OMX_PTR pComponentParameterStructure)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL || pComponentParameterStructure == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ if (pSECComponent->currentState == OMX_StateInvalid ) {
+ ret = OMX_StateInvalid;
+ goto EXIT;
+ }
+
+ switch (nParamIndex) {
+ case OMX_IndexParamVideoMpeg4:
+ {
+ OMX_VIDEO_PARAM_MPEG4TYPE *pDstMpeg4Param = (OMX_VIDEO_PARAM_MPEG4TYPE *)pComponentParameterStructure;
+ OMX_VIDEO_PARAM_MPEG4TYPE *pSrcMpeg4Param = NULL;
+ SEC_MPEG4_HANDLE *pMpeg4Dec = NULL;
+ ret = SEC_OMX_Check_SizeVersion(pDstMpeg4Param, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pDstMpeg4Param->nPortIndex >= ALL_PORT_NUM) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle;
+ pSrcMpeg4Param = &pMpeg4Dec->mpeg4Component[pDstMpeg4Param->nPortIndex];
+
+ SEC_OSAL_Memcpy(pDstMpeg4Param, pSrcMpeg4Param, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE));
+ }
+ break;
+ case OMX_IndexParamVideoH263:
+ {
+ OMX_VIDEO_PARAM_H263TYPE *pDstH263Param = (OMX_VIDEO_PARAM_H263TYPE *)pComponentParameterStructure;
+ OMX_VIDEO_PARAM_H263TYPE *pSrcH263Param = NULL;
+ SEC_MPEG4_HANDLE *pMpeg4Dec = NULL;
+ ret = SEC_OMX_Check_SizeVersion(pDstH263Param, sizeof(OMX_VIDEO_PARAM_H263TYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pDstH263Param->nPortIndex >= ALL_PORT_NUM) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle;
+ pSrcH263Param = &pMpeg4Dec->h263Component[pDstH263Param->nPortIndex];
+
+ SEC_OSAL_Memcpy(pDstH263Param, pSrcH263Param, sizeof(OMX_VIDEO_PARAM_H263TYPE));
+ }
+ break;
+ case OMX_IndexParamStandardComponentRole:
+ {
+ OMX_S32 codecType;
+ OMX_PARAM_COMPONENTROLETYPE *pComponentRole = (OMX_PARAM_COMPONENTROLETYPE *)pComponentParameterStructure;
+
+ ret = SEC_OMX_Check_SizeVersion(pComponentRole, sizeof(OMX_PARAM_COMPONENTROLETYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ codecType = ((SEC_MPEG4_HANDLE *)(pSECComponent->hCodecHandle))->hMFCMpeg4Handle.codecType;
+ if (codecType == CODEC_TYPE_MPEG4)
+ SEC_OSAL_Strcpy((char *)pComponentRole->cRole, SEC_OMX_COMPONENT_MPEG4_DEC_ROLE);
+ else
+ SEC_OSAL_Strcpy((char *)pComponentRole->cRole, SEC_OMX_COMPONENT_H263_DEC_ROLE);
+ }
+ break;
+ case OMX_IndexParamVideoProfileLevelQuerySupported:
+ {
+ OMX_VIDEO_PARAM_PROFILELEVELTYPE *pDstProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pComponentParameterStructure;
+ SEC_OMX_VIDEO_PROFILELEVEL *pProfileLevel = NULL;
+ OMX_U32 maxProfileLevelNum = 0;
+ OMX_S32 codecType;
+
+ ret = SEC_OMX_Check_SizeVersion(pDstProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pDstProfileLevel->nPortIndex >= ALL_PORT_NUM) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ codecType = ((SEC_MPEG4_HANDLE *)(pSECComponent->hCodecHandle))->hMFCMpeg4Handle.codecType;
+ if (codecType == CODEC_TYPE_MPEG4) {
+ pProfileLevel = supportedMPEG4ProfileLevels;
+ maxProfileLevelNum = sizeof(supportedMPEG4ProfileLevels) / sizeof(SEC_OMX_VIDEO_PROFILELEVEL);
+ } else {
+ pProfileLevel = supportedH263ProfileLevels;
+ maxProfileLevelNum = sizeof(supportedH263ProfileLevels) / sizeof(SEC_OMX_VIDEO_PROFILELEVEL);
+ }
+
+ if (pDstProfileLevel->nProfileIndex >= maxProfileLevelNum) {
+ ret = OMX_ErrorNoMore;
+ goto EXIT;
+ }
+
+ pProfileLevel += pDstProfileLevel->nProfileIndex;
+ pDstProfileLevel->eProfile = pProfileLevel->profile;
+ pDstProfileLevel->eLevel = pProfileLevel->level;
+ }
+ break;
+ case OMX_IndexParamVideoProfileLevelCurrent:
+ {
+ OMX_VIDEO_PARAM_PROFILELEVELTYPE *pDstProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pComponentParameterStructure;
+ OMX_VIDEO_PARAM_MPEG4TYPE *pSrcMpeg4Param = NULL;
+ OMX_VIDEO_PARAM_H263TYPE *pSrcH263Param = NULL;
+ SEC_MPEG4_HANDLE *pMpeg4Dec = NULL;
+ OMX_S32 codecType;
+
+ ret = SEC_OMX_Check_SizeVersion(pDstProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pDstProfileLevel->nPortIndex >= ALL_PORT_NUM) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle;
+ codecType = pMpeg4Dec->hMFCMpeg4Handle.codecType;
+ if (codecType == CODEC_TYPE_MPEG4) {
+ pSrcMpeg4Param = &pMpeg4Dec->mpeg4Component[pDstProfileLevel->nPortIndex];
+ pDstProfileLevel->eProfile = pSrcMpeg4Param->eProfile;
+ pDstProfileLevel->eLevel = pSrcMpeg4Param->eLevel;
+ } else {
+ pSrcH263Param = &pMpeg4Dec->h263Component[pDstProfileLevel->nPortIndex];
+ pDstProfileLevel->eProfile = pSrcH263Param->eProfile;
+ pDstProfileLevel->eLevel = pSrcH263Param->eLevel;
+ }
+ }
+ break;
+ case OMX_IndexParamVideoErrorCorrection:
+ {
+ OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pDstErrorCorrectionType = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *)pComponentParameterStructure;
+ OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pSrcErrorCorrectionType = NULL;
+ SEC_MPEG4_HANDLE *pMpeg4Dec = NULL;
+
+ ret = SEC_OMX_Check_SizeVersion(pDstErrorCorrectionType, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pDstErrorCorrectionType->nPortIndex != INPUT_PORT_INDEX) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle;
+ pSrcErrorCorrectionType = &pMpeg4Dec->errorCorrectionType[INPUT_PORT_INDEX];
+
+ pDstErrorCorrectionType->bEnableHEC = pSrcErrorCorrectionType->bEnableHEC;
+ pDstErrorCorrectionType->bEnableResync = pSrcErrorCorrectionType->bEnableResync;
+ pDstErrorCorrectionType->nResynchMarkerSpacing = pSrcErrorCorrectionType->nResynchMarkerSpacing;
+ pDstErrorCorrectionType->bEnableDataPartitioning = pSrcErrorCorrectionType->bEnableDataPartitioning;
+ pDstErrorCorrectionType->bEnableRVLC = pSrcErrorCorrectionType->bEnableRVLC;
+ }
+ break;
+ default:
+ ret = SEC_OMX_VideoDecodeGetParameter(hComponent, nParamIndex, pComponentParameterStructure);
+ break;
+ }
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_Mpeg4Dec_SetParameter(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_INDEXTYPE nIndex,
+ OMX_IN OMX_PTR pComponentParameterStructure)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL || pComponentParameterStructure == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ if (pSECComponent->currentState == OMX_StateInvalid ) {
+ ret = OMX_StateInvalid;
+ goto EXIT;
+ }
+
+ switch (nIndex) {
+ case OMX_IndexParamVideoMpeg4:
+ {
+ OMX_VIDEO_PARAM_MPEG4TYPE *pDstMpeg4Param = NULL;
+ OMX_VIDEO_PARAM_MPEG4TYPE *pSrcMpeg4Param = (OMX_VIDEO_PARAM_MPEG4TYPE *)pComponentParameterStructure;
+ SEC_MPEG4_HANDLE *pMpeg4Dec = NULL;
+
+ ret = SEC_OMX_Check_SizeVersion(pSrcMpeg4Param, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pSrcMpeg4Param->nPortIndex >= ALL_PORT_NUM) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle;
+ pDstMpeg4Param = &pMpeg4Dec->mpeg4Component[pSrcMpeg4Param->nPortIndex];
+
+ SEC_OSAL_Memcpy(pDstMpeg4Param, pSrcMpeg4Param, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE));
+ }
+ break;
+ case OMX_IndexParamVideoH263:
+ {
+ OMX_VIDEO_PARAM_H263TYPE *pDstH263Param = NULL;
+ OMX_VIDEO_PARAM_H263TYPE *pSrcH263Param = (OMX_VIDEO_PARAM_H263TYPE *)pComponentParameterStructure;
+ SEC_MPEG4_HANDLE *pMpeg4Dec = NULL;
+
+ ret = SEC_OMX_Check_SizeVersion(pSrcH263Param, sizeof(OMX_VIDEO_PARAM_H263TYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pSrcH263Param->nPortIndex >= ALL_PORT_NUM) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle;
+ pDstH263Param = &pMpeg4Dec->h263Component[pSrcH263Param->nPortIndex];
+
+ SEC_OSAL_Memcpy(pDstH263Param, pSrcH263Param, sizeof(OMX_VIDEO_PARAM_H263TYPE));
+ }
+ break;
+ case OMX_IndexParamStandardComponentRole:
+ {
+ OMX_PARAM_COMPONENTROLETYPE *pComponentRole = (OMX_PARAM_COMPONENTROLETYPE*)pComponentParameterStructure;
+
+ ret = SEC_OMX_Check_SizeVersion(pComponentRole, sizeof(OMX_PARAM_COMPONENTROLETYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if ((pSECComponent->currentState != OMX_StateLoaded) && (pSECComponent->currentState != OMX_StateWaitForResources)) {
+ ret = OMX_ErrorIncorrectStateOperation;
+ goto EXIT;
+ }
+
+ if (!SEC_OSAL_Strcmp((char*)pComponentRole->cRole, SEC_OMX_COMPONENT_MPEG4_DEC_ROLE)) {
+ pSECComponent->pSECPort[INPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingMPEG4;
+ //((SEC_MPEG4_HANDLE *)(pSECComponent->hCodecHandle))->hMFCMpeg4Handle.codecType = CODEC_TYPE_MPEG4;
+ } else if (!SEC_OSAL_Strcmp((char*)pComponentRole->cRole, SEC_OMX_COMPONENT_H263_DEC_ROLE)) {
+ pSECComponent->pSECPort[INPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingH263;
+ //((SEC_MPEG4_HANDLE *)(pSECComponent->hCodecHandle))->hMFCMpeg4Handle.codecType = CODEC_TYPE_H263;
+ } else {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ }
+ break;
+ case OMX_IndexParamPortDefinition:
+ {
+ OMX_PARAM_PORTDEFINITIONTYPE *pPortDefinition = (OMX_PARAM_PORTDEFINITIONTYPE *)pComponentParameterStructure;
+ OMX_U32 portIndex = pPortDefinition->nPortIndex;
+ SEC_OMX_BASEPORT *pSECPort;
+ OMX_U32 width, height, size;
+
+ if (portIndex >= pSECComponent->portParam.nPorts) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+ ret = SEC_OMX_Check_SizeVersion(pPortDefinition, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ pSECPort = &pSECComponent->pSECPort[portIndex];
+
+ if ((pSECComponent->currentState != OMX_StateLoaded) && (pSECComponent->currentState != OMX_StateWaitForResources)) {
+ if (pSECPort->portDefinition.bEnabled == OMX_TRUE) {
+ ret = OMX_ErrorIncorrectStateOperation;
+ goto EXIT;
+ }
+ }
+ if (pPortDefinition->nBufferCountActual < pSECPort->portDefinition.nBufferCountMin) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ SEC_OSAL_Memcpy(&pSECPort->portDefinition, pPortDefinition, pPortDefinition->nSize);
+
+ width = ((pSECPort->portDefinition.format.video.nFrameWidth + 15) & (~15));
+ height = ((pSECPort->portDefinition.format.video.nFrameHeight + 15) & (~15));
+ size = (width * height * 3) / 2;
+ pSECPort->portDefinition.format.video.nStride = width;
+ pSECPort->portDefinition.format.video.nSliceHeight = height;
+ pSECPort->portDefinition.nBufferSize = (size > pSECPort->portDefinition.nBufferSize) ? size : pSECPort->portDefinition.nBufferSize;
+
+ if (portIndex == INPUT_PORT_INDEX) {
+ SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+ pSECOutputPort->portDefinition.format.video.nFrameWidth = pSECPort->portDefinition.format.video.nFrameWidth;
+ pSECOutputPort->portDefinition.format.video.nFrameHeight = pSECPort->portDefinition.format.video.nFrameHeight;
+ pSECOutputPort->portDefinition.format.video.nStride = width;
+ pSECOutputPort->portDefinition.format.video.nSliceHeight = height;
+
+ switch (pSECOutputPort->portDefinition.format.video.eColorFormat) {
+ case OMX_COLOR_FormatYUV420Planar:
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ case OMX_SEC_COLOR_FormatNV12TPhysicalAddress:
+ case OMX_SEC_COLOR_FormatANBYUV420SemiPlanar:
+ pSECOutputPort->portDefinition.nBufferSize = (width * height * 3) / 2;
+ break;
+ default:
+ SEC_OSAL_Log(SEC_LOG_ERROR, "Color format is not support!! use default YUV size!!");
+ ret = OMX_ErrorUnsupportedSetting;
+ break;
+ }
+ }
+ }
+ break;
+ case OMX_IndexParamVideoProfileLevelCurrent:
+ {
+ OMX_VIDEO_PARAM_PROFILELEVELTYPE *pSrcProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pComponentParameterStructure;
+ OMX_VIDEO_PARAM_MPEG4TYPE *pDstMpeg4Param = NULL;
+ OMX_VIDEO_PARAM_H263TYPE *pDstH263Param = NULL;
+ SEC_MPEG4_HANDLE *pMpeg4Dec = NULL;
+ OMX_S32 codecType;
+
+ ret = SEC_OMX_Check_SizeVersion(pSrcProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE));
+ if (ret != OMX_ErrorNone)
+ goto EXIT;
+
+ if (pSrcProfileLevel->nPortIndex >= ALL_PORT_NUM) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle;
+ codecType = pMpeg4Dec->hMFCMpeg4Handle.codecType;
+ if (codecType == CODEC_TYPE_MPEG4) {
+ /*
+ * To do: Check validity of profile & level parameters
+ */
+
+ pDstMpeg4Param = &pMpeg4Dec->mpeg4Component[pSrcProfileLevel->nPortIndex];
+ pDstMpeg4Param->eProfile = pSrcProfileLevel->eProfile;
+ pDstMpeg4Param->eLevel = pSrcProfileLevel->eLevel;
+ } else {
+ /*
+ * To do: Check validity of profile & level parameters
+ */
+
+ pDstH263Param = &pMpeg4Dec->h263Component[pSrcProfileLevel->nPortIndex];
+ pDstH263Param->eProfile = pSrcProfileLevel->eProfile;
+ pDstH263Param->eLevel = pSrcProfileLevel->eLevel;
+ }
+ }
+ break;
+ case OMX_IndexParamVideoErrorCorrection:
+ {
+ OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pSrcErrorCorrectionType = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *)pComponentParameterStructure;
+ OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pDstErrorCorrectionType = NULL;
+ SEC_MPEG4_HANDLE *pMpeg4Dec = NULL;
+
+ ret = SEC_OMX_Check_SizeVersion(pSrcErrorCorrectionType, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pSrcErrorCorrectionType->nPortIndex != INPUT_PORT_INDEX) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle;
+ pDstErrorCorrectionType = &pMpeg4Dec->errorCorrectionType[INPUT_PORT_INDEX];
+
+ pDstErrorCorrectionType->bEnableHEC = pSrcErrorCorrectionType->bEnableHEC;
+ pDstErrorCorrectionType->bEnableResync = pSrcErrorCorrectionType->bEnableResync;
+ pDstErrorCorrectionType->nResynchMarkerSpacing = pSrcErrorCorrectionType->nResynchMarkerSpacing;
+ pDstErrorCorrectionType->bEnableDataPartitioning = pSrcErrorCorrectionType->bEnableDataPartitioning;
+ pDstErrorCorrectionType->bEnableRVLC = pSrcErrorCorrectionType->bEnableRVLC;
+ }
+ break;
+ default:
+ ret = SEC_OMX_VideoDecodeSetParameter(hComponent, nIndex, pComponentParameterStructure);
+ break;
+ }
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_Mpeg4Dec_GetConfig(
+ OMX_HANDLETYPE hComponent,
+ OMX_INDEXTYPE nIndex,
+ OMX_PTR pComponentConfigStructure)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ if (pComponentConfigStructure == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ if (pSECComponent->currentState == OMX_StateInvalid) {
+ ret = OMX_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ switch (nIndex) {
+ default:
+ ret = SEC_OMX_GetConfig(hComponent, nIndex, pComponentConfigStructure);
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_Mpeg4Dec_SetConfig(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_INDEXTYPE nIndex,
+ OMX_IN OMX_PTR pComponentConfigStructure)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL || pComponentConfigStructure == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ if (pSECComponent->currentState == OMX_StateInvalid) {
+ ret = OMX_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ switch (nIndex) {
+ case OMX_IndexVendorThumbnailMode:
+ {
+ SEC_MPEG4_HANDLE *pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle;
+
+ pMpeg4Dec->hMFCMpeg4Handle.bThumbnailMode = *((OMX_BOOL *)pComponentConfigStructure);
+ }
+ break;
+ default:
+ ret = SEC_OMX_SetConfig(hComponent, nIndex, pComponentConfigStructure);
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_Mpeg4Dec_GetExtensionIndex(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_STRING cParameterName,
+ OMX_OUT OMX_INDEXTYPE *pIndexType)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ if ((cParameterName == NULL) || (pIndexType == NULL)) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ if (pSECComponent->currentState == OMX_StateInvalid) {
+ ret = OMX_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ if (SEC_OSAL_Strcmp(cParameterName, SEC_INDEX_PARAM_ENABLE_THUMBNAIL) == 0) {
+ SEC_MPEG4_HANDLE *pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle;
+ *pIndexType = OMX_IndexVendorThumbnailMode;
+ ret = OMX_ErrorNone;
+#ifdef USE_ANDROID_EXTENSION
+ } else if (SEC_OSAL_Strcmp(cParameterName, SEC_INDEX_PARAM_ENABLE_ANB) == 0) {
+ if (isTvOutEnabled()) {
+ // Samsung normally pushes HW-decoded frames to the TV Out driver
+ // but it's hard for us to do that without source, so return an error
+ // and let Android fallback to software decoding
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+
+ *pIndexType = OMX_IndexParamEnableAndroidBuffers;
+ ret = OMX_ErrorNone;
+ } else if (SEC_OSAL_Strcmp(cParameterName, SEC_INDEX_PARAM_GET_ANB) == 0) {
+ *pIndexType = OMX_IndexParamGetAndroidNativeBuffer;
+ ret = OMX_ErrorNone;
+ } else if (SEC_OSAL_Strcmp(cParameterName, SEC_INDEX_PARAM_USE_ANB) == 0) {
+ *pIndexType = OMX_IndexParamUseAndroidNativeBuffer;
+ ret = OMX_ErrorNone;
+#endif
+ } else {
+ ret = SEC_OMX_GetExtensionIndex(hComponent, cParameterName, pIndexType);
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_Mpeg4Dec_ComponentRoleEnum(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_OUT OMX_U8 *cRole,
+ OMX_IN OMX_U32 nIndex)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+ OMX_S32 codecType;
+
+ FunctionIn();
+
+ if ((hComponent == NULL) || (cRole == NULL)) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ if (nIndex != (MAX_COMPONENT_ROLE_NUM - 1)) {
+ ret = OMX_ErrorNoMore;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = SEC_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+ if (pOMXComponent->pComponentPrivate == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ if (pSECComponent->currentState == OMX_StateInvalid ) {
+ ret = OMX_StateInvalid;
+ goto EXIT;
+ }
+
+ codecType = ((SEC_MPEG4_HANDLE *)(pSECComponent->hCodecHandle))->hMFCMpeg4Handle.codecType;
+ if (codecType == CODEC_TYPE_MPEG4)
+ SEC_OSAL_Strcpy((char *)cRole, SEC_OMX_COMPONENT_MPEG4_DEC_ROLE);
+ else
+ SEC_OSAL_Strcpy((char *)cRole, SEC_OMX_COMPONENT_H263_DEC_ROLE);
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_DecodeThread(OMX_HANDLETYPE hComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+ SEC_MPEG4_HANDLE *pMpeg4Dec = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle;
+
+ while (pMpeg4Dec->NBDecThread.bExitDecodeThread == OMX_FALSE) {
+ SEC_OSAL_SemaphoreWait(pMpeg4Dec->NBDecThread.hDecFrameStart);
+
+ if (pMpeg4Dec->NBDecThread.bExitDecodeThread == OMX_FALSE) {
+ pMpeg4Dec->hMFCMpeg4Handle.returnCodec = SsbSipMfcDecExe(pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle, pMpeg4Dec->NBDecThread.oneFrameSize);
+ SEC_OSAL_SemaphorePost(pMpeg4Dec->NBDecThread.hDecFrameEnd);
+ }
+ }
+
+EXIT:
+ SEC_OSAL_ThreadExit(NULL);
+ FunctionOut();
+
+ return ret;
+}
+
+/* MFC Init */
+OMX_ERRORTYPE SEC_MFC_Mpeg4Dec_Init(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ SEC_MPEG4_HANDLE *pMpeg4Dec = NULL;
+ OMX_HANDLETYPE hMFCHandle = NULL;
+ OMX_PTR pStreamBuffer = NULL;
+ OMX_PTR pStreamPhyBuffer = NULL;
+
+ FunctionIn();
+
+ pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle;
+ pMpeg4Dec->hMFCMpeg4Handle.bConfiguredMFC = OMX_FALSE;
+ pSECComponent->bUseFlagEOF = OMX_FALSE;
+ pSECComponent->bSaveFlagEOS = OMX_FALSE;
+
+ /* MFC(Multi Format Codec) decoder and CMM(Codec Memory Management) driver open */
+ SSBIP_MFC_BUFFER_TYPE buf_type = CACHE;
+ hMFCHandle = (OMX_PTR)SsbSipMfcDecOpen(&buf_type);
+ if (hMFCHandle == NULL) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ ghMFCHandle = pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle = hMFCHandle;
+
+ /* Allocate decoder's input buffer */
+ pStreamBuffer = SsbSipMfcDecGetInBuf(hMFCHandle, &pStreamPhyBuffer, DEFAULT_MFC_INPUT_BUFFER_SIZE);
+ if (pStreamBuffer == NULL) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+
+ pMpeg4Dec->MFCDecInputBuffer[0].VirAddr = pStreamBuffer;
+ pMpeg4Dec->MFCDecInputBuffer[0].PhyAddr = pStreamPhyBuffer;
+ pMpeg4Dec->MFCDecInputBuffer[0].bufferSize = DEFAULT_MFC_INPUT_BUFFER_SIZE;
+ pMpeg4Dec->MFCDecInputBuffer[0].dataSize = 0;
+ pMpeg4Dec->MFCDecInputBuffer[1].VirAddr = (unsigned char *)pStreamBuffer + pMpeg4Dec->MFCDecInputBuffer[0].bufferSize;
+ pMpeg4Dec->MFCDecInputBuffer[1].PhyAddr = (unsigned char *)pStreamPhyBuffer + pMpeg4Dec->MFCDecInputBuffer[0].bufferSize;
+ pMpeg4Dec->MFCDecInputBuffer[1].bufferSize = DEFAULT_MFC_INPUT_BUFFER_SIZE;
+ pMpeg4Dec->MFCDecInputBuffer[1].dataSize = 0;
+ pMpeg4Dec->indexInputBuffer = 0;
+
+ pMpeg4Dec->bFirstFrame = OMX_TRUE;
+
+ pMpeg4Dec->NBDecThread.bExitDecodeThread = OMX_FALSE;
+ pMpeg4Dec->NBDecThread.bDecoderRun = OMX_FALSE;
+ pMpeg4Dec->NBDecThread.oneFrameSize = 0;
+ SEC_OSAL_SemaphoreCreate(&(pMpeg4Dec->NBDecThread.hDecFrameStart));
+ SEC_OSAL_SemaphoreCreate(&(pMpeg4Dec->NBDecThread.hDecFrameEnd));
+ if (OMX_ErrorNone == SEC_OSAL_ThreadCreate(&pMpeg4Dec->NBDecThread.hNBDecodeThread,
+ SEC_MFC_DecodeThread,
+ pOMXComponent)) {
+ pMpeg4Dec->hMFCMpeg4Handle.returnCodec = MFC_RET_OK;
+ }
+
+ pMpeg4Dec->hMFCMpeg4Handle.pMFCStreamBuffer = pMpeg4Dec->MFCDecInputBuffer[0].VirAddr;
+ pMpeg4Dec->hMFCMpeg4Handle.pMFCStreamPhyBuffer = pMpeg4Dec->MFCDecInputBuffer[0].PhyAddr;
+ pSECComponent->processData[INPUT_PORT_INDEX].dataBuffer = pMpeg4Dec->MFCDecInputBuffer[0].VirAddr;
+ pSECComponent->processData[INPUT_PORT_INDEX].allocSize = pMpeg4Dec->MFCDecInputBuffer[0].bufferSize;
+
+ SEC_OSAL_Memset(pSECComponent->timeStamp, -19771003, sizeof(OMX_TICKS) * MAX_TIMESTAMP);
+ SEC_OSAL_Memset(pSECComponent->nFlags, 0, sizeof(OMX_U32) * MAX_FLAGS);
+ pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp = 0;
+ pSECComponent->getAllDelayBuffer = OMX_FALSE;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+/* MFC Terminate */
+OMX_ERRORTYPE SEC_MFC_Mpeg4Dec_Terminate(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ SEC_MPEG4_HANDLE *pMpeg4Dec = NULL;
+ OMX_HANDLETYPE hMFCHandle = NULL;
+
+ FunctionIn();
+
+ pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle;
+ hMFCHandle = pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle;
+
+ pMpeg4Dec->hMFCMpeg4Handle.pMFCStreamBuffer = NULL;
+ pMpeg4Dec->hMFCMpeg4Handle.pMFCStreamPhyBuffer = NULL;
+ pSECComponent->processData[INPUT_PORT_INDEX].dataBuffer = NULL;
+ pSECComponent->processData[INPUT_PORT_INDEX].allocSize = 0;
+
+ if (pMpeg4Dec->NBDecThread.hNBDecodeThread != NULL) {
+ pMpeg4Dec->NBDecThread.bExitDecodeThread = OMX_TRUE;
+ SEC_OSAL_SemaphorePost(pMpeg4Dec->NBDecThread.hDecFrameStart);
+ SEC_OSAL_ThreadTerminate(pMpeg4Dec->NBDecThread.hNBDecodeThread);
+ pMpeg4Dec->NBDecThread.hNBDecodeThread = NULL;
+ }
+
+ if(pMpeg4Dec->NBDecThread.hDecFrameEnd != NULL) {
+ SEC_OSAL_SemaphoreTerminate(pMpeg4Dec->NBDecThread.hDecFrameEnd);
+ pMpeg4Dec->NBDecThread.hDecFrameEnd = NULL;
+ }
+
+ if(pMpeg4Dec->NBDecThread.hDecFrameStart != NULL) {
+ SEC_OSAL_SemaphoreTerminate(pMpeg4Dec->NBDecThread.hDecFrameStart);
+ pMpeg4Dec->NBDecThread.hDecFrameStart = NULL;
+ }
+
+ if (hMFCHandle != NULL) {
+ SsbSipMfcDecClose(hMFCHandle);
+ pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle = NULL;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_Mpeg4_Decode(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA *pInputData, SEC_OMX_DATA *pOutputData)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ SEC_MPEG4_HANDLE *pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle;
+ OMX_HANDLETYPE hMFCHandle = pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle;
+ OMX_U32 oneFrameSize = pInputData->dataLen;
+ SSBSIP_MFC_DEC_OUTPUT_INFO outputInfo;
+ OMX_S32 configValue = 0;
+ int bufWidth = 0;
+ int bufHeight = 0;
+ OMX_BOOL outputDataValid = OMX_FALSE;
+
+ FunctionIn();
+
+ if (pMpeg4Dec->hMFCMpeg4Handle.bConfiguredMFC == OMX_FALSE) {
+ SSBSIP_MFC_CODEC_TYPE MFCCodecType;
+ if (pMpeg4Dec->hMFCMpeg4Handle.codecType == CODEC_TYPE_MPEG4) {
+ if (gbFIMV1)
+ MFCCodecType = FIMV1_DEC;
+ else
+ MFCCodecType = MPEG4_DEC;
+ } else {
+ MFCCodecType = H263_DEC;
+ }
+
+ if ((oneFrameSize <= 0) && (pInputData->nFlags & OMX_BUFFERFLAG_EOS)) {
+ pOutputData->timeStamp = pInputData->timeStamp;
+ pOutputData->nFlags = pInputData->nFlags;
+ ret = OMX_ErrorNone;
+ goto EXIT;
+ }
+
+ /* Set the number of extra buffer to prevent tearing */
+ configValue = 0;
+ SsbSipMfcDecSetConfig(hMFCHandle, MFC_DEC_SETCONF_EXTRA_BUFFER_NUM, &configValue);
+
+ /* Set mpeg4 deblocking filter enable */
+ configValue = 1;
+ SsbSipMfcDecSetConfig(hMFCHandle, MFC_DEC_SETCONF_POST_ENABLE, &configValue);
+
+ if (pMpeg4Dec->hMFCMpeg4Handle.bThumbnailMode == OMX_TRUE) {
+ configValue = 1; // the number that you want to delay
+ SsbSipMfcDecSetConfig(hMFCHandle, MFC_DEC_SETCONF_DISPLAY_DELAY, &configValue);
+ }
+
+ pMpeg4Dec->hMFCMpeg4Handle.returnCodec = SsbSipMfcDecInit(hMFCHandle, MFCCodecType, oneFrameSize);
+ if (pMpeg4Dec->hMFCMpeg4Handle.returnCodec == MFC_RET_OK) {
+ SSBSIP_MFC_IMG_RESOLUTION imgResol;
+ SEC_OMX_BASEPORT *pInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+
+ if (SsbSipMfcDecGetConfig(hMFCHandle, MFC_DEC_GETCONF_BUF_WIDTH_HEIGHT, &imgResol) != MFC_RET_OK) {
+ ret = OMX_ErrorMFCInit;
+ SEC_OSAL_Log(SEC_LOG_ERROR, "%s: SsbSipMfcDecGetConfig failed", __FUNCTION__);
+ goto EXIT;
+ }
+
+ /** Update Frame Size **/
+ if ((pInputPort->portDefinition.format.video.nFrameWidth != imgResol.width) ||
+ (pInputPort->portDefinition.format.video.nFrameHeight != imgResol.height)) {
+ /* change width and height information */
+ pInputPort->portDefinition.format.video.nFrameWidth = imgResol.width;
+ pInputPort->portDefinition.format.video.nFrameHeight = imgResol.height;
+ pInputPort->portDefinition.format.video.nStride = ((imgResol.width + 15) & (~15));
+ pInputPort->portDefinition.format.video.nSliceHeight = ((imgResol.height + 15) & (~15));
+
+ SEC_UpdateFrameSize(pOMXComponent);
+
+ /* Send Port Settings changed call back */
+ (*(pSECComponent->pCallbacks->EventHandler))
+ (pOMXComponent,
+ pSECComponent->callbackData,
+ OMX_EventPortSettingsChanged, // The command was completed
+ OMX_DirOutput, // This is the port index
+ 0,
+ NULL);
+ }
+
+ SEC_OSAL_Log(SEC_LOG_TRACE, "nFrameWidth(%d) nFrameHeight(%d), nStride(%d), nSliceHeight(%d)",
+ pInputPort->portDefinition.format.video.nFrameWidth, pInputPort->portDefinition.format.video.nFrameHeight,
+ pInputPort->portDefinition.format.video.nStride, pInputPort->portDefinition.format.video.nSliceHeight);
+
+ pMpeg4Dec->hMFCMpeg4Handle.bConfiguredMFC = OMX_TRUE;
+ if (pMpeg4Dec->hMFCMpeg4Handle.codecType == CODEC_TYPE_MPEG4) {
+ pOutputData->timeStamp = pInputData->timeStamp;
+ pOutputData->nFlags = pInputData->nFlags;
+ ret = OMX_ErrorNone;
+ } else {
+ pOutputData->dataLen = 0;
+ ret = OMX_ErrorInputDataDecodeYet;
+ }
+ goto EXIT;
+ } else {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "%s: SsbSipMfcDecInit failed", __FUNCTION__);
+ ret = OMX_ErrorMFCInit; /* OMX_ErrorUndefined */
+ goto EXIT;
+ }
+ }
+
+#ifndef FULL_FRAME_SEARCH
+ if ((pInputData->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) &&
+ (pSECComponent->bUseFlagEOF == OMX_FALSE))
+ pSECComponent->bUseFlagEOF = OMX_TRUE;
+#endif
+
+ pSECComponent->timeStamp[pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp] = pInputData->timeStamp;
+ pSECComponent->nFlags[pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp] = pInputData->nFlags;
+
+ if ((pMpeg4Dec->hMFCMpeg4Handle.returnCodec == MFC_RET_OK) &&
+ (pMpeg4Dec->bFirstFrame == OMX_FALSE)) {
+ SSBSIP_MFC_DEC_OUTBUF_STATUS status;
+ OMX_S32 indexTimestamp = 0;
+
+ /* wait for mfc decode done */
+ if (pMpeg4Dec->NBDecThread.bDecoderRun == OMX_TRUE) {
+ SEC_OSAL_SemaphoreWait(pMpeg4Dec->NBDecThread.hDecFrameEnd);
+ pMpeg4Dec->NBDecThread.bDecoderRun = OMX_FALSE;
+ }
+
+ status = SsbSipMfcDecGetOutBuf(hMFCHandle, &outputInfo);
+ bufWidth = (outputInfo.img_width + 15) & (~15);
+ bufHeight = (outputInfo.img_height + 15) & (~15);
+
+ if ((SsbSipMfcDecGetConfig(hMFCHandle, MFC_DEC_GETCONF_FRAME_TAG, &indexTimestamp) != MFC_RET_OK) ||
+ (((indexTimestamp < 0) || (indexTimestamp >= MAX_TIMESTAMP)))) {
+ pOutputData->timeStamp = pInputData->timeStamp;
+ pOutputData->nFlags = (pInputData->nFlags & (~OMX_BUFFERFLAG_EOS));
+ } else {
+ pOutputData->timeStamp = pSECComponent->timeStamp[indexTimestamp];
+ pOutputData->nFlags = pSECComponent->nFlags[indexTimestamp];
+ }
+ SEC_OSAL_Log(SEC_LOG_TRACE, "timestamp %lld us (%.2f secs)", pOutputData->timeStamp, pOutputData->timeStamp / 1E6);
+
+ if ((status == MFC_GETOUTBUF_DISPLAY_DECODING) ||
+ (status == MFC_GETOUTBUF_DISPLAY_ONLY)) {
+ outputDataValid = OMX_TRUE;
+ }
+ if (pOutputData->nFlags & OMX_BUFFERFLAG_EOS)
+ outputDataValid = OMX_FALSE;
+
+ if ((status == MFC_GETOUTBUF_DISPLAY_ONLY) ||
+ (pSECComponent->getAllDelayBuffer == OMX_TRUE))
+ ret = OMX_ErrorInputDataDecodeYet;
+
+ if (status == MFC_GETOUTBUF_DECODING_ONLY) {
+ if (((pInputData->nFlags & OMX_BUFFERFLAG_EOS) != OMX_BUFFERFLAG_EOS) &&
+ ((pSECComponent->bSaveFlagEOS == OMX_TRUE) || (pSECComponent->getAllDelayBuffer == OMX_TRUE))) {
+ pInputData->nFlags |= OMX_BUFFERFLAG_EOS;
+ pSECComponent->getAllDelayBuffer = OMX_TRUE;
+ ret = OMX_ErrorInputDataDecodeYet;
+ } else {
+ ret = OMX_ErrorNone;
+ }
+ outputDataValid = OMX_FALSE;
+ }
+
+#ifdef FULL_FRAME_SEARCH
+ if (((pInputData->nFlags & OMX_BUFFERFLAG_EOS) != OMX_BUFFERFLAG_EOS) &&
+ (pSECComponent->bSaveFlagEOS == OMX_TRUE)) {
+ pInputData->nFlags |= OMX_BUFFERFLAG_EOS;
+ pSECComponent->getAllDelayBuffer = OMX_TRUE;
+ ret = OMX_ErrorInputDataDecodeYet;
+ } else
+#endif
+ if ((pInputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) {
+ //configValue = 1;
+ //SsbSipMfcDecSetConfig(pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle, MFC_DEC_SETCONF_IS_LAST_FRAME, &configValue);
+ pInputData->nFlags = (pOutputData->nFlags & (~OMX_BUFFERFLAG_EOS));
+ pSECComponent->getAllDelayBuffer = OMX_TRUE;
+ ret = OMX_ErrorInputDataDecodeYet;
+ } else if ((pOutputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) {
+ pSECComponent->getAllDelayBuffer = OMX_FALSE;
+ ret = OMX_ErrorNone;
+ }
+ } else {
+ pOutputData->timeStamp = pInputData->timeStamp;
+ pOutputData->nFlags = pInputData->nFlags;
+
+ if ((pSECComponent->bSaveFlagEOS == OMX_TRUE) ||
+ (pSECComponent->getAllDelayBuffer == OMX_TRUE) ||
+ (pInputData->nFlags & OMX_BUFFERFLAG_EOS)) {
+ pOutputData->nFlags |= OMX_BUFFERFLAG_EOS;
+ pSECComponent->getAllDelayBuffer = OMX_FALSE;
+ }
+ if ((pMpeg4Dec->bFirstFrame == OMX_TRUE) &&
+ ((pOutputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS)) {
+ pInputData->nFlags = (pInputData->nFlags | OMX_BUFFERFLAG_EOS);
+ pOutputData->nFlags = (pOutputData->nFlags & (~OMX_BUFFERFLAG_EOS));
+ }
+
+ outputDataValid = OMX_FALSE;
+
+ /* ret = OMX_ErrorUndefined; */
+ ret = OMX_ErrorNone;
+ }
+
+ if (ret == OMX_ErrorInputDataDecodeYet) {
+ pMpeg4Dec->MFCDecInputBuffer[pMpeg4Dec->indexInputBuffer].dataSize = oneFrameSize;
+ pMpeg4Dec->indexInputBuffer++;
+ pMpeg4Dec->indexInputBuffer %= MFC_INPUT_BUFFER_NUM_MAX;
+ pMpeg4Dec->hMFCMpeg4Handle.pMFCStreamBuffer = pMpeg4Dec->MFCDecInputBuffer[pMpeg4Dec->indexInputBuffer].VirAddr;
+ pMpeg4Dec->hMFCMpeg4Handle.pMFCStreamPhyBuffer = pMpeg4Dec->MFCDecInputBuffer[pMpeg4Dec->indexInputBuffer].PhyAddr;
+ pSECComponent->processData[INPUT_PORT_INDEX].dataBuffer = pMpeg4Dec->MFCDecInputBuffer[pMpeg4Dec->indexInputBuffer].VirAddr;
+ pSECComponent->processData[INPUT_PORT_INDEX].allocSize = pMpeg4Dec->MFCDecInputBuffer[pMpeg4Dec->indexInputBuffer].bufferSize;
+ oneFrameSize = pMpeg4Dec->MFCDecInputBuffer[pMpeg4Dec->indexInputBuffer].dataSize;
+ //pInputData->dataLen = oneFrameSize;
+ //pInputData->remainDataLen = oneFrameSize;
+ }
+
+ if ((Check_Stream_PrefixCode(pInputData->dataBuffer, pInputData->dataLen, pMpeg4Dec->hMFCMpeg4Handle.codecType) == OMX_TRUE) &&
+ ((pOutputData->nFlags & OMX_BUFFERFLAG_EOS) != OMX_BUFFERFLAG_EOS)) {
+ SsbSipMfcDecSetConfig(hMFCHandle, MFC_DEC_SETCONF_FRAME_TAG, &(pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp));
+ pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp++;
+ pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp %= MAX_TIMESTAMP;
+
+ SsbSipMfcDecSetInBuf(pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle,
+ pMpeg4Dec->hMFCMpeg4Handle.pMFCStreamPhyBuffer,
+ pMpeg4Dec->hMFCMpeg4Handle.pMFCStreamBuffer,
+ pSECComponent->processData[INPUT_PORT_INDEX].allocSize);
+
+ pMpeg4Dec->MFCDecInputBuffer[pMpeg4Dec->indexInputBuffer].dataSize = oneFrameSize;
+ pMpeg4Dec->NBDecThread.oneFrameSize = oneFrameSize;
+
+ /* mfc decode start */
+ SEC_OSAL_SemaphorePost(pMpeg4Dec->NBDecThread.hDecFrameStart);
+ pMpeg4Dec->NBDecThread.bDecoderRun = OMX_TRUE;
+ pMpeg4Dec->hMFCMpeg4Handle.returnCodec = MFC_RET_OK;
+
+ pMpeg4Dec->indexInputBuffer++;
+ pMpeg4Dec->indexInputBuffer %= MFC_INPUT_BUFFER_NUM_MAX;
+ pMpeg4Dec->hMFCMpeg4Handle.pMFCStreamBuffer = pMpeg4Dec->MFCDecInputBuffer[pMpeg4Dec->indexInputBuffer].VirAddr;
+ pMpeg4Dec->hMFCMpeg4Handle.pMFCStreamPhyBuffer = pMpeg4Dec->MFCDecInputBuffer[pMpeg4Dec->indexInputBuffer].PhyAddr;
+ pSECComponent->processData[INPUT_PORT_INDEX].dataBuffer = pMpeg4Dec->MFCDecInputBuffer[pMpeg4Dec->indexInputBuffer].VirAddr;
+ pSECComponent->processData[INPUT_PORT_INDEX].allocSize = pMpeg4Dec->MFCDecInputBuffer[pMpeg4Dec->indexInputBuffer].bufferSize;
+ if (((pMpeg4Dec->hMFCMpeg4Handle.bThumbnailMode == OMX_TRUE) || (pSECComponent->bSaveFlagEOS == OMX_TRUE)) &&
+ (pMpeg4Dec->bFirstFrame == OMX_TRUE) &&
+ (outputDataValid == OMX_FALSE)) {
+ ret = OMX_ErrorInputDataDecodeYet;
+ }
+ pMpeg4Dec->bFirstFrame = OMX_FALSE;
+ }
+
+ /** Fill Output Buffer **/
+ if (outputDataValid == OMX_TRUE) {
+ SEC_OMX_BASEPORT *pSECInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+ void *pOutputBuf[3];
+
+ int frameSize = bufWidth * bufHeight;
+ int imageSize = outputInfo.img_width * outputInfo.img_height;
+
+ int actualWidth = outputInfo.img_width;
+ int actualHeight = outputInfo.img_height;
+ int actualImageSize = imageSize;
+
+ pOutputBuf[0] = (void *)pOutputData->dataBuffer;
+ pOutputBuf[1] = (void *)pOutputData->dataBuffer + actualImageSize;
+ pOutputBuf[2] = (void *)pOutputData->dataBuffer + ((actualImageSize * 5) / 4);
+
+#ifdef USE_ANDROID_EXTENSION
+ if (pSECOutputPort->bUseAndroidNativeBuffer == OMX_TRUE) {
+ OMX_U32 retANB = 0;
+ void *pVirAddrs[2];
+ actualWidth = (outputInfo.img_width + 15) & (~15);
+ actualImageSize = actualWidth * actualHeight;
+
+ retANB = getVADDRfromANB(pOutputData->dataBuffer,
+ (OMX_U32)pSECInputPort->portDefinition.format.video.nFrameWidth,
+ (OMX_U32)pSECInputPort->portDefinition.format.video.nFrameHeight,
+ pVirAddrs);
+ if (retANB != 0) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "Error getVADDRfromANB, Error code:%d", retANB);
+ ret = OMX_ErrorOverflow;
+ goto EXIT;
+ }
+ pOutputBuf[0] = pVirAddrs[0];
+ pOutputBuf[1] = pVirAddrs[1];
+ }
+#endif
+ if ((pMpeg4Dec->hMFCMpeg4Handle.bThumbnailMode == OMX_FALSE) &&
+ (pSECOutputPort->portDefinition.format.video.eColorFormat == OMX_SEC_COLOR_FormatNV12TPhysicalAddress))
+ {
+ /* if use Post copy address structure */
+ SEC_OSAL_Memcpy(pOutputBuf[0], &frameSize, sizeof(frameSize));
+ SEC_OSAL_Memcpy(pOutputBuf[0] + sizeof(frameSize), &(outputInfo.YPhyAddr), sizeof(outputInfo.YPhyAddr));
+ SEC_OSAL_Memcpy(pOutputBuf[0] + sizeof(frameSize) + (sizeof(void *) * 1), &(outputInfo.CPhyAddr), sizeof(outputInfo.CPhyAddr));
+ SEC_OSAL_Memcpy(pOutputBuf[0] + sizeof(frameSize) + (sizeof(void *) * 2), &(outputInfo.YVirAddr), sizeof(outputInfo.YVirAddr));
+ SEC_OSAL_Memcpy(pOutputBuf[0] + sizeof(frameSize) + (sizeof(void *) * 3), &(outputInfo.CVirAddr), sizeof(outputInfo.CVirAddr));
+ pOutputData->dataLen = (bufWidth * bufHeight * 3) / 2;
+ } else {
+ switch (pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eColorFormat) {
+ case OMX_COLOR_FormatYUV420Planar:
+ {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "YUV420P out");
+ csc_tiled_to_linear(
+ (unsigned char *)pOutputBuf[0],
+ (unsigned char *)outputInfo.YVirAddr,
+ actualWidth,
+ actualHeight);
+ csc_tiled_to_linear_deinterleave(
+ (unsigned char *)pOutputBuf[1],
+ (unsigned char *)pOutputBuf[2],
+ (unsigned char *)outputInfo.CVirAddr,
+ actualWidth,
+ actualHeight >> 1);
+ pOutputData->dataLen = actualImageSize * 3 / 2;
+ }
+ break;
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ case OMX_SEC_COLOR_FormatANBYUV420SemiPlanar:
+ default:
+ {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "YUV420SP out");
+ csc_tiled_to_linear(
+ (unsigned char *)pOutputBuf[0],
+ (unsigned char *)outputInfo.YVirAddr,
+ actualWidth,
+ actualHeight);
+ csc_tiled_to_linear(
+ (unsigned char *)pOutputBuf[1],
+ (unsigned char *)outputInfo.CVirAddr,
+ actualWidth,
+ actualHeight >> 1);
+ pOutputData->dataLen = actualImageSize * 3 / 2;
+ }
+ break;
+ }
+ }
+#ifdef USE_ANDROID_EXTENSION
+ if (pSECOutputPort->bUseAndroidNativeBuffer == OMX_TRUE)
+ putVADDRtoANB(pOutputData->dataBuffer);
+#endif
+ } else {
+ pOutputData->dataLen = 0;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+/* MFC Decode */
+OMX_ERRORTYPE SEC_MFC_Mpeg4Dec_bufferProcess(OMX_COMPONENTTYPE *pOMXComponent, SEC_OMX_DATA *pInputData, SEC_OMX_DATA *pOutputData)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ SEC_MPEG4_HANDLE *pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle;
+ SEC_OMX_BASEPORT *pInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ SEC_OMX_BASEPORT *pOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+ OMX_BOOL bCheckPrefix = OMX_FALSE;
+
+ FunctionIn();
+
+ if ((!CHECK_PORT_ENABLED(pInputPort)) || (!CHECK_PORT_ENABLED(pOutputPort)) ||
+ (!CHECK_PORT_POPULATED(pInputPort)) || (!CHECK_PORT_POPULATED(pOutputPort))) {
+ ret = OMX_ErrorNone;
+ goto EXIT;
+ }
+ if (OMX_FALSE == SEC_Check_BufferProcess_State(pSECComponent)) {
+ ret = OMX_ErrorNone;
+ goto EXIT;
+ }
+
+ ret = SEC_MFC_Mpeg4_Decode(pOMXComponent, pInputData, pOutputData);
+ if (ret != OMX_ErrorNone) {
+ if (ret == OMX_ErrorInputDataDecodeYet) {
+ pOutputData->usedDataLen = 0;
+ pOutputData->remainDataLen = pOutputData->dataLen;
+ } else {
+ pSECComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent,
+ pSECComponent->callbackData,
+ OMX_EventError, ret, 0, NULL);
+ }
+ } else {
+ pInputData->previousDataLen = pInputData->dataLen;
+ pInputData->usedDataLen += pInputData->dataLen;
+ pInputData->remainDataLen = pInputData->dataLen - pInputData->usedDataLen;
+ pInputData->dataLen -= pInputData->usedDataLen;
+ pInputData->usedDataLen = 0;
+
+ pOutputData->usedDataLen = 0;
+ pOutputData->remainDataLen = pOutputData->dataLen;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, OMX_STRING componentName)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+ SEC_MPEG4_HANDLE *pMpeg4Dec = NULL;
+ OMX_S32 codecType = -1;
+ int i = 0;
+
+ FunctionIn();
+
+ if ((hComponent == NULL) || (componentName == NULL)) {
+ ret = OMX_ErrorBadParameter;
+ SEC_OSAL_Log(SEC_LOG_ERROR, "%s: parameters are null, ret: %X", __FUNCTION__, ret);
+ goto EXIT;
+ }
+ if (SEC_OSAL_Strcmp(SEC_OMX_COMPONENT_MPEG4_DEC, componentName) == 0) {
+ codecType = CODEC_TYPE_MPEG4;
+ } else if (SEC_OSAL_Strcmp(SEC_OMX_COMPONENT_H263_DEC, componentName) == 0) {
+ codecType = CODEC_TYPE_H263;
+ } else {
+ ret = OMX_ErrorBadParameter;
+ SEC_OSAL_Log(SEC_LOG_ERROR, "%s: componentName(%s) error, ret: %X", __FUNCTION__, ret);
+ goto EXIT;
+ }
+
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = SEC_OMX_VideoDecodeComponentInit(pOMXComponent);
+ if (ret != OMX_ErrorNone) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "%s: SEC_OMX_VideoDecodeComponentInit error, ret: %X", __FUNCTION__, ret);
+ goto EXIT;
+ }
+ pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ pSECComponent->codecType = HW_VIDEO_CODEC;
+
+ pSECComponent->componentName = (OMX_STRING)SEC_OSAL_Malloc(MAX_OMX_COMPONENT_NAME_SIZE);
+ if (pSECComponent->componentName == NULL) {
+ SEC_OMX_VideoDecodeComponentDeinit(pOMXComponent);
+ ret = OMX_ErrorInsufficientResources;
+ SEC_OSAL_Log(SEC_LOG_ERROR, "%s: componentName alloc error, ret: %X", __FUNCTION__, ret);
+ goto EXIT;
+ }
+ SEC_OSAL_Memset(pSECComponent->componentName, 0, MAX_OMX_COMPONENT_NAME_SIZE);
+
+ pMpeg4Dec = SEC_OSAL_Malloc(sizeof(SEC_MPEG4_HANDLE));
+ if (pMpeg4Dec == NULL) {
+ SEC_OMX_VideoDecodeComponentDeinit(pOMXComponent);
+ ret = OMX_ErrorInsufficientResources;
+ SEC_OSAL_Log(SEC_LOG_ERROR, "%s: SEC_MPEG4_HANDLE alloc error, ret: %X", __FUNCTION__, ret);
+ goto EXIT;
+ }
+ SEC_OSAL_Memset(pMpeg4Dec, 0, sizeof(SEC_MPEG4_HANDLE));
+ pSECComponent->hCodecHandle = (OMX_HANDLETYPE)pMpeg4Dec;
+ pMpeg4Dec->hMFCMpeg4Handle.codecType = codecType;
+
+ if (codecType == CODEC_TYPE_MPEG4)
+ SEC_OSAL_Strcpy(pSECComponent->componentName, SEC_OMX_COMPONENT_MPEG4_DEC);
+ else
+ SEC_OSAL_Strcpy(pSECComponent->componentName, SEC_OMX_COMPONENT_H263_DEC);
+
+ /* Set componentVersion */
+ pSECComponent->componentVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER;
+ pSECComponent->componentVersion.s.nVersionMinor = VERSIONMINOR_NUMBER;
+ pSECComponent->componentVersion.s.nRevision = REVISION_NUMBER;
+ pSECComponent->componentVersion.s.nStep = STEP_NUMBER;
+ /* Set specVersion */
+ pSECComponent->specVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER;
+ pSECComponent->specVersion.s.nVersionMinor = VERSIONMINOR_NUMBER;
+ pSECComponent->specVersion.s.nRevision = REVISION_NUMBER;
+ pSECComponent->specVersion.s.nStep = STEP_NUMBER;
+
+ /* Android CapabilityFlags */
+ pSECComponent->capabilityFlags.iIsOMXComponentMultiThreaded = OMX_TRUE;
+ pSECComponent->capabilityFlags.iOMXComponentSupportsExternalInputBufferAlloc = OMX_TRUE;
+ pSECComponent->capabilityFlags.iOMXComponentSupportsExternalOutputBufferAlloc = OMX_TRUE;
+ pSECComponent->capabilityFlags.iOMXComponentSupportsMovableInputBuffers = OMX_FALSE;
+ pSECComponent->capabilityFlags.iOMXComponentSupportsPartialFrames = OMX_FALSE;
+ pSECComponent->capabilityFlags.iOMXComponentUsesNALStartCodes = OMX_TRUE;
+ pSECComponent->capabilityFlags.iOMXComponentCanHandleIncompleteFrames = OMX_TRUE;
+ pSECComponent->capabilityFlags.iOMXComponentUsesFullAVCFrames = OMX_TRUE;
+
+ /* Input port */
+ pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ pSECPort->portDefinition.format.video.nFrameWidth = DEFAULT_FRAME_WIDTH;
+ pSECPort->portDefinition.format.video.nFrameHeight= DEFAULT_FRAME_HEIGHT;
+ pSECPort->portDefinition.format.video.nStride = 0;
+ pSECPort->portDefinition.format.video.nSliceHeight = 0;
+ pSECPort->portDefinition.nBufferSize = DEFAULT_VIDEO_INPUT_BUFFER_SIZE;
+ if (codecType == CODEC_TYPE_MPEG4) {
+ pSECPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingMPEG4;
+ SEC_OSAL_Memset(pSECPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE);
+ SEC_OSAL_Strcpy(pSECPort->portDefinition.format.video.cMIMEType, "video/mpeg4");
+ } else {
+ pSECPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingH263;
+ SEC_OSAL_Memset(pSECPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE);
+ SEC_OSAL_Strcpy(pSECPort->portDefinition.format.video.cMIMEType, "video/h263");
+ }
+ pSECPort->portDefinition.format.video.pNativeRender = 0;
+ pSECPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE;
+ pSECPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatUnused;
+ pSECPort->portDefinition.bEnabled = OMX_TRUE;
+
+ /* Output port */
+ pSECPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+ pSECPort->portDefinition.format.video.nFrameWidth = DEFAULT_FRAME_WIDTH;
+ pSECPort->portDefinition.format.video.nFrameHeight= DEFAULT_FRAME_HEIGHT;
+ pSECPort->portDefinition.format.video.nStride = 0;
+ pSECPort->portDefinition.format.video.nSliceHeight = 0;
+ pSECPort->portDefinition.nBufferSize = DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE;
+ pSECPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
+ SEC_OSAL_Memset(pSECPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE);
+ SEC_OSAL_Strcpy(pSECPort->portDefinition.format.video.cMIMEType, "raw/video");
+ pSECPort->portDefinition.format.video.pNativeRender = 0;
+ pSECPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE;
+ pSECPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
+ pSECPort->portDefinition.bEnabled = OMX_TRUE;
+
+ if (codecType == CODEC_TYPE_MPEG4) {
+ for(i = 0; i < ALL_PORT_NUM; i++) {
+ INIT_SET_SIZE_VERSION(&pMpeg4Dec->mpeg4Component[i], OMX_VIDEO_PARAM_MPEG4TYPE);
+ pMpeg4Dec->mpeg4Component[i].nPortIndex = i;
+ pMpeg4Dec->mpeg4Component[i].eProfile = OMX_VIDEO_MPEG4ProfileSimple;
+ pMpeg4Dec->mpeg4Component[i].eLevel = OMX_VIDEO_MPEG4Level3;
+ }
+ } else {
+ for(i = 0; i < ALL_PORT_NUM; i++) {
+ INIT_SET_SIZE_VERSION(&pMpeg4Dec->h263Component[i], OMX_VIDEO_PARAM_H263TYPE);
+ pMpeg4Dec->h263Component[i].nPortIndex = i;
+ pMpeg4Dec->h263Component[i].eProfile = OMX_VIDEO_H263ProfileBaseline | OMX_VIDEO_H263ProfileISWV2;
+ pMpeg4Dec->h263Component[i].eLevel = OMX_VIDEO_H263Level45;
+ }
+ }
+
+ pOMXComponent->GetParameter = &SEC_MFC_Mpeg4Dec_GetParameter;
+ pOMXComponent->SetParameter = &SEC_MFC_Mpeg4Dec_SetParameter;
+ pOMXComponent->GetConfig = &SEC_MFC_Mpeg4Dec_GetConfig;
+ pOMXComponent->SetConfig = &SEC_MFC_Mpeg4Dec_SetConfig;
+ pOMXComponent->GetExtensionIndex = &SEC_MFC_Mpeg4Dec_GetExtensionIndex;
+ pOMXComponent->ComponentRoleEnum = &SEC_MFC_Mpeg4Dec_ComponentRoleEnum;
+ pOMXComponent->ComponentDeInit = &SEC_OMX_ComponentDeinit;
+
+ pSECComponent->sec_mfc_componentInit = &SEC_MFC_Mpeg4Dec_Init;
+ pSECComponent->sec_mfc_componentTerminate = &SEC_MFC_Mpeg4Dec_Terminate;
+ pSECComponent->sec_mfc_bufferProcess = &SEC_MFC_Mpeg4Dec_bufferProcess;
+ if (codecType == CODEC_TYPE_MPEG4)
+ pSECComponent->sec_checkInputFrame = &Check_Mpeg4_Frame;
+ else
+ pSECComponent->sec_checkInputFrame = &Check_H263_Frame;
+
+ pSECComponent->currentState = OMX_StateLoaded;
+
+ ret = OMX_ErrorNone;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_OMX_ComponentDeinit(OMX_HANDLETYPE hComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+ SEC_MPEG4_HANDLE *pMpeg4Dec = NULL;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ SEC_OSAL_Free(pSECComponent->componentName);
+ pSECComponent->componentName = NULL;
+
+ pMpeg4Dec = (SEC_MPEG4_HANDLE *)pSECComponent->hCodecHandle;
+ if (pMpeg4Dec != NULL) {
+ SEC_OSAL_Free(pMpeg4Dec);
+ pSECComponent->hCodecHandle = NULL;
+ }
+
+ ret = SEC_OMX_VideoDecodeComponentDeinit(pOMXComponent);
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ ret = OMX_ErrorNone;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
diff --git a/exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/SEC_OMX_Mpeg4dec.h b/exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/SEC_OMX_Mpeg4dec.h
new file mode 100644
index 0000000..9af04e3
--- /dev/null
+++ b/exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/SEC_OMX_Mpeg4dec.h
@@ -0,0 +1,98 @@
+/*
+ *
+ * Copyright 2010 Samsung Electronics S.LSI Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file SEC_OMX_Mpeg4dec.h
+ * @brief
+ * @author Yunji Kim (yunji.kim@samsung.com)
+ * @version 1.0
+ * @history
+ * 2010.7.15 : Create
+ */
+
+#ifndef SEC_OMX_MPEG4_DEC_COMPONENT
+#define SEC_OMX_MPEG4_DEC_COMPONENT
+
+#include "SEC_OMX_Def.h"
+#include "OMX_Component.h"
+
+
+typedef enum _CODEC_TYPE
+{
+ CODEC_TYPE_H263,
+ CODEC_TYPE_MPEG4
+} CODEC_TYPE;
+
+/*
+ * This structure is the same as BitmapInfoHhr struct in pv_avifile_typedefs.h file
+ */
+typedef struct _BitmapInfoHhr
+{
+ OMX_U32 BiSize;
+ OMX_U32 BiWidth;
+ OMX_U32 BiHeight;
+ OMX_U16 BiPlanes;
+ OMX_U16 BiBitCount;
+ OMX_U32 BiCompression;
+ OMX_U32 BiSizeImage;
+ OMX_U32 BiXPelsPerMeter;
+ OMX_U32 BiYPelsPerMeter;
+ OMX_U32 BiClrUsed;
+ OMX_U32 BiClrImportant;
+} BitmapInfoHhr;
+
+typedef struct _SEC_MFC_MPEG4_HANDLE
+{
+ OMX_HANDLETYPE hMFCHandle;
+ OMX_PTR pMFCStreamBuffer;
+ OMX_PTR pMFCStreamPhyBuffer;
+ OMX_U32 indexTimestamp;
+ OMX_BOOL bConfiguredMFC;
+ OMX_BOOL bThumbnailMode;
+ CODEC_TYPE codecType;
+ OMX_S32 returnCodec;
+} SEC_MFC_MPEG4_HANDLE;
+
+typedef struct _SEC_MPEG4_HANDLE
+{
+ /* OMX Codec specific */
+ OMX_VIDEO_PARAM_H263TYPE h263Component[ALL_PORT_NUM];
+ OMX_VIDEO_PARAM_MPEG4TYPE mpeg4Component[ALL_PORT_NUM];
+ OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE errorCorrectionType[ALL_PORT_NUM];
+
+ /* SEC MFC Codec specific */
+ SEC_MFC_MPEG4_HANDLE hMFCMpeg4Handle;
+
+ /* For Non-Block mode */
+ SEC_MFC_NBDEC_THREAD NBDecThread;
+ OMX_BOOL bFirstFrame;
+ MFC_DEC_INPUT_BUFFER MFCDecInputBuffer[MFC_INPUT_BUFFER_NUM_MAX];
+ OMX_U32 indexInputBuffer;
+} SEC_MPEG4_HANDLE;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, OMX_STRING componentName);
+ OMX_ERRORTYPE SEC_OMX_ComponentDeinit(OMX_HANDLETYPE hComponent);
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif
diff --git a/exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/library_register.c b/exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/library_register.c
new file mode 100644
index 0000000..02d8d39
--- /dev/null
+++ b/exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/library_register.c
@@ -0,0 +1,63 @@
+/*
+ *
+ * Copyright 2010 Samsung Electronics S.LSI Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file library_register.c
+ * @brief
+ * @author Yunji Kim (yunji.kim@samsung.com)
+ * @version 1.0
+ * @history
+ * 2010.7.15 : Create
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dlfcn.h>
+
+#include "SEC_OSAL_Memory.h"
+#include "SEC_OSAL_ETC.h"
+#include "library_register.h"
+
+#undef SEC_LOG_TAG
+#define SEC_LOG_TAG "SEC_MPEG4_DEC"
+#define SEC_LOG_OFF
+#include "SEC_OSAL_Log.h"
+
+
+OSCL_EXPORT_REF int SEC_OMX_COMPONENT_Library_Register(SECRegisterComponentType **ppSECComponent)
+{
+ FunctionIn();
+
+ if (ppSECComponent == NULL)
+ goto EXIT;
+
+ /* component 1 - video decoder MPEG4 */
+ SEC_OSAL_Strcpy(ppSECComponent[0]->componentName, SEC_OMX_COMPONENT_MPEG4_DEC);
+ SEC_OSAL_Strcpy(ppSECComponent[0]->roles[0], SEC_OMX_COMPONENT_MPEG4_DEC_ROLE);
+ ppSECComponent[0]->totalRoleNum = MAX_COMPONENT_ROLE_NUM;
+
+ /* component 2 - video decoder H.263 */
+ SEC_OSAL_Strcpy(ppSECComponent[1]->componentName, SEC_OMX_COMPONENT_H263_DEC);
+ SEC_OSAL_Strcpy(ppSECComponent[1]->roles[0], SEC_OMX_COMPONENT_H263_DEC_ROLE);
+ ppSECComponent[1]->totalRoleNum = MAX_COMPONENT_ROLE_NUM;
+
+EXIT:
+ FunctionOut();
+ return MAX_COMPONENT_NUM;
+}
+
diff --git a/exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/library_register.h b/exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/library_register.h
new file mode 100644
index 0000000..c3e5b9c
--- /dev/null
+++ b/exynos3/s5pc110/sec_mm/sec_omx/sec_omx_component/video/dec/mpeg4dec/library_register.h
@@ -0,0 +1,59 @@
+/*
+ *
+ * Copyright 2010 Samsung Electronics S.LSI Co. LTD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * @file library_register.h
+ * @brief
+ * @author Yunji Kim (yunji.kim@samsung.com)
+ * @version 1.0
+ * @history
+ * 2010.7.15 : Create
+ */
+
+#ifndef SEC_OMX_MPEG4_DEC_REG
+#define SEC_OMX_MPEG4_DEC_REG
+
+#include "SEC_OMX_Def.h"
+#include "OMX_Component.h"
+#include "SEC_OMX_Component_Register.h"
+
+
+#define OSCL_EXPORT_REF __attribute__((visibility("default")))
+#define MAX_COMPONENT_NUM 2
+#define MAX_COMPONENT_ROLE_NUM 1
+
+/* MPEG4 */
+#define SEC_OMX_COMPONENT_MPEG4_DEC "OMX.SEC.MPEG4.Decoder"
+#define SEC_OMX_COMPONENT_MPEG4_DEC_ROLE "video_decoder.mpeg4"
+
+/* H.263 */
+#define SEC_OMX_COMPONENT_H263_DEC "OMX.SEC.H263.Decoder"
+#define SEC_OMX_COMPONENT_H263_DEC_ROLE "video_decoder.h263"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+OSCL_EXPORT_REF int SEC_OMX_COMPONENT_Library_Register(SECRegisterComponentType **ppSECComponent);
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif
+