h264enc: Support prepending SPS/PPS to every IDR/I frames
authorJinsung Yang <jsgood.yang@samsung.com>
Sun, 30 Dec 2012 06:43:40 +0000 (15:43 +0900)
committerTaehwan Kim <t_h.kim@samsung.com>
Fri, 4 Jan 2013 00:42:53 +0000 (00:42 +0000)
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 <jsgood.yang@samsung.com>
component/video/enc/h264/Android.mk
component/video/enc/h264/Exynos_OMX_H264enc.c
component/video/enc/h264/Exynos_OMX_H264enc.h
include/exynos/Exynos_OMX_Def.h

index aeef1a560d94a5dd0d1eb56182593b5fc7299083..6f4b902e7d3352579036bf5d7bf7ed70d680ed8d 100644 (file)
@@ -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 \
index 85dbd894c03a908ea7cadc360081d2e37d0a14da..a0b10ca5a73e05f0346fc4c73a7b451ae71d32b6 100644 (file)
@@ -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);
     }
index cdd974710b968dd1f8bfda4a4921d0c7c7f5f3e3..9c49934ca70604801a82c3594ee2dcff13efd985 100644 (file)
@@ -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;
index af3d36f3b467ad3f820868ef37f00acafee4639c..a6873a416003e83c989f73e17959ee481af32a92 100644 (file)
@@ -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