fixed svace issues
[platform/adaptation/ap_samsung/libomxil-e3250-v4l2.git] / openmax / component / video / dec / h264 / Exynos_OMX_H264dec.c
index 54bf2f0..62f2380 100755 (executable)
@@ -27,6 +27,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <mm_types.h>
 
 #include "Exynos_OMX_Macros.h"
 #include "Exynos_OMX_Basecomponent.h"
@@ -41,7 +42,7 @@
 #include "Exynos_OSAL_SharedMemory.h"
 #include "Exynos_OSAL_Event.h"
 
-#include <mm_ta/mm_ta.h>
+
 
 #ifdef USE_PB
 #include "Exynos_OSAL_Platform_Specific.h"
@@ -145,6 +146,7 @@ EXIT:
     return ret;
 }
 
+#ifndef TIZEN_FEATURE_E3250
 int Check_H264_Frame(
     OMX_U8   *pInputStream,
     OMX_U32   buffSize,
@@ -223,6 +225,7 @@ EXIT:
 
     return accessUnitSize;
 }
+#endif
 
 static OMX_BOOL Check_H264_StartCode(
     OMX_U8 *pInputStream,
@@ -517,7 +520,7 @@ OMX_ERRORTYPE H264CodecSrcInit(OMX_COMPONENTTYPE *pOMXComponent)
 
 
     if (pVideoDec->bThumbnailMode == OMX_TRUE)
-        pDecOps->Set_DisplayDelay(hMFCHandle, 0); 
+        pDecOps->Set_DisplayDelay(hMFCHandle, 0);
 
     /* input buffer info */
     Exynos_OSAL_Memset(&bufferConf, 0, sizeof(bufferConf));
@@ -534,7 +537,7 @@ OMX_ERRORTYPE H264CodecSrcInit(OMX_COMPONENTTYPE *pOMXComponent)
     } else if (pExynosInputPort->bufferProcessType & BUFFER_COPY) {
         bufferConf.nSizeImage = DEFAULT_MFC_INPUT_BUFFER_SIZE;
         inputBufferNumber = MFC_INPUT_BUFFER_NUM_MAX;
-    }   
+    }
 
     /* should be done before prepare input buffer */
     if (pInbufOps->Enable_Cacheable(hMFCHandle) != VIDEO_ERROR_NONE) {
@@ -547,7 +550,7 @@ OMX_ERRORTYPE H264CodecSrcInit(OMX_COMPONENTTYPE *pOMXComponent)
         Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to set geometry for input buffer");
         ret = OMX_ErrorInsufficientResources;
         goto EXIT;
-    }   
+    }
 
     /* setup input buffer */
     if (pInbufOps->Setup(hMFCHandle, inputBufferNumber) != VIDEO_ERROR_NONE) {
@@ -596,7 +599,7 @@ OMX_ERRORTYPE H264CodecSrcInit(OMX_COMPONENTTYPE *pOMXComponent)
                 Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "@pVideoDec->pMFCDecInputBuffer[%d]->pVirAddr[%d]: 0x%x", i, plane, pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane]);
             }
 
-#ifdef SLP_PLATFORM
+#ifdef TIZEN_FEATURE_E3250
             if (pExynosInputPort == NULL || pExynosOutputPort == NULL || pOMXComponent == NULL) {
                 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "invalid param: pExynosInputPort= %p pExynosOutputPort= %p pOMXComponent= %p", pExynosInputPort, pExynosOutputPort, pOMXComponent);
             }
@@ -608,7 +611,7 @@ OMX_ERRORTYPE H264CodecSrcInit(OMX_COMPONENTTYPE *pOMXComponent)
         for (i = 0; i < pExynosInputPort->portDefinition.nBufferCountActual; i++) {
             ExynosVideoPlane plane;
             if (pVideoDec->bDRMPlayerMode == OMX_TRUE) {
-#ifdef SLP_PLATFORM
+#ifdef TIZEN_FEATURE_E3250
                 /* IL Client assigns FD value in pBuffer */
                 plane.addr = pExynosInputPort->extendBufferHeader[i].OMXBufferHeader->pBuffer;
 #else
@@ -1027,7 +1030,7 @@ OMX_ERRORTYPE H264CodecSrcSetup(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DAT
 
     /* set output geometry */
     Exynos_OSAL_Memset(&bufferConf, 0, sizeof(bufferConf));
-    pH264Dec->hMFCH264Handle.MFCOutputColorType = bufferConf.eColorFormat = VIDEO_COLORFORMAT_NV12_TILED;
+    pH264Dec->hMFCH264Handle.MFCOutputColorType = bufferConf.eColorFormat = VIDEO_COLORFORMAT_NV12;
     if (pOutbufOps->Set_Geometry(hMFCHandle, &bufferConf) != VIDEO_ERROR_NONE) {
         Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to set geometry for output buffer");
         ret = OMX_ErrorInsufficientResources;
@@ -1061,8 +1064,8 @@ OMX_ERRORTYPE H264CodecSrcSetup(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DAT
     ret = OMX_ErrorInputDataDecodeYet;
 
 #ifdef USE_IMMEDIATE_DISPLAY
-    /* Set Immediately display for I Frame*/   
-   pDecOps->Set_ImmediateDisplay(hMFCHandle); 
+    /* Set Immediately display for I Frame*/
+   pDecOps->Set_ImmediateDisplay(hMFCHandle);
 #endif
 
 EXIT:
@@ -1160,6 +1163,7 @@ OMX_ERRORTYPE H264CodecDstSetup(OMX_COMPONENTTYPE *pOMXComponent)
                 for (plane = 0; plane < MFC_OUTPUT_BUFFER_PLANE; plane++) {
                     planes[plane].fd = pExynosOutputPort->extendBufferHeader[i].buf_fd[plane];
                     planes[plane].addr = pExynosOutputPort->extendBufferHeader[i].pYUVBuf[plane];
+                    planes[plane].tbm_bo = pExynosOutputPort->extendBufferHeader[i].tbm_bo[plane];
                     planes[plane].allocSize = nAllocLen[plane];
                 }
 
@@ -1268,8 +1272,10 @@ OMX_ERRORTYPE H264CodecCheckResolutionChange(OMX_COMPONENTTYPE *pOMXComponent)
              OMX_DirOutput, /* This is the port index */
                  0,
              NULL);
-    }
+        }
     } else if (pExynosOutputPort->bufferProcessType & BUFFER_SHARE) {
+#ifndef TIZEN_FEATURE_E3250
+        /* The input port information has already been updated */
         if ((pExynosInputPort->portDefinition.format.video.nFrameWidth != pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth) ||
             (pExynosInputPort->portDefinition.format.video.nFrameHeight != pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight) ||
             (pExynosOutputPort->portDefinition.nBufferCountActual != pH264Dec->hMFCH264Handle.maxDPBNum)) {
@@ -1277,11 +1283,11 @@ OMX_ERRORTYPE H264CodecCheckResolutionChange(OMX_COMPONENTTYPE *pOMXComponent)
             pExynosInputPort->portDefinition.format.video.nFrameHeight = pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight;
             pExynosInputPort->portDefinition.format.video.nStride = ((pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth + 15) & (~15));
             pExynosInputPort->portDefinition.format.video.nSliceHeight = ((pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight + 15) & (~15));
-
+#endif
             if (pVideoDec->bDRCProcessing == OMX_TRUE) {
                 pVideoDec->nDRCSavedBufferCount = pExynosOutputPort->portDefinition.nBufferCountActual;
             }
-#ifdef SLP_PLATFORM
+#ifdef TIZEN_FEATURE_E3250
             pExynosOutputPort->portDefinition.nBufferCountActual = pH264Dec->hMFCH264Handle.maxDPBNum;
             pExynosOutputPort->portDefinition.nBufferCountMin = pH264Dec->hMFCH264Handle.maxDPBNum;
 #else
@@ -1299,7 +1305,9 @@ OMX_ERRORTYPE H264CodecCheckResolutionChange(OMX_COMPONENTTYPE *pOMXComponent)
                  OMX_DirOutput, /* This is the port index */
                  0,
                  NULL);
+#ifndef TIZEN_FEATURE_E3250
         }
+#endif
     }
 
     if (((pVideoDec->bDRCProcessing) && (pExynosOutputPort->bufferProcessType & BUFFER_COPY)) ||
@@ -1615,9 +1623,10 @@ OMX_ERRORTYPE Exynos_H264Dec_SetParameter(
             case OMX_COLOR_FormatYUV420SemiPlanar:
                 pExynosOutputPort->portDefinition.nBufferSize = (width * height * 3) / 2;
                 break;
-#ifdef SLP_PLATFORM /* NV12T fd */
+#ifdef TIZEN_FEATURE_E3250 /* NV12 fd */
+            case OMX_SEC_COLOR_FormatNV12L_DmaBuf_Fd:
             case OMX_SEC_COLOR_FormatNV12T_DmaBuf_Fd:
-                pExynosOutputPort->portDefinition.nBufferSize = sizeof(SCMN_IMGB);
+                pExynosOutputPort->portDefinition.nBufferSize = sizeof(MMVideoBuffer);
                 break;
 #endif
             case OMX_SEC_COLOR_FormatNV12Tiled:
@@ -1976,7 +1985,7 @@ OMX_ERRORTYPE Exynos_H264Dec_Init(OMX_COMPONENTTYPE *pOMXComponent)
                 Exynos_CodecBufferEnQueue(pExynosComponent, INPUT_PORT_INDEX, pVideoDec->pMFCDecInputBuffer[i]);
             }
         } else {
-#ifdef SLP_PLATFORM
+#ifdef TIZEN_FEATURE_E3250
                 if (pOMXComponent == NULL) {
                     Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s : %d: invalid parm: pOMXComponent = %p", __FUNCTION__, __LINE__, pOMXComponent);
                 }
@@ -2083,7 +2092,7 @@ OMX_ERRORTYPE Exynos_H264Dec_Terminate(OMX_COMPONENTTYPE *pOMXComponent)
     if (pExynosInputPort->bufferProcessType & BUFFER_COPY) {
         for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) {
             if (pVideoDec->pMFCDecInputBuffer[i] != NULL) {
-#ifndef SLP_PLATFORM /* do not use ion */
+#ifndef TIZEN_FEATURE_E3250 /* do not use ion */
                 for (plane = 0; plane < MFC_INPUT_BUFFER_PLANE; plane++) {
                     if (pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane] != NULL)
                         Exynos_OSAL_SharedMemory_Free(pVideoDec->hSharedMemory, pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane]);
@@ -2148,7 +2157,7 @@ OMX_ERRORTYPE Exynos_H264Dec_SrcIn(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_
         pH264Dec->hMFCH264Handle.indexTimestamp %= MAX_TIMESTAMP;
 
 #ifdef USE_IMMEDIATE_DISPLAY
-    /* Set Immediately display for I Frame*/   
+    /* Set Immediately display for I Frame*/
 
         if (pExynosComponent->checkTimeStamp.needCheckStartTimeStamp == OMX_TRUE) {
             if ( pExynosComponent->checkTimeStamp.bImmediateDisplay == OMX_FALSE) {
@@ -2162,7 +2171,7 @@ OMX_ERRORTYPE Exynos_H264Dec_SrcIn(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_
         /*Add First Frame check : */
         if((pSrcInputData->nFlags & OMX_BUFFERFLAG_CODECCONFIG) == OMX_BUFFERFLAG_CODECCONFIG)
         {
-            MMTA_ACUM_ITEM_END("Video First Frame Coming", 0);
+            Exynos_OSAL_Log(EXYNOS_LOG_TRACE,"Video First Frame Coming");
         }
 
         /* queue work for input buffer */
@@ -2233,12 +2242,12 @@ OMX_ERRORTYPE Exynos_H264Dec_SrcOut(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX
         if (pExynosInputPort->bufferProcessType & BUFFER_COPY) {
             int i = 0;
             while (pSrcOutputData->buffer.singlePlaneBuffer.dataBuffer != pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[0]) {
+                i++;
                 if (i >= MFC_INPUT_BUFFER_NUM_MAX) {
                     Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Can not find buffer");
                     ret = (OMX_ERRORTYPE)OMX_ErrorCodecDecode;
                     goto EXIT;
                 }
-                i++;
             }
             pVideoDec->pMFCDecInputBuffer[i]->dataSize = 0;
             pSrcOutputData->pPrivate = pVideoDec->pMFCDecInputBuffer[i];
@@ -2383,6 +2392,7 @@ OMX_ERRORTYPE Exynos_H264Dec_DstOut(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX
     for (plane = 0; plane < MFC_OUTPUT_BUFFER_PLANE; plane++) {
         pDstOutputData->buffer.multiPlaneBuffer.dataBuffer[plane] = pVideoBuffer->planes[plane].addr;
         pDstOutputData->buffer.multiPlaneBuffer.fd[plane] = pVideoBuffer->planes[plane].fd;
+        pDstOutputData->buffer.multiPlaneBuffer.tbm_bo[plane] = pVideoBuffer->planes[plane].tbm_bo;
         pDstOutputData->allocSize += pVideoBuffer->planes[plane].allocSize;
         pDstOutputData->dataLen +=  pVideoBuffer->planes[plane].dataSize;
     }
@@ -2397,8 +2407,8 @@ OMX_ERRORTYPE Exynos_H264Dec_DstOut(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX
     pBufferInfo->imageHeight = bufferGeometry->nFrameHeight;
     switch (bufferGeometry->eColorFormat) {
     case VIDEO_COLORFORMAT_NV12:
-#ifdef SLP_PLATFORM /* NV12T fd */
-        pBufferInfo->ColorFormat = OMX_SEC_COLOR_FormatNV12T_DmaBuf_Fd;
+#ifdef TIZEN_FEATURE_E3250 /* NV12 fd */
+        pBufferInfo->ColorFormat = OMX_SEC_COLOR_FormatNV12L_DmaBuf_Fd;
 #else
         pBufferInfo->ColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
 #endif
@@ -2434,7 +2444,7 @@ OMX_ERRORTYPE Exynos_H264Dec_DstOut(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX
         /* For timestamp correction. if mfc support frametype detect */
         Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "disp_pic_frame_type: %d", pVideoBuffer->frameType);
 //#ifdef NEED_TIMESTAMP_REORDER
-        /* SLP_PLATFORM */
+        /* TIZEN_FEATURE_E3250 */
         if (pVideoDec->bNeedTimestampReorder == OMX_TRUE) {
             Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "NEED_TIMESTAMP_REORDER ON");
             if ((pVideoBuffer->frameType == VIDEO_FRAME_I)) {
@@ -2736,13 +2746,13 @@ OSCL_EXPORT_REF OMX_ERRORTYPE Exynos_OMX_ComponentInit(OMX_HANDLETYPE hComponent
     Exynos_OSAL_Strcpy(pExynosPort->portDefinition.format.video.cMIMEType, "raw/video");
     pExynosPort->portDefinition.format.video.pNativeRender = 0;
     pExynosPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE;
-#ifdef SLP_PLATFORM
-    pExynosPort->portDefinition.format.video.eColorFormat = OMX_SEC_COLOR_FormatNV12T_DmaBuf_Fd;
+#ifdef TIZEN_FEATURE_E3250
+    pExynosPort->portDefinition.format.video.eColorFormat = OMX_SEC_COLOR_FormatNV12L_DmaBuf_Fd;
 #else
     pExynosPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatYUV420Planar;
 #endif
     pExynosPort->portDefinition.bEnabled = OMX_TRUE;
-#ifdef SLP_PLATFORM
+#ifdef TIZEN_FEATURE_E3250
     pExynosPort->bufferProcessType = BUFFER_SHARE;
 #else
     pExynosPort->bufferProcessType = BUFFER_COPY;
@@ -2778,11 +2788,11 @@ OSCL_EXPORT_REF OMX_ERRORTYPE Exynos_OMX_ComponentInit(OMX_HANDLETYPE hComponent
     pVideoDec->exynos_codec_enqueueAllBuffer = &H264CodecEnQueueAllBuffer;
     pVideoDec->exynos_codec_resetupAllElement = &H264CodecResetupAllElement;
 
-    pVideoDec->exynos_checkInputFrame                 = &Check_H264_Frame;
+    pVideoDec->exynos_checkInputFrame                 = NULL;
     pVideoDec->exynos_codec_getCodecInputPrivateData  = &GetCodecInputPrivateData;
     pVideoDec->exynos_codec_getCodecOutputPrivateData = &GetCodecOutputPrivateData;
 
-#ifndef SLP_PLATFORM /* do not use ion */
+#ifndef TIZEN_FEATURE_E3250 /* do not use ion */
     pVideoDec->hSharedMemory = Exynos_OSAL_SharedMemory_Open();
     if (pVideoDec->hSharedMemory == NULL) {
         Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__);
@@ -2821,7 +2831,7 @@ OMX_ERRORTYPE Exynos_OMX_ComponentDeinit(OMX_HANDLETYPE hComponent)
     pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
     pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
 
-#ifndef SLP_PLATFORM /* do not use ion */
+#ifndef TIZEN_FEATURE_E3250 /* do not use ion */
     Exynos_OSAL_SharedMemory_Close(pVideoDec->hSharedMemory);
 #endif
     Exynos_OSAL_Free(pExynosComponent->componentName);