ref: cee3329ff027a4846750fc55006007e27c838510
parent: 306a1daa14146aa8e7002bf067292939d030f517
author: Martin Storsjö <[email protected]>
date: Fri Jan 17 07:29:03 EST 2014
Add a runtime option for controlling frame skipping
--- a/codec/api/svc/codec_app_def.h
+++ b/codec/api/svc/codec_app_def.h
@@ -209,6 +209,7 @@
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
--- a/codec/console/enc/src/welsenc.cpp
+++ b/codec/console/enc/src/welsenc.cpp
@@ -215,6 +215,8 @@
pSvcParam.bEnableBackgroundDetection = atoi (strTag[1].c_str()) ? true : false;
} else if (strTag[0].compare ("EnableAdaptiveQuantization") == 0) {
pSvcParam.bEnableAdaptiveQuant = atoi (strTag[1].c_str()) ? true : false;
+ } else if (strTag[0].compare ("EnableFrameSkip") == 0) {
+ pSvcParam.bEnableFrameSkip = atoi (strTag[1].c_str()) ? true : false;
} else if (strTag[0].compare ("EnableLongTermReference") == 0) {
pSvcParam.bEnableLongTermReference = atoi (strTag[1].c_str()) ? true : false;
} else if (strTag[0].compare ("LtrMarkPeriod") == 0) {
@@ -364,6 +366,9 @@
else if (!strcmp (pCmd, "-aq") && (i < argc))
sParam.bEnableAdaptiveQuant = atoi (argv[i++]) ? true : false;
+ else if (!strcmp (pCmd, "-fs") && (i < argc))
+ sParam.bEnableFrameSkip = atoi (argv[i++]) ? true : false;
+
else if (!strcmp (pCmd, "-ltr") && (i < argc))
sParam.bEnableLongTermReference = atoi (argv[i++]) ? true : false;
@@ -464,6 +469,9 @@
else if (!strcmp (pCommand, "-aq") && (n < argc))
pSvcParam.bEnableAdaptiveQuant = atoi (argv[n++]) ? true : false;
+ else if (!strcmp (pCommand, "-fs") && (n < argc))
+ pSvcParam.bEnableFrameSkip = atoi (argv[n++]) ? true : false;
+
else if (!strcmp (pCommand, "-ltr") && (n < argc))
pSvcParam.bEnableLongTermReference = atoi (argv[n++]) ? true : false;
@@ -666,6 +674,7 @@
sParam.bEnableDenoise = 0; // denoise control
sParam.bEnableBackgroundDetection = 1; // background detection control
sParam.bEnableAdaptiveQuant = 1; // adaptive quantization control
+ sParam.bEnableFrameSkip = 1; // frame skipping
sParam.bEnableLongTermReference = 0; // long term reference control
sParam.iLtrMarkPeriod = 30;
--- a/codec/encoder/core/inc/param_svc.h
+++ b/codec/encoder/core/inc/param_svc.h
@@ -175,6 +175,8 @@
bool_t bEnableBackgroundDetection;
/* adaptive quantization control */
bool_t bEnableAdaptiveQuant;
+/* frame skipping */
+bool_t bEnableFrameSkip;
/* long term reference control */
bool_t bEnableLongTermReference;
@@ -249,6 +251,7 @@
bEnableSceneChangeDetect = true; // scene change detection control
bEnableBackgroundDetection = true; // background detection control
bEnableAdaptiveQuant = true; // adaptive quantization control
+ bEnableFrameSkip = true; // frame skipping
bEnableLongTermReference = false; // long term reference control
bEnableSpsPpsIdAddition = true; // pSps pPps id addition control
bPrefixNalAddingCtrl = true; // prefix NAL adding control
@@ -305,6 +308,9 @@
/* Adaptive quantization control */
bEnableAdaptiveQuant = pCodingParam.bEnableAdaptiveQuant ? true : false;
+
+ /* Frame skipping */
+ bEnableFrameSkip = pCodingParam.bEnableFrameSkip ? true : false;
/* Enable cropping source picture */
bEnableCropPic = pCodingParam.bEnableCropPic ? true : false;
--- a/codec/encoder/core/inc/rc.h
+++ b/codec/encoder/core/inc/rc.h
@@ -51,8 +51,6 @@
namespace WelsSVCEnc {
//trace
#define GOM_TRACE_FLAG 1
-//skip frame
-#define SKIP_FRAME_FLAG 1
#define WELS_RC_DISABLE 0
#define WELS_RC_GOM 1
--- a/codec/encoder/core/src/ratectl.cpp
+++ b/codec/encoder/core/src/ratectl.cpp
@@ -812,11 +812,10 @@
#endif
-#if SKIP_FRAME_FLAG
- if (pEncCtx->uiDependencyId == pEncCtx->pSvcParam->iNumDependencyLayer - 1) {
+ if (pEncCtx->pSvcParam->bEnableFrameSkip &&
+ pEncCtx->uiDependencyId == pEncCtx->pSvcParam->iNumDependencyLayer - 1) {
RcVBufferCalculationSkip (pEncCtx);
}
-#endif
if (pEncCtx->pSvcParam->iPaddingFlag)
RcVBufferCalculationPadding (pEncCtx);
--- a/codec/encoder/plus/src/welsEncoderExt.cpp
+++ b/codec/encoder/plus/src/welsEncoderExt.cpp
@@ -304,7 +304,7 @@
WelsLog (m_pEncContext, WELS_LOG_INFO, "CWelsH264SVCEncoder::Initialize, m_uiCountFrameNum= %d, m_iCspInternal= 0x%x\n",
m_uiCountFrameNum, m_iCspInternal);
WelsLog (m_pEncContext, WELS_LOG_INFO,
- "coding_param->iPicWidth= %d;coding_param->iPicHeight= %d;coding_param->iTargetBitrate= %d;coding_param->iRCMode= %d;coding_param->iTemporalLayerNum= %d;coding_param->iSpatialLayerNum= %d;coding_param->fFrameRate= %.6ff;coding_param->iInputCsp= %d;coding_param->iKeyPicCodingMode= %d;coding_param->uiIntraPeriod= %d;coding_param->bEnableSpsPpsIdAddition = %d;coding_param->bPrefixNalAddingCtrl = %d;coding_param->bEnableDenoise= %d;coding_param->bEnableBackgroundDetection= %d;coding_param->bEnableAdaptiveQuant= %d;coding_param->bEnableCropPic= %d;coding_param->bEnableLongTermReference= %d;coding_param->iLtrMarkPeriod= %d;\n",
+ "coding_param->iPicWidth= %d;coding_param->iPicHeight= %d;coding_param->iTargetBitrate= %d;coding_param->iRCMode= %d;coding_param->iTemporalLayerNum= %d;coding_param->iSpatialLayerNum= %d;coding_param->fFrameRate= %.6ff;coding_param->iInputCsp= %d;coding_param->iKeyPicCodingMode= %d;coding_param->uiIntraPeriod= %d;coding_param->bEnableSpsPpsIdAddition = %d;coding_param->bPrefixNalAddingCtrl = %d;coding_param->bEnableDenoise= %d;coding_param->bEnableBackgroundDetection= %d;coding_param->bEnableAdaptiveQuant= %d;coding_param->bEnableFrameSkip= %d;coding_param->bEnableCropPic= %d;coding_param->bEnableLongTermReference= %d;coding_param->iLtrMarkPeriod= %d;\n",
sEncodingParam.iPicWidth,
sEncodingParam.iPicHeight,
sEncodingParam.iTargetBitrate,
@@ -320,6 +320,7 @@
sEncodingParam.bEnableDenoise,
sEncodingParam.bEnableBackgroundDetection,
sEncodingParam.bEnableAdaptiveQuant,
+ sEncodingParam.bEnableFrameSkip,
sEncodingParam.bEnableCropPic,
sEncodingParam.bEnableLongTermReference,
sEncodingParam.iLtrMarkPeriod);
@@ -856,7 +857,7 @@
WelsLog (m_pEncContext, WELS_LOG_INFO, "ENCODER_OPTION_SVC_ENCODE_PARAM, sEncodingParam.iInputCsp= 0x%x\n",
sEncodingParam.iInputCsp);
WelsLog (m_pEncContext, WELS_LOG_INFO,
- "coding_param->iPicWidth= %d;coding_param->iPicHeight= %d;coding_param->iTargetBitrate= %d;coding_param->iRCMode= %d;coding_param->iPaddingFlag= %d;coding_param->iTemporalLayerNum= %d;coding_param->iSpatialLayerNum= %d;coding_param->fFrameRate= %.6ff;coding_param->iInputCsp= %d;coding_param->iKeyPicCodingMode= %d;coding_param->uiIntraPeriod= %d;coding_param->bEnableSpsPpsIdAddition = %d;coding_param->bPrefixNalAddingCtrl = %d;coding_param->bEnableDenoise= %d;coding_param->bEnableBackgroundDetection= %d;coding_param->bEnableAdaptiveQuant= %d;coding_param->bEnableCropPic= %d;coding_param->bEnableLongTermReference= %d;coding_param->iLtrMarkPeriod= %d;\n",
+ "coding_param->iPicWidth= %d;coding_param->iPicHeight= %d;coding_param->iTargetBitrate= %d;coding_param->iRCMode= %d;coding_param->iPaddingFlag= %d;coding_param->iTemporalLayerNum= %d;coding_param->iSpatialLayerNum= %d;coding_param->fFrameRate= %.6ff;coding_param->iInputCsp= %d;coding_param->iKeyPicCodingMode= %d;coding_param->uiIntraPeriod= %d;coding_param->bEnableSpsPpsIdAddition = %d;coding_param->bPrefixNalAddingCtrl = %d;coding_param->bEnableDenoise= %d;coding_param->bEnableBackgroundDetection= %d;coding_param->bEnableAdaptiveQuant= %d;coding_param->bEnableAdaptiveQuant= %d;coding_param->bEnableCropPic= %d;coding_param->bEnableLongTermReference= %d;coding_param->iLtrMarkPeriod= %d;\n",
sEncodingParam.iPicWidth,
sEncodingParam.iPicHeight,
sEncodingParam.iTargetBitrate,
@@ -873,6 +874,7 @@
sEncodingParam.bEnableDenoise,
sEncodingParam.bEnableBackgroundDetection,
sEncodingParam.bEnableAdaptiveQuant,
+ sEncodingParam.bEnableFrameSkip,
sEncodingParam.bEnableCropPic,
sEncodingParam.bEnableLongTermReference,
sEncodingParam.iLtrMarkPeriod);