From 728e5d6fd6342fd7f5395c1bfafc384cdd77eb5f Mon Sep 17 00:00:00 2001 From: SeungBeom Kim Date: Mon, 30 Mar 2015 14:14:58 +0200 Subject: [PATCH] video_enc: Change scheme of codec buffer alloc in video encode The case of input port copy mode in video encode, need codec buffer. This patch supports dynamic calculation of the buffer size of the codec. Backported-from: hardware/samsung_slsi/exynos5 Change-Id: Iac1ad718003061519fc9d0673d257406a4c77fd7 Signed-off-by: Andreas Schneider --- component/video/enc/Exynos_OMX_Venc.c | 51 ++++++++++--------- component/video/enc/h264/Exynos_OMX_H264enc.c | 37 +------------- .../video/enc/mpeg4/Exynos_OMX_Mpeg4enc.c | 37 +------------- 3 files changed, 28 insertions(+), 97 deletions(-) diff --git a/component/video/enc/Exynos_OMX_Venc.c b/component/video/enc/Exynos_OMX_Venc.c index 6e6438e..919a8b4 100644 --- a/component/video/enc/Exynos_OMX_Venc.c +++ b/component/video/enc/Exynos_OMX_Venc.c @@ -824,35 +824,36 @@ OMX_ERRORTYPE Exynos_OMX_ExtensionSetup(OMX_HANDLETYPE hComponent) break; } - if ((exynosInputPort->bufferProcessType & BUFFER_COPY) == BUFFER_COPY) { - OMX_U32 nPlaneSize[MAX_BUFFER_PLANE] = {0, 0, 0}; + } else { + pExtBufferInfo->eColorFormat = eColorFormat; + } + } - nPlaneSize[0] = DEFAULT_MFC_INPUT_YBUFFER_SIZE; - nPlaneSize[1] = DEFAULT_MFC_INPUT_CBUFFER_SIZE; + if ((exynosInputPort->bufferProcessType & BUFFER_COPY) == BUFFER_COPY) { + OMX_U32 nPlaneSize[MAX_BUFFER_PLANE] = {0, 0, 0}; - if (pVideoEnc->nInbufSpareSize > 0) { - nPlaneSize[0] = DEFAULT_MFC_INPUT_YBUFFER_SIZE + pVideoEnc->nInbufSpareSize; - nPlaneSize[1] = DEFAULT_MFC_INPUT_CBUFFER_SIZE + pVideoEnc->nInbufSpareSize; - } + nPlaneSize[0] = DEFAULT_MFC_INPUT_YBUFFER_SIZE; + nPlaneSize[1] = DEFAULT_MFC_INPUT_CBUFFER_SIZE; + + if (pVideoEnc->nInbufSpareSize > 0) { + nPlaneSize[0] = DEFAULT_MFC_INPUT_YBUFFER_SIZE + pVideoEnc->nInbufSpareSize; + nPlaneSize[1] = DEFAULT_MFC_INPUT_CBUFFER_SIZE + pVideoEnc->nInbufSpareSize; + } - Exynos_OSAL_SemaphoreCreate(&exynosInputPort->codecSemID); - Exynos_OSAL_QueueCreate(&exynosInputPort->codecBufferQ, MAX_QUEUE_ELEMENTS); + Exynos_OSAL_SemaphoreCreate(&exynosInputPort->codecSemID); + Exynos_OSAL_QueueCreate(&exynosInputPort->codecBufferQ, MAX_QUEUE_ELEMENTS); - ret = Exynos_Allocate_CodecBuffers(pOMXComponent, INPUT_PORT_INDEX, MFC_INPUT_BUFFER_NUM_MAX, nPlaneSize); - if (ret != OMX_ErrorNone) - goto EXIT; + ret = Exynos_Allocate_CodecBuffers(pOMXComponent, INPUT_PORT_INDEX, MFC_INPUT_BUFFER_NUM_MAX, nPlaneSize); + if (ret != OMX_ErrorNone) + goto EXIT; - for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) - Exynos_CodecBufferEnqueue(pExynosComponent, INPUT_PORT_INDEX, pVideoEnc->pMFCEncInputBuffer[i]); - } else if (exynosInputPort->bufferProcessType == BUFFER_SHARE) { - /*************/ - /* TBD */ - /*************/ - /* Does not require any actions. */ - } - } else { - pExtBufferInfo->eColorFormat = eColorFormat; - } + for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) + Exynos_CodecBufferEnqueue(pExynosComponent, INPUT_PORT_INDEX, pVideoEnc->pMFCEncInputBuffer[i]); + } else if (exynosInputPort->bufferProcessType == BUFFER_SHARE) { + /*************/ + /* TBD */ + /*************/ + /* Does not require any actions. */ } EXIT: @@ -1404,7 +1405,7 @@ OMX_ERRORTYPE Exynos_OMX_VideoEncodeComponentInit(OMX_IN OMX_HANDLETYPE hCompone pExynosComponent->bSaveFlagEOS = OMX_FALSE; pExynosComponent->bBehaviorEOS = OMX_FALSE; - pVideoEnc->bFirstInput = OMX_FALSE; + pVideoEnc->bFirstInput = OMX_TRUE; pVideoEnc->bFirstOutput = OMX_FALSE; pVideoEnc->configChange = OMX_FALSE; pVideoEnc->bQosChanged = OMX_FALSE; diff --git a/component/video/enc/h264/Exynos_OMX_H264enc.c b/component/video/enc/h264/Exynos_OMX_H264enc.c index c8622ac..b65fe9e 100644 --- a/component/video/enc/h264/Exynos_OMX_H264enc.c +++ b/component/video/enc/h264/Exynos_OMX_H264enc.c @@ -1615,42 +1615,6 @@ OMX_ERRORTYPE Exynos_H264Enc_Init(OMX_COMPONENTTYPE *pOMXComponent) pVideoEnc->nInbufSpareSize = pInbufOps->Get_SpareSize(hMFCHandle); pExynosInputPort->nPlaneCnt = MFC_DEFAULT_INPUT_BUFFER_PLANE; - if ((pExynosInputPort->bStoreMetaData != OMX_TRUE) && - (eColorFormat != OMX_COLOR_FormatAndroidOpaque)) { - if (pExynosInputPort->bufferProcessType & BUFFER_COPY) { - OMX_U32 nPlaneSize[MAX_BUFFER_PLANE] = {0, 0, 0}; - - if (pVideoEnc->bRGBSupport == OMX_TRUE) { - pExynosInputPort->nPlaneCnt = Exynos_OSAL_GetPlaneCount(eColorFormat); - Exynos_OSAL_GetPlaneSize(eColorFormat, ALIGN_TO_16B(1920), ALIGN_TO_16B(1080), nPlaneSize); - } else { - pExtBufferInfo->eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar; - pExynosInputPort->nPlaneCnt = Exynos_OSAL_GetPlaneCount(OMX_COLOR_FormatYUV420SemiPlanar); - Exynos_OSAL_GetPlaneSize(OMX_COLOR_FormatYUV420SemiPlanar, ALIGN_TO_16B(1920), ALIGN_TO_16B(1080), nPlaneSize); - } - - if (pVideoEnc->nInbufSpareSize > 0) { - for (i = 0; i < pExynosInputPort->nPlaneCnt; i++) - nPlaneSize[i] += pVideoEnc->nInbufSpareSize; - } - - Exynos_OSAL_SemaphoreCreate(&pExynosInputPort->codecSemID); - Exynos_OSAL_QueueCreate(&pExynosInputPort->codecBufferQ, MAX_QUEUE_ELEMENTS); - - ret = Exynos_Allocate_CodecBuffers(pOMXComponent, INPUT_PORT_INDEX, MFC_INPUT_BUFFER_NUM_MAX, nPlaneSize); - if (ret != OMX_ErrorNone) - goto EXIT; - - for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) - Exynos_CodecBufferEnqueue(pExynosComponent, INPUT_PORT_INDEX, pVideoEnc->pMFCEncInputBuffer[i]); - } else if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) { - /*************/ - /* TBD */ - /*************/ - /* Does not require any actions. */ - } - } - pExynosOutputPort->nPlaneCnt = MFC_DEFAULT_OUTPUT_BUFFER_PLANE; if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) { Exynos_OSAL_SemaphoreCreate(&pExynosOutputPort->codecSemID); @@ -1746,6 +1710,7 @@ OMX_ERRORTYPE Exynos_H264Enc_Terminate(OMX_COMPONENTTYPE *pOMXComponent) Exynos_Free_CodecBuffers(pOMXComponent, INPUT_PORT_INDEX); Exynos_OSAL_QueueTerminate(&pExynosInputPort->codecBufferQ); Exynos_OSAL_SemaphoreTerminate(pExynosInputPort->codecSemID); + pVideoEnc->bFirstInput = OMX_TRUE; } else if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) { /*************/ /* TBD */ diff --git a/component/video/enc/mpeg4/Exynos_OMX_Mpeg4enc.c b/component/video/enc/mpeg4/Exynos_OMX_Mpeg4enc.c index c282f24..5a942d5 100644 --- a/component/video/enc/mpeg4/Exynos_OMX_Mpeg4enc.c +++ b/component/video/enc/mpeg4/Exynos_OMX_Mpeg4enc.c @@ -1776,42 +1776,6 @@ OMX_ERRORTYPE Exynos_Mpeg4Enc_Init(OMX_COMPONENTTYPE *pOMXComponent) pVideoEnc->nInbufSpareSize = pInbufOps->Get_SpareSize(hMFCHandle); pExynosInputPort->nPlaneCnt = MFC_DEFAULT_INPUT_BUFFER_PLANE; - if ((pExynosInputPort->bStoreMetaData != OMX_TRUE) && - (eColorFormat != OMX_COLOR_FormatAndroidOpaque)) { - if (pExynosInputPort->bufferProcessType & BUFFER_COPY) { - OMX_U32 nPlaneSize[MAX_BUFFER_PLANE] = {0, 0, 0}; - - if (pVideoEnc->bRGBSupport == OMX_TRUE) { - pExynosInputPort->nPlaneCnt = Exynos_OSAL_GetPlaneCount(eColorFormat); - Exynos_OSAL_GetPlaneSize(eColorFormat, ALIGN_TO_16B(1920), ALIGN_TO_16B(1080), nPlaneSize); - } else { - pExtBufferInfo->eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar; - pExynosInputPort->nPlaneCnt = Exynos_OSAL_GetPlaneCount(OMX_COLOR_FormatYUV420SemiPlanar); - Exynos_OSAL_GetPlaneSize(OMX_COLOR_FormatYUV420SemiPlanar, ALIGN_TO_16B(1920), ALIGN_TO_16B(1080), nPlaneSize); - } - - if (pVideoEnc->nInbufSpareSize > 0) { - for (i = 0; i < pExynosInputPort->nPlaneCnt; i++) - nPlaneSize[i] += pVideoEnc->nInbufSpareSize; - } - - Exynos_OSAL_SemaphoreCreate(&pExynosInputPort->codecSemID); - Exynos_OSAL_QueueCreate(&pExynosInputPort->codecBufferQ, MAX_QUEUE_ELEMENTS); - - ret = Exynos_Allocate_CodecBuffers(pOMXComponent, INPUT_PORT_INDEX, MFC_INPUT_BUFFER_NUM_MAX, nPlaneSize); - if (ret != OMX_ErrorNone) - goto EXIT; - - for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) - Exynos_CodecBufferEnqueue(pExynosComponent, INPUT_PORT_INDEX, pVideoEnc->pMFCEncInputBuffer[i]); - } else if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) { - /*************/ - /* TBD */ - /*************/ - /* Does not require any actions. */ - } - } - pExynosOutputPort->nPlaneCnt = MFC_DEFAULT_OUTPUT_BUFFER_PLANE; if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) { Exynos_OSAL_SemaphoreCreate(&pExynosOutputPort->codecSemID); @@ -1901,6 +1865,7 @@ OMX_ERRORTYPE Exynos_Mpeg4Enc_Terminate(OMX_COMPONENTTYPE *pOMXComponent) Exynos_Free_CodecBuffers(pOMXComponent, INPUT_PORT_INDEX); Exynos_OSAL_QueueTerminate(&pExynosInputPort->codecBufferQ); Exynos_OSAL_SemaphoreTerminate(pExynosInputPort->codecSemID); + pVideoEnc->bFirstInput = OMX_TRUE; } else if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) { /*************/ /* TBD */ -- 2.20.1