summaryrefslogtreecommitdiffstats
path: root/exynos4/multimedia/openmax/sec_omx/component/audio
diff options
context:
space:
mode:
Diffstat (limited to 'exynos4/multimedia/openmax/sec_omx/component/audio')
-rw-r--r--exynos4/multimedia/openmax/sec_omx/component/audio/dec/Android.mk19
-rw-r--r--exynos4/multimedia/openmax/sec_omx/component/audio/dec/SEC_OMX_Adec.c1376
-rw-r--r--exynos4/multimedia/openmax/sec_omx/component/audio/dec/SEC_OMX_Adec.h132
-rw-r--r--exynos4/multimedia/openmax/sec_omx/component/audio/dec/mp3/Android.mk31
-rw-r--r--exynos4/multimedia/openmax/sec_omx/component/audio/dec/mp3/SEC_OMX_Mp3dec.c918
-rw-r--r--exynos4/multimedia/openmax/sec_omx/component/audio/dec/mp3/SEC_OMX_Mp3dec.h63
-rw-r--r--exynos4/multimedia/openmax/sec_omx/component/audio/dec/mp3/library_register.c58
-rw-r--r--exynos4/multimedia/openmax/sec_omx/component/audio/dec/mp3/library_register.h54
8 files changed, 2651 insertions, 0 deletions
diff --git a/exynos4/multimedia/openmax/sec_omx/component/audio/dec/Android.mk b/exynos4/multimedia/openmax/sec_omx/component/audio/dec/Android.mk
new file mode 100644
index 0000000..303737b
--- /dev/null
+++ b/exynos4/multimedia/openmax/sec_omx/component/audio/dec/Android.mk
@@ -0,0 +1,19 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ SEC_OMX_Adec.c
+
+LOCAL_MODULE := libSEC_OMX_Adec
+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)/audio/dec \
+ $(TARGET_OUT_HEADERS)/$(SEC_COPY_HEADERS_TO)
+
+include $(BUILD_STATIC_LIBRARY)
diff --git a/exynos4/multimedia/openmax/sec_omx/component/audio/dec/SEC_OMX_Adec.c b/exynos4/multimedia/openmax/sec_omx/component/audio/dec/SEC_OMX_Adec.c
new file mode 100644
index 0000000..dab7247
--- /dev/null
+++ b/exynos4/multimedia/openmax/sec_omx/component/audio/dec/SEC_OMX_Adec.c
@@ -0,0 +1,1376 @@
+/*
+ *
+ * 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_Adec.c
+ * @brief
+ * @author Yunji Kim (yunji.kim@samsung.com)
+ *
+ * @version 1.1.0
+ * @history
+ * 2011.10.18 : Create
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "SEC_OMX_Macros.h"
+#include "SEC_OSAL_Event.h"
+#include "SEC_OMX_Adec.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"
+#include "srp_api.h"
+
+#undef SEC_LOG_TAG
+#define SEC_LOG_TAG "SEC_AUDIO_DEC"
+#define SEC_LOG_OFF
+#include "SEC_OSAL_Log.h"
+
+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_BASEPORT *secInputPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ 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;
+ }
+
+ /* Audio extractor should parse into frame units. */
+ flagEOF = OMX_TRUE;
+ checkedSize = checkInputStreamLen;
+ copySize = checkedSize;
+
+ 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));
+ }
+ }
+ } else {
+ /*????????????????????????????????? Error ?????????????????????????????????*/
+ SEC_DataReset(pOMXComponent, INPUT_PORT_INDEX);
+ flagEOF = OMX_FALSE;
+ }
+
+ if ((inputUseBuffer->remainDataLen == 0) ||
+ (CHECK_PORT_BEING_FLUSHED(secInputPort)))
+ SEC_InputBufferReturn(pOMXComponent);
+ else
+ inputUseBuffer->dataValid = OMX_TRUE;
+ }
+
+ if (flagEOF == OMX_TRUE) {
+ if (pSECComponent->checkTimeStamp.needSetStartTimeStamp == OMX_TRUE) {
+ /* Flush SRP buffers */
+ SRP_Flush();
+
+ 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.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) ||
+ (CHECK_PORT_BEING_FLUSHED(secOutputPort)))
+ 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_AUDIODEC_COMPONENT *pVideoDec = (SEC_OMX_AUDIODEC_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_AudioDecodeGetParameter(
+ 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_IndexParamAudioInit:
+ {
+ 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_IndexParamAudioPortFormat:
+ {
+ OMX_AUDIO_PARAM_PORTFORMATTYPE *portFormat = (OMX_AUDIO_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_AUDIO_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->eEncoding = portDefinition->format.audio.eEncoding;
+ } 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->eEncoding = portDefinition->format.audio.eEncoding;
+ }
+ ret = OMX_ErrorNone;
+ }
+ break;
+ default:
+ {
+ ret = SEC_OMX_GetParameter(hComponent, nParamIndex, ComponentParameterStructure);
+ }
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+OMX_ERRORTYPE SEC_OMX_AudioDecodeSetParameter(
+ 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_IndexParamAudioPortFormat:
+ {
+ OMX_AUDIO_PARAM_PORTFORMATTYPE *portFormat = (OMX_AUDIO_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_AUDIO_PARAM_PORTFORMATTYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if ((portIndex >= pSECComponent->portParam.nPorts)) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ pSECPort = &pSECComponent->pSECPort[portIndex];
+ portDefinition = &pSECPort->portDefinition;
+
+ portDefinition->format.audio.eEncoding = portFormat->eEncoding;
+ ret = OMX_ErrorNone;
+ }
+ break;
+ default:
+ {
+ ret = SEC_OMX_SetParameter(hComponent, nIndex, ComponentParameterStructure);
+ }
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_OMX_AudioDecodeGetConfig(
+ 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_AudioDecodeSetConfig(
+ 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_IndexConfigAudioMute:
+ {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "OMX_IndexConfigAudioMute");
+ ret = OMX_ErrorUnsupportedIndex;
+ }
+ break;
+ case OMX_IndexConfigAudioVolume:
+ {
+ SEC_OSAL_Log(SEC_LOG_TRACE, "OMX_IndexConfigAudioVolume");
+ ret = OMX_ErrorUnsupportedIndex;
+ }
+ break;
+ default:
+ ret = SEC_OMX_SetConfig(hComponent, nIndex, pComponentConfigStructure);
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_OMX_AudioDecodeGetExtensionIndex(
+ 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;
+ }
+
+ ret = SEC_OMX_GetExtensionIndex(hComponent, cParameterName, pIndexType);
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_OMX_AudioDecodeComponentInit(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_AUDIODEC_COMPONENT *pAudioDec = 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;
+
+ pAudioDec = SEC_OSAL_Malloc(sizeof(SEC_OMX_AUDIODEC_COMPONENT));
+ if (pAudioDec == 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(pAudioDec, 0, sizeof(SEC_OMX_AUDIODEC_COMPONENT));
+ pSECComponent->hComponentHandle = (OMX_HANDLETYPE)pAudioDec;
+ pSECComponent->bSaveFlagEOS = OMX_FALSE;
+
+ /* Input port */
+ pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ pSECPort->portDefinition.nBufferCountActual = MAX_AUDIO_INPUTBUFFER_NUM;
+ pSECPort->portDefinition.nBufferCountMin = MAX_AUDIO_INPUTBUFFER_NUM;
+ pSECPort->portDefinition.nBufferSize = DEFAULT_AUDIO_INPUT_BUFFER_SIZE;
+ pSECPort->portDefinition.eDomain = OMX_PortDomainAudio;
+
+ pSECPort->portDefinition.format.audio.cMIMEType = SEC_OSAL_Malloc(MAX_OMX_MIMETYPE_SIZE);
+ SEC_OSAL_Strcpy(pSECPort->portDefinition.format.audio.cMIMEType, "audio/raw");
+ pSECPort->portDefinition.format.audio.pNativeRender = 0;
+ pSECPort->portDefinition.format.audio.bFlagErrorConcealment = OMX_FALSE;
+ pSECPort->portDefinition.format.audio.eEncoding = OMX_AUDIO_CodingUnused;
+
+ /* Output port */
+ pSECPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+ pSECPort->portDefinition.nBufferCountActual = MAX_AUDIO_OUTPUTBUFFER_NUM;
+ pSECPort->portDefinition.nBufferCountMin = MAX_AUDIO_OUTPUTBUFFER_NUM;
+ pSECPort->portDefinition.nBufferSize = DEFAULT_AUDIO_OUTPUT_BUFFER_SIZE;
+ pSECPort->portDefinition.eDomain = OMX_PortDomainAudio;
+
+ pSECPort->portDefinition.format.audio.cMIMEType = SEC_OSAL_Malloc(MAX_OMX_MIMETYPE_SIZE);
+ SEC_OSAL_Strcpy(pSECPort->portDefinition.format.audio.cMIMEType, "audio/raw");
+ pSECPort->portDefinition.format.audio.pNativeRender = 0;
+ pSECPort->portDefinition.format.audio.bFlagErrorConcealment = OMX_FALSE;
+ pSECPort->portDefinition.format.audio.eEncoding = OMX_AUDIO_CodingUnused;
+
+
+ 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_AudioDecodeComponentDeinit(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_AUDIODEC_COMPONENT *pAudioDec = 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;
+
+ pAudioDec = (SEC_OMX_AUDIODEC_COMPONENT *)pSECComponent->hComponentHandle;
+ SEC_OSAL_Free(pAudioDec);
+ pSECComponent->hComponentHandle = pAudioDec = NULL;
+
+ for(i = 0; i < ALL_PORT_NUM; i++) {
+ pSECPort = &pSECComponent->pSECPort[i];
+ SEC_OSAL_Free(pSECPort->portDefinition.format.audio.cMIMEType);
+ pSECPort->portDefinition.format.audio.cMIMEType = NULL;
+ }
+
+ ret = SEC_OMX_Port_Destructor(pOMXComponent);
+
+ ret = SEC_OMX_BaseComponent_Destructor(hComponent);
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
diff --git a/exynos4/multimedia/openmax/sec_omx/component/audio/dec/SEC_OMX_Adec.h b/exynos4/multimedia/openmax/sec_omx/component/audio/dec/SEC_OMX_Adec.h
new file mode 100644
index 0000000..8ff20ab
--- /dev/null
+++ b/exynos4/multimedia/openmax/sec_omx/component/audio/dec/SEC_OMX_Adec.h
@@ -0,0 +1,132 @@
+/*
+ *
+ * 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_Adec.h
+ * @brief
+ * @author Yunji Kim (yunji.kim@samsung.com)
+ *
+ * @version 1.1.0
+ * @history
+ * 2011.10.18 : Create
+ */
+
+#ifndef SEC_OMX_AUDIO_DECODE
+#define SEC_OMX_AUDIO_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_AUDIO_INPUTBUFFER_NUM 2
+#define MAX_AUDIO_OUTPUTBUFFER_NUM 2
+
+#define DEFAULT_AUDIO_INPUT_BUFFER_SIZE (16 * 1024)
+#define DEFAULT_AUDIO_OUTPUT_BUFFER_SIZE (32 * 1024)
+
+#define DEFAULT_AUDIO_SAMPLING_FREQ 44100
+#define DEFAULT_AUDIO_CHANNELS_NUM 2
+#define DEFAULT_AUDIO_BIT_PER_SAMPLE 16
+
+#define INPUT_PORT_SUPPORTFORMAT_NUM_MAX 1
+#define OUTPUT_PORT_SUPPORTFORMAT_NUM_MAX 1
+
+typedef struct _SRP_DEC_INPUT_BUFFER
+{
+ void *PhyAddr; // physical address
+ void *VirAddr; // virtual address
+ int bufferSize; // input buffer alloc size
+ int dataSize; // Data length
+} SRP_DEC_INPUT_BUFFER;
+
+typedef struct _SEC_OMX_AUDIODEC_COMPONENT
+{
+ OMX_HANDLETYPE hCodecHandle;
+
+ OMX_BOOL bFirstFrame;
+ OMX_PTR pInputBuffer;
+ SRP_DEC_INPUT_BUFFER SRPDecInputBuffer[MAX_AUDIO_INPUTBUFFER_NUM];
+ OMX_U32 indexInputBuffer;
+} SEC_OMX_AUDIODEC_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_AudioDecodeGetParameter(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_INDEXTYPE nParamIndex,
+ OMX_INOUT OMX_PTR ComponentParameterStructure);
+OMX_ERRORTYPE SEC_OMX_AudioDecodeSetParameter(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_INDEXTYPE nIndex,
+ OMX_IN OMX_PTR ComponentParameterStructure);
+OMX_ERRORTYPE SEC_OMX_AudioDecodeGetConfig(
+ OMX_HANDLETYPE hComponent,
+ OMX_INDEXTYPE nIndex,
+ OMX_PTR pComponentConfigStructure);
+OMX_ERRORTYPE SEC_OMX_AudioDecodeSetConfig(
+ OMX_HANDLETYPE hComponent,
+ OMX_INDEXTYPE nIndex,
+ OMX_PTR pComponentConfigStructure);
+OMX_ERRORTYPE SEC_OMX_AudioDecodeGetExtensionIndex(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_STRING cParameterName,
+ OMX_OUT OMX_INDEXTYPE *pIndexType);
+OMX_ERRORTYPE SEC_OMX_AudioDecodeComponentInit(OMX_IN OMX_HANDLETYPE hComponent);
+OMX_ERRORTYPE SEC_OMX_AudioDecodeComponentDeinit(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 /* SEC_OMX_AUDIO_DECODE */
diff --git a/exynos4/multimedia/openmax/sec_omx/component/audio/dec/mp3/Android.mk b/exynos4/multimedia/openmax/sec_omx/component/audio/dec/mp3/Android.mk
new file mode 100644
index 0000000..43af655
--- /dev/null
+++ b/exynos4/multimedia/openmax/sec_omx/component/audio/dec/mp3/Android.mk
@@ -0,0 +1,31 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := \
+ SEC_OMX_Mp3dec.c \
+ library_register.c
+
+LOCAL_PRELINK_MODULE := false
+LOCAL_MODULE := libOMX.SEC.MP3.Decoder
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/omx
+
+LOCAL_CFLAGS :=
+
+LOCAL_ARM_MODE := arm
+
+LOCAL_STATIC_LIBRARIES := libSEC_OMX_Adec libsecosal libsecbasecomponent \
+ libsrpapi
+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)/audio/dec \
+ $(TARGET_OUT_HEADERS)/$(SEC_COPY_HEADERS_TO)
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/exynos4/multimedia/openmax/sec_omx/component/audio/dec/mp3/SEC_OMX_Mp3dec.c b/exynos4/multimedia/openmax/sec_omx/component/audio/dec/mp3/SEC_OMX_Mp3dec.c
new file mode 100644
index 0000000..a8c77f6
--- /dev/null
+++ b/exynos4/multimedia/openmax/sec_omx/component/audio/dec/mp3/SEC_OMX_Mp3dec.c
@@ -0,0 +1,918 @@
+/*
+ *
+ * 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_Mp3dec.c
+ * @brief
+ * @author Yunji Kim (yunji.kim@samsung.com)
+ * @version 1.1.0
+ * @history
+ * 2011.10.18 : 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_Adec.h"
+#include "SEC_OSAL_ETC.h"
+#include "SEC_OSAL_Semaphore.h"
+#include "SEC_OSAL_Thread.h"
+#include "library_register.h"
+#include "SEC_OMX_Mp3dec.h"
+#include "srp_api.h"
+
+#undef SEC_LOG_TAG
+#define SEC_LOG_TAG "SEC_MP3_DEC"
+#define SEC_LOG_OFF
+#include "SEC_OSAL_Log.h"
+
+//#define SRP_DUMP_TO_FILE
+#ifdef SRP_DUMP_TO_FILE
+#include "stdio.h"
+
+FILE *inFile;
+FILE *outFile;
+#endif
+
+OMX_ERRORTYPE SEC_SRP_Mp3Dec_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_IndexParamAudioMp3:
+ {
+ OMX_AUDIO_PARAM_MP3TYPE *pDstMp3Param = (OMX_AUDIO_PARAM_MP3TYPE *)pComponentParameterStructure;
+ OMX_AUDIO_PARAM_MP3TYPE *pSrcMp3Param = NULL;
+ SEC_MP3_HANDLE *pMp3Dec = NULL;
+
+ ret = SEC_OMX_Check_SizeVersion(pDstMp3Param, sizeof(OMX_AUDIO_PARAM_MP3TYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pDstMp3Param->nPortIndex >= ALL_PORT_NUM) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ pMp3Dec = (SEC_MP3_HANDLE *)((SEC_OMX_AUDIODEC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ pSrcMp3Param = &pMp3Dec->mp3Param;
+
+ SEC_OSAL_Memcpy(pDstMp3Param, pSrcMp3Param, sizeof(OMX_AUDIO_PARAM_MP3TYPE));
+ }
+ break;
+ case OMX_IndexParamAudioPcm:
+ {
+ OMX_AUDIO_PARAM_PCMMODETYPE *pDstPcmParam = (OMX_AUDIO_PARAM_PCMMODETYPE *)pComponentParameterStructure;
+ OMX_AUDIO_PARAM_PCMMODETYPE *pSrcPcmParam = NULL;
+ SEC_MP3_HANDLE *pMp3Dec = NULL;
+
+ ret = SEC_OMX_Check_SizeVersion(pDstPcmParam, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pDstPcmParam->nPortIndex >= ALL_PORT_NUM) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ pMp3Dec = (SEC_MP3_HANDLE *)((SEC_OMX_AUDIODEC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ pSrcPcmParam = &pMp3Dec->pcmParam;
+
+ SEC_OSAL_Memcpy(pDstPcmParam, pSrcPcmParam, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
+ }
+ 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;
+ }
+
+ SEC_OSAL_Strcpy((char *)pComponentRole->cRole, SEC_OMX_COMPONENT_MP3_DEC_ROLE);
+ }
+ break;
+ default:
+ ret = SEC_OMX_AudioDecodeGetParameter(hComponent, nParamIndex, pComponentParameterStructure);
+ break;
+ }
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_SRP_Mp3Dec_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_IndexParamAudioMp3:
+ {
+ OMX_AUDIO_PARAM_MP3TYPE *pDstMp3Param = NULL;
+ OMX_AUDIO_PARAM_MP3TYPE *pSrcMp3Param = (OMX_AUDIO_PARAM_MP3TYPE *)pComponentParameterStructure;
+ SEC_MP3_HANDLE *pMp3Dec = NULL;
+
+ ret = SEC_OMX_Check_SizeVersion(pSrcMp3Param, sizeof(OMX_AUDIO_PARAM_MP3TYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pSrcMp3Param->nPortIndex >= ALL_PORT_NUM) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ pMp3Dec = (SEC_MP3_HANDLE *)((SEC_OMX_AUDIODEC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ pDstMp3Param = &pMp3Dec->mp3Param;
+
+ SEC_OSAL_Memcpy(pDstMp3Param, pSrcMp3Param, sizeof(OMX_AUDIO_PARAM_MP3TYPE));
+ }
+ break;
+ case OMX_IndexParamAudioPcm:
+ {
+ OMX_AUDIO_PARAM_PCMMODETYPE *pDstPcmParam = NULL;
+ OMX_AUDIO_PARAM_PCMMODETYPE *pSrcPcmParam = (OMX_AUDIO_PARAM_PCMMODETYPE *)pComponentParameterStructure;
+ SEC_MP3_HANDLE *pMp3Dec = NULL;
+
+ ret = SEC_OMX_Check_SizeVersion(pSrcPcmParam, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ if (pSrcPcmParam->nPortIndex >= ALL_PORT_NUM) {
+ ret = OMX_ErrorBadPortIndex;
+ goto EXIT;
+ }
+
+ pMp3Dec = (SEC_MP3_HANDLE *)((SEC_OMX_AUDIODEC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ pDstPcmParam = &pMp3Dec->pcmParam;
+
+ SEC_OSAL_Memcpy(pDstPcmParam, pSrcPcmParam, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
+ }
+ 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_MP3_DEC_ROLE)) {
+ pSECComponent->pSECPort[INPUT_PORT_INDEX].portDefinition.format.audio.eEncoding = OMX_AUDIO_CodingMP3;
+ } else {
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ }
+ break;
+ default:
+ ret = SEC_OMX_AudioDecodeSetParameter(hComponent, nIndex, pComponentParameterStructure);
+ break;
+ }
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_SRP_Mp3Dec_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_AudioDecodeGetConfig(hComponent, nIndex, pComponentConfigStructure);
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_SRP_Mp3Dec_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_AudioDecodeSetConfig(hComponent, nIndex, pComponentConfigStructure);
+ break;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_SRP_Mp3Dec_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;
+ }
+
+ ret = SEC_OMX_AudioDecodeGetExtensionIndex(hComponent, cParameterName, pIndexType);
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_SRP_Mp3Dec_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;
+ }
+
+ SEC_OSAL_Strcpy((char *)cRole, SEC_OMX_COMPONENT_MP3_DEC_ROLE);
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_SRP_Mp3Dec_Init(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ SEC_OMX_AUDIODEC_COMPONENT *pAudioDec = (SEC_OMX_AUDIODEC_COMPONENT *)pSECComponent->hComponentHandle;
+ SEC_MP3_HANDLE *pMp3Dec = (SEC_MP3_HANDLE *)pAudioDec->hCodecHandle;
+
+ FunctionIn();
+
+ SEC_OSAL_Memset(pSECComponent->timeStamp, -19771003, sizeof(OMX_TICKS) * MAX_TIMESTAMP);
+ SEC_OSAL_Memset(pSECComponent->nFlags, 0, sizeof(OMX_U32) * MAX_FLAGS);
+ pSECComponent->bUseFlagEOF = OMX_TRUE; /* Mp3 extractor should parse into frame unit. */
+ pSECComponent->bSaveFlagEOS = OMX_FALSE;
+ pMp3Dec->hSRPMp3Handle.bConfiguredSRP = OMX_FALSE;
+ pMp3Dec->hSRPMp3Handle.bSRPSendEOS = OMX_FALSE;
+ pSECComponent->getAllDelayBuffer = OMX_FALSE;
+
+#ifdef SRP_DUMP_TO_FILE
+ inFile = fopen("/data/InFile.mp3", "w+");
+ outFile = fopen("/data/OutFile.pcm", "w+");
+#endif
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_SRP_Mp3Dec_Terminate(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ SEC_OMX_BASECOMPONENT *pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+
+ FunctionIn();
+
+#ifdef SRP_DUMP_TO_FILE
+ fclose(inFile);
+ fclose(outFile);
+#endif
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_SRP_Mp3_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_AUDIODEC_COMPONENT *pAudioDec = (SEC_OMX_AUDIODEC_COMPONENT *)pSECComponent->hComponentHandle;
+ SEC_MP3_HANDLE *pMp3Dec = (SEC_MP3_HANDLE *)pAudioDec->hCodecHandle;
+ struct srp_dec_info codecDecInfo;
+ OMX_S32 returnCodec = 0;
+ unsigned long isSRPStopped = 0;
+ OMX_PTR dataBuffer = NULL;
+ unsigned int dataLen = 0;
+ OMX_BOOL isSRPIbufOverflow = OMX_FALSE;
+
+ FunctionIn();
+
+#ifdef SRP_DUMP_TO_FILE
+ if (pSECComponent->reInputData == OMX_FALSE) {
+ fwrite(pInputData->dataBuffer, pInputData->dataLen, 1, inFile);
+ }
+#endif
+
+ /* Save timestamp and flags of input data */
+ pOutputData->timeStamp = pInputData->timeStamp;
+ pOutputData->nFlags = pInputData->nFlags & (~OMX_BUFFERFLAG_EOS);
+
+ /* Decoding mp3 frames by SRP */
+ if (pSECComponent->getAllDelayBuffer == OMX_FALSE) {
+ returnCodec = SRP_Decode(pInputData->dataBuffer, pInputData->dataLen);
+
+ if (returnCodec >= 0) {
+ if (pInputData->nFlags & OMX_BUFFERFLAG_EOS) {
+ SRP_Send_EOS();
+ pMp3Dec->hSRPMp3Handle.bSRPSendEOS = OMX_TRUE;
+ }
+ } else if (returnCodec == SRP_ERROR_IBUF_OVERFLOW) {
+ isSRPIbufOverflow = OMX_TRUE;
+ ret = OMX_ErrorInputDataDecodeYet;
+ }
+ }
+
+ if (pMp3Dec->hSRPMp3Handle.bConfiguredSRP == OMX_FALSE) {
+ returnCodec = SRP_Get_Dec_Info(&codecDecInfo);
+ if (returnCodec < 0) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "SRP_Get_Dec_Info failed: %d", returnCodec);
+ ret = OMX_ErrorHardware;
+ goto EXIT;
+ }
+
+ if (!codecDecInfo.sample_rate || !codecDecInfo.channels) {
+ if (pMp3Dec->hSRPMp3Handle.bSRPSendEOS == OMX_TRUE) {
+ pOutputData->dataLen = 0;
+ pSECComponent->getAllDelayBuffer = OMX_TRUE;
+ ret = OMX_ErrorInputDataDecodeYet;
+ } else {
+ pSECComponent->getAllDelayBuffer = OMX_FALSE;
+ if (isSRPIbufOverflow)
+ ret = OMX_ErrorInputDataDecodeYet;
+ else
+ ret = OMX_ErrorNone;
+ }
+ goto EXIT;
+ }
+
+ SEC_OSAL_Log(SEC_LOG_TRACE, "numChannels(%d), samplingRate(%d)",
+ codecDecInfo.channels, codecDecInfo.sample_rate);
+
+ if (pMp3Dec->pcmParam.nChannels != codecDecInfo.channels ||
+ pMp3Dec->pcmParam.nSamplingRate != codecDecInfo.sample_rate) {
+ /* Change channel count and sampling rate information */
+ pMp3Dec->pcmParam.nChannels = codecDecInfo.channels;
+ pMp3Dec->pcmParam.nSamplingRate = codecDecInfo.sample_rate;
+
+ /* 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);
+ }
+
+ pMp3Dec->hSRPMp3Handle.bConfiguredSRP = OMX_TRUE;
+
+ if (pMp3Dec->hSRPMp3Handle.bSRPSendEOS == OMX_TRUE) {
+ pOutputData->dataLen = 0;
+ pSECComponent->getAllDelayBuffer = OMX_TRUE;
+ ret = OMX_ErrorInputDataDecodeYet;
+ } else {
+ pSECComponent->getAllDelayBuffer = OMX_FALSE;
+ if (isSRPIbufOverflow)
+ ret = OMX_ErrorInputDataDecodeYet;
+ else
+ ret = OMX_ErrorNone;
+ }
+ goto EXIT;
+ }
+
+ /* Get decoded data from SRP */
+ returnCodec = SRP_Get_PCM(&dataBuffer, &dataLen);
+ if (dataLen > 0) {
+ pOutputData->dataLen = dataLen;
+ SEC_OSAL_Memcpy(pOutputData->dataBuffer, dataBuffer, dataLen);
+ } else {
+ pOutputData->dataLen = 0;
+ }
+
+#ifdef SRP_DUMP_TO_FILE
+ if (pOutputData->dataLen > 0)
+ fwrite(pOutputData->dataBuffer, pOutputData->dataLen, 1, outFile);
+#endif
+
+ /* Delay EOS signal until all the PCM is returned from the SRP driver. */
+ if (pMp3Dec->hSRPMp3Handle.bSRPSendEOS == OMX_TRUE) {
+ if (pInputData->nFlags & OMX_BUFFERFLAG_EOS) {
+ returnCodec = SRP_GetParams(SRP_STOP_EOS_STATE, &isSRPStopped);
+ if (returnCodec != 0)
+ SEC_OSAL_Log(SEC_LOG_ERROR, "Fail SRP_STOP_EOS_STATE");
+ if (isSRPStopped == 1) {
+ pOutputData->nFlags |= OMX_BUFFERFLAG_EOS;
+ pSECComponent->getAllDelayBuffer = OMX_FALSE;
+ pMp3Dec->hSRPMp3Handle.bSRPSendEOS = OMX_FALSE; /* for repeating one song */
+ ret = OMX_ErrorNone;
+ } else {
+ pSECComponent->getAllDelayBuffer = OMX_TRUE;
+ ret = OMX_ErrorInputDataDecodeYet;
+ }
+ } else { /* Flush after EOS */
+ pMp3Dec->hSRPMp3Handle.bSRPSendEOS = OMX_FALSE;
+ }
+ }
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OMX_ERRORTYPE SEC_SRP_Mp3Dec_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))) {
+ if (pInputData->nFlags & OMX_BUFFERFLAG_EOS)
+ ret = OMX_ErrorInputDataDecodeYet;
+ else
+ ret = OMX_ErrorNone;
+
+ goto EXIT;
+ }
+ if (OMX_FALSE == SEC_Check_BufferProcess_State(pSECComponent)) {
+ if (pInputData->nFlags & OMX_BUFFERFLAG_EOS)
+ ret = OMX_ErrorInputDataDecodeYet;
+ else
+ ret = OMX_ErrorNone;
+
+ goto EXIT;
+ }
+
+ ret = SEC_SRP_Mp3_Decode_Block(pOMXComponent, pInputData, pOutputData);
+
+ if (ret != OMX_ErrorNone) {
+ if (ret == OMX_ErrorInputDataDecodeYet) {
+ pOutputData->usedDataLen = 0;
+ pOutputData->remainDataLen = pOutputData->dataLen;
+ } else {
+ pSECComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent,
+ pSECComponent->callbackData,
+ OMX_EventError, ret, 0, NULL);
+ }
+ } else {
+ pInputData->previousDataLen = pInputData->dataLen;
+ pInputData->usedDataLen += pInputData->dataLen;
+ pInputData->remainDataLen = pInputData->dataLen - pInputData->usedDataLen;
+ pInputData->dataLen -= pInputData->usedDataLen;
+ pInputData->usedDataLen = 0;
+
+ pOutputData->usedDataLen = 0;
+ pOutputData->remainDataLen = pOutputData->dataLen;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
+OSCL_EXPORT_REF OMX_ERRORTYPE SEC_OMX_ComponentInit(OMX_HANDLETYPE hComponent, OMX_STRING componentName)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ SEC_OMX_BASECOMPONENT *pSECComponent = NULL;
+ SEC_OMX_BASEPORT *pSECPort = NULL;
+ SEC_OMX_AUDIODEC_COMPONENT *pAudioDec = NULL;
+ SEC_MP3_HANDLE *pMp3Dec = NULL;
+ OMX_PTR pInputBuffer = NULL;
+ OMX_PTR pOutputBuffer = NULL;
+ unsigned int inputBufferSize = 0;
+ unsigned int inputBufferNum = 0;
+ unsigned int outputBufferSize = 0;
+ unsigned int outputBufferNum = 0;
+ OMX_S32 returnCodec;
+ int i = 0;
+
+ FunctionIn();
+
+ if ((hComponent == NULL) || (componentName == NULL)) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "%s: parameters are null, ret: %X", __FUNCTION__, ret);
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+ if (SEC_OSAL_Strcmp(SEC_OMX_COMPONENT_MP3_DEC, componentName) != 0) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "%s: componentName(%s) error, ret: %X", __FUNCTION__, componentName, ret);
+ ret = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ ret = SEC_OMX_AudioDecodeComponentInit(pOMXComponent);
+ if (ret != OMX_ErrorNone) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "%s: SEC_OMX_AudioDecodeComponentInit error, ret: %X", __FUNCTION__, ret);
+ goto EXIT;
+ }
+ pSECComponent = (SEC_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ pSECComponent->codecType = HW_AUDIO_DEC_CODEC;
+
+ pSECComponent->componentName = (OMX_STRING)SEC_OSAL_Malloc(MAX_OMX_COMPONENT_NAME_SIZE);
+ if (pSECComponent->componentName == NULL) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "%s: componentName alloc error, ret: %X", __FUNCTION__, ret);
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT_ERROR_1;
+ }
+ SEC_OSAL_Memset(pSECComponent->componentName, 0, MAX_OMX_COMPONENT_NAME_SIZE);
+ SEC_OSAL_Strcpy(pSECComponent->componentName, SEC_OMX_COMPONENT_MP3_DEC);
+
+ pMp3Dec = SEC_OSAL_Malloc(sizeof(SEC_MP3_HANDLE));
+ if (pMp3Dec == NULL) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "%s: SEC_MP3_HANDLE alloc error, ret: %X", __FUNCTION__, ret);
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT_ERROR_2;
+ }
+ SEC_OSAL_Memset(pMp3Dec, 0, sizeof(SEC_MP3_HANDLE));
+ pAudioDec = (SEC_OMX_AUDIODEC_COMPONENT *)pSECComponent->hComponentHandle;
+ pAudioDec->hCodecHandle = (OMX_HANDLETYPE)pMp3Dec;
+
+ /* Create and Init SRP */
+ pMp3Dec->hSRPMp3Handle.bSRPLoaded = OMX_FALSE;
+ returnCodec = SRP_Create(SRP_INIT_BLOCK_MODE);
+ if (returnCodec < 0) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "SRP_Create failed: %d", returnCodec);
+ ret = OMX_ErrorHardware;
+ goto EXIT_ERROR_3;
+ }
+ pMp3Dec->hSRPMp3Handle.hSRPHandle = (OMX_HANDLETYPE)returnCodec; /* SRP's fd */
+ returnCodec = SRP_Init();
+ if (returnCodec < 0) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "SRP_Init failed: %d", returnCodec);
+ ret = OMX_ErrorHardware;
+ goto EXIT_ERROR_4;
+ }
+ pMp3Dec->hSRPMp3Handle.bSRPLoaded = OMX_TRUE;
+
+ /* Get input buffer info from SRP */
+ returnCodec = SRP_Get_Ibuf_Info(&pInputBuffer, &inputBufferSize, &inputBufferNum);
+ if (returnCodec < 0) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "SRP_Get_Ibuf_Info failed: %d", returnCodec);
+ ret = OMX_ErrorHardware;
+ goto EXIT_ERROR_5;
+ }
+
+ pSECComponent->processData[INPUT_PORT_INDEX].allocSize = inputBufferSize;
+ pSECComponent->processData[INPUT_PORT_INDEX].dataBuffer = SEC_OSAL_Malloc(inputBufferSize);
+ if (pSECComponent->processData[INPUT_PORT_INDEX].dataBuffer == NULL) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "Input data buffer alloc failed");
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT_ERROR_5;
+ }
+
+ /* Get output buffer info from SRP */
+ returnCodec = SRP_Get_Obuf_Info(&pOutputBuffer, &outputBufferSize, &outputBufferNum);
+ if (returnCodec < 0) {
+ SEC_OSAL_Log(SEC_LOG_ERROR, "SRP_Get_Obuf_Info failed: %d", returnCodec);
+ ret = OMX_ErrorHardware;
+ goto EXIT_ERROR_6;
+ }
+
+ /* 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;
+
+ /* Input port */
+ pSECPort = &pSECComponent->pSECPort[INPUT_PORT_INDEX];
+ pSECPort->portDefinition.nBufferCountActual = inputBufferNum;
+ pSECPort->portDefinition.nBufferCountMin = inputBufferNum;
+ pSECPort->portDefinition.nBufferSize = inputBufferSize;
+ pSECPort->portDefinition.bEnabled = OMX_TRUE;
+ SEC_OSAL_Memset(pSECPort->portDefinition.format.audio.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE);
+ SEC_OSAL_Strcpy(pSECPort->portDefinition.format.audio.cMIMEType, "audio/mpeg");
+ pSECPort->portDefinition.format.audio.pNativeRender = 0;
+ pSECPort->portDefinition.format.audio.bFlagErrorConcealment = OMX_FALSE;
+ pSECPort->portDefinition.format.audio.eEncoding = OMX_AUDIO_CodingMP3;
+
+ /* Output port */
+ pSECPort = &pSECComponent->pSECPort[OUTPUT_PORT_INDEX];
+ pSECPort->portDefinition.nBufferCountActual = outputBufferNum;
+ pSECPort->portDefinition.nBufferCountMin = outputBufferNum;
+ pSECPort->portDefinition.nBufferSize = outputBufferSize;
+ pSECPort->portDefinition.bEnabled = OMX_TRUE;
+ SEC_OSAL_Memset(pSECPort->portDefinition.format.audio.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE);
+ SEC_OSAL_Strcpy(pSECPort->portDefinition.format.audio.cMIMEType, "audio/raw");
+ pSECPort->portDefinition.format.audio.pNativeRender = 0;
+ pSECPort->portDefinition.format.audio.bFlagErrorConcealment = OMX_FALSE;
+ pSECPort->portDefinition.format.audio.eEncoding = OMX_AUDIO_CodingPCM;
+
+ /* Default values for Mp3 audio param */
+ INIT_SET_SIZE_VERSION(&pMp3Dec->mp3Param, OMX_AUDIO_PARAM_MP3TYPE);
+ pMp3Dec->mp3Param.nPortIndex = INPUT_PORT_INDEX;
+ pMp3Dec->mp3Param.nChannels = DEFAULT_AUDIO_CHANNELS_NUM;
+ pMp3Dec->mp3Param.nBitRate = 0;
+ pMp3Dec->mp3Param.nSampleRate = DEFAULT_AUDIO_SAMPLING_FREQ;
+ pMp3Dec->mp3Param.nAudioBandWidth = 0;
+ pMp3Dec->mp3Param.eChannelMode = OMX_AUDIO_ChannelModeStereo;
+ pMp3Dec->mp3Param.eFormat = OMX_AUDIO_MP3StreamFormatMP1Layer3;
+
+ /* Default values for PCM audio param */
+ INIT_SET_SIZE_VERSION(&pMp3Dec->pcmParam, OMX_AUDIO_PARAM_PCMMODETYPE);
+ pMp3Dec->pcmParam.nPortIndex = OUTPUT_PORT_INDEX;
+ pMp3Dec->pcmParam.nChannels = DEFAULT_AUDIO_CHANNELS_NUM;
+ pMp3Dec->pcmParam.eNumData = OMX_NumericalDataSigned;
+ pMp3Dec->pcmParam.eEndian = OMX_EndianLittle;
+ pMp3Dec->pcmParam.bInterleaved = OMX_TRUE;
+ pMp3Dec->pcmParam.nBitPerSample = DEFAULT_AUDIO_BIT_PER_SAMPLE;
+ pMp3Dec->pcmParam.nSamplingRate = DEFAULT_AUDIO_SAMPLING_FREQ;
+ pMp3Dec->pcmParam.ePCMMode = OMX_AUDIO_PCMModeLinear;
+ pMp3Dec->pcmParam.eChannelMapping[0] = OMX_AUDIO_ChannelLF;
+ pMp3Dec->pcmParam.eChannelMapping[1] = OMX_AUDIO_ChannelRF;
+
+ pOMXComponent->GetParameter = &SEC_SRP_Mp3Dec_GetParameter;
+ pOMXComponent->SetParameter = &SEC_SRP_Mp3Dec_SetParameter;
+ pOMXComponent->GetConfig = &SEC_SRP_Mp3Dec_GetConfig;
+ pOMXComponent->SetConfig = &SEC_SRP_Mp3Dec_SetConfig;
+ pOMXComponent->GetExtensionIndex = &SEC_SRP_Mp3Dec_GetExtensionIndex;
+ pOMXComponent->ComponentRoleEnum = &SEC_SRP_Mp3Dec_ComponentRoleEnum;
+ pOMXComponent->ComponentDeInit = &SEC_OMX_ComponentDeinit;
+
+ /* ToDo: Change the function name associated with a specific codec */
+ pSECComponent->sec_mfc_componentInit = &SEC_SRP_Mp3Dec_Init;
+ pSECComponent->sec_mfc_componentTerminate = &SEC_SRP_Mp3Dec_Terminate;
+ pSECComponent->sec_mfc_bufferProcess = &SEC_SRP_Mp3Dec_bufferProcess;
+ pSECComponent->sec_checkInputFrame = NULL;
+
+ pSECComponent->currentState = OMX_StateLoaded;
+
+ ret = OMX_ErrorNone;
+ goto EXIT; /* This function is performed successfully. */
+
+EXIT_ERROR_6:
+ SEC_OSAL_Free(pSECComponent->processData[INPUT_PORT_INDEX].dataBuffer);
+ pSECComponent->processData[INPUT_PORT_INDEX].dataBuffer = NULL;
+ pSECComponent->processData[INPUT_PORT_INDEX].allocSize = 0;
+EXIT_ERROR_5:
+ SRP_Deinit();
+EXIT_ERROR_4:
+ SRP_Terminate();
+EXIT_ERROR_3:
+ SEC_OSAL_Free(pMp3Dec);
+ pAudioDec->hCodecHandle = NULL;
+EXIT_ERROR_2:
+ SEC_OSAL_Free(pSECComponent->componentName);
+ pSECComponent->componentName = NULL;
+EXIT_ERROR_1:
+ SEC_OMX_AudioDecodeComponentDeinit(pOMXComponent);
+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_MP3_HANDLE *pMp3Dec = 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;
+ if (pSECComponent->processData[INPUT_PORT_INDEX].dataBuffer) {
+ SEC_OSAL_Free(pSECComponent->processData[INPUT_PORT_INDEX].dataBuffer);
+ pSECComponent->processData[INPUT_PORT_INDEX].dataBuffer = NULL;
+ pSECComponent->processData[INPUT_PORT_INDEX].allocSize = 0;
+ }
+
+ pMp3Dec = (SEC_MP3_HANDLE *)((SEC_OMX_AUDIODEC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle;
+ if (pMp3Dec != NULL) {
+ if (pMp3Dec->hSRPMp3Handle.bSRPLoaded == OMX_TRUE) {
+ SRP_Deinit();
+ SRP_Terminate();
+ }
+ SEC_OSAL_Free(pMp3Dec);
+ ((SEC_OMX_AUDIODEC_COMPONENT *)pSECComponent->hComponentHandle)->hCodecHandle = NULL;
+ }
+
+ ret = SEC_OMX_AudioDecodeComponentDeinit(pOMXComponent);
+ if (ret != OMX_ErrorNone) {
+ goto EXIT;
+ }
+
+ ret = OMX_ErrorNone;
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
diff --git a/exynos4/multimedia/openmax/sec_omx/component/audio/dec/mp3/SEC_OMX_Mp3dec.h b/exynos4/multimedia/openmax/sec_omx/component/audio/dec/mp3/SEC_OMX_Mp3dec.h
new file mode 100644
index 0000000..a8b80f5
--- /dev/null
+++ b/exynos4/multimedia/openmax/sec_omx/component/audio/dec/mp3/SEC_OMX_Mp3dec.h
@@ -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 SEC_OMX_Mp3dec.h
+ * @brief
+ * @author Yunji Kim (yunji.kim@samsung.com)
+ * @version 1.1.0
+ * @history
+ * 2011.10.18 : Create
+ */
+
+#ifndef SEC_OMX_MP3_DEC_COMPONENT
+#define SEC_OMX_MP3_DEC_COMPONENT
+
+#include "SEC_OMX_Def.h"
+#include "OMX_Component.h"
+
+typedef struct _SEC_SRP_MP3_HANDLE
+{
+ OMX_HANDLETYPE hSRPHandle;
+ OMX_BOOL bConfiguredSRP;
+ OMX_BOOL bSRPLoaded;
+ OMX_BOOL bSRPSendEOS;
+ OMX_S32 returnCodec;
+} SEC_SRP_MP3_HANDLE;
+
+typedef struct _SEC_MP3_HANDLE
+{
+ /* OMX Codec specific */
+ OMX_AUDIO_PARAM_MP3TYPE mp3Param;
+ OMX_AUDIO_PARAM_PCMMODETYPE pcmParam;
+
+ /* SEC SRP Codec specific */
+ SEC_SRP_MP3_HANDLE hSRPMp3Handle;
+} SEC_MP3_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 /* SEC_OMX_MP3_DEC_COMPONENT */
diff --git a/exynos4/multimedia/openmax/sec_omx/component/audio/dec/mp3/library_register.c b/exynos4/multimedia/openmax/sec_omx/component/audio/dec/mp3/library_register.c
new file mode 100644
index 0000000..c94377a
--- /dev/null
+++ b/exynos4/multimedia/openmax/sec_omx/component/audio/dec/mp3/library_register.c
@@ -0,0 +1,58 @@
+/*
+ *
+ * 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
+ * 2011.10.18 : 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_MP3_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 - audio decoder MP3 */
+ SEC_OSAL_Strcpy(ppSECComponent[0]->componentName, SEC_OMX_COMPONENT_MP3_DEC);
+ SEC_OSAL_Strcpy(ppSECComponent[0]->roles[0], SEC_OMX_COMPONENT_MP3_DEC_ROLE);
+ ppSECComponent[0]->totalRoleNum = MAX_COMPONENT_ROLE_NUM;
+
+EXIT:
+ FunctionOut();
+ return MAX_COMPONENT_NUM;
+}
+
diff --git a/exynos4/multimedia/openmax/sec_omx/component/audio/dec/mp3/library_register.h b/exynos4/multimedia/openmax/sec_omx/component/audio/dec/mp3/library_register.h
new file mode 100644
index 0000000..90ae8c2
--- /dev/null
+++ b/exynos4/multimedia/openmax/sec_omx/component/audio/dec/mp3/library_register.h
@@ -0,0 +1,54 @@
+/*
+ *
+ * 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
+ * 2011.10.18 : Create
+ */
+
+#ifndef SEC_OMX_MP3_DEC_REG
+#define SEC_OMX_MP3_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
+
+/* MP3 */
+#define SEC_OMX_COMPONENT_MP3_DEC "OMX.SEC.MP3.Decoder"
+#define SEC_OMX_COMPONENT_MP3_DEC_ROLE "audio_decoder.mp3"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+OSCL_EXPORT_REF int SEC_OMX_COMPONENT_Library_Register(SECRegisterComponentType **ppSECComponent);
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif /* SEC_OMX_MP3_DEC_REG */
+