shithub: openh264

Download patch

ref: 8c7aaa8421bea7876904c0f3a63fe6a3229924a1
parent: 9a08b7f97c23eeae3ee0839fb09cc67c20c2eb41
parent: 30820fd8b5cc428b1703cbd9a09a02fae622b0f6
author: sijchen <[email protected]>
date: Sun Nov 30 16:39:39 EST 2014

Merge pull request #1568 from ruil2/cleanup

add iBitsVaryPercentage parameters to control bitrate

--- a/codec/api/svc/codec_app_def.h
+++ b/codec/api/svc/codec_app_def.h
@@ -126,7 +126,9 @@
   ENCODER_OPTION_GET_STATISTICS,             ///< read only
   ENCODER_OPTION_STATISTICS_LOG_INTERVAL,    ///< log interval in millisecond
 
-  ENCODER_OPTION_IS_LOSSLESS_LINK            ///< advanced algorithmetic settings
+  ENCODER_OPTION_IS_LOSSLESS_LINK,            ///< advanced algorithmetic settings
+
+  ENCODER_OPTION_BITS_VARY_PERCENTAGE        ///< bit vary percentage
 } ENCODER_OPTION;
 
 /**
--- a/codec/encoder/core/inc/param_svc.h
+++ b/codec/encoder/core/inc/param_svc.h
@@ -111,7 +111,7 @@
   char*       pCurPath; // record current lib path such as:/pData/pData/com.wels.enc/lib/
 
   bool		bDeblockingParallelFlag;	// deblocking filter parallelization control flag
-
+  int32_t   iBitsVaryPercentage;
   short
   iCountThreadsNum;                       //              # derived from disable_multiple_slice_idc (=0 or >1) means;
 
@@ -202,6 +202,7 @@
     iCountThreadsNum		= 1;	//		# derived from disable_multiple_slice_idc (=0 or >1) means;
 
     iDecompStages				= 0;	// GOP size dependency, unknown here and be revised later
+    iBitsVaryPercentage = 0;
   }
 
   int32_t ParamBaseTranscode (const SEncParamBase& pCodingParam) {
--- a/codec/encoder/core/src/ratectl.cpp
+++ b/codec/encoder/core/src/ratectl.cpp
@@ -125,7 +125,7 @@
     pWelsSvcRc->iNumberMbFrame = iMbWidth * (pDLayerParam->iVideoHeight >> 4);
     pWelsSvcRc->iSliceNum = pSliceCtx->iSliceNumInFrame;
 
-    pWelsSvcRc->iRcVaryPercentage = _BITS_RANGE;	// % -- for temp
+    pWelsSvcRc->iRcVaryPercentage = pEncCtx->pSvcParam->iBitsVaryPercentage;	// % -- for temp
     pWelsSvcRc->iRcVaryRatio = pWelsSvcRc->iRcVaryPercentage;
 
     pWelsSvcRc->iSkipBufferRatio  = SKIP_RATIO;
--- a/codec/encoder/plus/src/welsEncoderExt.cpp
+++ b/codec/encoder/plus/src/welsEncoderExt.cpp
@@ -1097,6 +1097,14 @@
              "CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_IS_LOSSLESS_LINK,bIsLosslessLink = %d", bValue);
   }
   break;
+  case ENCODER_OPTION_BITS_VARY_PERCENTAGE: {
+    int32_t iValue = * (static_cast<int32_t*> (pOption));
+    m_pEncContext->pSvcParam->iBitsVaryPercentage = iValue;
+    WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,
+             "CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_BITS_VARY_PERCENTAGE,iBitsVaryPercentage = %d", iValue);
+  }
+  break;
+
   default:
     return cmInitParaError;
   }