From e4e150b8d31a35d8bd36ecdb5e238a47f3e218c4 Mon Sep 17 00:00:00 2001 From: Huisung Kang Date: Mon, 29 Oct 2012 12:55:59 +0900 Subject: [PATCH] code cleanup Change-Id: I8627745966029678d9de77f8665e993f94972787 Signed-off-by: Huisung Kang --- component/common/Exynos_OMX_Basecomponent.c | 2 +- component/common/Exynos_OMX_Baseport.c | 6 +- component/common/Exynos_OMX_Baseport.h | 6 +- component/common/Exynos_OMX_Resourcemanager.c | 2 +- component/video/dec/Exynos_OMX_Vdec.c | 24 +- component/video/dec/Exynos_OMX_Vdec.h | 1 - component/video/dec/Exynos_OMX_VdecControl.c | 12 +- component/video/dec/h264/Exynos_OMX_H264dec.c | 11 +- component/video/dec/h264/library_register.h | 4 +- .../video/dec/mpeg4/Exynos_OMX_Mpeg4dec.c | 2 +- component/video/dec/vp8/Exynos_OMX_Vp8dec.c | 2 +- component/video/enc/Exynos_OMX_Venc.c | 19 +- component/video/enc/Exynos_OMX_Venc.h | 1 - component/video/enc/Exynos_OMX_VencControl.c | 1277 ++++++++++------- component/video/enc/Exynos_OMX_VencControl.h | 32 +- component/video/enc/h264/Exynos_OMX_H264enc.c | 27 +- component/video/enc/h264/Exynos_OMX_H264enc.h | 2 + component/video/enc/h264/library_register.h | 2 +- .../video/enc/mpeg4/Exynos_OMX_Mpeg4enc.c | 27 +- .../video/enc/mpeg4/Exynos_OMX_Mpeg4enc.h | 2 + osal/Exynos_OSAL_Android.cpp | 3 +- osal/Exynos_OSAL_Queue.c | 2 +- osal/Exynos_OSAL_SharedMemory.c | 1 - 23 files changed, 847 insertions(+), 620 deletions(-) diff --git a/component/common/Exynos_OMX_Basecomponent.c b/component/common/Exynos_OMX_Basecomponent.c index 252cdb2..8f1c185 100644 --- a/component/common/Exynos_OMX_Basecomponent.c +++ b/component/common/Exynos_OMX_Basecomponent.c @@ -297,7 +297,7 @@ OMX_ERRORTYPE Exynos_OMX_ComponentStateSet(OMX_COMPONENTTYPE *pOMXComponent, OMX pExynosPort = (pExynosComponent->pExynosPort + i); if (CHECK_PORT_TUNNELED(pExynosPort) && CHECK_PORT_BUFFER_SUPPLIER(pExynosPort)) { while (Exynos_OSAL_GetElemNum(&pExynosPort->bufferQ) > 0) { - message = (EXYNOS_OMX_MESSAGE*)Exynos_OSAL_Dequeue(&pExynosPort->bufferQ); + message = (EXYNOS_OMX_MESSAGE *)Exynos_OSAL_Dequeue(&pExynosPort->bufferQ); if (message != NULL) Exynos_OSAL_Free(message); } diff --git a/component/common/Exynos_OMX_Baseport.c b/component/common/Exynos_OMX_Baseport.c index 9c0c42d..9ed041d 100644 --- a/component/common/Exynos_OMX_Baseport.c +++ b/component/common/Exynos_OMX_Baseport.c @@ -652,7 +652,7 @@ OMX_ERRORTYPE Exynos_OMX_Port_Constructor(OMX_HANDLETYPE hComponent) /* Output Port */ pExynosOutputPort = &pExynosPort[OUTPUT_PORT_INDEX]; - Exynos_OSAL_QueueCreate(&pExynosOutputPort->bufferQ, MAX_QUEUE_ELEMENTS); /* For in case of "Output Buffer Share", MAX ELEMENTS(DPB + EDPB) */ + Exynos_OSAL_QueueCreate(&pExynosOutputPort->bufferQ, MAX_QUEUE_ELEMENTS); /* For in case of "Output Buffer Share", MAX ELEMENTS(DPB + EDPB) */ pExynosOutputPort->extendBufferHeader = Exynos_OSAL_Malloc(sizeof(EXYNOS_OMX_BUFFERHEADERTYPE) * MAX_BUFFER_NUM); if (pExynosOutputPort->extendBufferHeader == NULL) { @@ -774,8 +774,8 @@ EXIT: OMX_ERRORTYPE Exynos_OMX_Port_Destructor(OMX_HANDLETYPE hComponent) { - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; EXYNOS_OMX_BASEPORT *pExynosPort = NULL; diff --git a/component/common/Exynos_OMX_Baseport.h b/component/common/Exynos_OMX_Baseport.h index 165bbf2..49eb218 100644 --- a/component/common/Exynos_OMX_Baseport.h +++ b/component/common/Exynos_OMX_Baseport.h @@ -76,14 +76,14 @@ typedef void* CODEC_EXTRA_BUFFERINFO; typedef struct _EXYNOS_OMX_SINGLEPLANE_DATA { OMX_PTR dataBuffer; - int fd; + int fd; } EXYNOS_OMX_SINGLEPLANE_DATA; typedef struct _EXYNOS_OMX_MULTIPLANE_DATA { OMX_U32 validPlaneNum; OMX_PTR dataBuffer[MAX_BUFFER_PLANE]; - int fd[MAX_BUFFER_PLANE]; + int fd[MAX_BUFFER_PLANE]; } EXYNOS_OMX_MULTIPLANE_DATA; typedef struct _EXYNOS_OMX_DATA @@ -100,7 +100,7 @@ typedef struct _EXYNOS_OMX_DATA OMX_TICKS timeStamp; OMX_PTR pPrivate; CODEC_EXTRA_BUFFERINFO extInfo; - + /* For Share Buffer */ OMX_BUFFERHEADERTYPE* bufferHeader; } EXYNOS_OMX_DATA; diff --git a/component/common/Exynos_OMX_Resourcemanager.c b/component/common/Exynos_OMX_Resourcemanager.c index e8be83b..15cdb16 100644 --- a/component/common/Exynos_OMX_Resourcemanager.c +++ b/component/common/Exynos_OMX_Resourcemanager.c @@ -372,7 +372,7 @@ OMX_ERRORTYPE Exynos_OMX_Release_Resource(OMX_COMPONENTTYPE *pOMXComponent) Exynos_OSAL_MutexLock(ghVideoRMComponentListMutex); pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - + if (pExynosComponent->codecType == HW_VIDEO_DEC_CODEC) { pComponentTemp = gpVideoDecRMWaitingList; if (gpVideoDecRMComponentList == NULL) { diff --git a/component/video/dec/Exynos_OMX_Vdec.c b/component/video/dec/Exynos_OMX_Vdec.c index b7e0980..224e8f6 100644 --- a/component/video/dec/Exynos_OMX_Vdec.c +++ b/component/video/dec/Exynos_OMX_Vdec.c @@ -38,12 +38,14 @@ #include "Exynos_OSAL_Semaphore.h" #include "Exynos_OSAL_Mutex.h" #include "Exynos_OSAL_ETC.h" -#include "csc.h" #ifdef USE_ANB #include "Exynos_OSAL_Android.h" #endif +#include "ExynosVideoApi.h" +#include "csc.h" + #undef EXYNOS_LOG_TAG #define EXYNOS_LOG_TAG "EXYNOS_VIDEO_DEC" #define EXYNOS_LOG_OFF @@ -199,13 +201,13 @@ void Exynos_Wait_ProcessPause(EXYNOS_OMX_BASECOMPONENT *pExynosComponent, OMX_U3 OMX_BOOL Exynos_CSC_OutputData(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *dstOutputData) { - OMX_BOOL ret = OMX_FALSE; - EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle; - EXYNOS_OMX_BASEPORT *exynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; - EXYNOS_OMX_DATABUFFER *outputUseBuffer = &exynosOutputPort->way.port2WayDataBuffer.outputDataBuffer; - OMX_U32 copySize = 0; - DECODE_CODEC_EXTRA_BUFFERINFO *pBufferInfo = NULL; + OMX_BOOL ret = OMX_FALSE; + EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle; + EXYNOS_OMX_BASEPORT *exynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; + EXYNOS_OMX_DATABUFFER *outputUseBuffer = &exynosOutputPort->way.port2WayDataBuffer.outputDataBuffer; + OMX_U32 copySize = 0; + DECODE_CODEC_EXTRA_BUFFERINFO *pBufferInfo = NULL; FunctionIn(); @@ -624,7 +626,7 @@ OMX_ERRORTYPE Exynos_OMX_SrcOutputBufferProcess(OMX_HANDLETYPE hComponent) EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle; EXYNOS_OMX_BASEPORT *exynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; EXYNOS_OMX_DATABUFFER *srcOutputUseBuffer = &exynosInputPort->way.port2WayDataBuffer.outputDataBuffer; - EXYNOS_OMX_DATA srcOutputData; + EXYNOS_OMX_DATA srcOutputData; FunctionIn(); @@ -677,7 +679,7 @@ OMX_ERRORTYPE Exynos_OMX_DstInputBufferProcess(OMX_HANDLETYPE hComponent) EXYNOS_OMX_BASEPORT *exynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; EXYNOS_OMX_DATABUFFER *dstInputUseBuffer = &exynosOutputPort->way.port2WayDataBuffer.inputDataBuffer; EXYNOS_OMX_DATA dstInputData; - + FunctionIn(); while (!pVideoDec->bExitBufferProcessThread) { @@ -757,7 +759,7 @@ OMX_ERRORTYPE Exynos_OMX_DstOutputBufferProcess(OMX_HANDLETYPE hComponent) EXYNOS_OMX_BASEPORT *exynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; EXYNOS_OMX_DATABUFFER *dstOutputUseBuffer = &exynosOutputPort->way.port2WayDataBuffer.outputDataBuffer; EXYNOS_OMX_DATA *pDstOutputData = &exynosOutputPort->processData; - + FunctionIn(); while (!pVideoDec->bExitBufferProcessThread) { diff --git a/component/video/dec/Exynos_OMX_Vdec.h b/component/video/dec/Exynos_OMX_Vdec.h index 664c899..f701aa5 100644 --- a/component/video/dec/Exynos_OMX_Vdec.h +++ b/component/video/dec/Exynos_OMX_Vdec.h @@ -34,7 +34,6 @@ #include "Exynos_OSAL_Queue.h" #include "Exynos_OMX_Baseport.h" #include "Exynos_OMX_Basecomponent.h" -#include "ExynosVideoApi.h" #define MAX_VIDEO_INPUTBUFFER_NUM 5 #define MAX_VIDEO_OUTPUTBUFFER_NUM 2 diff --git a/component/video/dec/Exynos_OMX_VdecControl.c b/component/video/dec/Exynos_OMX_VdecControl.c index 0fe109b..6d8d948 100644 --- a/component/video/dec/Exynos_OMX_VdecControl.c +++ b/component/video/dec/Exynos_OMX_VdecControl.c @@ -37,13 +37,13 @@ #include "Exynos_OSAL_Mutex.h" #include "Exynos_OSAL_ETC.h" #include "Exynos_OSAL_SharedMemory.h" -#include "Exynos_OSAL_Queue.h" -#include "csc.h" #ifdef USE_ANB #include "Exynos_OSAL_Android.h" #endif +#include "ExynosVideoApi.h" + #undef EXYNOS_LOG_TAG #define EXYNOS_LOG_TAG "EXYNOS_VIDEO_DECCONTROL" #define EXYNOS_LOG_OFF @@ -1141,8 +1141,8 @@ OMX_ERRORTYPE Exynos_OMX_VideoDecodeGetParameter( case OMX_IndexParamPortDefinition: { OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = (OMX_PARAM_PORTDEFINITIONTYPE *)ComponentParameterStructure; - OMX_U32 portIndex = portDefinition->nPortIndex; - EXYNOS_OMX_BASEPORT *pExynosPort; + OMX_U32 portIndex = portDefinition->nPortIndex; + EXYNOS_OMX_BASEPORT *pExynosPort; ret = Exynos_OMX_GetParameter(hComponent, nParamIndex, ComponentParameterStructure); if (ret != OMX_ErrorNone) { @@ -1241,8 +1241,8 @@ OMX_ERRORTYPE Exynos_OMX_VideoDecodeSetParameter( case OMX_IndexParamPortDefinition: { OMX_PARAM_PORTDEFINITIONTYPE *pPortDefinition = (OMX_PARAM_PORTDEFINITIONTYPE *)ComponentParameterStructure; - OMX_U32 portIndex = pPortDefinition->nPortIndex; - EXYNOS_OMX_BASEPORT *pExynosPort; + OMX_U32 portIndex = pPortDefinition->nPortIndex; + EXYNOS_OMX_BASEPORT *pExynosPort; OMX_U32 width, height, size; OMX_U32 realWidth, realHeight; diff --git a/component/video/dec/h264/Exynos_OMX_H264dec.c b/component/video/dec/h264/Exynos_OMX_H264dec.c index 366c18f..dec8e71 100644 --- a/component/video/dec/h264/Exynos_OMX_H264dec.c +++ b/component/video/dec/h264/Exynos_OMX_H264dec.c @@ -350,7 +350,7 @@ EXIT: OMX_ERRORTYPE H264CodecClose(EXYNOS_H264DEC_HANDLE *pH264Dec) { - OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_ERRORTYPE ret = OMX_ErrorNone; void *hMFCHandle = NULL; ExynosVideoDecOps *pDecOps = NULL; ExynosVideoDecBufferOps *pInbufOps = NULL; @@ -649,7 +649,7 @@ OMX_ERRORTYPE H264CodecSrcSetup(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DAT void *hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle; EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; - OMX_U32 oneFrameSize = pSrcInputData->dataLen; + OMX_U32 oneFrameSize = pSrcInputData->dataLen; ExynosVideoDecOps *pDecOps = pH264Dec->hMFCH264Handle.pDecOps; ExynosVideoDecBufferOps *pInbufOps = pH264Dec->hMFCH264Handle.pInbufOps; @@ -729,11 +729,10 @@ OMX_ERRORTYPE H264CodecSrcSetup(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DAT /* Register input buffer */ for (i = 0; i < pExynosInputPort->portDefinition.nBufferCountActual; i++) { ExynosVideoPlane plane; - if (pVideoDec->bDRMPlayerMode == OMX_FALSE) { - plane.addr = pExynosInputPort->extendBufferHeader[i].OMXBufferHeader->pBuffer; + if (pVideoDec->bDRMPlayerMode == OMX_TRUE) { + plane.addr = Exynos_OSAL_SharedMemory_IONToVirt(pVideoDec->hSharedMemory, pExynosInputPort->extendBufferHeader[i].OMXBufferHeader->pBuffer); } else { - plane.addr = Exynos_OSAL_SharedMemory_IONToVirt(pVideoDec->hSharedMemory, - pExynosInputPort->extendBufferHeader[i].OMXBufferHeader->pBuffer); + plane.addr = pExynosInputPort->extendBufferHeader[i].OMXBufferHeader->pBuffer; } plane.allocSize = pExynosInputPort->extendBufferHeader[i].OMXBufferHeader->nAllocLen; plane.fd = pExynosInputPort->extendBufferHeader[i].buf_fd[0]; diff --git a/component/video/dec/h264/library_register.h b/component/video/dec/h264/library_register.h index 2886068..e727322 100644 --- a/component/video/dec/h264/library_register.h +++ b/component/video/dec/h264/library_register.h @@ -37,8 +37,8 @@ #define MAX_COMPONENT_ROLE_NUM 1 /* H.264 */ -#define EXYNOS_OMX_COMPONENT_H264_DEC "OMX.Exynos.AVC.Decoder" -#define EXYNOS_OMX_COMPONENT_H264_DRM_DEC "OMX.Exynos.AVC.Decoder.secure" +#define EXYNOS_OMX_COMPONENT_H264_DEC "OMX.Exynos.AVC.Decoder" +#define EXYNOS_OMX_COMPONENT_H264_DRM_DEC "OMX.Exynos.AVC.Decoder.secure" #define EXYNOS_OMX_COMPONENT_H264_DEC_ROLE "video_decoder.avc" diff --git a/component/video/dec/mpeg4/Exynos_OMX_Mpeg4dec.c b/component/video/dec/mpeg4/Exynos_OMX_Mpeg4dec.c index 764901f..4bea31b 100644 --- a/component/video/dec/mpeg4/Exynos_OMX_Mpeg4dec.c +++ b/component/video/dec/mpeg4/Exynos_OMX_Mpeg4dec.c @@ -1590,7 +1590,7 @@ OMX_ERRORTYPE Exynos_Mpeg4Dec_Init(OMX_COMPONENTTYPE *pOMXComponent) pExynosComponent->bUseFlagEOF = OMX_TRUE; pExynosComponent->bSaveFlagEOS = OMX_FALSE; - /* H.264 Codec Open */ + /* Mpeg4 Codec Open */ ret = Mpeg4CodecOpen(pMpeg4Dec); if (ret != OMX_ErrorNone) { goto EXIT; diff --git a/component/video/dec/vp8/Exynos_OMX_Vp8dec.c b/component/video/dec/vp8/Exynos_OMX_Vp8dec.c index 247e322..2d4169a 100644 --- a/component/video/dec/vp8/Exynos_OMX_Vp8dec.c +++ b/component/video/dec/vp8/Exynos_OMX_Vp8dec.c @@ -1182,7 +1182,7 @@ OMX_ERRORTYPE Exynos_VP8Dec_Init(OMX_COMPONENTTYPE *pOMXComponent) pExynosComponent->bUseFlagEOF = OMX_TRUE; pExynosComponent->bSaveFlagEOS = OMX_FALSE; - /* H.264 Codec Open */ + /* VP8 Codec Open */ ret = VP8CodecOpen(pVp8Dec); if (ret != OMX_ErrorNone) { goto EXIT; diff --git a/component/video/enc/Exynos_OMX_Venc.c b/component/video/enc/Exynos_OMX_Venc.c index 14a2f65..a5fcd17 100644 --- a/component/video/enc/Exynos_OMX_Venc.c +++ b/component/video/enc/Exynos_OMX_Venc.c @@ -38,10 +38,10 @@ #include "Exynos_OSAL_SharedMemory.h" #include "Exynos_OSAL_Mutex.h" #include "Exynos_OSAL_ETC.h" +#include "ExynosVideoApi.h" #include "csc.h" #ifdef USE_STOREMETADATA -#include #include "Exynos_OSAL_Android.h" #endif @@ -340,6 +340,7 @@ OMX_BOOL Exynos_Preprocessor_InputData(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_ OMX_PTR ppBuf[MAX_BUFFER_PLANE]; OMX_PTR allocSize[MAX_BUFFER_PLANE]; int plane = 0; + if (eColorFormat == OMX_COLOR_FormatAndroidOpaque) { Exynos_OSAL_GetInfoFromMetaData((OMX_BYTE)inputUseBuffer->bufferHeader->pBuffer, ppBuf); ExynosVideoPlane planes[MAX_BUFFER_PLANE]; @@ -593,7 +594,7 @@ OMX_ERRORTYPE Exynos_OMX_ExtensionSetup(OMX_HANDLETYPE hComponent) Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "pVideoEnc->pMFCEncInputBuffer[%d]->pVirAddr[0]: 0x%x", i, pVideoEnc->pMFCEncInputBuffer[i]->pVirAddr[0]); Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "pVideoEnc->pMFCEncInputBuffer[%d]->pVirAddr[1]: 0x%x", i, pVideoEnc->pMFCEncInputBuffer[i]->pVirAddr[1]); - Exynos_CodecBufferEnQueue(pExynosComponent, INPUT_PORT_INDEX, pVideoEnc->pMFCEncInputBuffer[i]); + Exynos_CodecBufferEnqueue(pExynosComponent, INPUT_PORT_INDEX, pVideoEnc->pMFCEncInputBuffer[i]); } } else if (exynosInputPort->bufferProcessType == BUFFER_SHARE) { /*************/ @@ -643,7 +644,7 @@ OMX_ERRORTYPE Exynos_OMX_SrcInputBufferProcess(OMX_HANDLETYPE hComponent) if (exynosInputPort->bufferProcessType & BUFFER_COPY) { OMX_PTR codecBuffer; if ((pSrcInputData->buffer.multiPlaneBuffer.dataBuffer[0] == NULL) || (pSrcInputData->pPrivate == NULL)) { - Exynos_CodecBufferDeQueue(pExynosComponent, INPUT_PORT_INDEX, &codecBuffer); + Exynos_CodecBufferDequeue(pExynosComponent, INPUT_PORT_INDEX, &codecBuffer); if (codecBuffer != NULL) { Exynos_Input_CodecBufferToData(pExynosComponent, codecBuffer, pSrcInputData); } @@ -700,7 +701,7 @@ OMX_ERRORTYPE Exynos_OMX_SrcOutputBufferProcess(OMX_HANDLETYPE hComponent) EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; EXYNOS_OMX_BASEPORT *exynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; EXYNOS_OMX_DATABUFFER *srcOutputUseBuffer = &exynosInputPort->way.port2WayDataBuffer.outputDataBuffer; - EXYNOS_OMX_DATA srcOutputData; + EXYNOS_OMX_DATA srcOutputData; FunctionIn(); @@ -725,7 +726,7 @@ OMX_ERRORTYPE Exynos_OMX_SrcOutputBufferProcess(OMX_HANDLETYPE hComponent) OMX_PTR codecBuffer; codecBuffer = srcOutputData.pPrivate; if (codecBuffer != NULL) - Exynos_CodecBufferEnQueue(pExynosComponent, INPUT_PORT_INDEX, codecBuffer); + Exynos_CodecBufferEnqueue(pExynosComponent, INPUT_PORT_INDEX, codecBuffer); } if (exynosInputPort->bufferProcessType & BUFFER_SHARE) { Exynos_Shared_DataToBuffer(&srcOutputData, srcOutputUseBuffer); @@ -753,7 +754,7 @@ OMX_ERRORTYPE Exynos_OMX_DstInputBufferProcess(OMX_HANDLETYPE hComponent) EXYNOS_OMX_BASEPORT *exynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; EXYNOS_OMX_DATABUFFER *dstInputUseBuffer = &exynosOutputPort->way.port2WayDataBuffer.inputDataBuffer; EXYNOS_OMX_DATA dstInputData; - + FunctionIn(); while (!pVideoEnc->bExitBufferProcessThread) { @@ -772,7 +773,7 @@ OMX_ERRORTYPE Exynos_OMX_DstInputBufferProcess(OMX_HANDLETYPE hComponent) Exynos_OSAL_MutexLock(dstInputUseBuffer->bufferMutex); if (exynosOutputPort->bufferProcessType & BUFFER_COPY) { OMX_PTR codecBuffer; - ret = Exynos_CodecBufferDeQueue(pExynosComponent, OUTPUT_PORT_INDEX, &codecBuffer); + ret = Exynos_CodecBufferDequeue(pExynosComponent, OUTPUT_PORT_INDEX, &codecBuffer); if (ret != OMX_ErrorNone) { Exynos_OSAL_MutexUnlock(dstInputUseBuffer->bufferMutex); break; @@ -820,7 +821,7 @@ OMX_ERRORTYPE Exynos_OMX_DstOutputBufferProcess(OMX_HANDLETYPE hComponent) EXYNOS_OMX_BASEPORT *exynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; EXYNOS_OMX_DATABUFFER *dstOutputUseBuffer = &exynosOutputPort->way.port2WayDataBuffer.outputDataBuffer; EXYNOS_OMX_DATA *pDstOutputData = &exynosOutputPort->processData; - + FunctionIn(); while (!pVideoEnc->bExitBufferProcessThread) { @@ -859,7 +860,7 @@ OMX_ERRORTYPE Exynos_OMX_DstOutputBufferProcess(OMX_HANDLETYPE hComponent) OMX_PTR codecBuffer; codecBuffer = pDstOutputData->pPrivate; if (codecBuffer != NULL) { - Exynos_CodecBufferEnQueue(pExynosComponent, OUTPUT_PORT_INDEX, codecBuffer); + Exynos_CodecBufferEnqueue(pExynosComponent, OUTPUT_PORT_INDEX, codecBuffer); pDstOutputData->pPrivate = NULL; } } diff --git a/component/video/enc/Exynos_OMX_Venc.h b/component/video/enc/Exynos_OMX_Venc.h index cb5f110..7049998 100644 --- a/component/video/enc/Exynos_OMX_Venc.h +++ b/component/video/enc/Exynos_OMX_Venc.h @@ -33,7 +33,6 @@ #include "Exynos_OSAL_Queue.h" #include "Exynos_OMX_Baseport.h" #include "Exynos_OMX_Basecomponent.h" -#include "ExynosVideoApi.h" #define MAX_VIDEO_INPUTBUFFER_NUM 5 #define MAX_VIDEO_OUTPUTBUFFER_NUM 4 diff --git a/component/video/enc/Exynos_OMX_VencControl.c b/component/video/enc/Exynos_OMX_VencControl.c index 8606943..facba5f 100644 --- a/component/video/enc/Exynos_OMX_VencControl.c +++ b/component/video/enc/Exynos_OMX_VencControl.c @@ -57,12 +57,12 @@ OMX_ERRORTYPE Exynos_OMX_UseBuffer( OMX_IN OMX_U32 nSizeBytes, OMX_IN OMX_U8 *pBuffer) { - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; - EXYNOS_OMX_BASEPORT *pExynosPort = NULL; - OMX_BUFFERHEADERTYPE *temp_bufferHeader = NULL; - OMX_U32 i = 0; + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; + EXYNOS_OMX_BASEPORT *pExynosPort = NULL; + OMX_BUFFERHEADERTYPE *pTempBufferHdr = NULL; + OMX_U32 i = 0; FunctionIn(); @@ -71,6 +71,7 @@ OMX_ERRORTYPE Exynos_OMX_UseBuffer( goto EXIT; } pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); if (ret != OMX_ErrorNone) { goto EXIT; @@ -82,11 +83,12 @@ OMX_ERRORTYPE Exynos_OMX_UseBuffer( } pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - pExynosPort = &pExynosComponent->pExynosPort[nPortIndex]; if (nPortIndex >= pExynosComponent->portParam.nPorts) { ret = OMX_ErrorBadPortIndex; goto EXIT; } + pExynosPort = &pExynosComponent->pExynosPort[nPortIndex]; + if (pExynosPort->portState != OMX_StateIdle) { ret = OMX_ErrorIncorrectStateOperation; goto EXIT; @@ -97,25 +99,25 @@ OMX_ERRORTYPE Exynos_OMX_UseBuffer( goto EXIT; } - temp_bufferHeader = (OMX_BUFFERHEADERTYPE *)Exynos_OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE)); - if (temp_bufferHeader == NULL) { + pTempBufferHdr = (OMX_BUFFERHEADERTYPE *)Exynos_OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE)); + if (pTempBufferHdr == NULL) { ret = OMX_ErrorInsufficientResources; goto EXIT; } - Exynos_OSAL_Memset(temp_bufferHeader, 0, sizeof(OMX_BUFFERHEADERTYPE)); + Exynos_OSAL_Memset(pTempBufferHdr, 0, sizeof(OMX_BUFFERHEADERTYPE)); for (i = 0; i < pExynosPort->portDefinition.nBufferCountActual; i++) { if (pExynosPort->bufferStateAllocate[i] == BUFFER_STATE_FREE) { - pExynosPort->extendBufferHeader[i].OMXBufferHeader = temp_bufferHeader; + pExynosPort->extendBufferHeader[i].OMXBufferHeader = pTempBufferHdr; pExynosPort->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; + INIT_SET_SIZE_VERSION(pTempBufferHdr, OMX_BUFFERHEADERTYPE); + pTempBufferHdr->pBuffer = pBuffer; + pTempBufferHdr->nAllocLen = nSizeBytes; + pTempBufferHdr->pAppPrivate = pAppPrivate; if (nPortIndex == INPUT_PORT_INDEX) - temp_bufferHeader->nInputPortIndex = INPUT_PORT_INDEX; + pTempBufferHdr->nInputPortIndex = INPUT_PORT_INDEX; else - temp_bufferHeader->nOutputPortIndex = OUTPUT_PORT_INDEX; + pTempBufferHdr->nOutputPortIndex = OUTPUT_PORT_INDEX; pExynosPort->assignedBufferNum++; if (pExynosPort->assignedBufferNum == pExynosPort->portDefinition.nBufferCountActual) { @@ -124,13 +126,13 @@ OMX_ERRORTYPE Exynos_OMX_UseBuffer( Exynos_OSAL_SemaphorePost(pExynosPort->loadedResource); /* Exynos_OSAL_MutexUnlock(pExynosComponent->compMutex); */ } - *ppBufferHdr = temp_bufferHeader; + *ppBufferHdr = pTempBufferHdr; ret = OMX_ErrorNone; goto EXIT; } } - Exynos_OSAL_Free(temp_bufferHeader); + Exynos_OSAL_Free(pTempBufferHdr); ret = OMX_ErrorInsufficientResources; EXIT: @@ -141,21 +143,21 @@ EXIT: OMX_ERRORTYPE Exynos_OMX_AllocateBuffer( OMX_IN OMX_HANDLETYPE hComponent, - OMX_INOUT OMX_BUFFERHEADERTYPE **ppBuffer, + OMX_INOUT OMX_BUFFERHEADERTYPE **ppBufferHdr, OMX_IN OMX_U32 nPortIndex, OMX_IN OMX_PTR pAppPrivate, OMX_IN OMX_U32 nSizeBytes) { - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; - EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL; - EXYNOS_OMX_BASEPORT *pExynosPort = NULL; - OMX_BUFFERHEADERTYPE *temp_bufferHeader = NULL; - OMX_U8 *temp_buffer = NULL; - int temp_buffer_fd = -1; - OMX_U32 i = 0; - MEMORY_TYPE mem_type; + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; + EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL; + EXYNOS_OMX_BASEPORT *pExynosPort = NULL; + OMX_BUFFERHEADERTYPE *pTempBufferHdr = NULL; + OMX_U8 *pTempBuffer = NULL; + int fdTempBuffer = -1; + MEMORY_TYPE eMemType; + OMX_U32 i = 0; FunctionIn(); @@ -164,6 +166,7 @@ OMX_ERRORTYPE Exynos_OMX_AllocateBuffer( goto EXIT; } pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); if (ret != OMX_ErrorNone) { goto EXIT; @@ -174,13 +177,18 @@ OMX_ERRORTYPE Exynos_OMX_AllocateBuffer( goto EXIT; } pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + + if (pExynosComponent->hComponentHandle == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; - pExynosPort = &pExynosComponent->pExynosPort[nPortIndex]; if (nPortIndex >= pExynosComponent->portParam.nPorts) { ret = OMX_ErrorBadPortIndex; goto EXIT; } + pExynosPort = &pExynosComponent->pExynosPort[nPortIndex]; /* if (pExynosPort->portState != OMX_StateIdle ) { ret = OMX_ErrorIncorrectStateOperation; @@ -192,39 +200,39 @@ OMX_ERRORTYPE Exynos_OMX_AllocateBuffer( goto EXIT; } - if (pExynosPort->bufferProcessType & BUFFER_SHARE) { - mem_type = NORMAL_MEMORY; - } else { - mem_type = SYSTEM_MEMORY; - } - temp_buffer = Exynos_OSAL_SharedMemory_Alloc(pVideoEnc->hSharedMemory, nSizeBytes, mem_type); - if (temp_buffer == NULL) { + if (pExynosPort->bufferProcessType & BUFFER_SHARE) + eMemType = NORMAL_MEMORY; + else + eMemType = SYSTEM_MEMORY; + + pTempBuffer = Exynos_OSAL_SharedMemory_Alloc(pVideoEnc->hSharedMemory, nSizeBytes, eMemType); + if (pTempBuffer == NULL) { ret = OMX_ErrorInsufficientResources; goto EXIT; } - temp_buffer_fd = Exynos_OSAL_SharedMemory_VirtToION(pVideoEnc->hSharedMemory, temp_buffer); + fdTempBuffer = Exynos_OSAL_SharedMemory_VirtToION(pVideoEnc->hSharedMemory, pTempBuffer); - temp_bufferHeader = (OMX_BUFFERHEADERTYPE *)Exynos_OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE)); - if (temp_bufferHeader == NULL) { - Exynos_OSAL_SharedMemory_Free(pVideoEnc->hSharedMemory, temp_buffer); + pTempBufferHdr = (OMX_BUFFERHEADERTYPE *)Exynos_OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE)); + if (pTempBufferHdr == NULL) { + Exynos_OSAL_SharedMemory_Free(pVideoEnc->hSharedMemory, pTempBuffer); ret = OMX_ErrorInsufficientResources; goto EXIT; } - Exynos_OSAL_Memset(temp_bufferHeader, 0, sizeof(OMX_BUFFERHEADERTYPE)); + Exynos_OSAL_Memset(pTempBufferHdr, 0, sizeof(OMX_BUFFERHEADERTYPE)); for (i = 0; i < pExynosPort->portDefinition.nBufferCountActual; i++) { if (pExynosPort->bufferStateAllocate[i] == BUFFER_STATE_FREE) { - pExynosPort->extendBufferHeader[i].OMXBufferHeader = temp_bufferHeader; - pExynosPort->extendBufferHeader[i].buf_fd[0] = temp_buffer_fd; + pExynosPort->extendBufferHeader[i].OMXBufferHeader = pTempBufferHdr; + pExynosPort->extendBufferHeader[i].buf_fd[0] = fdTempBuffer; pExynosPort->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; + INIT_SET_SIZE_VERSION(pTempBufferHdr, OMX_BUFFERHEADERTYPE); + pTempBufferHdr->pBuffer = pTempBuffer; + pTempBufferHdr->nAllocLen = nSizeBytes; + pTempBufferHdr->pAppPrivate = pAppPrivate; if (nPortIndex == INPUT_PORT_INDEX) - temp_bufferHeader->nInputPortIndex = INPUT_PORT_INDEX; + pTempBufferHdr->nInputPortIndex = INPUT_PORT_INDEX; else - temp_bufferHeader->nOutputPortIndex = OUTPUT_PORT_INDEX; + pTempBufferHdr->nOutputPortIndex = OUTPUT_PORT_INDEX; pExynosPort->assignedBufferNum++; if (pExynosPort->assignedBufferNum == pExynosPort->portDefinition.nBufferCountActual) { pExynosPort->portDefinition.bPopulated = OMX_TRUE; @@ -232,14 +240,14 @@ OMX_ERRORTYPE Exynos_OMX_AllocateBuffer( Exynos_OSAL_SemaphorePost(pExynosPort->loadedResource); /* Exynos_OSAL_MutexUnlock(pExynosComponent->compMutex); */ } - *ppBuffer = temp_bufferHeader; + *ppBufferHdr = pTempBufferHdr; ret = OMX_ErrorNone; goto EXIT; } } - Exynos_OSAL_Free(temp_bufferHeader); - Exynos_OSAL_SharedMemory_Free(pVideoEnc->hSharedMemory, temp_buffer); + Exynos_OSAL_Free(pTempBufferHdr); + Exynos_OSAL_SharedMemory_Free(pVideoEnc->hSharedMemory, pTempBuffer); ret = OMX_ErrorInsufficientResources; @@ -250,18 +258,17 @@ EXIT: } OMX_ERRORTYPE Exynos_OMX_FreeBuffer( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_U32 nPortIndex, + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_U32 nPortIndex, OMX_IN OMX_BUFFERHEADERTYPE *pBufferHdr) { - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; - EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL; - EXYNOS_OMX_BASEPORT *pExynosPort = NULL; - OMX_BUFFERHEADERTYPE *temp_bufferHeader = NULL; - OMX_U8 *temp_buffer = NULL; - OMX_U32 i = 0; + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; + EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL; + EXYNOS_OMX_BASEPORT *pExynosPort = NULL; + OMX_BUFFERHEADERTYPE *pOMXBufferHdr = NULL; + OMX_U32 i = 0; FunctionIn(); @@ -270,6 +277,7 @@ OMX_ERRORTYPE Exynos_OMX_FreeBuffer( goto EXIT; } pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); if (ret != OMX_ErrorNone) { goto EXIT; @@ -280,7 +288,17 @@ OMX_ERRORTYPE Exynos_OMX_FreeBuffer( goto EXIT; } pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + + if (pExynosComponent->hComponentHandle == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; + + if (nPortIndex >= pExynosComponent->portParam.nPorts) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } pExynosPort = &pExynosComponent->pExynosPort[nPortIndex]; if (CHECK_PORT_TUNNELED(pExynosPort) && CHECK_PORT_BUFFER_SUPPLIER(pExynosPort)) { @@ -288,7 +306,8 @@ OMX_ERRORTYPE Exynos_OMX_FreeBuffer( goto EXIT; } - if ((pExynosPort->portState != OMX_StateLoaded) && (pExynosPort->portState != OMX_StateInvalid)) { + if ((pExynosPort->portState != OMX_StateLoaded) && + (pExynosPort->portState != OMX_StateInvalid)) { (*(pExynosComponent->pCallbacks->EventHandler)) (pOMXComponent, pExynosComponent->callbackData, (OMX_U32)OMX_EventError, @@ -297,21 +316,26 @@ OMX_ERRORTYPE Exynos_OMX_FreeBuffer( } for (i = 0; i < /*pExynosPort->portDefinition.nBufferCountActual*/MAX_BUFFER_NUM; i++) { - if (((pExynosPort->bufferStateAllocate[i] | BUFFER_STATE_FREE) != 0) && (pExynosPort->extendBufferHeader[i].OMXBufferHeader != NULL)) { - if (pExynosPort->extendBufferHeader[i].OMXBufferHeader->pBuffer == pBufferHdr->pBuffer) { + if ((pExynosPort->bufferStateAllocate[i] != BUFFER_STATE_FREE) && + (pExynosPort->extendBufferHeader[i].OMXBufferHeader != NULL)) { + pOMXBufferHdr = pExynosPort->extendBufferHeader[i].OMXBufferHeader; + + if (pOMXBufferHdr->pBuffer == pBufferHdr->pBuffer) { if (pExynosPort->bufferStateAllocate[i] & BUFFER_STATE_ALLOCATED) { - Exynos_OSAL_SharedMemory_Free(pVideoEnc->hSharedMemory, pExynosPort->extendBufferHeader[i].OMXBufferHeader->pBuffer); - pExynosPort->extendBufferHeader[i].OMXBufferHeader->pBuffer = NULL; + Exynos_OSAL_SharedMemory_Free(pVideoEnc->hSharedMemory, pOMXBufferHdr->pBuffer); + pOMXBufferHdr->pBuffer = NULL; pBufferHdr->pBuffer = NULL; } else if (pExynosPort->bufferStateAllocate[i] & BUFFER_STATE_ASSIGNED) { ; /* None*/ } pExynosPort->assignedBufferNum--; + if (pExynosPort->bufferStateAllocate[i] & HEADER_STATE_ALLOCATED) { - Exynos_OSAL_Free(pExynosPort->extendBufferHeader[i].OMXBufferHeader); + Exynos_OSAL_Free(pOMXBufferHdr); pExynosPort->extendBufferHeader[i].OMXBufferHeader = NULL; pBufferHdr = NULL; } + pExynosPort->bufferStateAllocate[i] = BUFFER_STATE_FREE; ret = OMX_ErrorNone; goto EXIT; @@ -320,14 +344,13 @@ OMX_ERRORTYPE Exynos_OMX_FreeBuffer( } EXIT: - if (ret == OMX_ErrorNone) { - if (pExynosPort->assignedBufferNum == 0) { - Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pExynosPort->unloadedResource signal set"); - /* Exynos_OSAL_MutexLock(pExynosComponent->compMutex); */ - Exynos_OSAL_SemaphorePost(pExynosPort->unloadedResource); - /* Exynos_OSAL_MutexUnlock(pExynosComponent->compMutex); */ - pExynosPort->portDefinition.bPopulated = OMX_FALSE; - } + if ((ret == OMX_ErrorNone) && + (pExynosPort->assignedBufferNum == 0)) { + Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pExynosPort->unloadedResource signal set"); + /* Exynos_OSAL_MutexLock(pExynosComponent->compMutex); */ + Exynos_OSAL_SemaphorePost(pExynosPort->unloadedResource); + /* Exynos_OSAL_MutexUnlock(pExynosComponent->compMutex); */ + pExynosPort->portDefinition.bPopulated = OMX_FALSE; } FunctionOut(); @@ -335,13 +358,15 @@ EXIT: return ret; } -OMX_ERRORTYPE Exynos_OMX_AllocateTunnelBuffer(EXYNOS_OMX_BASEPORT *pOMXBasePort, OMX_U32 nPortIndex) +OMX_ERRORTYPE Exynos_OMX_AllocateTunnelBuffer( + EXYNOS_OMX_BASEPORT *pOMXBasePort, + OMX_U32 nPortIndex) { - OMX_ERRORTYPE ret = OMX_ErrorNone; - EXYNOS_OMX_BASEPORT *pExynosPort = NULL; - OMX_BUFFERHEADERTYPE *temp_bufferHeader = NULL; - OMX_U8 *temp_buffer = NULL; - OMX_U32 bufferSize = 0; + OMX_ERRORTYPE ret = OMX_ErrorNone; + EXYNOS_OMX_BASEPORT *pExynosPort = NULL; + OMX_BUFFERHEADERTYPE *pTempBufferHdr = NULL; + OMX_U8 *pTempBuffer = NULL; + OMX_U32 nBufferSize = 0; OMX_PARAM_PORTDEFINITIONTYPE portDefinition; ret = OMX_ErrorTunnelingUnsupported; @@ -349,13 +374,15 @@ EXIT: return ret; } -OMX_ERRORTYPE Exynos_OMX_FreeTunnelBuffer(EXYNOS_OMX_BASEPORT *pOMXBasePort, OMX_U32 nPortIndex) +OMX_ERRORTYPE Exynos_OMX_FreeTunnelBuffer( + EXYNOS_OMX_BASEPORT *pOMXBasePort, + OMX_U32 nPortIndex) { - OMX_ERRORTYPE ret = OMX_ErrorNone; - EXYNOS_OMX_BASEPORT* pExynosPort = NULL; - OMX_BUFFERHEADERTYPE* temp_bufferHeader = NULL; - OMX_U8 *temp_buffer = NULL; - OMX_U32 bufferSize = 0; + OMX_ERRORTYPE ret = OMX_ErrorNone; + EXYNOS_OMX_BASEPORT *pExynosPort = NULL; + OMX_BUFFERHEADERTYPE *pTempBufferHdr = NULL; + OMX_U8 *pTempBuffer = NULL; + OMX_U32 nBufferSize = 0; ret = OMX_ErrorTunnelingUnsupported; EXIT: @@ -376,7 +403,9 @@ EXIT: return ret; } -OMX_ERRORTYPE Exynos_OMX_GetFlushBuffer(EXYNOS_OMX_BASEPORT *pExynosPort, EXYNOS_OMX_DATABUFFER *pDataBuffer[]) +OMX_ERRORTYPE Exynos_OMX_GetFlushBuffer( + EXYNOS_OMX_BASEPORT *pExynosPort, + EXYNOS_OMX_DATABUFFER *pDataBuffer[]) { OMX_ERRORTYPE ret = OMX_ErrorNone; @@ -387,8 +416,8 @@ OMX_ERRORTYPE Exynos_OMX_GetFlushBuffer(EXYNOS_OMX_BASEPORT *pExynosPort, EXYNOS if (pExynosPort->portWayType == WAY1_PORT) { *pDataBuffer = &pExynosPort->way.port1WayDataBuffer.dataBuffer; } else if (pExynosPort->portWayType == WAY2_PORT) { - pDataBuffer[0] = &(pExynosPort->way.port2WayDataBuffer.inputDataBuffer); - pDataBuffer[1] = &(pExynosPort->way.port2WayDataBuffer.outputDataBuffer); + pDataBuffer[0] = &(pExynosPort->way.port2WayDataBuffer.inputDataBuffer); + pDataBuffer[1] = &(pExynosPort->way.port2WayDataBuffer.outputDataBuffer); } EXIT: @@ -397,73 +426,96 @@ EXIT: return ret; } -OMX_ERRORTYPE Exynos_OMX_FlushPort(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 portIndex) +OMX_ERRORTYPE Exynos_OMX_FlushPort( + OMX_COMPONENTTYPE *pOMXComponent, + OMX_S32 nPortIndex) { - OMX_ERRORTYPE ret = OMX_ErrorNone; - EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - EXYNOS_OMX_BASEPORT *pExynosPort = NULL; - OMX_BUFFERHEADERTYPE *bufferHeader = NULL; - EXYNOS_OMX_DATABUFFER *pDataPortBuffer[2] = {NULL, NULL}; - EXYNOS_OMX_MESSAGE *message = NULL; - OMX_U32 flushNum = 0; - OMX_S32 semValue = 0; - int i = 0, maxBufferNum = 0; + OMX_ERRORTYPE ret = OMX_ErrorNone; + EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; + EXYNOS_OMX_BASEPORT *pExynosPort = NULL; + OMX_BUFFERHEADERTYPE *pBufferHdr = NULL; + EXYNOS_OMX_DATABUFFER *pDataBuffer[2] = {NULL, NULL}; + EXYNOS_OMX_MESSAGE *pMessage = NULL; + OMX_S32 nSemaCnt = 0; + int i = 0; + FunctionIn(); - pExynosPort = &pExynosComponent->pExynosPort[portIndex]; + if (pOMXComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + + if ((nPortIndex < 0) || + (nPortIndex >= pExynosComponent->portParam.nPorts)) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + pExynosPort = &pExynosComponent->pExynosPort[nPortIndex]; while (Exynos_OSAL_GetElemNum(&pExynosPort->bufferQ) > 0) { - Exynos_OSAL_Get_SemaphoreCount(pExynosComponent->pExynosPort[portIndex].bufferSemID, &semValue); - if (semValue == 0) - Exynos_OSAL_SemaphorePost(pExynosComponent->pExynosPort[portIndex].bufferSemID); - - Exynos_OSAL_SemaphoreWait(pExynosComponent->pExynosPort[portIndex].bufferSemID); - message = (EXYNOS_OMX_MESSAGE *)Exynos_OSAL_Dequeue(&pExynosPort->bufferQ); - if ((message != NULL) && (message->messageType != EXYNOS_OMX_CommandFakeBuffer)) { - bufferHeader = (OMX_BUFFERHEADERTYPE *)message->pCmdData; - bufferHeader->nFilledLen = 0; - - if (portIndex == OUTPUT_PORT_INDEX) { - Exynos_OMX_OutputBufferReturn(pOMXComponent, bufferHeader); - } else if (portIndex == INPUT_PORT_INDEX) { - Exynos_OMX_InputBufferReturn(pOMXComponent, bufferHeader); + Exynos_OSAL_Get_SemaphoreCount(pExynosPort->bufferSemID, &nSemaCnt); + if (nSemaCnt == 0) + Exynos_OSAL_SemaphorePost(pExynosPort->bufferSemID); + + Exynos_OSAL_SemaphoreWait(pExynosPort->bufferSemID); + pMessage = (EXYNOS_OMX_MESSAGE *)Exynos_OSAL_Dequeue(&pExynosPort->bufferQ); + if ((pMessage != NULL) && + (pMessage->messageType != EXYNOS_OMX_CommandFakeBuffer)) { + pBufferHdr = (OMX_BUFFERHEADERTYPE *)pMessage->pCmdData; + pBufferHdr->nFilledLen = 0; + + if (nPortIndex == OUTPUT_PORT_INDEX) { + Exynos_OMX_OutputBufferReturn(pOMXComponent, pBufferHdr); + } else if (nPortIndex == INPUT_PORT_INDEX) { + Exynos_OMX_InputBufferReturn(pOMXComponent, pBufferHdr); } } - Exynos_OSAL_Free(message); - message = NULL; + Exynos_OSAL_Free(pMessage); + pMessage = NULL; } - Exynos_OMX_GetFlushBuffer(pExynosPort, pDataPortBuffer); - if (portIndex == INPUT_PORT_INDEX) { - if (pDataPortBuffer[0]->dataValid == OMX_TRUE) - Exynos_FlushInputBufferReturn(pOMXComponent, pDataPortBuffer[0]); - if (pDataPortBuffer[1]->dataValid == OMX_TRUE) - Exynos_FlushInputBufferReturn(pOMXComponent, pDataPortBuffer[1]); - } else if (portIndex == OUTPUT_PORT_INDEX) { - if (pDataPortBuffer[0]->dataValid == OMX_TRUE) - Exynos_FlushOutputBufferReturn(pOMXComponent, pDataPortBuffer[0]); - if (pDataPortBuffer[1]->dataValid == OMX_TRUE) - Exynos_FlushOutputBufferReturn(pOMXComponent, pDataPortBuffer[1]); + Exynos_OMX_GetFlushBuffer(pExynosPort, pDataBuffer); + if ((pDataBuffer[0] != NULL) && + (pDataBuffer[0]->dataValid == OMX_TRUE)) { + if (nPortIndex == INPUT_PORT_INDEX) + Exynos_FlushInputBufferReturn(pOMXComponent, pDataBuffer[0]); + else if (nPortIndex == OUTPUT_PORT_INDEX) + Exynos_FlushOutputBufferReturn(pOMXComponent, pDataBuffer[0]); + } + if ((pDataBuffer[1] != NULL) && + (pDataBuffer[1]->dataValid == OMX_TRUE)) { + if (nPortIndex == INPUT_PORT_INDEX) + Exynos_FlushInputBufferReturn(pOMXComponent, pDataBuffer[1]); + else if (nPortIndex == OUTPUT_PORT_INDEX) + Exynos_FlushOutputBufferReturn(pOMXComponent, pDataBuffer[1]); } if (pExynosComponent->bMultiThreadProcess == OMX_TRUE) { if (pExynosPort->bufferProcessType & BUFFER_SHARE) { if (pExynosPort->processData.bufferHeader != NULL) { - if (portIndex == INPUT_PORT_INDEX) { + if (nPortIndex == INPUT_PORT_INDEX) { Exynos_OMX_InputBufferReturn(pOMXComponent, pExynosPort->processData.bufferHeader); - } else if (portIndex == OUTPUT_PORT_INDEX) { + } else if (nPortIndex == OUTPUT_PORT_INDEX) { Exynos_OMX_OutputBufferReturn(pOMXComponent, pExynosPort->processData.bufferHeader); } } Exynos_ResetCodecData(&pExynosPort->processData); - maxBufferNum = pExynosPort->portDefinition.nBufferCountActual; - for (i = 0; i < maxBufferNum; i++) { + for (i = 0; i < pExynosPort->portDefinition.nBufferCountActual; i++) { if (pExynosPort->extendBufferHeader[i].bBufferInOMX == OMX_TRUE) { - if (portIndex == OUTPUT_PORT_INDEX) { - Exynos_OMX_OutputBufferReturn(pOMXComponent, pExynosPort->extendBufferHeader[i].OMXBufferHeader); - } else if (portIndex == INPUT_PORT_INDEX) { - Exynos_OMX_InputBufferReturn(pOMXComponent, pExynosPort->extendBufferHeader[i].OMXBufferHeader); + if (nPortIndex == OUTPUT_PORT_INDEX) { + Exynos_OMX_OutputBufferReturn(pOMXComponent, + pExynosPort->extendBufferHeader[i].OMXBufferHeader); + } else if (nPortIndex == INPUT_PORT_INDEX) { + Exynos_OMX_InputBufferReturn(pOMXComponent, + pExynosPort->extendBufferHeader[i].OMXBufferHeader); } } } @@ -472,12 +524,12 @@ OMX_ERRORTYPE Exynos_OMX_FlushPort(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 por Exynos_ResetCodecData(&pExynosPort->processData); } - while(1) { + while (1) { OMX_S32 cnt = 0; - Exynos_OSAL_Get_SemaphoreCount(pExynosComponent->pExynosPort[portIndex].bufferSemID, &cnt); + Exynos_OSAL_Get_SemaphoreCount(pExynosPort->bufferSemID, &cnt); if (cnt <= 0) break; - Exynos_OSAL_SemaphoreWait(pExynosComponent->pExynosPort[portIndex].bufferSemID); + Exynos_OSAL_SemaphoreWait(pExynosPort->bufferSemID); } Exynos_OSAL_ResetQueue(&pExynosPort->bufferQ); @@ -487,14 +539,17 @@ EXIT: return ret; } -OMX_ERRORTYPE Exynos_OMX_BufferFlush(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex, OMX_BOOL bEvent) +OMX_ERRORTYPE Exynos_OMX_BufferFlush( + OMX_COMPONENTTYPE *pOMXComponent, + OMX_S32 nPortIndex, + OMX_BOOL bEvent) { - OMX_ERRORTYPE ret = OMX_ErrorNone; - EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; - EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL; - EXYNOS_OMX_BASEPORT *pExynosPort = NULL; - EXYNOS_OMX_DATABUFFER *flushPortBuffer[2] = {NULL, NULL}; - OMX_U32 i = 0, cnt = 0; + OMX_ERRORTYPE ret = OMX_ErrorNone; + EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; + EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL; + EXYNOS_OMX_BASEPORT *pExynosPort = NULL; + EXYNOS_OMX_DATABUFFER *pDataBuffer[2] = {NULL, NULL}; + OMX_U32 i = 0; FunctionIn(); @@ -502,6 +557,7 @@ OMX_ERRORTYPE Exynos_OMX_BufferFlush(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 n ret = OMX_ErrorBadParameter; goto EXIT; } + ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); if (ret != OMX_ErrorNone) { goto EXIT; @@ -512,31 +568,53 @@ OMX_ERRORTYPE Exynos_OMX_BufferFlush(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 n goto EXIT; } pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + + if (pExynosComponent->hComponentHandle == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; + if ((nPortIndex < 0) || + (nPortIndex >= pExynosComponent->portParam.nPorts)) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + pExynosPort = &pExynosComponent->pExynosPort[nPortIndex]; + Exynos_OSAL_Log(EXYNOS_LOG_TRACE,"OMX_CommandFlush start, port:%d", nPortIndex); - pExynosComponent->pExynosPort[nPortIndex].bIsPortFlushed = OMX_TRUE; + pExynosPort->bIsPortFlushed = OMX_TRUE; if (pExynosComponent->bMultiThreadProcess == OMX_FALSE) { Exynos_OSAL_SignalSet(pExynosComponent->pauseEvent); } else { - Exynos_OSAL_SignalSet(pExynosComponent->pExynosPort[nPortIndex].pauseEvent); + Exynos_OSAL_SignalSet(pExynosPort->pauseEvent); } - pExynosPort = &pExynosComponent->pExynosPort[nPortIndex]; - Exynos_OMX_GetFlushBuffer(pExynosPort, flushPortBuffer); + Exynos_OMX_GetFlushBuffer(pExynosPort, pDataBuffer); + if (pDataBuffer[0] == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } - if (pExynosComponent->pExynosPort[nPortIndex].bufferProcessType & BUFFER_COPY) + if (pExynosPort->bufferProcessType & BUFFER_COPY) Exynos_OSAL_SemaphorePost(pExynosPort->codecSemID); Exynos_OSAL_SemaphorePost(pExynosPort->bufferSemID); pVideoEnc->exynos_codec_bufferProcessRun(pOMXComponent, nPortIndex); - Exynos_OSAL_MutexLock(flushPortBuffer[0]->bufferMutex); + + Exynos_OSAL_MutexLock(pDataBuffer[0]->bufferMutex); pVideoEnc->exynos_codec_stop(pOMXComponent, nPortIndex); - Exynos_OSAL_MutexLock(flushPortBuffer[1]->bufferMutex); + + if (pDataBuffer[1] != NULL) + Exynos_OSAL_MutexLock(pDataBuffer[1]->bufferMutex); + ret = Exynos_OMX_FlushPort(pOMXComponent, nPortIndex); - if (pExynosComponent->pExynosPort[nPortIndex].bufferProcessType & BUFFER_COPY) + if (ret != OMX_ErrorNone) + goto EXIT; + + if (pExynosPort->bufferProcessType & BUFFER_COPY) pVideoEnc->exynos_codec_enqueueAllBuffer(pOMXComponent, nPortIndex); Exynos_ResetCodecData(&pExynosPort->processData); @@ -551,7 +629,7 @@ OMX_ERRORTYPE Exynos_OMX_BufferFlush(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 n pExynosComponent->reInputData = OMX_FALSE; } - pExynosComponent->pExynosPort[nPortIndex].bIsPortFlushed = OMX_FALSE; + pExynosPort->bIsPortFlushed = OMX_FALSE; Exynos_OSAL_Log(EXYNOS_LOG_TRACE,"OMX_CommandFlush EventCmdComplete, port:%d", nPortIndex); if (bEvent == OMX_TRUE) pExynosComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent, @@ -559,8 +637,11 @@ OMX_ERRORTYPE Exynos_OMX_BufferFlush(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 n OMX_EventCmdComplete, OMX_CommandFlush, nPortIndex, NULL); } - Exynos_OSAL_MutexUnlock(flushPortBuffer[1]->bufferMutex); - Exynos_OSAL_MutexUnlock(flushPortBuffer[0]->bufferMutex); + + if (pDataBuffer[1] != NULL) + Exynos_OSAL_MutexUnlock(pDataBuffer[1]->bufferMutex); + + Exynos_OSAL_MutexUnlock(pDataBuffer[0]->bufferMutex); EXIT: if ((ret != OMX_ErrorNone) && (pOMXComponent != NULL) && (pExynosComponent != NULL)) { @@ -576,51 +657,65 @@ EXIT: return ret; } -OMX_ERRORTYPE Exynos_InputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent) +OMX_ERRORTYPE Exynos_InputBufferReturn( + OMX_COMPONENTTYPE *pOMXComponent) { - OMX_ERRORTYPE ret = OMX_ErrorNone; - EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - EXYNOS_OMX_BASEPORT *exynosOMXInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; - EXYNOS_OMX_DATABUFFER *dataBuffer = NULL; - OMX_BUFFERHEADERTYPE *bufferHeader = NULL; + OMX_ERRORTYPE ret = OMX_ErrorNone; + EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; + EXYNOS_OMX_BASEPORT *pExynosPort = NULL; + EXYNOS_OMX_DATABUFFER *pDataBuffer = NULL; + OMX_BUFFERHEADERTYPE *pBufferHdr = NULL; FunctionIn(); + if (pOMXComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + pExynosPort = &(pExynosComponent->pExynosPort[INPUT_PORT_INDEX]); + if (pExynosPort->bufferProcessType & BUFFER_COPY) { - dataBuffer = &(exynosOMXInputPort->way.port2WayDataBuffer.inputDataBuffer); + pDataBuffer = &(pExynosPort->way.port2WayDataBuffer.inputDataBuffer); } else if (pExynosPort->bufferProcessType & BUFFER_SHARE) { - dataBuffer = &(exynosOMXInputPort->way.port2WayDataBuffer.outputDataBuffer); + pDataBuffer = &(pExynosPort->way.port2WayDataBuffer.outputDataBuffer); } - bufferHeader = dataBuffer->bufferHeader; + if (pDataBuffer != NULL) + pBufferHdr = pDataBuffer->bufferHeader; - if (bufferHeader != NULL) { - if (exynosOMXInputPort->markType.hMarkTargetComponent != NULL ) { - bufferHeader->hMarkTargetComponent = exynosOMXInputPort->markType.hMarkTargetComponent; - bufferHeader->pMarkData = exynosOMXInputPort->markType.pMarkData; - exynosOMXInputPort->markType.hMarkTargetComponent = NULL; - exynosOMXInputPort->markType.pMarkData = NULL; + if (pBufferHdr != NULL) { + if (pExynosPort->markType.hMarkTargetComponent != NULL) { + pBufferHdr->hMarkTargetComponent = pExynosPort->markType.hMarkTargetComponent; + pBufferHdr->pMarkData = pExynosPort->markType.pMarkData; + pExynosPort->markType.hMarkTargetComponent = NULL; + pExynosPort->markType.pMarkData = NULL; } - if (bufferHeader->hMarkTargetComponent != NULL) { - if (bufferHeader->hMarkTargetComponent == pOMXComponent) { + if (pBufferHdr->hMarkTargetComponent != NULL) { + if (pBufferHdr->hMarkTargetComponent == pOMXComponent) { pExynosComponent->pCallbacks->EventHandler(pOMXComponent, pExynosComponent->callbackData, OMX_EventMark, - 0, 0, bufferHeader->pMarkData); + 0, 0, pBufferHdr->pMarkData); } else { - pExynosComponent->propagateMarkType.hMarkTargetComponent = bufferHeader->hMarkTargetComponent; - pExynosComponent->propagateMarkType.pMarkData = bufferHeader->pMarkData; + pExynosComponent->propagateMarkType.hMarkTargetComponent = pBufferHdr->hMarkTargetComponent; + pExynosComponent->propagateMarkType.pMarkData = pBufferHdr->pMarkData; } } - bufferHeader->nFilledLen = 0; - bufferHeader->nOffset = 0; - Exynos_OMX_InputBufferReturn(pOMXComponent, bufferHeader); + pBufferHdr->nFilledLen = 0; + pBufferHdr->nOffset = 0; + Exynos_OMX_InputBufferReturn(pOMXComponent, pBufferHdr); } /* reset dataBuffer */ - Exynos_ResetDataBuffer(dataBuffer); + Exynos_ResetDataBuffer(pDataBuffer); EXIT: FunctionOut(); @@ -628,44 +723,58 @@ EXIT: return ret; } -OMX_ERRORTYPE Exynos_FlushInputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATABUFFER *dataBuffer) +OMX_ERRORTYPE Exynos_FlushInputBufferReturn( + OMX_COMPONENTTYPE *pOMXComponent, + EXYNOS_OMX_DATABUFFER *pDataBuffer) { - OMX_ERRORTYPE ret = OMX_ErrorNone; - EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - EXYNOS_OMX_BASEPORT *exynosOMXInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; - OMX_BUFFERHEADERTYPE *bufferHeader = NULL; + OMX_ERRORTYPE ret = OMX_ErrorNone; + EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; + EXYNOS_OMX_BASEPORT *pExynosPort = NULL; + OMX_BUFFERHEADERTYPE *pBufferHdr = NULL; FunctionIn(); - bufferHeader = dataBuffer->bufferHeader; + if (pOMXComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + pExynosPort = &(pExynosComponent->pExynosPort[INPUT_PORT_INDEX]); + + pBufferHdr = pDataBuffer->bufferHeader; - if (bufferHeader != NULL) { - if (exynosOMXInputPort->markType.hMarkTargetComponent != NULL ) { - bufferHeader->hMarkTargetComponent = exynosOMXInputPort->markType.hMarkTargetComponent; - bufferHeader->pMarkData = exynosOMXInputPort->markType.pMarkData; - exynosOMXInputPort->markType.hMarkTargetComponent = NULL; - exynosOMXInputPort->markType.pMarkData = NULL; + if (pBufferHdr != NULL) { + if (pExynosPort->markType.hMarkTargetComponent != NULL) { + pBufferHdr->hMarkTargetComponent = pExynosPort->markType.hMarkTargetComponent; + pBufferHdr->pMarkData = pExynosPort->markType.pMarkData; + pExynosPort->markType.hMarkTargetComponent = NULL; + pExynosPort->markType.pMarkData = NULL; } - if (bufferHeader->hMarkTargetComponent != NULL) { - if (bufferHeader->hMarkTargetComponent == pOMXComponent) { + if (pBufferHdr->hMarkTargetComponent != NULL) { + if (pBufferHdr->hMarkTargetComponent == pOMXComponent) { pExynosComponent->pCallbacks->EventHandler(pOMXComponent, pExynosComponent->callbackData, OMX_EventMark, - 0, 0, bufferHeader->pMarkData); + 0, 0, pBufferHdr->pMarkData); } else { - pExynosComponent->propagateMarkType.hMarkTargetComponent = bufferHeader->hMarkTargetComponent; - pExynosComponent->propagateMarkType.pMarkData = bufferHeader->pMarkData; + pExynosComponent->propagateMarkType.hMarkTargetComponent = pBufferHdr->hMarkTargetComponent; + pExynosComponent->propagateMarkType.pMarkData = pBufferHdr->pMarkData; } } - bufferHeader->nFilledLen = 0; - bufferHeader->nOffset = 0; - Exynos_OMX_InputBufferReturn(pOMXComponent, bufferHeader); + pBufferHdr->nFilledLen = 0; + pBufferHdr->nOffset = 0; + Exynos_OMX_InputBufferReturn(pOMXComponent, pBufferHdr); } /* reset dataBuffer */ - Exynos_ResetDataBuffer(dataBuffer); + Exynos_ResetDataBuffer(pDataBuffer); EXIT: FunctionOut(); @@ -673,16 +782,22 @@ EXIT: return ret; } -OMX_ERRORTYPE Exynos_InputBufferGetQueue(EXYNOS_OMX_BASECOMPONENT *pExynosComponent) +OMX_ERRORTYPE Exynos_InputBufferGetQueue( + EXYNOS_OMX_BASECOMPONENT *pExynosComponent) { - OMX_ERRORTYPE ret = OMX_ErrorUndefined; - EXYNOS_OMX_BASEPORT *pExynosPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; - EXYNOS_OMX_MESSAGE *message = NULL; - EXYNOS_OMX_DATABUFFER *inputUseBuffer = NULL; + OMX_ERRORTYPE ret = OMX_ErrorUndefined; + EXYNOS_OMX_BASEPORT *pExynosPort = NULL; + EXYNOS_OMX_MESSAGE *pMessage = NULL; + EXYNOS_OMX_DATABUFFER *pDataBuffer = NULL; FunctionIn(); - inputUseBuffer = &(pExynosPort->way.port2WayDataBuffer.inputDataBuffer); + if (pExynosComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pExynosPort = &(pExynosComponent->pExynosPort[INPUT_PORT_INDEX]); + pDataBuffer = &(pExynosPort->way.port2WayDataBuffer.inputDataBuffer); if (pExynosComponent->currentState != OMX_StateExecuting) { ret = OMX_ErrorUndefined; @@ -690,31 +805,31 @@ OMX_ERRORTYPE Exynos_InputBufferGetQueue(EXYNOS_OMX_BASECOMPONENT *pExynosCompon } else if ((pExynosComponent->transientState != EXYNOS_OMX_TransStateExecutingToIdle) && (!CHECK_PORT_BEING_FLUSHED(pExynosPort))) { Exynos_OSAL_SemaphoreWait(pExynosPort->bufferSemID); - if (inputUseBuffer->dataValid != OMX_TRUE) { - message = (EXYNOS_OMX_MESSAGE *)Exynos_OSAL_Dequeue(&pExynosPort->bufferQ); - if (message == NULL) { + if (pDataBuffer->dataValid != OMX_TRUE) { + pMessage = (EXYNOS_OMX_MESSAGE *)Exynos_OSAL_Dequeue(&pExynosPort->bufferQ); + if (pMessage == NULL) { ret = OMX_ErrorUndefined; goto EXIT; } - if (message->messageType == EXYNOS_OMX_CommandFakeBuffer) { - Exynos_OSAL_Free(message); + if (pMessage->messageType == EXYNOS_OMX_CommandFakeBuffer) { + Exynos_OSAL_Free(pMessage); ret = OMX_ErrorCodecFlush; goto EXIT; } - inputUseBuffer->bufferHeader = (OMX_BUFFERHEADERTYPE *)(message->pCmdData); - inputUseBuffer->allocSize = inputUseBuffer->bufferHeader->nAllocLen; - inputUseBuffer->dataLen = inputUseBuffer->bufferHeader->nFilledLen; - inputUseBuffer->remainDataLen = inputUseBuffer->dataLen; - inputUseBuffer->usedDataLen = 0; - inputUseBuffer->dataValid = OMX_TRUE; - inputUseBuffer->nFlags = inputUseBuffer->bufferHeader->nFlags; - inputUseBuffer->timeStamp = inputUseBuffer->bufferHeader->nTimeStamp; + pDataBuffer->bufferHeader = (OMX_BUFFERHEADERTYPE *)(pMessage->pCmdData); + pDataBuffer->allocSize = pDataBuffer->bufferHeader->nAllocLen; + pDataBuffer->dataLen = pDataBuffer->bufferHeader->nFilledLen; + pDataBuffer->remainDataLen = pDataBuffer->dataLen; + pDataBuffer->usedDataLen = 0; + pDataBuffer->dataValid = OMX_TRUE; + pDataBuffer->nFlags = pDataBuffer->bufferHeader->nFlags; + pDataBuffer->timeStamp = pDataBuffer->bufferHeader->nTimeStamp; - Exynos_OSAL_Free(message); + Exynos_OSAL_Free(pMessage); - if (inputUseBuffer->allocSize <= inputUseBuffer->dataLen) - Exynos_OSAL_Log(EXYNOS_LOG_WARNING, "Input Buffer Full, Check input buffer size! allocSize:%d, dataLen:%d", inputUseBuffer->allocSize, inputUseBuffer->dataLen); + if (pDataBuffer->allocSize <= pDataBuffer->dataLen) + Exynos_OSAL_Log(EXYNOS_LOG_WARNING, "Input Buffer Full, Check input buffer size! allocSize:%d, dataLen:%d", pDataBuffer->allocSize, pDataBuffer->dataLen); } ret = OMX_ErrorNone; } @@ -724,47 +839,60 @@ EXIT: return ret; } -OMX_ERRORTYPE Exynos_OutputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent) +OMX_ERRORTYPE Exynos_OutputBufferReturn( + OMX_COMPONENTTYPE *pOMXComponent) { - OMX_ERRORTYPE ret = OMX_ErrorNone; - EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - EXYNOS_OMX_BASEPORT *exynosOMXOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; - EXYNOS_OMX_DATABUFFER *dataBuffer = NULL; - OMX_BUFFERHEADERTYPE *bufferHeader = NULL; + OMX_ERRORTYPE ret = OMX_ErrorNone; + EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; + EXYNOS_OMX_BASEPORT *pExynosPort = NULL; + EXYNOS_OMX_DATABUFFER *pDataBuffer = NULL; + OMX_BUFFERHEADERTYPE *pBufferHdr = NULL; FunctionIn(); - dataBuffer = &(exynosOMXOutputPort->way.port2WayDataBuffer.outputDataBuffer); - bufferHeader = dataBuffer->bufferHeader; + if (pOMXComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } - if (bufferHeader != NULL) { - bufferHeader->nFilledLen = dataBuffer->remainDataLen; - bufferHeader->nOffset = 0; - bufferHeader->nFlags = dataBuffer->nFlags; - bufferHeader->nTimeStamp = dataBuffer->timeStamp; + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + pExynosPort = &(pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]); + + pDataBuffer = &(pExynosPort->way.port2WayDataBuffer.outputDataBuffer); + pBufferHdr = pDataBuffer->bufferHeader; + + if (pBufferHdr != NULL) { + pBufferHdr->nFilledLen = pDataBuffer->remainDataLen; + pBufferHdr->nOffset = 0; + pBufferHdr->nFlags = pDataBuffer->nFlags; + pBufferHdr->nTimeStamp = pDataBuffer->timeStamp; if (pExynosComponent->propagateMarkType.hMarkTargetComponent != NULL) { - bufferHeader->hMarkTargetComponent = pExynosComponent->propagateMarkType.hMarkTargetComponent; - bufferHeader->pMarkData = pExynosComponent->propagateMarkType.pMarkData; + pBufferHdr->hMarkTargetComponent = pExynosComponent->propagateMarkType.hMarkTargetComponent; + pBufferHdr->pMarkData = pExynosComponent->propagateMarkType.pMarkData; pExynosComponent->propagateMarkType.hMarkTargetComponent = NULL; pExynosComponent->propagateMarkType.pMarkData = NULL; } - if ((bufferHeader->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) { - bufferHeader->nFilledLen = 0; - Exynos_OSAL_Log(EXYNOS_LOG_TRACE,"event OMX_BUFFERFLAG_EOS!!!"); + if ((pBufferHdr->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) { + pBufferHdr->nFilledLen = 0; + Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "event OMX_BUFFERFLAG_EOS!!!"); pExynosComponent->pCallbacks->EventHandler(pOMXComponent, pExynosComponent->callbackData, OMX_EventBufferFlag, OUTPUT_PORT_INDEX, - bufferHeader->nFlags, NULL); + pBufferHdr->nFlags, NULL); } - Exynos_OMX_OutputBufferReturn(pOMXComponent, bufferHeader); + Exynos_OMX_OutputBufferReturn(pOMXComponent, pBufferHdr); } /* reset dataBuffer */ - Exynos_ResetDataBuffer(dataBuffer); + Exynos_ResetDataBuffer(pDataBuffer); EXIT: FunctionOut(); @@ -772,44 +900,55 @@ EXIT: return ret; } -OMX_ERRORTYPE Exynos_FlushOutputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATABUFFER *dataBuffer) +OMX_ERRORTYPE Exynos_FlushOutputBufferReturn( + OMX_COMPONENTTYPE *pOMXComponent, + EXYNOS_OMX_DATABUFFER *pDataBuffer) { - OMX_ERRORTYPE ret = OMX_ErrorNone; - EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - EXYNOS_OMX_BASEPORT *exynosOMXOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; - OMX_BUFFERHEADERTYPE *bufferHeader = NULL; + OMX_ERRORTYPE ret = OMX_ErrorNone; + EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; + OMX_BUFFERHEADERTYPE *pBufferHdr = NULL; FunctionIn(); - bufferHeader = dataBuffer->bufferHeader; + if (pOMXComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + + if (pOMXComponent->pComponentPrivate == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + pBufferHdr = pDataBuffer->bufferHeader; - if (bufferHeader != NULL) { - bufferHeader->nFilledLen = dataBuffer->remainDataLen; - bufferHeader->nOffset = 0; - bufferHeader->nFlags = dataBuffer->nFlags; - bufferHeader->nTimeStamp = dataBuffer->timeStamp; + if (pBufferHdr != NULL) { + pBufferHdr->nFilledLen = pDataBuffer->remainDataLen; + pBufferHdr->nOffset = 0; + pBufferHdr->nFlags = pDataBuffer->nFlags; + pBufferHdr->nTimeStamp = pDataBuffer->timeStamp; if (pExynosComponent->propagateMarkType.hMarkTargetComponent != NULL) { - bufferHeader->hMarkTargetComponent = pExynosComponent->propagateMarkType.hMarkTargetComponent; - bufferHeader->pMarkData = pExynosComponent->propagateMarkType.pMarkData; + pBufferHdr->hMarkTargetComponent = pExynosComponent->propagateMarkType.hMarkTargetComponent; + pBufferHdr->pMarkData = pExynosComponent->propagateMarkType.pMarkData; pExynosComponent->propagateMarkType.hMarkTargetComponent = NULL; pExynosComponent->propagateMarkType.pMarkData = NULL; } - if ((bufferHeader->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) { - bufferHeader->nFilledLen = 0; - Exynos_OSAL_Log(EXYNOS_LOG_TRACE,"event OMX_BUFFERFLAG_EOS!!!"); + if ((pBufferHdr->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) { + pBufferHdr->nFilledLen = 0; + Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "event OMX_BUFFERFLAG_EOS!!!"); pExynosComponent->pCallbacks->EventHandler(pOMXComponent, pExynosComponent->callbackData, OMX_EventBufferFlag, OUTPUT_PORT_INDEX, - bufferHeader->nFlags, NULL); + pBufferHdr->nFlags, NULL); } - Exynos_OMX_OutputBufferReturn(pOMXComponent, bufferHeader); + Exynos_OMX_OutputBufferReturn(pOMXComponent, pBufferHdr); } /* reset dataBuffer */ - Exynos_ResetDataBuffer(dataBuffer); + Exynos_ResetDataBuffer(pDataBuffer); EXIT: FunctionOut(); @@ -817,57 +956,64 @@ EXIT: return ret; } -OMX_ERRORTYPE Exynos_OutputBufferGetQueue(EXYNOS_OMX_BASECOMPONENT *pExynosComponent) +OMX_ERRORTYPE Exynos_OutputBufferGetQueue( + EXYNOS_OMX_BASECOMPONENT *pExynosComponent) { - OMX_ERRORTYPE ret = OMX_ErrorUndefined; - EXYNOS_OMX_BASEPORT *pExynosPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; - EXYNOS_OMX_MESSAGE *message = NULL; - EXYNOS_OMX_DATABUFFER *outputUseBuffer = NULL; + OMX_ERRORTYPE ret = OMX_ErrorUndefined; + EXYNOS_OMX_BASEPORT *pExynosPort = NULL; + EXYNOS_OMX_MESSAGE *pMessage = NULL; + EXYNOS_OMX_DATABUFFER *pDataBuffer = NULL; FunctionIn(); + if (pExynosComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pExynosPort = &(pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]); + if (pExynosPort->bufferProcessType & BUFFER_COPY) { - outputUseBuffer = &(pExynosPort->way.port2WayDataBuffer.outputDataBuffer); + pDataBuffer = &(pExynosPort->way.port2WayDataBuffer.outputDataBuffer); } else if (pExynosPort->bufferProcessType & BUFFER_SHARE) { - outputUseBuffer = &(pExynosPort->way.port2WayDataBuffer.inputDataBuffer); + pDataBuffer = &(pExynosPort->way.port2WayDataBuffer.inputDataBuffer); } if (pExynosComponent->currentState != OMX_StateExecuting) { ret = OMX_ErrorUndefined; goto EXIT; } else if ((pExynosComponent->transientState != EXYNOS_OMX_TransStateExecutingToIdle) && - (!CHECK_PORT_BEING_FLUSHED(pExynosPort))){ + (!CHECK_PORT_BEING_FLUSHED(pExynosPort))) { Exynos_OSAL_SemaphoreWait(pExynosPort->bufferSemID); - if (outputUseBuffer->dataValid != OMX_TRUE) { - message = (EXYNOS_OMX_MESSAGE *)Exynos_OSAL_Dequeue(&pExynosPort->bufferQ); - if (message == NULL) { + if ((pDataBuffer != NULL) && + (pDataBuffer->dataValid != OMX_TRUE)) { + pMessage = (EXYNOS_OMX_MESSAGE *)Exynos_OSAL_Dequeue(&pExynosPort->bufferQ); + if (pMessage == NULL) { ret = OMX_ErrorUndefined; goto EXIT; } - if (message->messageType == EXYNOS_OMX_CommandFakeBuffer) { - Exynos_OSAL_Free(message); + if (pMessage->messageType == EXYNOS_OMX_CommandFakeBuffer) { + Exynos_OSAL_Free(pMessage); ret = OMX_ErrorCodecFlush; goto EXIT; } - outputUseBuffer->bufferHeader = (OMX_BUFFERHEADERTYPE *)(message->pCmdData); - outputUseBuffer->allocSize = outputUseBuffer->bufferHeader->nAllocLen; - outputUseBuffer->dataLen = 0; //dataBuffer->bufferHeader->nFilledLen; - outputUseBuffer->remainDataLen = outputUseBuffer->dataLen; - outputUseBuffer->usedDataLen = 0; //dataBuffer->bufferHeader->nOffset; - outputUseBuffer->dataValid = OMX_TRUE; - /* dataBuffer->nFlags = dataBuffer->bufferHeader->nFlags; */ - /* dataBuffer->nTimeStamp = dataBuffer->bufferHeader->nTimeStamp; */ + pDataBuffer->bufferHeader = (OMX_BUFFERHEADERTYPE *)(pMessage->pCmdData); + pDataBuffer->allocSize = pDataBuffer->bufferHeader->nAllocLen; + pDataBuffer->dataLen = 0; //dataBuffer->bufferHeader->nFilledLen; + pDataBuffer->remainDataLen = pDataBuffer->dataLen; + pDataBuffer->usedDataLen = 0; //dataBuffer->bufferHeader->nOffset; + pDataBuffer->dataValid = OMX_TRUE; + /* pDataBuffer->nFlags = pDataBuffer->bufferHeader->nFlags; */ + /* pDtaBuffer->nTimeStamp = pDataBuffer->bufferHeader->nTimeStamp; */ /* if (pExynosPort->bufferProcessType & BUFFER_SHARE) - outputUseBuffer->pPrivate = outputUseBuffer->bufferHeader->pOutputPortPrivate; + pDataBuffer->pPrivate = pDataBuffer->bufferHeader->pOutputPortPrivate; else if (pExynosPort->bufferProcessType & BUFFER_COPY) { - pExynosPort->processData.dataBuffer = outputUseBuffer->bufferHeader->pBuffer; - pExynosPort->processData.allocSize = outputUseBuffer->bufferHeader->nAllocLen; + pExynosPort->processData.dataBuffer = pDataBuffer->bufferHeader->pBuffer; + pExynosPort->processData.allocSize = pDataBuffer->bufferHeader->nAllocLen; } */ - - Exynos_OSAL_Free(message); + Exynos_OSAL_Free(pMessage); } ret = OMX_ErrorNone; } @@ -875,60 +1021,78 @@ EXIT: FunctionOut(); return ret; - } -OMX_BUFFERHEADERTYPE *Exynos_OutputBufferGetQueue_Direct(EXYNOS_OMX_BASECOMPONENT *pExynosComponent) +OMX_BUFFERHEADERTYPE *Exynos_OutputBufferGetQueue_Direct( + EXYNOS_OMX_BASECOMPONENT *pExynosComponent) { - OMX_BUFFERHEADERTYPE *retBuffer = NULL; - EXYNOS_OMX_BASEPORT *pExynosPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; - EXYNOS_OMX_MESSAGE *message = NULL; + OMX_BUFFERHEADERTYPE *pBufferHdr = NULL; + EXYNOS_OMX_BASEPORT *pExynosPort = NULL; + EXYNOS_OMX_MESSAGE *pMessage = NULL; FunctionIn(); + if (pExynosComponent == NULL) { + pBufferHdr = NULL; + goto EXIT; + } + pExynosPort = &(pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]); + if (pExynosComponent->currentState != OMX_StateExecuting) { - retBuffer = NULL; + pBufferHdr = NULL; goto EXIT; } else if ((pExynosComponent->transientState != EXYNOS_OMX_TransStateExecutingToIdle) && - (!CHECK_PORT_BEING_FLUSHED(pExynosPort))){ + (!CHECK_PORT_BEING_FLUSHED(pExynosPort))) { Exynos_OSAL_SemaphoreWait(pExynosPort->bufferSemID); - message = (EXYNOS_OMX_MESSAGE *)Exynos_OSAL_Dequeue(&pExynosPort->bufferQ); - if (message == NULL) { - retBuffer = NULL; + pMessage = (EXYNOS_OMX_MESSAGE *)Exynos_OSAL_Dequeue(&pExynosPort->bufferQ); + if (pMessage == NULL) { + pBufferHdr = NULL; goto EXIT; } - if (message->messageType == EXYNOS_OMX_CommandFakeBuffer) { - Exynos_OSAL_Free(message); - retBuffer = NULL; + if (pMessage->messageType == EXYNOS_OMX_CommandFakeBuffer) { + Exynos_OSAL_Free(pMessage); + pBufferHdr = NULL; goto EXIT; } - retBuffer = (OMX_BUFFERHEADERTYPE *)(message->pCmdData); - Exynos_OSAL_Free(message); + pBufferHdr = (OMX_BUFFERHEADERTYPE *)(pMessage->pCmdData); + Exynos_OSAL_Free(pMessage); } EXIT: FunctionOut(); - return retBuffer; + return pBufferHdr; } -OMX_ERRORTYPE Exynos_CodecBufferEnQueue(EXYNOS_OMX_BASECOMPONENT *pExynosComponent, OMX_U32 PortIndex, OMX_PTR data) +OMX_ERRORTYPE Exynos_CodecBufferEnqueue( + EXYNOS_OMX_BASECOMPONENT *pExynosComponent, + OMX_U32 nPortIndex, + OMX_PTR pData) { - OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_ERRORTYPE ret = OMX_ErrorNone; EXYNOS_OMX_BASEPORT *pExynosPort = NULL; FunctionIn(); - pExynosPort= &pExynosComponent->pExynosPort[PortIndex]; + if (pExynosComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } - if (data == NULL) { + if (nPortIndex >= pExynosComponent->portParam.nPorts) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + pExynosPort = &(pExynosComponent->pExynosPort[nPortIndex]); + + if (pData == NULL) { ret = OMX_ErrorInsufficientResources; goto EXIT; } - ret = Exynos_OSAL_Queue(&pExynosPort->codecBufferQ, (void *)data); + ret = Exynos_OSAL_Queue(&pExynosPort->codecBufferQ, (void *)pData); if (ret != 0) { ret = OMX_ErrorUndefined; goto EXIT; @@ -943,25 +1107,37 @@ EXIT: return ret; } -OMX_ERRORTYPE Exynos_CodecBufferDeQueue(EXYNOS_OMX_BASECOMPONENT *pExynosComponent, OMX_U32 PortIndex, OMX_PTR *data) +OMX_ERRORTYPE Exynos_CodecBufferDequeue( + EXYNOS_OMX_BASECOMPONENT *pExynosComponent, + OMX_U32 nPortIndex, + OMX_PTR *pData) { - OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_ERRORTYPE ret = OMX_ErrorNone; EXYNOS_OMX_BASEPORT *pExynosPort = NULL; - OMX_U32 tempData; + OMX_PTR pTempData = NULL; FunctionIn(); - pExynosPort = &pExynosComponent->pExynosPort[PortIndex]; - Exynos_OSAL_SemaphoreWait(pExynosPort->codecSemID); - tempData = (OMX_U32)Exynos_OSAL_Dequeue(&pExynosPort->codecBufferQ); - if (tempData == NULL) { - *data = NULL; - ret = OMX_ErrorUndefined; + if (pExynosComponent == NULL) { + ret = OMX_ErrorBadParameter; goto EXIT; } - *data = (OMX_PTR)tempData; - ret = OMX_ErrorNone; + if (nPortIndex >= pExynosComponent->portParam.nPorts) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + pExynosPort = &(pExynosComponent->pExynosPort[nPortIndex]); + + Exynos_OSAL_SemaphoreWait(pExynosPort->codecSemID); + pTempData = (OMX_PTR)Exynos_OSAL_Dequeue(&pExynosPort->codecBufferQ); + if (pTempData != NULL) { + *pData = (OMX_PTR)pTempData; + ret = OMX_ErrorNone; + } else { + *pData = NULL; + ret = OMX_ErrorUndefined; + } EXIT: FunctionOut(); @@ -969,20 +1145,32 @@ EXIT: return ret; } -OMX_ERRORTYPE Exynos_CodecBufferReset(EXYNOS_OMX_BASECOMPONENT *pExynosComponent, OMX_U32 PortIndex) +OMX_ERRORTYPE Exynos_CodecBufferReset( + EXYNOS_OMX_BASECOMPONENT *pExynosComponent, + OMX_U32 nPortIndex) { - OMX_ERRORTYPE ret = OMX_ErrorNone; - EXYNOS_OMX_BASEPORT *pExynosPort = NULL; + OMX_ERRORTYPE ret = OMX_ErrorNone; + EXYNOS_OMX_BASEPORT *pExynosPort = NULL; FunctionIn(); - pExynosPort= &pExynosComponent->pExynosPort[PortIndex]; + if (pExynosComponent == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + + if (nPortIndex >= pExynosComponent->portParam.nPorts) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + pExynosPort = &(pExynosComponent->pExynosPort[nPortIndex]); ret = Exynos_OSAL_ResetQueue(&pExynosPort->codecBufferQ); if (ret != 0) { ret = OMX_ErrorUndefined; goto EXIT; } + while (1) { int cnt = 0; Exynos_OSAL_Get_SemaphoreCount(pExynosPort->codecSemID, &cnt); @@ -1002,12 +1190,12 @@ EXIT: OMX_ERRORTYPE Exynos_OMX_VideoEncodeGetParameter( OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_INDEXTYPE nParamIndex, - OMX_INOUT OMX_PTR ComponentParameterStructure) + OMX_INOUT OMX_PTR pComponentParameterStructure) { - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; - EXYNOS_OMX_BASEPORT *pExynosPort = NULL; + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; + EXYNOS_OMX_BASEPORT *pExynosPort = NULL; FunctionIn(); @@ -1016,6 +1204,7 @@ OMX_ERRORTYPE Exynos_OMX_VideoEncodeGetParameter( goto EXIT; } pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); if (ret != OMX_ErrorNone) { goto EXIT; @@ -1027,12 +1216,12 @@ OMX_ERRORTYPE Exynos_OMX_VideoEncodeGetParameter( } pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - if (pExynosComponent->currentState == OMX_StateInvalid ) { + if (pExynosComponent->currentState == OMX_StateInvalid) { ret = OMX_ErrorInvalidState; goto EXIT; } - if (ComponentParameterStructure == NULL) { + if (pComponentParameterStructure == NULL) { ret = OMX_ErrorBadParameter; goto EXIT; } @@ -1040,183 +1229,191 @@ OMX_ERRORTYPE Exynos_OMX_VideoEncodeGetParameter( switch (nParamIndex) { case OMX_IndexParamVideoInit: { - OMX_PORT_PARAM_TYPE *portParam = (OMX_PORT_PARAM_TYPE *)ComponentParameterStructure; - ret = Exynos_OMX_Check_SizeVersion(portParam, sizeof(OMX_PORT_PARAM_TYPE)); + OMX_PORT_PARAM_TYPE *pPortParam = (OMX_PORT_PARAM_TYPE *)pComponentParameterStructure; + ret = Exynos_OMX_Check_SizeVersion(pPortParam, sizeof(OMX_PORT_PARAM_TYPE)); if (ret != OMX_ErrorNone) { goto EXIT; } - portParam->nPorts = pExynosComponent->portParam.nPorts; - portParam->nStartPortNumber = pExynosComponent->portParam.nStartPortNumber; + pPortParam->nPorts = pExynosComponent->portParam.nPorts; + pPortParam->nStartPortNumber = pExynosComponent->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; - EXYNOS_OMX_BASEPORT *pExynosPort = NULL; - OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL; - OMX_U32 supportFormatNum = 0; - - ret = Exynos_OMX_Check_SizeVersion(portFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE)); + OMX_VIDEO_PARAM_PORTFORMATTYPE *pPortFormat = (OMX_VIDEO_PARAM_PORTFORMATTYPE *)pComponentParameterStructure; + OMX_U32 nPortIndex = pPortFormat->nPortIndex; + OMX_U32 nIndex = pPortFormat->nIndex; + EXYNOS_OMX_BASEPORT *pExynosPort = NULL; + OMX_PARAM_PORTDEFINITIONTYPE *pPortDef = NULL; + OMX_U32 nSupportFormat = 0; + + ret = Exynos_OMX_Check_SizeVersion(pPortFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE)); if (ret != OMX_ErrorNone) { goto EXIT; } - if ((portIndex >= pExynosComponent->portParam.nPorts)) { + if (nPortIndex >= pExynosComponent->portParam.nPorts) { ret = OMX_ErrorBadPortIndex; goto EXIT; } - - if (portIndex == INPUT_PORT_INDEX) { + if (nPortIndex == INPUT_PORT_INDEX) { pExynosPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; - portDefinition = &pExynosPort->portDefinition; + pPortDef = &pExynosPort->portDefinition; - switch (index) { + switch (nIndex) { case supportFormat_0: - portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused; - portFormat->eColorFormat = OMX_COLOR_FormatYUV420Planar; - portFormat->xFramerate = portDefinition->format.video.xFramerate; + pPortFormat->eCompressionFormat = OMX_VIDEO_CodingUnused; + pPortFormat->eColorFormat = OMX_COLOR_FormatYUV420Planar; + pPortFormat->xFramerate = pPortDef->format.video.xFramerate; break; case supportFormat_1: - portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused; - portFormat->eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar; - portFormat->xFramerate = portDefinition->format.video.xFramerate; + pPortFormat->eCompressionFormat = OMX_VIDEO_CodingUnused; + pPortFormat->eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar; + pPortFormat->xFramerate = pPortDef->format.video.xFramerate; break; case supportFormat_2: - portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused; - portFormat->eColorFormat = OMX_SEC_COLOR_FormatNV12Tiled; - portFormat->xFramerate = portDefinition->format.video.xFramerate; + pPortFormat->eCompressionFormat = OMX_VIDEO_CodingUnused; + pPortFormat->eColorFormat = OMX_SEC_COLOR_FormatNV12Tiled; + pPortFormat->xFramerate = pPortDef->format.video.xFramerate; break; case supportFormat_3: - portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused; - portFormat->eColorFormat = OMX_SEC_COLOR_FormatNV21Linear; - portFormat->xFramerate = portDefinition->format.video.xFramerate; + pPortFormat->eCompressionFormat = OMX_VIDEO_CodingUnused; + pPortFormat->eColorFormat = OMX_SEC_COLOR_FormatNV21Linear; + pPortFormat->xFramerate = pPortDef->format.video.xFramerate; break; case supportFormat_4: - portFormat->eCompressionFormat = OMX_VIDEO_CodingUnused; - portFormat->eColorFormat = OMX_COLOR_FormatAndroidOpaque; - portFormat->xFramerate = portDefinition->format.video.xFramerate; + pPortFormat->eCompressionFormat = OMX_VIDEO_CodingUnused; + pPortFormat->eColorFormat = OMX_COLOR_FormatAndroidOpaque; + pPortFormat->xFramerate = pPortDef->format.video.xFramerate; break; default: - if (index > supportFormat_0) { + if (nIndex > supportFormat_0) { ret = OMX_ErrorNoMore; goto EXIT; } break; } - } else if (portIndex == OUTPUT_PORT_INDEX) { - supportFormatNum = OUTPUT_PORT_SUPPORTFORMAT_NUM_MAX - 1; - if (index > supportFormatNum) { + } else if (nPortIndex == OUTPUT_PORT_INDEX) { + nSupportFormat = OUTPUT_PORT_SUPPORTFORMAT_NUM_MAX - 1; + if (nIndex > nSupportFormat) { ret = OMX_ErrorNoMore; goto EXIT; } pExynosPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; - portDefinition = &pExynosPort->portDefinition; + pPortDef = &pExynosPort->portDefinition; - portFormat->eCompressionFormat = portDefinition->format.video.eCompressionFormat; - portFormat->eColorFormat = portDefinition->format.video.eColorFormat; - portFormat->xFramerate = portDefinition->format.video.xFramerate; + pPortFormat->eCompressionFormat = pPortDef->format.video.eCompressionFormat; + pPortFormat->eColorFormat = pPortDef->format.video.eColorFormat; + pPortFormat->xFramerate = pPortDef->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; - EXYNOS_OMX_BASEPORT *pExynosPort = NULL; - EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL; - OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL; + OMX_VIDEO_PARAM_BITRATETYPE *pVideoBitrate = (OMX_VIDEO_PARAM_BITRATETYPE *)pComponentParameterStructure; + OMX_U32 nPortIndex = pVideoBitrate->nPortIndex; + EXYNOS_OMX_BASEPORT *pExynosPort = NULL; + EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL; + OMX_PARAM_PORTDEFINITIONTYPE *pPortDef = NULL; - if ((portIndex != OUTPUT_PORT_INDEX)) { + if (nPortIndex != OUTPUT_PORT_INDEX) { ret = OMX_ErrorBadPortIndex; goto EXIT; } else { pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; - pExynosPort = &pExynosComponent->pExynosPort[portIndex]; - portDefinition = &pExynosPort->portDefinition; + if (pVideoEnc == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pExynosPort = &pExynosComponent->pExynosPort[nPortIndex]; + pPortDef = &pExynosPort->portDefinition; - videoRateControl->eControlRate = pVideoEnc->eControlRate[portIndex]; - videoRateControl->nTargetBitrate = portDefinition->format.video.nBitrate; + pVideoBitrate->eControlRate = pVideoEnc->eControlRate[nPortIndex]; + pVideoBitrate->nTargetBitrate = pPortDef->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; - EXYNOS_OMX_BASEPORT *pExynosPort = NULL; - EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL; - OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL; + OMX_VIDEO_PARAM_QUANTIZATIONTYPE *pVideoQuantization = (OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pComponentParameterStructure; + OMX_U32 nPortIndex = pVideoQuantization->nPortIndex; + EXYNOS_OMX_BASEPORT *pExynosPort = NULL; + EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL; + OMX_PARAM_PORTDEFINITIONTYPE *pPortDef = NULL; - if ((portIndex != OUTPUT_PORT_INDEX)) { + if (nPortIndex != OUTPUT_PORT_INDEX) { ret = OMX_ErrorBadPortIndex; goto EXIT; } else { pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; - pExynosPort = &pExynosComponent->pExynosPort[portIndex]; - portDefinition = &pExynosPort->portDefinition; + if (pVideoEnc == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pExynosPort = &pExynosComponent->pExynosPort[nPortIndex]; + pPortDef = &pExynosPort->portDefinition; - videoQuantizationControl->nQpI = pVideoEnc->quantization.nQpI; - videoQuantizationControl->nQpP = pVideoEnc->quantization.nQpP; - videoQuantizationControl->nQpB = pVideoEnc->quantization.nQpB; + pVideoQuantization->nQpI = pVideoEnc->quantization.nQpI; + pVideoQuantization->nQpP = pVideoEnc->quantization.nQpP; + pVideoQuantization->nQpB = pVideoEnc->quantization.nQpB; } ret = OMX_ErrorNone; - } break; case OMX_IndexParamPortDefinition: { - OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = (OMX_PARAM_PORTDEFINITIONTYPE *)ComponentParameterStructure; - OMX_U32 portIndex = portDefinition->nPortIndex; - EXYNOS_OMX_BASEPORT *pExynosPort; + OMX_PARAM_PORTDEFINITIONTYPE *pPortDef = (OMX_PARAM_PORTDEFINITIONTYPE *)pComponentParameterStructure; + OMX_U32 nPortIndex = pPortDef->nPortIndex; + EXYNOS_OMX_BASEPORT *pExynosPort = NULL; - if (portIndex >= pExynosComponent->portParam.nPorts) { + if (nPortIndex >= pExynosComponent->portParam.nPorts) { ret = OMX_ErrorBadPortIndex; goto EXIT; } - ret = Exynos_OMX_Check_SizeVersion(portDefinition, sizeof(OMX_PARAM_PORTDEFINITIONTYPE)); + + ret = Exynos_OMX_Check_SizeVersion(pPortDef, sizeof(OMX_PARAM_PORTDEFINITIONTYPE)); if (ret != OMX_ErrorNone) { goto EXIT; } - pExynosPort = &pExynosComponent->pExynosPort[portIndex]; - Exynos_OSAL_Memcpy(portDefinition, &pExynosPort->portDefinition, portDefinition->nSize); + pExynosPort = &pExynosComponent->pExynosPort[nPortIndex]; + Exynos_OSAL_Memcpy(pPortDef, &pExynosPort->portDefinition, pPortDef->nSize); #ifdef USE_STOREMETADATA - if ((portIndex == 0) && (pExynosPort->bStoreMetaData == OMX_TRUE)) { - portDefinition->nBufferSize = MAX_INPUT_METADATA_BUFFER_SIZE; + if ((nPortIndex == 0) && + (pExynosPort->bStoreMetaData == OMX_TRUE)) { + pPortDef->nBufferSize = MAX_INPUT_METADATA_BUFFER_SIZE; } #endif } break; default: { - ret = Exynos_OMX_GetParameter(hComponent, nParamIndex, ComponentParameterStructure); + ret = Exynos_OMX_GetParameter(hComponent, nParamIndex, pComponentParameterStructure); } break; } - EXIT: FunctionOut(); return ret; } + OMX_ERRORTYPE Exynos_OMX_VideoEncodeSetParameter( OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_INDEXTYPE nIndex, - OMX_IN OMX_PTR ComponentParameterStructure) + OMX_IN OMX_INDEXTYPE nParamIndex, + OMX_IN OMX_PTR pComponentParameterStructure) { - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; - EXYNOS_OMX_BASEPORT *pExynosPort = NULL; + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; + EXYNOS_OMX_BASEPORT *pExynosPort = NULL; FunctionIn(); @@ -1225,6 +1422,7 @@ OMX_ERRORTYPE Exynos_OMX_VideoEncodeSetParameter( goto EXIT; } pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); if (ret != OMX_ErrorNone) { goto EXIT; @@ -1236,124 +1434,131 @@ OMX_ERRORTYPE Exynos_OMX_VideoEncodeSetParameter( } pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - if (pExynosComponent->currentState == OMX_StateInvalid ) { + if (pExynosComponent->currentState == OMX_StateInvalid) { ret = OMX_ErrorInvalidState; goto EXIT; } - if (ComponentParameterStructure == NULL) { + if (pComponentParameterStructure == NULL) { ret = OMX_ErrorBadParameter; goto EXIT; } - switch (nIndex) { + switch (nParamIndex) { case OMX_IndexParamVideoPortFormat: { - OMX_VIDEO_PARAM_PORTFORMATTYPE *portFormat = (OMX_VIDEO_PARAM_PORTFORMATTYPE *)ComponentParameterStructure; - OMX_U32 portIndex = portFormat->nPortIndex; - OMX_U32 index = portFormat->nIndex; - EXYNOS_OMX_BASEPORT *pExynosPort = NULL; - OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL; - OMX_U32 supportFormatNum = 0; - - ret = Exynos_OMX_Check_SizeVersion(portFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE)); + OMX_VIDEO_PARAM_PORTFORMATTYPE *pPortFormat = (OMX_VIDEO_PARAM_PORTFORMATTYPE *)pComponentParameterStructure; + OMX_U32 nPortIndex = pPortFormat->nPortIndex; + OMX_U32 nIndex = pPortFormat->nIndex; + OMX_PARAM_PORTDEFINITIONTYPE *pPortDef = NULL; + OMX_U32 nSupportFormat = 0; + + ret = Exynos_OMX_Check_SizeVersion(pPortFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE)); if (ret != OMX_ErrorNone) { goto EXIT; } - if ((portIndex >= pExynosComponent->portParam.nPorts)) { + if (nPortIndex >= pExynosComponent->portParam.nPorts) { ret = OMX_ErrorBadPortIndex; goto EXIT; - } else { - pExynosPort = &pExynosComponent->pExynosPort[portIndex]; - portDefinition = &pExynosPort->portDefinition; - - portDefinition->format.video.eColorFormat = portFormat->eColorFormat; - portDefinition->format.video.eCompressionFormat = portFormat->eCompressionFormat; - portDefinition->format.video.xFramerate = portFormat->xFramerate; } + pPortDef = &(pExynosComponent->pExynosPort[nPortIndex].portDefinition); + + pPortDef->format.video.eColorFormat = pPortFormat->eColorFormat; + pPortDef->format.video.eCompressionFormat = pPortFormat->eCompressionFormat; + pPortDef->format.video.xFramerate = pPortFormat->xFramerate; } break; case OMX_IndexParamVideoBitrate: { - OMX_VIDEO_PARAM_BITRATETYPE *videoRateControl = (OMX_VIDEO_PARAM_BITRATETYPE *)ComponentParameterStructure; - OMX_U32 portIndex = videoRateControl->nPortIndex; - EXYNOS_OMX_BASEPORT *pExynosPort = NULL; - EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL; - OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL; + OMX_VIDEO_PARAM_BITRATETYPE *pVideoBitrate = (OMX_VIDEO_PARAM_BITRATETYPE *)pComponentParameterStructure; + OMX_U32 nPortIndex = pVideoBitrate->nPortIndex; + EXYNOS_OMX_BASEPORT *pExynosPort = NULL; + EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL; + OMX_PARAM_PORTDEFINITIONTYPE *pPortDef = NULL; - if ((portIndex != OUTPUT_PORT_INDEX)) { + if (nPortIndex != OUTPUT_PORT_INDEX) { ret = OMX_ErrorBadPortIndex; goto EXIT; } else { pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; - pExynosPort = &pExynosComponent->pExynosPort[portIndex]; - portDefinition = &pExynosPort->portDefinition; + if (pVideoEnc == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pPortDef = &(pExynosComponent->pExynosPort[nPortIndex].portDefinition); - pVideoEnc->eControlRate[portIndex] = videoRateControl->eControlRate; - portDefinition->format.video.nBitrate = videoRateControl->nTargetBitrate; + pVideoEnc->eControlRate[nPortIndex] = pVideoBitrate->eControlRate; + pPortDef->format.video.nBitrate = pVideoBitrate->nTargetBitrate; } ret = OMX_ErrorNone; } break; case OMX_IndexParamVideoQuantization: { - OMX_VIDEO_PARAM_QUANTIZATIONTYPE *videoQuantizationControl = (OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)ComponentParameterStructure; - OMX_U32 portIndex = videoQuantizationControl->nPortIndex; - EXYNOS_OMX_BASEPORT *pExynosPort = NULL; - EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL; - OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = NULL; + OMX_VIDEO_PARAM_QUANTIZATIONTYPE *pVideoQuantization = (OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pComponentParameterStructure; + OMX_U32 nPortIndex = pVideoQuantization->nPortIndex; + EXYNOS_OMX_BASEPORT *pExynosPort = NULL; + EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL; + OMX_PARAM_PORTDEFINITIONTYPE *pPortDef = NULL; - if ((portIndex != OUTPUT_PORT_INDEX)) { + if (nPortIndex != OUTPUT_PORT_INDEX) { ret = OMX_ErrorBadPortIndex; goto EXIT; } else { pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; - pExynosPort = &pExynosComponent->pExynosPort[portIndex]; - portDefinition = &pExynosPort->portDefinition; + if (pVideoEnc == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pExynosPort = &pExynosComponent->pExynosPort[nPortIndex]; + pPortDef = &pExynosPort->portDefinition; - pVideoEnc->quantization.nQpI = videoQuantizationControl->nQpI; - pVideoEnc->quantization.nQpP = videoQuantizationControl->nQpP; - pVideoEnc->quantization.nQpB = videoQuantizationControl->nQpB; + pVideoEnc->quantization.nQpI = pVideoQuantization->nQpI; + pVideoEnc->quantization.nQpP = pVideoQuantization->nQpP; + pVideoEnc->quantization.nQpB = pVideoQuantization->nQpB; } ret = OMX_ErrorNone; } break; case OMX_IndexParamPortDefinition: { - OMX_PARAM_PORTDEFINITIONTYPE *pPortDefinition = (OMX_PARAM_PORTDEFINITIONTYPE *)ComponentParameterStructure; - OMX_U32 portIndex = pPortDefinition->nPortIndex; - EXYNOS_OMX_BASEPORT *pExynosPort; + OMX_PARAM_PORTDEFINITIONTYPE *pPortDef = (OMX_PARAM_PORTDEFINITIONTYPE *)pComponentParameterStructure; + OMX_U32 nPortIndex = pPortDef->nPortIndex; + EXYNOS_OMX_BASEPORT *pExynosPort = NULL; OMX_U32 width, height, size; - if (portIndex >= pExynosComponent->portParam.nPorts) { + if (nPortIndex >= pExynosComponent->portParam.nPorts) { ret = OMX_ErrorBadPortIndex; goto EXIT; } - ret = Exynos_OMX_Check_SizeVersion(pPortDefinition, sizeof(OMX_PARAM_PORTDEFINITIONTYPE)); + + ret = Exynos_OMX_Check_SizeVersion(pPortDef, sizeof(OMX_PARAM_PORTDEFINITIONTYPE)); if (ret != OMX_ErrorNone) { goto EXIT; } - pExynosPort = &pExynosComponent->pExynosPort[portIndex]; + pExynosPort = &pExynosComponent->pExynosPort[nPortIndex]; - if ((pExynosComponent->currentState != OMX_StateLoaded) && (pExynosComponent->currentState != OMX_StateWaitForResources)) { + if ((pExynosComponent->currentState != OMX_StateLoaded) && + (pExynosComponent->currentState != OMX_StateWaitForResources)) { if (pExynosPort->portDefinition.bEnabled == OMX_TRUE) { ret = OMX_ErrorIncorrectStateOperation; goto EXIT; } } - if (pPortDefinition->nBufferCountActual < pExynosPort->portDefinition.nBufferCountMin) { + + if (pPortDef->nBufferCountActual < pExynosPort->portDefinition.nBufferCountMin) { ret = OMX_ErrorBadParameter; goto EXIT; } - Exynos_OSAL_Memcpy(&pExynosPort->portDefinition, pPortDefinition, pPortDefinition->nSize); - if (portIndex == INPUT_PORT_INDEX) { - EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; + Exynos_OSAL_Memcpy(&pExynosPort->portDefinition, pPortDef, pPortDef->nSize); + if (nPortIndex == INPUT_PORT_INDEX) { + pExynosPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; Exynos_UpdateFrameSize(pOMXComponent); Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pExynosOutputPort->portDefinition.nBufferSize: %d", - pExynosOutputPort->portDefinition.nBufferSize); + pExynosPort->portDefinition.nBufferSize); } ret = OMX_ErrorNone; } @@ -1361,17 +1566,16 @@ OMX_ERRORTYPE Exynos_OMX_VideoEncodeSetParameter( #ifdef USE_STOREMETADATA case OMX_IndexParamStoreMetaDataBuffer: { - ret = Exynos_OSAL_SetANBParameter(hComponent, nIndex, ComponentParameterStructure); + ret = Exynos_OSAL_SetANBParameter(hComponent, nParamIndex, pComponentParameterStructure); } break; #endif default: { - ret = Exynos_OMX_SetParameter(hComponent, nIndex, ComponentParameterStructure); + ret = Exynos_OMX_SetParameter(hComponent, nParamIndex, pComponentParameterStructure); } break; } - EXIT: FunctionOut(); @@ -1379,71 +1583,76 @@ EXIT: } OMX_ERRORTYPE Exynos_OMX_VideoEncodeGetConfig( - OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nIndex, - OMX_PTR pComponentConfigStructure) + OMX_HANDLETYPE hComponent, + OMX_INDEXTYPE nParamIndex, + OMX_PTR pComponentConfigStructure) { - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; FunctionIn(); - if (hComponent == NULL || pComponentConfigStructure == NULL) { + if ((hComponent == NULL) || + (pComponentConfigStructure == NULL)) { ret = OMX_ErrorBadParameter; goto EXIT; } pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); if (ret != OMX_ErrorNone) { goto EXIT; } + if (pOMXComponent->pComponentPrivate == NULL) { ret = OMX_ErrorBadParameter; goto EXIT; } pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + if (pExynosComponent->currentState == OMX_StateInvalid) { ret = OMX_ErrorInvalidState; goto EXIT; } - switch (nIndex) { + switch (nParamIndex) { case OMX_IndexConfigVideoBitrate: { - OMX_VIDEO_CONFIG_BITRATETYPE *pEncodeBitrate = (OMX_VIDEO_CONFIG_BITRATETYPE *)pComponentConfigStructure; - OMX_U32 portIndex = pEncodeBitrate->nPortIndex; - EXYNOS_OMX_BASEPORT *pExynosPort = NULL; + OMX_VIDEO_CONFIG_BITRATETYPE *pConfigBitrate = (OMX_VIDEO_CONFIG_BITRATETYPE *)pComponentConfigStructure; + OMX_U32 nPortIndex = pConfigBitrate->nPortIndex; + EXYNOS_OMX_BASEPORT *pExynosPort = NULL; - if ((portIndex != OUTPUT_PORT_INDEX)) { + if (nPortIndex != OUTPUT_PORT_INDEX) { ret = OMX_ErrorBadPortIndex; goto EXIT; } else { - pExynosPort = &pExynosComponent->pExynosPort[portIndex]; - pEncodeBitrate->nEncodeBitrate = pExynosPort->portDefinition.format.video.nBitrate; + pExynosPort = &pExynosComponent->pExynosPort[nPortIndex]; + pConfigBitrate->nEncodeBitrate = pExynosPort->portDefinition.format.video.nBitrate; } } break; case OMX_IndexConfigVideoFramerate: { - OMX_CONFIG_FRAMERATETYPE *pFramerate = (OMX_CONFIG_FRAMERATETYPE *)pComponentConfigStructure; - OMX_U32 portIndex = pFramerate->nPortIndex; - EXYNOS_OMX_BASEPORT *pExynosPort = NULL; + OMX_CONFIG_FRAMERATETYPE *pConfigFramerate = (OMX_CONFIG_FRAMERATETYPE *)pComponentConfigStructure; + OMX_U32 nPortIndex = pConfigFramerate->nPortIndex; + EXYNOS_OMX_BASEPORT *pExynosPort = NULL; - if ((portIndex != OUTPUT_PORT_INDEX)) { + if (nPortIndex != OUTPUT_PORT_INDEX) { ret = OMX_ErrorBadPortIndex; goto EXIT; } else { - pExynosPort = &pExynosComponent->pExynosPort[portIndex]; - pFramerate->xEncodeFramerate = pExynosPort->portDefinition.format.video.xFramerate; + pExynosPort = &pExynosComponent->pExynosPort[nPortIndex]; + pConfigFramerate->xEncodeFramerate = pExynosPort->portDefinition.format.video.xFramerate; } } break; default: - ret = Exynos_OMX_GetConfig(hComponent, nIndex, pComponentConfigStructure); + { + ret = Exynos_OMX_GetConfig(hComponent, nParamIndex, pComponentConfigStructure); + } break; } - EXIT: FunctionOut(); @@ -1451,85 +1660,96 @@ EXIT: } OMX_ERRORTYPE Exynos_OMX_VideoEncodeSetConfig( - OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nIndex, - OMX_PTR pComponentConfigStructure) + OMX_HANDLETYPE hComponent, + OMX_INDEXTYPE nParamIndex, + OMX_PTR pComponentConfigStructure) { - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; FunctionIn(); - if (hComponent == NULL || pComponentConfigStructure == NULL) { + if ((hComponent == NULL) || + (pComponentConfigStructure == NULL)) { ret = OMX_ErrorBadParameter; goto EXIT; } pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); if (ret != OMX_ErrorNone) { goto EXIT; } + if (pOMXComponent->pComponentPrivate == NULL) { ret = OMX_ErrorBadParameter; goto EXIT; } pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + if (pExynosComponent->currentState == OMX_StateInvalid) { ret = OMX_ErrorInvalidState; goto EXIT; } - switch (nIndex) { + switch (nParamIndex) { case OMX_IndexConfigVideoBitrate: { - OMX_VIDEO_CONFIG_BITRATETYPE *pEncodeBitrate = (OMX_VIDEO_CONFIG_BITRATETYPE *)pComponentConfigStructure; - OMX_U32 portIndex = pEncodeBitrate->nPortIndex; - EXYNOS_OMX_BASEPORT *pExynosPort = NULL; + OMX_VIDEO_CONFIG_BITRATETYPE *pConfigBitrate = (OMX_VIDEO_CONFIG_BITRATETYPE *)pComponentConfigStructure; + OMX_U32 nPortIndex = pConfigBitrate->nPortIndex; + EXYNOS_OMX_BASEPORT *pExynosPort = NULL; - if ((portIndex != OUTPUT_PORT_INDEX)) { + if (nPortIndex != OUTPUT_PORT_INDEX) { ret = OMX_ErrorBadPortIndex; goto EXIT; } else { - pExynosPort = &pExynosComponent->pExynosPort[portIndex]; - pExynosPort->portDefinition.format.video.nBitrate = pEncodeBitrate->nEncodeBitrate; + pExynosPort = &pExynosComponent->pExynosPort[nPortIndex]; + pExynosPort->portDefinition.format.video.nBitrate = pConfigBitrate->nEncodeBitrate; } } break; case OMX_IndexConfigVideoFramerate: { - OMX_CONFIG_FRAMERATETYPE *pFramerate = (OMX_CONFIG_FRAMERATETYPE *)pComponentConfigStructure; - OMX_U32 portIndex = pFramerate->nPortIndex; - EXYNOS_OMX_BASEPORT *pExynosPort = NULL; + OMX_CONFIG_FRAMERATETYPE *pConfigFramerate = (OMX_CONFIG_FRAMERATETYPE *)pComponentConfigStructure; + OMX_U32 nPortIndex = pConfigFramerate->nPortIndex; + EXYNOS_OMX_BASEPORT *pExynosPort = NULL; - if ((portIndex != OUTPUT_PORT_INDEX)) { + if (nPortIndex != OUTPUT_PORT_INDEX) { ret = OMX_ErrorBadPortIndex; goto EXIT; } else { - pExynosPort = &pExynosComponent->pExynosPort[portIndex]; - pExynosPort->portDefinition.format.video.xFramerate = pFramerate->xEncodeFramerate; + pExynosPort = &pExynosComponent->pExynosPort[nPortIndex]; + pExynosPort->portDefinition.format.video.xFramerate = pConfigFramerate->xEncodeFramerate; } } break; case OMX_IndexConfigVideoIntraVOPRefresh: { OMX_CONFIG_INTRAREFRESHVOPTYPE *pIntraRefreshVOP = (OMX_CONFIG_INTRAREFRESHVOPTYPE *)pComponentConfigStructure; - EXYNOS_OMX_VIDEOENC_COMPONENT *pVEncBase = ((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle); - OMX_U32 portIndex = pIntraRefreshVOP->nPortIndex; + EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL; + OMX_U32 nPortIndex = pIntraRefreshVOP->nPortIndex; + + if (pExynosComponent->hComponentHandle == NULL) { + ret = OMX_ErrorBadParameter; + goto EXIT; + } + pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; - if ((portIndex != OUTPUT_PORT_INDEX)) { + if (nPortIndex != OUTPUT_PORT_INDEX) { ret = OMX_ErrorBadPortIndex; goto EXIT; } else { - pVEncBase->IntraRefreshVOP = pIntraRefreshVOP->IntraRefreshVOP; + pVideoEnc->IntraRefreshVOP = pIntraRefreshVOP->IntraRefreshVOP; } } break; default: - ret = Exynos_OMX_SetConfig(hComponent, nIndex, pComponentConfigStructure); + { + ret = Exynos_OMX_SetConfig(hComponent, nParamIndex, pComponentConfigStructure); + } break; } - EXIT: FunctionOut(); @@ -1538,12 +1758,12 @@ EXIT: OMX_ERRORTYPE Exynos_OMX_VideoEncodeGetExtensionIndex( OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_STRING cParameterName, + OMX_IN OMX_STRING szParamName, OMX_OUT OMX_INDEXTYPE *pIndexType) { - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; - EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; + EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; FunctionIn(); @@ -1552,6 +1772,7 @@ OMX_ERRORTYPE Exynos_OMX_VideoEncodeGetExtensionIndex( goto EXIT; } pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; + ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); if (ret != OMX_ErrorNone) { goto EXIT; @@ -1563,25 +1784,25 @@ OMX_ERRORTYPE Exynos_OMX_VideoEncodeGetExtensionIndex( } pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; - if ((cParameterName == NULL) || (pIndexType == NULL)) { + if ((szParamName == NULL) || (pIndexType == NULL)) { ret = OMX_ErrorBadParameter; goto EXIT; } + if (pExynosComponent->currentState == OMX_StateInvalid) { ret = OMX_ErrorInvalidState; goto EXIT; } #ifdef USE_STOREMETADATA - if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_STORE_METADATA_BUFFER) == 0) { - *pIndexType = (OMX_INDEXTYPE) OMX_IndexParamStoreMetaDataBuffer; + if (Exynos_OSAL_Strcmp(szParamName, EXYNOS_INDEX_PARAM_STORE_METADATA_BUFFER) == 0) { + *pIndexType = (OMX_INDEXTYPE)OMX_IndexParamStoreMetaDataBuffer; } else { - ret = Exynos_OMX_GetExtensionIndex(hComponent, cParameterName, pIndexType); + ret = Exynos_OMX_GetExtensionIndex(hComponent, szParamName, pIndexType); } #else - ret = Exynos_OMX_GetExtensionIndex(hComponent, cParameterName, pIndexType); + ret = Exynos_OMX_GetExtensionIndex(hComponent, szParamName, pIndexType); #endif - EXIT: FunctionOut(); diff --git a/component/video/enc/Exynos_OMX_VencControl.h b/component/video/enc/Exynos_OMX_VencControl.h index 61bd7bb..1366230 100644 --- a/component/video/enc/Exynos_OMX_VencControl.h +++ b/component/video/enc/Exynos_OMX_VencControl.h @@ -52,17 +52,17 @@ OMX_ERRORTYPE Exynos_OMX_AllocateBuffer( OMX_IN OMX_PTR pAppPrivate, OMX_IN OMX_U32 nSizeBytes); OMX_ERRORTYPE Exynos_OMX_FreeBuffer( - OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_U32 nPortIndex, + OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_U32 nPortIndex, OMX_IN OMX_BUFFERHEADERTYPE *pBufferHdr); OMX_ERRORTYPE Exynos_OMX_AllocateTunnelBuffer( EXYNOS_OMX_BASEPORT *pOMXBasePort, - OMX_U32 nPortIndex); + OMX_U32 nPortIndex); OMX_ERRORTYPE Exynos_OMX_FreeTunnelBuffer( EXYNOS_OMX_BASEPORT *pOMXBasePort, - OMX_U32 nPortIndex); + OMX_U32 nPortIndex); OMX_ERRORTYPE Exynos_OMX_ComponentTunnelRequest( - OMX_IN OMX_HANDLETYPE hComp, + OMX_IN OMX_HANDLETYPE hComp, OMX_IN OMX_U32 nPort, OMX_IN OMX_HANDLETYPE hTunneledComp, OMX_IN OMX_U32 nTunneledPort, @@ -70,28 +70,28 @@ OMX_ERRORTYPE Exynos_OMX_ComponentTunnelRequest( OMX_ERRORTYPE Exynos_OMX_VideoEncodeGetParameter( OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_INDEXTYPE nParamIndex, - OMX_INOUT OMX_PTR ComponentParameterStructure); + OMX_INOUT OMX_PTR pComponentParameterStructure); OMX_ERRORTYPE Exynos_OMX_VideoEncodeSetParameter( OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_INDEXTYPE nIndex, - OMX_IN OMX_PTR ComponentParameterStructure); + OMX_IN OMX_PTR pComponentParameterStructure); OMX_ERRORTYPE Exynos_OMX_VideoEncodeGetConfig( - OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nIndex, - OMX_PTR pComponentConfigStructure); + OMX_HANDLETYPE hComponent, + OMX_INDEXTYPE nIndex, + OMX_PTR pComponentConfigStructure); OMX_ERRORTYPE Exynos_OMX_VideoEncodeSetConfig( - OMX_HANDLETYPE hComponent, - OMX_INDEXTYPE nIndex, - OMX_PTR pComponentConfigStructure); + OMX_HANDLETYPE hComponent, + OMX_INDEXTYPE nIndex, + OMX_PTR pComponentConfigStructure); OMX_ERRORTYPE Exynos_OMX_VideoEncodeGetExtensionIndex( OMX_IN OMX_HANDLETYPE hComponent, - OMX_IN OMX_STRING cParameterName, + OMX_IN OMX_STRING szParameterName, OMX_OUT OMX_INDEXTYPE *pIndexType); OMX_ERRORTYPE Exynos_InputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent); OMX_ERRORTYPE Exynos_OutputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent); OMX_ERRORTYPE Exynos_OMX_BufferFlush(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex, OMX_BOOL bEvent); -OMX_ERRORTYPE Exynos_FlushInputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATABUFFER *dataBuffer); -OMX_ERRORTYPE Exynos_FlushOutputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATABUFFER *dataBuffer); +OMX_ERRORTYPE Exynos_FlushInputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATABUFFER *pDataBuffer); +OMX_ERRORTYPE Exynos_FlushOutputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATABUFFER *pDataBuffer); #ifdef __cplusplus } #endif diff --git a/component/video/enc/h264/Exynos_OMX_H264enc.c b/component/video/enc/h264/Exynos_OMX_H264enc.c index 689e990..8a1b937 100644 --- a/component/video/enc/h264/Exynos_OMX_H264enc.c +++ b/component/video/enc/h264/Exynos_OMX_H264enc.c @@ -38,7 +38,6 @@ #include "Exynos_OSAL_Android.h" #include "library_register.h" #include "Exynos_OMX_H264enc.h" -#include "ExynosVideoApi.h" #include "Exynos_OSAL_SharedMemory.h" #include "Exynos_OSAL_Event.h" @@ -683,7 +682,7 @@ EXIT: return ret; } -OMX_ERRORTYPE H264CodecEnQueueAllBuffer(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex) +OMX_ERRORTYPE H264CodecEnqueueAllBuffer(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex) { OMX_ERRORTYPE ret = OMX_ErrorNone; EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; @@ -709,7 +708,7 @@ OMX_ERRORTYPE H264CodecEnQueueAllBuffer(OMX_COMPONENTTYPE *pOMXComponent, OMX_U3 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoEnc->pMFCEncInputBuffer[%d]->pVirAddr[0]: 0x%x", i, pVideoEnc->pMFCEncInputBuffer[i]->pVirAddr[0]); Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoEnc->pMFCEncInputBuffer[%d]->pVirAddr[1]: 0x%x", i, pVideoEnc->pMFCEncInputBuffer[i]->pVirAddr[1]); - Exynos_CodecBufferEnQueue(pExynosComponent, INPUT_PORT_INDEX, pVideoEnc->pMFCEncInputBuffer[i]); + Exynos_CodecBufferEnqueue(pExynosComponent, INPUT_PORT_INDEX, pVideoEnc->pMFCEncInputBuffer[i]); } pInbufOps->Clear_Queue(hMFCHandle); @@ -722,7 +721,7 @@ OMX_ERRORTYPE H264CodecEnQueueAllBuffer(OMX_COMPONENTTYPE *pOMXComponent, OMX_U3 for (i = 0; i < MFC_OUTPUT_BUFFER_NUM_MAX; i++) { pOutbufOps->Get_Buffer(hMFCHandle, i, &pBuffer); - Exynos_CodecBufferEnQueue(pExynosComponent, OUTPUT_PORT_INDEX, (OMX_PTR)pBuffer); + Exynos_CodecBufferEnqueue(pExynosComponent, OUTPUT_PORT_INDEX, (OMX_PTR)pBuffer); Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoEnc->pMFCEncOutputBuffer[%d]: 0x%x", i, pVideoEnc->pMFCEncOutputBuffer[i]); Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoEnc->pMFCEncInputBuffer[%d]->pVirAddr[0]: 0x%x", i, pVideoEnc->pMFCEncInputBuffer[i]->pVirAddr[0]); Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoEnc->pMFCEncInputBuffer[%d]->pVirAddr[1]: 0x%x", i, pVideoEnc->pMFCEncInputBuffer[i]->pVirAddr[1]); @@ -790,7 +789,7 @@ OMX_ERRORTYPE H264CodecSrcSetup(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DAT /* input buffer info: only 3 config values needed */ Exynos_OSAL_Memset(&bufferConf, 0, sizeof(bufferConf)); - bufferConf.eColorFormat = pEncParam->commonParam.FrameMap;//VIDEO_COLORFORMAT_NV12; + bufferConf.eColorFormat = pEncParam->commonParam.FrameMap; bufferConf.nFrameWidth = pExynosInputPort->portDefinition.format.video.nFrameWidth; bufferConf.nFrameHeight = pExynosInputPort->portDefinition.format.video.nFrameHeight; pInbufOps->Set_Shareable(hMFCHandle); @@ -1589,11 +1588,11 @@ OMX_ERRORTYPE Exynos_H264Enc_Init(OMX_COMPONENTTYPE *pOMXComponent) pVideoEnc->pMFCEncInputBuffer[i]->fd[2] = -1; pVideoEnc->pMFCEncInputBuffer[i]->bufferSize[2] = 0; - Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "pVideoEnc->pMFCEncInputBuffer[%d]: 0x%x", i, pVideoEnc->pMFCEncInputBuffer[i]); - Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "pVideoEnc->pMFCEncInputBuffer[%d]->pVirAddr[0]: 0x%x", i, pVideoEnc->pMFCEncInputBuffer[i]->pVirAddr[0]); - Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "pVideoEnc->pMFCEncInputBuffer[%d]->pVirAddr[1]: 0x%x", i, pVideoEnc->pMFCEncInputBuffer[i]->pVirAddr[1]); + Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoEnc->pMFCEncInputBuffer[%d]: 0x%x", i, pVideoEnc->pMFCEncInputBuffer[i]); + Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoEnc->pMFCEncInputBuffer[%d]->pVirAddr[0]: 0x%x", i, pVideoEnc->pMFCEncInputBuffer[i]->pVirAddr[0]); + Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoEnc->pMFCEncInputBuffer[%d]->pVirAddr[1]: 0x%x", i, pVideoEnc->pMFCEncInputBuffer[i]->pVirAddr[1]); - Exynos_CodecBufferEnQueue(pExynosComponent, INPUT_PORT_INDEX, pVideoEnc->pMFCEncInputBuffer[i]); + Exynos_CodecBufferEnqueue(pExynosComponent, INPUT_PORT_INDEX, pVideoEnc->pMFCEncInputBuffer[i]); } } else if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) { /*************/ @@ -1767,8 +1766,8 @@ OMX_ERRORTYPE Exynos_H264Enc_SrcIn(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_ #ifdef USE_METADATABUFFERTYPE nAllocLen[0] = ALIGN_TO_16B(pExynosInputPort->portDefinition.format.video.nFrameWidth) * - ALIGN_TO_16B(pExynosInputPort->portDefinition.format.video.nFrameHeight); - nAllocLen[1] = ALIGN(nAllocLen[0]/2,256); + ALIGN_TO_16B(pExynosInputPort->portDefinition.format.video.nFrameHeight); + nAllocLen[1] = ALIGN(nAllocLen[0] / 2,256); if ((pExynosInputPort->bStoreMetaData == OMX_TRUE) && (pExynosInputPort->bufferProcessType & BUFFER_SHARE)) { @@ -2163,7 +2162,9 @@ EXIT: return ret; } -OSCL_EXPORT_REF OMX_ERRORTYPE Exynos_OMX_ComponentInit(OMX_HANDLETYPE hComponent, OMX_STRING componentName) +OSCL_EXPORT_REF OMX_ERRORTYPE Exynos_OMX_ComponentInit( + OMX_HANDLETYPE hComponent, + OMX_STRING componentName) { OMX_ERRORTYPE ret = OMX_ErrorNone; OMX_COMPONENTTYPE *pOMXComponent = NULL; @@ -2286,7 +2287,7 @@ OSCL_EXPORT_REF OMX_ERRORTYPE Exynos_OMX_ComponentInit(OMX_HANDLETYPE hComponent pVideoEnc->exynos_codec_start = &H264CodecStart; pVideoEnc->exynos_codec_stop = &H264CodecStop; pVideoEnc->exynos_codec_bufferProcessRun = &H264CodecOutputBufferProcessRun; - pVideoEnc->exynos_codec_enqueueAllBuffer = &H264CodecEnQueueAllBuffer; + pVideoEnc->exynos_codec_enqueueAllBuffer = &H264CodecEnqueueAllBuffer; pVideoEnc->exynos_checkInputFrame = NULL; pVideoEnc->exynos_codec_getCodecInputPrivateData = &GetCodecInputPrivateData; diff --git a/component/video/enc/h264/Exynos_OMX_H264enc.h b/component/video/enc/h264/Exynos_OMX_H264enc.h index 4e66be6..cdd9747 100644 --- a/component/video/enc/h264/Exynos_OMX_H264enc.h +++ b/component/video/enc/h264/Exynos_OMX_H264enc.h @@ -31,6 +31,8 @@ #include "OMX_Component.h" #include "OMX_Video.h" +#include "ExynosVideoApi.h" + typedef struct _EXTRA_DATA { OMX_PTR pHeaderSPS; diff --git a/component/video/enc/h264/library_register.h b/component/video/enc/h264/library_register.h index b05475f..1d2022a 100644 --- a/component/video/enc/h264/library_register.h +++ b/component/video/enc/h264/library_register.h @@ -37,7 +37,7 @@ #define MAX_COMPONENT_ROLE_NUM 1 /* H.264 */ -#define EXYNOS_OMX_COMPONENT_H264_ENC "OMX.Exynos.AVC.Encoder" +#define EXYNOS_OMX_COMPONENT_H264_ENC "OMX.Exynos.AVC.Encoder" #define EXYNOS_OMX_COMPONENT_H264_ENC_ROLE "video_encoder.avc" diff --git a/component/video/enc/mpeg4/Exynos_OMX_Mpeg4enc.c b/component/video/enc/mpeg4/Exynos_OMX_Mpeg4enc.c index 5b7ab78..4a5f174 100644 --- a/component/video/enc/mpeg4/Exynos_OMX_Mpeg4enc.c +++ b/component/video/enc/mpeg4/Exynos_OMX_Mpeg4enc.c @@ -38,7 +38,6 @@ #include "Exynos_OSAL_Android.h" #include "library_register.h" #include "Exynos_OMX_Mpeg4enc.h" -#include "ExynosVideoApi.h" #include "Exynos_OSAL_SharedMemory.h" #include "Exynos_OSAL_Event.h" @@ -805,7 +804,7 @@ EXIT: return ret; } -OMX_ERRORTYPE Mpeg4CodecEnQueueAllBuffer(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex) +OMX_ERRORTYPE Mpeg4CodecEnqueueAllBuffer(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex) { OMX_ERRORTYPE ret = OMX_ErrorNone; EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; @@ -831,7 +830,7 @@ OMX_ERRORTYPE Mpeg4CodecEnQueueAllBuffer(OMX_COMPONENTTYPE *pOMXComponent, OMX_U Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoEnc->pMFCEncInputBuffer[%d]->pVirAddr[0]: 0x%x", i, pVideoEnc->pMFCEncInputBuffer[i]->pVirAddr[0]); Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoEnc->pMFCEncInputBuffer[%d]->pVirAddr[1]: 0x%x", i, pVideoEnc->pMFCEncInputBuffer[i]->pVirAddr[1]); - Exynos_CodecBufferEnQueue(pExynosComponent, INPUT_PORT_INDEX, pVideoEnc->pMFCEncInputBuffer[i]); + Exynos_CodecBufferEnqueue(pExynosComponent, INPUT_PORT_INDEX, pVideoEnc->pMFCEncInputBuffer[i]); } pInbufOps->Clear_Queue(hMFCHandle); @@ -844,7 +843,7 @@ OMX_ERRORTYPE Mpeg4CodecEnQueueAllBuffer(OMX_COMPONENTTYPE *pOMXComponent, OMX_U for (i = 0; i < MFC_OUTPUT_BUFFER_NUM_MAX; i++) { pOutbufOps->Get_Buffer(hMFCHandle, i, &pBuffer); - Exynos_CodecBufferEnQueue(pExynosComponent, OUTPUT_PORT_INDEX, (OMX_PTR)pBuffer); + Exynos_CodecBufferEnqueue(pExynosComponent, OUTPUT_PORT_INDEX, (OMX_PTR)pBuffer); Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoEnc->pMFCEncOutputBuffer[%d]: 0x%x", i, pVideoEnc->pMFCEncOutputBuffer[i]); Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoEnc->pMFCEncInputBuffer[%d]->pVirAddr[0]: 0x%x", i, pVideoEnc->pMFCEncInputBuffer[i]->pVirAddr[0]); Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoEnc->pMFCEncInputBuffer[%d]->pVirAddr[1]: 0x%x", i, pVideoEnc->pMFCEncInputBuffer[i]->pVirAddr[1]); @@ -916,7 +915,7 @@ OMX_ERRORTYPE Mpeg4CodecSrcSetup(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DA /* input buffer info: only 3 config values needed */ Exynos_OSAL_Memset(&bufferConf, 0, sizeof(bufferConf)); - bufferConf.eColorFormat = pEncParam->commonParam.FrameMap;//VIDEO_COLORFORMAT_NV12; + bufferConf.eColorFormat = pEncParam->commonParam.FrameMap; bufferConf.nFrameWidth = pExynosInputPort->portDefinition.format.video.nFrameWidth; bufferConf.nFrameHeight = pExynosInputPort->portDefinition.format.video.nFrameHeight; pInbufOps->Set_Shareable(hMFCHandle); @@ -1799,11 +1798,11 @@ OMX_ERRORTYPE Exynos_Mpeg4Enc_Init(OMX_COMPONENTTYPE *pOMXComponent) pVideoEnc->pMFCEncInputBuffer[i]->fd[2] = -1; pVideoEnc->pMFCEncInputBuffer[i]->bufferSize[2] = 0; - Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "pVideoEnc->pMFCEncInputBuffer[%d]: 0x%x", i, pVideoEnc->pMFCEncInputBuffer[i]); - Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "pVideoEnc->pMFCEncInputBuffer[%d]->pVirAddr[0]: 0x%x", i, pVideoEnc->pMFCEncInputBuffer[i]->pVirAddr[0]); - Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "pVideoEnc->pMFCEncInputBuffer[%d]->pVirAddr[1]: 0x%x", i, pVideoEnc->pMFCEncInputBuffer[i]->pVirAddr[1]); + Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoEnc->pMFCEncInputBuffer[%d]: 0x%x", i, pVideoEnc->pMFCEncInputBuffer[i]); + Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoEnc->pMFCEncInputBuffer[%d]->pVirAddr[0]: 0x%x", i, pVideoEnc->pMFCEncInputBuffer[i]->pVirAddr[0]); + Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoEnc->pMFCEncInputBuffer[%d]->pVirAddr[1]: 0x%x", i, pVideoEnc->pMFCEncInputBuffer[i]->pVirAddr[1]); - Exynos_CodecBufferEnQueue(pExynosComponent, INPUT_PORT_INDEX, pVideoEnc->pMFCEncInputBuffer[i]); + Exynos_CodecBufferEnqueue(pExynosComponent, INPUT_PORT_INDEX, pVideoEnc->pMFCEncInputBuffer[i]); } } else if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) { /*************/ @@ -1977,8 +1976,8 @@ OMX_ERRORTYPE Exynos_Mpeg4Enc_SrcIn(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX #ifdef USE_METADATABUFFERTYPE nAllocLen[0] = ALIGN_TO_16B(pExynosInputPort->portDefinition.format.video.nFrameWidth) * - ALIGN_TO_16B(pExynosInputPort->portDefinition.format.video.nFrameHeight); - nAllocLen[1] = ALIGN(nAllocLen[0]/2,256); + ALIGN_TO_16B(pExynosInputPort->portDefinition.format.video.nFrameHeight); + nAllocLen[1] = ALIGN(nAllocLen[0] / 2,256); if ((pExynosInputPort->bStoreMetaData == OMX_TRUE) && (pExynosInputPort->bufferProcessType & BUFFER_SHARE)) { @@ -2357,7 +2356,9 @@ EXIT: return ret; } -OSCL_EXPORT_REF OMX_ERRORTYPE Exynos_OMX_ComponentInit(OMX_HANDLETYPE hComponent, OMX_STRING componentName) +OSCL_EXPORT_REF OMX_ERRORTYPE Exynos_OMX_ComponentInit( + OMX_HANDLETYPE hComponent, + OMX_STRING componentName) { OMX_ERRORTYPE ret = OMX_ErrorNone; OMX_COMPONENTTYPE *pOMXComponent = NULL; @@ -2521,7 +2522,7 @@ OSCL_EXPORT_REF OMX_ERRORTYPE Exynos_OMX_ComponentInit(OMX_HANDLETYPE hComponent pVideoEnc->exynos_codec_start = &Mpeg4CodecStart; pVideoEnc->exynos_codec_stop = &Mpeg4CodecStop; pVideoEnc->exynos_codec_bufferProcessRun = &Mpeg4CodecOutputBufferProcessRun; - pVideoEnc->exynos_codec_enqueueAllBuffer = &Mpeg4CodecEnQueueAllBuffer; + pVideoEnc->exynos_codec_enqueueAllBuffer = &Mpeg4CodecEnqueueAllBuffer; pVideoEnc->exynos_checkInputFrame = NULL; pVideoEnc->exynos_codec_getCodecInputPrivateData = &GetCodecInputPrivateData; diff --git a/component/video/enc/mpeg4/Exynos_OMX_Mpeg4enc.h b/component/video/enc/mpeg4/Exynos_OMX_Mpeg4enc.h index a258587..aaf9477 100644 --- a/component/video/enc/mpeg4/Exynos_OMX_Mpeg4enc.h +++ b/component/video/enc/mpeg4/Exynos_OMX_Mpeg4enc.h @@ -31,6 +31,8 @@ #include "OMX_Component.h" #include "OMX_Video.h" +#include "ExynosVideoApi.h" + typedef enum _CODEC_TYPE { CODEC_TYPE_H263, diff --git a/osal/Exynos_OSAL_Android.cpp b/osal/Exynos_OSAL_Android.cpp index 142580c..f47e78b 100644 --- a/osal/Exynos_OSAL_Android.cpp +++ b/osal/Exynos_OSAL_Android.cpp @@ -48,6 +48,8 @@ #include "Exynos_OSAL_Android.h" #include "exynos_format.h" +#include "ExynosVideoApi.h" + #undef EXYNOS_LOG_TAG #define EXYNOS_LOG_TAG "Exynos_OSAL_Android" #define EXYNOS_LOG_OFF @@ -399,7 +401,6 @@ OMX_ERRORTYPE Exynos_OSAL_SetANBParameter( goto EXIT; } - switch (nIndex) { case OMX_IndexParamEnableAndroidBuffers: { diff --git a/osal/Exynos_OSAL_Queue.c b/osal/Exynos_OSAL_Queue.c index 4f226f7..fa9583c 100644 --- a/osal/Exynos_OSAL_Queue.c +++ b/osal/Exynos_OSAL_Queue.c @@ -167,7 +167,7 @@ int Exynos_OSAL_SetElemNum(EXYNOS_QUEUE *queueHandle, int ElemNum) return -1; Exynos_OSAL_MutexLock(queue->qMutex); - queue->numElem = ElemNum; + queue->numElem = ElemNum; Exynos_OSAL_MutexUnlock(queue->qMutex); return ElemNum; } diff --git a/osal/Exynos_OSAL_SharedMemory.c b/osal/Exynos_OSAL_SharedMemory.c index 38e23e2..f452117 100644 --- a/osal/Exynos_OSAL_SharedMemory.c +++ b/osal/Exynos_OSAL_SharedMemory.c @@ -174,7 +174,6 @@ OMX_PTR Exynos_OSAL_SharedMemory_Alloc(OMX_HANDLETYPE handle, OMX_U32 size, MEMO } IONBuffer = ion_alloc((ion_client)pHandle->hIONHandle, size, 0, mask, flag); - if (IONBuffer <= 0) { Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "ion_alloc Error: %d", IONBuffer); Exynos_OSAL_Free((OMX_PTR)pElement); -- 2.20.1