shithub: openh264

Download patch

ref: a899f05f2dc914651c521832811a5e07468d3e90
parent: 80f5aa216a6bca21eac52fd7d27b54e8803b6582
author: Martin Storsjö <[email protected]>
date: Tue Feb 18 07:12:55 EST 2014

Don't have SEncParamExt inherit SEncParamBase

Instead just duplicate the common fields. These fields had to
be duplicated for the C interface compatibility anyway - but
this way there is no risk to accidentally introduce an ABI
break since there is no need for the layout of SEncParamBase to
actually match the start of SEncParamExt.

--- a/codec/api/svc/codec_api.h
+++ b/codec/api/svc/codec_api.h
@@ -56,7 +56,7 @@
   /*
    * return: CM_RETURN: 0 - success; otherwise - failed;
    */
-  virtual int EXTAPI Initialize (const SEncParamBase* pParam, const INIT_TYPE kiInitType = INIT_TYPE_PARAMETER_BASED) = 0;
+  virtual int EXTAPI Initialize (const void* pParam, const INIT_TYPE kiInitType = INIT_TYPE_PARAMETER_BASED) = 0;
 
   virtual int EXTAPI Uninitialize() = 0;
 
@@ -140,7 +140,7 @@
 typedef const ISVCEncoderVtbl* ISVCEncoder;
 struct ISVCEncoderVtbl {
 
-  int (*Initialize) (ISVCEncoder*, const SEncParamBase* pParam, const INIT_TYPE kiInitType);
+  int (*Initialize) (ISVCEncoder*, const void* pParam, const INIT_TYPE kiInitType);
 
   int (*Uninitialize) (ISVCEncoder*);
 
--- a/codec/api/svc/codec_app_def.h
+++ b/codec/api/svc/codec_app_def.h
@@ -185,7 +185,6 @@
   SSliceConfig sSliceCfg;
 } SSpatialLayerConfig;
 
-#ifdef __cplusplus
 /* SVC Encoding Parameters */
 typedef struct TagEncParamBase{
 
@@ -201,8 +200,17 @@
 } SEncParamBase, *PEncParamBase;
 
 
-typedef struct TagEncParamExt:SEncParamBase
+typedef struct TagEncParamExt
 {
+  int       iUsageType;	//enable_screen_content_signal;// 0: //camera video signal; 1: screen content signal;
+  int		iInputCsp;	// color space of input sequence
+
+  int		iPicWidth;			// width of picture in samples
+  int		iPicHeight;			// height of picture in samples
+  int		iTargetBitrate;		// target bitrate desired
+  int       iRCMode;                 // RC mode
+  float	    fMaxFrameRate;			// input maximal frame rate
+
   int		iTemporalLayerNum;	// layer number at temporal level
   int		iSpatialLayerNum;	// layer number at spatial level
 
@@ -247,79 +255,6 @@
   int iMinQp;
 
 }SEncParamExt;
-#else
-/* SVC Encoding Parameters */
-typedef struct TagEncParamBase{
-
-    int       iUsageType;	//enable_screen_content_signal;// 0: //camera video signal; 1: screen content signal;
-    int		iInputCsp;	// color space of input sequence
-
-    int		iPicWidth;			// width of picture in samples
-    int		iPicHeight;			// height of picture in samples
-    int		iTargetBitrate;		// target bitrate desired
-    int       iRCMode;                 // RC mode
-    float	    fMaxFrameRate;			// input maximal frame rate
-
-} SEncParamBase, *PEncParamBase;
-
-typedef struct TagEncParamExt
-{
-    int       iUsageType;	//enable_screen_content_signal;// 0: //camera video signal; 1: screen content signal;
-    int		iInputCsp;	// color space of input sequence
-
-    int		iPicWidth;			// width of picture in samples
-    int		iPicHeight;			// height of picture in samples
-    int		iTargetBitrate;		// target bitrate desired
-    int       iRCMode;                 // RC mode
-    float	    fMaxFrameRate;			// input maximal frame rate
-
-    int		iTemporalLayerNum;	// layer number at temporal level
-    int		iSpatialLayerNum;	// layer number at spatial level
-
-    unsigned int		uiIntraPeriod;		// period of Intra frame
-    bool    bEnableSpsPpsIdAddition;
-    bool    bPrefixNalAddingCtrl;
-    bool    bEnableDenoise;	    // denoise control
-    bool    bEnableBackgroundDetection;// background detection control //VAA_BACKGROUND_DETECTION //BGD cmd
-    bool    bEnableAdaptiveQuant; // adaptive quantization control
-    bool    bEnableFrameSkip; // allow skipping frames to keep the bitrate within limits
-    bool	bEnableCropPic;	// enable cropping source picture.  8/25/2010
-    // false: Streaming Video Sharing; true: Video Conferencing Meeting;
-
-    bool     bEnableLongTermReference; // 0: on, 1: off
-    int      iLtrMarkPeriod;
-    int   iPaddingFlag;            // 0:disable padding;1:padding
-    int   iEtropyCodingModeFlag;
-
-    SSpatialLayerConfig sSpatialLayers[MAX_SPATIAL_LAYER_NUM];
-    int		    iNumRefFrame;		// number of reference frame used
-    unsigned int	uiFrameToBeCoded;	// frame to be encoded (at input frame rate)
-    unsigned int  uiGopSize;
-    bool   bEnableRc;
-    short		iMultipleThreadIdc;		// 1	# 0: auto(dynamic imp. internal encoder); 1: multiple threads imp. disabled; > 1: count number of threads;
-    short		iCountThreadsNum;			//		# derived from disable_multiple_slice_idc (=0 or >1) means;
-
-    int		iLTRRefNum;
-    bool		bEnableSSEI;
-    bool		bEnableFrameCroppingFlag;// enable frame cropping flag: TRUE always in application
-
-    /* Deblocking loop filter */
-    int		iLoopFilterDisableIdc;	// 0: on, 1: off, 2: on except for slice boundaries
-    int		iLoopFilterAlphaC0Offset;// AlphaOffset: valid range [-6, 6], default 0
-
-    int		iLoopFilterBetaOffset;	// BetaOffset:	valid range [-6, 6], default 0
-    int		iInterLayerLoopFilterDisableIdc; // Employed based upon inter-layer, same comment as above
-    int		iInterLayerLoopFilterAlphaC0Offset;	// InterLayerLoopFilterAlphaC0Offset
-    int		iInterLayerLoopFilterBetaOffset;	// InterLayerLoopFilterBetaOffset
-    bool      bEnableSceneChangeDetect;
-
-    //added
-    int iMaxQp;
-    int iMinQp;
-
-}SEncParamExt;
-
-#endif
 
 //Define a new struct to show the property of video bitstream.
 typedef struct {
--- a/codec/encoder/plus/inc/welsEncoderExt.h
+++ b/codec/encoder/plus/inc/welsEncoderExt.h
@@ -66,7 +66,7 @@
   /*
    * return: CM_RETURN: 0 - success; otherwise - failed;
    */
-  virtual int EXTAPI Initialize (const SEncParamBase* argv, const INIT_TYPE init_type);
+  virtual int EXTAPI Initialize (const void* argv, const INIT_TYPE init_type);
 
   virtual int EXTAPI Uninitialize();
 
--- a/codec/encoder/plus/src/welsEncoderExt.cpp
+++ b/codec/encoder/plus/src/welsEncoderExt.cpp
@@ -200,7 +200,7 @@
 /*
  *	SVC Encoder Initialization
  */
-int CWelsH264SVCEncoder::Initialize (const SEncParamBase* argv, const INIT_TYPE iInitType) {
+int CWelsH264SVCEncoder::Initialize (const void* argv, const INIT_TYPE iInitType) {
 
 
   if ((INIT_TYPE_PARAMETER_BASED != iInitType && INIT_TYPE_PARAMETER_EXT != iInitType)|| NULL == argv) {
@@ -213,7 +213,7 @@
   if(iInitType ==  INIT_TYPE_PARAMETER_BASED)
   {
 	 // Convert SEncParamBase into WelsSVCParamConfig here..
-	 if (sConfig.ParamBaseTranscode (*argv, true)) {
+	 if (sConfig.ParamBaseTranscode (*(const SEncParamBase*)argv, true)) {
 		 WelsLog (m_pEncContext, WELS_LOG_ERROR, "CWelsH264SVCEncoder::Initialize(), parameter_translation failed.\n");
 		 Uninitialize();
 		 return cmInitParaError;
--- a/test/cpp_interface_test.cpp
+++ b/test/cpp_interface_test.cpp
@@ -22,7 +22,7 @@
  */
 struct SVCEncoderImpl : public ISVCEncoder {
   virtual ~SVCEncoderImpl() {}
-  virtual int EXTAPI Initialize(const SEncParamBase* pParam,
+  virtual int EXTAPI Initialize(const void* pParam,
       const INIT_TYPE kiInitType) {
     EXPECT_TRUE(gThis == this);
     return 1;