! * \brief validate checking in parameter configuration * \pParam pParam SWelsSvcCodingParam* * \return successful - 0; otherwise none 0 for failed */
| 262 | * \return successful - 0; otherwise none 0 for failed |
| 263 | */ |
| 264 | int32_t ParamValidation (SLogContext* pLogCtx, SWelsSvcCodingParam* pCfg) { |
| 265 | const float fEpsn = 0.000001f; |
| 266 | int32_t i = 0; |
| 267 | |
| 268 | assert (pCfg != NULL); |
| 269 | |
| 270 | if (! (pCfg->iUsageType < INPUT_CONTENT_TYPE_ALL)) { |
| 271 | WelsLog (pLogCtx, WELS_LOG_ERROR, "ParamValidation(),Invalid usage type = %d", pCfg->iUsageType); |
| 272 | return ENC_RETURN_UNSUPPORTED_PARA; |
| 273 | } |
| 274 | if (pCfg->iUsageType == SCREEN_CONTENT_REAL_TIME) { |
| 275 | if (pCfg->iSpatialLayerNum > 1) { |
| 276 | WelsLog (pLogCtx, WELS_LOG_ERROR, "ParamValidation(),Invalid the number of Spatial layer(%d)for screen content", |
| 277 | pCfg->iSpatialLayerNum); |
| 278 | return ENC_RETURN_UNSUPPORTED_PARA; |
| 279 | } |
| 280 | if (pCfg->bEnableAdaptiveQuant) { |
| 281 | WelsLog (pLogCtx, WELS_LOG_WARNING, |
| 282 | "ParamValidation(), AdaptiveQuant(%d) is not supported yet for screen content, auto turned off", |
| 283 | pCfg->bEnableAdaptiveQuant); |
| 284 | pCfg->bEnableAdaptiveQuant = false; |
| 285 | } |
| 286 | if (pCfg->bEnableBackgroundDetection) { |
| 287 | WelsLog (pLogCtx, WELS_LOG_WARNING, |
| 288 | "ParamValidation(), BackgroundDetection(%d) is not supported yet for screen content, auto turned off", |
| 289 | pCfg->bEnableBackgroundDetection); |
| 290 | pCfg->bEnableBackgroundDetection = false; |
| 291 | } |
| 292 | if (pCfg->bEnableSceneChangeDetect == false) { |
| 293 | pCfg->bEnableSceneChangeDetect = true; |
| 294 | WelsLog (pLogCtx, WELS_LOG_WARNING, |
| 295 | "ParamValidation(), screen change detection should be turned on, change bEnableSceneChangeDetect as true"); |
| 296 | } |
| 297 | |
| 298 | } |
| 299 | |
| 300 | //turn off adaptive quant now, algorithms needs to be refactored |
| 301 | pCfg->bEnableAdaptiveQuant = false; |
| 302 | |
| 303 | if (pCfg->iSpatialLayerNum > 1) { |
| 304 | for (i = pCfg->iSpatialLayerNum - 1; i > 0; i--) { |
| 305 | SSpatialLayerConfig* fDlpUp = &pCfg->sSpatialLayers[i]; |
| 306 | SSpatialLayerConfig* fDlp = &pCfg->sSpatialLayers[i - 1]; |
| 307 | if ((fDlp->iVideoWidth > fDlpUp->iVideoWidth) || (fDlp->iVideoHeight > fDlpUp->iVideoHeight)) { |
| 308 | WelsLog (pLogCtx, WELS_LOG_ERROR, |
| 309 | "ParamValidation,Invalid resolution layer(%d) resolution(%d x %d) should be less than the upper spatial layer resolution(%d x %d) ", |
| 310 | i, fDlp->iVideoWidth, fDlp->iVideoHeight, fDlpUp->iVideoWidth, fDlpUp->iVideoHeight); |
| 311 | return ENC_RETURN_UNSUPPORTED_PARA; |
| 312 | } |
| 313 | } |
| 314 | } |
| 315 | |
| 316 | if (!CheckInRangeCloseOpen (pCfg->iLoopFilterDisableIdc, DEBLOCKING_IDC_0, DEBLOCKING_IDC_2 + 1) || |
| 317 | !CheckInRangeCloseOpen (pCfg->iLoopFilterAlphaC0Offset, DEBLOCKING_OFFSET_MINUS, DEBLOCKING_OFFSET + 1) || |
| 318 | !CheckInRangeCloseOpen (pCfg->iLoopFilterBetaOffset, DEBLOCKING_OFFSET_MINUS, DEBLOCKING_OFFSET + 1)) { |
| 319 | WelsLog (pLogCtx, WELS_LOG_ERROR, |
| 320 | "ParamValidation, Invalid iLoopFilterDisableIdc(%d) or iLoopFilterAlphaC0Offset(%d) or iLoopFilterBetaOffset(%d)!", |
| 321 | pCfg->iLoopFilterDisableIdc, pCfg->iLoopFilterAlphaC0Offset, pCfg->iLoopFilterBetaOffset); |
no test coverage detected