Merge pull request #1670 from ruil2/level
add profile and level checking in ParamValidation
This commit is contained in:
commit
b455c035f7
@ -112,7 +112,9 @@ int32_t WelsEncoderApplyBitRate (SLogContext* pLogCtx, SWelsSvcCodingParam* pPar
|
||||
int32_t WelsEncoderApplyBitVaryRang(SLogContext* pLogCtx, SWelsSvcCodingParam* pParam, int32_t iRang);
|
||||
int32_t WelsEncoderApplyLTR (SLogContext* pLogCtx, sWelsEncCtx** ppCtx, SLTRConfig* pLTRValue);
|
||||
int32_t FilterLTRRecoveryRequest (sWelsEncCtx* pCtx, SLTRRecoverRequest* pLTRRecoverRequest);
|
||||
|
||||
void CheckProfileSetting (SLogContext* pLogCtx,SWelsSvcCodingParam* pParam,int32_t iLayer, EProfileIdc uiProfileIdc);
|
||||
void CheckLevelSetting (SLogContext* pLogCtx,SWelsSvcCodingParam* pParam,int32_t iLayer, ELevelIdc uiLevelIdc);
|
||||
void CheckReferenceNumSetting (SLogContext* pLogCtx, SWelsSvcCodingParam* pParam,int32_t iNumRef);
|
||||
void FilterLTRMarkingFeedback (sWelsEncCtx* pCtx, SLTRMarkingFeedback* pLTRMarkingFeedback);
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,43 @@ int32_t WelsBitRateVerification (SLogContext* pLogCtx, SSpatialLayerConfig* pLay
|
||||
return ENC_RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
void CheckProfileSetting (SLogContext* pLogCtx, SWelsSvcCodingParam* pParam, int32_t iLayer, EProfileIdc uiProfileIdc) {
|
||||
SSpatialLayerConfig* pLayerInfo = &pParam->sSpatialLayers[iLayer];
|
||||
pLayerInfo->uiProfileIdc = uiProfileIdc;
|
||||
if ((iLayer == SPATIAL_LAYER_0) && (uiProfileIdc != PRO_BASELINE)) {
|
||||
pLayerInfo->uiProfileIdc = PRO_BASELINE;
|
||||
WelsLog (pLogCtx, WELS_LOG_WARNING, "doesn't support profile(%d),change to baseline profile",
|
||||
uiProfileIdc);
|
||||
}
|
||||
if (iLayer > SPATIAL_LAYER_0) {
|
||||
if ((uiProfileIdc != PRO_BASELINE) || (uiProfileIdc != PRO_SCALABLE_BASELINE)) {
|
||||
pLayerInfo->uiProfileIdc = PRO_BASELINE;
|
||||
WelsLog (pLogCtx, WELS_LOG_WARNING, "doesn't support profile(%d),change to baseline profile",
|
||||
uiProfileIdc);
|
||||
}
|
||||
}
|
||||
}
|
||||
void CheckLevelSetting (SLogContext* pLogCtx, SWelsSvcCodingParam* pParam, int32_t iLayer, ELevelIdc uiLevelIdc) {
|
||||
SSpatialLayerConfig* pLayerInfo = &pParam->sSpatialLayers[iLayer];
|
||||
pLayerInfo->uiLevelIdc = uiLevelIdc;
|
||||
if (uiLevelIdc == LEVEL_UNKNOWN) {
|
||||
pLayerInfo->uiLevelIdc = LEVEL_1_0;
|
||||
WelsLog (pLogCtx, WELS_LOG_INFO, "change LEVEL_UNKNOWN to LEVEL_1_0");
|
||||
} else if ((uiLevelIdc < LEVEL_1_0) || (uiLevelIdc > LEVEL_5_2)) {
|
||||
pLayerInfo->uiLevelIdc = LEVEL_1_0;
|
||||
WelsLog (pLogCtx, WELS_LOG_WARNING, "doesn't support level(%d) change to LEVEL_1_0", uiLevelIdc);
|
||||
}
|
||||
}
|
||||
void CheckReferenceNumSetting (SLogContext* pLogCtx, SWelsSvcCodingParam* pParam, int32_t iNumRef) {
|
||||
int32_t iRefUpperBound = (pParam->iUsageType == CAMERA_VIDEO_REAL_TIME) ?
|
||||
MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA : MAX_REFERENCE_PICTURE_COUNT_NUM_SCREEN;
|
||||
pParam->iNumRefFrame = iNumRef;
|
||||
if ((iNumRef < MIN_REF_PIC_COUNT) || (iNumRef > iRefUpperBound)) {
|
||||
pParam->iNumRefFrame = AUTO_REF_PIC_COUNT;
|
||||
WelsLog (pLogCtx, WELS_LOG_WARNING,
|
||||
"doesn't support the number of reference frame(%d) change to auto select mode", iNumRef);
|
||||
}
|
||||
}
|
||||
/*!
|
||||
* \brief validate checking in parameter configuration
|
||||
* \pParam pParam SWelsSvcCodingParam*
|
||||
@ -311,6 +347,8 @@ int32_t ParamValidationExt (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPa
|
||||
pSpatialLayer->sSliceCfg.uiSliceMode, pCodingParam->uiMaxNalSize);
|
||||
return ENC_RETURN_UNSUPPORTED_PARA;
|
||||
}
|
||||
CheckProfileSetting (pLogCtx, pCodingParam, i, pSpatialLayer->uiProfileIdc);
|
||||
CheckLevelSetting (pLogCtx, pCodingParam, i, pSpatialLayer->uiLevelIdc);
|
||||
//check pSlice settings under multi-pSlice
|
||||
if (kiPicWidth <= 16 && kiPicHeight <= 16) {
|
||||
//only have one MB, set to single_slice
|
||||
@ -3276,7 +3314,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
|
||||
if ((pSvcParam->iRCMode != RC_OFF_MODE))
|
||||
pCtx->pVpp->AnalyzePictureComplexity (pCtx, pCtx->pEncPic, ((pCtx->eSliceType == P_SLICE)
|
||||
&& (pCtx->iNumRef0 > 0)) ? pCtx->pRefList0[0] : NULL,
|
||||
iCurDid,(pCtx->eSliceType == P_SLICE)&&(pSvcParam->bEnableBackgroundDetection));
|
||||
iCurDid, (pCtx->eSliceType == P_SLICE) && (pSvcParam->bEnableBackgroundDetection));
|
||||
WelsUpdateRefSyntax (pCtx, pCtx->iPOC,
|
||||
eFrameType); //get reordering syntax used for writing slice header and transmit to encoder.
|
||||
PrefetchReferencePicture (pCtx, eFrameType); // update reference picture for current pDq layer
|
||||
|
@ -98,9 +98,6 @@ class CWelsH264SVCEncoder : public ISVCEncoder {
|
||||
|
||||
private:
|
||||
int InitializeInternal (SWelsSvcCodingParam* argv);
|
||||
void CheckProfileSetting (int32_t iLayer, EProfileIdc uiProfileIdc);
|
||||
void CheckLevelSetting (int32_t iLayer, ELevelIdc uiLevelIdc);
|
||||
void CheckReferenceNumSetting (int32_t iNumRef);
|
||||
void TraceParamInfo(SEncParamExt *pParam);
|
||||
void UpdateStatistics(const int64_t kiCurrentFrameTs, EVideoFrameType eFrameType, const int32_t kiCurrentFrameSize, const int64_t kiCurrentFrameMs);
|
||||
|
||||
|
@ -484,40 +484,6 @@ int CWelsH264SVCEncoder::ForceIntraFrame (bool bIDR) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
void CWelsH264SVCEncoder::CheckProfileSetting (int32_t iLayer, EProfileIdc uiProfileIdc) {
|
||||
SSpatialLayerConfig* pLayerInfo = &m_pEncContext->pSvcParam->sSpatialLayers[iLayer];
|
||||
pLayerInfo->uiProfileIdc = uiProfileIdc;
|
||||
if ((iLayer == SPATIAL_LAYER_0) && (uiProfileIdc != PRO_BASELINE)) {
|
||||
pLayerInfo->uiProfileIdc = PRO_BASELINE;
|
||||
WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_WARNING, "doesn't support profile(%d),change to baseline profile",
|
||||
uiProfileIdc);
|
||||
}
|
||||
if (iLayer > SPATIAL_LAYER_0) {
|
||||
if ((uiProfileIdc != PRO_BASELINE) || (uiProfileIdc != PRO_SCALABLE_BASELINE)) {
|
||||
pLayerInfo->uiProfileIdc = PRO_BASELINE;
|
||||
WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_WARNING, "doesn't support profile(%d),change to baseline profile",
|
||||
uiProfileIdc);
|
||||
}
|
||||
}
|
||||
}
|
||||
void CWelsH264SVCEncoder::CheckLevelSetting (int32_t iLayer, ELevelIdc uiLevelIdc) {
|
||||
SSpatialLayerConfig* pLayerInfo = &m_pEncContext->pSvcParam->sSpatialLayers[iLayer];
|
||||
pLayerInfo->uiLevelIdc = uiLevelIdc;
|
||||
if ((uiLevelIdc < LEVEL_1_0) || (uiLevelIdc > LEVEL_5_2)) {
|
||||
pLayerInfo->uiLevelIdc = LEVEL_5_2;
|
||||
WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_WARNING, "doesn't support level(%d) change to LEVEL_5_2", uiLevelIdc);
|
||||
}
|
||||
}
|
||||
void CWelsH264SVCEncoder::CheckReferenceNumSetting (int32_t iNumRef) {
|
||||
int32_t iRefUpperBound = (m_pEncContext->pSvcParam->iUsageType == CAMERA_VIDEO_REAL_TIME) ?
|
||||
MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA : MAX_REFERENCE_PICTURE_COUNT_NUM_SCREEN;
|
||||
m_pEncContext->pSvcParam->iNumRefFrame = iNumRef;
|
||||
if ((iNumRef < MIN_REF_PIC_COUNT) || (iNumRef > iRefUpperBound)) {
|
||||
m_pEncContext->pSvcParam->iNumRefFrame = AUTO_REF_PIC_COUNT;
|
||||
WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_WARNING,
|
||||
"doesn't support the number of reference frame(%d) change to auto select mode", iNumRef);
|
||||
}
|
||||
}
|
||||
void CWelsH264SVCEncoder::TraceParamInfo (SEncParamExt* pParam) {
|
||||
WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,
|
||||
"iUsageType = %d,iPicWidth= %d;iPicHeight= %d;iTargetBitrate= %d;iMaxBitrate= %d;iRCMode= %d;iPaddingFlag= %d;iTemporalLayerNum= %d;iSpatialLayerNum= %d;fFrameRate= %.6ff;uiIntraPeriod= %d;\
|
||||
@ -986,7 +952,8 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) {
|
||||
"CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_PROFILE,iLayer = %d(rang0-3)", pProfileInfo->iLayer);
|
||||
return cmInitParaError;
|
||||
}
|
||||
CheckProfileSetting (pProfileInfo->iLayer, pProfileInfo->uiProfileIdc);
|
||||
CheckProfileSetting (&m_pWelsTrace->m_sLogCtx, m_pEncContext->pSvcParam, pProfileInfo->iLayer,
|
||||
pProfileInfo->uiProfileIdc);
|
||||
WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,
|
||||
"CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_PROFILE,layerId = %d,expected profile = %d,actual profile = %d",
|
||||
pProfileInfo->iLayer, pProfileInfo->uiProfileIdc,
|
||||
@ -1000,7 +967,7 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) {
|
||||
"CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_PROFILE,iLayer = %d(rang0-3)", pLevelInfo->iLayer);
|
||||
return cmInitParaError;
|
||||
}
|
||||
CheckLevelSetting (pLevelInfo->iLayer, pLevelInfo->uiLevelIdc);
|
||||
CheckLevelSetting (&m_pWelsTrace->m_sLogCtx, m_pEncContext->pSvcParam, pLevelInfo->iLayer, pLevelInfo->uiLevelIdc);
|
||||
WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,
|
||||
"CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_LEVEL,layerId = %d,expected level = %d,actual level = %d",
|
||||
pLevelInfo->iLayer, pLevelInfo->uiLevelIdc, m_pEncContext->pSvcParam->sSpatialLayers[pLevelInfo->iLayer].uiLevelIdc);
|
||||
@ -1008,7 +975,7 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) {
|
||||
break;
|
||||
case ENCODER_OPTION_NUMBER_REF: {
|
||||
int32_t iValue = * ((int32_t*)pOption);
|
||||
CheckReferenceNumSetting (iValue);
|
||||
CheckReferenceNumSetting (&m_pWelsTrace->m_sLogCtx, m_pEncContext->pSvcParam, iValue);
|
||||
WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,
|
||||
"CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_NUMBER_REF,expected refNum = %d,actual refnum = %d", iValue,
|
||||
m_pEncContext->pSvcParam->iNumRefFrame);
|
||||
@ -1260,7 +1227,7 @@ void WelsDestroySVCEncoder (ISVCEncoder* pEncoder) {
|
||||
}
|
||||
}
|
||||
|
||||
OpenH264Version WelsGetCodecVersion () {
|
||||
OpenH264Version WelsGetCodecVersion() {
|
||||
(void) g_strCodecVer; // Avoid warnings about unused static variables
|
||||
return g_stCodecVersion;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user