exynos_omx: multi_thread: Support for CTS DecodeEditEncodeTest.
authorSeungBeom Kim <sbcrux.kim@samsung.com>
Mon, 11 Mar 2013 05:31:56 +0000 (14:31 +0900)
committerGreg Hackmann <ghackmann@google.com>
Fri, 22 Mar 2013 23:09:39 +0000 (16:09 -0700)
Added code to check the length of the input data in encoding time.

Bug: 8329017

Change-Id: I58e84625bf4b56c90404cbe3b5abc2bf693f1673
Signed-off-by: SeungBeom Kim <sbcrux.kim@samsung.com>
exynos_omx/openmax/exynos_omx/component/video/enc/Exynos_OMX_Venc.c
exynos_omx/openmax/exynos_omx/osal/Exynos_OSAL_Android.cpp
exynos_omx/openmax/exynos_omx/osal/Exynos_OSAL_Android.h
libcsc/csc_helper.c

index 86b06c9443a0b7e8c98c39425696cac5c895094f..a34ce73c841dd7649724b67122512b311f9d329d 100644 (file)
@@ -220,6 +220,7 @@ OMX_BOOL Exynos_CSC_InputData(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA
             ExynosVideoPlane planes[MAX_BUFFER_PLANE];
             size_t i;
 
+            csc_src_color_format = omx_2_hal_pixel_format((unsigned int)Exynos_OSAL_GetANBColorFormat(ppBuf[0]));
             Exynos_OSAL_LockANBHandle((OMX_U32)ppBuf[0], nFrameWidth, nFrameHeight, OMX_COLOR_FormatAndroidOpaque, planes);
 
 #if defined(USE_CSC_GSCALER) || defined(USE_CSC_G2D)
@@ -340,34 +341,43 @@ 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) {
+
+                if (inputUseBuffer->dataLen <= 0) {
+                    if (!(inputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS)) {
+                        Exynos_InputBufferReturn(pOMXComponent);
+
+                        /* reset dataBuffer */
+                        Exynos_ResetDataBuffer(inputUseBuffer);
+                    } else {
+                        /* Make EOS Buffer for MFC Processing scheme */
+                        /* Use ION Allocator */
+                        /*Alloc Y-Buffer */
+                        allocSize[0] = nFrameWidth * nFrameHeight;
+                        srcInputData->buffer.multiPlaneBuffer.dataBuffer[0] = (void *)Exynos_OSAL_SharedMemory_Alloc(pVideoEnc->hSharedMemory, allocSize[0], NORMAL_MEMORY);
+                        srcInputData->buffer.multiPlaneBuffer.fd[0] = Exynos_OSAL_SharedMemory_VirtToION(pVideoEnc->hSharedMemory, srcInputData->buffer.multiPlaneBuffer.dataBuffer[0]);
+                        /*Alloc C-Buffer */
+                        allocSize[1] = nFrameWidth * nFrameHeight >> 1;
+                        srcInputData->buffer.multiPlaneBuffer.dataBuffer[1] = (void *)Exynos_OSAL_SharedMemory_Alloc(pVideoEnc->hSharedMemory, allocSize[1], NORMAL_MEMORY);
+                        srcInputData->buffer.multiPlaneBuffer.fd[1] = Exynos_OSAL_SharedMemory_VirtToION(pVideoEnc->hSharedMemory, srcInputData->buffer.multiPlaneBuffer.dataBuffer[1]);
+                        /* input buffers are 2 plane. */
+                        srcInputData->buffer.multiPlaneBuffer.dataBuffer[2] = NULL;
+                        srcInputData->buffer.multiPlaneBuffer.fd[2] = -1;
+                    }
+                } else {
                     Exynos_OSAL_GetInfoFromMetaData((OMX_BYTE)inputUseBuffer->bufferHeader->pBuffer, ppBuf);
-                    ExynosVideoPlane planes[MAX_BUFFER_PLANE];
 
-                    Exynos_OSAL_LockANBHandle((OMX_U32)ppBuf[0], nFrameWidth, nFrameHeight, OMX_COLOR_FormatYUV420SemiPlanar, planes);
+                    if (eColorFormat == OMX_COLOR_FormatAndroidOpaque) {
+                        ExynosVideoPlane planes[MAX_BUFFER_PLANE];
 
-                    srcInputData->buffer.multiPlaneBuffer.fd[0] = planes[0].fd;
-                    srcInputData->buffer.multiPlaneBuffer.fd[1] = planes[1].fd;
-                    allocSize[0] = nFrameWidth * nFrameHeight;
-                    allocSize[1] = nFrameWidth * nFrameHeight >> 1;
+                        Exynos_OSAL_LockANBHandle((OMX_U32)ppBuf[0], nFrameWidth, nFrameHeight, OMX_COLOR_FormatYUV420SemiPlanar, planes);
 
-                    for (plane = 0; plane < MFC_INPUT_BUFFER_PLANE; plane++) {
-                        srcInputData->buffer.multiPlaneBuffer.dataBuffer[plane] =
-                            Exynos_OSAL_SharedMemory_IONToVirt(pVideoEnc->hSharedMemory, srcInputData->buffer.multiPlaneBuffer.fd[plane]);
-                        if(srcInputData->buffer.multiPlaneBuffer.dataBuffer[plane] == NULL) {
-                            srcInputData->buffer.multiPlaneBuffer.dataBuffer[plane] =
-                                Exynos_OSAL_SharedMemory_Map(pVideoEnc->hSharedMemory, allocSize[plane], srcInputData->buffer.multiPlaneBuffer.fd[plane]);
-                        }
+                        srcInputData->buffer.multiPlaneBuffer.fd[0] = planes[0].fd;
+                        srcInputData->buffer.multiPlaneBuffer.fd[1] = planes[1].fd;
+                    } else {
+                        /* kMetadataBufferTypeCameraSource */
+                        srcInputData->buffer.multiPlaneBuffer.fd[0] = ppBuf[0];
+                        srcInputData->buffer.multiPlaneBuffer.fd[1] = ppBuf[1];
                     }
-                    /* input buffers are 2 plane. */
-                    srcInputData->buffer.multiPlaneBuffer.dataBuffer[2] = NULL;
-                    srcInputData->buffer.multiPlaneBuffer.fd[2] = -1;
-                    Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "%s:%d YAddr: 0x%x CbCrAddr: 0x%x", __FUNCTION__, __LINE__, (unsigned int)ppBuf[0], (unsigned int)ppBuf[0]);
-                } else {
-                    /* kMetadataBufferTypeCameraSource */
-                    Exynos_OSAL_GetInfoFromMetaData((OMX_BYTE)inputUseBuffer->bufferHeader->pBuffer, ppBuf);
-                    srcInputData->buffer.multiPlaneBuffer.fd[0] = ppBuf[0];
-                    srcInputData->buffer.multiPlaneBuffer.fd[1] = ppBuf[1];
                     allocSize[0] = nFrameWidth * nFrameHeight;
                     allocSize[1] = nFrameWidth * nFrameHeight >> 1;
 
@@ -382,7 +392,6 @@ OMX_BOOL Exynos_Preprocessor_InputData(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_
                     /* input buffers are 2 plane. */
                     srcInputData->buffer.multiPlaneBuffer.dataBuffer[2] = NULL;
                     srcInputData->buffer.multiPlaneBuffer.fd[2] = -1;
-                    Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "%s:%d YAddr: 0x%x CbCrAddr: 0x%x", __FUNCTION__, __LINE__, (unsigned int)ppBuf[0], (unsigned int)ppBuf[0]);
                 }
             }
 #endif
@@ -403,23 +412,29 @@ OMX_BOOL Exynos_Preprocessor_InputData(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_
             Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "exynos_checkInputFrame : OMX_TRUE");
 
             if (((srcInputData->allocSize) - (srcInputData->dataLen)) >= copySize) {
-                ret = Exynos_CSC_InputData(pOMXComponent, srcInputData);
-                if (ret) {
-                    inputUseBuffer->dataLen -= copySize;
-                    inputUseBuffer->remainDataLen -= copySize;
-                    inputUseBuffer->usedDataLen += copySize;
-
-                    srcInputData->dataLen += copySize;
-                    srcInputData->remainDataLen += copySize;
-
-                    srcInputData->timeStamp = inputUseBuffer->timeStamp;
-                    srcInputData->nFlags = inputUseBuffer->nFlags;
-                    srcInputData->bufferHeader = inputUseBuffer->bufferHeader;
+                if ((copySize > 0) || (inputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS)) {
+                    ret = OMX_TRUE;
+                    if (copySize > 0)
+                        ret = Exynos_CSC_InputData(pOMXComponent, srcInputData);
+                    if (ret) {
+                        inputUseBuffer->dataLen -= copySize;
+                        inputUseBuffer->remainDataLen -= copySize;
+                        inputUseBuffer->usedDataLen += copySize;
+
+                        srcInputData->dataLen += copySize;
+                        srcInputData->remainDataLen += copySize;
+
+                        srcInputData->timeStamp = inputUseBuffer->timeStamp;
+                        srcInputData->nFlags = inputUseBuffer->nFlags;
+                        srcInputData->bufferHeader = inputUseBuffer->bufferHeader;
+                    } else {
+                        Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Exynos_CSC_InputData() failure");
+                        pExynosComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent,
+                                pExynosComponent->callbackData, OMX_EventError,
+                                OMX_ErrorUndefined, 0, NULL );
+                    }
                 } else {
-                    Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Exynos_CSC_InputData() failure");
-                    pExynosComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent,
-                            pExynosComponent->callbackData, OMX_EventError,
-                            OMX_ErrorUndefined, 0, NULL );
+                    ret = OMX_FALSE;
                 }
             } else {
                 Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "input codec buffer is smaller than decoded input data size Out Length");
@@ -552,7 +567,6 @@ OMX_ERRORTYPE Exynos_OMX_ExtensionSetup(OMX_HANDLETYPE hComponent)
     int i = 0;
     OMX_PTR ppBuf[MAX_BUFFER_PLANE];
 
-
     /* kMetadataBufferTypeGrallocSource */
     if (exynosInputPort->bStoreMetaData == OMX_TRUE) {
         Exynos_OSAL_GetInfoFromMetaData((OMX_BYTE)srcInputUseBuffer->bufferHeader->pBuffer, ppBuf);
@@ -610,7 +624,6 @@ OMX_ERRORTYPE Exynos_OMX_ExtensionSetup(OMX_HANDLETYPE hComponent)
         }
     }
 
-
 EXIT:
 
     return ret;
index b4fa5f214cfef431ce0ddf52612c756a7f3a8784..3a823f6c3d12ef2748f389da1f264c3964263f36 100644 (file)
@@ -612,6 +612,7 @@ OMX_COLOR_FORMATTYPE Exynos_OSAL_Hal2OMXPixelFormat(
     case HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED:
         omx_format = (OMX_COLOR_FORMATTYPE)OMX_SEC_COLOR_FormatNV12Tiled;
         break;
+    case HAL_PIXEL_FORMAT_BGRA_8888:
     case HAL_PIXEL_FORMAT_CUSTOM_ARGB_8888:
         omx_format = OMX_COLOR_Format32bitARGB8888;
         break;
index cfe8c36420257a34ba845cbedc44e25068c1973e..ee1e3420d27280de9392444a5fd458898e863a9f 100644 (file)
@@ -37,6 +37,8 @@
 extern "C" {
 #endif
 
+OMX_COLOR_FORMATTYPE Exynos_OSAL_GetANBColorFormat(OMX_IN OMX_U32 handle);
+
 OMX_ERRORTYPE Exynos_OSAL_GetANBParameter(OMX_IN OMX_HANDLETYPE hComponent,
                                           OMX_IN OMX_INDEXTYPE nIndex,
                                           OMX_INOUT OMX_PTR ComponentParameterStructure);
index d5cb4fb2be5e0af1d9cebb8e07f7a6873d43b664..eb853f3f14dadcec71892d6ca204bbc9b0be1e6d 100644 (file)
@@ -46,6 +46,7 @@ OMX_COLOR_FORMATTYPE hal_2_omx_pixel_format(
     case HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED:
         omx_format = OMX_SEC_COLOR_FormatNV12Tiled;
         break;
+    case HAL_PIXEL_FORMAT_BGRA_8888:
     case HAL_PIXEL_FORMAT_CUSTOM_ARGB_8888:
         omx_format = OMX_COLOR_Format32bitARGB8888;
         break;
@@ -125,7 +126,7 @@ unsigned int hal_2_g2d_pixel_order(unsigned int hal_format)
     switch (hal_format) {
     case HAL_PIXEL_FORMAT_BGRA_8888:
     case HAL_PIXEL_FORMAT_CUSTOM_ARGB_8888:
-        return AX_BGR;
+        return AX_RGB;
 
     case HAL_PIXEL_FORMAT_RGBA_8888:
     case HAL_PIXEL_FORMAT_RGBX_8888:
@@ -139,7 +140,7 @@ unsigned int hal_2_g2d_pixel_order(unsigned int hal_format)
         return P1_Y1CBY0CR;
 
     case HAL_PIXEL_FORMAT_YCbCr_420_SP:
-        return P2_CBCR;
+        return P2_CRCB;
 
     default:
         return ARGB_ORDER_END;