From e90eb9e89198c762ffb1dd9a0747843e6f997ced Mon Sep 17 00:00:00 2001 From: Taehwan Kim Date: Wed, 14 Nov 2012 02:16:12 +0000 Subject: [PATCH] vdec: modified codecBufferQ scheme about output port What is enqueued in codecBufferQ has been modified to CodecBuffer from VideoBuffer. Change-Id: Ib608bc65b4ee0bf2f2f013b86b31b12a2b36db90 Signed-off-by: Taehwan Kim --- component/video/dec/Exynos_OMX_Vdec.c | 32 ++++++++----------- component/video/dec/Exynos_OMX_Vdec.h | 2 +- component/video/dec/h264/Exynos_OMX_H264dec.c | 31 +++++++++++++----- .../video/dec/mpeg2/Exynos_OMX_Mpeg2dec.c | 31 +++++++++++++----- .../video/dec/mpeg4/Exynos_OMX_Mpeg4dec.c | 31 +++++++++++++----- component/video/dec/vc1/Exynos_OMX_Wmvdec.c | 31 +++++++++++++----- component/video/dec/vp8/Exynos_OMX_Vp8dec.c | 31 +++++++++++++----- 7 files changed, 130 insertions(+), 59 deletions(-) diff --git a/component/video/dec/Exynos_OMX_Vdec.c b/component/video/dec/Exynos_OMX_Vdec.c index f6a6e8f..a309ef1 100644 --- a/component/video/dec/Exynos_OMX_Vdec.c +++ b/component/video/dec/Exynos_OMX_Vdec.c @@ -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; } } diff --git a/component/video/dec/Exynos_OMX_Vdec.h b/component/video/dec/Exynos_OMX_Vdec.h index f701aa5..124fc21 100644 --- a/component/video/dec/Exynos_OMX_Vdec.h +++ b/component/video/dec/Exynos_OMX_Vdec.h @@ -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); diff --git a/component/video/dec/h264/Exynos_OMX_H264dec.c b/component/video/dec/h264/Exynos_OMX_H264dec.c index 9de204d..adc0618 100644 --- a/component/video/dec/h264/Exynos_OMX_H264dec.c +++ b/component/video/dec/h264/Exynos_OMX_H264dec.c @@ -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; diff --git a/component/video/dec/mpeg2/Exynos_OMX_Mpeg2dec.c b/component/video/dec/mpeg2/Exynos_OMX_Mpeg2dec.c index cb8b447..238ca92 100644 --- a/component/video/dec/mpeg2/Exynos_OMX_Mpeg2dec.c +++ b/component/video/dec/mpeg2/Exynos_OMX_Mpeg2dec.c @@ -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; diff --git a/component/video/dec/mpeg4/Exynos_OMX_Mpeg4dec.c b/component/video/dec/mpeg4/Exynos_OMX_Mpeg4dec.c index f0e9222..81b3dd4 100644 --- a/component/video/dec/mpeg4/Exynos_OMX_Mpeg4dec.c +++ b/component/video/dec/mpeg4/Exynos_OMX_Mpeg4dec.c @@ -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; diff --git a/component/video/dec/vc1/Exynos_OMX_Wmvdec.c b/component/video/dec/vc1/Exynos_OMX_Wmvdec.c index 2182d05..cc5a19b 100644 --- a/component/video/dec/vc1/Exynos_OMX_Wmvdec.c +++ b/component/video/dec/vc1/Exynos_OMX_Wmvdec.c @@ -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; diff --git a/component/video/dec/vp8/Exynos_OMX_Vp8dec.c b/component/video/dec/vp8/Exynos_OMX_Vp8dec.c index cbc06ff..59de07f 100644 --- a/component/video/dec/vp8/Exynos_OMX_Vp8dec.c +++ b/component/video/dec/vp8/Exynos_OMX_Vp8dec.c @@ -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; -- 2.20.1