From 743cabb0729891815dbd2594f319cb6cb8637a8c Mon Sep 17 00:00:00 2001 From: SeungBeom Kim Date: Sun, 29 Mar 2015 13:30:08 +0200 Subject: [PATCH] video_dec: Add ThumbnailMode decoding to h264 Extension name: - EXYNOS_INDEX_PARAM_ENABLE_THUMBNAIL "OMX.SEC.index.enableThumbnailMode" Backported-from: hardware/samsung_slsi/exynos5 Change-Id: I630cfa54de361dccfde1f8b56e7b8ba2f534654f Signed-off-by: Andreas Schneider --- component/video/dec/Exynos_OMX_Vdec.h | 2 + component/video/dec/Exynos_OMX_VdecControl.c | 51 +++++++++++++------ component/video/dec/h264/Exynos_OMX_H264dec.c | 27 +++++----- .../video/dec/mpeg4/Exynos_OMX_Mpeg4dec.c | 18 +++---- component/video/dec/vp8/Exynos_OMX_Vp8dec.c | 22 ++++---- include/exynos/Exynos_OMX_Def.h | 11 +++- 6 files changed, 78 insertions(+), 53 deletions(-) diff --git a/component/video/dec/Exynos_OMX_Vdec.h b/component/video/dec/Exynos_OMX_Vdec.h index b4fb164..7e05fbf 100644 --- a/component/video/dec/Exynos_OMX_Vdec.h +++ b/component/video/dec/Exynos_OMX_Vdec.h @@ -65,6 +65,8 @@ #define MAX_INPUTBUFFER_NUM_DYNAMIC 0 /* Dynamic number of metadata buffer */ +#define PLATFORM_DISPLAY_BUFFER 2 + typedef struct { void *pAddrY; diff --git a/component/video/dec/Exynos_OMX_VdecControl.c b/component/video/dec/Exynos_OMX_VdecControl.c index 4357ae8..90e3214 100644 --- a/component/video/dec/Exynos_OMX_VdecControl.c +++ b/component/video/dec/Exynos_OMX_VdecControl.c @@ -1342,6 +1342,26 @@ OMX_ERRORTYPE Exynos_OMX_VideoDecodeSetParameter( pVideoDec->bDTSMode = pDTSParam->bDTSMode; } break; + case OMX_IndexParamEnableThumbnailMode: + { + EXYNOS_OMX_VIDEO_THUMBNAILMODE *pThumbnailMode = (EXYNOS_OMX_VIDEO_THUMBNAILMODE *)ComponentParameterStructure; + EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle; + + ret = Exynos_OMX_Check_SizeVersion(pThumbnailMode, sizeof(EXYNOS_OMX_VIDEO_THUMBNAILMODE)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + + pVideoDec->bThumbnailMode = pThumbnailMode->bEnable; + if (pVideoDec->bThumbnailMode == OMX_TRUE) { + EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; + pExynosOutputPort->portDefinition.nBufferCountMin = 1; + pExynosOutputPort->portDefinition.nBufferCountActual = 1; + } + + ret = OMX_ErrorNone; + } + break; default: { ret = Exynos_OMX_SetParameter(hComponent, nIndex, ComponentParameterStructure); @@ -1448,14 +1468,6 @@ OMX_ERRORTYPE Exynos_OMX_VideoDecodeSetConfig( } switch (nIndex) { - case OMX_IndexVendorThumbnailMode: - { - EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle; - pVideoDec->bThumbnailMode = *((OMX_BOOL *)pComponentConfigStructure); - - ret = OMX_ErrorNone; - } - break; #ifdef USE_QOS_CTRL case OMX_IndexVendorSetQosRatio: { @@ -1542,18 +1554,27 @@ OMX_ERRORTYPE Exynos_OMX_VideoDecodeGetExtensionIndex( #endif #ifdef USE_ANB - if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_ENABLE_ANB) == 0) + if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_ENABLE_ANB) == 0) { *pIndexType = (OMX_INDEXTYPE) OMX_IndexParamEnableAndroidBuffers; - else if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_GET_ANB) == 0) + goto EXIT; + } + if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_GET_ANB) == 0) { *pIndexType = (OMX_INDEXTYPE) OMX_IndexParamGetAndroidNativeBuffer; - else if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_USE_ANB) == 0) + goto EXIT; + } + if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_USE_ANB) == 0) { *pIndexType = (OMX_INDEXTYPE) OMX_IndexParamUseAndroidNativeBuffer; - else - ret = Exynos_OMX_GetExtensionIndex(hComponent, cParameterName, pIndexType); -#else - ret = Exynos_OMX_GetExtensionIndex(hComponent, cParameterName, pIndexType); + goto EXIT; + } #endif + if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_ENABLE_THUMBNAIL) == 0) { + *pIndexType = OMX_IndexParamEnableThumbnailMode; + goto EXIT; + } + + ret = Exynos_OMX_GetExtensionIndex(hComponent, cParameterName, pIndexType); + EXIT: FunctionOut(); diff --git a/component/video/dec/h264/Exynos_OMX_H264dec.c b/component/video/dec/h264/Exynos_OMX_H264dec.c index 3d99689..1b42a88 100644 --- a/component/video/dec/h264/Exynos_OMX_H264dec.c +++ b/component/video/dec/h264/Exynos_OMX_H264dec.c @@ -787,8 +787,11 @@ OMX_ERRORTYPE H264CodecCheckResolutionChange(OMX_COMPONENTTYPE *pOMXComponent) /* get dpb count */ pH264Dec->hMFCH264Handle.maxDPBNum = pDecOps->Get_ActualBufferCount(hMFCHandle); - if (pVideoDec->bThumbnailMode == OMX_FALSE) + if (pVideoDec->bThumbnailMode == OMX_FALSE) { pH264Dec->hMFCH264Handle.maxDPBNum += EXTRA_DPB_NUM; + } else { + pH264Dec->hMFCH264Handle.maxDPBNum += PLATFORM_DISPLAY_BUFFER; + } Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "H264CodecSetup nOutbufs: %d", pH264Dec->hMFCH264Handle.maxDPBNum); pH264Dec->hMFCH264Handle.bConfiguredMFCSrc = OMX_TRUE; @@ -835,8 +838,8 @@ OMX_ERRORTYPE H264CodecCheckResolutionChange(OMX_COMPONENTTYPE *pOMXComponent) pInputPort->portDefinition.format.video.nStride = ((pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth + 15) & (~15)); pInputPort->portDefinition.format.video.nSliceHeight = ((pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight + 15) & (~15)); - pOutputPort->portDefinition.nBufferCountActual = pH264Dec->hMFCH264Handle.maxDPBNum - 2; - pOutputPort->portDefinition.nBufferCountMin = pH264Dec->hMFCH264Handle.maxDPBNum - 2; + pOutputPort->portDefinition.nBufferCountActual = pH264Dec->hMFCH264Handle.maxDPBNum - PLATFORM_DISPLAY_BUFFER; + pOutputPort->portDefinition.nBufferCountMin = pH264Dec->hMFCH264Handle.maxDPBNum - PLATFORM_DISPLAY_BUFFER; Exynos_UpdateFrameSize(pOMXComponent); @@ -914,8 +917,9 @@ OMX_ERRORTYPE H264CodecSrcSetup(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DAT goto EXIT; } - if (pVideoDec->bThumbnailMode == OMX_TRUE) - pDecOps->Set_DisplayDelay(hMFCHandle, 0); + if (pVideoDec->bThumbnailMode == OMX_TRUE) { + pDecOps->Set_IFrameDecoding(hMFCHandle); + } if ((pDecOps->Enable_DTSMode != NULL) && (pVideoDec->bDTSMode == OMX_TRUE)) @@ -1612,20 +1616,15 @@ OMX_ERRORTYPE Exynos_H264Dec_GetExtensionIndex( goto EXIT; } - if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_ENABLE_THUMBNAIL) == 0) { - EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; - *pIndexType = OMX_IndexVendorThumbnailMode; - ret = OMX_ErrorNone; - } #ifdef USE_S3D_SUPPORT - else if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_GET_S3D) == 0) { + if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_GET_S3D) == 0) { *pIndexType = OMX_IndexVendorS3DMode; ret = OMX_ErrorNone; + goto EXIT; } #endif - else { - ret = Exynos_OMX_VideoDecodeGetExtensionIndex(hComponent, cParameterName, pIndexType); - } + + ret = Exynos_OMX_VideoDecodeGetExtensionIndex(hComponent, cParameterName, pIndexType); EXIT: FunctionOut(); diff --git a/component/video/dec/mpeg4/Exynos_OMX_Mpeg4dec.c b/component/video/dec/mpeg4/Exynos_OMX_Mpeg4dec.c index d81b2e5..342f01f 100644 --- a/component/video/dec/mpeg4/Exynos_OMX_Mpeg4dec.c +++ b/component/video/dec/mpeg4/Exynos_OMX_Mpeg4dec.c @@ -787,8 +787,9 @@ OMX_ERRORTYPE Mpeg4CodecSrcSetup(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DA goto EXIT; } - if (pVideoDec->bThumbnailMode == OMX_TRUE) - pDecOps->Set_DisplayDelay(hMFCHandle, 0); + if (pVideoDec->bThumbnailMode == OMX_TRUE) { + pDecOps->Set_IFrameDecoding(hMFCHandle); + } if ((pDecOps->Enable_DTSMode != NULL) && (pVideoDec->bDTSMode == OMX_TRUE)) @@ -910,8 +911,11 @@ OMX_ERRORTYPE Mpeg4CodecSrcSetup(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DA /* get dpb count */ pMpeg4Dec->hMFCMpeg4Handle.maxDPBNum = pDecOps->Get_ActualBufferCount(hMFCHandle); - if (pVideoDec->bThumbnailMode == OMX_FALSE) + if (pVideoDec->bThumbnailMode == OMX_FALSE) { pMpeg4Dec->hMFCMpeg4Handle.maxDPBNum += EXTRA_DPB_NUM; + } else { + pMpeg4Dec->hMFCMpeg4Handle.maxDPBNum += PLATFORM_DISPLAY_BUFFER; + } Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "Mpeg4CodecSetup nOutbufs: %d", pMpeg4Dec->hMFCMpeg4Handle.maxDPBNum); pMpeg4Dec->hMFCMpeg4Handle.bConfiguredMFCSrc = OMX_TRUE; @@ -1580,13 +1584,7 @@ OMX_ERRORTYPE Exynos_Mpeg4Dec_GetExtensionIndex( goto EXIT; } - if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_ENABLE_THUMBNAIL) == 0) { - EXYNOS_MPEG4DEC_HANDLE *pMpeg4Dec = (EXYNOS_MPEG4DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; - *pIndexType = OMX_IndexVendorThumbnailMode; - ret = OMX_ErrorNone; - } else { - ret = Exynos_OMX_VideoDecodeGetExtensionIndex(hComponent, cParameterName, pIndexType); - } + ret = Exynos_OMX_VideoDecodeGetExtensionIndex(hComponent, cParameterName, pIndexType); EXIT: FunctionOut(); diff --git a/component/video/dec/vp8/Exynos_OMX_Vp8dec.c b/component/video/dec/vp8/Exynos_OMX_Vp8dec.c index 21d4177..7f65981 100644 --- a/component/video/dec/vp8/Exynos_OMX_Vp8dec.c +++ b/component/video/dec/vp8/Exynos_OMX_Vp8dec.c @@ -602,8 +602,9 @@ OMX_ERRORTYPE VP8CodecSrcSetup(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA goto EXIT; } - if (pVideoDec->bThumbnailMode == OMX_TRUE) - pDecOps->Set_DisplayDelay(hMFCHandle, 0); + if (pVideoDec->bThumbnailMode == OMX_TRUE) { + pDecOps->Set_IFrameDecoding(hMFCHandle); + } if ((pDecOps->Enable_DTSMode != NULL) && (pVideoDec->bDTSMode == OMX_TRUE)) @@ -721,8 +722,11 @@ OMX_ERRORTYPE VP8CodecSrcSetup(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA /* get dpb count */ pVp8Dec->hMFCVp8Handle.maxDPBNum = pDecOps->Get_ActualBufferCount(hMFCHandle); - if (pVideoDec->bThumbnailMode == OMX_FALSE) + if (pVideoDec->bThumbnailMode == OMX_FALSE) { pVp8Dec->hMFCVp8Handle.maxDPBNum += EXTRA_DPB_NUM; + } else { + pVp8Dec->hMFCVp8Handle.maxDPBNum += PLATFORM_DISPLAY_BUFFER; + } Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "Vp8CodecSetup nOutbufs: %d", pVp8Dec->hMFCVp8Handle.maxDPBNum); pVp8Dec->hMFCVp8Handle.bConfiguredMFCSrc = OMX_TRUE; @@ -759,8 +763,8 @@ OMX_ERRORTYPE VP8CodecSrcSetup(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA pExynosInputPort->portDefinition.format.video.nStride = ((pVp8Dec->hMFCVp8Handle.codecOutbufConf.nFrameWidth + 15) & (~15)); pExynosInputPort->portDefinition.format.video.nSliceHeight = ((pVp8Dec->hMFCVp8Handle.codecOutbufConf.nFrameHeight + 15) & (~15)); - pExynosOutputPort->portDefinition.nBufferCountActual = pVp8Dec->hMFCVp8Handle.maxDPBNum - 2; - pExynosOutputPort->portDefinition.nBufferCountMin = pVp8Dec->hMFCVp8Handle.maxDPBNum - 2; + pExynosOutputPort->portDefinition.nBufferCountActual = pVp8Dec->hMFCVp8Handle.maxDPBNum - PLATFORM_DISPLAY_BUFFER; + pExynosOutputPort->portDefinition.nBufferCountMin = pVp8Dec->hMFCVp8Handle.maxDPBNum - PLATFORM_DISPLAY_BUFFER; Exynos_UpdateFrameSize(pOMXComponent); @@ -1190,13 +1194,7 @@ OMX_ERRORTYPE Exynos_VP8Dec_GetExtensionIndex( goto EXIT; } - if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_ENABLE_THUMBNAIL) == 0) { - EXYNOS_VP8DEC_HANDLE *pVp8Dec = (EXYNOS_VP8DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; - *pIndexType = OMX_IndexVendorThumbnailMode; - ret = OMX_ErrorNone; - } else { - ret = Exynos_OMX_VideoDecodeGetExtensionIndex(hComponent, cParameterName, pIndexType); - } + ret = Exynos_OMX_VideoDecodeGetExtensionIndex(hComponent, cParameterName, pIndexType); EXIT: FunctionOut(); diff --git a/include/exynos/Exynos_OMX_Def.h b/include/exynos/Exynos_OMX_Def.h index 46b2741..6fa28a1 100644 --- a/include/exynos/Exynos_OMX_Def.h +++ b/include/exynos/Exynos_OMX_Def.h @@ -147,8 +147,8 @@ typedef struct OMX_VIDEO_VP8REFERENCEFRAMEINFOTYPE { typedef enum _EXYNOS_OMX_INDEXTYPE { -#define EXYNOS_INDEX_PARAM_ENABLE_THUMBNAIL "OMX.SEC.index.ThumbnailMode" - OMX_IndexVendorThumbnailMode = 0x7F000001, +#define EXYNOS_INDEX_PARAM_ENABLE_THUMBNAIL "OMX.SEC.index.enableThumbnailMode" + OMX_IndexParamEnableThumbnailMode = 0x7F000001, #define EXYNOS_INDEX_CONFIG_VIDEO_INTRAPERIOD "OMX.SEC.index.VideoIntraPeriod" OMX_IndexConfigVideoIntraPeriod = 0x7F000002, #ifdef USE_S3D_SUPPORT @@ -265,6 +265,13 @@ typedef struct _EXYNOS_OMX_VIDEO_PROFILELEVEL OMX_S32 level; } EXYNOS_OMX_VIDEO_PROFILELEVEL; +typedef struct _EXYNOS_OMX_VIDEO_THUMBNAILMODE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + OMX_U32 nPortIndex; + OMX_BOOL bEnable; +} EXYNOS_OMX_VIDEO_THUMBNAILMODE; + #ifdef USE_S3D_SUPPORT typedef enum _EXYNOS_OMX_FPARGMT_TYPE { -- 2.20.1