vdec: modified codecBufferQ scheme about output port
authorTaehwan Kim <t_h.kim@samsung.com>
Wed, 14 Nov 2012 02:16:12 +0000 (02:16 +0000)
committerTaehwan Kim <t_h.kim@samsung.com>
Thu, 29 Nov 2012 10:37:15 +0000 (10:37 +0000)
What is enqueued in codecBufferQ has been modified
to CodecBuffer from VideoBuffer.

Change-Id: Ib608bc65b4ee0bf2f2f013b86b31b12a2b36db90
Signed-off-by: Taehwan Kim <t_h.kim@samsung.com>
component/video/dec/Exynos_OMX_Vdec.c
component/video/dec/Exynos_OMX_Vdec.h
component/video/dec/h264/Exynos_OMX_H264dec.c
component/video/dec/mpeg2/Exynos_OMX_Mpeg2dec.c
component/video/dec/mpeg4/Exynos_OMX_Mpeg4dec.c
component/video/dec/vc1/Exynos_OMX_Wmvdec.c
component/video/dec/vp8/Exynos_OMX_Vp8dec.c

index f6a6e8f055f4ba65e85b38946194c82468881f51..a309ef1dd1fda30d097beef36287759022b5e670 100644 (file)
@@ -149,25 +149,23 @@ OMX_ERRORTYPE Exynos_Input_CodecBufferToData(EXYNOS_OMX_BASECOMPONENT *pExynosCo
     return ret;
 }
 
-OMX_ERRORTYPE Exynos_Output_CodecBufferToData(EXYNOS_OMX_BASECOMPONENT *pExynosComponent, OMX_PTR codecBuffer, EXYNOS_OMX_DATA *pData)
+OMX_ERRORTYPE Exynos_Output_CodecBufferToData(
+    CODEC_DEC_BUFFER    *pCodecBuffer,
+    EXYNOS_OMX_DATA     *pData)
 {
     OMX_ERRORTYPE                  ret = OMX_ErrorNone;
-    EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
-    OMX_PTR pSrcBuf[MAX_BUFFER_PLANE];
-    OMX_U32 allocSize[MAX_BUFFER_PLANE];
-
-    pVideoDec->exynos_codec_getCodecOutputPrivateData(codecBuffer, pSrcBuf, allocSize);
-    pData->buffer.multiPlaneBuffer.dataBuffer[0] = pSrcBuf[0];
-    pData->buffer.multiPlaneBuffer.dataBuffer[1] = pSrcBuf[1];
-    pData->buffer.multiPlaneBuffer.dataBuffer[2] = pSrcBuf[2];
-    pData->allocSize     = allocSize[0] + allocSize[1] + allocSize[2];
+
+    pData->buffer.multiPlaneBuffer.dataBuffer[0] = pCodecBuffer->pVirAddr[0];
+    pData->buffer.multiPlaneBuffer.dataBuffer[1] = pCodecBuffer->pVirAddr[1];
+    pData->buffer.multiPlaneBuffer.dataBuffer[2] = pCodecBuffer->pVirAddr[2];
+    pData->allocSize     = pCodecBuffer->bufferSize[0] + pCodecBuffer->bufferSize[1] + pCodecBuffer->bufferSize[2];
     pData->dataLen       = 0;
     pData->usedDataLen   = 0;
     pData->remainDataLen = 0;
 
     pData->nFlags        = 0;
     pData->timeStamp     = 0;
-    pData->pPrivate      = codecBuffer;
+    pData->pPrivate      = pCodecBuffer;
     pData->bufferHeader  = NULL;
 
     return ret;
@@ -725,13 +723,13 @@ OMX_ERRORTYPE Exynos_OMX_DstInputBufferProcess(OMX_HANDLETYPE hComponent)
             Exynos_OSAL_MutexLock(dstInputUseBuffer->bufferMutex);
             if (ret != OMX_ErrorOutputBufferUseYet) {
                 if (exynosOutputPort->bufferProcessType & BUFFER_COPY) {
-                    OMX_PTR codecBuffer;
-                    ret = Exynos_CodecBufferDeQueue(pExynosComponent, OUTPUT_PORT_INDEX, &codecBuffer);
+                    CODEC_DEC_BUFFER *pCodecBuffer = NULL;
+                    ret = Exynos_CodecBufferDeQueue(pExynosComponent, OUTPUT_PORT_INDEX, (OMX_PTR *)&pCodecBuffer);
                     if (ret != OMX_ErrorNone) {
                         Exynos_OSAL_MutexUnlock(dstInputUseBuffer->bufferMutex);
                         break;
                     }
-                    Exynos_Output_CodecBufferToData(pExynosComponent, codecBuffer, &dstInputData);
+                    Exynos_Output_CodecBufferToData(pCodecBuffer, &dstInputData);
                 }
 
                 if (exynosOutputPort->bufferProcessType & BUFFER_SHARE) {
@@ -822,10 +820,8 @@ OMX_ERRORTYPE Exynos_OMX_DstOutputBufferProcess(OMX_HANDLETYPE hComponent)
             }
 
             if (exynosOutputPort->bufferProcessType & BUFFER_COPY) {
-                OMX_PTR codecBuffer;
-                codecBuffer = pDstOutputData->pPrivate;
-                if (codecBuffer != NULL) {
-                    Exynos_CodecBufferEnQueue(pExynosComponent, OUTPUT_PORT_INDEX, codecBuffer);
+                if (pDstOutputData->pPrivate != NULL) {
+                    Exynos_CodecBufferEnQueue(pExynosComponent, OUTPUT_PORT_INDEX, pDstOutputData->pPrivate);
                     pDstOutputData->pPrivate = NULL;
                 }
             }
index f701aa506921c9ec30a023556bffe708f76fe135..124fc21d5b04e4efc1106eaf0ea4a7716df8bc1a 100644 (file)
@@ -130,7 +130,7 @@ int calc_plane(int width, int height);
 inline void Exynos_UpdateFrameSize(OMX_COMPONENTTYPE *pOMXComponent);
 OMX_BOOL Exynos_Check_BufferProcess_State(EXYNOS_OMX_BASECOMPONENT *pExynosComponent, OMX_U32 nPortIndex);
 OMX_ERRORTYPE Exynos_Input_CodecBufferToData(EXYNOS_OMX_BASECOMPONENT *pExynosComponent, OMX_PTR codecBuffer, EXYNOS_OMX_DATA *pData);
-OMX_ERRORTYPE Exynos_Output_CodecBufferToData(EXYNOS_OMX_BASECOMPONENT *pExynosComponent, OMX_PTR codecBuffer, EXYNOS_OMX_DATA *pData);
+OMX_ERRORTYPE Exynos_Output_CodecBufferToData(CODEC_DEC_BUFFER *pCodecBuffer, EXYNOS_OMX_DATA *pData);
 
 OMX_ERRORTYPE Exynos_OMX_SrcInputBufferProcess(OMX_HANDLETYPE hComponent);
 OMX_ERRORTYPE Exynos_OMX_SrcOutputBufferProcess(OMX_HANDLETYPE hComponent);
index 9de204d10dd1009cad706631d4a45818527ca970..adc06181ad23d6a3744fe7e42d2f60596a28057a 100644 (file)
@@ -581,16 +581,13 @@ OMX_ERRORTYPE H264CodecEnQueueAllBuffer(OMX_COMPONENTTYPE *pOMXComponent, OMX_U3
         pInbufOps->Clear_Queue(hMFCHandle);
     } else if ((nPortIndex == OUTPUT_PORT_INDEX) &&
                (pH264Dec->bDestinationStart == OMX_TRUE)) {
-        OMX_U32 dataLen[MFC_OUTPUT_BUFFER_PLANE] = {0, 0};
-        ExynosVideoBuffer *pBuffer = NULL;
-
         Exynos_CodecBufferReset(pExynosComponent, OUTPUT_PORT_INDEX);
 
-        nOutbufs = pDecOps->Get_ActualBufferCount(hMFCHandle);
-        nOutbufs += EXTRA_DPB_NUM;
-        for (i = 0; i < nOutbufs; i++) {
-            pOutbufOps->Get_Buffer(hMFCHandle, i, &pBuffer);
-            Exynos_CodecBufferEnQueue(pExynosComponent, OUTPUT_PORT_INDEX, (OMX_PTR)pBuffer);
+        for (i = 0; i < pH264Dec->hMFCH264Handle.maxDPBNum; i++) {
+            Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoDec->pMFCDecOutputBuffer[%d]: 0x%x", i, pVideoDec->pMFCDecOutputBuffer[i]);
+            Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoDec->pMFCDecOutputBuffer[%d]->pVirAddr[0]: 0x%x", i, pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[0]);
+
+            Exynos_CodecBufferEnQueue(pExynosComponent, OUTPUT_PORT_INDEX, pVideoDec->pMFCDecOutputBuffer[i]);
         }
         pOutbufOps->Clear_Queue(hMFCHandle);
     }
@@ -1928,6 +1925,24 @@ OMX_ERRORTYPE Exynos_H264Dec_DstOut(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX
     }
     pDstOutputData->usedDataLen = 0;
     pDstOutputData->pPrivate = pVideoBuffer;
+    if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) {
+        int i = 0;
+        pDstOutputData->pPrivate = NULL;
+        for (i = 0; i < MFC_OUTPUT_BUFFER_NUM_MAX; i++) {
+            if (pDstOutputData->buffer.multiPlaneBuffer.dataBuffer[0] ==
+                pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[0]) {
+                pDstOutputData->pPrivate = pVideoDec->pMFCDecOutputBuffer[i];
+                break;
+            }
+        }
+
+        if (pDstOutputData->pPrivate == NULL) {
+            Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Can not find buffer");
+            ret = (OMX_ERRORTYPE)OMX_ErrorCodecDecode;
+            goto EXIT;
+        }
+    }
+
     /* For Share Buffer */
     pDstOutputData->bufferHeader = (OMX_BUFFERHEADERTYPE *)pVideoBuffer->pPrivate;
 
index cb8b44716244993ea018ed5ef7f928b2955e93f1..238ca92d6df98b2e2596380ade1184abbab72ce1 100644 (file)
@@ -456,16 +456,13 @@ OMX_ERRORTYPE Mpeg2CodecEnQueueAllBuffer(OMX_COMPONENTTYPE *pOMXComponent, OMX_U
         pInbufOps->Clear_Queue(hMFCHandle);
     } else if ((nPortIndex == OUTPUT_PORT_INDEX) &&
                (pMpeg2Dec->bDestinationStart == OMX_TRUE)) {
-        OMX_U32 dataLen[MFC_OUTPUT_BUFFER_PLANE] = {0, 0};
-        ExynosVideoBuffer *pBuffer = NULL;
-
         Exynos_CodecBufferReset(pExynosComponent, OUTPUT_PORT_INDEX);
 
-        nOutbufs = pDecOps->Get_ActualBufferCount(hMFCHandle);
-        nOutbufs += EXTRA_DPB_NUM;
-        for (i = 0; i < nOutbufs; i++) {
-            pOutbufOps->Get_Buffer(hMFCHandle, i, &pBuffer);
-            Exynos_CodecBufferEnQueue(pExynosComponent, OUTPUT_PORT_INDEX, (OMX_PTR)pBuffer);
+        for (i = 0; i < pMpeg2Dec->hMFCMpeg2Handle.maxDPBNum; i++) {
+            Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoDec->pMFCDecOutputBuffer[%d]: 0x%x", i, pVideoDec->pMFCDecOutputBuffer[i]);
+            Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoDec->pMFCDecOutputBuffer[%d]->pVirAddr[0]: 0x%x", i, pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[0]);
+
+            Exynos_CodecBufferEnQueue(pExynosComponent, OUTPUT_PORT_INDEX, pVideoDec->pMFCDecOutputBuffer[i]);
         }
         pOutbufOps->Clear_Queue(hMFCHandle);
     }
@@ -1630,6 +1627,24 @@ OMX_ERRORTYPE Exynos_Mpeg2Dec_DstOut(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OM
     }
     pDstOutputData->usedDataLen = 0;
     pDstOutputData->pPrivate = pVideoBuffer;
+    if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) {
+        int i = 0;
+        pDstOutputData->pPrivate = NULL;
+        for (i = 0; i < MFC_OUTPUT_BUFFER_NUM_MAX; i++) {
+            if (pDstOutputData->buffer.multiPlaneBuffer.dataBuffer[0] ==
+                pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[0]) {
+                pDstOutputData->pPrivate = pVideoDec->pMFCDecOutputBuffer[i];
+                break;
+            }
+        }
+
+        if (pDstOutputData->pPrivate == NULL) {
+            Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Can not find buffer");
+            ret = (OMX_ERRORTYPE)OMX_ErrorCodecDecode;
+            goto EXIT;
+        }
+    }
+
     /* For Share Buffer */
     pDstOutputData->bufferHeader = (OMX_BUFFERHEADERTYPE *)pVideoBuffer->pPrivate;
 
index f0e92220cb168bd911317850aa79ab2bffda6920..81b3dd4887ebfa48270733911d64cbea6d008491 100644 (file)
@@ -673,16 +673,13 @@ OMX_ERRORTYPE Mpeg4CodecEnQueueAllBuffer(OMX_COMPONENTTYPE *pOMXComponent, OMX_U
         pInbufOps->Clear_Queue(hMFCHandle);
     } else if ((nPortIndex == OUTPUT_PORT_INDEX) &&
                (pMpeg4Dec->bDestinationStart == OMX_TRUE)) {
-        OMX_U32 dataLen[MFC_OUTPUT_BUFFER_PLANE] = {0, 0};
-        ExynosVideoBuffer *pBuffer = NULL;
-
         Exynos_CodecBufferReset(pExynosComponent, OUTPUT_PORT_INDEX);
 
-        nOutbufs = pDecOps->Get_ActualBufferCount(hMFCHandle);
-        nOutbufs += EXTRA_DPB_NUM;
-        for (i = 0; i < nOutbufs; i++) {
-            pOutbufOps->Get_Buffer(hMFCHandle, i, &pBuffer);
-            Exynos_CodecBufferEnQueue(pExynosComponent, OUTPUT_PORT_INDEX, (OMX_PTR)pBuffer);
+        for (i = 0; i < pMpeg4Dec->hMFCMpeg4Handle.maxDPBNum; i++) {
+            Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoDec->pMFCDecOutputBuffer[%d]: 0x%x", i, pVideoDec->pMFCDecOutputBuffer[i]);
+            Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoDec->pMFCDecOutputBuffer[%d]->pVirAddr[0]: 0x%x", i, pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[0]);
+
+            Exynos_CodecBufferEnQueue(pExynosComponent, OUTPUT_PORT_INDEX, pVideoDec->pMFCDecOutputBuffer[i]);
         }
         pOutbufOps->Clear_Queue(hMFCHandle);
     }
@@ -1982,6 +1979,24 @@ OMX_ERRORTYPE Exynos_Mpeg4Dec_DstOut(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OM
     }
     pDstOutputData->usedDataLen = 0;
     pDstOutputData->pPrivate = pVideoBuffer;
+    if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) {
+        int i = 0;
+        pDstOutputData->pPrivate = NULL;
+        for (i = 0; i < MFC_OUTPUT_BUFFER_NUM_MAX; i++) {
+            if (pDstOutputData->buffer.multiPlaneBuffer.dataBuffer[0] ==
+                pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[0]) {
+                pDstOutputData->pPrivate = pVideoDec->pMFCDecOutputBuffer[i];
+                break;
+            }
+        }
+
+        if (pDstOutputData->pPrivate == NULL) {
+            Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Can not find buffer");
+            ret = (OMX_ERRORTYPE)OMX_ErrorCodecDecode;
+            goto EXIT;
+        }
+    }
+
     /* For Share Buffer */
     pDstOutputData->bufferHeader = (OMX_BUFFERHEADERTYPE *)pVideoBuffer->pPrivate;
 
index 2182d05281805088ca4b9108728dad44119752ee..cc5a19b95b2f332b776124b186825e75280af9f7 100644 (file)
@@ -690,16 +690,13 @@ OMX_ERRORTYPE WmvCodecEnQueueAllBuffer(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32
         pInbufOps->Clear_Queue(hMFCHandle);
     } else if ((nPortIndex == OUTPUT_PORT_INDEX) &&
                (pWmvDec->bDestinationStart == OMX_TRUE)) {
-        OMX_U32 dataLen[MFC_OUTPUT_BUFFER_PLANE] = {0, 0};
-        ExynosVideoBuffer *pBuffer = NULL;
-
         Exynos_CodecBufferReset(pExynosComponent, OUTPUT_PORT_INDEX);
 
-        nOutbufs = pDecOps->Get_ActualBufferCount(hMFCHandle);
-        nOutbufs += EXTRA_DPB_NUM;
-        for (i = 0; i < nOutbufs; i++) {
-            pOutbufOps->Get_Buffer(hMFCHandle, i, &pBuffer);
-            Exynos_CodecBufferEnQueue(pExynosComponent, OUTPUT_PORT_INDEX, (OMX_PTR)pBuffer);
+        for (i = 0; i < pWmvDec->hMFCWmvHandle.maxDPBNum; i++) {
+            Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoDec->pMFCDecOutputBuffer[%d]: 0x%x", i, pVideoDec->pMFCDecOutputBuffer[i]);
+            Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoDec->pMFCDecOutputBuffer[%d]->pVirAddr[0]: 0x%x", i, pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[0]);
+
+            Exynos_CodecBufferEnQueue(pExynosComponent, OUTPUT_PORT_INDEX, pVideoDec->pMFCDecOutputBuffer[i]);
         }
         pOutbufOps->Clear_Queue(hMFCHandle);
     }
@@ -1861,6 +1858,24 @@ OMX_ERRORTYPE Exynos_WmvDec_DstOut(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_
     }
     pDstOutputData->usedDataLen = 0;
     pDstOutputData->pPrivate = pVideoBuffer;
+    if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) {
+        int i = 0;
+        pDstOutputData->pPrivate = NULL;
+        for (i = 0; i < MFC_OUTPUT_BUFFER_NUM_MAX; i++) {
+            if (pDstOutputData->buffer.multiPlaneBuffer.dataBuffer[0] ==
+                pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[0]) {
+                pDstOutputData->pPrivate = pVideoDec->pMFCDecOutputBuffer[i];
+                break;
+            }
+        }
+
+        if (pDstOutputData->pPrivate == NULL) {
+            Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Can not find buffer");
+            ret = (OMX_ERRORTYPE)OMX_ErrorCodecDecode;
+            goto EXIT;
+        }
+    }
+
     /* For Share Buffer */
     pDstOutputData->bufferHeader = (OMX_BUFFERHEADERTYPE *)pVideoBuffer->pPrivate;
 
index cbc06ff06997a2bfb6a6436a9f6565a4e4a5eda3..59de07f0a69350ae9e80cd0d3689edb679661182 100644 (file)
@@ -488,16 +488,13 @@ OMX_ERRORTYPE VP8CodecEnQueueAllBuffer(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32
         pInbufOps->Clear_Queue(hMFCHandle);
     } else if ((nPortIndex == OUTPUT_PORT_INDEX) &&
                (pVp8Dec->bDestinationStart == OMX_TRUE)) {
-        OMX_U32 dataLen[MFC_OUTPUT_BUFFER_PLANE] = {0, 0};
-        ExynosVideoBuffer *pBuffer = NULL;
-
         Exynos_CodecBufferReset(pExynosComponent, OUTPUT_PORT_INDEX);
 
-        nOutbufs = pDecOps->Get_ActualBufferCount(hMFCHandle);
-        nOutbufs += EXTRA_DPB_NUM;
-        for (i = 0; i < nOutbufs; i++) {
-            pOutbufOps->Get_Buffer(hMFCHandle, i, &pBuffer);
-            Exynos_CodecBufferEnQueue(pExynosComponent, OUTPUT_PORT_INDEX, (OMX_PTR)pBuffer);
+        for (i = 0; i < pVp8Dec->hMFCVp8Handle.maxDPBNum; i++) {
+            Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoDec->pMFCDecOutputBuffer[%d]: 0x%x", i, pVideoDec->pMFCDecOutputBuffer[i]);
+            Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoDec->pMFCDecOutputBuffer[%d]->pVirAddr[0]: 0x%x", i, pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[0]);
+
+            Exynos_CodecBufferEnQueue(pExynosComponent, OUTPUT_PORT_INDEX, pVideoDec->pMFCDecOutputBuffer[i]);
         }
         pOutbufOps->Clear_Queue(hMFCHandle);
     }
@@ -1574,6 +1571,24 @@ OMX_ERRORTYPE Exynos_VP8Dec_DstOut(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_
     }
     pDstOutputData->usedDataLen = 0;
     pDstOutputData->pPrivate = pVideoBuffer;
+    if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) {
+        int i = 0;
+        pDstOutputData->pPrivate = NULL;
+        for (i = 0; i < MFC_OUTPUT_BUFFER_NUM_MAX; i++) {
+            if (pDstOutputData->buffer.multiPlaneBuffer.dataBuffer[0] ==
+                pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[0]) {
+                pDstOutputData->pPrivate = pVideoDec->pMFCDecOutputBuffer[i];
+                break;
+            }
+        }
+
+        if (pDstOutputData->pPrivate == NULL) {
+            Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Can not find buffer");
+            ret = (OMX_ERRORTYPE)OMX_ErrorCodecDecode;
+            goto EXIT;
+        }
+    }
+
     /* For Share Buffer */
     pDstOutputData->bufferHeader = (OMX_BUFFERHEADERTYPE *)pVideoBuffer->pPrivate;