From d4ec0f61b9819c82c57daa98b891a3132ffa03b5 Mon Sep 17 00:00:00 2001 From: SeungBeom Kim Date: Fri, 10 Oct 2014 15:05:34 +0900 Subject: [PATCH] exynos_omx: multi_thread: Fix bug for video encode tests. If the output buffer that has been entered is invalid, OMX component may experience problems in Flush operation. This patch performs the following actions. If invalid output buffer has been entered in the codec setup process, OMX Component will return an error. Bug: 17785600 Bug: 17811083 Change-Id: Ida0939fae2b7102ab87d5242c8c71e732aba10a2 Signed-off-by: SeungBeom Kim --- .../component/video/enc/h264/Exynos_OMX_H264enc.c | 11 ++++++++++- .../component/video/enc/mpeg4/Exynos_OMX_Mpeg4enc.c | 13 +++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/exynos_omx/openmax/exynos_omx/component/video/enc/h264/Exynos_OMX_H264enc.c b/exynos_omx/openmax/exynos_omx/component/video/enc/h264/Exynos_OMX_H264enc.c index ee60500..518ed7c 100644 --- a/exynos_omx/openmax/exynos_omx/component/video/enc/h264/Exynos_OMX_H264enc.c +++ b/exynos_omx/openmax/exynos_omx/component/video/enc/h264/Exynos_OMX_H264enc.c @@ -1008,6 +1008,7 @@ OMX_ERRORTYPE H264CodecDstSetup(OMX_COMPONENTTYPE *pOMXComponent) /*************/ /* TBD */ /*************/ + ExynosVideoErrorType codecReturn = VIDEO_ERROR_NONE; ExynosVideoPlane plane; for (i = 0; i < pExynosOutputPort->portDefinition.nBufferCountActual; i++) { plane.addr = pExynosOutputPort->extendBufferHeader[i].OMXBufferHeader->pBuffer; @@ -1018,8 +1019,13 @@ OMX_ERRORTYPE H264CodecDstSetup(OMX_COMPONENTTYPE *pOMXComponent) ret = OMX_ErrorInsufficientResources; goto EXIT; } - pOutbufOps->Enqueue(hMFCHandle, (unsigned char **)&pExynosOutputPort->extendBufferHeader[i].OMXBufferHeader->pBuffer, + codecReturn = pOutbufOps->Enqueue(hMFCHandle, (unsigned char **)&pExynosOutputPort->extendBufferHeader[i].OMXBufferHeader->pBuffer, (unsigned int *)dataLen, MFC_OUTPUT_BUFFER_PLANE, NULL); + if (codecReturn != VIDEO_ERROR_NONE) { + Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Output buffer that has been entered is invalid."); + ret = OMX_ErrorUndefined; + goto EXIT; + } } } @@ -1735,6 +1741,9 @@ OMX_ERRORTYPE Exynos_H264Enc_SrcIn(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_ } if (pH264Enc->hMFCH264Handle.bConfiguredMFCDst == OMX_FALSE) { ret = H264CodecDstSetup(pOMXComponent); + if (ret != OMX_ErrorNone) { + goto EXIT; + } } if (pVideoEnc->configChange == OMX_TRUE) { diff --git a/exynos_omx/openmax/exynos_omx/component/video/enc/mpeg4/Exynos_OMX_Mpeg4enc.c b/exynos_omx/openmax/exynos_omx/component/video/enc/mpeg4/Exynos_OMX_Mpeg4enc.c index e915304..98480f8 100644 --- a/exynos_omx/openmax/exynos_omx/component/video/enc/mpeg4/Exynos_OMX_Mpeg4enc.c +++ b/exynos_omx/openmax/exynos_omx/component/video/enc/mpeg4/Exynos_OMX_Mpeg4enc.c @@ -1136,10 +1136,11 @@ OMX_ERRORTYPE Mpeg4CodecDstSetup(OMX_COMPONENTTYPE *pOMXComponent) (unsigned int *)dataLen, MFC_OUTPUT_BUFFER_PLANE, NULL); } } else if ((pExynosOutputPort->bufferProcessType & BUFFER_SHARE) == BUFFER_SHARE) { - /* Register input buffer */ + /* Register output buffer */ /*************/ /* TBD */ /*************/ + ExynosVideoErrorType codecReturn = VIDEO_ERROR_NONE; ExynosVideoPlane plane; for (i = 0; i < pExynosOutputPort->portDefinition.nBufferCountActual; i++) { plane.addr = pExynosOutputPort->extendBufferHeader[i].OMXBufferHeader->pBuffer; @@ -1150,8 +1151,13 @@ OMX_ERRORTYPE Mpeg4CodecDstSetup(OMX_COMPONENTTYPE *pOMXComponent) ret = OMX_ErrorInsufficientResources; goto EXIT; } - pOutbufOps->Enqueue(hMFCHandle, (unsigned char **)&pExynosOutputPort->extendBufferHeader[i].OMXBufferHeader->pBuffer, + codecReturn = pOutbufOps->Enqueue(hMFCHandle, (unsigned char **)&pExynosOutputPort->extendBufferHeader[i].OMXBufferHeader->pBuffer, (unsigned int *)dataLen, MFC_OUTPUT_BUFFER_PLANE, NULL); + if (codecReturn != VIDEO_ERROR_NONE) { + Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Output buffer that has been entered is invalid."); + ret = OMX_ErrorUndefined; + goto EXIT; + } } } @@ -1933,6 +1939,9 @@ OMX_ERRORTYPE Exynos_Mpeg4Enc_SrcIn(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX } if (pMpeg4Enc->hMFCMpeg4Handle.bConfiguredMFCDst == OMX_FALSE) { ret = Mpeg4CodecDstSetup(pOMXComponent); + if (ret != OMX_ErrorNone) { + goto EXIT; + } } if (pVideoEnc->configChange == OMX_TRUE) { -- 2.20.1