venc: added UnlockANBHandle in video encode component.
authorSeungBeom Kim <sbcrux.kim@samsung.com>
Thu, 20 Dec 2012 02:51:38 +0000 (11:51 +0900)
committerSeungBeom Kim <sbcrux.kim@samsung.com>
Thu, 20 Dec 2012 02:51:38 +0000 (11:51 +0900)
added UnlockANBHandle in video encode component
to support sharing gralloc buffer about input port.
locked ANB is needed unlock before returning.

Change-Id: Ibaf65e50134b3fcc96ad37f49cad5ac6b631e382
Signed-off-by: SeungBeom Kim <sbcrux.kim@samsung.com>
component/common/Exynos_OMX_Baseport.c
component/common/Exynos_OMX_Baseport.h
component/video/dec/Exynos_OMX_VdecControl.c
component/video/dec/Exynos_OMX_VdecControl.h
component/video/enc/Exynos_OMX_Venc.c
component/video/enc/Exynos_OMX_VencControl.c
component/video/enc/Exynos_OMX_VencControl.h
osal/Exynos_OSAL_Android.cpp

index 9ed041d3ec5e307a7928cb12a243ef48ccb5e549..9f14f34d663a2e6de17eed89f7308b21ecc360ba 100644 (file)
@@ -900,19 +900,3 @@ OMX_ERRORTYPE Exynos_Shared_BufferToData(EXYNOS_OMX_DATABUFFER *pUseBuffer, EXYN
 EXIT:
     return ret;
 }
-
-OMX_ERRORTYPE Exynos_Shared_DataToBuffer(EXYNOS_OMX_DATA *pData, EXYNOS_OMX_DATABUFFER *pUseBuffer)
-{
-    OMX_ERRORTYPE ret = OMX_ErrorNone;
-
-    pUseBuffer->bufferHeader          = pData->bufferHeader;
-    pUseBuffer->allocSize             = pData->allocSize;
-    pUseBuffer->dataLen               = pData->dataLen;
-    pUseBuffer->usedDataLen           = pData->usedDataLen;
-    pUseBuffer->remainDataLen         = pData->remainDataLen;
-    pUseBuffer->timeStamp             = pData->timeStamp;
-    pUseBuffer->nFlags                = pData->nFlags;
-    pUseBuffer->pPrivate              = pData->pPrivate;
-
-    return ret;
-}
index 49eb218fbb39766cc2bf948a28572ce5f2beb088..6ec33e5556322ad39a4625b5e62ac01867a0acab 100644 (file)
@@ -205,7 +205,6 @@ OMX_ERRORTYPE Exynos_OMX_Port_Destructor(OMX_HANDLETYPE hComponent);
 OMX_ERRORTYPE Exynos_ResetDataBuffer(EXYNOS_OMX_DATABUFFER *pDataBuffer);
 OMX_ERRORTYPE Exynos_ResetCodecData(EXYNOS_OMX_DATA *pData);
 OMX_ERRORTYPE Exynos_Shared_BufferToData(EXYNOS_OMX_DATABUFFER *pUseBuffer, EXYNOS_OMX_DATA *pData, EXYNOS_OMX_PLANE nPlane);
-OMX_ERRORTYPE Exynos_Shared_DataToBuffer(EXYNOS_OMX_DATA *pData, EXYNOS_OMX_DATABUFFER *pUseBuffer);
 
 #ifdef __cplusplus
 };
index d42f7c8d55d96ab38a947beac4bbcb0b7fcf118b..8569265012c0243dde2da5802da6a4f3247d2733 100644 (file)
@@ -1493,3 +1493,19 @@ EXIT:
     return ret;
 }
 #endif
+
+OMX_ERRORTYPE Exynos_Shared_DataToBuffer(EXYNOS_OMX_DATA *pData, EXYNOS_OMX_DATABUFFER *pUseBuffer)
+{
+    OMX_ERRORTYPE ret = OMX_ErrorNone;
+
+    pUseBuffer->bufferHeader          = pData->bufferHeader;
+    pUseBuffer->allocSize             = pData->allocSize;
+    pUseBuffer->dataLen               = pData->dataLen;
+    pUseBuffer->usedDataLen           = pData->usedDataLen;
+    pUseBuffer->remainDataLen         = pData->remainDataLen;
+    pUseBuffer->timeStamp             = pData->timeStamp;
+    pUseBuffer->nFlags                = pData->nFlags;
+    pUseBuffer->pPrivate              = pData->pPrivate;
+
+    return ret;
+}
index 15d22717e124b86019cc6a6e19aa0ffced9f6d0b..1d41198f67d599af00164e2e2fc97d1655514521 100644 (file)
@@ -96,6 +96,8 @@ OMX_ERRORTYPE Exynos_Shared_ANBBufferToData(EXYNOS_OMX_DATABUFFER *pUseBuffer, E
 OMX_ERRORTYPE Exynos_Shared_DataToANBBuffer(EXYNOS_OMX_DATA *pData, EXYNOS_OMX_DATABUFFER *pUseBuffer, EXYNOS_OMX_BASEPORT *pExynosPort);
 #endif
 
+OMX_ERRORTYPE Exynos_Shared_DataToBuffer(EXYNOS_OMX_DATA *pData, EXYNOS_OMX_DATABUFFER *pUseBuffer);
+
 #ifdef __cplusplus
 }
 #endif
index 62b4c9e195ad4005919bf7c549c42e8042afcfcb..f720885855b0d601dfd8a2108dbbe7bb68d90516 100644 (file)
@@ -610,7 +610,7 @@ OMX_BOOL Exynos_Postprocess_OutputData(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_
     FunctionIn();
 
     if (exynosOutputPort->bufferProcessType & BUFFER_SHARE) {
-        if (Exynos_Shared_DataToBuffer(dstOutputData, outputUseBuffer) == OMX_ErrorNone)
+        if (Exynos_Shared_DataToBuffer(dstOutputData, outputUseBuffer, OMX_FALSE) == OMX_ErrorNone)
             outputUseBuffer->dataValid = OMX_TRUE;
     }
 
@@ -870,7 +870,11 @@ OMX_ERRORTYPE Exynos_OMX_SrcOutputBufferProcess(OMX_HANDLETYPE hComponent)
                         Exynos_CodecBufferEnqueue(pExynosComponent, INPUT_PORT_INDEX, codecBuffer);
                 }
                 if (exynosInputPort->bufferProcessType & BUFFER_SHARE) {
-                    Exynos_Shared_DataToBuffer(&srcOutputData, srcOutputUseBuffer);
+                    OMX_BOOL bNeedUnlock = OMX_FALSE;
+                    OMX_COLOR_FORMATTYPE eColorFormat = exynosInputPort->portDefinition.format.video.eColorFormat;
+                    if (eColorFormat == OMX_COLOR_FormatAndroidOpaque)
+                        bNeedUnlock = OMX_TRUE;
+                    Exynos_Shared_DataToBuffer(&srcOutputData, srcOutputUseBuffer, bNeedUnlock);
                     Exynos_InputBufferReturn(pOMXComponent);
                 }
                 Exynos_ResetCodecData(&srcOutputData);
index 07794a1471fc579d10d3a27c64565ab930259592..88d0724e2238fb70582bf7a6d76e681078cfc565 100644 (file)
@@ -501,6 +501,14 @@ OMX_ERRORTYPE Exynos_OMX_FlushPort(
         if (pExynosPort->bufferProcessType & BUFFER_SHARE) {
             if (pExynosPort->processData.bufferHeader != NULL) {
                 if (nPortIndex == INPUT_PORT_INDEX) {
+#ifdef USE_METADATABUFFERTYPE
+                    if ((pExynosPort->bStoreMetaData == OMX_TRUE) &&
+                        (pExynosPort->portDefinition.format.video.eColorFormat == OMX_COLOR_FormatAndroidOpaque)) {
+                        OMX_PTR ppBuf[MAX_BUFFER_PLANE];
+                        Exynos_OSAL_GetInfoFromMetaData((OMX_BYTE)pExynosPort->processData.bufferHeader->pBuffer, ppBuf);
+                        Exynos_OSAL_UnlockANBHandle(ppBuf[0]);
+                    }
+#endif
                     Exynos_OMX_InputBufferReturn(pOMXComponent, pExynosPort->processData.bufferHeader);
                 } else if (nPortIndex == OUTPUT_PORT_INDEX) {
                     Exynos_OMX_OutputBufferReturn(pOMXComponent, pExynosPort->processData.bufferHeader);
@@ -514,6 +522,14 @@ OMX_ERRORTYPE Exynos_OMX_FlushPort(
                         Exynos_OMX_OutputBufferReturn(pOMXComponent,
                                                       pExynosPort->extendBufferHeader[i].OMXBufferHeader);
                     } else if (nPortIndex == INPUT_PORT_INDEX) {
+#ifdef USE_METADATABUFFERTYPE
+                        if ((pExynosPort->bStoreMetaData == OMX_TRUE) &&
+                            (pExynosPort->portDefinition.format.video.eColorFormat == OMX_COLOR_FormatAndroidOpaque)) {
+                            OMX_PTR ppBuf[MAX_BUFFER_PLANE];
+                            Exynos_OSAL_GetInfoFromMetaData((OMX_BYTE)pExynosPort->extendBufferHeader[i].OMXBufferHeader->pBuffer, ppBuf);
+                            Exynos_OSAL_UnlockANBHandle(ppBuf[0]);
+                        }
+#endif
                         Exynos_OMX_InputBufferReturn(pOMXComponent,
                                                      pExynosPort->extendBufferHeader[i].OMXBufferHeader);
                     }
@@ -1816,3 +1832,25 @@ EXIT:
 
     return ret;
 }
+
+OMX_ERRORTYPE Exynos_Shared_DataToBuffer(EXYNOS_OMX_DATA *pData, EXYNOS_OMX_DATABUFFER *pUseBuffer, OMX_BOOL bNeedUnlock)
+{
+    OMX_ERRORTYPE ret = OMX_ErrorNone;
+
+    pUseBuffer->bufferHeader          = pData->bufferHeader;
+    pUseBuffer->allocSize             = pData->allocSize;
+    pUseBuffer->dataLen               = pData->dataLen;
+    pUseBuffer->usedDataLen           = pData->usedDataLen;
+    pUseBuffer->remainDataLen         = pData->remainDataLen;
+    pUseBuffer->timeStamp             = pData->timeStamp;
+    pUseBuffer->nFlags                = pData->nFlags;
+    pUseBuffer->pPrivate              = pData->pPrivate;
+
+    if ((bNeedUnlock == OMX_TRUE) && (pUseBuffer->bufferHeader != NULL)) {
+        OMX_PTR ppBuf[MAX_BUFFER_PLANE];
+        Exynos_OSAL_GetInfoFromMetaData((OMX_BYTE)pUseBuffer->bufferHeader->pBuffer, ppBuf);
+        Exynos_OSAL_UnlockANBHandle(ppBuf[0]);
+    }
+
+    return ret;
+}
index 1366230293f113504b7bb9410f0b198d969d4d1b..946150bfb243d71d3b8ba1a2bb9d83abc964962c 100644 (file)
@@ -92,6 +92,8 @@ OMX_ERRORTYPE Exynos_OutputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent);
 OMX_ERRORTYPE Exynos_OMX_BufferFlush(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 nPortIndex, OMX_BOOL bEvent);\r
 OMX_ERRORTYPE Exynos_FlushInputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATABUFFER *pDataBuffer);\r
 OMX_ERRORTYPE Exynos_FlushOutputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATABUFFER *pDataBuffer);\r
+OMX_ERRORTYPE Exynos_Shared_DataToBuffer(EXYNOS_OMX_DATA *pData, EXYNOS_OMX_DATABUFFER *pUseBuffer, OMX_BOOL bNeedUnlock);\r
+\r
 #ifdef __cplusplus\r
 }\r
 #endif\r
index 188778bd3707aa09f7eafd738bbfd4aaa3cbe859..9c9a6e2745296aecbbb236d4f36da208659baa21 100644 (file)
@@ -61,6 +61,7 @@ using namespace android;
 extern "C" {
 #endif
 
+static int lockCnt = 0;
 
 OMX_ERRORTYPE Exynos_OSAL_LockANBHandle(
     OMX_IN OMX_U32 handle,
@@ -112,6 +113,8 @@ OMX_ERRORTYPE Exynos_OSAL_LockANBHandle(
         ret = OMX_ErrorUndefined;
         goto EXIT;
     }
+    lockCnt++;
+    Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "%s: lockCnt:%d", __func__, lockCnt);
 
 #ifdef USE_DMA_BUF
     vplanes[0].fd = priv_hnd->fd;
@@ -148,6 +151,8 @@ OMX_ERRORTYPE Exynos_OSAL_UnlockANBHandle(OMX_IN OMX_U32 handle)
         ret = OMX_ErrorUndefined;
         goto EXIT;
     }
+    lockCnt--;
+    Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "%s: lockCnt:%d", __func__, lockCnt);
 
     Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "%s: buffer unlocked: 0x%x", __func__, handle);