ref: b455c035f76776ec2fbc0f67f69744e8ba071c7f
parent: bac135ae81db5a3e41c4433864568d25a6688f95
parent: 00a2dc290c4172a691414370326f3390ccd0b8d9
author: sijchen <sijchen@cisco.com>
date: Thu Dec 25 12:37:01 EST 2014
Merge pull request #1670 from ruil2/level add profile and level checking in ParamValidation
--- a/codec/encoder/core/inc/extern.h
+++ b/codec/encoder/core/inc/extern.h
@@ -112,7 +112,9 @@
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);
}
--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -107,7 +107,43 @@
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 @@
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 @@
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
--- a/codec/encoder/plus/inc/welsEncoderExt.h
+++ b/codec/encoder/plus/inc/welsEncoderExt.h
@@ -98,9 +98,6 @@
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);
--- a/codec/encoder/plus/src/welsEncoderExt.cpp
+++ b/codec/encoder/plus/src/welsEncoderExt.cpp
@@ -484,40 +484,6 @@
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 @@
"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 @@
"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 @@
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 @@
}
}
-OpenH264Version WelsGetCodecVersion () {
+OpenH264Version WelsGetCodecVersion() {
(void) g_strCodecVer; // Avoid warnings about unused static variables
return g_stCodecVersion;
}