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
112112 || fMaxFrameRate - pCfg->fMaxFrameRate < -fEpsn)) {
113113 pCfg->fMaxFrameRate = fMaxFrameRate;
114114 }
115−
116− //bitrate setting validation
115+//bitrate setting validation
117116 if (pCfg->iRCMode != RC_OFF_MODE) {
118117 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+ }
119122 for (i = 0; i < pCfg->iSpatialLayerNum; ++ i) {
120123 SSpatialLayerConfig* pSpatialLayer = &pCfg->sSpatialLayers[i];
121124 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+ }
122130 }
123131 if (iTotalBitrate > pCfg->iTargetBitrate) {
124132 WelsLog (pLogCtx, WELS_LOG_ERROR,
125133 "Invalid settings in bitrate. the sum of each layer bitrate(%d) is larger than total bitrate setting(%d)\n",
126134 iTotalBitrate, pCfg->iTargetBitrate);
135+ return ENC_RETURN_INVALIDINPUT;
127136 }
128− }
129137
138+ }
130139 return ENC_RETURN_SUCCESS;
131140 }
132141

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