History

Merge pull request #1670 from ruil2/level

add profile and level checking in ParamValidation

sijchen committed 11 years ago

Commit b455c032 parents bac135a 00a2dc24 files · +48 −44Browse files

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

Unified · Split

codec/encoder/core/src/encoder_ext.cpp+40−2
@@ -107,7 +107,43 @@ int32_t WelsBitRateVerification (SLogContext* pLogCtx, SSpatialLayerConfig* pLay · 106 unmodified lines
107107 return ENC_RETURN_SUCCESS;
108108 }
109109
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+}
111147 /*!
112148 * \brief validate checking in parameter configuration
113149 * \pParam pParam SWelsSvcCodingParam*
@@ -311,6 +347,8 @@ int32_t ParamValidationExt (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPa · 197 unmodified lines
311347 pSpatialLayer->sSliceCfg.uiSliceMode, pCodingParam->uiMaxNalSize);
312348 return ENC_RETURN_UNSUPPORTED_PARA;
313349 }
350+ CheckProfileSetting (pLogCtx, pCodingParam, i, pSpatialLayer->uiProfileIdc);
351+ CheckLevelSetting (pLogCtx, pCodingParam, i, pSpatialLayer->uiLevelIdc);
314352 //check pSlice settings under multi-pSlice
315353 if (kiPicWidth <= 16 && kiPicHeight <= 16) {
316354 //only have one MB, set to single_slice
@@ -3276,7 +3314,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 2959 unmodified lines
32763314 if ((pSvcParam->iRCMode != RC_OFF_MODE))
32773315 pCtx->pVpp->AnalyzePictureComplexity (pCtx, pCtx->pEncPic, ((pCtx->eSliceType == P_SLICE)
32783316 && (pCtx->iNumRef0 > 0)) ? pCtx->pRefList0[0] : NULL,
3279− iCurDid,(pCtx->eSliceType == P_SLICE)&&(pSvcParam->bEnableBackgroundDetection));
3317+ iCurDid, (pCtx->eSliceType == P_SLICE) && (pSvcParam->bEnableBackgroundDetection));
32803318 WelsUpdateRefSyntax (pCtx, pCtx->iPOC,
32813319 eFrameType); //get reordering syntax used for writing slice header and transmit to encoder.
32823320 PrefetchReferencePicture (pCtx, eFrameType); // update reference picture for current pDq layer

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