History

add bitrate validation

ruil2 committed 12 years ago

Commit ce870bf1 parent 61017a21 file · +12 −3Browse files

Showing the changes to codec/encoder/core/src/encoder_ext.cpp (1 of 1 file). Show all

Unified · Split

codec/encoder/core/src/encoder_ext.cpp+12−3
@@ -112,21 +112,30 @@ int32_t ParamValidation (SLogContext* pLogCtx, SWelsSvcCodingParam* pCfg) { · 111 unmodified lines
112 || fMaxFrameRate - pCfg->fMaxFrameRate < -fEpsn)) {112 || fMaxFrameRate - pCfg->fMaxFrameRate < -fEpsn)) {
113 pCfg->fMaxFrameRate = fMaxFrameRate;113 pCfg->fMaxFrameRate = fMaxFrameRate;
114 }114 }
115 115//bitrate setting validation
116 //bitrate setting validation
117 if (pCfg->iRCMode != RC_OFF_MODE) {116 if (pCfg->iRCMode != RC_OFF_MODE) {
118 int32_t iTotalBitrate = 0;117 int32_t iTotalBitrate = 0;
118 if (pCfg->iTargetBitrate <= 0) {
119 WelsLog (pLogCtx, WELS_LOG_ERROR, "Invalid bitrate settings in total configure, bitrate= %d\n", pCfg->iTargetBitrate);
120 return ENC_RETURN_INVALIDINPUT;
121 }
119 for (i = 0; i < pCfg->iSpatialLayerNum; ++ i) {122 for (i = 0; i < pCfg->iSpatialLayerNum; ++ i) {
120 SSpatialLayerConfig* pSpatialLayer = &pCfg->sSpatialLayers[i];123 SSpatialLayerConfig* pSpatialLayer = &pCfg->sSpatialLayers[i];
121 iTotalBitrate += pSpatialLayer->iSpatialBitrate;124 iTotalBitrate += pSpatialLayer->iSpatialBitrate;
125 if (pSpatialLayer->iSpatialBitrate <= 0) {
126 WelsLog (pLogCtx, WELS_LOG_ERROR, "Invalid bitrate settings in layer %d, bitrate= %d\n", i,
127 pSpatialLayer->iSpatialBitrate);
128 return ENC_RETURN_INVALIDINPUT;
129 }
122 }130 }
123 if (iTotalBitrate > pCfg->iTargetBitrate) {131 if (iTotalBitrate > pCfg->iTargetBitrate) {
124 WelsLog (pLogCtx, WELS_LOG_ERROR,132 WelsLog (pLogCtx, WELS_LOG_ERROR,
125 "Invalid settings in bitrate. the sum of each layer bitrate(%d) is larger than total bitrate setting(%d)\n",133 "Invalid settings in bitrate. the sum of each layer bitrate(%d) is larger than total bitrate setting(%d)\n",
126 iTotalBitrate, pCfg->iTargetBitrate);134 iTotalBitrate, pCfg->iTargetBitrate);
135 return ENC_RETURN_INVALIDINPUT;
127 }136 }
128 }
129 137
138 }
130 return ENC_RETURN_SUCCESS;139 return ENC_RETURN_SUCCESS;
131}140}
132 141

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t