From d2ab55ed41850c96b2895618ed5e349b983771c1 Mon Sep 17 00:00:00 2001 From: Jinsung Yang Date: Sun, 30 Dec 2012 15:43:40 +0900 Subject: [PATCH] h264enc: Support prepending SPS/PPS to every IDR/I frames Encoder enables the feature prepending SPS/PPS to every IDR/I frames when called google extension index "OMX.google.android.index.prependSPSPPSToIDRFrames". Change-Id: I30e31f7b6631b399b16010acc8650ed071d45c71 Signed-off-by: Jinsung Yang --- component/video/enc/h264/Android.mk | 4 ++++ component/video/enc/h264/Exynos_OMX_H264enc.c | 22 +++++++++++++++++++ component/video/enc/h264/Exynos_OMX_H264enc.h | 1 + include/exynos/Exynos_OMX_Def.h | 3 +++ 4 files changed, 30 insertions(+) diff --git a/component/video/enc/h264/Android.mk b/component/video/enc/h264/Android.mk index aeef1a5..6f4b902 100644 --- a/component/video/enc/h264/Android.mk +++ b/component/video/enc/h264/Android.mk @@ -25,6 +25,10 @@ ifeq ($(BOARD_USE_CSC_HW), true) LOCAL_CFLAGS += -DUSE_CSC_HW endif +ifeq ($(BOARD_USE_H264_PREPEND_SPS_PPS), true) +LOCAL_CFLAGS += -DUSE_H264_PREPEND_SPS_PPS +endif + LOCAL_ARM_MODE := arm LOCAL_STATIC_LIBRARIES := libExynosOMX_Venc libExynosOMX_OSAL libExynosOMX_Basecomponent \ diff --git a/component/video/enc/h264/Exynos_OMX_H264enc.c b/component/video/enc/h264/Exynos_OMX_H264enc.c index 85dbd89..a0b10ca 100644 --- a/component/video/enc/h264/Exynos_OMX_H264enc.c +++ b/component/video/enc/h264/Exynos_OMX_H264enc.c @@ -851,6 +851,13 @@ OMX_ERRORTYPE H264CodecSrcSetup(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DAT } } + if (pMFCH264Handle->bPrependSpsPpsToIdr == OMX_TRUE) { + if (pEncOps->Enable_PrependSpsPpsToIdr) + pEncOps->Enable_PrependSpsPpsToIdr(pH264Enc->hMFCH264Handle.hMFCHandle); + else + Exynos_OSAL_Log(EXYNOS_LOG_WARNING, "%s: Not supported control: Enable_PrependSpsPpsToIdr", __func__); + } + /* input buffer info: only 3 config values needed */ Exynos_OSAL_Memset(&bufferConf, 0, sizeof(bufferConf)); bufferConf.eColorFormat = pEncParam->commonParam.FrameMap; @@ -1332,6 +1339,16 @@ OMX_ERRORTYPE Exynos_H264Enc_SetParameter( pDstErrorCorrectionType->bEnableRVLC = pSrcErrorCorrectionType->bEnableRVLC; } break; +#ifdef USE_H264_PREPEND_SPS_PPS + case OMX_IndexParamPrependSPSPPSToIDR: + { + EXYNOS_H264ENC_HANDLE *pH264Enc = NULL; + + pH264Enc = (EXYNOS_H264ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; + pH264Enc->hMFCH264Handle.bPrependSpsPpsToIdr = OMX_TRUE; + } + break; +#endif default: ret = Exynos_OMX_VideoEncodeSetParameter(hComponent, nIndex, pComponentParameterStructure); break; @@ -1514,6 +1531,11 @@ OMX_ERRORTYPE Exynos_H264Enc_GetExtensionIndex( if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_CONFIG_VIDEO_INTRAPERIOD) == 0) { *pIndexType = OMX_IndexConfigVideoIntraPeriod; ret = OMX_ErrorNone; +#ifdef USE_H264_PREPEND_SPS_PPS + } else if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_PREPEND_SPSPPS_TO_IDR) == 0) { + *pIndexType = OMX_IndexParamPrependSPSPPSToIDR; + goto EXIT; +#endif } else { ret = Exynos_OMX_VideoEncodeGetExtensionIndex(hComponent, cParameterName, pIndexType); } diff --git a/component/video/enc/h264/Exynos_OMX_H264enc.h b/component/video/enc/h264/Exynos_OMX_H264enc.h index cdd9747..9c49934 100644 --- a/component/video/enc/h264/Exynos_OMX_H264enc.h +++ b/component/video/enc/h264/Exynos_OMX_H264enc.h @@ -49,6 +49,7 @@ typedef struct _EXYNOS_MFC_H264ENC_HANDLE OMX_U32 outputIndexTimestamp; OMX_BOOL bConfiguredMFCSrc; OMX_BOOL bConfiguredMFCDst; + OMX_BOOL bPrependSpsPpsToIdr; EXTRA_DATA headerData; ExynosVideoDecOps *pEncOps; diff --git a/include/exynos/Exynos_OMX_Def.h b/include/exynos/Exynos_OMX_Def.h index af3d36f..a6873a4 100644 --- a/include/exynos/Exynos_OMX_Def.h +++ b/include/exynos/Exynos_OMX_Def.h @@ -87,6 +87,9 @@ typedef enum _EXYNOS_OMX_INDEXTYPE /* for Android Store Metadata Inbuffer */ #define EXYNOS_INDEX_PARAM_STORE_METADATA_BUFFER "OMX.google.android.index.storeMetaDataInBuffers" OMX_IndexParamStoreMetaDataBuffer = 0x7F000014, + /* prepend SPS/PPS to I/IDR for H.264 Encoder */ +#define EXYNOS_INDEX_PARAM_PREPEND_SPSPPS_TO_IDR "OMX.google.android.index.prependSPSPPSToIDRFrames" + OMX_IndexParamPrependSPSPPSToIDR = 0x7F000015, /* for Android PV OpenCore*/ OMX_COMPONENT_CAPABILITY_TYPE_INDEX = 0xFF7A347 -- 2.20.1