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