add profile and level checking in ParamValidation
Showing the changes to codec/encoder/core/src/encoder_ext.cpp (1 of 4 files). Show all
Unified · Split
| @@ -107,7 +107,43 @@ int32_t WelsBitRateVerification (SLogContext* pLogCtx, SSpatialLayerConfig* pLay · 106 unmodified lines | |||
| 107 | return ENC_RETURN_SUCCESS; | 107 | return ENC_RETURN_SUCCESS; |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | 110 | void CheckProfileSetting (SLogContext* pLogCtx, SWelsSvcCodingParam* pParam, int32_t iLayer, EProfileIdc uiProfileIdc) { | |
| 111 | SSpatialLayerConfig* pLayerInfo = &pParam->sSpatialLayers[iLayer]; | ||
| 112 | pLayerInfo->uiProfileIdc = uiProfileIdc; | ||
| 113 | if ((iLayer == SPATIAL_LAYER_0) && (uiProfileIdc != PRO_BASELINE)) { | ||
| 114 | pLayerInfo->uiProfileIdc = PRO_BASELINE; | ||
| 115 | WelsLog (pLogCtx, WELS_LOG_WARNING, "doesn't support profile(%d),change to baseline profile", | ||
| 116 | uiProfileIdc); | ||
| 117 | } | ||
| 118 | if (iLayer > SPATIAL_LAYER_0) { | ||
| 119 | if ((uiProfileIdc != PRO_BASELINE) || (uiProfileIdc != PRO_SCALABLE_BASELINE)) { | ||
| 120 | pLayerInfo->uiProfileIdc = PRO_BASELINE; | ||
| 121 | WelsLog (pLogCtx, WELS_LOG_WARNING, "doesn't support profile(%d),change to baseline profile", | ||
| 122 | uiProfileIdc); | ||
| 123 | } | ||
| 124 | } | ||
| 125 | } | ||
| 126 | void CheckLevelSetting (SLogContext* pLogCtx, SWelsSvcCodingParam* pParam, int32_t iLayer, ELevelIdc uiLevelIdc) { | ||
| 127 | SSpatialLayerConfig* pLayerInfo = &pParam->sSpatialLayers[iLayer]; | ||
| 128 | pLayerInfo->uiLevelIdc = uiLevelIdc; | ||
| 129 | if (uiLevelIdc == LEVEL_UNKNOWN) { | ||
| 130 | pLayerInfo->uiLevelIdc = LEVEL_1_0; | ||
| 131 | WelsLog (pLogCtx, WELS_LOG_INFO, "change LEVEL_UNKNOWN to LEVEL_1_0"); | ||
| 132 | } else if ((uiLevelIdc < LEVEL_1_0) || (uiLevelIdc > LEVEL_5_2)) { | ||
| 133 | pLayerInfo->uiLevelIdc = LEVEL_1_0; | ||
| 134 | WelsLog (pLogCtx, WELS_LOG_WARNING, "doesn't support level(%d) change to LEVEL_1_0", uiLevelIdc); | ||
| 135 | } | ||
| 136 | } | ||
| 137 | void CheckReferenceNumSetting (SLogContext* pLogCtx, SWelsSvcCodingParam* pParam, int32_t iNumRef) { | ||
| 138 | int32_t iRefUpperBound = (pParam->iUsageType == CAMERA_VIDEO_REAL_TIME) ? | ||
| 139 | MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA : MAX_REFERENCE_PICTURE_COUNT_NUM_SCREEN; | ||
| 140 | pParam->iNumRefFrame = iNumRef; | ||
| 141 | if ((iNumRef < MIN_REF_PIC_COUNT) || (iNumRef > iRefUpperBound)) { | ||
| 142 | pParam->iNumRefFrame = AUTO_REF_PIC_COUNT; | ||
| 143 | WelsLog (pLogCtx, WELS_LOG_WARNING, | ||
| 144 | "doesn't support the number of reference frame(%d) change to auto select mode", iNumRef); | ||
| 145 | } | ||
| 146 | } | ||
| 111 | /*! | 147 | /*! |
| 112 | * \brief validate checking in parameter configuration | 148 | * \brief validate checking in parameter configuration |
| 113 | * \pParam pParam SWelsSvcCodingParam* | 149 | * \pParam pParam SWelsSvcCodingParam* |
| @@ -311,6 +347,8 @@ int32_t ParamValidationExt (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPa · 197 unmodified lines | |||
| 311 | pSpatialLayer->sSliceCfg.uiSliceMode, pCodingParam->uiMaxNalSize); | 347 | pSpatialLayer->sSliceCfg.uiSliceMode, pCodingParam->uiMaxNalSize); |
| 312 | return ENC_RETURN_UNSUPPORTED_PARA; | 348 | return ENC_RETURN_UNSUPPORTED_PARA; |
| 313 | } | 349 | } |
| 350 | CheckProfileSetting (pLogCtx, pCodingParam, i, pSpatialLayer->uiProfileIdc); | ||
| 351 | CheckLevelSetting (pLogCtx, pCodingParam, i, pSpatialLayer->uiLevelIdc); | ||
| 314 | //check pSlice settings under multi-pSlice | 352 | //check pSlice settings under multi-pSlice |
| 315 | if (kiPicWidth <= 16 && kiPicHeight <= 16) { | 353 | if (kiPicWidth <= 16 && kiPicHeight <= 16) { |
| 316 | //only have one MB, set to single_slice | 354 | //only have one MB, set to single_slice |
| @@ -3276,7 +3314,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 2959 unmodified lines | |||
| 3276 | if ((pSvcParam->iRCMode != RC_OFF_MODE)) | 3314 | if ((pSvcParam->iRCMode != RC_OFF_MODE)) |
| 3277 | pCtx->pVpp->AnalyzePictureComplexity (pCtx, pCtx->pEncPic, ((pCtx->eSliceType == P_SLICE) | 3315 | pCtx->pVpp->AnalyzePictureComplexity (pCtx, pCtx->pEncPic, ((pCtx->eSliceType == P_SLICE) |
| 3278 | && (pCtx->iNumRef0 > 0)) ? pCtx->pRefList0[0] : NULL, | 3316 | && (pCtx->iNumRef0 > 0)) ? pCtx->pRefList0[0] : NULL, |
| 3279 | iCurDid,(pCtx->eSliceType == P_SLICE)&&(pSvcParam->bEnableBackgroundDetection)); | 3317 | iCurDid, (pCtx->eSliceType == P_SLICE) && (pSvcParam->bEnableBackgroundDetection)); |
| 3280 | WelsUpdateRefSyntax (pCtx, pCtx->iPOC, | 3318 | WelsUpdateRefSyntax (pCtx, pCtx->iPOC, |
| 3281 | eFrameType); //get reordering syntax used for writing slice header and transmit to encoder. | 3319 | eFrameType); //get reordering syntax used for writing slice header and transmit to encoder. |
| 3282 | PrefetchReferencePicture (pCtx, eFrameType); // update reference picture for current pDq layer | 3320 | PrefetchReferencePicture (pCtx, eFrameType); // update reference picture for current pDq layer |