ref: bff52694c4616db569eebf02a7fe894241f106d6
parent: 6a295d5e8e88f38b1c1f91ac338e7ac48023ddaa
parent: eb357b51f275b1611ae624ec4aa4c6fa4a21e894
author: sijchen <sijchen@cisco.com>
date: Mon May 12 10:44:06 EDT 2014
Merge pull request #817 from ruil2/enc_bitrate fix bitrate setting and add bitrate validation
--- a/codec/console/enc/src/welsenc.cpp
+++ b/codec/console/enc/src/welsenc.cpp
@@ -371,7 +371,7 @@
sParam.iRCMode = (RC_MODES) atoi (argv[i++]);
else if (!strcmp (pCmd, "-tarb") && (i < argc))
- sParam.iTargetBitrate = atoi (argv[i++]);
+ sParam.iTargetBitrate = 1000*atoi (argv[i++]);
else if (!strcmp (pCmd, "-ltarb") && (i + 1 < argc)) {
int iLayer = atoi (argv[i++]);
@@ -513,7 +513,7 @@
g_LevelSetting = atoi (argv[n++]);
else if (!strcmp (pCommand, "-tarb") && (n < argc))
- pSvcParam.iTargetBitrate = atoi (argv[n++]);
+ pSvcParam.iTargetBitrate = 1000*atoi (argv[n++]);
else if (!strcmp (pCommand, "-numl") && (n < argc)) {
pSvcParam.iSpatialLayerNum = atoi (argv[n++]);
--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -112,6 +112,19 @@
pCfg->fMaxFrameRate = fMaxFrameRate;
}
+ //bitrate setting validation
+ if (pCfg->iRCMode != RC_OFF_MODE){
+ int32_t iTotalBitrate = 0;
+ for (i = 0; i < pCfg->iSpatialLayerNum; ++ i) {
+ SDLayerParam* fDlp = &pCfg->sDependencyLayers[i];
+ iTotalBitrate += fDlp->iSpatialBitrate;
+ }
+ if(iTotalBitrate > pCfg->iTargetBitrate){
+ WelsLog(NULL, WELS_LOG_ERROR,"Invalid setttings in bitrate. the sum of each layer bitrate(%) is larger than total bitrate setting(%d)\n",
+ iTotalBitrate,pCfg->iTargetBitrate);
+ }
+ }
+
return ENC_RETURN_SUCCESS;
}