shithub: openh264

Download patch

ref: e9429e2f93de3d8a07c9eea105fdc3a264184428
parent: bf44265c2ccc4f602b3cf65b0025e27ce13cc5ee
parent: dea37ce439043633afee3284c1895096f1903e0b
author: sijchen <sijchen@cisco.com>
date: Wed Jun 17 13:35:03 EDT 2015

Merge pull request #1988 from sijchen/ps4

add a frame-skip setting option

--- a/codec/api/svc/codec_app_def.h
+++ b/codec/api/svc/codec_app_def.h
@@ -112,6 +112,7 @@
   ENCODER_OPTION_MAX_BITRATE,
   ENCODER_OPTION_INTER_SPATIAL_PRED,
   ENCODER_OPTION_RC_MODE,
+  ENCODER_OPTION_RC_FRAME_SKIP,
   ENCODER_PADDING_PADDING,                   ///< 0:disable padding;1:padding
 
   ENCODER_OPTION_PROFILE,                    ///< assgin the profile for each layer
--- a/codec/encoder/core/inc/rc.h
+++ b/codec/encoder/core/inc/rc.h
@@ -278,6 +278,7 @@
 void UpdateMaxBrCheckWindowStatus(sWelsEncCtx* pCtx, int32_t iSpatialNum, const long long uiTimeStamp);
 void RcTraceFrameBits (sWelsEncCtx* pEncCtx, long long uiTimeStamp);
 void WelsRcInitModule (sWelsEncCtx* pCtx, RC_MODES iRcMode);
+void WelsRcInitFuncPointers (sWelsEncCtx* pEncCtx, RC_MODES iRcMode);
 void WelsRcFreeMemory (sWelsEncCtx* pCtx);
 
 }
--- a/codec/encoder/core/src/ratectl.cpp
+++ b/codec/encoder/core/src/ratectl.cpp
@@ -1420,7 +1420,8 @@
     RcVBufferCalculationPadding (pEncCtx);
   pWelsSvcRc->iFrameCodedInVGop++;
 }
-void  WelsRcInitModule (sWelsEncCtx* pEncCtx, RC_MODES iRcMode) {
+
+void  WelsRcInitFuncPointers (sWelsEncCtx* pEncCtx, RC_MODES iRcMode) {
   SWelsRcFunc*   pRcf = &pEncCtx->pFuncList->pfRc;
   switch (iRcMode) {
   case RC_OFF_MODE:
@@ -1485,7 +1486,10 @@
 
     break;
   }
+}
 
+void  WelsRcInitModule (sWelsEncCtx* pEncCtx, RC_MODES iRcMode) {
+  WelsRcInitFuncPointers (pEncCtx, iRcMode);
   RcInitSequenceParameter (pEncCtx);
 }
 
--- a/codec/encoder/plus/src/welsEncoderExt.cpp
+++ b/codec/encoder/plus/src/welsEncoderExt.cpp
@@ -877,8 +877,23 @@
     int32_t iValue = * ((int32_t*)pOption);
     m_pEncContext->pSvcParam->iRCMode = (RC_MODES) iValue;
     WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,
-             "CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_RC_MODE iRCMode= %d ",
+             "CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_RC_MODE iRCMode= %d (Note: not suggest changing RC-mode in middle of encoding)",
              iValue);
+    WelsRcInitFuncPointers(m_pEncContext, m_pEncContext->pSvcParam->iRCMode);
+  }
+  break;
+  case ENCODER_OPTION_RC_FRAME_SKIP: { // 0:FRAME-SKIP disabled;1:FRAME-SKIP enabled
+    bool bValue = * ((bool*)pOption);
+    if (m_pEncContext->pSvcParam->iRCMode != RC_OFF_MODE) {
+      m_pEncContext->pSvcParam->bEnableFrameSkip = bValue;
+      WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,
+               "CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_RC_FRAME_SKIP, frame-skip setting(%d)",
+               bValue);
+    } else {
+      WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,
+               "CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_RC_FRAME_SKIP, rc off, frame-skip setting(%d) un-useful",
+               bValue);
+    }
   }
   break;
   case ENCODER_PADDING_PADDING: { // 0:disable padding;1:padding