summaryrefslogtreecommitdiffstats
path: root/exynos/multimedia/openmax/component/video
diff options
context:
space:
mode:
Diffstat (limited to 'exynos/multimedia/openmax/component/video')
-rw-r--r--exynos/multimedia/openmax/component/video/dec/Android.mk23
-rw-r--r--exynos/multimedia/openmax/component/video/dec/SEC_OMX_Vdec.c1505
-rw-r--r--exynos/multimedia/openmax/component/video/dec/SEC_OMX_Vdec.h153
-rw-r--r--exynos/multimedia/openmax/component/video/dec/h264/Android.mk58
-rw-r--r--exynos/multimedia/openmax/component/video/dec/h264/SEC_OMX_H264dec.c2067
-rw-r--r--exynos/multimedia/openmax/component/video/dec/h264/SEC_OMX_H264dec.h79
-rw-r--r--exynos/multimedia/openmax/component/video/dec/h264/library_register.c60
-rw-r--r--exynos/multimedia/openmax/component/video/dec/h264/library_register.h56
-rw-r--r--exynos/multimedia/openmax/component/video/dec/mpeg4/Android.mk52
-rw-r--r--exynos/multimedia/openmax/component/video/dec/mpeg4/SEC_OMX_Mpeg4dec.c2048
-rw-r--r--exynos/multimedia/openmax/component/video/dec/mpeg4/SEC_OMX_Mpeg4dec.h97
-rw-r--r--exynos/multimedia/openmax/component/video/dec/mpeg4/library_register.c63
-rw-r--r--exynos/multimedia/openmax/component/video/dec/mpeg4/library_register.h59
-rw-r--r--exynos/multimedia/openmax/component/video/dec/vc1/Android.mk52
-rw-r--r--exynos/multimedia/openmax/component/video/dec/vc1/SEC_OMX_Wmvdec.c1960
-rw-r--r--exynos/multimedia/openmax/component/video/dec/vc1/SEC_OMX_Wmvdec.h99
-rw-r--r--exynos/multimedia/openmax/component/video/dec/vc1/library_register.c57
-rw-r--r--exynos/multimedia/openmax/component/video/dec/vc1/library_register.h52
-rw-r--r--exynos/multimedia/openmax/component/video/dec/vp8/Android.mk47
-rw-r--r--exynos/multimedia/openmax/component/video/dec/vp8/SEC_OMX_Vp8dec.c1547
-rw-r--r--exynos/multimedia/openmax/component/video/dec/vp8/SEC_OMX_Vp8dec.h66
-rw-r--r--exynos/multimedia/openmax/component/video/dec/vp8/library_register.c58
-rw-r--r--exynos/multimedia/openmax/component/video/dec/vp8/library_register.h54
-rw-r--r--exynos/multimedia/openmax/component/video/enc/Android.mk27
-rw-r--r--exynos/multimedia/openmax/component/video/enc/SEC_OMX_Venc.c1802
-rw-r--r--exynos/multimedia/openmax/component/video/enc/SEC_OMX_Venc.h163
-rw-r--r--exynos/multimedia/openmax/component/video/enc/h264/Android.mk39
-rw-r--r--exynos/multimedia/openmax/component/video/enc/h264/SEC_OMX_H264enc.c1582
-rw-r--r--exynos/multimedia/openmax/component/video/enc/h264/SEC_OMX_H264enc.h77
-rw-r--r--exynos/multimedia/openmax/component/video/enc/h264/library_register.c55
-rw-r--r--exynos/multimedia/openmax/component/video/enc/h264/library_register.h55
-rw-r--r--exynos/multimedia/openmax/component/video/enc/mpeg4/Android.mk39
-rw-r--r--exynos/multimedia/openmax/component/video/enc/mpeg4/SEC_OMX_Mpeg4enc.c1774
-rw-r--r--exynos/multimedia/openmax/component/video/enc/mpeg4/SEC_OMX_Mpeg4enc.h77
-rw-r--r--exynos/multimedia/openmax/component/video/enc/mpeg4/library_register.c64
-rw-r--r--exynos/multimedia/openmax/component/video/enc/mpeg4/library_register.h59
36 files changed, 16125 insertions, 0 deletions
diff --git a/exynos/multimedia/openmax/component/video/dec/Android.mk b/exynos/multimedia/openmax/component/video/dec/Android.mk
new file mode 100644
index 0000000..349be6f
--- /dev/null
+++ b/exynos/multimedia/openmax/component/video/dec/Android.mk
@@ -0,0 +1,23 @@
+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)/osal \
+ $(SEC_OMX_TOP)/core \
+ $(SEC_OMX_COMPONENT)/common \
+ $(SEC_OMX_COMPONENT)/video/dec
+
+ifeq ($(BOARD_USE_ANB), true)
+LOCAL_STATIC_LIBRARIES := libsecosal
+LOCAL_CFLAGS += -DUSE_ANB
+endif
+
+include $(BUILD_STATIC_LIBRARY)
diff --git a/exynos/multimedia/openmax/component/video/dec/SEC_OMX_Vdec.c b/exynos/multimedia/openmax/component/video/dec/SEC_OMX_Vdec.c
new file mode 100644
index 0000000..80d2a50
--- /dev/null
+++ b/exynos/multimedia/openmax/component/video/dec/SEC_OMX_Vdec.c
@@ -0,0 +1,1505 @@
+/*
+ *
+ * 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.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 "SEC_OSAL_Semaphore.h"
+#include "SEC_OSAL_Mutex.h"
+#include "SEC_OSAL_ETC.h"
+
+#ifdef USE_ANB
+#include "SEC_OSAL_Android.h"
+#endif
+
+#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_FormatNV12TPhysicalAddress:
+ case OMX_SEC_COLOR_FormatANBYUV420SemiPlanar:
+ if (width && height)
+ secOutputPort->portDefinition.nBufferSize = (width * height * 3) / 2;
+ break;
+ case OMX_SEC_COLOR_FormatNV12Tiled:
+ width = secOutputPort->portDefinition.format.video.nFrameWidth;
+ height = secOutputPort->portDefinition.format.video.nFrameHeight;
+ if (width && height) {
+ secOutputPort->portDefinition.nBufferSize =
+ ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height)) \
+ + ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height/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;
+ OMX_U32 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;
+ OMX_U32 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;
+ OMX_U32 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_SignalWait(pSECComponent->pauseEvent, DEF_MAX_WAIT_TIME);
+ SEC_OSAL_SignalReset(pSECComponent->pauseEvent);
+ }
+
+ 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_SignalWait(pSECComponent->pauseEvent, DEF_MAX_WAIT_TIME);
+ SEC_OSAL_SignalReset(pSECComponent->pauseEvent);
+ }
+
+ /* 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;
+ SEC_OSAL_Log(SEC_LOG_TRACE, "first frame timestamp after seeking %lld us (%.2f secs)",
+ inputData->timeStamp, inputData->timeStamp / 1E6);
+ }
+
+ 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_BASEPORT *secOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+ 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");
+
+ ret = OMX_FALSE;
+
+ /* reset outputData */
+ SEC_DataReset(pOMXComponent, OUTPUT_PORT_INDEX);
+ }
+ } 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_VIDEODEC_COMPONENT *pVideoDec = (SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle;
+ 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_SignalWait(pSECComponent->pauseEvent, DEF_MAX_WAIT_TIME);
+ SEC_OSAL_SignalReset(pSECComponent->pauseEvent);
+ }
+
+ 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_ErrorInvalidState;
+ 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;
+ portFormat->xFramerate = portDefinition->format.video.xFramerate;
+ break;
+ case supportFormat_1:
+ portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
+ portFormat->eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
+ 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;
+ case supportFormat_3:
+ portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
+ portFormat->eColorFormat = OMX_SEC_COLOR_FormatNV12Tiled;
+ portFormat->xFramerate = portDefinition->format.video.xFramerate;
+ break;
+ }
+ }
+ ret = OMX_ErrorNone;
+ }
+ break;
+#ifdef USE_ANB
+ case OMX_IndexParamGetAndroidNativeBuffer:
+ {
+ ret = SEC_OSAL_GetANBParameter(hComponent, nParamIndex, 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_ErrorInvalidState;
+ 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;
+#ifdef USE_ANB
+ case OMX_IndexParamEnableAndroidBuffers:
+ case OMX_IndexParamUseAndroidNativeBuffer:
+ {
+ ret = SEC_OSAL_SetANBParameter(hComponent, nIndex, ComponentParameterStructure);
+ }
+ break;
+#endif
+ default:
+ {
+ ret = SEC_OMX_SetParameter(hComponent, nIndex, ComponentParameterStructure);
+ }
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_OMX_VideoDecodeGetConfig(
+ 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_OMX_VideoDecodeSetConfig(
+ 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_OMX_VIDEODEC_COMPONENT *pVideoDec = (SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle;
+ pVideoDec->bThumbnailMode = *((OMX_BOOL *)pComponentConfigStructure);
+
+ ret = OMX_ErrorNone;
+ }
+ break;
+ default:
+ ret = SEC_OMX_SetConfig(hComponent, nIndex, pComponentConfigStructure);
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_OMX_VideoDecodeGetExtensionIndex(
+ 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;
+ }
+
+#ifdef USE_ANB
+ if (SEC_OSAL_Strcmp(cParameterName, SEC_INDEX_PARAM_ENABLE_ANB) == 0)
+ *pIndexType = (OMX_INDEXTYPE) OMX_IndexParamEnableAndroidBuffers;
+ else if (SEC_OSAL_Strcmp(cParameterName, SEC_INDEX_PARAM_GET_ANB) == 0)
+ *pIndexType = (OMX_INDEXTYPE) OMX_IndexParamGetAndroidNativeBuffer;
+ else if (SEC_OSAL_Strcmp(cParameterName, SEC_INDEX_PARAM_USE_ANB) == 0)
+ *pIndexType = (OMX_INDEXTYPE) OMX_IndexParamUseAndroidNativeBuffer;
+ else
+ ret = SEC_OMX_GetExtensionIndex(hComponent, cParameterName, pIndexType);
+#else
+ ret = SEC_OMX_GetExtensionIndex(hComponent, cParameterName, pIndexType);
+#endif
+
+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;
+ SEC_OMX_VIDEODEC_COMPONENT *pVideoDec = 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;
+
+ pVideoDec = SEC_OSAL_Malloc(sizeof(SEC_OMX_VIDEODEC_COMPONENT));
+ if (pVideoDec == NULL) {
+ SEC_OMX_BaseComponent_Destructor(pOMXComponent);
+ ret = OMX_ErrorInsufficientResources;
+ SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__);
+ goto EXIT;
+ }
+
+ SEC_OSAL_Memset(pVideoDec, 0, sizeof(SEC_OMX_VIDEODEC_COMPONENT));
+ pSECComponent->hComponentHandle = (OMX_HANDLETYPE)pVideoDec;
+
+ 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;
+ SEC_OMX_VIDEODEC_COMPONENT *pVideoDec = 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;
+
+ pVideoDec = (SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle;
+ SEC_OSAL_Free(pVideoDec);
+ pSECComponent->hComponentHandle = pVideoDec = NULL;
+
+ 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/exynos/multimedia/openmax/component/video/dec/SEC_OMX_Vdec.h b/exynos/multimedia/openmax/component/video/dec/SEC_OMX_Vdec.h
new file mode 100644
index 0000000..806ad44
--- /dev/null
+++ b/exynos/multimedia/openmax/component/video/dec/SEC_OMX_Vdec.h
@@ -0,0 +1,153 @@
+/*
+ *
+ * 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.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"
+#include "SEC_OMX_Basecomponent.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 1024 * 1024 * MFC_INPUT_BUFFER_NUM_MAX /*DEFAULT_VIDEO_INPUT_BUFFER_SIZE*/
+
+#define INPUT_PORT_SUPPORTFORMAT_NUM_MAX 1
+#define OUTPUT_PORT_SUPPORTFORMAT_NUM_MAX 4
+
+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;
+
+typedef struct _SEC_OMX_VIDEODEC_COMPONENT
+{
+ OMX_HANDLETYPE hCodecHandle;
+ SEC_MFC_NBDEC_THREAD NBDecThread;
+
+ OMX_BOOL bThumbnailMode;
+ OMX_BOOL bFirstFrame;
+ MFC_DEC_INPUT_BUFFER MFCDecInputBuffer[MFC_INPUT_BUFFER_NUM_MAX];
+ OMX_U32 indexInputBuffer;
+} SEC_OMX_VIDEODEC_COMPONENT;
+
+
+#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_VideoDecodeGetConfig(
+ OMX_HANDLETYPE hComponent,
+ OMX_INDEXTYPE nIndex,
+ OMX_PTR pComponentConfigStructure);
+OMX_ERRORTYPE SEC_OMX_VideoDecodeSetConfig(
+ OMX_HANDLETYPE hComponent,
+ OMX_INDEXTYPE nIndex,
+ OMX_PTR pComponentConfigStructure);
+OMX_ERRORTYPE SEC_OMX_VideoDecodeGetExtensionIndex(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_STRING cParameterName,
+ OMX_OUT OMX_INDEXTYPE *pIndexType);
+OMX_ERRORTYPE SEC_OMX_VideoDecodeComponentInit(OMX_IN OMX_HANDLETYPE hComponent);
+OMX_ERRORTYPE SEC_OMX_VideoDecodeComponentDeinit(OMX_IN OMX_HANDLETYPE hComponent);
+OMX_BOOL SEC_Check_BufferProcess_State(SEC_OMX_BASECOMPONENT *pSECComponent);
+inline void SEC_UpdateFrameSize(OMX_COMPONENTTYPE *pOMXComponent);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/exynos/multimedia/openmax/component/video/dec/h264/Android.mk b/exynos/multimedia/openmax/component/video/dec/h264/Android.mk
new file mode 100644
index 0000000..5ac0170
--- /dev/null
+++ b/exynos/multimedia/openmax/component/video/dec/h264/Android.mk
@@ -0,0 +1,58 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := \
+ SEC_OMX_H264dec.c \
+ library_register.c
+
+LOCAL_PRELINK_MODULE := false
+LOCAL_MODULE := libOMX.SEC.AVC.Decoder
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/omx
+
+LOCAL_CFLAGS :=
+
+ifeq ($(BOARD_NONBLOCK_MODE_PROCESS), true)
+LOCAL_CFLAGS += -DNONBLOCK_MODE_PROCESS
+endif
+
+ifeq ($(BOARD_USE_ANB), true)
+LOCAL_CFLAGS += -DUSE_ANB
+ifeq ($(BOARD_USE_CSC_FIMC), true)
+ifeq ($(BOARD_USE_V4L2_ION), false)
+LOCAL_CFLAGS += -DUSE_CSC_FIMC
+endif
+endif
+endif
+
+ifeq ($(BOARD_USE_V4L2), false)
+ifeq ($(BOARD_USE_S3D_SUPPORT), true)
+LOCAL_CFLAGS += -DS3D_SUPPORT
+endif
+endif
+
+LOCAL_ARM_MODE := arm
+
+LOCAL_STATIC_LIBRARIES := libSEC_OMX_Vdec libsecosal libsecbasecomponent \
+ libseccscapi libsecmfcapi
+LOCAL_SHARED_LIBRARIES := libc libdl libcutils libutils libui \
+ libSEC_OMX_Resourcemanager
+
+ifeq ($(filter-out exynos4,$(TARGET_BOARD_PLATFORM)),)
+LOCAL_SHARED_LIBRARIES += libhwconverter
+endif
+
+#ifeq ($(BOARD_USE_V4L2_ION),true)
+#LOCAL_SHARED_LIBRARIES += libion
+#endif
+
+LOCAL_C_INCLUDES := $(SEC_OMX_INC)/khronos \
+ $(SEC_OMX_INC)/sec \
+ $(SEC_OMX_TOP)/osal \
+ $(SEC_OMX_TOP)/core \
+ $(SEC_OMX_COMPONENT)/common \
+ $(SEC_OMX_COMPONENT)/video/dec \
+ $(TARGET_OUT_HEADERS)/$(SEC_COPY_HEADERS_TO)
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/exynos/multimedia/openmax/component/video/dec/h264/SEC_OMX_H264dec.c b/exynos/multimedia/openmax/component/video/dec/h264/SEC_OMX_H264dec.c
new file mode 100644
index 0000000..5efa041
--- /dev/null
+++ b/exynos/multimedia/openmax/component/video/dec/h264/SEC_OMX_H264dec.c
@@ -0,0 +1,2067 @@
+/*
+ *
+ * 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.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 "SEC_OSAL_ETC.h"
+#include "SEC_OSAL_Semaphore.h"
+#include "SEC_OSAL_Thread.h"
+#include "library_register.h"
+#include "SEC_OMX_H264dec.h"
+#include "SsbSipMfcApi.h"
+#include "color_space_convertor.h"
+
+#ifdef USE_ANB
+#include "SEC_OSAL_Android.h"
+#endif
+
+/* To use CSC FIMC in SEC OMX, gralloc should allocate physical memory using FIMC */
+/* It means GRALLOC_USAGE_HW_FIMC1 should be set on Native Window usage */
+#ifdef USE_CSC_FIMC
+#include "csc_fimc.h"
+#endif
+
+#undef SEC_LOG_TAG
+#define SEC_LOG_TAG "SEC_H264_DEC"
+#define SEC_LOG_OFF
+#include "SEC_OSAL_Log.h"
+
+#define H264_DEC_NUM_OF_EXTRA_BUFFERS 7
+
+#ifdef S3D_SUPPORT
+#define ADD_SPS_PPS_I_FRAME
+#else
+//#define ADD_SPS_PPS_I_FRAME
+#endif
+//#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_AVCProfileBaseline, OMX_VIDEO_AVCLevel32},
+ {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel4},
+
+ {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_AVCProfileMain, OMX_VIDEO_AVCLevel32},
+ {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel4},
+
+ {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},
+ {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel32},
+ {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel4}};
+
+
+static int Check_H264_Frame(OMX_U8 *pInputStream, OMX_U32 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 == (int)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 == (int)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_ErrorInvalidState;
+ 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 *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->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 *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->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 *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->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_ErrorInvalidState;
+ 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 *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->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;
+ OMX_U32 realWidth, realHeight;
+
+ 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);
+
+ realWidth = pSECPort->portDefinition.format.video.nFrameWidth;
+ realHeight = pSECPort->portDefinition.format.video.nFrameHeight;
+ width = ((realWidth + 15) & (~15));
+ height = ((realHeight + 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;
+ case OMX_SEC_COLOR_FormatNV12Tiled:
+ pSECOutputPort->portDefinition.nBufferSize =
+ ALIGN_TO_8KB(ALIGN_TO_128B(realWidth) * ALIGN_TO_32B(realHeight)) \
+ + ALIGN_TO_8KB(ALIGN_TO_128B(realWidth) * ALIGN_TO_32B(realHeight/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 *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->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 *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->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 *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->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_VideoDecodeGetConfig(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) {
+ default:
+ ret = SEC_OMX_VideoDecodeSetConfig(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 *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+
+ *pIndexType = OMX_IndexVendorThumbnailMode;
+
+ ret = OMX_ErrorNone;
+ } else {
+ ret = SEC_OMX_VideoDecodeGetExtensionIndex(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 = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ SEC_OMX_VIDEODEC_COMPONENT *pVideoDec = (SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle;
+ SEC_H264DEC_HANDLE *pH264Dec = (SEC_H264DEC_HANDLE *)pVideoDec->hCodecHandle;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ while (pVideoDec->NBDecThread.bExitDecodeThread == OMX_FALSE) {
+ SEC_OSAL_SemaphoreWait(pVideoDec->NBDecThread.hDecFrameStart);
+
+ if (pVideoDec->NBDecThread.bExitDecodeThread == OMX_FALSE) {
+ pH264Dec->hMFCH264Handle.returnCodec = SsbSipMfcDecExe(pH264Dec->hMFCH264Handle.hMFCHandle, pVideoDec->NBDecThread.oneFrameSize);
+ SEC_OSAL_SemaphorePost(pVideoDec->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_OMX_VIDEODEC_COMPONENT *pVideoDec = (SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle;
+ SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+ SEC_H264DEC_HANDLE *pH264Dec = NULL;
+ OMX_PTR hMFCHandle = NULL;
+ OMX_PTR pStreamBuffer = NULL;
+ OMX_PTR pStreamPhyBuffer = NULL;
+#ifdef S3D_SUPPORT
+ OMX_S32 setConfVal = 0;
+#endif
+
+ pH264Dec = (SEC_H264DEC_HANDLE *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->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 */
+ if (pSECOutputPort->portDefinition.format.video.eColorFormat == OMX_SEC_COLOR_FormatNV12TPhysicalAddress) {
+ hMFCHandle = (OMX_PTR)SsbSipMfcDecOpen();
+ } else {
+ SSBIP_MFC_BUFFER_TYPE buf_type = CACHE;
+ hMFCHandle = (OMX_PTR)SsbSipMfcDecOpenExt(&buf_type);
+ }
+
+ if (hMFCHandle == NULL) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ pH264Dec->hMFCH264Handle.hMFCHandle = hMFCHandle;
+
+#ifdef S3D_SUPPORT
+ /*Enable SEI parsing for checking frame_packing S3D*/
+ setConfVal = 1;
+ SsbSipMfcDecSetConfig(hMFCHandle, MFC_DEC_SETCONF_SEI_PARSE, &setConfVal);
+#endif
+
+ /* Allocate decoder's input buffer */
+ /* Get first input buffer */
+ pStreamBuffer = SsbSipMfcDecGetInBuf(hMFCHandle, &pStreamPhyBuffer, DEFAULT_MFC_INPUT_BUFFER_SIZE / 2);
+ if (pStreamBuffer == NULL) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ pVideoDec->MFCDecInputBuffer[0].VirAddr = pStreamBuffer;
+ pVideoDec->MFCDecInputBuffer[0].PhyAddr = pStreamPhyBuffer;
+ pVideoDec->MFCDecInputBuffer[0].bufferSize = DEFAULT_MFC_INPUT_BUFFER_SIZE / 2;
+ pVideoDec->MFCDecInputBuffer[0].dataSize = 0;
+
+#ifdef NONBLOCK_MODE_PROCESS
+ /* Get second input buffer */
+ pStreamBuffer = NULL;
+ pStreamBuffer = SsbSipMfcDecGetInBuf(hMFCHandle, &pStreamPhyBuffer, DEFAULT_MFC_INPUT_BUFFER_SIZE / 2);
+ if (pStreamBuffer == NULL) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ pVideoDec->MFCDecInputBuffer[1].VirAddr = pStreamBuffer;
+ pVideoDec->MFCDecInputBuffer[1].PhyAddr = pStreamPhyBuffer;
+ pVideoDec->MFCDecInputBuffer[1].bufferSize = DEFAULT_MFC_INPUT_BUFFER_SIZE / 2;
+ pVideoDec->MFCDecInputBuffer[1].dataSize = 0;
+ pVideoDec->indexInputBuffer = 0;
+
+ pVideoDec->bFirstFrame = OMX_TRUE;
+
+ pVideoDec->NBDecThread.bExitDecodeThread = OMX_FALSE;
+ pVideoDec->NBDecThread.bDecoderRun = OMX_FALSE;
+ pVideoDec->NBDecThread.oneFrameSize = 0;
+ SEC_OSAL_SemaphoreCreate(&(pVideoDec->NBDecThread.hDecFrameStart));
+ SEC_OSAL_SemaphoreCreate(&(pVideoDec->NBDecThread.hDecFrameEnd));
+ if (OMX_ErrorNone == SEC_OSAL_ThreadCreate(&pVideoDec->NBDecThread.hNBDecodeThread,
+ SEC_MFC_DecodeThread,
+ pOMXComponent)) {
+ pH264Dec->hMFCH264Handle.returnCodec = MFC_RET_OK;
+ }
+#endif
+
+ pH264Dec->hMFCH264Handle.pMFCStreamBuffer = pVideoDec->MFCDecInputBuffer[0].VirAddr;
+ pH264Dec->hMFCH264Handle.pMFCStreamPhyBuffer = pVideoDec->MFCDecInputBuffer[0].PhyAddr;
+ pSECComponent->processData[INPUT_PORT_INDEX].dataBuffer = pVideoDec->MFCDecInputBuffer[0].VirAddr;
+ pSECComponent->processData[INPUT_PORT_INDEX].allocSize = pVideoDec->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;
+ pH264Dec->hMFCH264Handle.outputIndexTimestamp = 0;
+
+ pSECComponent->getAllDelayBuffer = OMX_FALSE;
+
+#ifdef USE_CSC_FIMC
+ pH264Dec->hFIMCHandle = csc_fimc_open();
+#endif
+
+EXIT:
+ FunctionOut();
+
+ 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_OMX_VIDEODEC_COMPONENT *pVideoDec = (SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle;
+ SEC_H264DEC_HANDLE *pH264Dec = NULL;
+ OMX_PTR hMFCHandle = NULL;
+
+ FunctionIn();
+
+ pH264Dec = (SEC_H264DEC_HANDLE *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->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;
+
+#ifdef NONBLOCK_MODE_PROCESS
+ if (pVideoDec->NBDecThread.hNBDecodeThread != NULL) {
+ pVideoDec->NBDecThread.bExitDecodeThread = OMX_TRUE;
+ SEC_OSAL_SemaphorePost(pVideoDec->NBDecThread.hDecFrameStart);
+ SEC_OSAL_ThreadTerminate(pVideoDec->NBDecThread.hNBDecodeThread);
+ pVideoDec->NBDecThread.hNBDecodeThread = NULL;
+ }
+
+ if(pVideoDec->NBDecThread.hDecFrameEnd != NULL) {
+ SEC_OSAL_SemaphoreTerminate(pVideoDec->NBDecThread.hDecFrameEnd);
+ pVideoDec->NBDecThread.hDecFrameEnd = NULL;
+ }
+
+ if(pVideoDec->NBDecThread.hDecFrameStart != NULL) {
+ SEC_OSAL_SemaphoreTerminate(pVideoDec->NBDecThread.hDecFrameStart);
+ pVideoDec->NBDecThread.hDecFrameStart = NULL;
+ }
+#endif
+
+ if (hMFCHandle != NULL) {
+ SsbSipMfcDecClose(hMFCHandle);
+ hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle = NULL;
+ }
+
+#ifdef USE_CSC_FIMC
+ if (pH264Dec->hFIMCHandle != NULL) {
+ csc_fimc_close(pH264Dec->hFIMCHandle);
+ pH264Dec->hFIMCHandle = NULL;
+ }
+#endif
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_H264_Decode_Nonblock(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_OMX_VIDEODEC_COMPONENT *pVideoDec = (SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle;
+ SEC_H264DEC_HANDLE *pH264Dec = (SEC_H264DEC_HANDLE *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ SEC_OMX_BASEPORT *pSECInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+ OMX_U32 oneFrameSize = pInputData->dataLen;
+ SSBSIP_MFC_DEC_OUTPUT_INFO outputInfo;
+ OMX_S32 setConfVal = 0;
+ int bufWidth = 0;
+ int bufHeight = 0;
+ OMX_U32 FrameBufferYSize = 0;
+ OMX_U32 FrameBufferUVSize = 0;
+ OMX_BOOL outputDataValid = OMX_FALSE;
+#ifdef S3D_SUPPORT
+ SSBSIP_MFC_FRAME_PACKING frame_packing;
+#endif
+
+ 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;
+ }
+
+ /* Default number in the driver is optimized */
+ if (pVideoDec->bThumbnailMode == OMX_TRUE) {
+ setConfVal = 0;
+ SsbSipMfcDecSetConfig(pH264Dec->hMFCH264Handle.hMFCHandle, MFC_DEC_SETCONF_DISPLAY_DELAY, &setConfVal);
+ } else {
+ setConfVal = H264_DEC_NUM_OF_EXTRA_BUFFERS;
+ SsbSipMfcDecSetConfig(pH264Dec->hMFCH264Handle.hMFCHandle, MFC_DEC_SETCONF_EXTRA_BUFFER_NUM, &setConfVal);
+
+ setConfVal = 8;
+ SsbSipMfcDecSetConfig(pH264Dec->hMFCH264Handle.hMFCHandle, MFC_DEC_SETCONF_DISPLAY_DELAY, &setConfVal);
+ }
+
+ SsbSipMfcDecSetInBuf(pH264Dec->hMFCH264Handle.hMFCHandle,
+ pH264Dec->hMFCH264Handle.pMFCStreamPhyBuffer,
+ pH264Dec->hMFCH264Handle.pMFCStreamBuffer,
+ pSECComponent->processData[INPUT_PORT_INDEX].allocSize);
+
+ 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;
+
+ SsbSipMfcDecGetConfig(pH264Dec->hMFCH264Handle.hMFCHandle, MFC_DEC_GETCONF_BUF_WIDTH_HEIGHT, &imgResol);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "set width height information : %d, %d",
+ pSECInputPort->portDefinition.format.video.nFrameWidth,
+ pSECInputPort->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);
+
+ pSECOutputPort->cropRectangle.nTop = cropInfo.crop_top_offset;
+ pSECOutputPort->cropRectangle.nLeft = cropInfo.crop_left_offset;
+ pSECOutputPort->cropRectangle.nWidth = imgResol.width - cropInfo.crop_left_offset - cropInfo.crop_right_offset;
+ pSECOutputPort->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 */
+ pSECInputPort->portDefinition.format.video.nFrameWidth = imgResol.width;
+ pSECInputPort->portDefinition.format.video.nFrameHeight = imgResol.height;
+ pSECInputPort->portDefinition.format.video.nStride = ((imgResol.width + 15) & (~15));
+ pSECInputPort->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);
+ }
+ if ((pSECInputPort->portDefinition.format.video.nFrameWidth != (unsigned int)imgResol.width) ||
+ (pSECInputPort->portDefinition.format.video.nFrameHeight != (unsigned int)imgResol.height)) {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "change width height information : OMX_EventPortSettingsChanged");
+
+ /* change width and height information */
+ pSECInputPort->portDefinition.format.video.nFrameWidth = imgResol.width;
+ pSECInputPort->portDefinition.format.video.nFrameHeight = imgResol.height;
+ pSECInputPort->portDefinition.format.video.nStride = ((imgResol.width + 15) & (~15));
+ pSECInputPort->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) &&
+ (pVideoDec->bFirstFrame == OMX_FALSE)) {
+ SSBSIP_MFC_DEC_OUTBUF_STATUS status;
+ OMX_S32 indexTimestamp = 0;
+
+ /* wait for mfc decode done */
+ if (pVideoDec->NBDecThread.bDecoderRun == OMX_TRUE) {
+ SEC_OSAL_SemaphoreWait(pVideoDec->NBDecThread.hDecFrameEnd);
+ pVideoDec->NBDecThread.bDecoderRun = OMX_FALSE;
+ }
+
+ SEC_OSAL_SleepMillisec(0);
+ status = SsbSipMfcDecGetOutBuf(pH264Dec->hMFCH264Handle.hMFCHandle, &outputInfo);
+ bufWidth = (outputInfo.img_width + 15) & (~15);
+ bufHeight = (outputInfo.img_height + 15) & (~15);
+ FrameBufferYSize = ALIGN_TO_8KB(ALIGN_TO_128B(outputInfo.img_width) * ALIGN_TO_32B(outputInfo.img_height));
+ FrameBufferUVSize = ALIGN_TO_8KB(ALIGN_TO_128B(outputInfo.img_width) * ALIGN_TO_32B(outputInfo.img_height/2));
+
+#ifdef S3D_SUPPORT
+ /* Check Whether frame packing information is available */
+ SsbSipMfcDecGetConfig(pH264Dec->hMFCH264Handle.hMFCHandle, MFC_DEC_GETCONF_FRAME_PACKING, &frame_packing);
+
+ if (pVideoDec->bThumbnailMode == OMX_FALSE &&
+ frame_packing.available &&
+ pH264Dec->hMFCH264Handle.bS3DMode == OMX_FALSE) {
+
+ SEC_OSAL_Log(SEC_LOG_TRACE, "arrangement ID: 0x%08x", frame_packing.arrangement_id);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "arrangement_type: %d", frame_packing.arrangement_type);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "content_interpretation_type: %d", frame_packing.content_interpretation_type);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "current_frame_is_frame0_flag: %d", frame_packing.current_frame_is_frame0_flag);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "spatial_flipping_flag: %d", frame_packing.spatial_flipping_flag);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "fr0X:%d fr0Y:%d fr0X:%d fr0Y:%d", frame_packing.frame0_grid_pos_x,
+ frame_packing.frame0_grid_pos_y, frame_packing.frame1_grid_pos_x, frame_packing.frame1_grid_pos_y);
+
+ /* Change Outport eColorFormat based on Framepacking information*/
+ if (frame_packing.arrangement_type == 3) {
+ if (frame_packing.content_interpretation_type == 1) {
+ switch (pSECOutputPort->portDefinition.format.video.eColorFormat) {
+ case OMX_SEC_COLOR_FormatNV12Tiled:
+ pSECOutputPort->portDefinition.format.video.eColorFormat = OMX_SEC_COLOR_FormatNV12Tiled_SBS_LR;
+ break;
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ case OMX_SEC_COLOR_FormatANBYUV420SemiPlanar:
+ pSECOutputPort->portDefinition.format.video.eColorFormat = OMX_SEC_COLOR_FormatYUV420SemiPlanar_SBS_LR;
+ break;
+ case OMX_COLOR_FormatYUV420Planar:
+ default:
+ pSECOutputPort->portDefinition.format.video.eColorFormat = OMX_SEC_COLOR_FormatYUV420Planar_SBS_LR;
+ break;
+ }
+ } else if (frame_packing.content_interpretation_type == 2) {
+ switch (pSECOutputPort->portDefinition.format.video.eColorFormat) {
+ case OMX_SEC_COLOR_FormatNV12Tiled:
+ pSECOutputPort->portDefinition.format.video.eColorFormat = OMX_SEC_COLOR_FormatNV12Tiled_SBS_RL;
+ break;
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ case OMX_SEC_COLOR_FormatANBYUV420SemiPlanar:
+ pSECOutputPort->portDefinition.format.video.eColorFormat = OMX_SEC_COLOR_FormatYUV420SemiPlanar_SBS_RL;
+ break;
+ case OMX_COLOR_FormatYUV420Planar:
+ default:
+ pSECOutputPort->portDefinition.format.video.eColorFormat = OMX_SEC_COLOR_FormatYUV420Planar_SBS_RL;
+ break;
+ }
+ }
+ } else if (frame_packing.arrangement_type == 4) {
+ if (frame_packing.content_interpretation_type == 1) {
+ switch (pSECOutputPort->portDefinition.format.video.eColorFormat) {
+ case OMX_SEC_COLOR_FormatNV12Tiled:
+ pSECOutputPort->portDefinition.format.video.eColorFormat = OMX_SEC_COLOR_FormatNV12Tiled_TB_LR;
+ break;
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ case OMX_SEC_COLOR_FormatANBYUV420SemiPlanar:
+ pSECOutputPort->portDefinition.format.video.eColorFormat = OMX_SEC_COLOR_FormatYUV420SemiPlanar_TB_LR;
+ break;
+ case OMX_COLOR_FormatYUV420Planar:
+ default:
+ pSECOutputPort->portDefinition.format.video.eColorFormat = OMX_SEC_COLOR_FormatYUV420Planar_TB_LR;
+ break;
+ }
+ } else if (frame_packing.content_interpretation_type == 2) {
+ switch (pSECOutputPort->portDefinition.format.video.eColorFormat) {
+ case OMX_SEC_COLOR_FormatNV12Tiled:
+ pSECOutputPort->portDefinition.format.video.eColorFormat = OMX_SEC_COLOR_FormatNV12Tiled_TB_RL;
+ break;
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ case OMX_SEC_COLOR_FormatANBYUV420SemiPlanar:
+ pSECOutputPort->portDefinition.format.video.eColorFormat = OMX_SEC_COLOR_FormatYUV420SemiPlanar_TB_RL;
+ break;
+ case OMX_COLOR_FormatYUV420Planar:
+ default:
+ pSECOutputPort->portDefinition.format.video.eColorFormat = OMX_SEC_COLOR_FormatYUV420Planar_TB_RL;
+ break;
+ }
+ }
+ }
+
+ /** Send Port Settings changed call back - output color format change */
+ (*(pSECComponent->pCallbacks->EventHandler))
+ (pOMXComponent,
+ pSECComponent->callbackData,
+ OMX_EventPortSettingsChanged, /* The command was completed */
+ OMX_DirOutput, /* This is the port index */
+ 0,
+ NULL);
+
+ if ((pSECOutputPort->cropRectangle.nTop != 0) || (pSECOutputPort->cropRectangle.nLeft != 0)) {
+ /** 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);
+ }
+ pH264Dec->hMFCH264Handle.bS3DMode = OMX_TRUE;
+ SEC_OSAL_SleepMillisec(0);
+ ret = OMX_ErrorInputDataDecodeYet;
+ goto EXIT;
+ }
+#endif
+
+ 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;
+ } else {
+ /* For timestamp correction. if mfc support frametype detect */
+ SEC_OSAL_Log(SEC_LOG_TRACE, "disp_pic_frame_type: %d", outputInfo.disp_pic_frame_type);
+#ifdef NEED_TIMESTAMP_REORDER
+ if ((outputInfo.disp_pic_frame_type == MFC_FRAME_TYPE_I_FRAME) ||
+ (pH264Dec->hMFCH264Handle.bFlashPlayerMode == OMX_TRUE)) {
+ pOutputData->timeStamp = pSECComponent->timeStamp[indexTimestamp];
+ pOutputData->nFlags = pSECComponent->nFlags[indexTimestamp];
+ pH264Dec->hMFCH264Handle.outputIndexTimestamp = indexTimestamp;
+ } else {
+ pOutputData->timeStamp = pSECComponent->timeStamp[pH264Dec->hMFCH264Handle.outputIndexTimestamp];
+ pOutputData->nFlags = pSECComponent->nFlags[pH264Dec->hMFCH264Handle.outputIndexTimestamp];
+ }
+#else
+ pOutputData->timeStamp = pSECComponent->timeStamp[indexTimestamp];
+ pOutputData->nFlags = pSECComponent->nFlags[indexTimestamp];
+#endif
+ 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;
+ pH264Dec->hMFCH264Handle.outputIndexTimestamp++;
+ pH264Dec->hMFCH264Handle.outputIndexTimestamp %= MAX_TIMESTAMP;
+ }
+ 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) {
+ 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 ((pVideoDec->bFirstFrame == OMX_TRUE) &&
+ ((pOutputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) &&
+ ((pInputData->nFlags & OMX_BUFFERFLAG_CODECCONFIG) != OMX_BUFFERFLAG_CODECCONFIG)) {
+ pOutputData->nFlags = (pOutputData->nFlags & (~OMX_BUFFERFLAG_EOS));
+ }
+
+ outputDataValid = OMX_FALSE;
+
+ /* ret = OMX_ErrorUndefined; */
+ ret = OMX_ErrorNone;
+ }
+
+ if (ret == OMX_ErrorInputDataDecodeYet) {
+ pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].dataSize = oneFrameSize;
+ pVideoDec->indexInputBuffer++;
+ pVideoDec->indexInputBuffer %= MFC_INPUT_BUFFER_NUM_MAX;
+ pH264Dec->hMFCH264Handle.pMFCStreamBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].VirAddr;
+ pH264Dec->hMFCH264Handle.pMFCStreamPhyBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].PhyAddr;
+ pSECComponent->processData[INPUT_PORT_INDEX].dataBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].VirAddr;
+ pSECComponent->processData[INPUT_PORT_INDEX].allocSize = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].bufferSize;
+ oneFrameSize = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].dataSize;
+ //pInputData->dataLen = oneFrameSize;
+ //pInputData->remainDataLen = oneFrameSize;
+ }
+
+ if ((Check_H264_StartCode(pInputData->dataBuffer, oneFrameSize) == OMX_TRUE) &&
+ ((pOutputData->nFlags & OMX_BUFFERFLAG_EOS) != OMX_BUFFERFLAG_EOS)) {
+ if ((ret != OMX_ErrorInputDataDecodeYet) || (pSECComponent->getAllDelayBuffer == OMX_TRUE)) {
+ 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);
+
+ pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].dataSize = oneFrameSize;
+ pVideoDec->NBDecThread.oneFrameSize = oneFrameSize;
+
+ /* mfc decode start */
+ SEC_OSAL_SemaphorePost(pVideoDec->NBDecThread.hDecFrameStart);
+ pVideoDec->NBDecThread.bDecoderRun = OMX_TRUE;
+ pH264Dec->hMFCH264Handle.returnCodec = MFC_RET_OK;
+
+ SEC_OSAL_SleepMillisec(0);
+
+ pVideoDec->indexInputBuffer++;
+ pVideoDec->indexInputBuffer %= MFC_INPUT_BUFFER_NUM_MAX;
+ pH264Dec->hMFCH264Handle.pMFCStreamBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].VirAddr;
+ pH264Dec->hMFCH264Handle.pMFCStreamPhyBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].PhyAddr;
+ pSECComponent->processData[INPUT_PORT_INDEX].dataBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].VirAddr;
+ pSECComponent->processData[INPUT_PORT_INDEX].allocSize = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].bufferSize;
+
+ if ((pVideoDec->bFirstFrame == OMX_TRUE) &&
+ (pSECComponent->bSaveFlagEOS == OMX_TRUE) &&
+ (outputDataValid == OMX_FALSE)) {
+ ret = OMX_ErrorInputDataDecodeYet;
+ }
+
+ pVideoDec->bFirstFrame = OMX_FALSE;
+ } else {
+ if (pSECComponent->checkTimeStamp.needCheckStartTimeStamp == OMX_TRUE)
+ pSECComponent->checkTimeStamp.needSetStartTimeStamp = OMX_TRUE;
+ }
+
+ /** Fill Output Buffer **/
+ if (outputDataValid == OMX_TRUE) {
+ void *pOutputBuf = (void *)pOutputData->dataBuffer;
+ void *pYUVBuf[3];
+
+ int frameSize = bufWidth * bufHeight;
+ int actualWidth = outputInfo.img_width;
+ int actualHeight = outputInfo.img_height;
+ int actualImageSize = actualWidth * actualHeight;
+
+ pYUVBuf[0] = (unsigned char *)pOutputBuf;
+ pYUVBuf[1] = (unsigned char *)pOutputBuf + actualImageSize;
+ pYUVBuf[2] = (unsigned char *)pOutputBuf + actualImageSize + actualImageSize / 4;
+ pOutputData->dataLen = (actualImageSize * 3) / 2;
+
+#ifdef USE_ANB
+ if (pSECOutputPort->bIsANBEnabled == OMX_TRUE) {
+ OMX_U32 stride;
+ SEC_OSAL_LockANB(pOutputData->dataBuffer, actualWidth, actualHeight, pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eColorFormat, &stride, pYUVBuf);
+ actualWidth = stride;
+ pOutputData->dataLen = sizeof(void *);
+ }
+#endif
+ if ((pVideoDec->bThumbnailMode == OMX_FALSE) &&
+ (pSECOutputPort->portDefinition.format.video.eColorFormat == OMX_SEC_COLOR_FormatNV12TPhysicalAddress)) {
+ /* if use Post copy address structure */
+ SEC_OSAL_Memcpy(pOutputBuf, &(outputInfo.YPhyAddr), sizeof(outputInfo.YPhyAddr));
+ SEC_OSAL_Memcpy((unsigned char *)pOutputBuf + (sizeof(void *) * 1), &(outputInfo.CPhyAddr), sizeof(outputInfo.CPhyAddr));
+ SEC_OSAL_Memcpy((unsigned char *)pOutputBuf + (sizeof(void *) * 2), &(outputInfo.YVirAddr), sizeof(outputInfo.YVirAddr));
+ SEC_OSAL_Memcpy((unsigned char *)pOutputBuf + (sizeof(void *) * 3), &(outputInfo.CVirAddr), sizeof(outputInfo.CVirAddr));
+ pOutputData->dataLen = (actualWidth * actualHeight * 3) / 2;
+ } else {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "YUV420p out for ThumbnailMode/Flash player mode");
+ switch (pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eColorFormat) {
+ case OMX_SEC_COLOR_FormatNV12Tiled:
+#ifdef S3D_SUPPORT
+ case OMX_SEC_COLOR_FormatNV12Tiled_SBS_LR:
+ case OMX_SEC_COLOR_FormatNV12Tiled_SBS_RL:
+ case OMX_SEC_COLOR_FormatNV12Tiled_TB_LR:
+ case OMX_SEC_COLOR_FormatNV12Tiled_TB_RL:
+#endif
+ SEC_OSAL_Memcpy(pOutputBuf, outputInfo.YVirAddr, FrameBufferYSize);
+ SEC_OSAL_Memcpy((unsigned char *)pOutputBuf + FrameBufferYSize, outputInfo.CVirAddr, FrameBufferUVSize);
+ pOutputData->dataLen = FrameBufferYSize + FrameBufferUVSize;
+ break;
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+#ifdef S3D_SUPPORT
+ case OMX_SEC_COLOR_FormatYUV420SemiPlanar_SBS_LR:
+ case OMX_SEC_COLOR_FormatYUV420SemiPlanar_SBS_RL:
+ case OMX_SEC_COLOR_FormatYUV420SemiPlanar_TB_LR:
+ case OMX_SEC_COLOR_FormatYUV420SemiPlanar_TB_RL:
+#endif
+ case OMX_SEC_COLOR_FormatANBYUV420SemiPlanar:
+#ifdef USE_CSC_FIMC
+ if ((pSECOutputPort->bIsANBEnabled == OMX_TRUE) && (pH264Dec->hFIMCHandle != NULL)) {
+ void *pPhys[3];
+ SEC_OSAL_GetPhysANB(pOutputData->dataBuffer, pPhys);
+ pYUVBuf[0] = outputInfo.YPhyAddr;
+ pYUVBuf[1] = outputInfo.CPhyAddr;
+ csc_fimc_convert_nv12t(pH264Dec->hFIMCHandle, pPhys,
+ pYUVBuf, actualWidth, actualHeight,
+ OMX_COLOR_FormatYUV420SemiPlanar);
+ break;
+ }
+#endif
+ csc_tiled_to_linear_y_neon(
+ (unsigned char *)pYUVBuf[0],
+ (unsigned char *)outputInfo.YVirAddr,
+ actualWidth,
+ actualHeight);
+ csc_tiled_to_linear_uv_neon(
+ (unsigned char *)pYUVBuf[1],
+ (unsigned char *)outputInfo.CVirAddr,
+ actualWidth,
+ actualHeight / 2);
+ break;
+ case OMX_COLOR_FormatYUV420Planar:
+#ifdef S3D_SUPPORT
+ case OMX_SEC_COLOR_FormatYUV420Planar_SBS_LR:
+ case OMX_SEC_COLOR_FormatYUV420Planar_SBS_RL:
+ case OMX_SEC_COLOR_FormatYUV420Planar_TB_LR:
+ case OMX_SEC_COLOR_FormatYUV420Planar_TB_RL:
+#endif
+ default:
+#ifdef USE_CSC_FIMC
+ if ((pSECOutputPort->bIsANBEnabled == OMX_TRUE) && (pH264Dec->hFIMCHandle != NULL)) {
+ void *pPhys[3];
+ SEC_OSAL_GetPhysANB(pOutputData->dataBuffer, pPhys);
+ pYUVBuf[0] = outputInfo.YPhyAddr;
+ pYUVBuf[1] = outputInfo.CPhyAddr;
+ csc_fimc_convert_nv12t(pH264Dec->hFIMCHandle, pPhys,
+ pYUVBuf, actualWidth, actualHeight,
+ OMX_COLOR_FormatYUV420Planar);
+ break;
+ }
+#endif
+ csc_tiled_to_linear_y_neon(
+ (unsigned char *)pYUVBuf[0],
+ (unsigned char *)outputInfo.YVirAddr,
+ actualWidth,
+ actualHeight);
+ csc_tiled_to_linear_uv_deinterleave_neon(
+ (unsigned char *)pYUVBuf[1],
+ (unsigned char *)pYUVBuf[2],
+ (unsigned char *)outputInfo.CVirAddr,
+ actualWidth,
+ actualHeight / 2);
+ break;
+ }
+ }
+#ifdef USE_ANB
+ if (pSECOutputPort->bIsANBEnabled == OMX_TRUE) {
+ SEC_OSAL_UnlockANB(pOutputData->dataBuffer);
+ }
+#endif
+ } else {
+ pOutputData->dataLen = 0;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_H264_Decode_Block(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_OMX_VIDEODEC_COMPONENT *pVideoDec = (SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle;
+ SEC_OMX_BASEPORT *pSECInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+ SEC_H264DEC_HANDLE *pH264Dec = (SEC_H264DEC_HANDLE *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ OMX_U32 oneFrameSize = pInputData->dataLen;
+ SSBSIP_MFC_DEC_OUTPUT_INFO outputInfo;
+ OMX_S32 setConfVal = 0;
+ OMX_S32 returnCodec = 0;
+ int bufWidth = 0;
+ int bufHeight = 0;
+ OMX_U32 FrameBufferYSize;
+ OMX_U32 FrameBufferUVSize;
+
+ 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;
+ }
+
+ /* Default number in the driver is optimized */
+ if (pVideoDec->bThumbnailMode == OMX_TRUE) {
+ setConfVal = 0;
+ SsbSipMfcDecSetConfig(pH264Dec->hMFCH264Handle.hMFCHandle, MFC_DEC_SETCONF_DISPLAY_DELAY, &setConfVal);
+ } else {
+ setConfVal = H264_DEC_NUM_OF_EXTRA_BUFFERS;
+ SsbSipMfcDecSetConfig(pH264Dec->hMFCH264Handle.hMFCHandle, MFC_DEC_SETCONF_EXTRA_BUFFER_NUM, &setConfVal);
+
+ setConfVal = 8;
+ SsbSipMfcDecSetConfig(pH264Dec->hMFCH264Handle.hMFCHandle, MFC_DEC_SETCONF_DISPLAY_DELAY, &setConfVal);
+ }
+
+ returnCodec = SsbSipMfcDecInit(pH264Dec->hMFCH264Handle.hMFCHandle, eCodecType, oneFrameSize);
+ if (returnCodec == MFC_RET_OK) {
+ SSBSIP_MFC_IMG_RESOLUTION imgResol;
+ SSBSIP_MFC_CROP_INFORMATION cropInfo;
+
+ SsbSipMfcDecGetConfig(pH264Dec->hMFCH264Handle.hMFCHandle, MFC_DEC_GETCONF_BUF_WIDTH_HEIGHT, &imgResol);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "set width height information : %d, %d",
+ pSECInputPort->portDefinition.format.video.nFrameWidth,
+ pSECInputPort->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);
+
+ pSECOutputPort->cropRectangle.nTop = cropInfo.crop_top_offset;
+ pSECOutputPort->cropRectangle.nLeft = cropInfo.crop_left_offset;
+ pSECOutputPort->cropRectangle.nWidth = imgResol.width - cropInfo.crop_left_offset - cropInfo.crop_right_offset;
+ pSECOutputPort->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 */
+ pSECInputPort->portDefinition.format.video.nFrameWidth = imgResol.width;
+ pSECInputPort->portDefinition.format.video.nFrameHeight = imgResol.height;
+ pSECInputPort->portDefinition.format.video.nStride = ((imgResol.width + 15) & (~15));
+ pSECInputPort->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);
+ }
+ if ((pSECInputPort->portDefinition.format.video.nFrameWidth != (unsigned int)imgResol.width) ||
+ (pSECInputPort->portDefinition.format.video.nFrameHeight != (unsigned int)imgResol.height)) {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "change width height information : OMX_EventPortSettingsChanged");
+ /* change width and height information */
+ pSECInputPort->portDefinition.format.video.nFrameWidth = imgResol.width;
+ pSECInputPort->portDefinition.format.video.nFrameHeight = imgResol.height;
+ pSECInputPort->portDefinition.format.video.nStride = ((imgResol.width + 15) & (~15));
+ pSECInputPort->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
+
+ if (Check_H264_StartCode(pInputData->dataBuffer, pInputData->dataLen) == OMX_TRUE) {
+ pSECComponent->timeStamp[pH264Dec->hMFCH264Handle.indexTimestamp] = pInputData->timeStamp;
+ pSECComponent->nFlags[pH264Dec->hMFCH264Handle.indexTimestamp] = pInputData->nFlags;
+ SsbSipMfcDecSetConfig(pH264Dec->hMFCH264Handle.hMFCHandle, MFC_DEC_SETCONF_FRAME_TAG, &(pH264Dec->hMFCH264Handle.indexTimestamp));
+
+ returnCodec = SsbSipMfcDecExe(pH264Dec->hMFCH264Handle.hMFCHandle, oneFrameSize);
+ } else {
+ if (pSECComponent->checkTimeStamp.needCheckStartTimeStamp == OMX_TRUE)
+ pSECComponent->checkTimeStamp.needSetStartTimeStamp = OMX_TRUE;
+
+ pOutputData->timeStamp = pInputData->timeStamp;
+ pOutputData->nFlags = pInputData->nFlags;
+ returnCodec = MFC_RET_OK;
+ goto EXIT;
+ }
+
+ if (returnCodec == MFC_RET_OK) {
+ SSBSIP_MFC_DEC_OUTBUF_STATUS status;
+ OMX_S32 indexTimestamp = 0;
+
+ status = SsbSipMfcDecGetOutBuf(pH264Dec->hMFCH264Handle.hMFCHandle, &outputInfo);
+ bufWidth = (outputInfo.img_width + 15) & (~15);
+ bufHeight = (outputInfo.img_height + 15) & (~15);
+ FrameBufferYSize = ALIGN_TO_8KB(ALIGN_TO_128B(outputInfo.img_width) * ALIGN_TO_32B(outputInfo.img_height));
+ FrameBufferUVSize = ALIGN_TO_8KB(ALIGN_TO_128B(outputInfo.img_width) * ALIGN_TO_32B(outputInfo.img_height/2));
+
+ if (status != MFC_GETOUTBUF_DISPLAY_ONLY) {
+ pH264Dec->hMFCH264Handle.indexTimestamp++;
+ pH264Dec->hMFCH264Handle.indexTimestamp %= MAX_TIMESTAMP;
+ }
+
+ 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;
+ } else {
+ /* For timestamp correction. if mfc support frametype detect */
+ SEC_OSAL_Log(SEC_LOG_TRACE, "disp_pic_frame_type: %d", outputInfo.disp_pic_frame_type);
+#ifdef NEED_TIMESTAMP_REORDER
+ if ((outputInfo.disp_pic_frame_type == MFC_FRAME_TYPE_I_FRAME) ||
+ (pH264Dec->hMFCH264Handle.bFlashPlayerMode != OMX_FALSE)) {
+ pOutputData->timeStamp = pSECComponent->timeStamp[indexTimestamp];
+ pOutputData->nFlags = pSECComponent->nFlags[indexTimestamp];
+ pH264Dec->hMFCH264Handle.outputIndexTimestamp = indexTimestamp;
+ } else {
+ pOutputData->timeStamp = pSECComponent->timeStamp[pH264Dec->hMFCH264Handle.outputIndexTimestamp];
+ pOutputData->nFlags = pSECComponent->nFlags[pH264Dec->hMFCH264Handle.outputIndexTimestamp];
+ }
+#else
+ pOutputData->timeStamp = pSECComponent->timeStamp[indexTimestamp];
+ pOutputData->nFlags = pSECComponent->nFlags[indexTimestamp];
+#endif
+ 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)) {
+ /** Fill Output Buffer **/
+ void *pOutputBuf = (void *)pOutputData->dataBuffer;
+ void *pYUVBuf[3];
+
+ int frameSize = bufWidth * bufHeight;
+ int actualWidth = outputInfo.img_width;
+ int actualHeight = outputInfo.img_height;
+ int actualImageSize = actualWidth * actualHeight;
+
+ pYUVBuf[0] = (unsigned char *)pOutputBuf;
+ pYUVBuf[1] = (unsigned char *)pOutputBuf + actualImageSize;
+ pYUVBuf[2] = (unsigned char *)pOutputBuf + actualImageSize + actualImageSize / 4;
+ pOutputData->dataLen = (actualImageSize * 3) / 2;
+
+#ifdef USE_ANB
+ if (pSECOutputPort->bIsANBEnabled == OMX_TRUE) {
+ OMX_U32 stride;
+ SEC_OSAL_LockANB(pOutputData->dataBuffer, actualWidth, actualHeight, pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eColorFormat, &stride, pYUVBuf);
+ actualWidth = stride;
+ pOutputData->dataLen = sizeof(void *);
+ }
+#endif
+ if ((pVideoDec->bThumbnailMode == OMX_FALSE) &&
+ (pSECOutputPort->portDefinition.format.video.eColorFormat == OMX_SEC_COLOR_FormatNV12TPhysicalAddress)) {
+ /* if use Post copy address structure */
+ SEC_OSAL_Memcpy(pOutputBuf, &(outputInfo.YPhyAddr), sizeof(outputInfo.YPhyAddr));
+ SEC_OSAL_Memcpy((unsigned char *)pOutputBuf + (sizeof(void *) * 1), &(outputInfo.CPhyAddr), sizeof(outputInfo.CPhyAddr));
+ SEC_OSAL_Memcpy((unsigned char *)pOutputBuf + (sizeof(void *) * 2), &(outputInfo.YVirAddr), sizeof(outputInfo.YVirAddr));
+ SEC_OSAL_Memcpy((unsigned char *)pOutputBuf + (sizeof(void *) * 3), &(outputInfo.CVirAddr), sizeof(outputInfo.CVirAddr));
+ pOutputData->dataLen = (actualWidth * actualHeight * 3) / 2;
+ } else {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "YUV420p out for ThumbnailMode/Flash player mode");
+ switch (pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eColorFormat) {
+ case OMX_SEC_COLOR_FormatNV12Tiled:
+ SEC_OSAL_Memcpy(pOutputBuf, outputInfo.YVirAddr, FrameBufferYSize);
+ SEC_OSAL_Memcpy((unsigned char *)pOutputBuf + FrameBufferYSize, outputInfo.CVirAddr, FrameBufferUVSize);
+ pOutputData->dataLen = FrameBufferYSize + FrameBufferUVSize;
+ break;
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ case OMX_SEC_COLOR_FormatANBYUV420SemiPlanar:
+#ifdef USE_CSC_FIMC
+ if ((pSECOutputPort->bIsANBEnabled == OMX_TRUE) && (pH264Dec->hFIMCHandle != NULL)) {
+ void *pPhys[3];
+ SEC_OSAL_GetPhysANB(pOutputData->dataBuffer, pPhys);
+ pYUVBuf[0] = outputInfo.YPhyAddr;
+ pYUVBuf[1] = outputInfo.CPhyAddr;
+ csc_fimc_convert_nv12t(pH264Dec->hFIMCHandle, pPhys,
+ pYUVBuf, actualWidth, actualHeight,
+ OMX_SEC_COLOR_FormatANBYUV420SemiPlanar);
+ break;
+ }
+#endif
+ csc_tiled_to_linear_y_neon(
+ (unsigned char *)pYUVBuf[0],
+ (unsigned char *)outputInfo.YVirAddr,
+ actualWidth,
+ actualHeight);
+ csc_tiled_to_linear_uv_neon(
+ (unsigned char *)pYUVBuf[1],
+ (unsigned char *)outputInfo.CVirAddr,
+ actualWidth,
+ actualHeight / 2);
+ break;
+ case OMX_COLOR_FormatYUV420Planar:
+ default:
+#ifdef USE_CSC_FIMC
+ if ((pSECOutputPort->bIsANBEnabled == OMX_TRUE) && (pH264Dec->hFIMCHandle != NULL)) {
+ void *pPhys[3];
+ SEC_OSAL_GetPhysANB(pOutputData->dataBuffer, pPhys);
+ pYUVBuf[0] = outputInfo.YPhyAddr;
+ pYUVBuf[1] = outputInfo.CPhyAddr;
+ csc_fimc_convert_nv12t(pH264Dec->hFIMCHandle, pPhys,
+ pYUVBuf, actualWidth, actualHeight,
+ OMX_COLOR_FormatYUV420Planar);
+ break;
+ }
+#endif
+ csc_tiled_to_linear_y_neon(
+ (unsigned char *)pYUVBuf[0],
+ (unsigned char *)outputInfo.YVirAddr,
+ actualWidth,
+ actualHeight);
+ csc_tiled_to_linear_uv_deinterleave_neon(
+ (unsigned char *)pYUVBuf[1],
+ (unsigned char *)pYUVBuf[2],
+ (unsigned char *)outputInfo.CVirAddr,
+ actualWidth,
+ actualHeight / 2);
+ break;
+ }
+ }
+
+#ifdef USE_ANB
+ if (pSECOutputPort->bIsANBEnabled == OMX_TRUE) {
+ SEC_OSAL_UnlockANB(pOutputData->dataBuffer);
+ }
+#endif
+ pH264Dec->hMFCH264Handle.outputIndexTimestamp++;
+ pH264Dec->hMFCH264Handle.outputIndexTimestamp %= MAX_TIMESTAMP;
+ }
+ if (pOutputData->nFlags & OMX_BUFFERFLAG_EOS)
+ pOutputData->dataLen = 0;
+
+ 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;
+ }
+ goto EXIT;
+ }
+
+#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) {
+ 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;
+ }
+ pOutputData->dataLen = 0;
+
+ /* ret = OMX_ErrorUndefined; */
+ ret = OMX_ErrorNone;
+ goto EXIT;
+ }
+
+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 *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->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;
+ }
+
+#ifdef NONBLOCK_MODE_PROCESS
+ ret = SEC_MFC_H264_Decode_Nonblock(pOMXComponent, pInputData, pOutputData);
+#else
+ ret = SEC_MFC_H264_Decode_Block(pOMXComponent, pInputData, pOutputData);
+#endif
+ 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_OMX_VIDEODEC_COMPONENT *pVideoDec = NULL;
+ SEC_H264DEC_HANDLE *pH264Dec = NULL;
+ OMX_BOOL bFlashPlayerMode = OMX_FALSE;
+ 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) {
+ bFlashPlayerMode = OMX_FALSE;
+ } else if (SEC_OSAL_Strcmp(SEC_OMX_COMPONENT_H264_FP_DEC, componentName) == 0) {
+ bFlashPlayerMode = OMX_TRUE;
+ } else {
+ 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_DEC_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));
+ pVideoDec = (SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle;
+ pVideoDec->hCodecHandle = (OMX_HANDLETYPE)pH264Dec;
+
+ if (bFlashPlayerMode == OMX_FALSE)
+ SEC_OSAL_Strcpy(pSECComponent->componentName, SEC_OMX_COMPONENT_H264_DEC);
+ else
+ SEC_OSAL_Strcpy(pSECComponent->componentName, SEC_OMX_COMPONENT_H264_FP_DEC);
+
+ pH264Dec->hMFCH264Handle.bFlashPlayerMode = bFlashPlayerMode;
+#ifdef S3D_SUPPORT
+ pH264Dec->hMFCH264Handle.bS3DMode = OMX_FALSE;
+#endif
+
+ /* 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;
+ if (bFlashPlayerMode != OMX_FALSE) {
+ pSECPort->portDefinition.nBufferCountActual = MAX_H264_FP_VIDEO_INPUTBUFFER_NUM;
+ pSECPort->portDefinition.nBufferCountMin = MAX_H264_FP_VIDEO_INPUTBUFFER_NUM;
+ }
+
+ /* 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_FormatYUV420Planar;
+ pSECPort->portDefinition.bEnabled = OMX_TRUE;
+ if (bFlashPlayerMode != OMX_FALSE) {
+ pSECPort->portDefinition.nBufferCountActual = MAX_H264_FP_VIDEO_OUTPUTBUFFER_NUM;
+ pSECPort->portDefinition.nBufferCountMin = MAX_H264_FP_VIDEO_OUTPUTBUFFER_NUM;
+ }
+
+ 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 *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ if (pH264Dec != NULL) {
+ SEC_OSAL_Free(pH264Dec);
+ pH264Dec = ((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle = NULL;
+ }
+
+ ret = SEC_OMX_VideoDecodeComponentDeinit(pOMXComponent);
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ ret = OMX_ErrorNone;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
diff --git a/exynos/multimedia/openmax/component/video/dec/h264/SEC_OMX_H264dec.h b/exynos/multimedia/openmax/component/video/dec/h264/SEC_OMX_H264dec.h
new file mode 100644
index 0000000..06e3116
--- /dev/null
+++ b/exynos/multimedia/openmax/component/video/dec/h264/SEC_OMX_H264dec.h
@@ -0,0 +1,79 @@
+/*
+ *
+ * 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.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"
+
+
+#define MAX_H264_FP_VIDEO_INPUTBUFFER_NUM 4
+#define MAX_H264_FP_VIDEO_OUTPUTBUFFER_NUM 4
+
+typedef struct _SEC_MFC_H264DEC_HANDLE
+{
+ OMX_HANDLETYPE hMFCHandle;
+ OMX_PTR pMFCStreamBuffer;
+ OMX_PTR pMFCStreamPhyBuffer;
+ OMX_U32 indexTimestamp;
+ OMX_U32 outputIndexTimestamp;
+ OMX_BOOL bConfiguredMFC;
+ OMX_BOOL bFlashPlayerMode;
+#ifdef S3D_SUPPORT
+ OMX_BOOL bS3DMode;
+#endif
+ 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;
+
+ /* CSC FIMC handle */
+#ifdef USE_CSC_FIMC
+ OMX_PTR hFIMCHandle;
+#endif
+} 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/exynos/multimedia/openmax/component/video/dec/h264/library_register.c b/exynos/multimedia/openmax/component/video/dec/h264/library_register.c
new file mode 100644
index 0000000..579a071
--- /dev/null
+++ b/exynos/multimedia/openmax/component/video/dec/h264/library_register.c
@@ -0,0 +1,60 @@
+/*
+ *
+ * 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.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;
+
+ /* component 2 - video decoder H.264 for flash player */
+ SEC_OSAL_Strcpy(secComponents[1]->componentName, SEC_OMX_COMPONENT_H264_FP_DEC);
+ SEC_OSAL_Strcpy(secComponents[1]->roles[0], SEC_OMX_COMPONENT_H264_DEC_ROLE);
+ secComponents[1]->totalRoleNum = MAX_COMPONENT_ROLE_NUM;
+
+EXIT:
+ FunctionOut();
+
+ return MAX_COMPONENT_NUM;
+}
+
diff --git a/exynos/multimedia/openmax/component/video/dec/h264/library_register.h b/exynos/multimedia/openmax/component/video/dec/h264/library_register.h
new file mode 100644
index 0000000..be7384b
--- /dev/null
+++ b/exynos/multimedia/openmax/component/video/dec/h264/library_register.h
@@ -0,0 +1,56 @@
+/*
+ *
+ * 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.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 2
+#define MAX_COMPONENT_ROLE_NUM 1
+
+/* H.264 */
+#define SEC_OMX_COMPONENT_H264_DEC "OMX.SEC.AVC.Decoder"
+#define SEC_OMX_COMPONENT_H264_FP_DEC "OMX.SEC.FP.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/exynos/multimedia/openmax/component/video/dec/mpeg4/Android.mk b/exynos/multimedia/openmax/component/video/dec/mpeg4/Android.mk
new file mode 100644
index 0000000..d45c727
--- /dev/null
+++ b/exynos/multimedia/openmax/component/video/dec/mpeg4/Android.mk
@@ -0,0 +1,52 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := \
+ SEC_OMX_Mpeg4dec.c \
+ library_register.c
+
+LOCAL_PRELINK_MODULE := false
+LOCAL_MODULE := libOMX.SEC.M4V.Decoder
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/omx
+
+LOCAL_CFLAGS :=
+
+ifeq ($(BOARD_NONBLOCK_MODE_PROCESS), true)
+LOCAL_CFLAGS += -DNONBLOCK_MODE_PROCESS
+endif
+
+ifeq ($(BOARD_USE_ANB), true)
+LOCAL_CFLAGS += -DUSE_ANB
+ifeq ($(BOARD_USE_CSC_FIMC), true)
+ifeq ($(BOARD_USE_V4L2_ION), false)
+LOCAL_CFLAGS += -DUSE_CSC_FIMC
+endif
+endif
+endif
+
+LOCAL_ARM_MODE := arm
+
+LOCAL_STATIC_LIBRARIES := libSEC_OMX_Vdec libsecosal libsecbasecomponent \
+ libseccscapi libsecmfcapi
+LOCAL_SHARED_LIBRARIES := libc libdl libcutils libutils libui \
+ libSEC_OMX_Resourcemanager
+
+ifeq ($(filter-out exynos4,$(TARGET_BOARD_PLATFORM)),)
+LOCAL_SHARED_LIBRARIES += libhwconverter
+endif
+
+#ifeq ($(BOARD_USE_V4L2_ION),true)
+#LOCAL_SHARED_LIBRARIES += libion
+#endif
+
+LOCAL_C_INCLUDES := $(SEC_OMX_INC)/khronos \
+ $(SEC_OMX_INC)/sec \
+ $(SEC_OMX_TOP)/osal \
+ $(SEC_OMX_TOP)/core \
+ $(SEC_OMX_COMPONENT)/common \
+ $(SEC_OMX_COMPONENT)/video/dec \
+ $(TARGET_OUT_HEADERS)/$(SEC_COPY_HEADERS_TO)
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/exynos/multimedia/openmax/component/video/dec/mpeg4/SEC_OMX_Mpeg4dec.c b/exynos/multimedia/openmax/component/video/dec/mpeg4/SEC_OMX_Mpeg4dec.c
new file mode 100644
index 0000000..5969c71
--- /dev/null
+++ b/exynos/multimedia/openmax/component/video/dec/mpeg4/SEC_OMX_Mpeg4dec.c
@@ -0,0 +1,2048 @@
+/*
+ *
+ * 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.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 "SEC_OSAL_ETC.h"
+#include "SEC_OSAL_Semaphore.h"
+#include "SEC_OSAL_Thread.h"
+#include "library_register.h"
+#include "SEC_OMX_Mpeg4dec.h"
+#include "SsbSipMfcApi.h"
+#include "color_space_convertor.h"
+
+#ifdef USE_ANB
+#include "SEC_OSAL_Android.h"
+#endif
+
+/* To use CSC FIMC in SEC OMX, gralloc should allocate physical memory using FIMC */
+/* It means GRALLOC_USAGE_HW_FIMC1 should be set on Native Window usage */
+#ifdef USE_CSC_FIMC
+#include "csc_fimc.h"
+#endif
+
+#undef SEC_LOG_TAG
+#define SEC_LOG_TAG "SEC_MPEG4_DEC"
+#define SEC_LOG_OFF
+#include "SEC_OSAL_Log.h"
+
+#define MPEG4_DEC_NUM_OF_EXTRA_BUFFERS 7
+
+//#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)
+{
+ OMX_U32 len;
+ int 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)
+{
+ OMX_U32 len;
+ int 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_ErrorInvalidState;
+ 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 *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->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 *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->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 *)(((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->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 *)(((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->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 *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->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 *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->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_ErrorInvalidState;
+ 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 *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->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 *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->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 *)(((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->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 *)(((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->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;
+ OMX_U32 realWidth, realHeight;
+
+ 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);
+
+ realWidth = pSECPort->portDefinition.format.video.nFrameWidth;
+ realHeight = pSECPort->portDefinition.format.video.nFrameHeight;
+ width = ((realWidth + 15) & (~15));
+ height = ((realHeight + 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;
+ case OMX_SEC_COLOR_FormatNV12Tiled:
+ pSECOutputPort->portDefinition.nBufferSize =
+ ALIGN_TO_8KB(ALIGN_TO_128B(realWidth) * ALIGN_TO_32B(realHeight)) \
+ + ALIGN_TO_8KB(ALIGN_TO_128B(realWidth) * ALIGN_TO_32B(realHeight/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 *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->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 *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->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_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) {
+ default:
+ ret = SEC_OMX_VideoDecodeGetConfig(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) {
+ default:
+ ret = SEC_OMX_VideoDecodeSetConfig(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 *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+
+ *pIndexType = OMX_IndexVendorThumbnailMode;
+
+ ret = OMX_ErrorNone;
+ } else {
+ ret = SEC_OMX_VideoDecodeGetExtensionIndex(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_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ codecType = ((SEC_MPEG4_HANDLE *)(((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->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 = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ SEC_OMX_VIDEODEC_COMPONENT *pVideoDec = (SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle;
+ SEC_MPEG4_HANDLE *pMpeg4Dec = (SEC_MPEG4_HANDLE *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ while (pVideoDec->NBDecThread.bExitDecodeThread == OMX_FALSE) {
+ SEC_OSAL_SemaphoreWait(pVideoDec->NBDecThread.hDecFrameStart);
+
+ if (pVideoDec->NBDecThread.bExitDecodeThread == OMX_FALSE) {
+ pMpeg4Dec->hMFCMpeg4Handle.returnCodec = SsbSipMfcDecExe(pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle, pVideoDec->NBDecThread.oneFrameSize);
+ SEC_OSAL_SemaphorePost(pVideoDec->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_OMX_VIDEODEC_COMPONENT *pVideoDec = (SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle;
+ SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+ SEC_MPEG4_HANDLE *pMpeg4Dec = NULL;
+ OMX_HANDLETYPE hMFCHandle = NULL;
+ OMX_PTR pStreamBuffer = NULL;
+ OMX_PTR pStreamPhyBuffer = NULL;
+
+ FunctionIn();
+
+ pMpeg4Dec = (SEC_MPEG4_HANDLE *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->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 */
+ if (pSECOutputPort->portDefinition.format.video.eColorFormat == OMX_SEC_COLOR_FormatNV12TPhysicalAddress) {
+ hMFCHandle = (OMX_PTR)SsbSipMfcDecOpen();
+ } else {
+ SSBIP_MFC_BUFFER_TYPE buf_type = CACHE;
+ hMFCHandle = (OMX_PTR)SsbSipMfcDecOpenExt(&buf_type);
+ }
+
+ if (hMFCHandle == NULL) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ ghMFCHandle = pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle = hMFCHandle;
+
+ /* Allocate decoder's input buffer */
+ /* Get first input buffer */
+ pStreamBuffer = SsbSipMfcDecGetInBuf(hMFCHandle, &pStreamPhyBuffer, DEFAULT_MFC_INPUT_BUFFER_SIZE / 2);
+ if (pStreamBuffer == NULL) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ pVideoDec->MFCDecInputBuffer[0].VirAddr = pStreamBuffer;
+ pVideoDec->MFCDecInputBuffer[0].PhyAddr = pStreamPhyBuffer;
+ pVideoDec->MFCDecInputBuffer[0].bufferSize = DEFAULT_MFC_INPUT_BUFFER_SIZE / 2;
+ pVideoDec->MFCDecInputBuffer[0].dataSize = 0;
+
+#ifdef NONBLOCK_MODE_PROCESS
+ /* Get second input buffer */
+ pStreamBuffer = NULL;
+ pStreamBuffer = SsbSipMfcDecGetInBuf(hMFCHandle, &pStreamPhyBuffer, DEFAULT_MFC_INPUT_BUFFER_SIZE / 2);
+ if (pStreamBuffer == NULL) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ pVideoDec->MFCDecInputBuffer[1].VirAddr = pStreamBuffer;
+ pVideoDec->MFCDecInputBuffer[1].PhyAddr = pStreamPhyBuffer;
+ pVideoDec->MFCDecInputBuffer[1].bufferSize = DEFAULT_MFC_INPUT_BUFFER_SIZE / 2;
+ pVideoDec->MFCDecInputBuffer[1].dataSize = 0;
+ pVideoDec->indexInputBuffer = 0;
+
+ pVideoDec->bFirstFrame = OMX_TRUE;
+
+ pVideoDec->NBDecThread.bExitDecodeThread = OMX_FALSE;
+ pVideoDec->NBDecThread.bDecoderRun = OMX_FALSE;
+ pVideoDec->NBDecThread.oneFrameSize = 0;
+ SEC_OSAL_SemaphoreCreate(&(pVideoDec->NBDecThread.hDecFrameStart));
+ SEC_OSAL_SemaphoreCreate(&(pVideoDec->NBDecThread.hDecFrameEnd));
+ if (OMX_ErrorNone == SEC_OSAL_ThreadCreate(&pVideoDec->NBDecThread.hNBDecodeThread,
+ SEC_MFC_DecodeThread,
+ pOMXComponent)) {
+ pMpeg4Dec->hMFCMpeg4Handle.returnCodec = MFC_RET_OK;
+ }
+#endif
+
+ pMpeg4Dec->hMFCMpeg4Handle.pMFCStreamBuffer = pVideoDec->MFCDecInputBuffer[0].VirAddr;
+ pMpeg4Dec->hMFCMpeg4Handle.pMFCStreamPhyBuffer = pVideoDec->MFCDecInputBuffer[0].PhyAddr;
+ pSECComponent->processData[INPUT_PORT_INDEX].dataBuffer = pVideoDec->MFCDecInputBuffer[0].VirAddr;
+ pSECComponent->processData[INPUT_PORT_INDEX].allocSize = pVideoDec->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;
+ pMpeg4Dec->hMFCMpeg4Handle.outputIndexTimestamp = 0;
+
+ pSECComponent->getAllDelayBuffer = OMX_FALSE;
+
+#ifdef USE_CSC_FIMC
+ pMpeg4Dec->hFIMCHandle = csc_fimc_open();
+#endif
+
+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_OMX_VIDEODEC_COMPONENT *pVideoDec = (SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle;
+ SEC_MPEG4_HANDLE *pMpeg4Dec = NULL;
+ OMX_HANDLETYPE hMFCHandle = NULL;
+
+ FunctionIn();
+
+ pMpeg4Dec = (SEC_MPEG4_HANDLE *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->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;
+
+#ifdef NONBLOCK_MODE_PROCESS
+ if (pVideoDec->NBDecThread.hNBDecodeThread != NULL) {
+ pVideoDec->NBDecThread.bExitDecodeThread = OMX_TRUE;
+ SEC_OSAL_SemaphorePost(pVideoDec->NBDecThread.hDecFrameStart);
+ SEC_OSAL_ThreadTerminate(pVideoDec->NBDecThread.hNBDecodeThread);
+ pVideoDec->NBDecThread.hNBDecodeThread = NULL;
+ }
+
+ if(pVideoDec->NBDecThread.hDecFrameEnd != NULL) {
+ SEC_OSAL_SemaphoreTerminate(pVideoDec->NBDecThread.hDecFrameEnd);
+ pVideoDec->NBDecThread.hDecFrameEnd = NULL;
+ }
+
+ if(pVideoDec->NBDecThread.hDecFrameStart != NULL) {
+ SEC_OSAL_SemaphoreTerminate(pVideoDec->NBDecThread.hDecFrameStart);
+ pVideoDec->NBDecThread.hDecFrameStart = NULL;
+ }
+#endif
+
+ if (hMFCHandle != NULL) {
+ SsbSipMfcDecClose(hMFCHandle);
+ ghMFCHandle = hMFCHandle = NULL;
+ pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle = NULL;
+ }
+
+#ifdef USE_CSC_FIMC
+ if (pMpeg4Dec->hFIMCHandle != NULL) {
+ csc_fimc_close(pMpeg4Dec->hFIMCHandle);
+ pMpeg4Dec->hFIMCHandle = NULL;
+ }
+#endif
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_Mpeg4_Decode_Nonblock(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_OMX_VIDEODEC_COMPONENT *pVideoDec = (SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle;
+ SEC_OMX_BASEPORT *pSECInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+ SEC_MPEG4_HANDLE *pMpeg4Dec = (SEC_MPEG4_HANDLE *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ OMX_HANDLETYPE hMFCHandle = pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle;
+ OMX_U32 oneFrameSize = pInputData->dataLen;
+ SSBSIP_MFC_DEC_OUTPUT_INFO outputInfo;
+ OMX_S32 configValue;
+ int bufWidth;
+ int bufHeight;
+ OMX_U32 FrameBufferYSize = 0;
+ OMX_U32 FrameBufferUVSize = 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 mpeg4 deblocking filter enable */
+ configValue = 1;
+ SsbSipMfcDecSetConfig(hMFCHandle, MFC_DEC_SETCONF_POST_ENABLE, &configValue);
+
+ if (pVideoDec->bThumbnailMode == OMX_TRUE) {
+ configValue = 0; // the number that you want to delay
+ SsbSipMfcDecSetConfig(hMFCHandle, MFC_DEC_SETCONF_DISPLAY_DELAY, &configValue);
+ } else {
+ configValue = MPEG4_DEC_NUM_OF_EXTRA_BUFFERS;
+ SsbSipMfcDecSetConfig(hMFCHandle, MFC_DEC_SETCONF_EXTRA_BUFFER_NUM, &configValue);
+ }
+
+ SsbSipMfcDecSetInBuf(pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle,
+ pMpeg4Dec->hMFCMpeg4Handle.pMFCStreamPhyBuffer,
+ pMpeg4Dec->hMFCMpeg4Handle.pMFCStreamBuffer,
+ pSECComponent->processData[INPUT_PORT_INDEX].allocSize);
+
+ pMpeg4Dec->hMFCMpeg4Handle.returnCodec = SsbSipMfcDecInit(hMFCHandle, MFCCodecType, oneFrameSize);
+ if (pMpeg4Dec->hMFCMpeg4Handle.returnCodec == MFC_RET_OK) {
+ SSBSIP_MFC_IMG_RESOLUTION imgResol;
+
+ 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 ((pSECInputPort->portDefinition.format.video.nFrameWidth != (unsigned int)imgResol.width) ||
+ (pSECInputPort->portDefinition.format.video.nFrameHeight != (unsigned int)imgResol.height)) {
+ /* change width and height information */
+ pSECInputPort->portDefinition.format.video.nFrameWidth = imgResol.width;
+ pSECInputPort->portDefinition.format.video.nFrameHeight = imgResol.height;
+ pSECInputPort->portDefinition.format.video.nStride = ((imgResol.width + 15) & (~15));
+ pSECInputPort->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)",
+ pSECInputPort->portDefinition.format.video.nFrameWidth, pSECInputPort->portDefinition.format.video.nFrameHeight,
+ pSECInputPort->portDefinition.format.video.nStride, pSECInputPort->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) &&
+ (pVideoDec->bFirstFrame == OMX_FALSE)) {
+ SSBSIP_MFC_DEC_OUTBUF_STATUS status;
+ OMX_S32 indexTimestamp = 0;
+
+ /* wait for mfc decode done */
+ if (pVideoDec->NBDecThread.bDecoderRun == OMX_TRUE) {
+ SEC_OSAL_SemaphoreWait(pVideoDec->NBDecThread.hDecFrameEnd);
+ pVideoDec->NBDecThread.bDecoderRun = OMX_FALSE;
+ }
+
+ SEC_OSAL_SleepMillisec(0);
+ status = SsbSipMfcDecGetOutBuf(hMFCHandle, &outputInfo);
+ bufWidth = (outputInfo.img_width + 15) & (~15);
+ bufHeight = (outputInfo.img_height + 15) & (~15);
+ FrameBufferYSize = ALIGN_TO_8KB(ALIGN_TO_128B(outputInfo.img_width) * ALIGN_TO_32B(outputInfo.img_height));
+ FrameBufferUVSize = ALIGN_TO_8KB(ALIGN_TO_128B(outputInfo.img_width) * ALIGN_TO_32B(outputInfo.img_height/2));
+
+ 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;
+ } else {
+ /* For timestamp correction. if mfc support frametype detect */
+ SEC_OSAL_Log(SEC_LOG_TRACE, "disp_pic_frame_type: %d", outputInfo.disp_pic_frame_type);
+#ifdef NEED_TIMESTAMP_REORDER
+ if (outputInfo.disp_pic_frame_type == MFC_FRAME_TYPE_I_FRAME) {
+ pOutputData->timeStamp = pSECComponent->timeStamp[indexTimestamp];
+ pOutputData->nFlags = pSECComponent->nFlags[indexTimestamp];
+ pMpeg4Dec->hMFCMpeg4Handle.outputIndexTimestamp = indexTimestamp;
+ } else {
+ pOutputData->timeStamp = pSECComponent->timeStamp[pMpeg4Dec->hMFCMpeg4Handle.outputIndexTimestamp];
+ pOutputData->nFlags = pSECComponent->nFlags[pMpeg4Dec->hMFCMpeg4Handle.outputIndexTimestamp];
+ }
+#else
+ pOutputData->timeStamp = pSECComponent->timeStamp[indexTimestamp];
+ pOutputData->nFlags = pSECComponent->nFlags[indexTimestamp];
+#endif
+ }
+
+ if ((status == MFC_GETOUTBUF_DISPLAY_DECODING) ||
+ (status == MFC_GETOUTBUF_DISPLAY_ONLY)) {
+ outputDataValid = OMX_TRUE;
+ pMpeg4Dec->hMFCMpeg4Handle.outputIndexTimestamp++;
+ pMpeg4Dec->hMFCMpeg4Handle.outputIndexTimestamp %= MAX_TIMESTAMP;
+ }
+ 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) {
+ 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 ((pVideoDec->bFirstFrame == OMX_TRUE) &&
+ ((pOutputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) &&
+ ((pInputData->nFlags & OMX_BUFFERFLAG_CODECCONFIG) != OMX_BUFFERFLAG_CODECCONFIG)) {
+ pOutputData->nFlags = (pOutputData->nFlags & (~OMX_BUFFERFLAG_EOS));
+ }
+
+ outputDataValid = OMX_FALSE;
+
+ /* ret = OMX_ErrorUndefined; */
+ ret = OMX_ErrorNone;
+ }
+
+ if (ret == OMX_ErrorInputDataDecodeYet) {
+ pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].dataSize = oneFrameSize;
+ pVideoDec->indexInputBuffer++;
+ pVideoDec->indexInputBuffer %= MFC_INPUT_BUFFER_NUM_MAX;
+ pMpeg4Dec->hMFCMpeg4Handle.pMFCStreamBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].VirAddr;
+ pMpeg4Dec->hMFCMpeg4Handle.pMFCStreamPhyBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].PhyAddr;
+ pSECComponent->processData[INPUT_PORT_INDEX].dataBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].VirAddr;
+ pSECComponent->processData[INPUT_PORT_INDEX].allocSize = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].bufferSize;
+ oneFrameSize = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].dataSize;
+ //pInputData->dataLen = oneFrameSize;
+ //pInputData->remainDataLen = oneFrameSize;
+ }
+
+ if ((Check_Stream_PrefixCode(pInputData->dataBuffer, oneFrameSize, pMpeg4Dec->hMFCMpeg4Handle.codecType) == OMX_TRUE) &&
+ ((pOutputData->nFlags & OMX_BUFFERFLAG_EOS) != OMX_BUFFERFLAG_EOS)) {
+ if ((ret != OMX_ErrorInputDataDecodeYet) || (pSECComponent->getAllDelayBuffer == OMX_TRUE)) {
+ SsbSipMfcDecSetConfig(pMpeg4Dec->hMFCMpeg4Handle.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);
+
+ pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].dataSize = oneFrameSize;
+ pVideoDec->NBDecThread.oneFrameSize = oneFrameSize;
+
+ /* mfc decode start */
+ SEC_OSAL_SemaphorePost(pVideoDec->NBDecThread.hDecFrameStart);
+ pVideoDec->NBDecThread.bDecoderRun = OMX_TRUE;
+ pMpeg4Dec->hMFCMpeg4Handle.returnCodec = MFC_RET_OK;
+
+ SEC_OSAL_SleepMillisec(0);
+
+ pVideoDec->indexInputBuffer++;
+ pVideoDec->indexInputBuffer %= MFC_INPUT_BUFFER_NUM_MAX;
+ pMpeg4Dec->hMFCMpeg4Handle.pMFCStreamBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].VirAddr;
+ pMpeg4Dec->hMFCMpeg4Handle.pMFCStreamPhyBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].PhyAddr;
+ pSECComponent->processData[INPUT_PORT_INDEX].dataBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].VirAddr;
+ pSECComponent->processData[INPUT_PORT_INDEX].allocSize = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].bufferSize;
+
+ if ((pVideoDec->bFirstFrame == OMX_TRUE) &&
+ (pSECComponent->bSaveFlagEOS == OMX_TRUE) &&
+ (outputDataValid == OMX_FALSE)) {
+ ret = OMX_ErrorInputDataDecodeYet;
+ }
+
+ pVideoDec->bFirstFrame = OMX_FALSE;
+ } else {
+ if (pSECComponent->checkTimeStamp.needCheckStartTimeStamp == OMX_TRUE)
+ pSECComponent->checkTimeStamp.needSetStartTimeStamp = OMX_TRUE;
+ }
+
+ /** Fill Output Buffer **/
+ if (outputDataValid == OMX_TRUE) {
+ void *pOutputBuf = (void *)pOutputData->dataBuffer;
+ void *pYUVBuf[3];
+
+ int frameSize = bufWidth * bufHeight;
+ int width = outputInfo.img_width;
+ int height = outputInfo.img_height;
+ int imageSize = outputInfo.img_width * outputInfo.img_height;
+
+ pYUVBuf[0] = (unsigned char *)pOutputBuf;
+ pYUVBuf[1] = (unsigned char *)pOutputBuf + imageSize;
+ pYUVBuf[2] = (unsigned char *)pOutputBuf + imageSize + imageSize / 4;
+ pOutputData->dataLen = (imageSize * 3) / 2;
+
+#ifdef USE_ANB
+ if (pSECOutputPort->bIsANBEnabled == OMX_TRUE) {
+ OMX_U32 stride;
+ SEC_OSAL_LockANB(pOutputData->dataBuffer, width, height, pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eColorFormat, &stride, pYUVBuf);
+ width = stride;
+ pOutputData->dataLen = sizeof(void *);
+ }
+#endif
+ if ((pVideoDec->bThumbnailMode == OMX_FALSE) &&
+ (pSECOutputPort->portDefinition.format.video.eColorFormat == OMX_SEC_COLOR_FormatNV12TPhysicalAddress)) {
+ /* if use Post copy address structure */
+ SEC_OSAL_Memcpy(pOutputBuf, &(outputInfo.YPhyAddr), sizeof(outputInfo.YPhyAddr));
+ SEC_OSAL_Memcpy((unsigned char *)pOutputBuf + (sizeof(void *) * 1), &(outputInfo.CPhyAddr), sizeof(outputInfo.CPhyAddr));
+ SEC_OSAL_Memcpy((unsigned char *)pOutputBuf + (sizeof(void *) * 2), &(outputInfo.YVirAddr), sizeof(outputInfo.YVirAddr));
+ SEC_OSAL_Memcpy((unsigned char *)pOutputBuf + (sizeof(void *) * 3), &(outputInfo.CVirAddr), sizeof(outputInfo.CVirAddr));
+ pOutputData->dataLen = (outputInfo.img_width * outputInfo.img_height * 3) / 2;
+ } else {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "YUV420 out for ThumbnailMode");
+ switch (pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eColorFormat) {
+ case OMX_SEC_COLOR_FormatNV12Tiled:
+ SEC_OSAL_Memcpy(pOutputBuf, outputInfo.YVirAddr, FrameBufferYSize);
+ SEC_OSAL_Memcpy((unsigned char *)pOutputBuf + FrameBufferYSize, outputInfo.CVirAddr, FrameBufferUVSize);
+ pOutputData->dataLen = FrameBufferYSize + FrameBufferUVSize;
+ break;
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ case OMX_SEC_COLOR_FormatANBYUV420SemiPlanar:
+#ifdef USE_CSC_FIMC
+ if ((pSECOutputPort->bIsANBEnabled == OMX_TRUE) && (pMpeg4Dec->hFIMCHandle != NULL)) {
+ void *pPhys[3];
+ SEC_OSAL_GetPhysANB(pOutputData->dataBuffer, pPhys);
+ pYUVBuf[0] = outputInfo.YPhyAddr;
+ pYUVBuf[1] = outputInfo.CPhyAddr;
+ csc_fimc_convert_nv12t(pMpeg4Dec->hFIMCHandle, pPhys,
+ pYUVBuf, width, height,
+ OMX_COLOR_FormatYUV420SemiPlanar);
+ break;
+ }
+#endif
+ csc_tiled_to_linear_y_neon(
+ (unsigned char *)pYUVBuf[0],
+ (unsigned char *)outputInfo.YVirAddr,
+ width,
+ height);
+ csc_tiled_to_linear_uv_neon(
+ (unsigned char *)pYUVBuf[1],
+ (unsigned char *)outputInfo.CVirAddr,
+ width,
+ height / 2);
+ break;
+ case OMX_COLOR_FormatYUV420Planar:
+ default:
+#ifdef USE_CSC_FIMC
+ if ((pSECOutputPort->bIsANBEnabled == OMX_TRUE) && (pMpeg4Dec->hFIMCHandle != NULL)) {
+ void *pPhys[3];
+ SEC_OSAL_GetPhysANB(pOutputData->dataBuffer, pPhys);
+ pYUVBuf[0] = outputInfo.YPhyAddr;
+ pYUVBuf[1] = outputInfo.CPhyAddr;
+ csc_fimc_convert_nv12t(pMpeg4Dec->hFIMCHandle, pPhys,
+ pYUVBuf, width, height,
+ OMX_COLOR_FormatYUV420Planar);
+ break;
+ }
+#endif
+ csc_tiled_to_linear_y_neon(
+ (unsigned char *)pYUVBuf[0],
+ (unsigned char *)outputInfo.YVirAddr,
+ width,
+ height);
+ csc_tiled_to_linear_uv_deinterleave_neon(
+ (unsigned char *)pYUVBuf[1],
+ (unsigned char *)pYUVBuf[2],
+ (unsigned char *)outputInfo.CVirAddr,
+ width,
+ height / 2);
+ break;
+ }
+ }
+#ifdef USE_ANB
+ if (pSECOutputPort->bIsANBEnabled == OMX_TRUE) {
+ SEC_OSAL_UnlockANB(pOutputData->dataBuffer);
+ }
+#endif
+ } else {
+ pOutputData->dataLen = 0;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_Mpeg4_Decode_Block(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_OMX_VIDEODEC_COMPONENT *pVideoDec = (SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle;
+ SEC_OMX_BASEPORT *pSECInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+ SEC_MPEG4_HANDLE *pMpeg4Dec = (SEC_MPEG4_HANDLE *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ OMX_HANDLETYPE hMFCHandle = pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle;
+ OMX_U32 oneFrameSize = pInputData->dataLen;
+ SSBSIP_MFC_DEC_OUTPUT_INFO outputInfo;
+ OMX_S32 configValue;
+ OMX_S32 returnCodec;
+ int bufWidth;
+ int bufHeight;
+ OMX_U32 FrameBufferYSize;
+ OMX_U32 FrameBufferUVSize;
+
+ 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 mpeg4 deblocking filter enable */
+ configValue = 1;
+ SsbSipMfcDecSetConfig(hMFCHandle, MFC_DEC_SETCONF_POST_ENABLE, &configValue);
+
+ if (pVideoDec->bThumbnailMode == OMX_TRUE) {
+ configValue = 0; // the number that you want to delay
+ SsbSipMfcDecSetConfig(hMFCHandle, MFC_DEC_SETCONF_DISPLAY_DELAY, &configValue);
+ } else {
+ configValue = MPEG4_DEC_NUM_OF_EXTRA_BUFFERS;
+ SsbSipMfcDecSetConfig(hMFCHandle, MFC_DEC_SETCONF_EXTRA_BUFFER_NUM, &configValue);
+ }
+
+ returnCodec = SsbSipMfcDecInit(hMFCHandle, MFCCodecType, oneFrameSize);
+ if (returnCodec == MFC_RET_OK) {
+ SSBSIP_MFC_IMG_RESOLUTION imgResol;
+
+ 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 ((pSECInputPort->portDefinition.format.video.nFrameWidth != (unsigned int)imgResol.width) ||
+ (pSECInputPort->portDefinition.format.video.nFrameHeight != (unsigned int)imgResol.height)) {
+ /* change width and height information */
+ pSECInputPort->portDefinition.format.video.nFrameWidth = imgResol.width;
+ pSECInputPort->portDefinition.format.video.nFrameHeight = imgResol.height;
+ pSECInputPort->portDefinition.format.video.nStride = ((imgResol.width + 15) & (~15));
+ pSECInputPort->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)",
+ pSECInputPort->portDefinition.format.video.nFrameWidth, pSECInputPort->portDefinition.format.video.nFrameHeight,
+ pSECInputPort->portDefinition.format.video.nStride, pSECInputPort->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
+
+ if (Check_Stream_PrefixCode(pInputData->dataBuffer, pInputData->dataLen, pMpeg4Dec->hMFCMpeg4Handle.codecType) == OMX_TRUE) {
+ pSECComponent->timeStamp[pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp] = pInputData->timeStamp;
+ pSECComponent->nFlags[pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp] = pInputData->nFlags;
+ SsbSipMfcDecSetConfig(hMFCHandle, MFC_DEC_SETCONF_FRAME_TAG, &(pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp));
+
+ returnCodec = SsbSipMfcDecExe(hMFCHandle, oneFrameSize);
+ } else {
+ if (pSECComponent->checkTimeStamp.needCheckStartTimeStamp == OMX_TRUE)
+ pSECComponent->checkTimeStamp.needSetStartTimeStamp = OMX_TRUE;
+
+ pOutputData->timeStamp = pInputData->timeStamp;
+ pOutputData->nFlags = pInputData->nFlags;
+ returnCodec = MFC_RET_OK;
+ goto EXIT;
+ }
+
+ if (returnCodec == MFC_RET_OK) {
+ SSBSIP_MFC_DEC_OUTBUF_STATUS status;
+ OMX_S32 indexTimestamp = 0;
+
+ status = SsbSipMfcDecGetOutBuf(hMFCHandle, &outputInfo);
+ bufWidth = (outputInfo.img_width + 15) & (~15);
+ bufHeight = (outputInfo.img_height + 15) & (~15);
+ FrameBufferYSize = ALIGN_TO_8KB(ALIGN_TO_128B(outputInfo.img_width) * ALIGN_TO_32B(outputInfo.img_height));
+ FrameBufferUVSize = ALIGN_TO_8KB(ALIGN_TO_128B(outputInfo.img_width) * ALIGN_TO_32B(outputInfo.img_height/2));
+
+ if (status != MFC_GETOUTBUF_DISPLAY_ONLY) {
+ pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp++;
+ pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp %= MAX_TIMESTAMP;
+ }
+
+ 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;
+ } else {
+ /* For timestamp correction. if mfc support frametype detect */
+ SEC_OSAL_Log(SEC_LOG_TRACE, "disp_pic_frame_type: %d", outputInfo.disp_pic_frame_type);
+#ifdef NEED_TIMESTAMP_REORDER
+ if (outputInfo.disp_pic_frame_type == MFC_FRAME_TYPE_I_FRAME) {
+ pOutputData->timeStamp = pSECComponent->timeStamp[indexTimestamp];
+ pOutputData->nFlags = pSECComponent->nFlags[indexTimestamp];
+ pMpeg4Dec->hMFCMpeg4Handle.outputIndexTimestamp = indexTimestamp;
+ } else {
+ pOutputData->timeStamp = pSECComponent->timeStamp[pMpeg4Dec->hMFCMpeg4Handle.outputIndexTimestamp];
+ pOutputData->nFlags = pSECComponent->nFlags[pMpeg4Dec->hMFCMpeg4Handle.outputIndexTimestamp];
+ }
+#else
+ pOutputData->timeStamp = pSECComponent->timeStamp[indexTimestamp];
+ pOutputData->nFlags = pSECComponent->nFlags[indexTimestamp];
+#endif
+ }
+
+ if ((status == MFC_GETOUTBUF_DISPLAY_DECODING) ||
+ (status == MFC_GETOUTBUF_DISPLAY_ONLY)) {
+ /** Fill Output Buffer **/
+ void *pOutputBuf = (void *)pOutputData->dataBuffer;
+ void *pYUVBuf[3];
+
+ int frameSize = bufWidth * bufHeight;
+ int width = outputInfo.img_width;
+ int height = outputInfo.img_height;
+ int imageSize = outputInfo.img_width * outputInfo.img_height;
+
+ pYUVBuf[0] = (unsigned char *)pOutputBuf;
+ pYUVBuf[1] = (unsigned char *)pOutputBuf + imageSize;
+ pYUVBuf[2] = (unsigned char *)pOutputBuf + imageSize + imageSize / 4;
+ pOutputData->dataLen = (imageSize * 3) / 2;
+
+#ifdef USE_ANB
+ if (pSECOutputPort->bIsANBEnabled == OMX_TRUE) {
+ OMX_U32 stride;
+ SEC_OSAL_LockANB(pOutputData->dataBuffer, width, height, pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eColorFormat, &stride, pYUVBuf);
+ width = stride;
+ pOutputData->dataLen = sizeof(void *);
+ }
+#endif
+ if ((pVideoDec->bThumbnailMode == OMX_FALSE) &&
+ (pSECOutputPort->portDefinition.format.video.eColorFormat == OMX_SEC_COLOR_FormatNV12TPhysicalAddress)) {
+ /* if use Post copy address structure */
+ SEC_OSAL_Memcpy(pOutputBuf, &(outputInfo.YPhyAddr), sizeof(outputInfo.YPhyAddr));
+ SEC_OSAL_Memcpy((unsigned char *)pOutputBuf + (sizeof(void *) * 1), &(outputInfo.CPhyAddr), sizeof(outputInfo.CPhyAddr));
+ SEC_OSAL_Memcpy((unsigned char *)pOutputBuf + (sizeof(void *) * 2), &(outputInfo.YVirAddr), sizeof(outputInfo.YVirAddr));
+ SEC_OSAL_Memcpy((unsigned char *)pOutputBuf + (sizeof(void *) * 3), &(outputInfo.CVirAddr), sizeof(outputInfo.CVirAddr));
+ pOutputData->dataLen = (outputInfo.img_width * outputInfo.img_height * 3) / 2;
+ } else {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "YUV420 out for ThumbnailMode");
+ switch (pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eColorFormat) {
+ case OMX_SEC_COLOR_FormatNV12Tiled:
+ SEC_OSAL_Memcpy(pOutputBuf, outputInfo.YVirAddr, FrameBufferYSize);
+ SEC_OSAL_Memcpy((unsigned char *)pOutputBuf + FrameBufferYSize, outputInfo.CVirAddr, FrameBufferUVSize);
+ pOutputData->dataLen = FrameBufferYSize + FrameBufferUVSize;
+ break;
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ case OMX_SEC_COLOR_FormatANBYUV420SemiPlanar:
+#ifdef USE_CSC_FIMC
+ if ((pSECOutputPort->bIsANBEnabled == OMX_TRUE) && (pMpeg4Dec->hFIMCHandle != NULL)) {
+ void *pPhys[3];
+ SEC_OSAL_GetPhysANB(pOutputData->dataBuffer, pPhys);
+ pYUVBuf[0] = outputInfo.YPhyAddr;
+ pYUVBuf[1] = outputInfo.CPhyAddr;
+ csc_fimc_convert_nv12t(pMpeg4Dec->hFIMCHandle, pPhys,
+ pYUVBuf, width, height,
+ OMX_SEC_COLOR_FormatANBYUV420SemiPlanar);
+ break;
+ }
+#endif
+ csc_tiled_to_linear_y_neon(
+ (unsigned char *)pYUVBuf[0],
+ (unsigned char *)outputInfo.YVirAddr,
+ width,
+ height);
+ csc_tiled_to_linear_uv_neon(
+ (unsigned char *)pYUVBuf[1],
+ (unsigned char *)outputInfo.CVirAddr,
+ width,
+ height / 2);
+ break;
+ case OMX_COLOR_FormatYUV420Planar:
+ default:
+#ifdef USE_CSC_FIMC
+ if ((pSECOutputPort->bIsANBEnabled == OMX_TRUE) && (pMpeg4Dec->hFIMCHandle != NULL)) {
+ void *pPhys[3];
+ SEC_OSAL_GetPhysANB(pOutputData->dataBuffer, pPhys);
+ pYUVBuf[0] = outputInfo.YPhyAddr;
+ pYUVBuf[1] = outputInfo.CPhyAddr;
+ csc_fimc_convert_nv12t(pMpeg4Dec->hFIMCHandle, pPhys,
+ pYUVBuf, width, height,
+ OMX_COLOR_FormatYUV420Planar);
+ break;
+ }
+#endif
+ csc_tiled_to_linear_y_neon(
+ (unsigned char *)pYUVBuf[0],
+ (unsigned char *)outputInfo.YVirAddr,
+ width,
+ height);
+ csc_tiled_to_linear_uv_deinterleave_neon(
+ (unsigned char *)pYUVBuf[1],
+ (unsigned char *)pYUVBuf[2],
+ (unsigned char *)outputInfo.CVirAddr,
+ width,
+ height / 2);
+ break;
+ }
+ }
+
+#ifdef USE_ANB
+ if (pSECOutputPort->bIsANBEnabled == OMX_TRUE) {
+ SEC_OSAL_UnlockANB(pOutputData->dataBuffer);
+ }
+#endif
+ pMpeg4Dec->hMFCMpeg4Handle.outputIndexTimestamp++;
+ pMpeg4Dec->hMFCMpeg4Handle.outputIndexTimestamp %= MAX_TIMESTAMP;
+ }
+ if (pOutputData->nFlags & OMX_BUFFERFLAG_EOS)
+ pOutputData->dataLen = 0;
+
+ 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;
+ }
+ goto EXIT;
+ }
+
+#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) {
+ 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;
+ }
+ pOutputData->dataLen = 0;
+
+ /* ret = OMX_ErrorUndefined; */
+ ret = OMX_ErrorNone;
+ goto EXIT;
+ }
+
+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 *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ SEC_OMX_BASEPORT *pSECInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+ OMX_BOOL bCheckPrefix = 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;
+ }
+
+#ifdef NONBLOCK_MODE_PROCESS
+ ret = SEC_MFC_Mpeg4_Decode_Nonblock(pOMXComponent, pInputData, pOutputData);
+#else
+ ret = SEC_MFC_Mpeg4_Decode_Block(pOMXComponent, pInputData, pOutputData);
+#endif
+ 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_OMX_VIDEODEC_COMPONENT *pVideoDec = 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_DEC_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));
+ pVideoDec = (SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle;
+ pVideoDec->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_FormatYUV420Planar;
+ 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 *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ if (pMpeg4Dec != NULL) {
+ SEC_OSAL_Free(pMpeg4Dec);
+ ((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle = NULL;
+ }
+
+ ret = SEC_OMX_VideoDecodeComponentDeinit(pOMXComponent);
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ ret = OMX_ErrorNone;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
diff --git a/exynos/multimedia/openmax/component/video/dec/mpeg4/SEC_OMX_Mpeg4dec.h b/exynos/multimedia/openmax/component/video/dec/mpeg4/SEC_OMX_Mpeg4dec.h
new file mode 100644
index 0000000..c844ff9
--- /dev/null
+++ b/exynos/multimedia/openmax/component/video/dec/mpeg4/SEC_OMX_Mpeg4dec.h
@@ -0,0 +1,97 @@
+/*
+ *
+ * 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.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_U32 outputIndexTimestamp;
+ OMX_BOOL bConfiguredMFC;
+ 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;
+
+ /* CSC FIMC handle */
+#ifdef USE_CSC_FIMC
+ OMX_PTR hFIMCHandle;
+#endif
+} 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/exynos/multimedia/openmax/component/video/dec/mpeg4/library_register.c b/exynos/multimedia/openmax/component/video/dec/mpeg4/library_register.c
new file mode 100644
index 0000000..2ae1b0d
--- /dev/null
+++ b/exynos/multimedia/openmax/component/video/dec/mpeg4/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.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/exynos/multimedia/openmax/component/video/dec/mpeg4/library_register.h b/exynos/multimedia/openmax/component/video/dec/mpeg4/library_register.h
new file mode 100644
index 0000000..40aec73
--- /dev/null
+++ b/exynos/multimedia/openmax/component/video/dec/mpeg4/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.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
+
diff --git a/exynos/multimedia/openmax/component/video/dec/vc1/Android.mk b/exynos/multimedia/openmax/component/video/dec/vc1/Android.mk
new file mode 100644
index 0000000..9412233
--- /dev/null
+++ b/exynos/multimedia/openmax/component/video/dec/vc1/Android.mk
@@ -0,0 +1,52 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := \
+ SEC_OMX_Wmvdec.c \
+ library_register.c
+
+LOCAL_PRELINK_MODULE := false
+LOCAL_MODULE := libOMX.SEC.WMV.Decoder
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/omx
+
+LOCAL_CFLAGS :=
+
+ifeq ($(BOARD_NONBLOCK_MODE_PROCESS), true)
+LOCAL_CFLAGS += -DNONBLOCK_MODE_PROCESS
+endif
+
+ifeq ($(BOARD_USE_ANB), true)
+LOCAL_CFLAGS += -DUSE_ANB
+ifeq ($(BOARD_USE_CSC_FIMC), true)
+ifeq ($(BOARD_USE_V4L2_ION), false)
+LOCAL_CFLAGS += -DUSE_CSC_FIMC
+endif
+endif
+endif
+
+LOCAL_ARM_MODE := arm
+
+LOCAL_STATIC_LIBRARIES := libSEC_OMX_Vdec libsecosal libsecbasecomponent \
+ libseccscapi libsecmfcapi
+LOCAL_SHARED_LIBRARIES := libc libdl libcutils libutils libui \
+ libSEC_OMX_Resourcemanager
+
+ifeq ($(filter-out exynos4,$(TARGET_BOARD_PLATFORM)),)
+LOCAL_SHARED_LIBRARIES += libhwconverter
+endif
+
+#ifeq ($(BOARD_USE_V4L2_ION),true)
+#LOCAL_SHARED_LIBRARIES += libion
+#endif
+
+LOCAL_C_INCLUDES := $(SEC_OMX_INC)/khronos \
+ $(SEC_OMX_INC)/sec \
+ $(SEC_OMX_TOP)/osal \
+ $(SEC_OMX_TOP)/core \
+ $(SEC_OMX_COMPONENT)/common \
+ $(SEC_OMX_COMPONENT)/video/dec \
+ $(TARGET_OUT_HEADERS)/$(SEC_COPY_HEADERS_TO)
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/exynos/multimedia/openmax/component/video/dec/vc1/SEC_OMX_Wmvdec.c b/exynos/multimedia/openmax/component/video/dec/vc1/SEC_OMX_Wmvdec.c
new file mode 100644
index 0000000..ebc2a0f
--- /dev/null
+++ b/exynos/multimedia/openmax/component/video/dec/vc1/SEC_OMX_Wmvdec.c
@@ -0,0 +1,1960 @@
+/*
+ *
+ * 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_Wmvdec.c
+ * @brief
+ * @author HyeYeon Chung (hyeon.chung@samsung.com)
+ * @version 1.1.0
+ * @history
+ * 2010.8.16 : Create
+ * 2010.8.20 : Support WMV3 (Vc-1 Simple/Main Profile)
+ * 2010.8.21 : Support WMvC1 (Vc-1 Advanced Profile)
+ */
+
+#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 "SEC_OSAL_ETC.h"
+#include "SEC_OSAL_Semaphore.h"
+#include "SEC_OSAL_Thread.h"
+#include "SEC_OSAL_Memory.h"
+#include "library_register.h"
+#include "SEC_OMX_Wmvdec.h"
+#include "SsbSipMfcApi.h"
+#include "SEC_OSAL_Event.h"
+#include "color_space_convertor.h"
+
+#ifdef USE_ANB
+#include "SEC_OSAL_Android.h"
+#endif
+
+/* To use CSC FIMC in SEC OMX, gralloc should allocate physical memory using FIMC */
+/* It means GRALLOC_USAGE_HW_FIMC1 should be set on Native Window usage */
+#ifdef USE_CSC_FIMC
+#include "csc_fimc.h"
+#endif
+
+#undef SEC_LOG_TAG
+#define SEC_LOG_TAG "SEC_WMV_DEC"
+#define SEC_LOG_OFF
+#include "SEC_OSAL_Log.h"
+
+#define WMV_DEC_NUM_OF_EXTRA_BUFFERS 7
+
+//#define FULL_FRAME_SEARCH
+
+/* ASF parser does not send start code on OpenCORE */
+#define WO_START_CODE
+
+static OMX_HANDLETYPE ghMFCHandle = NULL;
+static WMV_FORMAT gWvmFormat = WMV_FORMAT_UNKNOWN;
+
+const OMX_U32 wmv3 = 0x33564d57;
+const OMX_U32 wvc1 = 0x31435657;
+const OMX_U32 wmva = 0x41564d57;
+
+static int Check_Wmv_Frame(OMX_U8 *pInputStream, OMX_U32 buffSize, OMX_U32 flag, OMX_BOOL bPreviousFrameEOF, OMX_BOOL *pbEndOfFrame)
+{
+ OMX_U32 compressionID;
+ OMX_BOOL bFrameStart;
+ OMX_U32 len, readStream;
+ OMX_U32 startCode;
+
+ SEC_OSAL_Log(SEC_LOG_TRACE, "buffSize = %d", buffSize);
+
+ len = 0;
+ bFrameStart = OMX_FALSE;
+
+ if (flag & OMX_BUFFERFLAG_CODECCONFIG) {
+ BitmapInfoHhr *pBitmapInfoHeader;
+ pBitmapInfoHeader = (BitmapInfoHhr *)pInputStream;
+
+ compressionID = pBitmapInfoHeader->BiCompression;
+ if (compressionID == wmv3) {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "WMV_FORMAT_WMV3");
+ gWvmFormat = WMV_FORMAT_WMV3;
+
+ *pbEndOfFrame = OMX_TRUE;
+ return buffSize;
+ }
+ else if ((compressionID == wvc1) || (compressionID == wmva)) {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "WMV_FORMAT_VC1");
+ gWvmFormat = WMV_FORMAT_VC1;
+
+#ifdef WO_START_CODE
+/* ASF parser does not send start code on OpenCORE */
+ *pbEndOfFrame = OMX_TRUE;
+ return buffSize;
+#endif
+ }
+ }
+
+ if (gWvmFormat == WMV_FORMAT_WMV3) {
+ *pbEndOfFrame = OMX_TRUE;
+ return buffSize;
+ }
+
+#ifdef WO_START_CODE
+/* ASF parser does not send start code on OpenCORE */
+ if (gWvmFormat == WMV_FORMAT_VC1) {
+ *pbEndOfFrame = OMX_TRUE;
+ return buffSize;
+ }
+#else
+ /* TODO : for comformanc test based on common buffer scheme w/o parser */
+
+ if (bPreviousFrameEOF == OMX_FALSE)
+ bFrameStart = OMX_TRUE;
+
+ startCode = 0xFFFFFFFF;
+ if (bFrameStart == OMX_FALSE) {
+ /* find Frame start code */
+ while(startCode != 0x10D) {
+ readStream = *(pInputStream + len);
+ startCode = (startCode << 8) | readStream;
+ len++;
+ if (len > buffSize)
+ goto EXIT;
+ }
+ }
+
+ /* find next Frame start code */
+ startCode = 0xFFFFFFFF;
+ while ((startCode != 0x10D)) {
+ readStream = *(pInputStream + len);
+ startCode = (startCode << 8) | readStream;
+ len++;
+ if (len > buffSize)
+ goto EXIT;
+ }
+
+ *pbEndOfFrame = OMX_TRUE;
+
+ SEC_OSAL_Log(SEC_LOG_TRACE, "1. Check_Wmv_Frame returned EOF = %d, len = %d, buffSize = %d", *pbEndOfFrame, len - 4, buffSize);
+
+ return len - 4;
+#endif
+
+EXIT :
+ *pbEndOfFrame = OMX_FALSE;
+
+ SEC_OSAL_Log(SEC_LOG_TRACE, "2. Check_Wmv_Frame returned EOF = %d, len = %d, buffSize = %d", *pbEndOfFrame, len - 1, buffSize);
+
+ return --len;
+}
+
+OMX_BOOL Check_Stream_PrefixCode(OMX_U8 *pInputStream, OMX_U32 streamSize, WMV_FORMAT wmvFormat)
+{
+ switch (wmvFormat) {
+ case WMV_FORMAT_WMV3:
+ if (streamSize > 0)
+ return OMX_TRUE;
+ else
+ return OMX_FALSE;
+ break;
+ case WMV_FORMAT_VC1:
+
+#ifdef WO_START_CODE
+ /* ASF parser does not send start code on OpenCORE */
+ if (streamSize > 3)
+ return OMX_TRUE;
+ else
+ return OMX_FALSE;
+ break;
+#else
+ /* TODO : for comformanc test based on common buffer scheme w/o parser */
+ if (streamSize < 3) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "%s: streamSize is too small (%d)", __FUNCTION__, streamSize);
+ return OMX_FALSE;
+ } else if ((pInputStream[0] == 0x00) &&
+ (pInputStream[1] == 0x00) &&
+ (pInputStream[2] == 0x01)) {
+ return OMX_TRUE;
+ } else {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "%s: Cannot find prefix", __FUNCTION__);
+ return OMX_FALSE;
+ }
+#endif
+ break;
+
+ default:
+ SEC_OSAL_Log(SEC_LOG_WARNING, "%s: undefined wmvFormat (%d)", __FUNCTION__, wmvFormat);
+ return OMX_FALSE;
+ break;
+ }
+}
+
+OMX_BOOL Make_Stream_MetaData(OMX_U8 *pInputStream, OMX_U32 *pStreamSize, WMV_FORMAT wmvFormat)
+{
+ OMX_U32 width, height;
+ OMX_U8 *pCurrBuf = pInputStream;
+ OMX_U32 currPos = 0;
+
+ FunctionIn();
+
+ /* Sequence Layer Data Structure */
+ OMX_U8 const_C5[4] = {0x00, 0x00, 0x00, 0xc5};
+ OMX_U8 const_04[4] = {0x04, 0x00, 0x00, 0x00};
+ OMX_U8 const_0C[4] = {0x0C, 0x00, 0x00, 0x00};
+ OMX_U8 struct_B_1[4] = {0xB3, 0x19, 0x00, 0x00};
+ OMX_U8 struct_B_2[4] = {0x44, 0x62, 0x05, 0x00};
+ OMX_U8 struct_B_3[4] = {0x0F, 0x00, 0x00, 0x00};
+ OMX_U8 struct_C[4] = {0x30, 0x00, 0x00, 0x00};
+
+ switch (wmvFormat) {
+ case WMV_FORMAT_WMV3:
+ if (*pStreamSize >= BITMAPINFOHEADER_SIZE) {
+ BitmapInfoHhr *pBitmapInfoHeader;
+ pBitmapInfoHeader = (BitmapInfoHhr *)pInputStream;
+
+ width = pBitmapInfoHeader->BiWidth;
+ height = pBitmapInfoHeader->BiHeight;
+ if (*pStreamSize > BITMAPINFOHEADER_SIZE)
+ SEC_OSAL_Memcpy(struct_C, pInputStream+BITMAPINFOHEADER_SIZE, 4);
+
+ SEC_OSAL_Memcpy(pCurrBuf + currPos, const_C5, 4);
+ currPos +=4;
+
+ SEC_OSAL_Memcpy(pCurrBuf + currPos, const_04, 4);
+ currPos +=4;
+
+ SEC_OSAL_Memcpy(pCurrBuf + currPos, struct_C, 4);
+ currPos +=4;
+
+ /* struct_A : VERT_SIZE */
+ pCurrBuf[currPos] = height & 0xFF;
+ pCurrBuf[currPos+1] = (height>>8) & 0xFF;
+ pCurrBuf[currPos+2] = (height>>16) & 0xFF;
+ pCurrBuf[currPos+3] = (height>>24) & 0xFF;
+ currPos +=4;
+
+ /* struct_A : HORIZ_SIZE */
+ pCurrBuf[currPos] = width & 0xFF;
+ pCurrBuf[currPos+1] = (width>>8) & 0xFF;
+ pCurrBuf[currPos+2] = (width>>16) & 0xFF;
+ pCurrBuf[currPos+3] = (width>>24) & 0xFF;
+ currPos +=4;
+
+ SEC_OSAL_Memcpy(pCurrBuf + currPos,const_0C, 4);
+ currPos +=4;
+
+ SEC_OSAL_Memcpy(pCurrBuf + currPos, struct_B_1, 4);
+ currPos +=4;
+
+ SEC_OSAL_Memcpy(pCurrBuf + currPos, struct_B_2, 4);
+ currPos +=4;
+
+ SEC_OSAL_Memcpy(pCurrBuf + currPos, struct_B_3, 4);
+ currPos +=4;
+
+ *pStreamSize = currPos;
+ return OMX_TRUE;
+ } else {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "%s: *pStreamSize is too small to contain metadata(%d)", __FUNCTION__, *pStreamSize);
+ return OMX_FALSE;
+ }
+ break;
+ case WMV_FORMAT_VC1:
+ if (*pStreamSize >= BITMAPINFOHEADER_ASFBINDING_SIZE) {
+ SEC_OSAL_Memcpy(pCurrBuf, pInputStream + BITMAPINFOHEADER_ASFBINDING_SIZE, *pStreamSize - BITMAPINFOHEADER_ASFBINDING_SIZE);
+ *pStreamSize -= BITMAPINFOHEADER_ASFBINDING_SIZE;
+ return OMX_TRUE;
+ } else {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "%s: *pStreamSize is too small to contain metadata(%d)", __FUNCTION__, *pStreamSize);
+ return OMX_FALSE;
+ }
+ break;
+ default:
+ SEC_OSAL_Log(SEC_LOG_WARNING, "%s: It is not necessary to make bitstream metadata for wmvFormat (%d)", __FUNCTION__, wmvFormat);
+ return OMX_FALSE;
+ break;
+ }
+}
+
+#ifdef WO_START_CODE
+OMX_BOOL Make_Stream_StartCode(OMX_U8 *pInputStream, OMX_U32 streamSize, WMV_FORMAT wmvFormat)
+{
+ OMX_U8 frameStartCode[4] = {0x00, 0x00, 0x01, 0x0d};
+ OMX_U32 i;
+
+ switch (wmvFormat) {
+ case WMV_FORMAT_WMV3:
+ return OMX_TRUE;
+ break;
+
+ case WMV_FORMAT_VC1:
+ /* Should find better way to shift data */
+ SEC_OSAL_Memmove(pInputStream+4, pInputStream, streamSize);
+ SEC_OSAL_Memcpy(pInputStream, frameStartCode, 4);
+
+ return OMX_TRUE;
+ break;
+
+ default:
+ SEC_OSAL_Log(SEC_LOG_WARNING, "%s: undefined wmvFormat (%d)", __FUNCTION__, wmvFormat);
+ return OMX_FALSE;
+ break;
+ }
+}
+#endif
+
+OMX_ERRORTYPE SEC_MFC_WmvDec_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_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ switch (nParamIndex) {
+ case OMX_IndexParamVideoWmv:
+ {
+ OMX_VIDEO_PARAM_WMVTYPE *pDstWmvParam = (OMX_VIDEO_PARAM_WMVTYPE *)pComponentParameterStructure;
+ OMX_VIDEO_PARAM_WMVTYPE *pSrcWmvParam = NULL;
+ SEC_WMV_HANDLE *pWmvDec = NULL;
+ ret = SEC_OMX_Check_SizeVersion(pDstWmvParam, sizeof(OMX_VIDEO_PARAM_WMVTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pDstWmvParam->nPortIndex > OUTPUT_PORT_INDEX) {
+ ret = OMX_ErrorBadPortIndex;
+ }
+
+ pWmvDec = (SEC_WMV_HANDLE *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ pSrcWmvParam = &pWmvDec->WmvComponent[pDstWmvParam->nPortIndex];
+
+ SEC_OSAL_Memcpy(pDstWmvParam, pSrcWmvParam, sizeof(OMX_VIDEO_PARAM_WMVTYPE));
+ }
+ 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_WMV_DEC_ROLE);
+ }
+ break;
+ case OMX_IndexParamVideoErrorCorrection:
+ {
+ OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pDstErrorCorrectionType = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *)pComponentParameterStructure;
+ OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pSrcErrorCorrectionType = NULL;
+ SEC_WMV_HANDLE *pWmvDec = 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;
+ }
+
+ pWmvDec = (SEC_WMV_HANDLE *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ pSrcErrorCorrectionType = &pWmvDec->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_WmvDec_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_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ switch (nIndex) {
+ case OMX_IndexParamVideoWmv:
+ {
+ OMX_VIDEO_PARAM_WMVTYPE *pDstWmvParam = NULL;
+ OMX_VIDEO_PARAM_WMVTYPE *pSrcWmvParam = (OMX_VIDEO_PARAM_WMVTYPE *)pComponentParameterStructure;
+ SEC_WMV_HANDLE *pWmvDec = NULL;
+ ret = SEC_OMX_Check_SizeVersion(pSrcWmvParam, sizeof(OMX_VIDEO_PARAM_WMVTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pSrcWmvParam->nPortIndex > OUTPUT_PORT_INDEX) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ pWmvDec = (SEC_WMV_HANDLE *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ pDstWmvParam = &pWmvDec->WmvComponent[pSrcWmvParam->nPortIndex];
+
+ SEC_OSAL_Memcpy(pDstWmvParam, pSrcWmvParam, sizeof(OMX_VIDEO_PARAM_WMVTYPE));
+ }
+ 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_WMV_DEC_ROLE)) {
+ pSECComponent->pSECPort[INPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingWMV;
+ } 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;
+ OMX_U32 realWidth, realHeight;
+
+ 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);
+
+ realWidth = pSECPort->portDefinition.format.video.nFrameWidth;
+ realHeight = pSECPort->portDefinition.format.video.nFrameHeight;
+ width = ((realWidth + 15) & (~15));
+ height = ((realHeight + 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;
+ case OMX_SEC_COLOR_FormatNV12Tiled:
+ pSECOutputPort->portDefinition.nBufferSize =
+ ALIGN_TO_8KB(ALIGN_TO_128B(realWidth) * ALIGN_TO_32B(realHeight)) \
+ + ALIGN_TO_8KB(ALIGN_TO_128B(realWidth) * ALIGN_TO_32B(realHeight/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_IndexParamVideoErrorCorrection:
+ {
+ OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pSrcErrorCorrectionType = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *)pComponentParameterStructure;
+ OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pDstErrorCorrectionType = NULL;
+ SEC_WMV_HANDLE *pWmvDec = 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;
+ }
+
+ pWmvDec = (SEC_WMV_HANDLE *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ pDstErrorCorrectionType = &pWmvDec->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_WmvDec_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_VideoDecodeGetConfig(hComponent, nIndex, pComponentConfigStructure);
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_WmvDec_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) {
+ default:
+ ret = SEC_OMX_VideoDecodeSetConfig(hComponent, nIndex, pComponentConfigStructure);
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_WmvDec_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_WMV_HANDLE *pWmvDec = (SEC_WMV_HANDLE *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+
+ *pIndexType = OMX_IndexVendorThumbnailMode;
+
+ ret = OMX_ErrorNone;
+ } else {
+ ret = SEC_OMX_VideoDecodeGetExtensionIndex(hComponent, cParameterName, pIndexType);
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_WmvDec_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;
+
+ 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_WMV_DEC_ROLE);
+ ret = OMX_ErrorNone;
+ } else {
+ ret = OMX_ErrorUnsupportedIndex;
+ }
+
+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 = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ SEC_OMX_VIDEODEC_COMPONENT *pVideoDec = (SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle;
+ SEC_WMV_HANDLE *pWmvDec = (SEC_WMV_HANDLE *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ while (pVideoDec->NBDecThread.bExitDecodeThread == OMX_FALSE) {
+ SEC_OSAL_SemaphoreWait(pVideoDec->NBDecThread.hDecFrameStart);
+
+ if (pVideoDec->NBDecThread.bExitDecodeThread == OMX_FALSE) {
+ pWmvDec->hMFCWmvHandle.returnCodec = SsbSipMfcDecExe(pWmvDec->hMFCWmvHandle.hMFCHandle, pVideoDec->NBDecThread.oneFrameSize);
+ SEC_OSAL_SemaphorePost(pVideoDec->NBDecThread.hDecFrameEnd);
+ }
+ }
+
+EXIT:
+ SEC_OSAL_ThreadExit(NULL);
+ FunctionOut();
+
+ return ret;
+}
+
+/* MFC Init */
+OMX_ERRORTYPE SEC_MFC_WmvDec_Init(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ SEC_OMX_VIDEODEC_COMPONENT *pVideoDec = (SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle;
+ SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+ SEC_WMV_HANDLE *pWmvDec = NULL;
+ OMX_HANDLETYPE hMFCHandle = NULL;
+ OMX_PTR pStreamBuffer = NULL;
+ OMX_PTR pStreamPhyBuffer = NULL;
+
+ FunctionIn();
+
+ pWmvDec = (SEC_WMV_HANDLE *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ pWmvDec->hMFCWmvHandle.bConfiguredMFC = OMX_FALSE;
+ pSECComponent->bUseFlagEOF = OMX_FALSE;
+ pSECComponent->bSaveFlagEOS = OMX_FALSE;
+
+ /* MFC(Multi Format Codec) decoder and CMM(Codec Memory Management) driver open */
+ if (pSECOutputPort->portDefinition.format.video.eColorFormat == OMX_SEC_COLOR_FormatNV12TPhysicalAddress) {
+ hMFCHandle = (OMX_PTR)SsbSipMfcDecOpen();
+ } else {
+ SSBIP_MFC_BUFFER_TYPE buf_type = CACHE;
+ hMFCHandle = (OMX_PTR)SsbSipMfcDecOpenExt(&buf_type);
+ }
+
+ if (hMFCHandle == NULL) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ ghMFCHandle = pWmvDec->hMFCWmvHandle.hMFCHandle = hMFCHandle;
+
+ /* Allocate decoder's input buffer */
+ /* Get first input buffer */
+ pStreamBuffer = SsbSipMfcDecGetInBuf(hMFCHandle, &pStreamPhyBuffer, DEFAULT_MFC_INPUT_BUFFER_SIZE / 2);
+ if (pStreamBuffer == NULL) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ pVideoDec->MFCDecInputBuffer[0].VirAddr = pStreamBuffer;
+ pVideoDec->MFCDecInputBuffer[0].PhyAddr = pStreamPhyBuffer;
+ pVideoDec->MFCDecInputBuffer[0].bufferSize = DEFAULT_MFC_INPUT_BUFFER_SIZE / 2;
+ pVideoDec->MFCDecInputBuffer[0].dataSize = 0;
+
+#ifdef NONBLOCK_MODE_PROCESS
+ /* Get second input buffer */
+ pStreamBuffer = NULL;
+ pStreamBuffer = SsbSipMfcDecGetInBuf(hMFCHandle, &pStreamPhyBuffer, DEFAULT_MFC_INPUT_BUFFER_SIZE / 2);
+ if (pStreamBuffer == NULL) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ pVideoDec->MFCDecInputBuffer[1].VirAddr = pStreamBuffer;
+ pVideoDec->MFCDecInputBuffer[1].PhyAddr = pStreamPhyBuffer;
+ pVideoDec->MFCDecInputBuffer[1].bufferSize = DEFAULT_MFC_INPUT_BUFFER_SIZE / 2;
+ pVideoDec->MFCDecInputBuffer[1].dataSize = 0;
+ pVideoDec->indexInputBuffer = 0;
+
+ pVideoDec->bFirstFrame = OMX_TRUE;
+
+ pVideoDec->NBDecThread.bExitDecodeThread = OMX_FALSE;
+ pVideoDec->NBDecThread.bDecoderRun = OMX_FALSE;
+ pVideoDec->NBDecThread.oneFrameSize = 0;
+ SEC_OSAL_SemaphoreCreate(&(pVideoDec->NBDecThread.hDecFrameStart));
+ SEC_OSAL_SemaphoreCreate(&(pVideoDec->NBDecThread.hDecFrameEnd));
+ if (OMX_ErrorNone == SEC_OSAL_ThreadCreate(&pVideoDec->NBDecThread.hNBDecodeThread,
+ SEC_MFC_DecodeThread,
+ pOMXComponent)) {
+ pWmvDec->hMFCWmvHandle.returnCodec = MFC_RET_OK;
+ }
+#endif
+
+ pWmvDec->hMFCWmvHandle.pMFCStreamBuffer = pVideoDec->MFCDecInputBuffer[0].VirAddr;
+ pWmvDec->hMFCWmvHandle.pMFCStreamPhyBuffer = pVideoDec->MFCDecInputBuffer[0].PhyAddr;
+ pSECComponent->processData[INPUT_PORT_INDEX].dataBuffer = pVideoDec->MFCDecInputBuffer[0].VirAddr;
+ pSECComponent->processData[INPUT_PORT_INDEX].allocSize = pVideoDec->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);
+ pWmvDec->hMFCWmvHandle.indexTimestamp = 0;
+ pWmvDec->hMFCWmvHandle.outputIndexTimestamp = 0;
+ pSECComponent->getAllDelayBuffer = OMX_FALSE;
+
+#ifdef USE_CSC_FIMC
+ pWmvDec->hFIMCHandle = csc_fimc_open();
+#endif
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+/* MFC Terminate */
+OMX_ERRORTYPE SEC_MFC_WmvDec_Terminate(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ SEC_OMX_VIDEODEC_COMPONENT *pVideoDec = (SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle;
+ SEC_WMV_HANDLE *pWmvDec = NULL;
+ OMX_HANDLETYPE hMFCHandle = NULL;
+
+ FunctionIn();
+
+ pWmvDec = (SEC_WMV_HANDLE *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ hMFCHandle = pWmvDec->hMFCWmvHandle.hMFCHandle;
+
+ pWmvDec->hMFCWmvHandle.pMFCStreamBuffer = NULL;
+ pWmvDec->hMFCWmvHandle.pMFCStreamPhyBuffer = NULL;
+ pSECComponent->processData[INPUT_PORT_INDEX].dataBuffer = NULL;
+ pSECComponent->processData[INPUT_PORT_INDEX].allocSize = 0;
+
+#ifdef NONBLOCK_MODE_PROCESS
+ if (pVideoDec->NBDecThread.hNBDecodeThread != NULL) {
+ pVideoDec->NBDecThread.bExitDecodeThread = OMX_TRUE;
+ SEC_OSAL_SemaphorePost(pVideoDec->NBDecThread.hDecFrameStart);
+ SEC_OSAL_ThreadTerminate(pVideoDec->NBDecThread.hNBDecodeThread);
+ pVideoDec->NBDecThread.hNBDecodeThread = NULL;
+ }
+
+ if(pVideoDec->NBDecThread.hDecFrameEnd != NULL) {
+ SEC_OSAL_SemaphoreTerminate(pVideoDec->NBDecThread.hDecFrameEnd);
+ pVideoDec->NBDecThread.hDecFrameEnd = NULL;
+ }
+
+ if(pVideoDec->NBDecThread.hDecFrameStart != NULL) {
+ SEC_OSAL_SemaphoreTerminate(pVideoDec->NBDecThread.hDecFrameStart);
+ pVideoDec->NBDecThread.hDecFrameStart = NULL;
+ }
+#endif
+
+ if (hMFCHandle != NULL) {
+ SsbSipMfcDecClose(hMFCHandle);
+ pWmvDec->hMFCWmvHandle.hMFCHandle = NULL;
+ }
+
+#ifdef USE_CSC_FIMC
+ if (pWmvDec->hFIMCHandle != NULL) {
+ csc_fimc_close(pWmvDec->hFIMCHandle);
+ pWmvDec->hFIMCHandle = NULL;
+ }
+#endif
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_Wmv_Decode_Nonblock(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_OMX_VIDEODEC_COMPONENT *pVideoDec = (SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle;
+ SEC_OMX_BASEPORT *pSECInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+ SEC_WMV_HANDLE *pWmvDec = (SEC_WMV_HANDLE *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ OMX_U32 oneFrameSize = pInputData->dataLen;
+ SSBSIP_MFC_DEC_OUTPUT_INFO outputInfo;
+ OMX_S32 configValue = 0;
+ OMX_BOOL bMetaData = OMX_FALSE;
+ OMX_BOOL bStartCode = OMX_FALSE;
+ int bufWidth = 0;
+ int bufHeight = 0;
+ OMX_U32 FrameBufferYSize = 0;
+ OMX_U32 FrameBufferUVSize = 0;
+ OMX_BOOL outputDataValid = OMX_FALSE;
+
+ FunctionIn();
+
+ if (pWmvDec->hMFCWmvHandle.bConfiguredMFC == OMX_FALSE) {
+ SSBSIP_MFC_CODEC_TYPE MFCCodecType;
+
+ if ((oneFrameSize <= 0) && (pInputData->nFlags & OMX_BUFFERFLAG_EOS)) {
+ pOutputData->timeStamp = pInputData->timeStamp;
+ pOutputData->nFlags = pInputData->nFlags;
+ ret = OMX_ErrorNone;
+ goto EXIT;
+ }
+
+ if (pWmvDec->hMFCWmvHandle.wmvFormat == WMV_FORMAT_WMV3)
+ MFCCodecType = VC1RCV_DEC;
+ else if (pWmvDec->hMFCWmvHandle.wmvFormat == WMV_FORMAT_VC1)
+ MFCCodecType = VC1_DEC;
+ else
+ MFCCodecType = UNKNOWN_TYPE;
+
+ SEC_OSAL_Log(SEC_LOG_TRACE, "codec type = %d", MFCCodecType);
+
+ if (pVideoDec->bThumbnailMode == OMX_TRUE) {
+ configValue = 0; // the number that you want to delay
+ SsbSipMfcDecSetConfig(pWmvDec->hMFCWmvHandle.hMFCHandle, MFC_DEC_SETCONF_DISPLAY_DELAY, &configValue);
+ } else {
+ configValue = WMV_DEC_NUM_OF_EXTRA_BUFFERS;
+ SsbSipMfcDecSetConfig(pWmvDec->hMFCWmvHandle.hMFCHandle, MFC_DEC_SETCONF_EXTRA_BUFFER_NUM, &configValue);
+ }
+
+ bMetaData = Make_Stream_MetaData(pInputData->dataBuffer, &oneFrameSize, pWmvDec->hMFCWmvHandle.wmvFormat);
+ if (bMetaData == OMX_FALSE) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "Fail to Make Stream MetaData");
+ ret = OMX_ErrorMFCInit;
+ goto EXIT;
+ }
+
+ SsbSipMfcDecSetInBuf(pWmvDec->hMFCWmvHandle.hMFCHandle,
+ pWmvDec->hMFCWmvHandle.pMFCStreamPhyBuffer,
+ pWmvDec->hMFCWmvHandle.pMFCStreamBuffer,
+ pSECComponent->processData[INPUT_PORT_INDEX].allocSize);
+
+ pWmvDec->hMFCWmvHandle.returnCodec = SsbSipMfcDecInit(pWmvDec->hMFCWmvHandle.hMFCHandle, MFCCodecType, oneFrameSize);
+ if (pWmvDec->hMFCWmvHandle.returnCodec == MFC_RET_OK) {
+ SSBSIP_MFC_IMG_RESOLUTION imgResol;
+
+ if (SsbSipMfcDecGetConfig(pWmvDec->hMFCWmvHandle.hMFCHandle, MFC_DEC_GETCONF_BUF_WIDTH_HEIGHT, &imgResol) != MFC_RET_OK) {
+ ret = OMX_ErrorMFCInit;
+ SEC_OSAL_Log(SEC_LOG_ERROR, "SsbSipMfcDecGetConfig failed");
+ goto EXIT;
+ }
+
+ SEC_OSAL_Log(SEC_LOG_TRACE, "## nFrameWidth(%d) nFrameHeight(%d), nStride(%d), nSliceHeight(%d)",
+ pSECInputPort->portDefinition.format.video.nFrameWidth, pSECInputPort->portDefinition.format.video.nFrameHeight,
+ pSECInputPort->portDefinition.format.video.nStride, pSECInputPort->portDefinition.format.video.nSliceHeight);
+
+ /** Update Frame Size **/
+ if ((pSECInputPort->portDefinition.format.video.nFrameWidth != (unsigned int)imgResol.width) ||
+ (pSECInputPort->portDefinition.format.video.nFrameHeight != (unsigned int)imgResol.height)) {
+ /* change width and height information */
+ pSECInputPort->portDefinition.format.video.nFrameWidth = imgResol.width;
+ pSECInputPort->portDefinition.format.video.nFrameHeight = imgResol.height;
+ pSECInputPort->portDefinition.format.video.nStride = ((imgResol.width + 15) & (~15));
+ pSECInputPort->portDefinition.format.video.nSliceHeight = ((imgResol.height + 15) & (~15));
+
+ SEC_OSAL_Log(SEC_LOG_TRACE, "nFrameWidth(%d) nFrameHeight(%d), nStride(%d), nSliceHeight(%d)",
+ pSECInputPort->portDefinition.format.video.nFrameWidth, pSECInputPort->portDefinition.format.video.nFrameHeight,
+ pSECInputPort->portDefinition.format.video.nStride, pSECInputPort->portDefinition.format.video.nSliceHeight);
+
+ 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);
+ }
+
+ pWmvDec->hMFCWmvHandle.bConfiguredMFC = OMX_TRUE;
+
+ if (pWmvDec->hMFCWmvHandle.wmvFormat == WMV_FORMAT_WMV3) {
+ pOutputData->timeStamp = pInputData->timeStamp;
+ pOutputData->nFlags = pInputData->nFlags;
+ ret = OMX_ErrorNone;
+ } else {
+
+#ifdef WO_START_CODE
+/* ASF parser does not send start code on OpenCORE */
+ pOutputData->timeStamp = pInputData->timeStamp;
+ pOutputData->nFlags = pInputData->nFlags;
+ ret = OMX_ErrorNone;
+#else
+/* TODO : for comformanc test based on common buffer scheme w/o parser */
+ pOutputData->dataLen = 0;
+ ret = OMX_ErrorInputDataDecodeYet;
+#endif
+ }
+ goto EXIT;
+ } else {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "SsbSipMfcDecInit failed");
+ 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[pWmvDec->hMFCWmvHandle.indexTimestamp] = pInputData->timeStamp;
+ pSECComponent->nFlags[pWmvDec->hMFCWmvHandle.indexTimestamp] = pInputData->nFlags;
+
+ if ((pWmvDec->hMFCWmvHandle.returnCodec == MFC_RET_OK) && (pVideoDec->bFirstFrame == OMX_FALSE)) {
+ SSBSIP_MFC_DEC_OUTBUF_STATUS status;
+ OMX_S32 indexTimestamp = 0;
+
+ /* wait for mfc decode done */
+ if (pVideoDec->NBDecThread.bDecoderRun == OMX_TRUE) {
+ SEC_OSAL_SemaphoreWait(pVideoDec->NBDecThread.hDecFrameEnd);
+ pVideoDec->NBDecThread.bDecoderRun = OMX_FALSE;
+ }
+
+ SEC_OSAL_SleepMillisec(0);
+ status = SsbSipMfcDecGetOutBuf(pWmvDec->hMFCWmvHandle.hMFCHandle, &outputInfo);
+ bufWidth = (outputInfo.img_width + 15) & (~15);
+ bufHeight = (outputInfo.img_height + 15) & (~15);
+ FrameBufferYSize = ALIGN_TO_8KB(ALIGN_TO_128B(outputInfo.img_width) * ALIGN_TO_32B(outputInfo.img_height));
+ FrameBufferUVSize = ALIGN_TO_8KB(ALIGN_TO_128B(outputInfo.img_width) * ALIGN_TO_32B(outputInfo.img_height/2));
+
+ if ((SsbSipMfcDecGetConfig(pWmvDec->hMFCWmvHandle.hMFCHandle, MFC_DEC_GETCONF_FRAME_TAG, &indexTimestamp) != MFC_RET_OK) ||
+ (((indexTimestamp < 0) || (indexTimestamp >= MAX_TIMESTAMP)))) {
+ pOutputData->timeStamp = pInputData->timeStamp;
+ pOutputData->nFlags = pInputData->nFlags;
+ } else {
+ /* For timestamp correction. if mfc support frametype detect */
+ SEC_OSAL_Log(SEC_LOG_TRACE, "disp_pic_frame_type: %d", outputInfo.disp_pic_frame_type);
+#ifdef NEED_TIMESTAMP_REORDER
+ if (outputInfo.disp_pic_frame_type == MFC_FRAME_TYPE_I_FRAME) {
+ pOutputData->timeStamp = pSECComponent->timeStamp[indexTimestamp];
+ pOutputData->nFlags = pSECComponent->nFlags[indexTimestamp];
+ pWmvDec->hMFCWmvHandle.outputIndexTimestamp = indexTimestamp;
+ } else {
+ pOutputData->timeStamp = pSECComponent->timeStamp[pWmvDec->hMFCWmvHandle.outputIndexTimestamp];
+ pOutputData->nFlags = pSECComponent->nFlags[pWmvDec->hMFCWmvHandle.outputIndexTimestamp];
+ }
+#else
+ pOutputData->timeStamp = pSECComponent->timeStamp[indexTimestamp];
+ pOutputData->nFlags = pSECComponent->nFlags[indexTimestamp];
+#endif
+ }
+
+ if ((status == MFC_GETOUTBUF_DISPLAY_DECODING) ||
+ (status == MFC_GETOUTBUF_DISPLAY_ONLY)) {
+ outputDataValid = OMX_TRUE;
+ pWmvDec->hMFCWmvHandle.outputIndexTimestamp++;
+ pWmvDec->hMFCWmvHandle.outputIndexTimestamp %= MAX_TIMESTAMP;
+ }
+ 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) {
+ 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 ((pVideoDec->bFirstFrame == OMX_TRUE) &&
+ ((pOutputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) &&
+ ((pInputData->nFlags & OMX_BUFFERFLAG_CODECCONFIG) != OMX_BUFFERFLAG_CODECCONFIG)) {
+ pOutputData->nFlags = (pOutputData->nFlags & (~OMX_BUFFERFLAG_EOS));
+ }
+
+ outputDataValid = OMX_FALSE;
+
+ /* ret = OMX_ErrorUndefined; */
+ ret = OMX_ErrorNone;
+ }
+
+#ifdef WO_START_CODE
+ if (pInputData->allocSize < oneFrameSize+4) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "Can't attach startcode due to lack of buffer space");
+ ret = OMX_ErrorMFCInit;
+ goto EXIT;
+ }
+
+ bStartCode = Make_Stream_StartCode(pInputData->dataBuffer, oneFrameSize, pWmvDec->hMFCWmvHandle.wmvFormat);
+ if (bStartCode == OMX_FALSE) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "Fail to Make Stream Start Code");
+ ret = OMX_ErrorMFCInit;
+ goto EXIT;
+ }
+#endif
+
+ if (ret == OMX_ErrorInputDataDecodeYet) {
+ pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].dataSize = oneFrameSize;
+ pVideoDec->indexInputBuffer++;
+ pVideoDec->indexInputBuffer %= MFC_INPUT_BUFFER_NUM_MAX;
+ pWmvDec->hMFCWmvHandle.pMFCStreamBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].VirAddr;
+ pWmvDec->hMFCWmvHandle.pMFCStreamPhyBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].PhyAddr;
+ pSECComponent->processData[INPUT_PORT_INDEX].dataBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].VirAddr;
+ pSECComponent->processData[INPUT_PORT_INDEX].allocSize = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].bufferSize;
+ oneFrameSize = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].dataSize;
+ //pInputData->dataLen = oneFrameSize;
+ //pInputData->remainDataLen = oneFrameSize;
+ }
+
+ SEC_OSAL_Log(SEC_LOG_TRACE, "SsbSipMfcDecExe oneFrameSize = %d", oneFrameSize);
+
+ if ((Check_Stream_PrefixCode(pInputData->dataBuffer, oneFrameSize, pWmvDec->hMFCWmvHandle.wmvFormat) == OMX_TRUE) &&
+ ((pOutputData->nFlags & OMX_BUFFERFLAG_EOS) != OMX_BUFFERFLAG_EOS)) {
+ if ((ret != OMX_ErrorInputDataDecodeYet) || (pSECComponent->getAllDelayBuffer == OMX_TRUE)) {
+ SsbSipMfcDecSetConfig(pWmvDec->hMFCWmvHandle.hMFCHandle, MFC_DEC_SETCONF_FRAME_TAG, &(pWmvDec->hMFCWmvHandle.indexTimestamp));
+ pWmvDec->hMFCWmvHandle.indexTimestamp++;
+ pWmvDec->hMFCWmvHandle.indexTimestamp %= MAX_TIMESTAMP;
+ }
+
+ SsbSipMfcDecSetInBuf(pWmvDec->hMFCWmvHandle.hMFCHandle,
+ pWmvDec->hMFCWmvHandle.pMFCStreamPhyBuffer,
+ pWmvDec->hMFCWmvHandle.pMFCStreamBuffer,
+ pSECComponent->processData[INPUT_PORT_INDEX].allocSize);
+
+ pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].dataSize = oneFrameSize;
+#ifdef WO_START_CODE
+ pVideoDec->NBDecThread.oneFrameSize = oneFrameSize + 4; /* Frame Start Code */
+#else
+ pVideoDec->NBDecThread.oneFrameSize = oneFrameSize;
+#endif
+ /* mfc decode start */
+ SEC_OSAL_SemaphorePost(pVideoDec->NBDecThread.hDecFrameStart);
+ pVideoDec->NBDecThread.bDecoderRun = OMX_TRUE;
+ pWmvDec->hMFCWmvHandle.returnCodec = MFC_RET_OK;
+
+ SEC_OSAL_SleepMillisec(0);
+
+ pVideoDec->indexInputBuffer++;
+ pVideoDec->indexInputBuffer %= MFC_INPUT_BUFFER_NUM_MAX;
+ pWmvDec->hMFCWmvHandle.pMFCStreamBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].VirAddr;
+ pWmvDec->hMFCWmvHandle.pMFCStreamPhyBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].PhyAddr;
+ pSECComponent->processData[INPUT_PORT_INDEX].dataBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].VirAddr;
+ pSECComponent->processData[INPUT_PORT_INDEX].allocSize = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].bufferSize;
+
+ if ((pVideoDec->bFirstFrame == OMX_TRUE) &&
+ (pSECComponent->bSaveFlagEOS == OMX_TRUE) &&
+ (outputDataValid == OMX_FALSE)) {
+ ret = OMX_ErrorInputDataDecodeYet;
+ }
+
+ pVideoDec->bFirstFrame = OMX_FALSE;
+ } else {
+ if (pSECComponent->checkTimeStamp.needCheckStartTimeStamp == OMX_TRUE)
+ pSECComponent->checkTimeStamp.needSetStartTimeStamp = OMX_TRUE;
+ }
+
+ /** 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 = (void *)pOutputData->dataBuffer;
+ void *pYUVBuf[3];
+
+ int frameSize = bufWidth * bufHeight;
+ int width = outputInfo.img_width;
+ int height = outputInfo.img_height;
+ int imageSize = outputInfo.img_width * outputInfo.img_height;
+
+ pYUVBuf[0] = (unsigned char *)pOutputBuf;
+ pYUVBuf[1] = (unsigned char *)pOutputBuf + imageSize;
+ pYUVBuf[2] = (unsigned char *)pOutputBuf + imageSize + imageSize / 4;
+ pOutputData->dataLen = (imageSize * 3) / 2;
+
+#ifdef USE_ANB
+ if (pSECOutputPort->bIsANBEnabled == OMX_TRUE) {
+ OMX_U32 stride;
+ SEC_OSAL_LockANB(pOutputData->dataBuffer, width, height, pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eColorFormat, &stride, pYUVBuf);
+ width = stride;
+ pOutputData->dataLen = sizeof(void *);
+ }
+#endif
+ if ((pVideoDec->bThumbnailMode == OMX_FALSE) &&
+ (pSECOutputPort->portDefinition.format.video.eColorFormat == OMX_SEC_COLOR_FormatNV12TPhysicalAddress)) {
+ /* if use Post copy address structure */
+ SEC_OSAL_Memcpy(pOutputBuf, &(outputInfo.YPhyAddr), sizeof(outputInfo.YPhyAddr));
+ SEC_OSAL_Memcpy((unsigned char *)pOutputBuf + (sizeof(void *) * 1), &(outputInfo.CPhyAddr), sizeof(outputInfo.CPhyAddr));
+ SEC_OSAL_Memcpy((unsigned char *)pOutputBuf + (sizeof(void *) * 2), &(outputInfo.YVirAddr), sizeof(outputInfo.YVirAddr));
+ SEC_OSAL_Memcpy((unsigned char *)pOutputBuf + (sizeof(void *) * 3), &(outputInfo.CVirAddr), sizeof(outputInfo.CVirAddr));
+ pOutputData->dataLen = (outputInfo.img_width * outputInfo.img_height * 3) / 2;
+ } else {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "YUV420 out for ThumbnailMode");
+ switch (pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eColorFormat) {
+ case OMX_SEC_COLOR_FormatNV12Tiled:
+ SEC_OSAL_Memcpy(pOutputBuf, outputInfo.YVirAddr, FrameBufferYSize);
+ SEC_OSAL_Memcpy((unsigned char *)pOutputBuf + FrameBufferYSize, outputInfo.CVirAddr, FrameBufferUVSize);
+ pOutputData->dataLen = FrameBufferYSize + FrameBufferUVSize;
+ break;
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ case OMX_SEC_COLOR_FormatANBYUV420SemiPlanar:
+#ifdef USE_CSC_FIMC
+ if ((pSECOutputPort->bIsANBEnabled == OMX_TRUE) && (pWmvDec->hFIMCHandle != NULL)) {
+ void *pPhys[3];
+ SEC_OSAL_GetPhysANB(pOutputData->dataBuffer, pPhys);
+ pYUVBuf[0] = outputInfo.YPhyAddr;
+ pYUVBuf[1] = outputInfo.CPhyAddr;
+ csc_fimc_convert_nv12t(pWmvDec->hFIMCHandle, pPhys,
+ pYUVBuf, width, height,
+ OMX_SEC_COLOR_FormatANBYUV420SemiPlanar);
+ break;
+ }
+#endif
+ csc_tiled_to_linear_y_neon(
+ (unsigned char *)pYUVBuf[0],
+ (unsigned char *)outputInfo.YVirAddr,
+ width,
+ height);
+ csc_tiled_to_linear_uv_neon(
+ (unsigned char *)pYUVBuf[1],
+ (unsigned char *)outputInfo.CVirAddr,
+ width,
+ height / 2);
+ break;
+ case OMX_COLOR_FormatYUV420Planar:
+ default:
+#ifdef USE_CSC_FIMC
+ if ((pSECOutputPort->bIsANBEnabled == OMX_TRUE) && (pWmvDec->hFIMCHandle != NULL)) {
+ void *pPhys[3];
+ SEC_OSAL_GetPhysANB(pOutputData->dataBuffer, pPhys);
+ pYUVBuf[0] = outputInfo.YPhyAddr;
+ pYUVBuf[1] = outputInfo.CPhyAddr;
+ csc_fimc_convert_nv12t(pWmvDec->hFIMCHandle, pPhys,
+ pYUVBuf, width, height,
+ OMX_COLOR_FormatYUV420Planar);
+ break;
+ }
+#endif
+ csc_tiled_to_linear_y_neon(
+ (unsigned char *)pYUVBuf[0],
+ (unsigned char *)outputInfo.YVirAddr,
+ width,
+ height);
+ csc_tiled_to_linear_uv_deinterleave_neon(
+ (unsigned char *)pYUVBuf[1],
+ (unsigned char *)pYUVBuf[2],
+ (unsigned char *)outputInfo.CVirAddr,
+ width,
+ height / 2);
+ break;
+ }
+ }
+#ifdef USE_ANB
+ if (pSECOutputPort->bIsANBEnabled == OMX_TRUE) {
+ SEC_OSAL_UnlockANB(pOutputData->dataBuffer);
+ }
+#endif
+ } else {
+ pOutputData->dataLen = 0;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_Wmv_Decode_Block(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_OMX_VIDEODEC_COMPONENT *pVideoDec = (SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle;
+ SEC_OMX_BASEPORT *pSECInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+ SEC_WMV_HANDLE *pWmvDec = (SEC_WMV_HANDLE *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ OMX_U32 oneFrameSize = pInputData->dataLen;
+ SSBSIP_MFC_DEC_OUTPUT_INFO outputInfo;
+ OMX_S32 configValue = 0;
+ OMX_S32 returnCodec = 0;
+ OMX_BOOL bMetaData = OMX_FALSE;
+ OMX_BOOL bStartCode = OMX_FALSE;
+ int bufWidth = 0;
+ int bufHeight = 0;
+ OMX_U32 FrameBufferYSize;
+ OMX_U32 FrameBufferUVSize;
+
+ FunctionIn();
+
+ if (pWmvDec->hMFCWmvHandle.bConfiguredMFC == OMX_FALSE) {
+ SSBSIP_MFC_CODEC_TYPE MFCCodecType;
+
+ if ((oneFrameSize <= 0) && (pInputData->nFlags & OMX_BUFFERFLAG_EOS)) {
+ pOutputData->timeStamp = pInputData->timeStamp;
+ pOutputData->nFlags = pInputData->nFlags;
+ ret = OMX_ErrorNone;
+ goto EXIT;
+ }
+
+ if (pWmvDec->hMFCWmvHandle.wmvFormat == WMV_FORMAT_WMV3)
+ MFCCodecType = VC1RCV_DEC;
+ else if (pWmvDec->hMFCWmvHandle.wmvFormat == WMV_FORMAT_VC1)
+ MFCCodecType = VC1_DEC;
+ else
+ MFCCodecType = UNKNOWN_TYPE;
+
+ SEC_OSAL_Log(SEC_LOG_TRACE, "codec type = %d", MFCCodecType);
+
+ if (pVideoDec->bThumbnailMode == OMX_TRUE) {
+ configValue = 0; // the number that you want to delay
+ SsbSipMfcDecSetConfig(pWmvDec->hMFCWmvHandle.hMFCHandle, MFC_DEC_SETCONF_DISPLAY_DELAY, &configValue);
+ } else {
+ configValue = WMV_DEC_NUM_OF_EXTRA_BUFFERS;
+ SsbSipMfcDecSetConfig(pWmvDec->hMFCWmvHandle.hMFCHandle, MFC_DEC_SETCONF_EXTRA_BUFFER_NUM, &configValue);
+ }
+
+ bMetaData = Make_Stream_MetaData(pInputData->dataBuffer, &oneFrameSize, pWmvDec->hMFCWmvHandle.wmvFormat);
+ if (bMetaData == OMX_FALSE) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "Fail to Make Stream MetaData");
+ ret = OMX_ErrorMFCInit;
+ goto EXIT;
+ }
+
+ returnCodec = SsbSipMfcDecInit(pWmvDec->hMFCWmvHandle.hMFCHandle, MFCCodecType, oneFrameSize);
+ if (returnCodec == MFC_RET_OK) {
+ SSBSIP_MFC_IMG_RESOLUTION imgResol;
+
+ if (SsbSipMfcDecGetConfig(pWmvDec->hMFCWmvHandle.hMFCHandle, MFC_DEC_GETCONF_BUF_WIDTH_HEIGHT, &imgResol) != MFC_RET_OK) {
+ ret = OMX_ErrorMFCInit;
+ SEC_OSAL_Log(SEC_LOG_ERROR, "SsbSipMfcDecGetConfig failed");
+ goto EXIT;
+ }
+
+ SEC_OSAL_Log(SEC_LOG_TRACE, "## nFrameWidth(%d) nFrameHeight(%d), nStride(%d), nSliceHeight(%d)",
+ pSECInputPort->portDefinition.format.video.nFrameWidth, pSECInputPort->portDefinition.format.video.nFrameHeight,
+ pSECInputPort->portDefinition.format.video.nStride, pSECInputPort->portDefinition.format.video.nSliceHeight);
+
+ /** Update Frame Size **/
+ if ((pSECInputPort->portDefinition.format.video.nFrameWidth != (unsigned int)imgResol.width) ||
+ (pSECInputPort->portDefinition.format.video.nFrameHeight != (unsigned int)imgResol.height)) {
+ /* change width and height information */
+ pSECInputPort->portDefinition.format.video.nFrameWidth = imgResol.width;
+ pSECInputPort->portDefinition.format.video.nFrameHeight = imgResol.height;
+ pSECInputPort->portDefinition.format.video.nStride = ((imgResol.width + 15) & (~15));
+ pSECInputPort->portDefinition.format.video.nSliceHeight = ((imgResol.height + 15) & (~15));
+
+ SEC_OSAL_Log(SEC_LOG_TRACE, "nFrameWidth(%d) nFrameHeight(%d), nStride(%d), nSliceHeight(%d)",
+ pSECInputPort->portDefinition.format.video.nFrameWidth, pSECInputPort->portDefinition.format.video.nFrameHeight,
+ pSECInputPort->portDefinition.format.video.nStride, pSECInputPort->portDefinition.format.video.nSliceHeight);
+
+ 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);
+ }
+
+ pWmvDec->hMFCWmvHandle.bConfiguredMFC = OMX_TRUE;
+
+ if (pWmvDec->hMFCWmvHandle.wmvFormat == WMV_FORMAT_WMV3) {
+ pOutputData->timeStamp = pInputData->timeStamp;
+ pOutputData->nFlags = pInputData->nFlags;
+ ret = OMX_ErrorNone;
+ } else {
+
+#ifdef WO_START_CODE
+/* ASF parser does not send start code on OpenCORE */
+ pOutputData->timeStamp = pInputData->timeStamp;
+ pOutputData->nFlags = pInputData->nFlags;
+ ret = OMX_ErrorNone;
+#else
+/* TODO : for comformanc test based on common buffer scheme w/o parser */
+ pOutputData->dataLen = 0;
+ ret = OMX_ErrorInputDataDecodeYet;
+#endif
+ }
+ goto EXIT;
+ } else {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "SsbSipMfcDecInit failed");
+ 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
+
+#ifdef WO_START_CODE
+ if (pInputData->allocSize < oneFrameSize+4) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "Can't attach startcode due to lack of buffer space");
+ ret = OMX_ErrorMFCInit;
+ goto EXIT;
+ }
+
+ bStartCode = Make_Stream_StartCode(pInputData->dataBuffer, oneFrameSize, pWmvDec->hMFCWmvHandle.wmvFormat);
+ if (bStartCode == OMX_FALSE) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "Fail to Make Stream Start Code");
+ ret = OMX_ErrorMFCInit;
+ goto EXIT;
+ }
+#endif
+
+ SEC_OSAL_Log(SEC_LOG_TRACE, "SsbSipMfcDecExe oneFrameSize = %d", oneFrameSize);
+
+ if (Check_Stream_PrefixCode(pInputData->dataBuffer, pInputData->dataLen, pWmvDec->hMFCWmvHandle.wmvFormat) == OMX_TRUE) {
+ pSECComponent->timeStamp[pWmvDec->hMFCWmvHandle.indexTimestamp] = pInputData->timeStamp;
+ pSECComponent->nFlags[pWmvDec->hMFCWmvHandle.indexTimestamp] = pInputData->nFlags;
+ SsbSipMfcDecSetConfig(pWmvDec->hMFCWmvHandle.hMFCHandle, MFC_DEC_SETCONF_FRAME_TAG, &(pWmvDec->hMFCWmvHandle.indexTimestamp));
+
+#ifdef WO_START_CODE
+ returnCodec = SsbSipMfcDecExe(pWmvDec->hMFCWmvHandle.hMFCHandle, oneFrameSize+4); /* Frame Start Code */
+#else
+ returnCodec = SsbSipMfcDecExe(pWmvDec->hMFCWmvHandle.hMFCHandle, oneFrameSize);
+#endif
+ } else {
+ if (pSECComponent->checkTimeStamp.needCheckStartTimeStamp == OMX_TRUE)
+ pSECComponent->checkTimeStamp.needSetStartTimeStamp = OMX_TRUE;
+
+ pOutputData->timeStamp = pInputData->timeStamp;
+ pOutputData->nFlags = pInputData->nFlags;
+ returnCodec = MFC_RET_OK;
+ goto EXIT;
+ }
+
+ if (returnCodec == MFC_RET_OK) {
+ SSBSIP_MFC_DEC_OUTBUF_STATUS status;
+ OMX_S32 indexTimestamp = 0;
+
+ status = SsbSipMfcDecGetOutBuf(pWmvDec->hMFCWmvHandle.hMFCHandle, &outputInfo);
+ bufWidth = (outputInfo.img_width + 15) & (~15);
+ bufHeight = (outputInfo.img_height + 15) & (~15);
+ FrameBufferYSize = ALIGN_TO_8KB(ALIGN_TO_128B(outputInfo.img_width) * ALIGN_TO_32B(outputInfo.img_height));
+ FrameBufferUVSize = ALIGN_TO_8KB(ALIGN_TO_128B(outputInfo.img_width) * ALIGN_TO_32B(outputInfo.img_height/2));
+
+ if (status != MFC_GETOUTBUF_DISPLAY_ONLY) {
+ pWmvDec->hMFCWmvHandle.indexTimestamp++;
+ pWmvDec->hMFCWmvHandle.indexTimestamp %= MAX_TIMESTAMP;
+ }
+
+ if (SsbSipMfcDecGetConfig(pWmvDec->hMFCWmvHandle.hMFCHandle, MFC_DEC_GETCONF_FRAME_TAG, &indexTimestamp) != MFC_RET_OK ||
+ (((indexTimestamp < 0) || (indexTimestamp >= MAX_TIMESTAMP)))) {
+ pOutputData->timeStamp = pInputData->timeStamp;
+ pOutputData->nFlags = pInputData->nFlags;
+ } else {
+ /* For timestamp correction. if mfc support frametype detect */
+ SEC_OSAL_Log(SEC_LOG_TRACE, "disp_pic_frame_type: %d", outputInfo.disp_pic_frame_type);
+#ifdef NEED_TIMESTAMP_REORDER
+ if (outputInfo.disp_pic_frame_type == MFC_FRAME_TYPE_I_FRAME) {
+ pOutputData->timeStamp = pSECComponent->timeStamp[indexTimestamp];
+ pOutputData->nFlags = pSECComponent->nFlags[indexTimestamp];
+ pWmvDec->hMFCWmvHandle.outputIndexTimestamp = indexTimestamp;
+ } else {
+ pOutputData->timeStamp = pSECComponent->timeStamp[pWmvDec->hMFCWmvHandle.outputIndexTimestamp];
+ pOutputData->nFlags = pSECComponent->nFlags[pWmvDec->hMFCWmvHandle.outputIndexTimestamp];
+ }
+#else
+ pOutputData->timeStamp = pSECComponent->timeStamp[indexTimestamp];
+ pOutputData->nFlags = pSECComponent->nFlags[indexTimestamp];
+#endif
+ }
+
+ if ((status == MFC_GETOUTBUF_DISPLAY_DECODING) ||
+ (status == MFC_GETOUTBUF_DISPLAY_ONLY)) {
+ /** Fill Output Buffer **/
+ void *pOutputBuf = (void *)pOutputData->dataBuffer;
+ void *pYUVBuf[3];
+
+ int frameSize = bufWidth * bufHeight;
+ int width = outputInfo.img_width;
+ int height = outputInfo.img_height;
+ int imageSize = outputInfo.img_width * outputInfo.img_height;
+
+ pYUVBuf[0] = (unsigned char *)pOutputBuf;
+ pYUVBuf[1] = (unsigned char *)pOutputBuf + imageSize;
+ pYUVBuf[2] = (unsigned char *)pOutputBuf + imageSize + imageSize / 4;
+ pOutputData->dataLen = (imageSize * 3) / 2;
+
+#ifdef USE_ANB
+ if (pSECOutputPort->bIsANBEnabled == OMX_TRUE) {
+ OMX_U32 stride;
+ SEC_OSAL_LockANB(pOutputData->dataBuffer, width, height, pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eColorFormat, &stride, pYUVBuf);
+ width = stride;
+ pOutputData->dataLen = sizeof(void *);
+ }
+#endif
+ if ((pVideoDec->bThumbnailMode == OMX_FALSE) &&
+ (pSECOutputPort->portDefinition.format.video.eColorFormat == OMX_SEC_COLOR_FormatNV12TPhysicalAddress)) {
+ SEC_OSAL_Memcpy(pOutputBuf, &(outputInfo.YPhyAddr), sizeof(outputInfo.YPhyAddr));
+ SEC_OSAL_Memcpy((unsigned char *)pOutputBuf + (sizeof(void *) * 1), &(outputInfo.CPhyAddr), sizeof(outputInfo.CPhyAddr));
+ SEC_OSAL_Memcpy((unsigned char *)pOutputBuf + (sizeof(void *) * 2), &(outputInfo.YVirAddr), sizeof(outputInfo.YVirAddr));
+ SEC_OSAL_Memcpy((unsigned char *)pOutputBuf + (sizeof(void *) * 3), &(outputInfo.CVirAddr), sizeof(outputInfo.CVirAddr));
+ pOutputData->dataLen = (outputInfo.img_width * outputInfo.img_height * 3) / 2;
+ } else {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "YUV420 out for ThumbnailMode");
+ switch (pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eColorFormat) {
+ case OMX_SEC_COLOR_FormatNV12Tiled:
+ SEC_OSAL_Memcpy(pOutputBuf, outputInfo.YVirAddr, FrameBufferYSize);
+ SEC_OSAL_Memcpy((unsigned char *)pOutputBuf + FrameBufferYSize, outputInfo.CVirAddr, FrameBufferUVSize);
+ pOutputData->dataLen = FrameBufferYSize + FrameBufferUVSize;
+ break;
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ case OMX_SEC_COLOR_FormatANBYUV420SemiPlanar:
+#ifdef USE_CSC_FIMC
+ if ((pSECOutputPort->bIsANBEnabled == OMX_TRUE) && (pWmvDec->hFIMCHandle != NULL)) {
+ void *pPhys[3];
+ SEC_OSAL_GetPhysANB(pOutputData->dataBuffer, pPhys);
+ pYUVBuf[0] = outputInfo.YPhyAddr;
+ pYUVBuf[1] = outputInfo.CPhyAddr;
+ csc_fimc_convert_nv12t(pWmvDec->hFIMCHandle, pPhys,
+ pYUVBuf, width, height,
+ OMX_SEC_COLOR_FormatANBYUV420SemiPlanar);
+ break;
+ }
+#endif
+ csc_tiled_to_linear_y_neon(
+ (unsigned char *)pYUVBuf[0],
+ (unsigned char *)outputInfo.YVirAddr,
+ width,
+ height);
+ csc_tiled_to_linear_uv_neon(
+ (unsigned char *)pYUVBuf[1],
+ (unsigned char *)outputInfo.CVirAddr,
+ width,
+ height / 2);
+ break;
+ case OMX_COLOR_FormatYUV420Planar:
+ default:
+#ifdef USE_CSC_FIMC
+ if ((pSECOutputPort->bIsANBEnabled == OMX_TRUE) && (pWmvDec->hFIMCHandle != NULL)) {
+ void *pPhys[3];
+ SEC_OSAL_GetPhysANB(pOutputData->dataBuffer, pPhys);
+ pYUVBuf[0] = outputInfo.YPhyAddr;
+ pYUVBuf[1] = outputInfo.CPhyAddr;
+ csc_fimc_convert_nv12t(pWmvDec->hFIMCHandle, pPhys,
+ pYUVBuf, width, height,
+ OMX_COLOR_FormatYUV420Planar);
+ break;
+ }
+#endif
+ csc_tiled_to_linear_y_neon(
+ (unsigned char *)pYUVBuf[0],
+ (unsigned char *)outputInfo.YVirAddr,
+ width,
+ height);
+ csc_tiled_to_linear_uv_deinterleave_neon(
+ (unsigned char *)pYUVBuf[1],
+ (unsigned char *)pYUVBuf[2],
+ (unsigned char *)outputInfo.CVirAddr,
+ width,
+ height / 2);
+ break;
+ }
+ }
+
+#ifdef USE_ANB
+ if (pSECOutputPort->bIsANBEnabled == OMX_TRUE) {
+ SEC_OSAL_UnlockANB(pOutputData->dataBuffer);
+ }
+#endif
+ pWmvDec->hMFCWmvHandle.outputIndexTimestamp++;
+ pWmvDec->hMFCWmvHandle.outputIndexTimestamp %= MAX_TIMESTAMP;
+ }
+ if (pOutputData->nFlags & OMX_BUFFERFLAG_EOS)
+ pOutputData->dataLen = 0;
+
+ 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;
+ }
+ goto EXIT;
+ }
+
+#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) {
+ 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;
+ }
+ pOutputData->dataLen = 0;
+
+ /* ret = OMX_ErrorUndefined; */
+ ret = OMX_ErrorNone;
+ goto EXIT;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+/* MFC Decode */
+OMX_ERRORTYPE SEC_MFC_WmvDec_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_WMV_HANDLE *pWmvDec = (SEC_WMV_HANDLE *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ SEC_OMX_BASEPORT *pSECInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+ OMX_BOOL bCheckPrefix = OMX_FALSE;
+
+ FunctionIn();
+
+ if ((!CHECK_PORT_ENABLED(pSECInputPort)) || (!CHECK_PORT_ENABLED(pSECOutputPort)) ||
+ (!CHECK_PORT_POPULATED(pSECInputPort)) || (!CHECK_PORT_POPULATED(pSECOutputPort))) {
+ goto EXIT;
+ }
+ if (OMX_FALSE == SEC_Check_BufferProcess_State(pSECComponent)) {
+ goto EXIT;
+ }
+
+ pWmvDec->hMFCWmvHandle.wmvFormat = gWvmFormat;
+
+#ifdef NONBLOCK_MODE_PROCESS
+ ret = SEC_MFC_Wmv_Decode_Nonblock(pOMXComponent, pInputData, pOutputData);
+#else
+ ret = SEC_MFC_Wmv_Decode_Block(pOMXComponent, pInputData, pOutputData);
+#endif
+ 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_OMX_VIDEODEC_COMPONENT *pVideoDec = NULL;
+ SEC_WMV_HANDLE *pWmvDec = NULL;
+ OMX_S32 wmvFormat = WMV_FORMAT_UNKNOWN;
+ int i = 0;
+
+ FunctionIn();
+
+ if ((hComponent == NULL) || (componentName == NULL)) {
+ ret = OMX_ErrorBadParameter;
+ SEC_OSAL_Log(SEC_LOG_ERROR, "SEC_OMX_ComponentInit: parameters are null, ret:%X", ret);
+ goto EXIT;
+ }
+ if (SEC_OSAL_Strcmp(SEC_OMX_COMPONENT_WMV_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, "SEC_OMX_ComponentInit: SEC_OMX_VideoDecodeComponentInit error, ret: %X", ret);
+ goto EXIT;
+ }
+ pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ pSECComponent->codecType = HW_VIDEO_DEC_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, "SEC_OMX_ComponentInit: componentName alloc error, ret: %X", ret);
+ goto EXIT;
+ }
+ SEC_OSAL_Memset(pSECComponent->componentName, 0, MAX_OMX_COMPONENT_NAME_SIZE);
+
+ pWmvDec = SEC_OSAL_Malloc(sizeof(SEC_WMV_HANDLE));
+ if (pWmvDec == NULL) {
+ SEC_OMX_VideoDecodeComponentDeinit(pOMXComponent);
+ ret = OMX_ErrorInsufficientResources;
+ SEC_OSAL_Log(SEC_LOG_ERROR, "SEC_OMX_ComponentInit: SEC_WMV_HANDLE alloc error, ret: %X", ret);
+ goto EXIT;
+ }
+ SEC_OSAL_Memset(pWmvDec, 0, sizeof(SEC_WMV_HANDLE));
+ pVideoDec = (SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle;
+ pVideoDec->hCodecHandle = (OMX_HANDLETYPE)pWmvDec;
+ pWmvDec->hMFCWmvHandle.wmvFormat = wmvFormat;
+
+ SEC_OSAL_Strcpy(pSECComponent->componentName, SEC_OMX_COMPONENT_WMV_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;
+
+ pSECPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingWMV;
+ SEC_OSAL_Memset(pSECPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE);
+ SEC_OSAL_Strcpy(pSECPort->portDefinition.format.video.cMIMEType, "video/wmv");
+
+ 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_FormatYUV420Planar;
+ pSECPort->portDefinition.bEnabled = OMX_TRUE;
+
+ for(i = 0; i < ALL_PORT_NUM; i++) {
+ INIT_SET_SIZE_VERSION(&pWmvDec->WmvComponent[i], OMX_VIDEO_PARAM_WMVTYPE);
+ pWmvDec->WmvComponent[i].nPortIndex = i;
+ pWmvDec->WmvComponent[i].eFormat = OMX_VIDEO_WMVFormat9;
+ }
+
+ pOMXComponent->GetParameter = &SEC_MFC_WmvDec_GetParameter;
+ pOMXComponent->SetParameter = &SEC_MFC_WmvDec_SetParameter;
+ pOMXComponent->GetConfig = &SEC_MFC_WmvDec_GetConfig;
+ pOMXComponent->SetConfig = &SEC_MFC_WmvDec_SetConfig;
+ pOMXComponent->GetExtensionIndex = &SEC_MFC_WmvDec_GetExtensionIndex;
+ pOMXComponent->ComponentRoleEnum = &SEC_MFC_WmvDec_ComponentRoleEnum;
+ pOMXComponent->ComponentDeInit = &SEC_OMX_ComponentDeinit;
+
+ pSECComponent->sec_mfc_componentInit = &SEC_MFC_WmvDec_Init;
+ pSECComponent->sec_mfc_componentTerminate = &SEC_MFC_WmvDec_Terminate;
+ pSECComponent->sec_mfc_bufferProcess = &SEC_MFC_WmvDec_bufferProcess;
+ pSECComponent->sec_checkInputFrame = &Check_Wmv_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_WMV_HANDLE *pWmvDec = 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;
+
+ pWmvDec = (SEC_WMV_HANDLE *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ if (pWmvDec != NULL) {
+ SEC_OSAL_Free(pWmvDec);
+ pWmvDec = ((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle = NULL;
+ }
+
+ ret = SEC_OMX_VideoDecodeComponentDeinit(pOMXComponent);
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ ret = OMX_ErrorNone;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
diff --git a/exynos/multimedia/openmax/component/video/dec/vc1/SEC_OMX_Wmvdec.h b/exynos/multimedia/openmax/component/video/dec/vc1/SEC_OMX_Wmvdec.h
new file mode 100644
index 0000000..c68b644
--- /dev/null
+++ b/exynos/multimedia/openmax/component/video/dec/vc1/SEC_OMX_Wmvdec.h
@@ -0,0 +1,99 @@
+/*
+ *
+ * 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_Wmvdec.h
+ * @brief
+ * @author HyeYeon Chung (hyeon.chung@samsung.com)
+ * @version 1.1.0
+ * @history
+ * 2010.8.20 : Create
+ */
+
+#ifndef SEC_OMX_WMV_DEC_COMPONENT
+#define SEC_OMX_WMV_DEC_COMPONENT
+
+#include "SEC_OMX_Def.h"
+#include "OMX_Component.h"
+
+#define BITMAPINFOHEADER_SIZE 40
+#define BITMAPINFOHEADER_ASFBINDING_SIZE 41
+#define COMPRESSION_POS 16
+
+typedef enum WMV_FORMAT {
+ WMV_FORMAT_VC1,
+ WMV_FORMAT_WMV3,
+ WMV_FORMAT_UNKNOWN
+} WMV_FORMAT;
+
+/*
+ * 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_WMV_HANDLE
+{
+ OMX_HANDLETYPE hMFCHandle;
+ OMX_PTR pMFCStreamBuffer;
+ OMX_PTR pMFCStreamPhyBuffer;
+ OMX_U32 indexTimestamp;
+ OMX_U32 outputIndexTimestamp;
+ OMX_BOOL bConfiguredMFC;
+ WMV_FORMAT wmvFormat;
+ OMX_S32 returnCodec;
+} SEC_MFC_WMV_HANDLE;
+
+typedef struct _SEC_WMV_HANDLE
+{
+ /* OMX Codec specific */
+ OMX_VIDEO_PARAM_WMVTYPE WmvComponent[ALL_PORT_NUM];
+ OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE errorCorrectionType[ALL_PORT_NUM];
+
+ /* SEC MFC Codec specific */
+ SEC_MFC_WMV_HANDLE hMFCWmvHandle;
+
+ /* CSC FIMC handle */
+#ifdef USE_CSC_FIMC
+ OMX_PTR hFIMCHandle;
+#endif
+} SEC_WMV_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/exynos/multimedia/openmax/component/video/dec/vc1/library_register.c b/exynos/multimedia/openmax/component/video/dec/vc1/library_register.c
new file mode 100644
index 0000000..ce04f18
--- /dev/null
+++ b/exynos/multimedia/openmax/component/video/dec/vc1/library_register.c
@@ -0,0 +1,57 @@
+/*
+ *
+ * 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 HyeYeon Chung (hyeon.chung@samsung.com)
+ * @version 1.1.0
+ * @history
+ * 2010.8.20 : 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_WMV_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 WMV */
+ SEC_OSAL_Strcpy(ppSECComponent[0]->componentName, SEC_OMX_COMPONENT_WMV_DEC);
+ SEC_OSAL_Strcpy(ppSECComponent[0]->roles[0], SEC_OMX_COMPONENT_WMV_DEC_ROLE);
+ ppSECComponent[0]->totalRoleNum = MAX_COMPONENT_ROLE_NUM;
+
+EXIT:
+ FunctionOut();
+ return MAX_COMPONENT_NUM;
+} \ No newline at end of file
diff --git a/exynos/multimedia/openmax/component/video/dec/vc1/library_register.h b/exynos/multimedia/openmax/component/video/dec/vc1/library_register.h
new file mode 100644
index 0000000..adac586
--- /dev/null
+++ b/exynos/multimedia/openmax/component/video/dec/vc1/library_register.h
@@ -0,0 +1,52 @@
+/*
+ *
+ * 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 HyeYeon Chung (hyeon.chung.chung@samsung.com)
+ * @version 1.1.0
+ * @history
+ * 2010.7.15 : Create
+ */
+
+#ifndef SEC_OMX_WMV_DEC_REG
+#define SEC_OMX_WMV_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 1
+#define MAX_COMPONENT_ROLE_NUM 1
+
+/* WMV */
+#define SEC_OMX_COMPONENT_WMV_DEC "OMX.SEC.WMV.Decoder"
+#define SEC_OMX_COMPONENT_WMV_DEC_ROLE "video_decoder.wmv"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+OSCL_EXPORT_REF int SEC_OMX_COMPONENT_Library_Register(SECRegisterComponentType **ppSECComponent);
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif \ No newline at end of file
diff --git a/exynos/multimedia/openmax/component/video/dec/vp8/Android.mk b/exynos/multimedia/openmax/component/video/dec/vp8/Android.mk
new file mode 100644
index 0000000..e4629a6
--- /dev/null
+++ b/exynos/multimedia/openmax/component/video/dec/vp8/Android.mk
@@ -0,0 +1,47 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := \
+ SEC_OMX_Vp8dec.c \
+ library_register.c
+
+LOCAL_PRELINK_MODULE := false
+LOCAL_MODULE := libOMX.SEC.VP8.Decoder
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/omx
+
+LOCAL_CFLAGS :=
+
+ifeq ($(BOARD_NONBLOCK_MODE_PROCESS), true)
+LOCAL_CFLAGS += -DNONBLOCK_MODE_PROCESS
+endif
+
+ifeq ($(BOARD_USE_ANB), true)
+LOCAL_CFLAGS += -DUSE_ANB
+endif
+
+LOCAL_ARM_MODE := arm
+
+LOCAL_STATIC_LIBRARIES := libSEC_OMX_Vdec libsecosal libsecbasecomponent \
+ libseccscapi libsecmfcapi
+LOCAL_SHARED_LIBRARIES := libc libdl libcutils libutils libui \
+ libSEC_OMX_Resourcemanager
+
+ifeq ($(filter-out exynos4,$(TARGET_BOARD_PLATFORM)),)
+LOCAL_SHARED_LIBRARIES += libhwconverter
+endif
+
+#ifeq ($(BOARD_USE_V4L2_ION),true)
+#LOCAL_SHARED_LIBRARIES += libion
+#endif
+
+LOCAL_C_INCLUDES := $(SEC_OMX_INC)/khronos \
+ $(SEC_OMX_INC)/sec \
+ $(SEC_OMX_TOP)/osal \
+ $(SEC_OMX_TOP)/core \
+ $(SEC_OMX_COMPONENT)/common \
+ $(SEC_OMX_COMPONENT)/video/dec \
+ $(TARGET_OUT_HEADERS)/$(SEC_COPY_HEADERS_TO)
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/exynos/multimedia/openmax/component/video/dec/vp8/SEC_OMX_Vp8dec.c b/exynos/multimedia/openmax/component/video/dec/vp8/SEC_OMX_Vp8dec.c
new file mode 100644
index 0000000..1642ac2
--- /dev/null
+++ b/exynos/multimedia/openmax/component/video/dec/vp8/SEC_OMX_Vp8dec.c
@@ -0,0 +1,1547 @@
+/*
+ *
+ * Copyright 2011 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_Vp8dec.c
+ * @brief
+ * @author Satish Kumar Reddy (palli.satish@samsung.com)
+ * @version 1.1.0
+ * @history
+ * 2011.11.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 "SEC_OSAL_ETC.h"
+#include "SEC_OSAL_Semaphore.h"
+#include "SEC_OSAL_Thread.h"
+#include "library_register.h"
+#include "SEC_OMX_Vp8dec.h"
+#include "SsbSipMfcApi.h"
+#include "color_space_convertor.h"
+
+#ifdef USE_ANB
+#include "SEC_OSAL_Android.h"
+#endif
+
+#undef SEC_LOG_TAG
+#define SEC_LOG_TAG "SEC_VP8_DEC"
+#define SEC_LOG_OFF
+#include "SEC_OSAL_Log.h"
+
+#define VP8_DEC_NUM_OF_EXTRA_BUFFERS 7
+
+//#define FULL_FRAME_SEARCH /* Full frame search not support*/
+
+static int Check_VP8_Frame(OMX_U8 *pInputStream, int buffSize, OMX_U32 flag, OMX_BOOL bPreviousFrameEOF, OMX_BOOL *pbEndOfFrame)
+{
+ /* Uncompressed data Chunk comprises a common
+ (for key frames and interframes) 3-byte frame tag that
+ contains four fields
+ - 1-bit frame type (0 - key frame, 1 - inter frame)
+ - 3-bit version number (0 - 3 are defined as four different
+ profiles with different decoding complexity)
+ - 1-bit show_frame flag ( 0 - current frame not for display,
+ 1 - current frame is for dispaly)
+ - 19-bit field - size of the first data partition in bytes
+
+ Key Frames : frame tag followed by 7 bytes of uncompressed
+ data
+ 3-bytes : Start code (byte 0: 0x9d,byte 1: 0x01,byte 2: 0x2a)
+ Next 4-bytes: Width & height, Horizontal and vertical scale information
+ 16 bits : (2 bits Horizontal Scale << 14) | Width (14 bits)
+ 16 bits : (2 bits Vertical Scale << 14) | Height (14 bits)
+ */
+ int width, height;
+ int horizSscale, vertScale;
+
+ FunctionIn();
+
+ *pbEndOfFrame = OMX_TRUE;
+
+ /*Check for Key frame*/
+ if (!(pInputStream[0] & 0x01)){
+ /* Key Frame Start code*/
+ if (pInputStream[3] != 0x9d || pInputStream[4] != 0x01 || pInputStream[5]!=0x2a) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, " VP8 Key Frame Start Code not Found");
+ *pbEndOfFrame = OMX_FALSE;
+ }
+ SEC_OSAL_Log(SEC_LOG_TRACE, " VP8 Found Key Frame Start Code");
+ width = (pInputStream[6] | (pInputStream[7] << 8)) & 0x3fff;
+ horizSscale = pInputStream[7] >> 6;
+ height = (pInputStream[8] | (pInputStream[9] << 8)) & 0x3fff;
+ vertScale = pInputStream[9] >> 6;
+ SEC_OSAL_Log(SEC_LOG_TRACE, "width = %d, height = %d, horizSscale = %d, vertScale = %d", width, height, horizSscale, vertScale);
+ }
+
+ FunctionOut();
+ return buffSize;
+}
+
+OMX_BOOL Check_VP8_StartCode(OMX_U8 *pInputStream, OMX_U32 streamSize)
+{
+ SEC_OSAL_Log(SEC_LOG_TRACE, "streamSize: %d",streamSize);
+ if (streamSize < 3) {
+ return OMX_FALSE;
+ }
+
+ if (!(pInputStream[0] & 0x01)){
+ /* Key Frame Start code*/
+ if (pInputStream[3] != 0x9d || pInputStream[4] != 0x01 || pInputStream[5]!=0x2a) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, " VP8 Key Frame Start Code not Found");
+ return OMX_FALSE;
+ }
+ SEC_OSAL_Log(SEC_LOG_TRACE, " VP8 Found Key Frame Start Code");
+ }
+
+ return OMX_TRUE;
+}
+
+OMX_ERRORTYPE SEC_MFC_VP8Dec_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_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ switch (nParamIndex) {
+ 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_VP8_DEC_ROLE);
+ }
+ break;
+ case OMX_IndexParamVideoErrorCorrection:
+ {
+ OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pDstErrorCorrectionType = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *)pComponentParameterStructure;
+ OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pSrcErrorCorrectionType = NULL;
+ SEC_VP8DEC_HANDLE *pVp8Dec = 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;
+ }
+
+ pVp8Dec = (SEC_VP8DEC_HANDLE *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ pSrcErrorCorrectionType = &pVp8Dec->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_VP8Dec_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_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ switch (nIndex) {
+ 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_VP8_DEC_ROLE)) {
+ pSECComponent->pSECPort[INPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingVPX;
+ } 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;
+ OMX_U32 realWidth, realHeight;
+
+ 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);
+
+ realWidth = pSECPort->portDefinition.format.video.nFrameWidth;
+ realHeight = pSECPort->portDefinition.format.video.nFrameHeight;
+ width = ((realWidth + 15) & (~15));
+ height = ((realHeight + 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;
+ case OMX_SEC_COLOR_FormatNV12Tiled:
+ pSECOutputPort->portDefinition.nBufferSize =
+ ALIGN_TO_8KB(ALIGN_TO_128B(realWidth) * ALIGN_TO_32B(realHeight)) \
+ + ALIGN_TO_8KB(ALIGN_TO_128B(realWidth) * ALIGN_TO_32B(realHeight/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_IndexParamVideoErrorCorrection:
+ {
+ OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pSrcErrorCorrectionType = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *)pComponentParameterStructure;
+ OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pDstErrorCorrectionType = NULL;
+ SEC_VP8DEC_HANDLE *pVp8Dec = 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;
+ }
+
+ pVp8Dec = (SEC_VP8DEC_HANDLE *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ pDstErrorCorrectionType = &pVp8Dec->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_VP8Dec_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_VideoDecodeGetConfig(hComponent, nIndex, pComponentConfigStructure);
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_VP8Dec_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) {
+ default:
+ ret = SEC_OMX_VideoDecodeSetConfig(hComponent, nIndex, pComponentConfigStructure);
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_VP8Dec_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_VP8DEC_HANDLE *pVp8Dec = (SEC_VP8DEC_HANDLE *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+
+ *pIndexType = OMX_IndexVendorThumbnailMode;
+
+ ret = OMX_ErrorNone;
+ } else {
+ ret = SEC_OMX_VideoDecodeGetExtensionIndex(hComponent, cParameterName, pIndexType);
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_VP8Dec_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_VP8_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 = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ SEC_OMX_VIDEODEC_COMPONENT *pVideoDec = (SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle;
+ SEC_VP8DEC_HANDLE *pVp8Dec = (SEC_VP8DEC_HANDLE *)pVideoDec->hCodecHandle;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ while (pVideoDec->NBDecThread.bExitDecodeThread == OMX_FALSE) {
+ SEC_OSAL_SemaphoreWait(pVideoDec->NBDecThread.hDecFrameStart);
+
+ if (pVideoDec->NBDecThread.bExitDecodeThread == OMX_FALSE) {
+ pVp8Dec->hMFCVp8Handle.returnCodec = SsbSipMfcDecExe(pVp8Dec->hMFCVp8Handle.hMFCHandle, pVideoDec->NBDecThread.oneFrameSize);
+ SEC_OSAL_SemaphorePost(pVideoDec->NBDecThread.hDecFrameEnd);
+ }
+ }
+
+EXIT:
+ SEC_OSAL_ThreadExit(NULL);
+ FunctionOut();
+
+ return ret;
+}
+
+/* MFC Init */
+OMX_ERRORTYPE SEC_MFC_VP8Dec_Init(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ SEC_OMX_VIDEODEC_COMPONENT *pVideoDec = (SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle;
+ SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+ SEC_VP8DEC_HANDLE *pVp8Dec = NULL;
+ OMX_PTR hMFCHandle = NULL;
+ OMX_PTR pStreamBuffer = NULL;
+ OMX_PTR pStreamPhyBuffer = NULL;
+
+ pVp8Dec = (SEC_VP8DEC_HANDLE *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ pVp8Dec->hMFCVp8Handle.bConfiguredMFC = OMX_FALSE;
+ pSECComponent->bUseFlagEOF = OMX_FALSE;
+ pSECComponent->bSaveFlagEOS = OMX_FALSE;
+
+ /* MFC(Multi Function Codec) decoder and CMM(Codec Memory Management) driver open */
+ if (pSECOutputPort->portDefinition.format.video.eColorFormat == OMX_SEC_COLOR_FormatNV12TPhysicalAddress) {
+ hMFCHandle = (OMX_PTR)SsbSipMfcDecOpen();
+ } else {
+ SSBIP_MFC_BUFFER_TYPE buf_type = CACHE;
+ hMFCHandle = (OMX_PTR)SsbSipMfcDecOpenExt(&buf_type);
+ }
+
+ if (hMFCHandle == NULL) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ pVp8Dec->hMFCVp8Handle.hMFCHandle = hMFCHandle;
+
+ /* Allocate decoder's input buffer */
+ /* Get first input buffer */
+ pStreamBuffer = SsbSipMfcDecGetInBuf(hMFCHandle, &pStreamPhyBuffer, DEFAULT_MFC_INPUT_BUFFER_SIZE / 2);
+ if (pStreamBuffer == NULL) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ pVideoDec->MFCDecInputBuffer[0].VirAddr = pStreamBuffer;
+ pVideoDec->MFCDecInputBuffer[0].PhyAddr = pStreamPhyBuffer;
+ pVideoDec->MFCDecInputBuffer[0].bufferSize = DEFAULT_MFC_INPUT_BUFFER_SIZE / 2;
+ pVideoDec->MFCDecInputBuffer[0].dataSize = 0;
+
+#ifdef NONBLOCK_MODE_PROCESS
+ /* Get second input buffer */
+ pStreamBuffer = NULL;
+ pStreamBuffer = SsbSipMfcDecGetInBuf(hMFCHandle, &pStreamPhyBuffer, DEFAULT_MFC_INPUT_BUFFER_SIZE / 2);
+ if (pStreamBuffer == NULL) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ pVideoDec->MFCDecInputBuffer[1].VirAddr = pStreamBuffer;
+ pVideoDec->MFCDecInputBuffer[1].PhyAddr = pStreamPhyBuffer;
+ pVideoDec->MFCDecInputBuffer[1].bufferSize = DEFAULT_MFC_INPUT_BUFFER_SIZE / 2;
+ pVideoDec->MFCDecInputBuffer[1].dataSize = 0;
+ pVideoDec->indexInputBuffer = 0;
+
+ pVideoDec->bFirstFrame = OMX_TRUE;
+
+ pVideoDec->NBDecThread.bExitDecodeThread = OMX_FALSE;
+ pVideoDec->NBDecThread.bDecoderRun = OMX_FALSE;
+ pVideoDec->NBDecThread.oneFrameSize = 0;
+ SEC_OSAL_SemaphoreCreate(&(pVideoDec->NBDecThread.hDecFrameStart));
+ SEC_OSAL_SemaphoreCreate(&(pVideoDec->NBDecThread.hDecFrameEnd));
+ if (OMX_ErrorNone == SEC_OSAL_ThreadCreate(&pVideoDec->NBDecThread.hNBDecodeThread,
+ SEC_MFC_DecodeThread,
+ pOMXComponent)) {
+ pVp8Dec->hMFCVp8Handle.returnCodec = MFC_RET_OK;
+ }
+#endif
+
+ pVp8Dec->hMFCVp8Handle.pMFCStreamBuffer = pVideoDec->MFCDecInputBuffer[0].VirAddr;
+ pVp8Dec->hMFCVp8Handle.pMFCStreamPhyBuffer = pVideoDec->MFCDecInputBuffer[0].PhyAddr;
+ pSECComponent->processData[INPUT_PORT_INDEX].dataBuffer = pVideoDec->MFCDecInputBuffer[0].VirAddr;
+ pSECComponent->processData[INPUT_PORT_INDEX].allocSize = pVideoDec->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);
+ pVp8Dec->hMFCVp8Handle.indexTimestamp = 0;
+ pVp8Dec->hMFCVp8Handle.outputIndexTimestamp = 0;
+
+ pSECComponent->getAllDelayBuffer = OMX_FALSE;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+/* MFC Terminate */
+OMX_ERRORTYPE SEC_MFC_VP8Dec_Terminate(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ SEC_OMX_VIDEODEC_COMPONENT *pVideoDec = (SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle;
+ SEC_VP8DEC_HANDLE *pVp8Dec = NULL;
+ OMX_PTR hMFCHandle = NULL;
+
+ FunctionIn();
+
+ pVp8Dec = (SEC_VP8DEC_HANDLE *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ hMFCHandle = pVp8Dec->hMFCVp8Handle.hMFCHandle;
+
+ pVp8Dec->hMFCVp8Handle.pMFCStreamBuffer = NULL;
+ pVp8Dec->hMFCVp8Handle.pMFCStreamPhyBuffer = NULL;
+ pSECComponent->processData[INPUT_PORT_INDEX].dataBuffer = NULL;
+ pSECComponent->processData[INPUT_PORT_INDEX].allocSize = 0;
+
+#ifdef NONBLOCK_MODE_PROCESS
+ if (pVideoDec->NBDecThread.hNBDecodeThread != NULL) {
+ pVideoDec->NBDecThread.bExitDecodeThread = OMX_TRUE;
+ SEC_OSAL_SemaphorePost(pVideoDec->NBDecThread.hDecFrameStart);
+ SEC_OSAL_ThreadTerminate(pVideoDec->NBDecThread.hNBDecodeThread);
+ pVideoDec->NBDecThread.hNBDecodeThread = NULL;
+ }
+
+ if(pVideoDec->NBDecThread.hDecFrameEnd != NULL) {
+ SEC_OSAL_SemaphoreTerminate(pVideoDec->NBDecThread.hDecFrameEnd);
+ pVideoDec->NBDecThread.hDecFrameEnd = NULL;
+ }
+
+ if(pVideoDec->NBDecThread.hDecFrameStart != NULL) {
+ SEC_OSAL_SemaphoreTerminate(pVideoDec->NBDecThread.hDecFrameStart);
+ pVideoDec->NBDecThread.hDecFrameStart = NULL;
+ }
+#endif
+
+ if (hMFCHandle != NULL) {
+ SsbSipMfcDecClose(hMFCHandle);
+ hMFCHandle = pVp8Dec->hMFCVp8Handle.hMFCHandle = NULL;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_VP8_Decode_Nonblock(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_OMX_VIDEODEC_COMPONENT *pVideoDec = (SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle;
+ SEC_VP8DEC_HANDLE *pVp8Dec = (SEC_VP8DEC_HANDLE *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ SEC_OMX_BASEPORT *pSECInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+ OMX_U32 oneFrameSize = pInputData->dataLen;
+ SSBSIP_MFC_DEC_OUTPUT_INFO outputInfo;
+ OMX_S32 setConfVal = 0;
+ int bufWidth = 0;
+ int bufHeight = 0;
+ OMX_U32 FrameBufferYSize = 0;
+ OMX_U32 FrameBufferUVSize = 0;
+ OMX_BOOL outputDataValid = OMX_FALSE;
+
+ FunctionIn();
+
+ if (pVp8Dec->hMFCVp8Handle.bConfiguredMFC == OMX_FALSE) {
+ SSBSIP_MFC_CODEC_TYPE eCodecType = VP8_DEC;
+
+ if ((oneFrameSize <= 0) && (pInputData->nFlags & OMX_BUFFERFLAG_EOS)) {
+ pOutputData->timeStamp = pInputData->timeStamp;
+ pOutputData->nFlags = pInputData->nFlags;
+ ret = OMX_ErrorNone;
+ goto EXIT;
+ }
+
+ /* Default number in the driver is optimized */
+ if (pVideoDec->bThumbnailMode == OMX_TRUE) {
+ setConfVal = 0;
+ SsbSipMfcDecSetConfig(pVp8Dec->hMFCVp8Handle.hMFCHandle, MFC_DEC_SETCONF_DISPLAY_DELAY, &setConfVal);
+ } else {
+ setConfVal = VP8_DEC_NUM_OF_EXTRA_BUFFERS;
+ SsbSipMfcDecSetConfig(pVp8Dec->hMFCVp8Handle.hMFCHandle, MFC_DEC_SETCONF_EXTRA_BUFFER_NUM, &setConfVal);
+
+ setConfVal = 8;
+ SsbSipMfcDecSetConfig(pVp8Dec->hMFCVp8Handle.hMFCHandle, MFC_DEC_SETCONF_DISPLAY_DELAY, &setConfVal);
+ }
+
+ SsbSipMfcDecSetInBuf(pVp8Dec->hMFCVp8Handle.hMFCHandle,
+ pVp8Dec->hMFCVp8Handle.pMFCStreamPhyBuffer,
+ pVp8Dec->hMFCVp8Handle.pMFCStreamBuffer,
+ pSECComponent->processData[INPUT_PORT_INDEX].allocSize);
+
+ pVp8Dec->hMFCVp8Handle.returnCodec = SsbSipMfcDecInit(pVp8Dec->hMFCVp8Handle.hMFCHandle, eCodecType, oneFrameSize);
+ if (pVp8Dec->hMFCVp8Handle.returnCodec == MFC_RET_OK) {
+ SSBSIP_MFC_IMG_RESOLUTION imgResol;
+
+ SsbSipMfcDecGetConfig(pVp8Dec->hMFCVp8Handle.hMFCHandle, MFC_DEC_GETCONF_BUF_WIDTH_HEIGHT, &imgResol);
+ SEC_OSAL_Log(SEC_LOG_ERROR, "set width height information : %d, %d",
+ pSECInputPort->portDefinition.format.video.nFrameWidth,
+ pSECInputPort->portDefinition.format.video.nFrameHeight);
+ SEC_OSAL_Log(SEC_LOG_ERROR, "mfc width height information : %d, %d",
+ imgResol.width, imgResol.height);
+
+ if ((pSECInputPort->portDefinition.format.video.nFrameWidth != imgResol.width) ||
+ (pSECInputPort->portDefinition.format.video.nFrameHeight != imgResol.height)) {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "change width height information : OMX_EventPortSettingsChanged");
+
+ /* change width and height information */
+ pSECInputPort->portDefinition.format.video.nFrameWidth = imgResol.width;
+ pSECInputPort->portDefinition.format.video.nFrameHeight = imgResol.height;
+ pSECInputPort->portDefinition.format.video.nStride = ((imgResol.width + 15) & (~15));
+ pSECInputPort->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);
+ }
+
+ pVp8Dec->hMFCVp8Handle.bConfiguredMFC = OMX_TRUE;
+ pOutputData->timeStamp = pInputData->timeStamp;
+ pOutputData->nFlags = pInputData->nFlags;
+
+ ret = OMX_ErrorInputDataDecodeYet;
+ 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[pVp8Dec->hMFCVp8Handle.indexTimestamp] = pInputData->timeStamp;
+ pSECComponent->nFlags[pVp8Dec->hMFCVp8Handle.indexTimestamp] = pInputData->nFlags;
+
+ if ((pVp8Dec->hMFCVp8Handle.returnCodec == MFC_RET_OK) &&
+ (pVideoDec->bFirstFrame == OMX_FALSE)) {
+ SSBSIP_MFC_DEC_OUTBUF_STATUS status;
+ OMX_S32 indexTimestamp = 0;
+
+ /* wait for mfc decode done */
+ if (pVideoDec->NBDecThread.bDecoderRun == OMX_TRUE) {
+ SEC_OSAL_SemaphoreWait(pVideoDec->NBDecThread.hDecFrameEnd);
+ pVideoDec->NBDecThread.bDecoderRun = OMX_FALSE;
+ }
+
+ SEC_OSAL_SleepMillisec(0);
+ status = SsbSipMfcDecGetOutBuf(pVp8Dec->hMFCVp8Handle.hMFCHandle, &outputInfo);
+ bufWidth = (outputInfo.img_width + 15) & (~15);
+ bufHeight = (outputInfo.img_height + 15) & (~15);
+ FrameBufferYSize = ALIGN_TO_8KB(ALIGN_TO_128B(outputInfo.img_width) * ALIGN_TO_32B(outputInfo.img_height));
+ FrameBufferUVSize = ALIGN_TO_8KB(ALIGN_TO_128B(outputInfo.img_width) * ALIGN_TO_32B(outputInfo.img_height/2));
+
+ if ((SsbSipMfcDecGetConfig(pVp8Dec->hMFCVp8Handle.hMFCHandle, MFC_DEC_GETCONF_FRAME_TAG, &indexTimestamp) != MFC_RET_OK) ||
+ (((indexTimestamp < 0) || (indexTimestamp >= MAX_TIMESTAMP)))) {
+ pOutputData->timeStamp = pInputData->timeStamp;
+ pOutputData->nFlags = pInputData->nFlags;
+ } else {
+ /* For timestamp correction. if mfc support frametype detect */
+ SEC_OSAL_Log(SEC_LOG_TRACE, "disp_pic_frame_type: %d", outputInfo.disp_pic_frame_type);
+#ifdef NEED_TIMESTAMP_REORDER
+ if (outputInfo.disp_pic_frame_type == MFC_FRAME_TYPE_I_FRAME) {
+ pOutputData->timeStamp = pSECComponent->timeStamp[indexTimestamp];
+ pOutputData->nFlags = pSECComponent->nFlags[indexTimestamp];
+ pVp8Dec->hMFCVp8Handle.outputIndexTimestamp = indexTimestamp;
+ } else {
+ pOutputData->timeStamp = pSECComponent->timeStamp[pVp8Dec->hMFCVp8Handle.outputIndexTimestamp];
+ pOutputData->nFlags = pSECComponent->nFlags[pVp8Dec->hMFCVp8Handle.outputIndexTimestamp];
+ }
+#else
+ pOutputData->timeStamp = pSECComponent->timeStamp[indexTimestamp];
+ pOutputData->nFlags = pSECComponent->nFlags[indexTimestamp];
+#endif
+ 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;
+ pVp8Dec->hMFCVp8Handle.outputIndexTimestamp++;
+ pVp8Dec->hMFCVp8Handle.outputIndexTimestamp %= MAX_TIMESTAMP;
+ }
+ 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) {
+ 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 ((pVideoDec->bFirstFrame == OMX_TRUE) &&
+ ((pOutputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) &&
+ ((pInputData->nFlags & OMX_BUFFERFLAG_CODECCONFIG) != OMX_BUFFERFLAG_CODECCONFIG)) {
+ pOutputData->nFlags = (pOutputData->nFlags & (~OMX_BUFFERFLAG_EOS));
+ }
+
+ outputDataValid = OMX_FALSE;
+
+ /* ret = OMX_ErrorUndefined; */
+ ret = OMX_ErrorNone;
+ }
+
+ if (ret == OMX_ErrorInputDataDecodeYet) {
+ pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].dataSize = oneFrameSize;
+ pVideoDec->indexInputBuffer++;
+ pVideoDec->indexInputBuffer %= MFC_INPUT_BUFFER_NUM_MAX;
+ pVp8Dec->hMFCVp8Handle.pMFCStreamBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].VirAddr;
+ pVp8Dec->hMFCVp8Handle.pMFCStreamPhyBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].PhyAddr;
+ pSECComponent->processData[INPUT_PORT_INDEX].dataBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].VirAddr;
+ pSECComponent->processData[INPUT_PORT_INDEX].allocSize = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].bufferSize;
+ oneFrameSize = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].dataSize;
+ //pInputData->dataLen = oneFrameSize;
+ //pInputData->remainDataLen = oneFrameSize;
+ }
+
+ if ((Check_VP8_StartCode(pInputData->dataBuffer, oneFrameSize) == OMX_TRUE) &&
+ ((pOutputData->nFlags & OMX_BUFFERFLAG_EOS) != OMX_BUFFERFLAG_EOS)) {
+ if ((ret != OMX_ErrorInputDataDecodeYet) || (pSECComponent->getAllDelayBuffer == OMX_TRUE)) {
+ SsbSipMfcDecSetConfig(pVp8Dec->hMFCVp8Handle.hMFCHandle, MFC_DEC_SETCONF_FRAME_TAG, &(pVp8Dec->hMFCVp8Handle.indexTimestamp));
+ pVp8Dec->hMFCVp8Handle.indexTimestamp++;
+ pVp8Dec->hMFCVp8Handle.indexTimestamp %= MAX_TIMESTAMP;
+ }
+
+ SsbSipMfcDecSetInBuf(pVp8Dec->hMFCVp8Handle.hMFCHandle,
+ pVp8Dec->hMFCVp8Handle.pMFCStreamPhyBuffer,
+ pVp8Dec->hMFCVp8Handle.pMFCStreamBuffer,
+ pSECComponent->processData[INPUT_PORT_INDEX].allocSize);
+
+ pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].dataSize = oneFrameSize;
+ pVideoDec->NBDecThread.oneFrameSize = oneFrameSize;
+
+ /* mfc decode start */
+ SEC_OSAL_SemaphorePost(pVideoDec->NBDecThread.hDecFrameStart);
+ pVideoDec->NBDecThread.bDecoderRun = OMX_TRUE;
+ pVp8Dec->hMFCVp8Handle.returnCodec = MFC_RET_OK;
+
+ SEC_OSAL_SleepMillisec(0);
+
+ pVideoDec->indexInputBuffer++;
+ pVideoDec->indexInputBuffer %= MFC_INPUT_BUFFER_NUM_MAX;
+ pVp8Dec->hMFCVp8Handle.pMFCStreamBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].VirAddr;
+ pVp8Dec->hMFCVp8Handle.pMFCStreamPhyBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].PhyAddr;
+ pSECComponent->processData[INPUT_PORT_INDEX].dataBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].VirAddr;
+ pSECComponent->processData[INPUT_PORT_INDEX].allocSize = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].bufferSize;
+
+ if ((pVideoDec->bFirstFrame == OMX_TRUE) &&
+ (pSECComponent->bSaveFlagEOS == OMX_TRUE) &&
+ (outputDataValid == OMX_FALSE)) {
+ ret = OMX_ErrorInputDataDecodeYet;
+ }
+
+ pVideoDec->bFirstFrame = OMX_FALSE;
+ } else {
+ if (pSECComponent->checkTimeStamp.needCheckStartTimeStamp == OMX_TRUE)
+ pSECComponent->checkTimeStamp.needSetStartTimeStamp = OMX_TRUE;
+ }
+
+ /** Fill Output Buffer **/
+ if (outputDataValid == OMX_TRUE) {
+ void *pOutputBuf = (void *)pOutputData->dataBuffer;
+ void *pYUVBuf[3];
+
+ int frameSize = bufWidth * bufHeight;
+ int width = outputInfo.img_width;
+ int height = outputInfo.img_height;
+ int imageSize = outputInfo.img_width * outputInfo.img_height;
+
+ pYUVBuf[0] = (unsigned char *)pOutputBuf;
+ pYUVBuf[1] = (unsigned char *)pOutputBuf + imageSize;
+ pYUVBuf[2] = (unsigned char *)pOutputBuf + imageSize + imageSize / 4;
+ pOutputData->dataLen = (imageSize * 3) / 2;
+
+#ifdef USE_ANB
+ if (pSECOutputPort->bIsANBEnabled == OMX_TRUE) {
+ unsigned int stride;
+ SEC_OSAL_LockANB(pOutputData->dataBuffer, width, height, pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eColorFormat, &stride, pYUVBuf);
+ width = stride;
+ pOutputData->dataLen = sizeof(void *);
+ }
+#endif
+ if ((pVideoDec->bThumbnailMode == OMX_FALSE) &&
+ (pSECOutputPort->portDefinition.format.video.eColorFormat == OMX_SEC_COLOR_FormatNV12TPhysicalAddress)) {
+ /* if use Post copy address structure */
+ SEC_OSAL_Memcpy(pOutputBuf, &(outputInfo.YPhyAddr), sizeof(outputInfo.YPhyAddr));
+ SEC_OSAL_Memcpy((unsigned char *)pOutputBuf + (sizeof(void *) * 1), &(outputInfo.CPhyAddr), sizeof(outputInfo.CPhyAddr));
+ SEC_OSAL_Memcpy((unsigned char *)pOutputBuf + (sizeof(void *) * 2), &(outputInfo.YVirAddr), sizeof(outputInfo.YVirAddr));
+ SEC_OSAL_Memcpy((unsigned char *)pOutputBuf + (sizeof(void *) * 3), &(outputInfo.CVirAddr), sizeof(outputInfo.CVirAddr));
+ pOutputData->dataLen = (width * height * 3) / 2;
+ } else {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "YUV420 SP/P Output mode");
+ switch (pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eColorFormat) {
+ case OMX_SEC_COLOR_FormatNV12Tiled:
+ SEC_OSAL_Memcpy(pOutputBuf, outputInfo.YVirAddr, FrameBufferYSize);
+ SEC_OSAL_Memcpy((unsigned char *)pOutputBuf + FrameBufferYSize, outputInfo.CVirAddr, FrameBufferUVSize);
+ pOutputData->dataLen = FrameBufferYSize + FrameBufferUVSize;
+ break;
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ case OMX_SEC_COLOR_FormatANBYUV420SemiPlanar:
+ csc_tiled_to_linear_y_neon(
+ (unsigned char *)pYUVBuf[0],
+ (unsigned char *)outputInfo.YVirAddr,
+ width,
+ height);
+ csc_tiled_to_linear_uv_neon(
+ (unsigned char *)pYUVBuf[1],
+ (unsigned char *)outputInfo.CVirAddr,
+ width,
+ height / 2);
+ break;
+ break;
+ case OMX_COLOR_FormatYUV420Planar:
+ default:
+ csc_tiled_to_linear_y_neon(
+ (unsigned char *)pYUVBuf[0],
+ (unsigned char *)outputInfo.YVirAddr,
+ width,
+ height);
+ csc_tiled_to_linear_uv_deinterleave_neon(
+ (unsigned char *)pYUVBuf[1],
+ (unsigned char *)pYUVBuf[2],
+ (unsigned char *)outputInfo.CVirAddr,
+ width,
+ height / 2);
+ break;
+ }
+ }
+#ifdef USE_ANB
+ if (pSECOutputPort->bIsANBEnabled == OMX_TRUE) {
+ SEC_OSAL_UnlockANB(pOutputData->dataBuffer);
+ }
+#endif
+ } else {
+ pOutputData->dataLen = 0;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_VP8_Decode_Block(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_OMX_VIDEODEC_COMPONENT *pVideoDec = (SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle;
+ SEC_OMX_BASEPORT *pSECInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+ SEC_VP8DEC_HANDLE *pVp8Dec = (SEC_VP8DEC_HANDLE *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ OMX_U32 oneFrameSize = pInputData->dataLen;
+ SSBSIP_MFC_DEC_OUTPUT_INFO outputInfo;
+ OMX_S32 setConfVal = 0;
+ OMX_S32 returnCodec = 0;
+ int bufWidth = 0;
+ int bufHeight = 0;
+ OMX_U32 FrameBufferYSize;
+ OMX_U32 FrameBufferUVSize;
+
+ FunctionIn();
+
+ if (pVp8Dec->hMFCVp8Handle.bConfiguredMFC == OMX_FALSE) {
+ SSBSIP_MFC_CODEC_TYPE eCodecType = VP8_DEC;
+
+ if ((oneFrameSize <= 0) && (pInputData->nFlags & OMX_BUFFERFLAG_EOS)) {
+ pOutputData->timeStamp = pInputData->timeStamp;
+ pOutputData->nFlags = pInputData->nFlags;
+ ret = OMX_ErrorNone;
+ goto EXIT;
+ }
+
+ /* Default number in the driver is optimized */
+ if (pVideoDec->bThumbnailMode == OMX_TRUE) {
+ setConfVal = 0;
+ SsbSipMfcDecSetConfig(pVp8Dec->hMFCVp8Handle.hMFCHandle, MFC_DEC_SETCONF_DISPLAY_DELAY, &setConfVal);
+ } else {
+ setConfVal = VP8_DEC_NUM_OF_EXTRA_BUFFERS;
+ SsbSipMfcDecSetConfig(pVp8Dec->hMFCVp8Handle.hMFCHandle, MFC_DEC_SETCONF_EXTRA_BUFFER_NUM, &setConfVal);
+ }
+
+ returnCodec = SsbSipMfcDecInit(pVp8Dec->hMFCVp8Handle.hMFCHandle, eCodecType, oneFrameSize);
+ if (returnCodec == MFC_RET_OK) {
+ SSBSIP_MFC_IMG_RESOLUTION imgResol;
+
+ SsbSipMfcDecGetConfig(pVp8Dec->hMFCVp8Handle.hMFCHandle, MFC_DEC_GETCONF_BUF_WIDTH_HEIGHT, &imgResol);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "set width height information : %d, %d",
+ pSECInputPort->portDefinition.format.video.nFrameWidth,
+ pSECInputPort->portDefinition.format.video.nFrameHeight);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "mfc width height information : %d, %d",
+ imgResol.width, imgResol.height);
+
+ /** Update Frame Size **/
+ if ((pSECInputPort->portDefinition.format.video.nFrameWidth != imgResol.width) ||
+ (pSECInputPort->portDefinition.format.video.nFrameHeight != imgResol.height)) {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "change width height information : OMX_EventPortSettingsChanged");
+ /* change width and height information */
+ pSECInputPort->portDefinition.format.video.nFrameWidth = imgResol.width;
+ pSECInputPort->portDefinition.format.video.nFrameHeight = imgResol.height;
+ pSECInputPort->portDefinition.format.video.nStride = ((imgResol.width + 15) & (~15));
+ pSECInputPort->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);
+ }
+
+ pVp8Dec->hMFCVp8Handle.bConfiguredMFC = OMX_TRUE;
+ pOutputData->timeStamp = pInputData->timeStamp;
+ pOutputData->nFlags = pInputData->nFlags;
+
+ ret = OMX_ErrorInputDataDecodeYet;
+ 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
+
+ if (Check_VP8_StartCode(pInputData->dataBuffer, pInputData->dataLen) == OMX_TRUE) {
+ pSECComponent->timeStamp[pVp8Dec->hMFCVp8Handle.indexTimestamp] = pInputData->timeStamp;
+ pSECComponent->nFlags[pVp8Dec->hMFCVp8Handle.indexTimestamp] = pInputData->nFlags;
+ SsbSipMfcDecSetConfig(pVp8Dec->hMFCVp8Handle.hMFCHandle, MFC_DEC_SETCONF_FRAME_TAG, &(pVp8Dec->hMFCVp8Handle.indexTimestamp));
+
+ returnCodec = SsbSipMfcDecExe(pVp8Dec->hMFCVp8Handle.hMFCHandle, oneFrameSize);
+ } else {
+ if (pSECComponent->checkTimeStamp.needCheckStartTimeStamp == OMX_TRUE)
+ pSECComponent->checkTimeStamp.needSetStartTimeStamp = OMX_TRUE;
+
+ pOutputData->timeStamp = pInputData->timeStamp;
+ pOutputData->nFlags = pInputData->nFlags;
+ returnCodec = MFC_RET_OK;
+ goto EXIT;
+ }
+
+ if (returnCodec == MFC_RET_OK) {
+ SSBSIP_MFC_DEC_OUTBUF_STATUS status;
+ OMX_S32 indexTimestamp = 0;
+
+ status = SsbSipMfcDecGetOutBuf(pVp8Dec->hMFCVp8Handle.hMFCHandle, &outputInfo);
+ bufWidth = (outputInfo.img_width + 15) & (~15);
+ bufHeight = (outputInfo.img_height + 15) & (~15);
+ FrameBufferYSize = ALIGN_TO_8KB(ALIGN_TO_128B(outputInfo.img_width) * ALIGN_TO_32B(outputInfo.img_height));
+ FrameBufferUVSize = ALIGN_TO_8KB(ALIGN_TO_128B(outputInfo.img_width) * ALIGN_TO_32B(outputInfo.img_height/2));
+
+ if (status != MFC_GETOUTBUF_DISPLAY_ONLY) {
+ pVp8Dec->hMFCVp8Handle.indexTimestamp++;
+ pVp8Dec->hMFCVp8Handle.indexTimestamp %= MAX_TIMESTAMP;
+ }
+
+ if ((SsbSipMfcDecGetConfig(pVp8Dec->hMFCVp8Handle.hMFCHandle, MFC_DEC_GETCONF_FRAME_TAG, &indexTimestamp) != MFC_RET_OK) ||
+ (((indexTimestamp < 0) || (indexTimestamp >= MAX_TIMESTAMP)))) {
+ pOutputData->timeStamp = pInputData->timeStamp;
+ pOutputData->nFlags = pInputData->nFlags;
+ } else {
+ /* For timestamp correction. if mfc support frametype detect */
+ SEC_OSAL_Log(SEC_LOG_TRACE, "disp_pic_frame_type: %d", outputInfo.disp_pic_frame_type);
+#ifdef NEED_TIMESTAMP_REORDER
+ if (outputInfo.disp_pic_frame_type == MFC_FRAME_TYPE_I_FRAME) {
+ pOutputData->timeStamp = pSECComponent->timeStamp[indexTimestamp];
+ pOutputData->nFlags = pSECComponent->nFlags[indexTimestamp];
+ pVp8Dec->hMFCVp8Handle.outputIndexTimestamp = indexTimestamp;
+ } else {
+ pOutputData->timeStamp = pSECComponent->timeStamp[pVp8Dec->hMFCVp8Handle.outputIndexTimestamp];
+ pOutputData->nFlags = pSECComponent->nFlags[pVp8Dec->hMFCVp8Handle.outputIndexTimestamp];
+ }
+#else
+ pOutputData->timeStamp = pSECComponent->timeStamp[indexTimestamp];
+ pOutputData->nFlags = pSECComponent->nFlags[indexTimestamp];
+#endif
+ 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)) {
+ /** Fill Output Buffer **/
+ void *pOutputBuf = (void *)pOutputData->dataBuffer;
+ void *pYUVBuf[3];
+
+ int frameSize = bufWidth * bufHeight;
+ int width = outputInfo.img_width;
+ int height = outputInfo.img_height;
+ int imageSize = outputInfo.img_width * outputInfo.img_height;
+
+ pYUVBuf[0] = (unsigned char *)pOutputBuf;
+ pYUVBuf[1] = (unsigned char *)pOutputBuf + imageSize;
+ pYUVBuf[2] = (unsigned char *)pOutputBuf + imageSize + imageSize / 4;
+ pOutputData->dataLen = (imageSize * 3) / 2;
+
+#ifdef USE_ANB
+ if (pSECOutputPort->bIsANBEnabled == OMX_TRUE) {
+ unsigned int stride;
+ SEC_OSAL_LockANB(pOutputData->dataBuffer, width, height, pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eColorFormat, &stride, pYUVBuf);
+ width = stride;
+ pOutputData->dataLen = sizeof(void *);
+ }
+#endif
+ if ((pVideoDec->bThumbnailMode == OMX_FALSE) &&
+ (pSECOutputPort->portDefinition.format.video.eColorFormat == OMX_SEC_COLOR_FormatNV12TPhysicalAddress)) {
+ /* if use Post copy address structure */
+ SEC_OSAL_Memcpy(pOutputBuf, &(outputInfo.YPhyAddr), sizeof(outputInfo.YPhyAddr));
+ SEC_OSAL_Memcpy((unsigned char *)pOutputBuf + (sizeof(void *) * 1), &(outputInfo.CPhyAddr), sizeof(outputInfo.CPhyAddr));
+ SEC_OSAL_Memcpy((unsigned char *)pOutputBuf + (sizeof(void *) * 2), &(outputInfo.YVirAddr), sizeof(outputInfo.YVirAddr));
+ SEC_OSAL_Memcpy((unsigned char *)pOutputBuf + (sizeof(void *) * 3), &(outputInfo.CVirAddr), sizeof(outputInfo.CVirAddr));
+ pOutputData->dataLen = (width * height * 3) / 2;
+ } else {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "YUV420 SP/P Output mode");
+ switch (pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eColorFormat) {
+ case OMX_SEC_COLOR_FormatNV12Tiled:
+ SEC_OSAL_Memcpy(pOutputBuf, outputInfo.YVirAddr, FrameBufferYSize);
+ SEC_OSAL_Memcpy((unsigned char *)pOutputBuf + FrameBufferYSize, outputInfo.CVirAddr, FrameBufferUVSize);
+ pOutputData->dataLen = FrameBufferYSize + FrameBufferUVSize;
+ break;
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ case OMX_SEC_COLOR_FormatANBYUV420SemiPlanar:
+ csc_tiled_to_linear_y_neon(
+ (unsigned char *)pYUVBuf[0],
+ (unsigned char *)outputInfo.YVirAddr,
+ width,
+ height);
+ csc_tiled_to_linear_uv_neon(
+ (unsigned char *)pYUVBuf[1],
+ (unsigned char *)outputInfo.CVirAddr,
+ width,
+ height / 2);
+ break;
+ case OMX_COLOR_FormatYUV420Planar:
+ default:
+ csc_tiled_to_linear_y_neon(
+ (unsigned char *)pYUVBuf[0],
+ (unsigned char *)outputInfo.YVirAddr,
+ width,
+ height);
+ csc_tiled_to_linear_uv_deinterleave_neon(
+ (unsigned char *)pYUVBuf[1],
+ (unsigned char *)pYUVBuf[2],
+ (unsigned char *)outputInfo.CVirAddr,
+ width,
+ height / 2);
+ break;
+ }
+ }
+
+#ifdef USE_ANB
+ if (pSECOutputPort->bIsANBEnabled == OMX_TRUE) {
+ SEC_OSAL_UnlockANB(pOutputData->dataBuffer);
+ }
+#endif
+ pVp8Dec->hMFCVp8Handle.outputIndexTimestamp++;
+ pVp8Dec->hMFCVp8Handle.outputIndexTimestamp %= MAX_TIMESTAMP;
+ }
+ if (pOutputData->nFlags & OMX_BUFFERFLAG_EOS)
+ pOutputData->dataLen = 0;
+
+ 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;
+ }
+ goto EXIT;
+ }
+
+#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) {
+ 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;
+ }
+ pOutputData->dataLen = 0;
+
+ /* ret = OMX_ErrorUndefined; */
+ ret = OMX_ErrorNone;
+ goto EXIT;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+/* MFC Decode */
+OMX_ERRORTYPE SEC_MFC_VP8Dec_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_VP8DEC_HANDLE *pVp8Dec = (SEC_VP8DEC_HANDLE *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->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;
+ }
+
+#ifdef NONBLOCK_MODE_PROCESS
+ ret = SEC_MFC_VP8_Decode_Nonblock(pOMXComponent, pInputData, pOutputData);
+#else
+ ret = SEC_MFC_VP8_Decode_Block(pOMXComponent, pInputData, pOutputData);
+#endif
+ 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_OMX_VIDEODEC_COMPONENT *pVideoDec = NULL;
+ SEC_VP8DEC_HANDLE *pVp8Dec = NULL;
+ //OMX_BOOL bFlashPlayerMode = OMX_FALSE;
+ 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_VP8_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_DEC_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);
+
+ pVp8Dec = SEC_OSAL_Malloc(sizeof(SEC_VP8DEC_HANDLE));
+ if (pVp8Dec == NULL) {
+ SEC_OMX_VideoDecodeComponentDeinit(pOMXComponent);
+ ret = OMX_ErrorInsufficientResources;
+ SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__);
+ goto EXIT;
+ }
+ SEC_OSAL_Memset(pVp8Dec, 0, sizeof(SEC_VP8DEC_HANDLE));
+ pVideoDec = (SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle;
+ pVideoDec->hCodecHandle = (OMX_HANDLETYPE)pVp8Dec;
+
+ SEC_OSAL_Strcpy(pSECComponent->componentName, SEC_OMX_COMPONENT_VP8_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_CodingVPX;
+ SEC_OSAL_Memset(pSECPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE);
+ SEC_OSAL_Strcpy(pSECPort->portDefinition.format.video.cMIMEType, "video/x-vnd.on2.vp8");
+ 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_FormatYUV420Planar;
+ 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_VP8Dec_GetParameter;
+ pOMXComponent->SetParameter = &SEC_MFC_VP8Dec_SetParameter;
+ pOMXComponent->GetConfig = &SEC_MFC_VP8Dec_GetConfig;
+ pOMXComponent->SetConfig = &SEC_MFC_VP8Dec_SetConfig;
+ pOMXComponent->GetExtensionIndex = &SEC_MFC_VP8Dec_GetExtensionIndex;
+ pOMXComponent->ComponentRoleEnum = &SEC_MFC_VP8Dec_ComponentRoleEnum;
+ pOMXComponent->ComponentDeInit = &SEC_OMX_ComponentDeinit;
+
+ pSECComponent->sec_mfc_componentInit = &SEC_MFC_VP8Dec_Init;
+ pSECComponent->sec_mfc_componentTerminate = &SEC_MFC_VP8Dec_Terminate;
+ pSECComponent->sec_mfc_bufferProcess = &SEC_MFC_VP8Dec_bufferProcess;
+ pSECComponent->sec_checkInputFrame = &Check_VP8_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_VP8DEC_HANDLE *pVp8Dec = 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;
+
+ pVp8Dec = (SEC_VP8DEC_HANDLE *)((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ if (pVp8Dec != NULL) {
+ SEC_OSAL_Free(pVp8Dec);
+ pVp8Dec = ((SEC_OMX_VIDEODEC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle = NULL;
+ }
+
+ ret = SEC_OMX_VideoDecodeComponentDeinit(pOMXComponent);
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ ret = OMX_ErrorNone;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
diff --git a/exynos/multimedia/openmax/component/video/dec/vp8/SEC_OMX_Vp8dec.h b/exynos/multimedia/openmax/component/video/dec/vp8/SEC_OMX_Vp8dec.h
new file mode 100644
index 0000000..40ce20c
--- /dev/null
+++ b/exynos/multimedia/openmax/component/video/dec/vp8/SEC_OMX_Vp8dec.h
@@ -0,0 +1,66 @@
+/*
+ *
+ * Copyright 2011 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_Vp8dec.h
+ * @brief
+ * @author Satish Kumar Reddy (palli.satish@samsung.com)
+ * @version 1.1.0
+ * @history
+ * 2011.10.10 : Create
+ */
+
+#ifndef SEC_OMX_VP8_DEC_COMPONENT
+#define SEC_OMX_VP8_DEC_COMPONENT
+
+#include "SEC_OMX_Def.h"
+#include "OMX_Component.h"
+#include "OMX_Video.h"
+
+
+typedef struct _SEC_MFC_VP8DEC_HANDLE
+{
+ OMX_HANDLETYPE hMFCHandle;
+ OMX_PTR pMFCStreamBuffer;
+ OMX_PTR pMFCStreamPhyBuffer;
+ OMX_U32 indexTimestamp;
+ OMX_U32 outputIndexTimestamp;
+ OMX_BOOL bConfiguredMFC;
+ OMX_S32 returnCodec;
+} SEC_MFC_VP8DEC_HANDLE;
+
+typedef struct _SEC_VP8DEC_HANDLE
+{
+ /* OMX Codec specific */
+ OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE errorCorrectionType[ALL_PORT_NUM];
+
+ /* SEC MFC Codec specific */
+ SEC_MFC_VP8DEC_HANDLE hMFCVp8Handle;
+} SEC_VP8DEC_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/exynos/multimedia/openmax/component/video/dec/vp8/library_register.c b/exynos/multimedia/openmax/component/video/dec/vp8/library_register.c
new file mode 100644
index 0000000..13f7f4a
--- /dev/null
+++ b/exynos/multimedia/openmax/component/video/dec/vp8/library_register.c
@@ -0,0 +1,58 @@
+/*
+ *
+ * Copyright 2011 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 Satish Kumar Reddy (palli.satish@samsung.com)
+ * @version 1.1.0
+ * @history
+ * 2011.11.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_VP8_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 VP8 */
+ SEC_OSAL_Strcpy(ppSECComponent[0]->componentName, SEC_OMX_COMPONENT_VP8_DEC);
+ SEC_OSAL_Strcpy(ppSECComponent[0]->roles[0], SEC_OMX_COMPONENT_VP8_DEC_ROLE);
+ ppSECComponent[0]->totalRoleNum = MAX_COMPONENT_ROLE_NUM;
+
+EXIT:
+ FunctionOut();
+ return MAX_COMPONENT_NUM;
+}
+
diff --git a/exynos/multimedia/openmax/component/video/dec/vp8/library_register.h b/exynos/multimedia/openmax/component/video/dec/vp8/library_register.h
new file mode 100644
index 0000000..5e17150
--- /dev/null
+++ b/exynos/multimedia/openmax/component/video/dec/vp8/library_register.h
@@ -0,0 +1,54 @@
+/*
+ *
+ * Copyright 2011 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 Satish Kumar Reddy (palli.satish@samsung.com)
+ * @version 1.1.0
+ * @history
+ * 2011.11.15 : Create
+ */
+
+#ifndef SEC_OMX_VP8_DEC_REG
+#define SEC_OMX_VP8_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 1
+#define MAX_COMPONENT_ROLE_NUM 1
+
+/* VP8 */
+#define SEC_OMX_COMPONENT_VP8_DEC "OMX.SEC.VP8.Decoder"
+#define SEC_OMX_COMPONENT_VP8_DEC_ROLE "video_decoder.vpx"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+OSCL_EXPORT_REF int SEC_OMX_COMPONENT_Library_Register(SECRegisterComponentType **ppSECComponent);
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif
diff --git a/exynos/multimedia/openmax/component/video/enc/Android.mk b/exynos/multimedia/openmax/component/video/enc/Android.mk
new file mode 100644
index 0000000..e13d54d
--- /dev/null
+++ b/exynos/multimedia/openmax/component/video/enc/Android.mk
@@ -0,0 +1,27 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ SEC_OMX_Venc.c
+
+LOCAL_MODULE := libSEC_OMX_Venc
+LOCAL_ARM_MODE := arm
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_C_INCLUDES := $(SEC_OMX_INC)/khronos \
+ $(SEC_OMX_INC)/sec \
+ $(SEC_OMX_TOP)/osal \
+ $(SEC_OMX_TOP)/core \
+ $(SEC_OMX_COMPONENT)/common \
+ $(SEC_OMX_COMPONENT)/video/dec \
+ $(TARGET_OUT_HEADERS)/$(SEC_COPY_HEADERS_TO)
+
+ifeq ($(BOARD_USE_METADATABUFFERTYPE), true)
+LOCAL_CFLAGS += -DUSE_METADATABUFFERTYPE
+endif
+
+ifeq ($(BOARD_USE_STOREMETADATA), true)
+LOCAL_CFLAGS += -DUSE_STOREMETADATA
+endif
+
+include $(BUILD_STATIC_LIBRARY)
diff --git a/exynos/multimedia/openmax/component/video/enc/SEC_OMX_Venc.c b/exynos/multimedia/openmax/component/video/enc/SEC_OMX_Venc.c
new file mode 100644
index 0000000..d3f16b9
--- /dev/null
+++ b/exynos/multimedia/openmax/component/video/enc/SEC_OMX_Venc.c
@@ -0,0 +1,1802 @@
+/*
+ *
+ * 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_Venc.c
+ * @brief
+ * @author SeungBeom Kim (sbcrux.kim@samsung.com)
+ * Yunji Kim (yunji.kim@samsung.com)
+ * @version 1.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_Venc.h"
+#include "SEC_OMX_Basecomponent.h"
+#include "SEC_OSAL_Thread.h"
+#include "SEC_OSAL_Mutex.h"
+#include "SEC_OSAL_Semaphore.h"
+#include "SEC_OSAL_ETC.h"
+#include "color_space_convertor.h"
+
+#ifdef USE_STOREMETADATA
+#include "SEC_OSAL_Android.h"
+#endif
+
+#undef SEC_LOG_TAG
+#define SEC_LOG_TAG "SEC_VIDEO_ENC"
+#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;
+
+ if (width && height)
+ secOutputPort->portDefinition.nBufferSize = (width * height * 3) / 2;
+ }
+
+ 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;
+ OMX_U32 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;
+ OMX_U32 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;
+ OMX_U32 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;
+ OMX_PARAM_PORTDEFINITIONTYPE portDefinition;
+
+ 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_SignalWait(pSECComponent->pauseEvent, DEF_MAX_WAIT_TIME);
+ SEC_OSAL_SignalReset(pSECComponent->pauseEvent);
+ }
+
+ 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->bufferHeader->nOffset;
+ dataBuffer->dataValid = OMX_TRUE;
+ dataBuffer->nFlags = dataBuffer->bufferHeader->nFlags;
+ dataBuffer->timeStamp = dataBuffer->bufferHeader->nTimeStamp;
+ pSECComponent->processData[INPUT_PORT_INDEX].dataBuffer = dataBuffer->bufferHeader->pBuffer;
+ pSECComponent->processData[INPUT_PORT_INDEX].allocSize = dataBuffer->bufferHeader->nAllocLen;
+ SEC_OSAL_Free(message);
+ }
+ 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_SignalWait(pSECComponent->pauseEvent, DEF_MAX_WAIT_TIME);
+ SEC_OSAL_SignalReset(pSECComponent->pauseEvent);
+ }
+
+ /* 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; */
+ 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_VIDEOENC_COMPONENT *pVideoEnc = (SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle;
+ 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 flagEOS = OMX_FALSE;
+ OMX_BOOL flagEOF = OMX_FALSE;
+ OMX_BOOL previousFrameEOF = OMX_FALSE;
+
+ if (inputUseBuffer->dataValid == OMX_TRUE) {
+ checkInputStream = inputUseBuffer->bufferHeader->pBuffer + inputUseBuffer->usedDataLen;
+ checkInputStreamLen = inputUseBuffer->remainDataLen;
+
+ if ((inputUseBuffer->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) &&
+ (pSECComponent->bUseFlagEOF == OMX_FALSE)) {
+ pSECComponent->bUseFlagEOF = OMX_TRUE;
+ }
+
+ if (inputData->dataLen == 0) {
+ previousFrameEOF = OMX_TRUE;
+ } else {
+ previousFrameEOF = OMX_FALSE;
+ }
+ if (pSECComponent->bUseFlagEOF == OMX_TRUE) {
+ flagEOF = OMX_TRUE;
+ checkedSize = checkInputStreamLen;
+ if (checkedSize == 0) {
+ SEC_OMX_BASEPORT *pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ int width = pSECPort->portDefinition.format.video.nFrameWidth;
+ int height = pSECPort->portDefinition.format.video.nFrameHeight;
+ inputUseBuffer->remainDataLen = inputUseBuffer->dataLen = (width * height * 3) / 2;
+ checkedSize = checkInputStreamLen = inputUseBuffer->remainDataLen;
+ inputUseBuffer->nFlags |= OMX_BUFFERFLAG_EOS;
+ }
+ if (inputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS) {
+ flagEOS = OMX_TRUE;
+ }
+ } else {
+ SEC_OMX_BASEPORT *pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ int width = pSECPort->portDefinition.format.video.nFrameWidth;
+ int height = pSECPort->portDefinition.format.video.nFrameHeight;
+ unsigned int oneFrameSize = 0;
+
+ switch (pSECPort->portDefinition.format.video.eColorFormat) {
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ case OMX_COLOR_FormatYUV420Planar:
+ case OMX_SEC_COLOR_FormatNV12TPhysicalAddress:
+ case OMX_SEC_COLOR_FormatNV12LPhysicalAddress:
+ oneFrameSize = (width * height * 3) / 2;
+ break;
+ case OMX_SEC_COLOR_FormatNV12LVirtualAddress:
+ oneFrameSize = ALIGN((ALIGN(width, 16) * ALIGN(height, 16)), 2048) + ALIGN((ALIGN(width, 16) * ALIGN(height >> 1, 8)), 2048);
+ break;
+ default:
+ SEC_OSAL_Log(SEC_LOG_ERROR, "SEC_Preprocessor_InputData: eColorFormat is wrong");
+ break;
+ }
+
+ if (previousFrameEOF == OMX_TRUE) {
+ if (checkInputStreamLen >= oneFrameSize) {
+ checkedSize = oneFrameSize;
+ flagEOF = OMX_TRUE;
+ } else {
+ flagEOF = OMX_FALSE;
+ }
+ } else {
+ if (checkInputStreamLen >= (oneFrameSize - inputData->dataLen)) {
+ checkedSize = oneFrameSize - inputData->dataLen;
+ flagEOF = OMX_TRUE;
+ } else {
+ flagEOF = OMX_FALSE;
+ }
+ }
+
+ if ((flagEOF == OMX_FALSE) && (inputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS)) {
+ flagEOF = OMX_TRUE;
+ flagEOS = OMX_TRUE;
+ }
+ }
+
+ 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) {
+ SEC_OMX_BASEPORT *pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ if ((pSECPort->portDefinition.format.video.eColorFormat != OMX_SEC_COLOR_FormatNV12TPhysicalAddress) &&
+ (pSECPort->portDefinition.format.video.eColorFormat != OMX_SEC_COLOR_FormatNV12LPhysicalAddress) &&
+ (pSECPort->portDefinition.format.video.eColorFormat != OMX_SEC_COLOR_FormatNV12LVirtualAddress)) {
+ if (flagEOF == OMX_TRUE) {
+ OMX_U32 width, height;
+
+ width = pSECPort->portDefinition.format.video.nFrameWidth;
+ height = pSECPort->portDefinition.format.video.nFrameHeight;
+
+ SEC_OSAL_Log(SEC_LOG_TRACE, "pVideoEnc->MFCEncInputBuffer[%d].YVirAddr : 0x%x", pVideoEnc->indexInputBuffer, pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].YVirAddr);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "pVideoEnc->MFCEncInputBuffer[%d].CVirAddr : 0x%x", pVideoEnc->indexInputBuffer, pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].CVirAddr);
+
+ SEC_OSAL_Log(SEC_LOG_TRACE, "width:%d, height:%d, Ysize:%d", width, height, ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height)));
+ SEC_OSAL_Log(SEC_LOG_TRACE, "width:%d, height:%d, Csize:%d", width, height, ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height / 2)));
+
+ if (pSECPort->bStoreMetaData == OMX_FALSE) {
+ switch (pSECPort->portDefinition.format.video.eColorFormat) {
+ case OMX_COLOR_FormatYUV420Planar:
+ /* YUV420Planar case it needed changed interleave UV plane (MFC spec.)*/
+ SEC_OSAL_Memcpy(pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].YVirAddr,
+ checkInputStream, (width * height));
+ csc_interleave_memcpy_neon(pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].CVirAddr,
+ checkInputStream + (width * height),
+ checkInputStream + (((width * height) * 5) / 4),
+ width * height >> 2);
+ break;
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ SEC_OSAL_Memcpy(pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].YVirAddr,
+ checkInputStream, (width * height));
+ SEC_OSAL_Memcpy(pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].CVirAddr,
+ checkInputStream + (width * height), (width * height / 2));
+ break;
+ case OMX_SEC_COLOR_FormatNV12Tiled:
+ SEC_OSAL_Memcpy(pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].YVirAddr,
+ checkInputStream, ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height)));
+ SEC_OSAL_Memcpy(pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].CVirAddr,
+ checkInputStream + ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height)),
+ ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height / 2)));
+ break;
+ default:
+ break;
+ }
+ }
+#ifdef USE_METADATABUFFERTYPE
+ else {
+ if (pSECPort->portDefinition.format.video.eColorFormat == OMX_COLOR_FormatAndroidOpaque) {
+ OMX_PTR ppBuf[3];
+ OMX_PTR pOutBuffer;
+
+ SEC_OSAL_GetInfoFromMetaData(inputData, ppBuf);
+ SEC_OSAL_LockANBHandle((OMX_U32)ppBuf[0], width, height, OMX_COLOR_FormatAndroidOpaque, &pOutBuffer);
+
+ csc_ARGB8888_to_YUV420SP(pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].YVirAddr,
+ pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].CVirAddr,
+ pOutBuffer, width, height);
+
+ SEC_OSAL_UnlockANBHandle((OMX_U32)ppBuf[0]);
+ }
+ }
+#endif
+ }
+ }
+
+ inputUseBuffer->dataLen -= copySize; /* ???????????? do not need ?????????????? */
+ 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 {
+ if ((checkedSize == checkInputStreamLen) && (pSECComponent->bSaveFlagEOS == OMX_TRUE)) {
+ inputData->nFlags |= OMX_BUFFERFLAG_EOS;
+ flagEOF = OMX_TRUE;
+ pSECComponent->bSaveFlagEOS = OMX_FALSE;
+ } else {
+ inputData->nFlags = (inputUseBuffer->nFlags & (~OMX_BUFFERFLAG_EOS));
+ }
+ }
+ } else {
+ /*????????????????????????????????? Error ?????????????????????????????????*/
+ SEC_DataReset(pOMXComponent, INPUT_PORT_INDEX);
+ flagEOF = OMX_FALSE;
+ }
+
+ if (inputUseBuffer->remainDataLen == 0) {
+ if(flagEOF == OMX_FALSE)
+ 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;
+ }
+ 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;
+
+ if (outputUseBuffer->dataValid == OMX_TRUE) {
+ if (pSECComponent->checkTimeStamp.needCheckStartTimeStamp == OMX_TRUE) {
+ if (pSECComponent->checkTimeStamp.startTimeStamp == outputData->timeStamp){
+ 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;
+ if (copySize > 0)
+ SEC_OSAL_Memcpy((outputUseBuffer->bufferHeader->pBuffer + outputUseBuffer->dataLen),
+ (outputData->dataBuffer + outputData->usedDataLen),
+ copySize);
+
+ 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 encoded data size Out Length");
+
+ ret = OMX_FALSE;
+
+ /* reset outputData */
+ SEC_DataReset(pOMXComponent, OUTPUT_PORT_INDEX);
+ }
+ } else {
+ ret = OMX_FALSE;
+ }
+
+EXIT:
+ 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_VIDEOENC_COMPONENT *pVideoEnc = (SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle;
+ 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_SignalWait(pSECComponent->pauseEvent, DEF_MAX_WAIT_TIME);
+ SEC_OSAL_SignalReset(pSECComponent->pauseEvent);
+ }
+
+ 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);
+
+ if (inputUseBuffer->remainDataLen == 0)
+ SEC_InputBufferReturn(pOMXComponent);
+ else
+ inputUseBuffer->dataValid = OMX_TRUE;
+
+ SEC_OSAL_MutexUnlock(outputUseBuffer->bufferMutex);
+ SEC_OSAL_MutexUnlock(inputUseBuffer->bufferMutex);
+
+ if (ret == OMX_ErrorInputDataEncodeYet)
+ 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_VideoEncodeGetParameter(
+ 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_ErrorInvalidState;
+ 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;
+
+ 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;
+
+ switch (index) {
+ case supportFormat_0:
+ portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
+ portFormat->eColorFormat = OMX_COLOR_FormatYUV420Planar;
+ portFormat->xFramerate = portDefinition->format.video.xFramerate;
+ break;
+ case supportFormat_1:
+ portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
+ portFormat->eColorFormat = OMX_SEC_COLOR_FormatNV12TPhysicalAddress;
+ portFormat->xFramerate = portDefinition->format.video.xFramerate;
+ break;
+ case supportFormat_2:
+ portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
+ portFormat->eColorFormat = OMX_SEC_COLOR_FormatNV12LPhysicalAddress;
+ portFormat->xFramerate = portDefinition->format.video.xFramerate;
+ break;
+ case supportFormat_3:
+ portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
+ portFormat->eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
+ portFormat->xFramerate = portDefinition->format.video.xFramerate;
+ break;
+ case supportFormat_4:
+ portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
+ portFormat->eColorFormat = OMX_SEC_COLOR_FormatNV12Tiled;
+ portFormat->xFramerate = portDefinition->format.video.xFramerate;
+ break;
+ case supportFormat_5:
+ portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
+ portFormat->eColorFormat = OMX_SEC_COLOR_FormatNV12LVirtualAddress;
+ portFormat->xFramerate = portDefinition->format.video.xFramerate;
+ break;
+ case supportFormat_6:
+ portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused;
+ portFormat->eColorFormat = OMX_COLOR_FormatAndroidOpaque;
+ 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;
+
+ portFormat->eCompressionFormat = portDefinition->format.video.eCompressionFormat;
+ portFormat->eColorFormat = portDefinition->format.video.eColorFormat;
+ portFormat->xFramerate = portDefinition->format.video.xFramerate;
+ }
+ 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;
+ SEC_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
+ OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL;
+
+ if ((portIndex != OUTPUT_PORT_INDEX)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ } else {
+ pVideoEnc = (SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle;
+ pSECPort = &pSECComponent->pSECPort[portIndex];
+ portDefinition = &pSECPort->portDefinition;
+
+ videoRateControl->eControlRate = pVideoEnc->eControlRate[portIndex];
+ videoRateControl->nTargetBitrate = portDefinition->format.video.nBitrate;
+ }
+ ret = OMX_ErrorNone;
+ }
+ break;
+ case OMX_IndexParamVideoQuantization:
+ {
+ OMX_VIDEO_PARAM_QUANTIZATIONTYPE *videoQuantizationControl = (OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)ComponentParameterStructure;
+ OMX_U32 portIndex = videoQuantizationControl->nPortIndex;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+ SEC_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
+ OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL;
+
+ if ((portIndex != OUTPUT_PORT_INDEX)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ } else {
+ pVideoEnc = (SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle;
+ pSECPort = &pSECComponent->pSECPort[portIndex];
+ portDefinition = &pSECPort->portDefinition;
+
+ videoQuantizationControl->nQpI = pVideoEnc->quantization.nQpI;
+ videoQuantizationControl->nQpP = pVideoEnc->quantization.nQpP;
+ videoQuantizationControl->nQpB = pVideoEnc->quantization.nQpB;
+ }
+ ret = OMX_ErrorNone;
+
+ }
+ break;
+ case OMX_IndexParamPortDefinition:
+ {
+ OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = (OMX_PARAM_PORTDEFINITIONTYPE *)ComponentParameterStructure;
+ OMX_U32 portIndex = portDefinition->nPortIndex;
+ SEC_OMX_BASEPORT *pSECPort;
+
+ if (portIndex >= pSECComponent->portParam.nPorts) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+ ret = SEC_OMX_Check_SizeVersion(portDefinition, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ pSECPort = &pSECComponent->pSECPort[portIndex];
+ SEC_OSAL_Memcpy(portDefinition, &pSECPort->portDefinition, portDefinition->nSize);
+
+#ifdef USE_STOREMETADATA
+ if ((portIndex == 0) &&
+ (pSECPort->bStoreMetaData == OMX_TRUE) &&
+ (pSECPort->portDefinition.format.video.eColorFormat != OMX_SEC_COLOR_FormatNV12LVirtualAddress)) {
+ portDefinition->nBufferSize = MAX_INPUT_METADATA_BUFFER_SIZE;
+ }
+#endif
+ }
+ break;
+ default:
+ {
+ ret = SEC_OMX_GetParameter(hComponent, nParamIndex, ComponentParameterStructure);
+ }
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+OMX_ERRORTYPE SEC_OMX_VideoEncodeSetParameter(
+ 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_ErrorInvalidState;
+ 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;
+ SEC_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
+ OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL;
+
+ if ((portIndex != OUTPUT_PORT_INDEX)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ } else {
+ pVideoEnc = (SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle;
+ pSECPort = &pSECComponent->pSECPort[portIndex];
+ portDefinition = &pSECPort->portDefinition;
+
+ pVideoEnc->eControlRate[portIndex] = videoRateControl->eControlRate;
+ portDefinition->format.video.nBitrate = videoRateControl->nTargetBitrate;
+ }
+ ret = OMX_ErrorNone;
+ }
+ break;
+ case OMX_IndexParamVideoQuantization:
+ {
+ OMX_VIDEO_PARAM_QUANTIZATIONTYPE *videoQuantizationControl = (OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)ComponentParameterStructure;
+ OMX_U32 portIndex = videoQuantizationControl->nPortIndex;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+ SEC_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
+ OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL;
+
+ if ((portIndex != OUTPUT_PORT_INDEX)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ } else {
+ pVideoEnc = (SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle;
+ pSECPort = &pSECComponent->pSECPort[portIndex];
+ portDefinition = &pSECPort->portDefinition;
+
+ pVideoEnc->quantization.nQpI = videoQuantizationControl->nQpI;
+ pVideoEnc->quantization.nQpP = videoQuantizationControl->nQpP;
+ pVideoEnc->quantization.nQpB = videoQuantizationControl->nQpB;
+ }
+ ret = OMX_ErrorNone;
+ }
+ break;
+ case OMX_IndexParamPortDefinition:
+ {
+ OMX_PARAM_PORTDEFINITIONTYPE *pPortDefinition = (OMX_PARAM_PORTDEFINITIONTYPE *)ComponentParameterStructure;
+ 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);
+ if (portIndex == INPUT_PORT_INDEX) {
+ SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+ SEC_UpdateFrameSize(pOMXComponent);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "pSECOutputPort->portDefinition.nBufferSize: %d",
+ pSECOutputPort->portDefinition.nBufferSize);
+ }
+ ret = OMX_ErrorNone;
+ }
+ break;
+#ifdef USE_STOREMETADATA
+ case OMX_IndexParamStoreMetaDataBuffer:
+ {
+ ret = SEC_OSAL_SetANBParameter(hComponent, nIndex, ComponentParameterStructure);
+ }
+ break;
+#endif
+ default:
+ {
+ ret = SEC_OMX_SetParameter(hComponent, nIndex, ComponentParameterStructure);
+ }
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_OMX_VideoEncodeGetConfig(
+ 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 || 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_IndexConfigVideoBitrate:
+ {
+ OMX_VIDEO_CONFIG_BITRATETYPE *pEncodeBitrate = (OMX_VIDEO_CONFIG_BITRATETYPE *)pComponentConfigStructure;
+ OMX_U32 portIndex = pEncodeBitrate->nPortIndex;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+
+ if ((portIndex != OUTPUT_PORT_INDEX)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ } else {
+ pSECPort = &pSECComponent->pSECPort[portIndex];
+ pEncodeBitrate->nEncodeBitrate = pSECPort->portDefinition.format.video.nBitrate;
+ }
+ }
+ break;
+ case OMX_IndexConfigVideoFramerate:
+ {
+ OMX_CONFIG_FRAMERATETYPE *pFramerate = (OMX_CONFIG_FRAMERATETYPE *)pComponentConfigStructure;
+ OMX_U32 portIndex = pFramerate->nPortIndex;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+
+ if ((portIndex != OUTPUT_PORT_INDEX)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ } else {
+ pSECPort = &pSECComponent->pSECPort[portIndex];
+ pFramerate->xEncodeFramerate = pSECPort->portDefinition.format.video.xFramerate;
+ }
+ }
+ break;
+ default:
+ ret = SEC_OMX_SetConfig(hComponent, nIndex, pComponentConfigStructure);
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_OMX_VideoEncodeSetConfig(
+ 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 || 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_IndexConfigVideoBitrate:
+ {
+ OMX_VIDEO_CONFIG_BITRATETYPE *pEncodeBitrate = (OMX_VIDEO_CONFIG_BITRATETYPE *)pComponentConfigStructure;
+ OMX_U32 portIndex = pEncodeBitrate->nPortIndex;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+
+ if ((portIndex != OUTPUT_PORT_INDEX)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ } else {
+ pSECPort = &pSECComponent->pSECPort[portIndex];
+ pSECPort->portDefinition.format.video.nBitrate = pEncodeBitrate->nEncodeBitrate;
+ }
+ }
+ break;
+ case OMX_IndexConfigVideoFramerate:
+ {
+ OMX_CONFIG_FRAMERATETYPE *pFramerate = (OMX_CONFIG_FRAMERATETYPE *)pComponentConfigStructure;
+ OMX_U32 portIndex = pFramerate->nPortIndex;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+
+ if ((portIndex != OUTPUT_PORT_INDEX)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ } else {
+ pSECPort = &pSECComponent->pSECPort[portIndex];
+ pSECPort->portDefinition.format.video.xFramerate = pFramerate->xEncodeFramerate;
+ }
+ }
+ break;
+ case OMX_IndexConfigVideoIntraVOPRefresh:
+ {
+ OMX_CONFIG_INTRAREFRESHVOPTYPE *pIntraRefreshVOP = (OMX_CONFIG_INTRAREFRESHVOPTYPE *)pComponentConfigStructure;
+ SEC_OMX_VIDEOENC_COMPONENT *pVEncBase = ((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle);
+ OMX_U32 portIndex = pIntraRefreshVOP->nPortIndex;
+
+ if ((portIndex != OUTPUT_PORT_INDEX)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ } else {
+ pVEncBase->IntraRefreshVOP = pIntraRefreshVOP->IntraRefreshVOP;
+ }
+ }
+ break;
+ default:
+ ret = SEC_OMX_SetConfig(hComponent, nIndex, pComponentConfigStructure);
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_OMX_VideoEncodeGetExtensionIndex(
+ 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;
+ }
+
+#ifdef USE_STOREMETADATA
+ if (SEC_OSAL_Strcmp(cParameterName, SEC_INDEX_PARAM_STORE_METADATA_BUFFER) == 0) {
+ *pIndexType = (OMX_INDEXTYPE) OMX_IndexParamStoreMetaDataBuffer;
+ } else {
+ ret = SEC_OMX_GetExtensionIndex(hComponent, cParameterName, pIndexType);
+ }
+#else
+ ret = SEC_OMX_GetExtensionIndex(hComponent, cParameterName, pIndexType);
+#endif
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_OMX_VideoEncodeComponentInit(OMX_IN OMX_HANDLETYPE hComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+ SEC_OMX_VIDEOENC_COMPONENT *pVideoEnc = 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;
+
+ pVideoEnc = SEC_OSAL_Malloc(sizeof(SEC_OMX_VIDEOENC_COMPONENT));
+ if (pVideoEnc == NULL) {
+ SEC_OMX_BaseComponent_Destructor(pOMXComponent);
+ ret = OMX_ErrorInsufficientResources;
+ SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__);
+ goto EXIT;
+ }
+
+ SEC_OSAL_Memset(pVideoEnc, 0, sizeof(SEC_OMX_VIDEOENC_COMPONENT));
+ pSECComponent->hComponentHandle = (OMX_HANDLETYPE)pVideoEnc;
+
+ pSECComponent->bSaveFlagEOS = OMX_FALSE;
+
+ pVideoEnc->configChange = OMX_FALSE;
+ pVideoEnc->quantization.nQpI = 20;
+ pVideoEnc->quantization.nQpP = 20;
+ pVideoEnc->quantization.nQpB = 20;
+
+ /* 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;
+ pVideoEnc->eControlRate[INPUT_PORT_INDEX] = OMX_Video_ControlRateDisable;
+
+ pSECPort->bStoreMetaData = OMX_FALSE;
+
+ /* 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;
+ pVideoEnc->eControlRate[OUTPUT_PORT_INDEX] = OMX_Video_ControlRateDisable;
+
+ 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_VideoEncodeComponentDeinit(OMX_IN OMX_HANDLETYPE hComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+ SEC_OMX_VIDEOENC_COMPONENT *pVideoEnc = 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;
+
+ pVideoEnc = (SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle;
+ SEC_OSAL_Free(pVideoEnc);
+ pSECComponent->hComponentHandle = pVideoEnc = NULL;
+
+ 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/exynos/multimedia/openmax/component/video/enc/SEC_OMX_Venc.h b/exynos/multimedia/openmax/component/video/enc/SEC_OMX_Venc.h
new file mode 100644
index 0000000..b16b372
--- /dev/null
+++ b/exynos/multimedia/openmax/component/video/enc/SEC_OMX_Venc.h
@@ -0,0 +1,163 @@
+/*
+ *
+ * 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_Venc.h
+ * @brief
+ * @author SeungBeom Kim (sbcrux.kim@samsung.com)
+ * Yunji Kim (yunji.kim@samsung.com)
+ * @version 1.1.0
+ * @history
+ * 2010.7.15 : Create
+ */
+
+#ifndef SEC_OMX_VIDEO_ENCODE
+#define SEC_OMX_VIDEO_ENCODE
+
+#include "OMX_Component.h"
+#include "SEC_OMX_Def.h"
+#include "SEC_OSAL_Queue.h"
+#include "SEC_OMX_Baseport.h"
+#include "SEC_OMX_Basecomponent.h"
+
+#define MAX_VIDEO_INPUTBUFFER_NUM 5
+#define MAX_VIDEO_OUTPUTBUFFER_NUM 4
+
+#define DEFAULT_FRAME_WIDTH 176
+#define DEFAULT_FRAME_HEIGHT 144
+
+#define DEFAULT_VIDEO_INPUT_BUFFER_SIZE ALIGN_TO_8KB(ALIGN_TO_128B(DEFAULT_FRAME_WIDTH) * ALIGN_TO_32B(DEFAULT_FRAME_HEIGHT)) \
+ + ALIGN_TO_8KB(ALIGN_TO_128B(DEFAULT_FRAME_WIDTH) * ALIGN_TO_32B(DEFAULT_FRAME_HEIGHT / 2))
+ /* (DEFAULT_FRAME_WIDTH * DEFAULT_FRAME_HEIGHT * 3) / 2 */
+#define DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE DEFAULT_VIDEO_INPUT_BUFFER_SIZE
+
+#define MFC_INPUT_BUFFER_NUM_MAX 2
+
+#define INPUT_PORT_SUPPORTFORMAT_NUM_MAX 7
+#define OUTPUT_PORT_SUPPORTFORMAT_NUM_MAX 1
+
+#ifdef USE_STOREMETADATA
+// The largest metadata buffer size advertised
+// when metadata buffer mode is used for video encoding
+#define MAX_INPUT_METADATA_BUFFER_SIZE (64)
+#endif
+
+typedef struct
+{
+ void *pAddrY;
+ void *pAddrC;
+} MFC_ENC_ADDR_INFO;
+
+typedef struct _SEC_MFC_NBENC_THREAD
+{
+ OMX_HANDLETYPE hNBEncodeThread;
+ OMX_HANDLETYPE hEncFrameStart;
+ OMX_HANDLETYPE hEncFrameEnd;
+ OMX_BOOL bExitEncodeThread;
+ OMX_BOOL bEncoderRun;
+} SEC_MFC_NBENC_THREAD;
+
+typedef struct _MFC_ENC_INPUT_BUFFER
+{
+ void *YPhyAddr; // physical address of Y
+ void *CPhyAddr; // physical address of CbCr
+ void *YVirAddr; // virtual address of Y
+ void *CVirAddr; // virtual address of CbCr
+ int YBufferSize; // input buffer alloc size of Y
+ int CBufferSize; // input buffer alloc size of CbCr
+ int YDataSize; // input size of Y data
+ int CDataSize; // input size of CbCr data
+} MFC_ENC_INPUT_BUFFER;
+
+typedef struct _SEC_OMX_VIDEOENC_COMPONENT
+{
+ OMX_HANDLETYPE hCodecHandle;
+ SEC_MFC_NBENC_THREAD NBEncThread;
+
+ OMX_BOOL configChange;
+ OMX_BOOL IntraRefreshVOP;
+ OMX_VIDEO_CONTROLRATETYPE eControlRate[ALL_PORT_NUM];
+ OMX_VIDEO_PARAM_QUANTIZATIONTYPE quantization;
+ OMX_BOOL bFirstFrame;
+ MFC_ENC_INPUT_BUFFER MFCEncInputBuffer[MFC_INPUT_BUFFER_NUM_MAX];
+ OMX_U32 indexInputBuffer;
+} SEC_OMX_VIDEOENC_COMPONENT;
+
+#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_VideoEncodeGetParameter(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_INDEXTYPE nParamIndex,
+ OMX_INOUT OMX_PTR ComponentParameterStructure);
+OMX_ERRORTYPE SEC_OMX_VideoEncodeSetParameter(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_INDEXTYPE nIndex,
+ OMX_IN OMX_PTR ComponentParameterStructure);
+OMX_ERRORTYPE SEC_OMX_VideoEncodeGetConfig(
+ OMX_HANDLETYPE hComponent,
+ OMX_INDEXTYPE nIndex,
+ OMX_PTR pComponentConfigStructure);
+OMX_ERRORTYPE SEC_OMX_VideoEncodeSetConfig(
+ OMX_HANDLETYPE hComponent,
+ OMX_INDEXTYPE nIndex,
+ OMX_PTR pComponentConfigStructure);
+OMX_ERRORTYPE SEC_OMX_VideoEncodeGetExtensionIndex(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_STRING cParameterName,
+ OMX_OUT OMX_INDEXTYPE *pIndexType);
+OMX_ERRORTYPE SEC_OMX_VideoEncodeComponentInit(OMX_IN OMX_HANDLETYPE hComponent);
+OMX_ERRORTYPE SEC_OMX_VideoEncodeComponentDeinit(OMX_IN OMX_HANDLETYPE hComponent);
+OMX_BOOL SEC_Check_BufferProcess_State(SEC_OMX_BASECOMPONENT *pSECComponent);
+inline void SEC_UpdateFrameSize(OMX_COMPONENTTYPE *pOMXComponent);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/exynos/multimedia/openmax/component/video/enc/h264/Android.mk b/exynos/multimedia/openmax/component/video/enc/h264/Android.mk
new file mode 100644
index 0000000..435fbf7
--- /dev/null
+++ b/exynos/multimedia/openmax/component/video/enc/h264/Android.mk
@@ -0,0 +1,39 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := \
+ SEC_OMX_H264enc.c \
+ library_register.c
+
+LOCAL_PRELINK_MODULE := false
+LOCAL_MODULE := libOMX.SEC.AVC.Encoder
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/omx
+
+LOCAL_CFLAGS :=
+
+ifeq ($(BOARD_NONBLOCK_MODE_PROCESS), true)
+LOCAL_CFLAGS += -DNONBLOCK_MODE_PROCESS
+endif
+
+ifeq ($(BOARD_USE_METADATABUFFERTYPE), true)
+LOCAL_CFLAGS += -DUSE_METADATABUFFERTYPE
+endif
+
+LOCAL_ARM_MODE := arm
+
+LOCAL_STATIC_LIBRARIES := libSEC_OMX_Venc libsecosal libsecbasecomponent \
+ libseccscapi libsecmfcapi
+LOCAL_SHARED_LIBRARIES := libc libdl libcutils libutils libui \
+ libSEC_OMX_Resourcemanager
+
+LOCAL_C_INCLUDES := $(SEC_OMX_INC)/khronos \
+ $(SEC_OMX_INC)/sec \
+ $(SEC_OMX_TOP)/osal \
+ $(SEC_OMX_TOP)/core \
+ $(SEC_OMX_COMPONENT)/common \
+ $(SEC_OMX_COMPONENT)/video/enc \
+ $(TARGET_OUT_HEADERS)/$(SEC_COPY_HEADERS_TO)
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/exynos/multimedia/openmax/component/video/enc/h264/SEC_OMX_H264enc.c b/exynos/multimedia/openmax/component/video/enc/h264/SEC_OMX_H264enc.c
new file mode 100644
index 0000000..dfba49d
--- /dev/null
+++ b/exynos/multimedia/openmax/component/video/enc/h264/SEC_OMX_H264enc.c
@@ -0,0 +1,1582 @@
+/*
+ *
+ * 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_H264enc.c
+ * @brief
+ * @author SeungBeom Kim (sbcrux.kim@samsung.com)
+ * @version 1.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_Venc.h"
+#include "SEC_OSAL_ETC.h"
+#include "SEC_OSAL_Semaphore.h"
+#include "SEC_OSAL_Thread.h"
+#include "SEC_OSAL_Android.h"
+#include "library_register.h"
+#include "SEC_OMX_H264enc.h"
+#include "SsbSipMfcApi.h"
+#include "color_space_convertor.h"
+
+#undef SEC_LOG_TAG
+#define SEC_LOG_TAG "SEC_H264_ENC"
+#define SEC_LOG_OFF
+#include "SEC_OSAL_Log.h"
+
+
+/* H.264 Encoder 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_AVCProfileBaseline, OMX_VIDEO_AVCLevel32},
+ {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel4},
+
+ {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_AVCProfileMain, OMX_VIDEO_AVCLevel32},
+ {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel4},
+
+ {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},
+ {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel32},
+ {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel4}};
+
+
+OMX_U32 OMXAVCProfileToProfileIDC(OMX_VIDEO_AVCPROFILETYPE profile)
+{
+ OMX_U32 ret = 0; //default OMX_VIDEO_AVCProfileMain
+
+ if (profile == OMX_VIDEO_AVCProfileMain)
+ ret = 0;
+ else if (profile == OMX_VIDEO_AVCProfileHigh)
+ ret = 1;
+ else if (profile == OMX_VIDEO_AVCProfileBaseline)
+ ret = 2;
+
+ return ret;
+}
+
+OMX_U32 OMXAVCLevelToLevelIDC(OMX_VIDEO_AVCLEVELTYPE level)
+{
+ OMX_U32 ret = 40; //default OMX_VIDEO_AVCLevel4
+
+ if (level == OMX_VIDEO_AVCLevel1)
+ ret = 10;
+ else if (level == OMX_VIDEO_AVCLevel1b)
+ ret = 9;
+ else if (level == OMX_VIDEO_AVCLevel11)
+ ret = 11;
+ else if (level == OMX_VIDEO_AVCLevel12)
+ ret = 12;
+ else if (level == OMX_VIDEO_AVCLevel13)
+ ret = 13;
+ else if (level == OMX_VIDEO_AVCLevel2)
+ ret = 20;
+ else if (level == OMX_VIDEO_AVCLevel21)
+ ret = 21;
+ else if (level == OMX_VIDEO_AVCLevel22)
+ ret = 22;
+ else if (level == OMX_VIDEO_AVCLevel3)
+ ret = 30;
+ else if (level == OMX_VIDEO_AVCLevel31)
+ ret = 31;
+ else if (level == OMX_VIDEO_AVCLevel32)
+ ret = 32;
+ else if (level == OMX_VIDEO_AVCLevel4)
+ ret = 40;
+
+ return ret;
+}
+
+OMX_U8 *FindDelimiter(OMX_U8 *pBuffer, OMX_U32 size)
+{
+ OMX_U32 i;
+
+ for (i = 0; i < size - 3; i++) {
+ if ((pBuffer[i] == 0x00) &&
+ (pBuffer[i + 1] == 0x00) &&
+ (pBuffer[i + 2] == 0x00) &&
+ (pBuffer[i + 3] == 0x01))
+ return (pBuffer + i);
+ }
+
+ return NULL;
+}
+
+void H264PrintParams(SSBSIP_MFC_ENC_H264_PARAM *h264Arg)
+{
+ SEC_OSAL_Log(SEC_LOG_TRACE, "SourceWidth : %d\n", h264Arg->SourceWidth);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "SourceHeight : %d\n", h264Arg->SourceHeight);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "ProfileIDC : %d\n", h264Arg->ProfileIDC);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "LevelIDC : %d\n", h264Arg->LevelIDC);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "IDRPeriod : %d\n", h264Arg->IDRPeriod);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "NumberReferenceFrames : %d\n", h264Arg->NumberReferenceFrames);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "NumberRefForPframes : %d\n", h264Arg->NumberRefForPframes);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "SliceMode : %d\n", h264Arg->SliceMode);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "SliceArgument : %d\n", h264Arg->SliceArgument);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "NumberBFrames : %d\n", h264Arg->NumberBFrames);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "LoopFilterDisable : %d\n", h264Arg->LoopFilterDisable);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "LoopFilterAlphaC0Offset : %d\n", h264Arg->LoopFilterAlphaC0Offset);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "LoopFilterBetaOffset : %d\n", h264Arg->LoopFilterBetaOffset);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "SymbolMode : %d\n", h264Arg->SymbolMode);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "PictureInterlace : %d\n", h264Arg->PictureInterlace);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "Transform8x8Mode : %d\n", h264Arg->Transform8x8Mode);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "RandomIntraMBRefresh : %d\n", h264Arg->RandomIntraMBRefresh);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "PadControlOn : %d\n", h264Arg->PadControlOn);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "LumaPadVal : %d\n", h264Arg->LumaPadVal);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "CbPadVal : %d\n", h264Arg->CbPadVal);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "CrPadVal : %d\n", h264Arg->CrPadVal);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "EnableFRMRateControl : %d\n", h264Arg->EnableFRMRateControl);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "EnableMBRateControl : %d\n", h264Arg->EnableMBRateControl);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "FrameRate : %d\n", h264Arg->FrameRate);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "Bitrate : %d\n", h264Arg->Bitrate);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "FrameQp : %d\n", h264Arg->FrameQp);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "QSCodeMax : %d\n", h264Arg->QSCodeMax);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "QSCodeMin : %d\n", h264Arg->QSCodeMin);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "CBRPeriodRf : %d\n", h264Arg->CBRPeriodRf);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "DarkDisable : %d\n", h264Arg->DarkDisable);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "SmoothDisable : %d\n", h264Arg->SmoothDisable);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "StaticDisable : %d\n", h264Arg->StaticDisable);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "ActivityDisable : %d\n", h264Arg->ActivityDisable);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "FrameMap : %d\n", h264Arg->FrameMap);
+}
+
+void Set_H264Enc_Param(SSBSIP_MFC_ENC_H264_PARAM *pH264Arg, SEC_OMX_BASECOMPONENT *pSECComponent)
+{
+ SEC_OMX_BASEPORT *pSECInputPort = NULL;
+ SEC_OMX_BASEPORT *pSECOutputPort = NULL;
+ SEC_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
+ SEC_H264ENC_HANDLE *pH264Enc = NULL;
+
+ pVideoEnc = (SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle;
+ pH264Enc = (SEC_H264ENC_HANDLE *)((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ pSECInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+
+ pH264Arg->codecType = H264_ENC;
+ pH264Arg->SourceWidth = pSECOutputPort->portDefinition.format.video.nFrameWidth;
+ pH264Arg->SourceHeight = pSECOutputPort->portDefinition.format.video.nFrameHeight;
+ pH264Arg->IDRPeriod = pH264Enc->AVCComponent[OUTPUT_PORT_INDEX].nPFrames + 1;
+ pH264Arg->SliceMode = 0;
+ pH264Arg->RandomIntraMBRefresh = 0;
+ pH264Arg->Bitrate = pSECOutputPort->portDefinition.format.video.nBitrate;
+ pH264Arg->QSCodeMax = 51;
+ pH264Arg->QSCodeMin = 10;
+ pH264Arg->PadControlOn = 0; // 0: disable, 1: enable
+ pH264Arg->LumaPadVal = 0;
+ pH264Arg->CbPadVal = 0;
+ pH264Arg->CrPadVal = 0;
+
+ pH264Arg->ProfileIDC = OMXAVCProfileToProfileIDC(pH264Enc->AVCComponent[OUTPUT_PORT_INDEX].eProfile); //0; //(OMX_VIDEO_AVCProfileMain)
+ pH264Arg->LevelIDC = OMXAVCLevelToLevelIDC(pH264Enc->AVCComponent[OUTPUT_PORT_INDEX].eLevel); //40; //(OMX_VIDEO_AVCLevel4)
+ pH264Arg->FrameRate = (pSECInputPort->portDefinition.format.video.xFramerate) >> 16;
+ pH264Arg->SliceArgument = 0; // Slice mb/byte size number
+ pH264Arg->NumberBFrames = 0; // 0 ~ 2
+ pH264Arg->NumberReferenceFrames = 1;
+ pH264Arg->NumberRefForPframes = 1;
+ pH264Arg->LoopFilterDisable = 1; // 1: Loop Filter Disable, 0: Filter Enable
+ pH264Arg->LoopFilterAlphaC0Offset = 0;
+ pH264Arg->LoopFilterBetaOffset = 0;
+ pH264Arg->SymbolMode = 0; // 0: CAVLC, 1: CABAC
+ pH264Arg->PictureInterlace = 0;
+ pH264Arg->Transform8x8Mode = 0; // 0: 4x4, 1: allow 8x8
+ pH264Arg->DarkDisable = 1;
+ pH264Arg->SmoothDisable = 1;
+ pH264Arg->StaticDisable = 1;
+ pH264Arg->ActivityDisable = 1;
+
+ pH264Arg->FrameQp = pVideoEnc->quantization.nQpI;
+ pH264Arg->FrameQp_P = pVideoEnc->quantization.nQpP;
+ pH264Arg->FrameQp_B = pVideoEnc->quantization.nQpB;
+
+ SEC_OSAL_Log(SEC_LOG_TRACE, "pVideoEnc->eControlRate[OUTPUT_PORT_INDEX]: 0x%x", pVideoEnc->eControlRate[OUTPUT_PORT_INDEX]);
+ switch (pVideoEnc->eControlRate[OUTPUT_PORT_INDEX]) {
+ case OMX_Video_ControlRateVariable:
+ SEC_OSAL_Log(SEC_LOG_TRACE, "Video Encode VBR");
+ pH264Arg->EnableFRMRateControl = 0; // 0: Disable, 1: Frame level RC
+ pH264Arg->EnableMBRateControl = 0; // 0: Disable, 1:MB level RC
+ pH264Arg->CBRPeriodRf = 100;
+ break;
+ case OMX_Video_ControlRateConstant:
+ SEC_OSAL_Log(SEC_LOG_TRACE, "Video Encode CBR");
+ pH264Arg->EnableFRMRateControl = 1; // 0: Disable, 1: Frame level RC
+ pH264Arg->EnableMBRateControl = 1; // 0: Disable, 1:MB level RC
+ pH264Arg->CBRPeriodRf = 10;
+ break;
+ case OMX_Video_ControlRateDisable:
+ default: //Android default
+ SEC_OSAL_Log(SEC_LOG_TRACE, "Video Encode VBR");
+ pH264Arg->EnableFRMRateControl = 0;
+ pH264Arg->EnableMBRateControl = 0;
+ pH264Arg->CBRPeriodRf = 100;
+ break;
+ }
+
+ switch ((SEC_OMX_COLOR_FORMATTYPE)pSECInputPort->portDefinition.format.video.eColorFormat) {
+ case OMX_SEC_COLOR_FormatNV12LPhysicalAddress:
+ case OMX_SEC_COLOR_FormatNV12LVirtualAddress:
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ case OMX_COLOR_FormatYUV420Planar:
+#ifdef USE_METADATABUFFERTYPE
+ case OMX_COLOR_FormatAndroidOpaque:
+#endif
+ pH264Arg->FrameMap = NV12_LINEAR;
+ break;
+ case OMX_SEC_COLOR_FormatNV12TPhysicalAddress:
+ case OMX_SEC_COLOR_FormatNV12Tiled:
+ default:
+ pH264Arg->FrameMap = NV12_TILE;
+ break;
+ }
+
+ H264PrintParams(pH264Arg);
+}
+
+void Change_H264Enc_Param(SSBSIP_MFC_ENC_H264_PARAM *pH264Arg, SEC_OMX_BASECOMPONENT *pSECComponent)
+{
+ SEC_OMX_BASEPORT *pSECInputPort = NULL;
+ SEC_OMX_BASEPORT *pSECOutputPort = NULL;
+ SEC_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
+ SEC_H264ENC_HANDLE *pH264Enc = NULL;
+
+ pVideoEnc = (SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle;
+ pH264Enc = (SEC_H264ENC_HANDLE *)((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ pSECInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+
+ if (pVideoEnc->IntraRefreshVOP == OMX_TRUE) {
+ int set_conf_IntraRefreshVOP = 1;
+ SsbSipMfcEncSetConfig(pH264Enc->hMFCH264Handle.hMFCHandle,
+ MFC_ENC_SETCONF_FRAME_TYPE,
+ &set_conf_IntraRefreshVOP);
+ pVideoEnc->IntraRefreshVOP = OMX_FALSE;
+ }
+ if (pH264Arg->IDRPeriod != (int)pH264Enc->AVCComponent[OUTPUT_PORT_INDEX].nPFrames + 1) {
+ int set_conf_IDRPeriod = pH264Enc->AVCComponent[OUTPUT_PORT_INDEX].nPFrames + 1;
+ SsbSipMfcEncSetConfig(pH264Enc->hMFCH264Handle.hMFCHandle,
+ MFC_ENC_SETCONF_I_PERIOD,
+ &set_conf_IDRPeriod);
+ }
+ if (pH264Arg->Bitrate != (int)pSECOutputPort->portDefinition.format.video.nBitrate) {
+ int set_conf_bitrate = pSECOutputPort->portDefinition.format.video.nBitrate;
+ SsbSipMfcEncSetConfig(pH264Enc->hMFCH264Handle.hMFCHandle,
+ MFC_ENC_SETCONF_CHANGE_BIT_RATE,
+ &set_conf_bitrate);
+ }
+ if (pH264Arg->FrameRate != (int)((pSECOutputPort->portDefinition.format.video.xFramerate) >> 16)) {
+ int set_conf_framerate = (pSECInputPort->portDefinition.format.video.xFramerate) >> 16;
+ SsbSipMfcEncSetConfig(pH264Enc->hMFCH264Handle.hMFCHandle,
+ MFC_ENC_SETCONF_CHANGE_FRAME_RATE,
+ &set_conf_framerate);
+ }
+
+ Set_H264Enc_Param(pH264Arg, pSECComponent);
+ H264PrintParams(pH264Arg);
+}
+
+OMX_ERRORTYPE SEC_MFC_H264Enc_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_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ switch (nParamIndex) {
+ case OMX_IndexParamVideoAvc:
+ {
+ OMX_VIDEO_PARAM_AVCTYPE *pDstAVCComponent = (OMX_VIDEO_PARAM_AVCTYPE *)pComponentParameterStructure;
+ OMX_VIDEO_PARAM_AVCTYPE *pSrcAVCComponent = NULL;
+ SEC_H264ENC_HANDLE *pH264Enc = 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;
+ }
+
+ pH264Enc = (SEC_H264ENC_HANDLE *)((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ pSrcAVCComponent = &pH264Enc->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_ENC_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_H264ENC_HANDLE *pH264Enc = 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;
+ }
+
+ pH264Enc = (SEC_H264ENC_HANDLE *)((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ pSrcAVCComponent = &pH264Enc->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_H264ENC_HANDLE *pH264Enc = NULL;
+
+ ret = SEC_OMX_Check_SizeVersion(pDstErrorCorrectionType, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pDstErrorCorrectionType->nPortIndex != OUTPUT_PORT_INDEX) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ pH264Enc = (SEC_H264ENC_HANDLE *)((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ pSrcErrorCorrectionType = &pH264Enc->errorCorrectionType[OUTPUT_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_VideoEncodeGetParameter(hComponent, nParamIndex, pComponentParameterStructure);
+ break;
+ }
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_H264Enc_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_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ switch (nIndex) {
+ case OMX_IndexParamVideoAvc:
+ {
+ OMX_VIDEO_PARAM_AVCTYPE *pDstAVCComponent = NULL;
+ OMX_VIDEO_PARAM_AVCTYPE *pSrcAVCComponent = (OMX_VIDEO_PARAM_AVCTYPE *)pComponentParameterStructure;
+ SEC_H264ENC_HANDLE *pH264Enc = 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;
+ }
+
+ pH264Enc = (SEC_H264ENC_HANDLE *)((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ pDstAVCComponent = &pH264Enc->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_ENC_ROLE)) {
+ pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingAVC;
+ } else {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ }
+ break;
+ case OMX_IndexParamVideoProfileLevelCurrent:
+ {
+ OMX_VIDEO_PARAM_PROFILELEVELTYPE *pSrcProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pComponentParameterStructure;
+ OMX_VIDEO_PARAM_AVCTYPE *pDstAVCComponent = NULL;
+ SEC_H264ENC_HANDLE *pH264Enc = 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;
+ }
+
+ pH264Enc = (SEC_H264ENC_HANDLE *)((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+
+ pDstAVCComponent = &pH264Enc->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_H264ENC_HANDLE *pH264Enc = NULL;
+
+ ret = SEC_OMX_Check_SizeVersion(pSrcErrorCorrectionType, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pSrcErrorCorrectionType->nPortIndex != OUTPUT_PORT_INDEX) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ pH264Enc = (SEC_H264ENC_HANDLE *)((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ pDstErrorCorrectionType = &pH264Enc->errorCorrectionType[OUTPUT_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_VideoEncodeSetParameter(hComponent, nIndex, pComponentParameterStructure);
+ break;
+ }
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_H264Enc_GetConfig(
+ OMX_HANDLETYPE hComponent,
+ OMX_INDEXTYPE nIndex,
+ OMX_PTR pComponentConfigStructure)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+ SEC_H264ENC_HANDLE *pH264Enc = 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;
+ }
+ pH264Enc = (SEC_H264ENC_HANDLE *)((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+
+ switch (nIndex) {
+ case OMX_IndexConfigVideoAVCIntraPeriod:
+ {
+ OMX_VIDEO_CONFIG_AVCINTRAPERIOD *pAVCIntraPeriod = (OMX_VIDEO_CONFIG_AVCINTRAPERIOD *)pComponentConfigStructure;
+ OMX_U32 portIndex = pAVCIntraPeriod->nPortIndex;
+
+ if ((portIndex != OUTPUT_PORT_INDEX)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ } else {
+ pAVCIntraPeriod->nIDRPeriod = pH264Enc->AVCComponent[OUTPUT_PORT_INDEX].nPFrames + 1;
+ pAVCIntraPeriod->nPFrames = pH264Enc->AVCComponent[OUTPUT_PORT_INDEX].nPFrames;
+ }
+ }
+ break;
+ default:
+ ret = SEC_OMX_VideoEncodeGetConfig(hComponent, nIndex, pComponentConfigStructure);
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_H264Enc_SetConfig(
+ OMX_HANDLETYPE hComponent,
+ OMX_INDEXTYPE nIndex,
+ OMX_PTR pComponentConfigStructure)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+ SEC_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
+ SEC_H264ENC_HANDLE *pH264Enc = 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;
+ }
+
+ pVideoEnc = ((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle);
+ pH264Enc = (SEC_H264ENC_HANDLE *)((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+
+ switch (nIndex) {
+ case OMX_IndexConfigVideoIntraPeriod:
+ {
+ SEC_OMX_VIDEOENC_COMPONENT *pVEncBase = ((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle);
+ OMX_U32 nPFrames = (*((OMX_U32 *)pComponentConfigStructure)) - 1;
+
+ pH264Enc->AVCComponent[OUTPUT_PORT_INDEX].nPFrames = nPFrames;
+
+ ret = OMX_ErrorNone;
+ }
+ break;
+ case OMX_IndexConfigVideoAVCIntraPeriod:
+ {
+ OMX_VIDEO_CONFIG_AVCINTRAPERIOD *pAVCIntraPeriod = (OMX_VIDEO_CONFIG_AVCINTRAPERIOD *)pComponentConfigStructure;
+ OMX_U32 portIndex = pAVCIntraPeriod->nPortIndex;
+
+ if ((portIndex != OUTPUT_PORT_INDEX)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ } else {
+ if (pAVCIntraPeriod->nIDRPeriod == (pAVCIntraPeriod->nPFrames + 1))
+ pH264Enc->AVCComponent[OUTPUT_PORT_INDEX].nPFrames = pAVCIntraPeriod->nPFrames;
+ else {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ }
+ }
+ break;
+ default:
+ ret = SEC_OMX_VideoEncodeSetConfig(hComponent, nIndex, pComponentConfigStructure);
+ break;
+ }
+
+EXIT:
+ if (ret == OMX_ErrorNone)
+ pVideoEnc->configChange = OMX_TRUE;
+
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_H264Enc_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_CONFIG_VIDEO_INTRAPERIOD) == 0) {
+ *pIndexType = OMX_IndexConfigVideoIntraPeriod;
+ ret = OMX_ErrorNone;
+ } else {
+ ret = SEC_OMX_VideoEncodeGetExtensionIndex(hComponent, cParameterName, pIndexType);
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_H264Enc_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_ENC_ROLE);
+ ret = OMX_ErrorNone;
+ } else {
+ ret = OMX_ErrorNoMore;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_EncodeThread(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_VIDEOENC_COMPONENT *pVideoEnc = (SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle;
+ SEC_H264ENC_HANDLE *pH264Enc = (SEC_H264ENC_HANDLE *)pVideoEnc->hCodecHandle;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ while (pVideoEnc->NBEncThread.bExitEncodeThread == OMX_FALSE) {
+ SEC_OSAL_SemaphoreWait(pVideoEnc->NBEncThread.hEncFrameStart);
+
+ if (pVideoEnc->NBEncThread.bExitEncodeThread == OMX_FALSE) {
+ pH264Enc->hMFCH264Handle.returnCodec = SsbSipMfcEncExe(pH264Enc->hMFCH264Handle.hMFCHandle);
+ SEC_OSAL_SemaphorePost(pVideoEnc->NBEncThread.hEncFrameEnd);
+ }
+ }
+
+EXIT:
+ FunctionOut();
+ SEC_OSAL_ThreadExit(NULL);
+
+ return ret;
+}
+
+/* MFC Init */
+OMX_ERRORTYPE SEC_MFC_H264Enc_Init(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ SEC_OMX_VIDEOENC_COMPONENT *pVideoEnc = (SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle;
+ SEC_OMX_BASEPORT *pSECInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ SEC_H264ENC_HANDLE *pH264Enc = NULL;
+ OMX_PTR hMFCHandle = NULL;
+ OMX_S32 returnCodec = 0;
+
+ FunctionIn();
+
+ pH264Enc = (SEC_H264ENC_HANDLE *)((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ pH264Enc->hMFCH264Handle.bConfiguredMFC = OMX_FALSE;
+ pSECComponent->bUseFlagEOF = OMX_FALSE;
+ pSECComponent->bSaveFlagEOS = OMX_FALSE;
+
+ /* MFC(Multi Function Codec) encoder and CMM(Codec Memory Management) driver open */
+ switch (pSECInputPort->portDefinition.format.video.eColorFormat) {
+ case OMX_SEC_COLOR_FormatNV12TPhysicalAddress:
+ case OMX_SEC_COLOR_FormatNV12LPhysicalAddress:
+ case OMX_SEC_COLOR_FormatNV12LVirtualAddress:
+ hMFCHandle = (OMX_PTR)SsbSipMfcEncOpen();
+ break;
+ default: {
+ SSBIP_MFC_BUFFER_TYPE buf_type = CACHE;
+ hMFCHandle = (OMX_PTR)SsbSipMfcEncOpenExt(&buf_type);
+ break;
+ }
+ }
+
+ if (hMFCHandle == NULL) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ pH264Enc->hMFCH264Handle.hMFCHandle = hMFCHandle;
+
+ Set_H264Enc_Param(&(pH264Enc->hMFCH264Handle.mfcVideoAvc), pSECComponent);
+
+ returnCodec = SsbSipMfcEncInit(hMFCHandle, &(pH264Enc->hMFCH264Handle.mfcVideoAvc));
+ if (returnCodec != MFC_RET_OK) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+
+ /* Allocate encoder's input buffer */
+ returnCodec = SsbSipMfcEncGetInBuf(hMFCHandle, &(pH264Enc->hMFCH264Handle.inputInfo));
+ if (returnCodec != MFC_RET_OK) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ pVideoEnc->MFCEncInputBuffer[0].YPhyAddr = pH264Enc->hMFCH264Handle.inputInfo.YPhyAddr;
+ pVideoEnc->MFCEncInputBuffer[0].CPhyAddr = pH264Enc->hMFCH264Handle.inputInfo.CPhyAddr;
+ pVideoEnc->MFCEncInputBuffer[0].YVirAddr = pH264Enc->hMFCH264Handle.inputInfo.YVirAddr;
+ pVideoEnc->MFCEncInputBuffer[0].CVirAddr = pH264Enc->hMFCH264Handle.inputInfo.CVirAddr;
+ pVideoEnc->MFCEncInputBuffer[0].YBufferSize = pH264Enc->hMFCH264Handle.inputInfo.YSize;
+ pVideoEnc->MFCEncInputBuffer[0].CBufferSize = pH264Enc->hMFCH264Handle.inputInfo.CSize;
+ pVideoEnc->MFCEncInputBuffer[0].YDataSize = 0;
+ pVideoEnc->MFCEncInputBuffer[0].CDataSize = 0;
+ SEC_OSAL_Log(SEC_LOG_TRACE, "pH264Enc->hMFCH264Handle.inputInfo.YVirAddr : 0x%x", pH264Enc->hMFCH264Handle.inputInfo.YVirAddr);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "pH264Enc->hMFCH264Handle.inputInfo.CVirAddr : 0x%x", pH264Enc->hMFCH264Handle.inputInfo.CVirAddr);
+
+ returnCodec = SsbSipMfcEncGetInBuf(hMFCHandle, &(pH264Enc->hMFCH264Handle.inputInfo));
+ if (returnCodec != MFC_RET_OK) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ pVideoEnc->MFCEncInputBuffer[1].YPhyAddr = pH264Enc->hMFCH264Handle.inputInfo.YPhyAddr;
+ pVideoEnc->MFCEncInputBuffer[1].CPhyAddr = pH264Enc->hMFCH264Handle.inputInfo.CPhyAddr;
+ pVideoEnc->MFCEncInputBuffer[1].YVirAddr = pH264Enc->hMFCH264Handle.inputInfo.YVirAddr;
+ pVideoEnc->MFCEncInputBuffer[1].CVirAddr = pH264Enc->hMFCH264Handle.inputInfo.CVirAddr;
+ pVideoEnc->MFCEncInputBuffer[1].YBufferSize = pH264Enc->hMFCH264Handle.inputInfo.YSize;
+ pVideoEnc->MFCEncInputBuffer[1].CBufferSize = pH264Enc->hMFCH264Handle.inputInfo.CSize;
+ pVideoEnc->MFCEncInputBuffer[1].YDataSize = 0;
+ pVideoEnc->MFCEncInputBuffer[1].CDataSize = 0;
+ SEC_OSAL_Log(SEC_LOG_TRACE, "pH264Enc->hMFCH264Handle.inputInfo.YVirAddr : 0x%x", pH264Enc->hMFCH264Handle.inputInfo.YVirAddr);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "pH264Enc->hMFCH264Handle.inputInfo.CVirAddr : 0x%x", pH264Enc->hMFCH264Handle.inputInfo.CVirAddr);
+
+ pVideoEnc->indexInputBuffer = 0;
+
+ pVideoEnc->bFirstFrame = OMX_TRUE;
+
+#ifdef NONBLOCK_MODE_PROCESS
+ pVideoEnc->NBEncThread.bExitEncodeThread = OMX_FALSE;
+ pVideoEnc->NBEncThread.bEncoderRun = OMX_FALSE;
+ SEC_OSAL_SemaphoreCreate(&(pVideoEnc->NBEncThread.hEncFrameStart));
+ SEC_OSAL_SemaphoreCreate(&(pVideoEnc->NBEncThread.hEncFrameEnd));
+ if (OMX_ErrorNone == SEC_OSAL_ThreadCreate(&pVideoEnc->NBEncThread.hNBEncodeThread,
+ SEC_MFC_EncodeThread,
+ pOMXComponent)) {
+ pH264Enc->hMFCH264Handle.returnCodec = MFC_RET_OK;
+ }
+#endif
+ SEC_OSAL_Memset(pSECComponent->timeStamp, -19771003, sizeof(OMX_TICKS) * MAX_TIMESTAMP);
+ SEC_OSAL_Memset(pSECComponent->nFlags, 0, sizeof(OMX_U32) * MAX_FLAGS);
+ pH264Enc->hMFCH264Handle.indexTimestamp = 0;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+/* MFC Terminate */
+OMX_ERRORTYPE SEC_MFC_H264Enc_Terminate(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ SEC_OMX_VIDEOENC_COMPONENT *pVideoEnc = ((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle);
+ SEC_H264ENC_HANDLE *pH264Enc = NULL;
+ OMX_PTR hMFCHandle = NULL;
+
+ FunctionIn();
+
+ pH264Enc = (SEC_H264ENC_HANDLE *)((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+#ifdef NONBLOCK_MODE_PROCESS
+ if (pVideoEnc->NBEncThread.hNBEncodeThread != NULL) {
+ pVideoEnc->NBEncThread.bExitEncodeThread = OMX_TRUE;
+ SEC_OSAL_SemaphorePost(pVideoEnc->NBEncThread.hEncFrameStart);
+ SEC_OSAL_ThreadTerminate(pVideoEnc->NBEncThread.hNBEncodeThread);
+ pVideoEnc->NBEncThread.hNBEncodeThread = NULL;
+ }
+
+ if(pVideoEnc->NBEncThread.hEncFrameEnd != NULL) {
+ SEC_OSAL_SemaphoreTerminate(pVideoEnc->NBEncThread.hEncFrameEnd);
+ pVideoEnc->NBEncThread.hEncFrameEnd = NULL;
+ }
+
+ if(pVideoEnc->NBEncThread.hEncFrameStart != NULL) {
+ SEC_OSAL_SemaphoreTerminate(pVideoEnc->NBEncThread.hEncFrameStart);
+ pVideoEnc->NBEncThread.hEncFrameStart = NULL;
+ }
+#endif
+
+ hMFCHandle = pH264Enc->hMFCH264Handle.hMFCHandle;
+ if (hMFCHandle != NULL) {
+ SsbSipMfcEncClose(hMFCHandle);
+ hMFCHandle = pH264Enc->hMFCH264Handle.hMFCHandle = NULL;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_H264_Encode_Nonblock(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_OMX_VIDEOENC_COMPONENT *pVideoEnc = ((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle);
+ SEC_H264ENC_HANDLE *pH264Enc = (SEC_H264ENC_HANDLE *)((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ SSBSIP_MFC_ENC_INPUT_INFO *pInputInfo = &pH264Enc->hMFCH264Handle.inputInfo;
+ SSBSIP_MFC_ENC_OUTPUT_INFO outputInfo;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+ MFC_ENC_ADDR_INFO addrInfo;
+ OMX_U32 oneFrameSize = pInputData->dataLen;
+
+ FunctionIn();
+
+ if (pH264Enc->hMFCH264Handle.bConfiguredMFC == OMX_FALSE) {
+ pH264Enc->hMFCH264Handle.returnCodec = SsbSipMfcEncGetOutBuf(pH264Enc->hMFCH264Handle.hMFCHandle, &outputInfo);
+ if (pH264Enc->hMFCH264Handle.returnCodec != MFC_RET_OK) {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "%s - SsbSipMfcEncGetOutBuf Failed\n", __func__);
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ } else {
+ OMX_U8 *p = NULL;
+ int iSpsSize = 0;
+ int iPpsSize = 0;
+
+ p = FindDelimiter((OMX_U8 *)outputInfo.StrmVirAddr + 4, outputInfo.headerSize - 4);
+
+ iSpsSize = (unsigned int)p - (unsigned int)outputInfo.StrmVirAddr;
+ pH264Enc->hMFCH264Handle.headerData.pHeaderSPS = (OMX_PTR)outputInfo.StrmVirAddr;
+ pH264Enc->hMFCH264Handle.headerData.SPSLen = iSpsSize;
+
+ iPpsSize = outputInfo.headerSize - iSpsSize;
+ pH264Enc->hMFCH264Handle.headerData.pHeaderPPS = (OMX_U8 *)outputInfo.StrmVirAddr + iSpsSize;
+ pH264Enc->hMFCH264Handle.headerData.PPSLen = iPpsSize;
+ }
+
+ pOutputData->dataBuffer = outputInfo.StrmVirAddr;
+ pOutputData->allocSize = outputInfo.headerSize;
+ pOutputData->dataLen = outputInfo.headerSize;
+ pOutputData->timeStamp = 0;
+ pOutputData->nFlags |= OMX_BUFFERFLAG_CODECCONFIG;
+ pOutputData->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
+
+ pH264Enc->hMFCH264Handle.bConfiguredMFC = OMX_TRUE;
+
+ ret = OMX_ErrorInputDataEncodeYet;
+ goto EXIT;
+ }
+
+ if ((pInputData->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) &&
+ (pSECComponent->bUseFlagEOF == OMX_FALSE))
+ pSECComponent->bUseFlagEOF = OMX_TRUE;
+
+ if (oneFrameSize <= 0) {
+ pOutputData->timeStamp = pInputData->timeStamp;
+ pOutputData->nFlags = pInputData->nFlags;
+
+ ret = OMX_ErrorNone;
+ goto EXIT;
+ }
+
+ pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ if (((pInputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) ||
+ (pSECComponent->getAllDelayBuffer == OMX_TRUE)){
+ /* Dummy input data for get out encoded last frame */
+ pInputInfo->YPhyAddr = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].YPhyAddr;
+ pInputInfo->CPhyAddr = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].CPhyAddr;
+ pInputInfo->YVirAddr = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].YVirAddr;
+ pInputInfo->CVirAddr = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].CVirAddr;
+ } else {
+ switch (pSECPort->portDefinition.format.video.eColorFormat) {
+ case OMX_SEC_COLOR_FormatNV12TPhysicalAddress:
+ case OMX_SEC_COLOR_FormatNV12LPhysicalAddress: {
+#ifndef USE_METADATABUFFERTYPE
+ /* USE_FIMC_FRAME_BUFFER */
+ SEC_OSAL_Memcpy(&addrInfo.pAddrY, pInputData->dataBuffer, sizeof(addrInfo.pAddrY));
+ SEC_OSAL_Memcpy(&addrInfo.pAddrC, pInputData->dataBuffer + sizeof(addrInfo.pAddrY), sizeof(addrInfo.pAddrC));
+#else
+ OMX_PTR ppBuf[3];
+ SEC_OSAL_GetInfoFromMetaData(pInputData, ppBuf);
+
+ SEC_OSAL_Memcpy(&addrInfo.pAddrY, ppBuf[0], sizeof(addrInfo.pAddrY));
+ SEC_OSAL_Memcpy(&addrInfo.pAddrC, ppBuf[1], sizeof(addrInfo.pAddrC));
+#endif
+ pInputInfo->YPhyAddr = addrInfo.pAddrY;
+ pInputInfo->CPhyAddr = addrInfo.pAddrC;
+ break;
+ }
+ case OMX_SEC_COLOR_FormatNV12LVirtualAddress:
+ addrInfo.pAddrY = *((void **)pInputData->dataBuffer);
+ addrInfo.pAddrC = (void *)((char *)addrInfo.pAddrY + pInputInfo->YSize);
+
+ pInputInfo->YPhyAddr = addrInfo.pAddrY;
+ pInputInfo->CPhyAddr = addrInfo.pAddrC;
+ break;
+ default:
+ pInputInfo->YPhyAddr = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].YPhyAddr;
+ pInputInfo->CPhyAddr = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].CPhyAddr;
+ pInputInfo->YVirAddr = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].YVirAddr;
+ pInputInfo->CVirAddr = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].CVirAddr;
+ break;
+ }
+ }
+
+ pSECComponent->timeStamp[pH264Enc->hMFCH264Handle.indexTimestamp] = pInputData->timeStamp;
+ pSECComponent->nFlags[pH264Enc->hMFCH264Handle.indexTimestamp] = pInputData->nFlags;
+
+ if ((pH264Enc->hMFCH264Handle.returnCodec == MFC_RET_OK) &&
+ (pVideoEnc->bFirstFrame == OMX_FALSE)) {
+ OMX_S32 indexTimestamp = 0;
+
+ /* wait for mfc encode done */
+ if (pVideoEnc->NBEncThread.bEncoderRun != OMX_FALSE) {
+ SEC_OSAL_SemaphoreWait(pVideoEnc->NBEncThread.hEncFrameEnd);
+ pVideoEnc->NBEncThread.bEncoderRun = OMX_FALSE;
+ }
+
+ SEC_OSAL_SleepMillisec(0);
+ pH264Enc->hMFCH264Handle.returnCodec = SsbSipMfcEncGetOutBuf(pH264Enc->hMFCH264Handle.hMFCHandle, &outputInfo);
+ if ((SsbSipMfcEncGetConfig(pH264Enc->hMFCH264Handle.hMFCHandle, MFC_ENC_GETCONF_FRAME_TAG, &indexTimestamp) != MFC_RET_OK) ||
+ (((indexTimestamp < 0) || (indexTimestamp >= MAX_TIMESTAMP)))){
+ pOutputData->timeStamp = pInputData->timeStamp;
+ pOutputData->nFlags = pInputData->nFlags;
+ } else {
+ pOutputData->timeStamp = pSECComponent->timeStamp[indexTimestamp];
+ pOutputData->nFlags = pSECComponent->nFlags[indexTimestamp];
+ }
+
+ if (pH264Enc->hMFCH264Handle.returnCodec == MFC_RET_OK) {
+ /** Fill Output Buffer **/
+ pOutputData->dataBuffer = outputInfo.StrmVirAddr;
+ pOutputData->allocSize = outputInfo.dataSize;
+ pOutputData->dataLen = outputInfo.dataSize;
+ pOutputData->usedDataLen = 0;
+
+ pOutputData->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
+ if (outputInfo.frameType == MFC_FRAME_TYPE_I_FRAME)
+ pOutputData->nFlags |= OMX_BUFFERFLAG_SYNCFRAME;
+
+ SEC_OSAL_Log(SEC_LOG_TRACE, "MFC Encode OK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
+
+ ret = OMX_ErrorNone;
+ } else {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "%s: SsbSipMfcEncGetOutBuf failed, ret:%d", __FUNCTION__, pH264Enc->hMFCH264Handle.returnCodec);
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+
+ if (pSECComponent->getAllDelayBuffer == OMX_TRUE) {
+ ret = OMX_ErrorInputDataEncodeYet;
+ }
+ if ((pInputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) {
+ pInputData->nFlags = (pOutputData->nFlags & (~OMX_BUFFERFLAG_EOS));
+ pSECComponent->getAllDelayBuffer = OMX_TRUE;
+ ret = OMX_ErrorInputDataEncodeYet;
+ }
+ if ((pOutputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) {
+ pSECComponent->getAllDelayBuffer = OMX_FALSE;
+ pOutputData->dataLen = 0;
+ pOutputData->usedDataLen = 0;
+ SEC_OSAL_Log(SEC_LOG_TRACE, "OMX_BUFFERFLAG_EOS!!!");
+ ret = OMX_ErrorNone;
+ }
+ }
+ if (pH264Enc->hMFCH264Handle.returnCodec != MFC_RET_OK) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "In %s : SsbSipMfcEncExe Failed!!!\n", __func__);
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+
+ pH264Enc->hMFCH264Handle.returnCodec = SsbSipMfcEncSetInBuf(pH264Enc->hMFCH264Handle.hMFCHandle, pInputInfo);
+ if (pH264Enc->hMFCH264Handle.returnCodec != MFC_RET_OK) {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "Error : SsbSipMfcEncSetInBuf() \n");
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ } else {
+ pVideoEnc->indexInputBuffer++;
+ pVideoEnc->indexInputBuffer %= MFC_INPUT_BUFFER_NUM_MAX;
+ }
+
+ if (pVideoEnc->configChange == OMX_TRUE) {
+ Change_H264Enc_Param(&(pH264Enc->hMFCH264Handle.mfcVideoAvc), pSECComponent);
+ pVideoEnc->configChange = OMX_FALSE;
+ }
+
+ SsbSipMfcEncSetConfig(pH264Enc->hMFCH264Handle.hMFCHandle, MFC_ENC_SETCONF_FRAME_TAG, &(pH264Enc->hMFCH264Handle.indexTimestamp));
+
+ /* mfc encode start */
+ SEC_OSAL_SemaphorePost(pVideoEnc->NBEncThread.hEncFrameStart);
+ pVideoEnc->NBEncThread.bEncoderRun = OMX_TRUE;
+ pH264Enc->hMFCH264Handle.indexTimestamp++;
+ pH264Enc->hMFCH264Handle.indexTimestamp %= MAX_TIMESTAMP;
+ pVideoEnc->bFirstFrame = OMX_FALSE;
+ SEC_OSAL_SleepMillisec(0);
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_H264_Encode_Block(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_OMX_VIDEOENC_COMPONENT *pVideoEnc = ((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle);
+ SEC_H264ENC_HANDLE *pH264Enc = (SEC_H264ENC_HANDLE *)((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ SSBSIP_MFC_ENC_INPUT_INFO *pInputInfo = &pH264Enc->hMFCH264Handle.inputInfo;
+ SSBSIP_MFC_ENC_OUTPUT_INFO outputInfo;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+ MFC_ENC_ADDR_INFO addrInfo;
+ OMX_U32 oneFrameSize = pInputData->dataLen;
+ OMX_S32 returnCodec = 0;
+
+ FunctionIn();
+
+ if (pH264Enc->hMFCH264Handle.bConfiguredMFC == OMX_FALSE) {
+ returnCodec = SsbSipMfcEncGetOutBuf(pH264Enc->hMFCH264Handle.hMFCHandle, &outputInfo);
+ if (returnCodec != MFC_RET_OK)
+ {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "%s - SsbSipMfcEncGetOutBuf Failed\n", __func__);
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ } else {
+ OMX_U8 *p = NULL;
+ int iSpsSize = 0;
+ int iPpsSize = 0;
+
+ p = FindDelimiter((OMX_U8 *)outputInfo.StrmVirAddr + 4, outputInfo.headerSize - 4);
+
+ iSpsSize = (unsigned int)p - (unsigned int)outputInfo.StrmVirAddr;
+ pH264Enc->hMFCH264Handle.headerData.pHeaderSPS = (OMX_PTR)outputInfo.StrmVirAddr;
+ pH264Enc->hMFCH264Handle.headerData.SPSLen = iSpsSize;
+
+ iPpsSize = outputInfo.headerSize - iSpsSize;
+ pH264Enc->hMFCH264Handle.headerData.pHeaderPPS = (OMX_U8 *)outputInfo.StrmVirAddr + iSpsSize;
+ pH264Enc->hMFCH264Handle.headerData.PPSLen = iPpsSize;
+ }
+
+ pOutputData->dataBuffer = outputInfo.StrmVirAddr;
+ pOutputData->allocSize = outputInfo.headerSize;
+ pOutputData->dataLen = outputInfo.headerSize;
+ pOutputData->timeStamp = 0;
+ pOutputData->nFlags |= OMX_BUFFERFLAG_CODECCONFIG;
+ pOutputData->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
+
+ pH264Enc->hMFCH264Handle.bConfiguredMFC = OMX_TRUE;
+
+ ret = OMX_ErrorInputDataEncodeYet;
+ goto EXIT;
+ }
+
+ if ((pInputData->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) &&
+ (pSECComponent->bUseFlagEOF == OMX_FALSE))
+ pSECComponent->bUseFlagEOF = OMX_TRUE;
+
+ if (oneFrameSize <= 0) {
+ pOutputData->timeStamp = pInputData->timeStamp;
+ pOutputData->nFlags = pInputData->nFlags;
+
+ ret = OMX_ErrorNone;
+ goto EXIT;
+ }
+
+ pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ switch (pSECPort->portDefinition.format.video.eColorFormat) {
+ case OMX_SEC_COLOR_FormatNV12TPhysicalAddress:
+ case OMX_SEC_COLOR_FormatNV12LPhysicalAddress: {
+#ifndef USE_METADATABUFFERTYPE
+ /* USE_FIMC_FRAME_BUFFER */
+ SEC_OSAL_Memcpy(&addrInfo.pAddrY, pInputData->dataBuffer, sizeof(addrInfo.pAddrY));
+ SEC_OSAL_Memcpy(&addrInfo.pAddrC, pInputData->dataBuffer + sizeof(addrInfo.pAddrY), sizeof(addrInfo.pAddrC));
+#else
+ OMX_PTR ppBuf[3];
+ SEC_OSAL_GetInfoFromMetaData(pInputData, ppBuf);
+
+ SEC_OSAL_Memcpy(&addrInfo.pAddrY, ppBuf[0], sizeof(addrInfo.pAddrY));
+ SEC_OSAL_Memcpy(&addrInfo.pAddrC, ppBuf[1], sizeof(addrInfo.pAddrC));
+#endif
+ pInputInfo->YPhyAddr = addrInfo.pAddrY;
+ pInputInfo->CPhyAddr = addrInfo.pAddrC;
+ break;
+ }
+ case OMX_SEC_COLOR_FormatNV12LVirtualAddress:
+ addrInfo.pAddrY = *((void **)pInputData->dataBuffer);
+ addrInfo.pAddrC = (void *)((char *)addrInfo.pAddrY + pInputInfo->YSize);
+
+ pInputInfo->YPhyAddr = addrInfo.pAddrY;
+ pInputInfo->CPhyAddr = addrInfo.pAddrC;
+ break;
+ default:
+ pInputInfo->YPhyAddr = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].YPhyAddr;
+ pInputInfo->CPhyAddr = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].CPhyAddr;
+ pInputInfo->YVirAddr = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].YVirAddr;
+ pInputInfo->CVirAddr = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].CVirAddr;
+ break;
+ }
+
+ returnCodec = SsbSipMfcEncSetInBuf(pH264Enc->hMFCH264Handle.hMFCHandle, pInputInfo);
+ if (returnCodec != MFC_RET_OK) {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "Error : SsbSipMfcEncSetInBuf() \n");
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ } else {
+ pVideoEnc->indexInputBuffer++;
+ pVideoEnc->indexInputBuffer %= MFC_INPUT_BUFFER_NUM_MAX;
+ }
+
+ if (pVideoEnc->configChange == OMX_TRUE) {
+ Change_H264Enc_Param(&(pH264Enc->hMFCH264Handle.mfcVideoAvc), pSECComponent);
+ pVideoEnc->configChange = OMX_FALSE;
+ }
+
+ pSECComponent->timeStamp[pH264Enc->hMFCH264Handle.indexTimestamp] = pInputData->timeStamp;
+ pSECComponent->nFlags[pH264Enc->hMFCH264Handle.indexTimestamp] = pInputData->nFlags;
+ SsbSipMfcEncSetConfig(pH264Enc->hMFCH264Handle.hMFCHandle, MFC_ENC_SETCONF_FRAME_TAG, &(pH264Enc->hMFCH264Handle.indexTimestamp));
+
+ returnCodec = SsbSipMfcEncExe(pH264Enc->hMFCH264Handle.hMFCHandle);
+ if (returnCodec == MFC_RET_OK) {
+ OMX_S32 indexTimestamp = 0;
+
+ pH264Enc->hMFCH264Handle.indexTimestamp++;
+ pH264Enc->hMFCH264Handle.indexTimestamp %= MAX_TIMESTAMP;
+
+ returnCodec = SsbSipMfcEncGetOutBuf(pH264Enc->hMFCH264Handle.hMFCHandle, &outputInfo);
+ if ((SsbSipMfcEncGetConfig(pH264Enc->hMFCH264Handle.hMFCHandle, MFC_ENC_GETCONF_FRAME_TAG, &indexTimestamp) != MFC_RET_OK) ||
+ (((indexTimestamp < 0) || (indexTimestamp >= MAX_TIMESTAMP)))){
+ pOutputData->timeStamp = pInputData->timeStamp;
+ pOutputData->nFlags = pInputData->nFlags;
+ } else {
+ pOutputData->timeStamp = pSECComponent->timeStamp[indexTimestamp];
+ pOutputData->nFlags = pSECComponent->nFlags[indexTimestamp];
+ }
+
+ if (returnCodec == MFC_RET_OK) {
+ /** Fill Output Buffer **/
+ pOutputData->dataBuffer = outputInfo.StrmVirAddr;
+ pOutputData->allocSize = outputInfo.dataSize;
+ pOutputData->dataLen = outputInfo.dataSize;
+ pOutputData->usedDataLen = 0;
+
+ pOutputData->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
+ if (outputInfo.frameType == MFC_FRAME_TYPE_I_FRAME)
+ pOutputData->nFlags |= OMX_BUFFERFLAG_SYNCFRAME;
+
+ SEC_OSAL_Log(SEC_LOG_TRACE, "MFC Encode OK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
+
+ ret = OMX_ErrorNone;
+ }
+ }
+
+ if (returnCodec != MFC_RET_OK) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "In %s : SsbSipMfcEncExe OR SsbSipMfcEncGetOutBuf Failed!!!\n", __func__);
+ ret = OMX_ErrorUndefined;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+/* MFC Encode */
+OMX_ERRORTYPE SEC_MFC_H264Enc_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_H264ENC_HANDLE *pH264Enc = (SEC_H264ENC_HANDLE *)((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ SEC_OMX_BASEPORT *pSECInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ SEC_OMX_BASEPORT *pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+ OMX_BOOL endOfFrame = OMX_FALSE;
+ OMX_BOOL flagEOS = 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;
+ }
+
+#ifdef NONBLOCK_MODE_PROCESS
+ ret = SEC_MFC_H264_Encode_Nonblock(pOMXComponent, pInputData, pOutputData);
+#else
+ ret = SEC_MFC_H264_Encode_Block(pOMXComponent, pInputData, pOutputData);
+#endif
+ if (ret != OMX_ErrorNone) {
+ if (ret == OMX_ErrorInputDataEncodeYet) {
+ pOutputData->usedDataLen = 0;
+ pOutputData->remainDataLen = pOutputData->dataLen;
+ } else {
+ pSECComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent,
+ pSECComponent->callbackData,
+ OMX_EventError, ret, 0, NULL);
+ }
+ } else {
+ pInputData->usedDataLen += pInputData->dataLen;
+ pInputData->remainDataLen = pInputData->dataLen - pInputData->usedDataLen;
+ pInputData->dataLen -= pInputData->usedDataLen;
+ pInputData->usedDataLen = 0;
+
+ /* pOutputData->usedDataLen = 0; */
+ pOutputData->remainDataLen = pOutputData->dataLen - pOutputData->usedDataLen;
+ }
+
+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_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
+ SEC_H264ENC_HANDLE *pH264Enc = 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_ENC, 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_VideoEncodeComponentInit(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_ENC_CODEC;
+
+ pSECComponent->componentName = (OMX_STRING)SEC_OSAL_Malloc(MAX_OMX_COMPONENT_NAME_SIZE);
+ if (pSECComponent->componentName == NULL) {
+ SEC_OMX_VideoEncodeComponentDeinit(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);
+
+ pH264Enc = SEC_OSAL_Malloc(sizeof(SEC_H264ENC_HANDLE));
+ if (pH264Enc == NULL) {
+ SEC_OMX_VideoEncodeComponentDeinit(pOMXComponent);
+ ret = OMX_ErrorInsufficientResources;
+ SEC_OSAL_Log(SEC_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__);
+ goto EXIT;
+ }
+ SEC_OSAL_Memset(pH264Enc, 0, sizeof(SEC_H264ENC_HANDLE));
+ pVideoEnc = (SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle;
+ pVideoEnc->hCodecHandle = (OMX_HANDLETYPE)pH264Enc;
+
+ SEC_OSAL_Strcpy(pSECComponent->componentName, SEC_OMX_COMPONENT_H264_ENC);
+ /* 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.nBufferSize = DEFAULT_VIDEO_INPUT_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.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
+ 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.nBufferSize = DEFAULT_VIDEO_OUTPUT_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.eColorFormat = OMX_COLOR_FormatUnused;
+ pSECPort->portDefinition.bEnabled = OMX_TRUE;
+
+ for(i = 0; i < ALL_PORT_NUM; i++) {
+ INIT_SET_SIZE_VERSION(&pH264Enc->AVCComponent[i], OMX_VIDEO_PARAM_AVCTYPE);
+ pH264Enc->AVCComponent[i].nPortIndex = i;
+ pH264Enc->AVCComponent[i].eProfile = OMX_VIDEO_AVCProfileBaseline;
+ pH264Enc->AVCComponent[i].eLevel = OMX_VIDEO_AVCLevel31;
+
+ pH264Enc->AVCComponent[i].nPFrames = 20;
+ }
+
+ pOMXComponent->GetParameter = &SEC_MFC_H264Enc_GetParameter;
+ pOMXComponent->SetParameter = &SEC_MFC_H264Enc_SetParameter;
+ pOMXComponent->GetConfig = &SEC_MFC_H264Enc_GetConfig;
+ pOMXComponent->SetConfig = &SEC_MFC_H264Enc_SetConfig;
+ pOMXComponent->GetExtensionIndex = &SEC_MFC_H264Enc_GetExtensionIndex;
+ pOMXComponent->ComponentRoleEnum = &SEC_MFC_H264Enc_ComponentRoleEnum;
+ pOMXComponent->ComponentDeInit = &SEC_OMX_ComponentDeinit;
+
+ pSECComponent->sec_mfc_componentInit = &SEC_MFC_H264Enc_Init;
+ pSECComponent->sec_mfc_componentTerminate = &SEC_MFC_H264Enc_Terminate;
+ pSECComponent->sec_mfc_bufferProcess = &SEC_MFC_H264Enc_bufferProcess;
+ pSECComponent->sec_checkInputFrame = NULL;
+
+ 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_H264ENC_HANDLE *pH264Enc = 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;
+
+ pH264Enc = (SEC_H264ENC_HANDLE *)((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ if (pH264Enc != NULL) {
+ SEC_OSAL_Free(pH264Enc);
+ pH264Enc = ((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle = NULL;
+ }
+
+ ret = SEC_OMX_VideoEncodeComponentDeinit(pOMXComponent);
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ ret = OMX_ErrorNone;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
diff --git a/exynos/multimedia/openmax/component/video/enc/h264/SEC_OMX_H264enc.h b/exynos/multimedia/openmax/component/video/enc/h264/SEC_OMX_H264enc.h
new file mode 100644
index 0000000..cc0a94f
--- /dev/null
+++ b/exynos/multimedia/openmax/component/video/enc/h264/SEC_OMX_H264enc.h
@@ -0,0 +1,77 @@
+/*
+ *
+ * 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_H264enc.h
+ * @brief
+ * @author SeungBeom Kim (sbcrux.kim@samsung.com)
+ * @version 1.1.0
+ * @history
+ * 2010.7.15 : Create
+ */
+
+#ifndef SEC_OMX_H264_ENC_COMPONENT
+#define SEC_OMX_H264_ENC_COMPONENT
+
+#include "SEC_OMX_Def.h"
+#include "OMX_Component.h"
+#include "OMX_Video.h"
+#include "SsbSipMfcApi.h"
+
+
+typedef struct _EXTRA_DATA
+{
+ OMX_PTR pHeaderSPS;
+ OMX_U32 SPSLen;
+ OMX_PTR pHeaderPPS;
+ OMX_U32 PPSLen;
+} EXTRA_DATA;
+
+typedef struct _SEC_MFC_H264ENC_HANDLE
+{
+ OMX_HANDLETYPE hMFCHandle;
+ SSBSIP_MFC_ENC_H264_PARAM mfcVideoAvc;
+ SSBSIP_MFC_ENC_INPUT_INFO inputInfo;
+/* SSBSIP_MFC_ENC_OUTPUT_INFO outputInfo; */
+ OMX_U32 indexTimestamp;
+ OMX_BOOL bConfiguredMFC;
+ EXTRA_DATA headerData;
+ OMX_S32 returnCodec;
+} SEC_MFC_H264ENC_HANDLE;
+
+typedef struct _SEC_H264ENC_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_H264ENC_HANDLE hMFCH264Handle;
+} SEC_H264ENC_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/exynos/multimedia/openmax/component/video/enc/h264/library_register.c b/exynos/multimedia/openmax/component/video/enc/h264/library_register.c
new file mode 100644
index 0000000..e24e126
--- /dev/null
+++ b/exynos/multimedia/openmax/component/video/enc/h264/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.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_ENC);
+ SEC_OSAL_Strcpy(secComponents[0]->roles[0], SEC_OMX_COMPONENT_H264_ENC_ROLE);
+ secComponents[0]->totalRoleNum = MAX_COMPONENT_ROLE_NUM;
+
+EXIT:
+ FunctionOut();
+
+ return MAX_COMPONENT_NUM;
+}
+
diff --git a/exynos/multimedia/openmax/component/video/enc/h264/library_register.h b/exynos/multimedia/openmax/component/video/enc/h264/library_register.h
new file mode 100644
index 0000000..9511e3c
--- /dev/null
+++ b/exynos/multimedia/openmax/component/video/enc/h264/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.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_ENC "OMX.SEC.AVC.Encoder"
+#define SEC_OMX_COMPONENT_H264_ENC_ROLE "video_encoder.avc"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+OSCL_EXPORT_REF int SEC_OMX_COMPONENT_Library_Register(SECRegisterComponentType **secComponents);
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif
+
diff --git a/exynos/multimedia/openmax/component/video/enc/mpeg4/Android.mk b/exynos/multimedia/openmax/component/video/enc/mpeg4/Android.mk
new file mode 100644
index 0000000..ad6a604
--- /dev/null
+++ b/exynos/multimedia/openmax/component/video/enc/mpeg4/Android.mk
@@ -0,0 +1,39 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := \
+ SEC_OMX_Mpeg4enc.c \
+ library_register.c
+
+LOCAL_PRELINK_MODULE := false
+LOCAL_MODULE := libOMX.SEC.M4V.Encoder
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/omx
+
+LOCAL_CFLAGS :=
+
+ifeq ($(BOARD_NONBLOCK_MODE_PROCESS), true)
+LOCAL_CFLAGS += -DNONBLOCK_MODE_PROCESS
+endif
+
+ifeq ($(BOARD_USE_METADATABUFFERTYPE), true)
+LOCAL_CFLAGS += -DUSE_METADATABUFFERTYPE
+endif
+
+LOCAL_ARM_MODE := arm
+
+LOCAL_STATIC_LIBRARIES := libSEC_OMX_Venc libsecosal libsecbasecomponent \
+ libseccscapi libsecmfcapi
+LOCAL_SHARED_LIBRARIES := libc libdl libcutils libutils libui \
+ libSEC_OMX_Resourcemanager
+
+LOCAL_C_INCLUDES := $(SEC_OMX_INC)/khronos \
+ $(SEC_OMX_INC)/sec \
+ $(SEC_OMX_TOP)/osal \
+ $(SEC_OMX_TOP)/core \
+ $(SEC_OMX_COMPONENT)/common \
+ $(SEC_OMX_COMPONENT)/video/enc \
+ $(TARGET_OUT_HEADERS)/$(SEC_COPY_HEADERS_TO)
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/exynos/multimedia/openmax/component/video/enc/mpeg4/SEC_OMX_Mpeg4enc.c b/exynos/multimedia/openmax/component/video/enc/mpeg4/SEC_OMX_Mpeg4enc.c
new file mode 100644
index 0000000..ebfbe6e
--- /dev/null
+++ b/exynos/multimedia/openmax/component/video/enc/mpeg4/SEC_OMX_Mpeg4enc.c
@@ -0,0 +1,1774 @@
+/*
+ *
+ * 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_Mpeg4enc.c
+ * @brief
+ * @author Yunji Kim (yunji.kim@samsung.com)
+ * @version 1.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_Venc.h"
+#include "SEC_OSAL_Semaphore.h"
+#include "SEC_OSAL_Thread.h"
+#include "SEC_OSAL_ETC.h"
+#include "SEC_OSAL_Android.h"
+#include "library_register.h"
+#include "SEC_OMX_Mpeg4enc.h"
+#include "SsbSipMfcApi.h"
+#include "color_space_convertor.h"
+
+#undef SEC_LOG_TAG
+#define SEC_LOG_TAG "SEC_MPEG4_ENC"
+#define SEC_LOG_OFF
+#include "SEC_OSAL_Log.h"
+
+
+/* MPEG4 Encoder 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 Encoder Supported Levels & profiles */
+SEC_OMX_VIDEO_PROFILELEVEL supportedH263ProfileLevels[] = {
+ {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}};
+
+OMX_U32 OMXMpeg4ProfileToMFCProfile(OMX_VIDEO_MPEG4PROFILETYPE profile)
+{
+ OMX_U32 ret;
+
+ switch (profile) {
+ case OMX_VIDEO_MPEG4ProfileSimple:
+ ret = 0;
+ break;
+ case OMX_VIDEO_MPEG4ProfileAdvancedSimple:
+ ret = 1;
+ break;
+ default:
+ ret = 0;
+ };
+
+ return ret;
+}
+OMX_U32 OMXMpeg4LevelToMFCLevel(OMX_VIDEO_MPEG4LEVELTYPE level)
+{
+ OMX_U32 ret;
+
+ switch (level) {
+ case OMX_VIDEO_MPEG4Level0:
+ ret = 0;
+ break;
+ case OMX_VIDEO_MPEG4Level0b:
+ ret = 9;
+ break;
+ case OMX_VIDEO_MPEG4Level1:
+ ret = 1;
+ break;
+ case OMX_VIDEO_MPEG4Level2:
+ ret = 2;
+ break;
+ case OMX_VIDEO_MPEG4Level3:
+ ret = 3;
+ break;
+ case OMX_VIDEO_MPEG4Level4:
+ case OMX_VIDEO_MPEG4Level4a:
+ ret = 4;
+ break;
+ case OMX_VIDEO_MPEG4Level5:
+ ret = 5;
+ break;
+ default:
+ ret = 0;
+ };
+
+ return ret;
+}
+
+void Mpeg4PrintParams(SSBSIP_MFC_ENC_MPEG4_PARAM *pMpeg4Param)
+{
+ SEC_OSAL_Log(SEC_LOG_TRACE, "SourceWidth : %d\n", pMpeg4Param->SourceWidth);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "SourceHeight : %d\n", pMpeg4Param->SourceHeight);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "IDRPeriod : %d\n", pMpeg4Param->IDRPeriod);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "SliceMode : %d\n", pMpeg4Param->SliceMode);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "RandomIntraMBRefresh : %d\n", pMpeg4Param->RandomIntraMBRefresh);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "EnableFRMRateControl : %d\n", pMpeg4Param->EnableFRMRateControl);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "Bitrate : %d\n", pMpeg4Param->Bitrate);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "FrameQp : %d\n", pMpeg4Param->FrameQp);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "FrameQp_P : %d\n", pMpeg4Param->FrameQp_P);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "QSCodeMax : %d\n", pMpeg4Param->QSCodeMax);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "QSCodeMin : %d\n", pMpeg4Param->QSCodeMin);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "CBRPeriodRf : %d\n", pMpeg4Param->CBRPeriodRf);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "PadControlOn : %d\n", pMpeg4Param->PadControlOn);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "LumaPadVal : %d\n", pMpeg4Param->LumaPadVal);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "CbPadVal : %d\n", pMpeg4Param->CbPadVal);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "CrPadVal : %d\n", pMpeg4Param->CrPadVal);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "FrameMap : %d\n", pMpeg4Param->FrameMap);
+
+ /* MPEG4 specific parameters */
+ SEC_OSAL_Log(SEC_LOG_TRACE, "ProfileIDC : %d\n", pMpeg4Param->ProfileIDC);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "LevelIDC : %d\n", pMpeg4Param->LevelIDC);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "FrameQp_B : %d\n", pMpeg4Param->FrameQp_B);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "TimeIncreamentRes : %d\n", pMpeg4Param->TimeIncreamentRes);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "VopTimeIncreament : %d\n", pMpeg4Param->VopTimeIncreament);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "SliceArgument : %d\n", pMpeg4Param->SliceArgument);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "NumberBFrames : %d\n", pMpeg4Param->NumberBFrames);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "DisableQpelME : %d\n", pMpeg4Param->DisableQpelME);
+}
+
+void H263PrintParams(SSBSIP_MFC_ENC_H263_PARAM *pH263Param)
+{
+ SEC_OSAL_Log(SEC_LOG_TRACE, "SourceWidth : %d\n", pH263Param->SourceWidth);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "SourceHeight : %d\n", pH263Param->SourceHeight);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "IDRPeriod : %d\n", pH263Param->IDRPeriod);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "SliceMode : %d\n", pH263Param->SliceMode);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "RandomIntraMBRefresh : %d\n", pH263Param->RandomIntraMBRefresh);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "EnableFRMRateControl : %d\n", pH263Param->EnableFRMRateControl);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "Bitrate : %d\n", pH263Param->Bitrate);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "FrameQp : %d\n", pH263Param->FrameQp);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "FrameQp_P : %d\n", pH263Param->FrameQp_P);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "QSCodeMax : %d\n", pH263Param->QSCodeMax);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "QSCodeMin : %d\n", pH263Param->QSCodeMin);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "CBRPeriodRf : %d\n", pH263Param->CBRPeriodRf);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "PadControlOn : %d\n", pH263Param->PadControlOn);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "LumaPadVal : %d\n", pH263Param->LumaPadVal);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "CbPadVal : %d\n", pH263Param->CbPadVal);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "CrPadVal : %d\n", pH263Param->CrPadVal);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "FrameMap : %d\n", pH263Param->FrameMap);
+
+ /* H.263 specific parameters */
+ SEC_OSAL_Log(SEC_LOG_TRACE, "FrameRate : %d\n", pH263Param->FrameRate);
+}
+
+void Set_Mpeg4Enc_Param(SSBSIP_MFC_ENC_MPEG4_PARAM *pMpeg4Param, SEC_OMX_BASECOMPONENT *pSECComponent)
+{
+ SEC_OMX_BASEPORT *pSECInputPort = NULL;
+ SEC_OMX_BASEPORT *pSECOutputPort = NULL;
+ SEC_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
+ SEC_MPEG4ENC_HANDLE *pMpeg4Enc = NULL;
+
+ pVideoEnc = (SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle;
+ pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ pSECInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+
+ pMpeg4Param->codecType = MPEG4_ENC;
+ pMpeg4Param->SourceWidth = pSECOutputPort->portDefinition.format.video.nFrameWidth;
+ pMpeg4Param->SourceHeight = pSECOutputPort->portDefinition.format.video.nFrameHeight;
+ pMpeg4Param->IDRPeriod = pMpeg4Enc->mpeg4Component[OUTPUT_PORT_INDEX].nPFrames + 1;
+ pMpeg4Param->SliceMode = 0;
+ pMpeg4Param->RandomIntraMBRefresh = 0;
+ pMpeg4Param->Bitrate = pSECOutputPort->portDefinition.format.video.nBitrate;
+ pMpeg4Param->QSCodeMax = 30;
+ pMpeg4Param->QSCodeMin = 10;
+ pMpeg4Param->PadControlOn = 0; /* 0: Use boundary pixel, 1: Use the below setting value */
+ pMpeg4Param->LumaPadVal = 0;
+ pMpeg4Param->CbPadVal = 0;
+ pMpeg4Param->CrPadVal = 0;
+
+ pMpeg4Param->ProfileIDC = OMXMpeg4ProfileToMFCProfile(pMpeg4Enc->mpeg4Component[OUTPUT_PORT_INDEX].eProfile);
+ pMpeg4Param->LevelIDC = OMXMpeg4LevelToMFCLevel(pMpeg4Enc->mpeg4Component[OUTPUT_PORT_INDEX].eLevel);
+ pMpeg4Param->TimeIncreamentRes = (pSECInputPort->portDefinition.format.video.xFramerate) >> 16;
+ pMpeg4Param->VopTimeIncreament = 1;
+ pMpeg4Param->SliceArgument = 0; /* MB number or byte number */
+ pMpeg4Param->NumberBFrames = 0; /* 0(not used) ~ 2 */
+ pMpeg4Param->DisableQpelME = 1;
+
+ pMpeg4Param->FrameQp = pVideoEnc->quantization.nQpI;
+ pMpeg4Param->FrameQp_P = pVideoEnc->quantization.nQpP;
+ pMpeg4Param->FrameQp_B = pVideoEnc->quantization.nQpB;
+
+ SEC_OSAL_Log(SEC_LOG_TRACE, "pVideoEnc->eControlRate[OUTPUT_PORT_INDEX]: 0x%x", pVideoEnc->eControlRate[OUTPUT_PORT_INDEX]);
+ switch (pVideoEnc->eControlRate[OUTPUT_PORT_INDEX]) {
+ case OMX_Video_ControlRateVariable:
+ SEC_OSAL_Log(SEC_LOG_TRACE, "Video Encode VBR");
+ pMpeg4Param->EnableFRMRateControl = 0; // 0: Disable, 1: Frame level RC
+ pMpeg4Param->CBRPeriodRf = 100;
+ break;
+ case OMX_Video_ControlRateConstant:
+ SEC_OSAL_Log(SEC_LOG_TRACE, "Video Encode CBR");
+ pMpeg4Param->EnableFRMRateControl = 1; // 0: Disable, 1: Frame level RC
+ pMpeg4Param->CBRPeriodRf = 10;
+ break;
+ case OMX_Video_ControlRateDisable:
+ default: //Android default
+ SEC_OSAL_Log(SEC_LOG_TRACE, "Video Encode VBR");
+ pMpeg4Param->EnableFRMRateControl = 0;
+ pMpeg4Param->CBRPeriodRf = 100;
+ break;
+ }
+
+ switch ((SEC_OMX_COLOR_FORMATTYPE)pSECInputPort->portDefinition.format.video.eColorFormat) {
+ case OMX_SEC_COLOR_FormatNV12LPhysicalAddress:
+ case OMX_SEC_COLOR_FormatNV12LVirtualAddress:
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ case OMX_COLOR_FormatYUV420Planar:
+#ifdef METADATABUFFERTYPE
+ case OMX_COLOR_FormatAndroidOpaque:
+#endif
+ pMpeg4Param->FrameMap = NV12_LINEAR;
+ break;
+ case OMX_SEC_COLOR_FormatNV12TPhysicalAddress:
+ case OMX_SEC_COLOR_FormatNV12Tiled:
+ default:
+ pMpeg4Param->FrameMap = NV12_TILE;
+ break;
+ }
+
+ Mpeg4PrintParams(pMpeg4Param);
+}
+
+void Change_Mpeg4Enc_Param(SSBSIP_MFC_ENC_MPEG4_PARAM *pMpeg4Param, SEC_OMX_BASECOMPONENT *pSECComponent)
+{
+ SEC_OMX_BASEPORT *pSECInputPort = NULL;
+ SEC_OMX_BASEPORT *pSECOutputPort = NULL;
+ SEC_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
+ SEC_MPEG4ENC_HANDLE *pMpeg4Enc = NULL;
+
+ pVideoEnc = (SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle;
+ pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ pSECInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+
+ if (pVideoEnc->IntraRefreshVOP == OMX_TRUE) {
+ int set_conf_IntraRefreshVOP = 1;
+ SsbSipMfcEncSetConfig(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle,
+ MFC_ENC_SETCONF_FRAME_TYPE,
+ &set_conf_IntraRefreshVOP);
+ pVideoEnc->IntraRefreshVOP = OMX_FALSE;
+ }
+
+ if (pMpeg4Param->IDRPeriod != (int)pMpeg4Enc->mpeg4Component[OUTPUT_PORT_INDEX].nPFrames + 1) {
+ int set_conf_IDRPeriod = pMpeg4Enc->mpeg4Component[OUTPUT_PORT_INDEX].nPFrames + 1;
+ SsbSipMfcEncSetConfig(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle,
+ MFC_ENC_SETCONF_I_PERIOD,
+ &set_conf_IDRPeriod);
+ }
+ if (pMpeg4Param->Bitrate != (int)pSECOutputPort->portDefinition.format.video.nBitrate) {
+ int set_conf_bitrate = pSECOutputPort->portDefinition.format.video.nBitrate;
+ SsbSipMfcEncSetConfig(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle,
+ MFC_ENC_SETCONF_CHANGE_BIT_RATE,
+ &set_conf_bitrate);
+ }
+ if (pMpeg4Param->TimeIncreamentRes != (int)((pSECOutputPort->portDefinition.format.video.xFramerate) >> 16)) {
+ int set_conf_framerate = (pSECInputPort->portDefinition.format.video.xFramerate) >> 16;
+ SsbSipMfcEncSetConfig(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle,
+ MFC_ENC_SETCONF_CHANGE_FRAME_RATE,
+ &set_conf_framerate);
+ }
+
+ Set_Mpeg4Enc_Param(pMpeg4Param, pSECComponent);
+ Mpeg4PrintParams(pMpeg4Param);
+}
+
+void Set_H263Enc_Param(SSBSIP_MFC_ENC_H263_PARAM *pH263Param, SEC_OMX_BASECOMPONENT *pSECComponent)
+{
+ SEC_OMX_BASEPORT *pSECInputPort = NULL;
+ SEC_OMX_BASEPORT *pSECOutputPort = NULL;
+ SEC_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
+ SEC_MPEG4ENC_HANDLE *pMpeg4Enc = NULL;
+
+ pVideoEnc = (SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle;
+ pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ pSECInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+
+ pH263Param->codecType = H263_ENC;
+ pH263Param->SourceWidth = pSECOutputPort->portDefinition.format.video.nFrameWidth;
+ pH263Param->SourceHeight = pSECOutputPort->portDefinition.format.video.nFrameHeight;
+ pH263Param->IDRPeriod = pMpeg4Enc->h263Component[OUTPUT_PORT_INDEX].nPFrames + 1;
+ pH263Param->SliceMode = 0;
+ pH263Param->RandomIntraMBRefresh = 0;
+ pH263Param->Bitrate = pSECOutputPort->portDefinition.format.video.nBitrate;
+ pH263Param->QSCodeMax = 30;
+ pH263Param->QSCodeMin = 10;
+ pH263Param->PadControlOn = 0; /* 0: Use boundary pixel, 1: Use the below setting value */
+ pH263Param->LumaPadVal = 0;
+ pH263Param->CbPadVal = 0;
+ pH263Param->CrPadVal = 0;
+
+ pH263Param->FrameRate = (pSECInputPort->portDefinition.format.video.xFramerate) >> 16;
+
+ pH263Param->FrameQp = pVideoEnc->quantization.nQpI;
+ pH263Param->FrameQp_P = pVideoEnc->quantization.nQpP;
+
+ SEC_OSAL_Log(SEC_LOG_TRACE, "pVideoEnc->eControlRate[OUTPUT_PORT_INDEX]: 0x%x", pVideoEnc->eControlRate[OUTPUT_PORT_INDEX]);
+ switch (pVideoEnc->eControlRate[OUTPUT_PORT_INDEX]) {
+ case OMX_Video_ControlRateVariable:
+ SEC_OSAL_Log(SEC_LOG_TRACE, "Video Encode VBR");
+ pH263Param->EnableFRMRateControl = 0; // 0: Disable, 1: Frame level RC
+ pH263Param->CBRPeriodRf = 100;
+ break;
+ case OMX_Video_ControlRateConstant:
+ SEC_OSAL_Log(SEC_LOG_TRACE, "Video Encode CBR");
+ pH263Param->EnableFRMRateControl = 1; // 0: Disable, 1: Frame level RC
+ pH263Param->CBRPeriodRf = 10;
+ break;
+ case OMX_Video_ControlRateDisable:
+ default: //Android default
+ SEC_OSAL_Log(SEC_LOG_TRACE, "Video Encode VBR");
+ pH263Param->EnableFRMRateControl = 0;
+ pH263Param->CBRPeriodRf = 100;
+ break;
+ }
+
+ switch ((SEC_OMX_COLOR_FORMATTYPE)pSECInputPort->portDefinition.format.video.eColorFormat) {
+ case OMX_SEC_COLOR_FormatNV12LPhysicalAddress:
+ case OMX_SEC_COLOR_FormatNV12LVirtualAddress:
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ pH263Param->FrameMap = NV12_LINEAR;
+ break;
+ case OMX_SEC_COLOR_FormatNV12TPhysicalAddress:
+ case OMX_SEC_COLOR_FormatNV12Tiled:
+ default:
+ pH263Param->FrameMap = NV12_TILE;
+ break;
+ }
+
+ H263PrintParams(pH263Param);
+}
+
+void Change_H263Enc_Param(SSBSIP_MFC_ENC_H263_PARAM *pH263Param, SEC_OMX_BASECOMPONENT *pSECComponent)
+{
+ SEC_OMX_BASEPORT *pSECInputPort = NULL;
+ SEC_OMX_BASEPORT *pSECOutputPort = NULL;
+ SEC_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
+ SEC_MPEG4ENC_HANDLE *pMpeg4Enc = NULL;
+
+ pVideoEnc = (SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle;
+ pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ pSECInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ pSECOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+
+ if (pVideoEnc->IntraRefreshVOP == OMX_TRUE) {
+ int set_conf_IntraRefreshVOP = 1;
+ SsbSipMfcEncSetConfig(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle,
+ MFC_ENC_SETCONF_FRAME_TYPE,
+ &set_conf_IntraRefreshVOP);
+ pVideoEnc->IntraRefreshVOP = OMX_FALSE;
+ }
+ if (pH263Param->IDRPeriod != (int)pMpeg4Enc->h263Component[OUTPUT_PORT_INDEX].nPFrames + 1) {
+ int set_conf_IDRPeriod = pMpeg4Enc->h263Component[OUTPUT_PORT_INDEX].nPFrames + 1;
+ SsbSipMfcEncSetConfig(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle,
+ MFC_ENC_SETCONF_I_PERIOD,
+ &set_conf_IDRPeriod);
+ }
+ if (pH263Param->Bitrate != (int)pSECOutputPort->portDefinition.format.video.nBitrate) {
+ int set_conf_bitrate = pSECOutputPort->portDefinition.format.video.nBitrate;
+ SsbSipMfcEncSetConfig(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle,
+ MFC_ENC_SETCONF_CHANGE_BIT_RATE,
+ &set_conf_bitrate);
+ }
+ if (pH263Param->FrameRate != (int)((pSECOutputPort->portDefinition.format.video.xFramerate) >> 16)) {
+ int set_conf_framerate = (pSECInputPort->portDefinition.format.video.xFramerate) >> 16;
+ SsbSipMfcEncSetConfig(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle,
+ MFC_ENC_SETCONF_CHANGE_FRAME_RATE,
+ &set_conf_framerate);
+ }
+
+ Set_H263Enc_Param(pH263Param, pSECComponent);
+ H263PrintParams(pH263Param);
+}
+
+OMX_ERRORTYPE SEC_MFC_Mpeg4Enc_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_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ switch (nParamIndex) {
+ case OMX_IndexParamVideoMpeg4:
+ {
+ OMX_VIDEO_PARAM_MPEG4TYPE *pDstMpeg4Param = (OMX_VIDEO_PARAM_MPEG4TYPE *)pComponentParameterStructure;
+ OMX_VIDEO_PARAM_MPEG4TYPE *pSrcMpeg4Param = NULL;
+ SEC_MPEG4ENC_HANDLE *pMpeg4Enc = 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;
+ }
+
+ pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ pSrcMpeg4Param = &pMpeg4Enc->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_MPEG4ENC_HANDLE *pMpeg4Enc = 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;
+ }
+
+ pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ pSrcH263Param = &pMpeg4Enc->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_MPEG4ENC_HANDLE *)(((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle))->hMFCMpeg4Handle.codecType;
+ if (codecType == CODEC_TYPE_MPEG4)
+ SEC_OSAL_Strcpy((char *)pComponentRole->cRole, SEC_OMX_COMPONENT_MPEG4_ENC_ROLE);
+ else
+ SEC_OSAL_Strcpy((char *)pComponentRole->cRole, SEC_OMX_COMPONENT_H263_ENC_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_MPEG4ENC_HANDLE *)(((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->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_MPEG4ENC_HANDLE *pMpeg4Enc = 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;
+ }
+
+ pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ codecType = pMpeg4Enc->hMFCMpeg4Handle.codecType;
+ if (codecType == CODEC_TYPE_MPEG4) {
+ pSrcMpeg4Param = &pMpeg4Enc->mpeg4Component[pDstProfileLevel->nPortIndex];
+ pDstProfileLevel->eProfile = pSrcMpeg4Param->eProfile;
+ pDstProfileLevel->eLevel = pSrcMpeg4Param->eLevel;
+ } else {
+ pSrcH263Param = &pMpeg4Enc->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_MPEG4ENC_HANDLE *pMpeg4Enc = NULL;
+
+ ret = SEC_OMX_Check_SizeVersion(pDstErrorCorrectionType, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pDstErrorCorrectionType->nPortIndex != OUTPUT_PORT_INDEX) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ pSrcErrorCorrectionType = &pMpeg4Enc->errorCorrectionType[OUTPUT_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_VideoEncodeGetParameter(hComponent, nParamIndex, pComponentParameterStructure);
+ break;
+ }
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_Mpeg4Enc_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_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ switch (nIndex) {
+ case OMX_IndexParamVideoMpeg4:
+ {
+ OMX_VIDEO_PARAM_MPEG4TYPE *pDstMpeg4Param = NULL;
+ OMX_VIDEO_PARAM_MPEG4TYPE *pSrcMpeg4Param = (OMX_VIDEO_PARAM_MPEG4TYPE *)pComponentParameterStructure;
+ SEC_MPEG4ENC_HANDLE *pMpeg4Enc = 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;
+ }
+
+ pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ pDstMpeg4Param = &pMpeg4Enc->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_MPEG4ENC_HANDLE *pMpeg4Enc = 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;
+ }
+
+ pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ pDstH263Param = &pMpeg4Enc->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_ENC_ROLE)) {
+ pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingMPEG4;
+ //((SEC_MPEG4ENC_HANDLE *)(((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle))->hMFCMpeg4Handle.codecType = CODEC_TYPE_MPEG4;
+ } else if (!SEC_OSAL_Strcmp((char*)pComponentRole->cRole, SEC_OMX_COMPONENT_H263_ENC_ROLE)) {
+ pSECComponent->pSECPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingH263;
+ //((SEC_MPEG4ENC_HANDLE *)(((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle))->hMFCMpeg4Handle.codecType = CODEC_TYPE_H263;
+ } else {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ }
+ 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_MPEG4ENC_HANDLE *pMpeg4Enc = 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;
+ }
+
+ pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ codecType = pMpeg4Enc->hMFCMpeg4Handle.codecType;
+ if (codecType == CODEC_TYPE_MPEG4) {
+ /*
+ * To do: Check validity of profile & level parameters
+ */
+
+ pDstMpeg4Param = &pMpeg4Enc->mpeg4Component[pSrcProfileLevel->nPortIndex];
+ pDstMpeg4Param->eProfile = pSrcProfileLevel->eProfile;
+ pDstMpeg4Param->eLevel = pSrcProfileLevel->eLevel;
+ } else {
+ /*
+ * To do: Check validity of profile & level parameters
+ */
+
+ pDstH263Param = &pMpeg4Enc->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_MPEG4ENC_HANDLE *pMpeg4Enc = NULL;
+
+ ret = SEC_OMX_Check_SizeVersion(pSrcErrorCorrectionType, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pSrcErrorCorrectionType->nPortIndex != OUTPUT_PORT_INDEX) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ pDstErrorCorrectionType = &pMpeg4Enc->errorCorrectionType[OUTPUT_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_VideoEncodeSetParameter(hComponent, nIndex, pComponentParameterStructure);
+ break;
+ }
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_Mpeg4Enc_GetConfig(
+ 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) {
+ default:
+ ret = SEC_OMX_VideoEncodeGetConfig(hComponent, nIndex, pComponentConfigStructure);
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_Mpeg4Enc_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;
+ SEC_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
+ SEC_MPEG4ENC_HANDLE *pMpeg4Enc = 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;
+ }
+
+ pVideoEnc = ((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle);
+
+ switch (nIndex) {
+ case OMX_IndexConfigVideoIntraPeriod:
+ {
+ SEC_OMX_VIDEOENC_COMPONENT *pVEncBase = ((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle);
+ pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ OMX_U32 nPFrames = (*((OMX_U32 *)pComponentConfigStructure)) - 1;
+
+ if (pMpeg4Enc->hMFCMpeg4Handle.codecType == CODEC_TYPE_MPEG4)
+ pMpeg4Enc->mpeg4Component[OUTPUT_PORT_INDEX].nPFrames = nPFrames;
+ else
+ pMpeg4Enc->h263Component[OUTPUT_PORT_INDEX].nPFrames = nPFrames;
+
+ ret = OMX_ErrorNone;
+ }
+ break;
+ default:
+ ret = SEC_OMX_VideoEncodeSetConfig(hComponent, nIndex, pComponentConfigStructure);
+ break;
+ }
+
+EXIT:
+ if (ret == OMX_ErrorNone)
+ pVideoEnc->configChange = OMX_TRUE;
+
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_Mpeg4Enc_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_CONFIG_VIDEO_INTRAPERIOD) == 0) {
+ *pIndexType = OMX_IndexConfigVideoIntraPeriod;
+ ret = OMX_ErrorNone;
+ } else {
+ ret = SEC_OMX_VideoEncodeGetExtensionIndex(hComponent, cParameterName, pIndexType);
+ }
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_Mpeg4Enc_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_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ codecType = ((SEC_MPEG4ENC_HANDLE *)(((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle))->hMFCMpeg4Handle.codecType;
+ if (codecType == CODEC_TYPE_MPEG4)
+ SEC_OSAL_Strcpy((char *)cRole, SEC_OMX_COMPONENT_MPEG4_ENC_ROLE);
+ else
+ SEC_OSAL_Strcpy((char *)cRole, SEC_OMX_COMPONENT_H263_ENC_ROLE);
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_EncodeThread(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_VIDEOENC_COMPONENT *pVideoEnc = (SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle;
+ SEC_MPEG4ENC_HANDLE *pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+
+ FunctionIn();
+
+ if (hComponent == NULL) {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ while (pVideoEnc->NBEncThread.bExitEncodeThread == OMX_FALSE) {
+ SEC_OSAL_SemaphoreWait(pVideoEnc->NBEncThread.hEncFrameStart);
+
+ if (pVideoEnc->NBEncThread.bExitEncodeThread == OMX_FALSE) {
+ pMpeg4Enc->hMFCMpeg4Handle.returnCodec = SsbSipMfcEncExe(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle);
+ SEC_OSAL_SemaphorePost(pVideoEnc->NBEncThread.hEncFrameEnd);
+ }
+ }
+
+EXIT:
+ FunctionOut();
+ SEC_OSAL_ThreadExit(NULL);
+
+ return ret;
+}
+
+/* MFC Init */
+OMX_ERRORTYPE SEC_MFC_Mpeg4Enc_Init(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ SEC_OMX_VIDEOENC_COMPONENT *pVideoEnc = ((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle);
+ SEC_OMX_BASEPORT *pSECInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ SEC_MPEG4ENC_HANDLE *pMpeg4Enc = NULL;
+ OMX_HANDLETYPE hMFCHandle = NULL;
+ OMX_S32 returnCodec = 0;
+
+ FunctionIn();
+
+ pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ pMpeg4Enc->hMFCMpeg4Handle.bConfiguredMFC = OMX_FALSE;
+ pSECComponent->bUseFlagEOF = OMX_FALSE;
+ pSECComponent->bSaveFlagEOS = OMX_FALSE;
+
+ /* MFC(Multi Format Codec) encoder and CMM(Codec Memory Management) driver open */
+ switch (pSECInputPort->portDefinition.format.video.eColorFormat) {
+ case OMX_SEC_COLOR_FormatNV12TPhysicalAddress:
+ case OMX_SEC_COLOR_FormatNV12LPhysicalAddress:
+ case OMX_SEC_COLOR_FormatNV12LVirtualAddress:
+ hMFCHandle = (OMX_PTR)SsbSipMfcEncOpen();
+ break;
+ default: {
+ SSBIP_MFC_BUFFER_TYPE buf_type = CACHE;
+ hMFCHandle = (OMX_PTR)SsbSipMfcEncOpenExt(&buf_type);
+ break;
+ }
+ }
+
+ if (hMFCHandle == NULL) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle = hMFCHandle;
+
+ /* set MFC ENC VIDEO PARAM and initialize MFC encoder instance */
+ if (pMpeg4Enc->hMFCMpeg4Handle.codecType == CODEC_TYPE_MPEG4) {
+ Set_Mpeg4Enc_Param(&(pMpeg4Enc->hMFCMpeg4Handle.mpeg4MFCParam), pSECComponent);
+ returnCodec = SsbSipMfcEncInit(hMFCHandle, &(pMpeg4Enc->hMFCMpeg4Handle.mpeg4MFCParam));
+ } else {
+ Set_H263Enc_Param(&(pMpeg4Enc->hMFCMpeg4Handle.h263MFCParam), pSECComponent);
+ returnCodec = SsbSipMfcEncInit(hMFCHandle, &(pMpeg4Enc->hMFCMpeg4Handle.h263MFCParam));
+ }
+ if (returnCodec != MFC_RET_OK) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+
+ /* Allocate encoder's input buffer */
+ returnCodec = SsbSipMfcEncGetInBuf(hMFCHandle, &(pMpeg4Enc->hMFCMpeg4Handle.inputInfo));
+ if (returnCodec != MFC_RET_OK) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ pVideoEnc->MFCEncInputBuffer[0].YPhyAddr = pMpeg4Enc->hMFCMpeg4Handle.inputInfo.YPhyAddr;
+ pVideoEnc->MFCEncInputBuffer[0].CPhyAddr = pMpeg4Enc->hMFCMpeg4Handle.inputInfo.CPhyAddr;
+ pVideoEnc->MFCEncInputBuffer[0].YVirAddr = pMpeg4Enc->hMFCMpeg4Handle.inputInfo.YVirAddr;
+ pVideoEnc->MFCEncInputBuffer[0].CVirAddr = pMpeg4Enc->hMFCMpeg4Handle.inputInfo.CVirAddr;
+ pVideoEnc->MFCEncInputBuffer[0].YBufferSize = pMpeg4Enc->hMFCMpeg4Handle.inputInfo.YSize;
+ pVideoEnc->MFCEncInputBuffer[0].CBufferSize = pMpeg4Enc->hMFCMpeg4Handle.inputInfo.CSize;
+ pVideoEnc->MFCEncInputBuffer[0].YDataSize = 0;
+ pVideoEnc->MFCEncInputBuffer[0].CDataSize = 0;
+ SEC_OSAL_Log(SEC_LOG_TRACE, "pMpeg4Enc->hMFCMpeg4Handle.inputInfo.YVirAddr : 0x%x", pMpeg4Enc->hMFCMpeg4Handle.inputInfo.YVirAddr);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "pMpeg4Enc->hMFCMpeg4Handle.inputInfo.CVirAddr : 0x%x", pMpeg4Enc->hMFCMpeg4Handle.inputInfo.CVirAddr);
+
+ returnCodec = SsbSipMfcEncGetInBuf(hMFCHandle, &(pMpeg4Enc->hMFCMpeg4Handle.inputInfo));
+ if (returnCodec != MFC_RET_OK) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ pVideoEnc->MFCEncInputBuffer[1].YPhyAddr = pMpeg4Enc->hMFCMpeg4Handle.inputInfo.YPhyAddr;
+ pVideoEnc->MFCEncInputBuffer[1].CPhyAddr = pMpeg4Enc->hMFCMpeg4Handle.inputInfo.CPhyAddr;
+ pVideoEnc->MFCEncInputBuffer[1].YVirAddr = pMpeg4Enc->hMFCMpeg4Handle.inputInfo.YVirAddr;
+ pVideoEnc->MFCEncInputBuffer[1].CVirAddr = pMpeg4Enc->hMFCMpeg4Handle.inputInfo.CVirAddr;
+ pVideoEnc->MFCEncInputBuffer[1].YBufferSize = pMpeg4Enc->hMFCMpeg4Handle.inputInfo.YSize;
+ pVideoEnc->MFCEncInputBuffer[1].CBufferSize = pMpeg4Enc->hMFCMpeg4Handle.inputInfo.CSize;
+ pVideoEnc->MFCEncInputBuffer[1].YDataSize = 0;
+ pVideoEnc->MFCEncInputBuffer[1].CDataSize = 0;
+ SEC_OSAL_Log(SEC_LOG_TRACE, "pMpeg4Enc->hMFCMpeg4Handle.inputInfo.YVirAddr : 0x%x", pMpeg4Enc->hMFCMpeg4Handle.inputInfo.YVirAddr);
+ SEC_OSAL_Log(SEC_LOG_TRACE, "pMpeg4Enc->hMFCMpeg4Handle.inputInfo.CVirAddr : 0x%x", pMpeg4Enc->hMFCMpeg4Handle.inputInfo.CVirAddr);
+
+ pVideoEnc->indexInputBuffer = 0;
+
+ pVideoEnc->bFirstFrame = OMX_TRUE;
+
+#ifdef NONBLOCK_MODE_PROCESS
+ pVideoEnc->NBEncThread.bExitEncodeThread = OMX_FALSE;
+ pVideoEnc->NBEncThread.bEncoderRun = OMX_FALSE;
+ SEC_OSAL_SemaphoreCreate(&(pVideoEnc->NBEncThread.hEncFrameStart));
+ SEC_OSAL_SemaphoreCreate(&(pVideoEnc->NBEncThread.hEncFrameEnd));
+ if (OMX_ErrorNone == SEC_OSAL_ThreadCreate(&pVideoEnc->NBEncThread.hNBEncodeThread,
+ SEC_MFC_EncodeThread,
+ pOMXComponent)) {
+ pMpeg4Enc->hMFCMpeg4Handle.returnCodec = MFC_RET_OK;
+ }
+#endif
+ SEC_OSAL_Memset(pSECComponent->timeStamp, -19771003, sizeof(OMX_TICKS) * MAX_TIMESTAMP);
+ SEC_OSAL_Memset(pSECComponent->nFlags, 0, sizeof(OMX_U32) * MAX_FLAGS);
+ pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp = 0;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+/* MFC Terminate */
+OMX_ERRORTYPE SEC_MFC_Mpeg4Enc_Terminate(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ SEC_OMX_VIDEOENC_COMPONENT *pVideoEnc = ((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle);
+ SEC_MPEG4ENC_HANDLE *pMpeg4Enc = NULL;
+ OMX_HANDLETYPE hMFCHandle = NULL;
+
+ FunctionIn();
+
+ pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+#ifdef NONBLOCK_MODE_PROCESS
+ if (pVideoEnc->NBEncThread.hNBEncodeThread != NULL) {
+ pVideoEnc->NBEncThread.bExitEncodeThread = OMX_TRUE;
+ SEC_OSAL_SemaphorePost(pVideoEnc->NBEncThread.hEncFrameStart);
+ SEC_OSAL_ThreadTerminate(pVideoEnc->NBEncThread.hNBEncodeThread);
+ pVideoEnc->NBEncThread.hNBEncodeThread = NULL;
+ }
+
+ if(pVideoEnc->NBEncThread.hEncFrameEnd != NULL) {
+ SEC_OSAL_SemaphoreTerminate(pVideoEnc->NBEncThread.hEncFrameEnd);
+ pVideoEnc->NBEncThread.hEncFrameEnd = NULL;
+ }
+
+ if(pVideoEnc->NBEncThread.hEncFrameStart != NULL) {
+ SEC_OSAL_SemaphoreTerminate(pVideoEnc->NBEncThread.hEncFrameStart);
+ pVideoEnc->NBEncThread.hEncFrameStart = NULL;
+ }
+#endif
+
+ hMFCHandle = pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle;
+ if (hMFCHandle != NULL) {
+ SsbSipMfcEncClose(hMFCHandle);
+ hMFCHandle = pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle = NULL;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_Mpeg4_Encode_Nonblock(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_OMX_VIDEOENC_COMPONENT *pVideoEnc = ((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle);
+ SEC_MPEG4ENC_HANDLE *pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ OMX_HANDLETYPE hMFCHandle = pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle;
+ SSBSIP_MFC_ENC_INPUT_INFO *pInputInfo = &(pMpeg4Enc->hMFCMpeg4Handle.inputInfo);
+ SSBSIP_MFC_ENC_OUTPUT_INFO outputInfo;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+ MFC_ENC_ADDR_INFO addrInfo;
+ OMX_U32 oneFrameSize = pInputData->dataLen;
+
+ FunctionIn();
+
+ if (pMpeg4Enc->hMFCMpeg4Handle.bConfiguredMFC == OMX_FALSE) {
+ pMpeg4Enc->hMFCMpeg4Handle.returnCodec = SsbSipMfcEncGetOutBuf(hMFCHandle, &outputInfo);
+ if (pMpeg4Enc->hMFCMpeg4Handle.returnCodec != MFC_RET_OK)
+ {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "%s: SsbSipMfcEncGetOutBuf failed, ret:%d", __FUNCTION__, pMpeg4Enc->hMFCMpeg4Handle.returnCodec);
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+
+ pOutputData->dataBuffer = outputInfo.StrmVirAddr;
+ pOutputData->allocSize = outputInfo.headerSize;
+ pOutputData->dataLen = outputInfo.headerSize;
+ pOutputData->timeStamp = 0;
+ pOutputData->nFlags |= OMX_BUFFERFLAG_CODECCONFIG;
+ pOutputData->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
+
+ pMpeg4Enc->hMFCMpeg4Handle.bConfiguredMFC = OMX_TRUE;
+
+ ret = OMX_ErrorInputDataEncodeYet;
+ goto EXIT;
+ }
+
+ if ((pInputData->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) &&
+ (pSECComponent->bUseFlagEOF == OMX_FALSE))
+ pSECComponent->bUseFlagEOF = OMX_TRUE;
+
+ if (oneFrameSize <= 0) {
+ pOutputData->timeStamp = pInputData->timeStamp;
+ pOutputData->nFlags = pInputData->nFlags;
+
+ ret = OMX_ErrorNone;
+ goto EXIT;
+ }
+
+ pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ if (((pInputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) ||
+ (pSECComponent->getAllDelayBuffer == OMX_TRUE)){
+ /* Dummy input data for get out encoded last frame */
+ pInputInfo->YPhyAddr = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].YPhyAddr;
+ pInputInfo->CPhyAddr = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].CPhyAddr;
+ pInputInfo->YVirAddr = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].YVirAddr;
+ pInputInfo->CVirAddr = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].CVirAddr;
+ } else {
+ switch (pSECPort->portDefinition.format.video.eColorFormat) {
+ case OMX_SEC_COLOR_FormatNV12TPhysicalAddress:
+ case OMX_SEC_COLOR_FormatNV12LPhysicalAddress: {
+#ifndef USE_METADATABUFFERTYPE
+ /* USE_FIMC_FRAME_BUFFER */
+ SEC_OSAL_Memcpy(&addrInfo.pAddrY, pInputData->dataBuffer, sizeof(addrInfo.pAddrY));
+ SEC_OSAL_Memcpy(&addrInfo.pAddrC, pInputData->dataBuffer + sizeof(addrInfo.pAddrY), sizeof(addrInfo.pAddrC));
+#else
+ OMX_PTR ppBuf[3];
+ SEC_OSAL_GetInfoFromMetaData(pInputData, ppBuf);
+
+ SEC_OSAL_Memcpy(&addrInfo.pAddrY, ppBuf[0], sizeof(addrInfo.pAddrY));
+ SEC_OSAL_Memcpy(&addrInfo.pAddrC, ppBuf[1], sizeof(addrInfo.pAddrC));
+#endif
+ pInputInfo->YPhyAddr = addrInfo.pAddrY;
+ pInputInfo->CPhyAddr = addrInfo.pAddrC;
+ break;
+ }
+ case OMX_SEC_COLOR_FormatNV12LVirtualAddress:
+ addrInfo.pAddrY = *((void **)pInputData->dataBuffer);
+ addrInfo.pAddrC = (void *)((char *)addrInfo.pAddrY + pInputInfo->YSize);
+
+ pInputInfo->YPhyAddr = addrInfo.pAddrY;
+ pInputInfo->CPhyAddr = addrInfo.pAddrC;
+ break;
+ default:
+ pInputInfo->YPhyAddr = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].YPhyAddr;
+ pInputInfo->CPhyAddr = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].CPhyAddr;
+ pInputInfo->YVirAddr = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].YVirAddr;
+ pInputInfo->CVirAddr = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].CVirAddr;
+ break;
+ }
+ }
+
+ pSECComponent->timeStamp[pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp] = pInputData->timeStamp;
+ pSECComponent->nFlags[pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp] = pInputData->nFlags;
+
+ if ((pMpeg4Enc->hMFCMpeg4Handle.returnCodec == MFC_RET_OK) &&
+ (pVideoEnc->bFirstFrame == OMX_FALSE)) {
+ OMX_S32 indexTimestamp = 0;
+
+ /* wait for mfc encode done */
+ if (pVideoEnc->NBEncThread.bEncoderRun != OMX_FALSE) {
+ SEC_OSAL_SemaphoreWait(pVideoEnc->NBEncThread.hEncFrameEnd);
+ pVideoEnc->NBEncThread.bEncoderRun = OMX_FALSE;
+ }
+
+ SEC_OSAL_SleepMillisec(0);
+ pMpeg4Enc->hMFCMpeg4Handle.returnCodec = SsbSipMfcEncGetOutBuf(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle, &outputInfo);
+ if ((SsbSipMfcEncGetConfig(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle, MFC_ENC_GETCONF_FRAME_TAG, &indexTimestamp) != MFC_RET_OK) ||
+ (((indexTimestamp < 0) || (indexTimestamp >= MAX_TIMESTAMP)))){
+ pOutputData->timeStamp = pInputData->timeStamp;
+ pOutputData->nFlags = pInputData->nFlags;
+ } else {
+ pOutputData->timeStamp = pSECComponent->timeStamp[indexTimestamp];
+ pOutputData->nFlags = pSECComponent->nFlags[indexTimestamp];
+ }
+
+ if (pMpeg4Enc->hMFCMpeg4Handle.returnCodec == MFC_RET_OK) {
+ /** Fill Output Buffer **/
+ pOutputData->dataBuffer = outputInfo.StrmVirAddr;
+ pOutputData->allocSize = outputInfo.dataSize;
+ pOutputData->dataLen = outputInfo.dataSize;
+ pOutputData->usedDataLen = 0;
+
+ pOutputData->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
+ if (outputInfo.frameType == MFC_FRAME_TYPE_I_FRAME)
+ pOutputData->nFlags |= OMX_BUFFERFLAG_SYNCFRAME;
+
+ SEC_OSAL_Log(SEC_LOG_TRACE, "MFC Encode OK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
+
+ ret = OMX_ErrorNone;
+ } else {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "%s: SsbSipMfcEncGetOutBuf failed, ret:%d", __FUNCTION__, pMpeg4Enc->hMFCMpeg4Handle.returnCodec);
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+
+ if (pSECComponent->getAllDelayBuffer == OMX_TRUE) {
+ ret = OMX_ErrorInputDataEncodeYet;
+ }
+ if ((pInputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) {
+ pInputData->nFlags = (pOutputData->nFlags & (~OMX_BUFFERFLAG_EOS));
+ pSECComponent->getAllDelayBuffer = OMX_TRUE;
+ ret = OMX_ErrorInputDataEncodeYet;
+ }
+ if ((pOutputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) {
+ pSECComponent->getAllDelayBuffer = OMX_FALSE;
+ pOutputData->dataLen = 0;
+ pOutputData->usedDataLen = 0;
+ SEC_OSAL_Log(SEC_LOG_TRACE, "OMX_BUFFERFLAG_EOS!!!");
+ ret = OMX_ErrorNone;
+ }
+ }
+ if (pMpeg4Enc->hMFCMpeg4Handle.returnCodec != MFC_RET_OK) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "In %s : SsbSipMfcEncExe Failed!!!\n", __func__);
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+
+ pMpeg4Enc->hMFCMpeg4Handle.returnCodec = SsbSipMfcEncSetInBuf(hMFCHandle, pInputInfo);
+ if (pMpeg4Enc->hMFCMpeg4Handle.returnCodec != MFC_RET_OK) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "%s: SsbSipMfcEncSetInBuf failed, ret:%d", __FUNCTION__, pMpeg4Enc->hMFCMpeg4Handle.returnCodec);
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ } else {
+ pVideoEnc->indexInputBuffer++;
+ pVideoEnc->indexInputBuffer %= MFC_INPUT_BUFFER_NUM_MAX;
+ }
+
+ if (pVideoEnc->configChange == OMX_TRUE) {
+ if (pMpeg4Enc->hMFCMpeg4Handle.codecType == CODEC_TYPE_MPEG4)
+ Change_Mpeg4Enc_Param(&(pMpeg4Enc->hMFCMpeg4Handle.mpeg4MFCParam), pSECComponent);
+ else
+ Change_H263Enc_Param(&(pMpeg4Enc->hMFCMpeg4Handle.h263MFCParam), pSECComponent);
+ pVideoEnc->configChange = OMX_FALSE;
+ }
+
+ SsbSipMfcEncSetConfig(hMFCHandle, MFC_ENC_SETCONF_FRAME_TAG, &(pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp));
+
+ /* mfc encode start */
+ SEC_OSAL_SemaphorePost(pVideoEnc->NBEncThread.hEncFrameStart);
+ pVideoEnc->NBEncThread.bEncoderRun = OMX_TRUE;
+ pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp++;
+ pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp %= MAX_TIMESTAMP;
+ pVideoEnc->bFirstFrame = OMX_FALSE;
+ SEC_OSAL_SleepMillisec(0);
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_MFC_Mpeg4_Encode_Block(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_OMX_VIDEOENC_COMPONENT *pVideoEnc = ((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle);
+ SEC_MPEG4ENC_HANDLE *pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ OMX_HANDLETYPE hMFCHandle = pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle;
+ SSBSIP_MFC_ENC_INPUT_INFO *pInputInfo = &(pMpeg4Enc->hMFCMpeg4Handle.inputInfo);
+ SSBSIP_MFC_ENC_OUTPUT_INFO outputInfo;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+ MFC_ENC_ADDR_INFO addrInfo;
+ OMX_U32 oneFrameSize = pInputData->dataLen;
+ OMX_S32 returnCodec = 0;
+
+ FunctionIn();
+
+ if (pMpeg4Enc->hMFCMpeg4Handle.bConfiguredMFC == OMX_FALSE) {
+ returnCodec = SsbSipMfcEncGetOutBuf(hMFCHandle, &outputInfo);
+ if (returnCodec != MFC_RET_OK)
+ {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "%s: SsbSipMfcEncGetOutBuf failed, ret:%d", __FUNCTION__, returnCodec);
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ }
+
+ pOutputData->dataBuffer = outputInfo.StrmVirAddr;
+ pOutputData->allocSize = outputInfo.headerSize;
+ pOutputData->dataLen = outputInfo.headerSize;
+ pOutputData->timeStamp = 0;
+ pOutputData->nFlags |= OMX_BUFFERFLAG_CODECCONFIG;
+ pOutputData->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
+
+ pMpeg4Enc->hMFCMpeg4Handle.bConfiguredMFC = OMX_TRUE;
+
+ ret = OMX_ErrorInputDataEncodeYet;
+ goto EXIT;
+ }
+
+ if ((pInputData->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) &&
+ (pSECComponent->bUseFlagEOF == OMX_FALSE))
+ pSECComponent->bUseFlagEOF = OMX_TRUE;
+
+ if (oneFrameSize <= 0) {
+ pOutputData->timeStamp = pInputData->timeStamp;
+ pOutputData->nFlags = pInputData->nFlags;
+
+ ret = OMX_ErrorNone;
+ goto EXIT;
+ }
+
+ pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ switch (pSECPort->portDefinition.format.video.eColorFormat) {
+ case OMX_SEC_COLOR_FormatNV12TPhysicalAddress:
+ case OMX_SEC_COLOR_FormatNV12LPhysicalAddress: {
+#ifndef USE_METADATABUFFERTYPE
+ /* USE_FIMC_FRAME_BUFFER */
+ SEC_OSAL_Memcpy(&addrInfo.pAddrY, pInputData->dataBuffer, sizeof(addrInfo.pAddrY));
+ SEC_OSAL_Memcpy(&addrInfo.pAddrC, pInputData->dataBuffer + sizeof(addrInfo.pAddrY), sizeof(addrInfo.pAddrC));
+#else
+ OMX_PTR ppBuf[3];
+ SEC_OSAL_GetInfoFromMetaData(pInputData,ppBuf);
+
+ SEC_OSAL_Memcpy(&addrInfo.pAddrY, ppBuf[0], sizeof(addrInfo.pAddrY));
+ SEC_OSAL_Memcpy(&addrInfo.pAddrC, ppBuf[1], sizeof(addrInfo.pAddrC));
+#endif
+ pInputInfo->YPhyAddr = addrInfo.pAddrY;
+ pInputInfo->CPhyAddr = addrInfo.pAddrC;
+ break;
+ }
+ case OMX_SEC_COLOR_FormatNV12LVirtualAddress:
+ addrInfo.pAddrY = *((void **)pInputData->dataBuffer);
+ addrInfo.pAddrC = (void *)((char *)addrInfo.pAddrY + pInputInfo->YSize);
+
+ pInputInfo->YPhyAddr = addrInfo.pAddrY;
+ pInputInfo->CPhyAddr = addrInfo.pAddrC;
+ break;
+ default:
+ pInputInfo->YPhyAddr = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].YPhyAddr;
+ pInputInfo->CPhyAddr = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].CPhyAddr;
+ pInputInfo->YVirAddr = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].YVirAddr;
+ pInputInfo->CVirAddr = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].CVirAddr;
+ break;
+ }
+
+ returnCodec = SsbSipMfcEncSetInBuf(hMFCHandle, pInputInfo);
+ if (returnCodec != MFC_RET_OK) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "%s: SsbSipMfcEncSetInBuf failed, ret:%d", __FUNCTION__, returnCodec);
+ ret = OMX_ErrorUndefined;
+ goto EXIT;
+ } else {
+ pVideoEnc->indexInputBuffer++;
+ pVideoEnc->indexInputBuffer %= MFC_INPUT_BUFFER_NUM_MAX;
+ }
+
+ if (pVideoEnc->configChange == OMX_TRUE) {
+ if (pMpeg4Enc->hMFCMpeg4Handle.codecType == CODEC_TYPE_MPEG4)
+ Change_Mpeg4Enc_Param(&(pMpeg4Enc->hMFCMpeg4Handle.mpeg4MFCParam), pSECComponent);
+ else
+ Change_H263Enc_Param(&(pMpeg4Enc->hMFCMpeg4Handle.h263MFCParam), pSECComponent);
+ pVideoEnc->configChange = OMX_FALSE;
+ }
+
+ pSECComponent->timeStamp[pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp] = pInputData->timeStamp;
+ pSECComponent->nFlags[pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp] = pInputData->nFlags;
+ SsbSipMfcEncSetConfig(hMFCHandle, MFC_ENC_SETCONF_FRAME_TAG, &(pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp));
+
+ returnCodec = SsbSipMfcEncExe(hMFCHandle);
+ if (returnCodec == MFC_RET_OK) {
+ OMX_S32 indexTimestamp = 0;
+
+ pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp++;
+ pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp %= MAX_TIMESTAMP;
+
+ returnCodec = SsbSipMfcEncGetOutBuf(hMFCHandle, &outputInfo);
+
+ if ((SsbSipMfcEncGetConfig(hMFCHandle, MFC_ENC_GETCONF_FRAME_TAG, &indexTimestamp) != MFC_RET_OK) ||
+ (((indexTimestamp < 0) || (indexTimestamp >= MAX_TIMESTAMP)))) {
+ pOutputData->timeStamp = pInputData->timeStamp;
+ pOutputData->nFlags = pInputData->nFlags;
+ } else {
+ pOutputData->timeStamp = pSECComponent->timeStamp[indexTimestamp];
+ pOutputData->nFlags = pSECComponent->nFlags[indexTimestamp];
+ }
+
+ if (returnCodec == MFC_RET_OK) {
+ /** Fill Output Buffer **/
+ pOutputData->dataBuffer = outputInfo.StrmVirAddr;
+ pOutputData->allocSize = outputInfo.dataSize;
+ pOutputData->dataLen = outputInfo.dataSize;
+ pOutputData->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
+ if (outputInfo.frameType == MFC_FRAME_TYPE_I_FRAME)
+ pOutputData->nFlags |= OMX_BUFFERFLAG_SYNCFRAME;
+
+ ret = OMX_ErrorNone;
+ } else {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "%s: SsbSipMfcEncGetOutBuf failed, ret:%d", __FUNCTION__, returnCodec);
+ ret = OMX_ErrorUndefined;
+ }
+ } else {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "%s: SsbSipMfcEncExe failed, ret:%d", __FUNCTION__, returnCodec);
+ ret = OMX_ErrorUndefined;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+/* MFC Encode */
+OMX_ERRORTYPE SEC_MFC_Mpeg4Enc_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_OMX_BASEPORT *pInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ SEC_OMX_BASEPORT *pOutputPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+
+ FunctionIn();
+
+ if ((!CHECK_PORT_ENABLED(pInputPort)) || (!CHECK_PORT_ENABLED(pOutputPort)) ||
+ (!CHECK_PORT_POPULATED(pInputPort)) || (!CHECK_PORT_POPULATED(pOutputPort))) {
+ goto EXIT;
+ }
+ if (OMX_FALSE == SEC_Check_BufferProcess_State(pSECComponent)) {
+ goto EXIT;
+ }
+
+#ifdef NONBLOCK_MODE_PROCESS
+ ret = SEC_MFC_Mpeg4_Encode_Nonblock(pOMXComponent, pInputData, pOutputData);
+#else
+ ret = SEC_MFC_Mpeg4_Encode_Block(pOMXComponent, pInputData, pOutputData);
+#endif
+ if (ret != OMX_ErrorNone) {
+ if (ret == OMX_ErrorInputDataEncodeYet) {
+ pOutputData->usedDataLen = 0;
+ pOutputData->remainDataLen = pOutputData->dataLen;
+ } else {
+ pSECComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent,
+ pSECComponent->callbackData,
+ OMX_EventError, ret, 0, NULL);
+ }
+ } else {
+ 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_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
+ SEC_MPEG4ENC_HANDLE *pMpeg4Enc = 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_ENC, componentName) == 0) {
+ codecType = CODEC_TYPE_MPEG4;
+ } else if (SEC_OSAL_Strcmp(SEC_OMX_COMPONENT_H263_ENC, componentName) == 0) {
+ codecType = CODEC_TYPE_H263;
+ } else {
+ ret = OMX_ErrorBadParameter;
+ SEC_OSAL_Log(SEC_LOG_ERROR, "%s: componentName(%s) error, ret: %X", __FUNCTION__, componentName, ret);
+ goto EXIT;
+ }
+
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = SEC_OMX_VideoEncodeComponentInit(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_ENC_CODEC;
+
+ pSECComponent->componentName = (OMX_STRING)SEC_OSAL_Malloc(MAX_OMX_COMPONENT_NAME_SIZE);
+ if (pSECComponent->componentName == NULL) {
+ SEC_OMX_VideoEncodeComponentDeinit(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);
+
+ pMpeg4Enc = SEC_OSAL_Malloc(sizeof(SEC_MPEG4ENC_HANDLE));
+ if (pMpeg4Enc == NULL) {
+ SEC_OMX_VideoEncodeComponentDeinit(pOMXComponent);
+ ret = OMX_ErrorInsufficientResources;
+ SEC_OSAL_Log(SEC_LOG_ERROR, "%s: SEC_MPEG4ENC_HANDLE alloc error, ret: %X", __FUNCTION__, ret);
+ goto EXIT;
+ }
+ SEC_OSAL_Memset(pMpeg4Enc, 0, sizeof(SEC_MPEG4ENC_HANDLE));
+ pVideoEnc = (SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle;
+ pVideoEnc->hCodecHandle = (OMX_HANDLETYPE)pMpeg4Enc;
+ pMpeg4Enc->hMFCMpeg4Handle.codecType = codecType;
+
+ if (codecType == CODEC_TYPE_MPEG4)
+ SEC_OSAL_Strcpy(pSECComponent->componentName, SEC_OMX_COMPONENT_MPEG4_ENC);
+ else
+ SEC_OSAL_Strcpy(pSECComponent->componentName, SEC_OMX_COMPONENT_H263_ENC);
+
+ /* 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.nBitrate = 64000;
+ pSECPort->portDefinition.format.video.xFramerate= (15 << 16);
+ pSECPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
+ pSECPort->portDefinition.format.video.pNativeRender = 0;
+ pSECPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE;
+ 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.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
+ pSECPort->portDefinition.nBufferSize = DEFAULT_VIDEO_INPUT_BUFFER_SIZE;
+ 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.nBitrate = 64000;
+ pSECPort->portDefinition.format.video.xFramerate= (15 << 16);
+ 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.nBufferSize = DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE;
+ pSECPort->portDefinition.bEnabled = OMX_TRUE;
+
+ if (codecType == CODEC_TYPE_MPEG4) {
+ for(i = 0; i < ALL_PORT_NUM; i++) {
+ INIT_SET_SIZE_VERSION(&pMpeg4Enc->mpeg4Component[i], OMX_VIDEO_PARAM_MPEG4TYPE);
+ pMpeg4Enc->mpeg4Component[i].nPortIndex = i;
+ pMpeg4Enc->mpeg4Component[i].eProfile = OMX_VIDEO_MPEG4ProfileSimple;
+ pMpeg4Enc->mpeg4Component[i].eLevel = OMX_VIDEO_MPEG4Level4;
+
+ pMpeg4Enc->mpeg4Component[i].nPFrames = 10;
+ pMpeg4Enc->mpeg4Component[i].nBFrames = 0; /* No support for B frames */
+ pMpeg4Enc->mpeg4Component[i].nMaxPacketSize = 256; /* Default value */
+ pMpeg4Enc->mpeg4Component[i].nAllowedPictureTypes = OMX_VIDEO_PictureTypeI | OMX_VIDEO_PictureTypeP;
+ pMpeg4Enc->mpeg4Component[i].bGov = OMX_FALSE;
+
+ }
+ } else {
+ for(i = 0; i < ALL_PORT_NUM; i++) {
+ INIT_SET_SIZE_VERSION(&pMpeg4Enc->h263Component[i], OMX_VIDEO_PARAM_H263TYPE);
+ pMpeg4Enc->h263Component[i].nPortIndex = i;
+ pMpeg4Enc->h263Component[i].eProfile = OMX_VIDEO_H263ProfileBaseline;
+ pMpeg4Enc->h263Component[i].eLevel = OMX_VIDEO_H263Level45;
+
+ pMpeg4Enc->h263Component[i].nPFrames = 20;
+ pMpeg4Enc->h263Component[i].nBFrames = 0; /* No support for B frames */
+ pMpeg4Enc->h263Component[i].bPLUSPTYPEAllowed = OMX_FALSE;
+ pMpeg4Enc->h263Component[i].nAllowedPictureTypes = OMX_VIDEO_PictureTypeI | OMX_VIDEO_PictureTypeP;
+ pMpeg4Enc->h263Component[i].bForceRoundingTypeToZero = OMX_TRUE;
+ pMpeg4Enc->h263Component[i].nPictureHeaderRepetition = 0;
+ pMpeg4Enc->h263Component[i].nGOBHeaderInterval = 0;
+ }
+ }
+
+ pOMXComponent->GetParameter = &SEC_MFC_Mpeg4Enc_GetParameter;
+ pOMXComponent->SetParameter = &SEC_MFC_Mpeg4Enc_SetParameter;
+ pOMXComponent->GetConfig = &SEC_MFC_Mpeg4Enc_GetConfig;
+ pOMXComponent->SetConfig = &SEC_MFC_Mpeg4Enc_SetConfig;
+ pOMXComponent->GetExtensionIndex = &SEC_MFC_Mpeg4Enc_GetExtensionIndex;
+ pOMXComponent->ComponentRoleEnum = &SEC_MFC_Mpeg4Enc_ComponentRoleEnum;
+ pOMXComponent->ComponentDeInit = &SEC_OMX_ComponentDeinit;
+
+ pSECComponent->sec_mfc_componentInit = &SEC_MFC_Mpeg4Enc_Init;
+ pSECComponent->sec_mfc_componentTerminate = &SEC_MFC_Mpeg4Enc_Terminate;
+ pSECComponent->sec_mfc_bufferProcess = &SEC_MFC_Mpeg4Enc_bufferProcess;
+ pSECComponent->sec_checkInputFrame = NULL;
+
+ 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_MPEG4ENC_HANDLE *pMpeg4Enc = 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;
+
+ pMpeg4Enc = (SEC_MPEG4ENC_HANDLE *)((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ if (pMpeg4Enc != NULL) {
+ SEC_OSAL_Free(pMpeg4Enc);
+ pMpeg4Enc = ((SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle = NULL;
+ }
+
+ ret = SEC_OMX_VideoEncodeComponentDeinit(pOMXComponent);
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ ret = OMX_ErrorNone;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
diff --git a/exynos/multimedia/openmax/component/video/enc/mpeg4/SEC_OMX_Mpeg4enc.h b/exynos/multimedia/openmax/component/video/enc/mpeg4/SEC_OMX_Mpeg4enc.h
new file mode 100644
index 0000000..aa32c42
--- /dev/null
+++ b/exynos/multimedia/openmax/component/video/enc/mpeg4/SEC_OMX_Mpeg4enc.h
@@ -0,0 +1,77 @@
+/*
+ *
+ * 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_Mpeg4enc.h
+ * @brief
+ * @author Yunji Kim (yunji.kim@samsung.com)
+ * @version 1.1.0
+ * @history
+ * 2010.7.15 : Create
+ */
+
+#ifndef SEC_OMX_MPEG4_ENC_COMPONENT
+#define SEC_OMX_MPEG4_ENC_COMPONENT
+
+#include "SEC_OMX_Def.h"
+#include "OMX_Component.h"
+#include "SsbSipMfcApi.h"
+
+
+typedef enum _CODEC_TYPE
+{
+ CODEC_TYPE_H263,
+ CODEC_TYPE_MPEG4
+} CODEC_TYPE;
+
+typedef struct _SEC_MFC_MPEG4ENC_HANDLE
+{
+ OMX_HANDLETYPE hMFCHandle;
+ SSBSIP_MFC_ENC_MPEG4_PARAM mpeg4MFCParam;
+ SSBSIP_MFC_ENC_H263_PARAM h263MFCParam;
+ SSBSIP_MFC_ENC_INPUT_INFO inputInfo;
+ OMX_U32 indexTimestamp;
+ OMX_BOOL bConfiguredMFC;
+ CODEC_TYPE codecType;
+ OMX_S32 returnCodec;
+} SEC_MFC_MPEG4ENC_HANDLE;
+
+typedef struct _SEC_MPEG4ENC_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_MPEG4ENC_HANDLE hMFCMpeg4Handle;
+} SEC_MPEG4ENC_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/exynos/multimedia/openmax/component/video/enc/mpeg4/library_register.c b/exynos/multimedia/openmax/component/video/enc/mpeg4/library_register.c
new file mode 100644
index 0000000..d43b2d7
--- /dev/null
+++ b/exynos/multimedia/openmax/component/video/enc/mpeg4/library_register.c
@@ -0,0 +1,64 @@
+/*
+ *
+ * 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.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_ENC"
+#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 encoder MPEG4 */
+ SEC_OSAL_Strcpy(ppSECComponent[0]->componentName, SEC_OMX_COMPONENT_MPEG4_ENC);
+ SEC_OSAL_Strcpy(ppSECComponent[0]->roles[0], SEC_OMX_COMPONENT_MPEG4_ENC_ROLE);
+ ppSECComponent[0]->totalRoleNum = MAX_COMPONENT_ROLE_NUM;
+
+ /* component 2 - video encoder H.263 */
+ SEC_OSAL_Strcpy(ppSECComponent[1]->componentName, SEC_OMX_COMPONENT_H263_ENC);
+ SEC_OSAL_Strcpy(ppSECComponent[1]->roles[0], SEC_OMX_COMPONENT_H263_ENC_ROLE);
+ ppSECComponent[1]->totalRoleNum = MAX_COMPONENT_ROLE_NUM;
+
+EXIT:
+ FunctionOut();
+ return MAX_COMPONENT_NUM;
+}
+
diff --git a/exynos/multimedia/openmax/component/video/enc/mpeg4/library_register.h b/exynos/multimedia/openmax/component/video/enc/mpeg4/library_register.h
new file mode 100644
index 0000000..42a168b
--- /dev/null
+++ b/exynos/multimedia/openmax/component/video/enc/mpeg4/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.1.0
+ * @history
+ * 2010.7.15 : Create
+ */
+
+#ifndef SEC_OMX_MPEG4_ENC_REG
+#define SEC_OMX_MPEG4_ENC_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_ENC "OMX.SEC.MPEG4.Encoder"
+#define SEC_OMX_COMPONENT_MPEG4_ENC_ROLE "video_encoder.mpeg4"
+
+/* H.263 */
+#define SEC_OMX_COMPONENT_H263_ENC "OMX.SEC.H263.Encoder"
+#define SEC_OMX_COMPONENT_H263_ENC_ROLE "video_encoder.h263"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+OSCL_EXPORT_REF int SEC_OMX_COMPONENT_Library_Register(SECRegisterComponentType **ppSECComponent);
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif
+