shithub: openh264

Download patch

ref: 7c0369da239abcbceba5bce857055f99e8d89329
parent: 82b70b34fe3ca03af1e7f79aa92d85e6917454d1
author: ruil2 <ruil2@cisco.com>
date: Thu Nov 27 10:55:48 EST 2014

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/plus/src/welsEncoderExt.cpp
+++ b/codec/encoder/plus/src/welsEncoderExt.cpp
@@ -642,10 +642,11 @@
     int64_t iTimeDiff = kiCurrentFrameTs - m_pEncContext->iLastStatisticsLogTs;
     if ((iTimeDiff > m_pEncContext->iStatisticsLogInterval) || (0 == pStatistics->uiInputFrameCount % 300)) {
       if (iTimeDiff) {
-        pStatistics->fLatestFrameRate = static_cast<float> ((pStatistics->uiInputFrameCount - m_pEncContext->iLastStatisticsFrameCount) * 1000 /
-                                                             iTimeDiff);
+        pStatistics->fLatestFrameRate = static_cast<float> ((pStatistics->uiInputFrameCount -
+                                        m_pEncContext->iLastStatisticsFrameCount) * 1000 /
+                                        iTimeDiff);
         pStatistics->uiBitRate = static_cast<unsigned int> ((m_pEncContext->iTotalEncodedBits -
-                                                             m_pEncContext->iLastStatisticsBits) * 1000 / iTimeDiff);
+                                 m_pEncContext->iLastStatisticsBits) * 1000 / iTimeDiff);
       }
 
       // update variables
@@ -1072,6 +1073,14 @@
              "CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_IS_LOSSLESS_LINK,bIsLosslessLink = %d", bValue);
   }
   break;
+  case ENCODER_OPTION_BITS_VARY_PERCENTAGE: {
+    bool bValue = * (static_cast<bool*> (pOption));
+    m_pEncContext->pSvcParam->iBitsVaryPercentage = bValue;
+    WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,
+             "CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_BITS_VARY_PERCENTAGE,iBitsVaryPercentage = %d", bValue);
+  }
+  break;
+
   default:
     return cmInitParaError;
   }