From e50b9040b2786c84cbf0995c31ed8d32e428d21a Mon Sep 17 00:00:00 2001 From: Taehwan Kim Date: Wed, 14 Nov 2012 07:08:15 +0000 Subject: [PATCH] venc: modified codecBufferQ scheme about output port what is enqueued in codecBufferQ has been modified to CodecBuffer from VideoBuffer. Change-Id: Ia1c9a9b11d0d92e383be3c3f0b4163fb4b350ddf Signed-off-by: Taehwan Kim --- component/video/enc/Exynos_OMX_Venc.c | 26 ++++++++--------- component/video/enc/Exynos_OMX_Venc.h | 2 +- component/video/enc/h264/Exynos_OMX_H264enc.c | 28 +++++++++++++++---- .../video/enc/mpeg4/Exynos_OMX_Mpeg4enc.c | 28 +++++++++++++++---- 4 files changed, 56 insertions(+), 28 deletions(-) diff --git a/component/video/enc/Exynos_OMX_Venc.c b/component/video/enc/Exynos_OMX_Venc.c index ca6fbc8..8233ac0 100644 --- a/component/video/enc/Exynos_OMX_Venc.c +++ b/component/video/enc/Exynos_OMX_Venc.c @@ -117,23 +117,21 @@ 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_ENC_BUFFER *pCodecBuffer, + EXYNOS_OMX_DATA *pData) { OMX_ERRORTYPE ret = OMX_ErrorNone; - EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; - OMX_PTR pSrcBuf; - OMX_U32 allocSize; - pVideoEnc->exynos_codec_getCodecOutputPrivateData(codecBuffer, &pSrcBuf, &allocSize); - pData->buffer.singlePlaneBuffer.dataBuffer = pSrcBuf; - pData->allocSize = allocSize; + pData->buffer.singlePlaneBuffer.dataBuffer = pCodecBuffer->pVirAddr[0]; + pData->allocSize = pCodecBuffer->bufferSize[0]; 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; @@ -793,13 +791,13 @@ OMX_ERRORTYPE Exynos_OMX_DstInputBufferProcess(OMX_HANDLETYPE hComponent) Exynos_OSAL_MutexLock(dstInputUseBuffer->bufferMutex); if (exynosOutputPort->bufferProcessType & BUFFER_COPY) { - OMX_PTR codecBuffer; - ret = Exynos_CodecBufferDequeue(pExynosComponent, OUTPUT_PORT_INDEX, &codecBuffer); + CODEC_ENC_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) { @@ -878,10 +876,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/enc/Exynos_OMX_Venc.h b/component/video/enc/Exynos_OMX_Venc.h index 7049998..af2f423 100644 --- a/component/video/enc/Exynos_OMX_Venc.h +++ b/component/video/enc/Exynos_OMX_Venc.h @@ -131,7 +131,7 @@ extern "C" { 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_ENC_BUFFER *pCodecBuffer, EXYNOS_OMX_DATA *pData); OMX_ERRORTYPE Exynos_OMX_SrcInputBufferProcess(OMX_HANDLETYPE hComponent); diff --git a/component/video/enc/h264/Exynos_OMX_H264enc.c b/component/video/enc/h264/Exynos_OMX_H264enc.c index 1c141b6..126b023 100644 --- a/component/video/enc/h264/Exynos_OMX_H264enc.c +++ b/component/video/enc/h264/Exynos_OMX_H264enc.c @@ -723,18 +723,15 @@ OMX_ERRORTYPE H264CodecEnqueueAllBuffer(OMX_COMPONENTTYPE *pOMXComponent, OMX_U3 pInbufOps->Clear_Queue(hMFCHandle); } else if ((nPortIndex == OUTPUT_PORT_INDEX) && (pH264Enc->bDestinationStart == OMX_TRUE)) { - OMX_U32 dataLen[2] = {0, 0}; - ExynosVideoBuffer *pBuffer = NULL; - Exynos_CodecBufferReset(pExynosComponent, OUTPUT_PORT_INDEX); for (i = 0; i < MFC_OUTPUT_BUFFER_NUM_MAX; i++) { - pOutbufOps->Get_Buffer(hMFCHandle, i, &pBuffer); - Exynos_CodecBufferEnqueue(pExynosComponent, OUTPUT_PORT_INDEX, (OMX_PTR)pBuffer); Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoEnc->pMFCEncOutputBuffer[%d]: 0x%x", i, pVideoEnc->pMFCEncOutputBuffer[i]); Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoEnc->pMFCEncInputBuffer[%d]->pVirAddr[0]: 0x%x", i, pVideoEnc->pMFCEncInputBuffer[i]->pVirAddr[0]); - Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoEnc->pMFCEncInputBuffer[%d]->pVirAddr[1]: 0x%x", i, pVideoEnc->pMFCEncInputBuffer[i]->pVirAddr[1]); + + Exynos_CodecBufferEnqueue(pExynosComponent, OUTPUT_PORT_INDEX, pVideoEnc->pMFCEncOutputBuffer[i]); } + pOutbufOps->Clear_Queue(hMFCHandle); } @@ -1937,6 +1934,7 @@ OMX_ERRORTYPE Exynos_H264Enc_DstOut(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; EXYNOS_H264ENC_HANDLE *pH264Enc = (EXYNOS_H264ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; + EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; void *hMFCHandle = pH264Enc->hMFCH264Handle.hMFCHandle; ExynosVideoEncOps *pEncOps = pH264Enc->hMFCH264Handle.pEncOps; ExynosVideoEncBufferOps *pOutbufOps = pH264Enc->hMFCH264Handle.pOutbufOps; @@ -1967,6 +1965,24 @@ OMX_ERRORTYPE Exynos_H264Enc_DstOut(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX pDstOutputData->remainDataLen = pVideoBuffer->planes[0].dataSize; 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.singlePlaneBuffer.dataBuffer == + pVideoEnc->pMFCEncOutputBuffer[i]->pVirAddr[0]) { + pDstOutputData->pPrivate = pVideoEnc->pMFCEncOutputBuffer[i]->pVirAddr[0]; + break; + } + } + + if (pDstOutputData->pPrivate == NULL) { + Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Can not find buffer"); + ret = (OMX_ERRORTYPE)OMX_ErrorCodecEncode; + goto EXIT; + } + } + /* For Share Buffer */ pDstOutputData->bufferHeader = (OMX_BUFFERHEADERTYPE *)pVideoBuffer->pPrivate; diff --git a/component/video/enc/mpeg4/Exynos_OMX_Mpeg4enc.c b/component/video/enc/mpeg4/Exynos_OMX_Mpeg4enc.c index ddf0c4d..66382ed 100644 --- a/component/video/enc/mpeg4/Exynos_OMX_Mpeg4enc.c +++ b/component/video/enc/mpeg4/Exynos_OMX_Mpeg4enc.c @@ -845,18 +845,15 @@ OMX_ERRORTYPE Mpeg4CodecEnqueueAllBuffer(OMX_COMPONENTTYPE *pOMXComponent, OMX_U pInbufOps->Clear_Queue(hMFCHandle); } else if ((nPortIndex == OUTPUT_PORT_INDEX) && (pMpeg4Enc->bDestinationStart == OMX_TRUE)) { - OMX_U32 dataLen[2] = {0, 0}; - ExynosVideoBuffer *pBuffer = NULL; - Exynos_CodecBufferReset(pExynosComponent, OUTPUT_PORT_INDEX); for (i = 0; i < MFC_OUTPUT_BUFFER_NUM_MAX; i++) { - pOutbufOps->Get_Buffer(hMFCHandle, i, &pBuffer); - Exynos_CodecBufferEnqueue(pExynosComponent, OUTPUT_PORT_INDEX, (OMX_PTR)pBuffer); Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoEnc->pMFCEncOutputBuffer[%d]: 0x%x", i, pVideoEnc->pMFCEncOutputBuffer[i]); Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoEnc->pMFCEncInputBuffer[%d]->pVirAddr[0]: 0x%x", i, pVideoEnc->pMFCEncInputBuffer[i]->pVirAddr[0]); - Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoEnc->pMFCEncInputBuffer[%d]->pVirAddr[1]: 0x%x", i, pVideoEnc->pMFCEncInputBuffer[i]->pVirAddr[1]); + + Exynos_CodecBufferEnqueue(pExynosComponent, OUTPUT_PORT_INDEX, pVideoEnc->pMFCEncOutputBuffer[i]); } + pOutbufOps->Clear_Queue(hMFCHandle); } @@ -2151,6 +2148,7 @@ OMX_ERRORTYPE Exynos_Mpeg4Enc_DstOut(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OM EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; + EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; void *hMFCHandle = pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle; ExynosVideoEncOps *pEncOps = pMpeg4Enc->hMFCMpeg4Handle.pEncOps; ExynosVideoEncBufferOps *pOutbufOps = pMpeg4Enc->hMFCMpeg4Handle.pOutbufOps; @@ -2181,6 +2179,24 @@ OMX_ERRORTYPE Exynos_Mpeg4Enc_DstOut(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OM pDstOutputData->remainDataLen = pVideoBuffer->planes[0].dataSize; 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.singlePlaneBuffer.dataBuffer == + pVideoEnc->pMFCEncOutputBuffer[i]->pVirAddr[0]) { + pDstOutputData->pPrivate = pVideoEnc->pMFCEncOutputBuffer[i]->pVirAddr[0]; + break; + } + } + + if (pDstOutputData->pPrivate == NULL) { + Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Can not find buffer"); + ret = (OMX_ERRORTYPE)OMX_ErrorCodecEncode; + goto EXIT; + } + } + /* For Share Buffer */ pDstOutputData->bufferHeader = (OMX_BUFFERHEADERTYPE *)pVideoBuffer->pPrivate; -- 2.20.1