shithub: openh264

Download patch

ref: 40ce2396f8011cb6a9aaa1f408eb81aaa5c1b38a
parent: 1ccaf1175b986f7fb0f000c9d800a5bcd98433fa
author: unknown <[email protected]>
date: Tue Apr 29 09:15:28 EDT 2014

use the parameters set by app instead of the default values

--- a/codec/api/svc/codec_app_def.h
+++ b/codec/api/svc/codec_app_def.h
@@ -50,6 +50,7 @@
 #define SAVED_NALUNIT_NUM_TMP		( (MAX_SPATIAL_LAYER_NUM*MAX_QUALITY_LAYER_NUM) + 1 + MAX_SPATIAL_LAYER_NUM ) //SPS/PPS + SEI/SSEI + PADDING_NAL
 #define MAX_SLICES_NUM_TMP			( ( MAX_NAL_UNITS_IN_LAYER - SAVED_NALUNIT_NUM_TMP ) / 3 )
 
+#define AUTO_REF_PIC_COUNT  -1  // encoder selects the number of reference frame automatically
 typedef enum {
   /* Errors derived from bitstream parsing */
   dsErrorFree			= 0x00,	/* Bitstream error-free */
--- a/codec/encoder/core/inc/param_svc.h
+++ b/codec/encoder/core/inc/param_svc.h
@@ -139,7 +139,7 @@
 static void FillDefault (SEncParamExt& param) {
   memset(&param, 0, sizeof(param));
   param.uiIntraPeriod		= 0;			// intra period (multiple of GOP size as desired)
-  param.iNumRefFrame		= MIN_REF_PIC_COUNT;	// number of reference frame used
+  param.iNumRefFrame		= AUTO_REF_PIC_COUNT;// number of reference frame used
 
   param.iPicWidth	= 0;    //   actual input picture width
   param.iPicHeight	= 0;	//   actual input picture height
@@ -312,10 +312,10 @@
   iLoopFilterDisableIdc	= pCodingParam.iLoopFilterDisableIdc;	// 0: on, 1: off, 2: on except for slice boundaries,
   if (iLoopFilterDisableIdc == 0) // Loop filter requested to be enabled
     iLoopFilterDisableIdc = 2; // Disable loop filter on slice boundaries since that's not allowed with multithreading
-  iLoopFilterAlphaC0Offset = 0;	// AlphaOffset: valid range [-6, 6], default 0
-  iLoopFilterBetaOffset	= 0;	// BetaOffset:	valid range [-6, 6], default 0
+  iLoopFilterAlphaC0Offset = pCodingParam.iLoopFilterAlphaC0Offset;	// AlphaOffset: valid range [-6, 6], default 0
+  iLoopFilterBetaOffset = pCodingParam.iLoopFilterBetaOffset;	// BetaOffset:	valid range [-6, 6], default 0
 
-  bEnableFrameCroppingFlag	= true;
+  bEnableFrameCroppingFlag	= pCodingParam.bEnableFrameCroppingFlag;
 
   /* Rate Control */
   iRCMode = pCodingParam.iRCMode;    // rc mode
@@ -329,7 +329,7 @@
   bEnableDenoise = pCodingParam.bEnableDenoise ? true : false;    // Denoise Control  // only support 0 or 1 now
 
   /* Scene change detection control */
-  bEnableSceneChangeDetect	= true;
+  bEnableSceneChangeDetect	= pCodingParam.bEnableSceneChangeDetect;
 
   /* Background detection Control */
   bEnableBackgroundDetection = pCodingParam.bEnableBackgroundDetection ? true : false;
@@ -347,7 +347,7 @@
   iMultipleThreadIdc = pCodingParam.iMultipleThreadIdc;
 
   /* For ssei information */
-  bEnableSSEI		= true;
+  bEnableSSEI		= pCodingParam.bEnableSSEI;
 
   /* Layer definition */
   iSpatialLayerNum	= (int8_t)WELS_CLIP3 (pCodingParam.iSpatialLayerNum, 1,
@@ -365,15 +365,19 @@
   if (iUsageType == SCREEN_CONTENT_REAL_TIME) {
     if (bEnableLongTermReference) {
       iLTRRefNum = WELS_CLIP3(pCodingParam.iLTRRefNum,1,LONG_TERM_REF_NUM_SCREEN);
-      iNumRefFrame = WELS_MAX(1, WELS_LOG2 (uiGopSize)) + iLTRRefNum;
+      if( iNumRefFrame == AUTO_REF_PIC_COUNT)
+        iNumRefFrame = WELS_MAX(1, WELS_LOG2 (uiGopSize)) + iLTRRefNum;
     } else {
       iLTRRefNum = 0;
-      iNumRefFrame = 1;
+      if( iNumRefFrame == AUTO_REF_PIC_COUNT)
+        iNumRefFrame = 1;
     }
   } else {
     iLTRRefNum = bEnableLongTermReference ? WELS_CLIP3(pCodingParam.iLTRRefNum,1,LONG_TERM_REF_NUM) : 0;
-    iNumRefFrame		= ((uiGopSize >> 1) > 1) ? ((uiGopSize >> 1) + iLTRRefNum) : (MIN_REF_PIC_COUNT + iLTRRefNum);
-    iNumRefFrame		= WELS_CLIP3 (iNumRefFrame, MIN_REF_PIC_COUNT, MAX_REFERENCE_PICTURE_COUNT_NUM);
+    if( iNumRefFrame == AUTO_REF_PIC_COUNT){
+      iNumRefFrame		= ((uiGopSize >> 1) > 1) ? ((uiGopSize >> 1) + iLTRRefNum) : (MIN_REF_PIC_COUNT + iLTRRefNum);
+      iNumRefFrame		= WELS_CLIP3 (iNumRefFrame, MIN_REF_PIC_COUNT, MAX_REFERENCE_PICTURE_COUNT_NUM);
+    }
   }
   iLtrMarkPeriod  = pCodingParam.iLtrMarkPeriod;