Merge pull request #817 from ruil2/enc_bitrate

fix bitrate setting and add bitrate validation
This commit is contained in:
sijchen 2014-05-12 14:44:06 +08:00
commit bff52694c4
2 changed files with 15 additions and 2 deletions

View File

@ -371,7 +371,7 @@ int ParseCommandLine (int argc, char** argv, SEncParamExt& sParam) {
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 @@ int ParseCommandLine (int argc, char** argv, SSourcePicture* pSrcPic, SEncParamE
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++]);

View File

@ -112,6 +112,19 @@ int32_t ParamValidation (SWelsSvcCodingParam* pCfg) {
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;
}