Merge pull request #1739 from sijchen/sps_list3

[Encoder] rename the SpsPpsStrategy to enum
This commit is contained in:
huili2 2015-01-19 13:31:51 +08:00
commit 01fd220ef9
9 changed files with 166 additions and 74 deletions

View File

@ -432,7 +432,7 @@ typedef struct TagEncParamExt {
ECOMPLEXITY_MODE iComplexityMode;
unsigned int uiIntraPeriod; ///< period of Intra frame
int iNumRefFrame; ///< number of reference frame used
int iSpsPpsIdStrategy; ///< different stategy in adjust ID in SPS/PPS: 0- constant ID, 1-additional ID, 6-mapping and additional
EParameterSetStrategy eSpsPpsIdStrategy; ///< different stategy in adjust ID in SPS/PPS: 0- constant ID, 1-additional ID, 6-mapping and additional
bool bPrefixNalAddingCtrl; ///< false:not use Prefix NAL; true: use Prefix NAL
bool bEnableSSEI; ///< false:not use SSEI; true: use SSEI -- TODO: planning to remove the interface of SSEI
bool bSimulcastAVC; ///< (when encoding more than 1 spatial layer) false: use SVC syntax for higher layers; true: use Simulcast AVC -- coming soon

View File

@ -233,7 +233,27 @@ int ParseConfig (CReadConfig& cRdCfg, SSourcePicture* pSrcPic, SEncParamExt& pSv
} else if (strTag[0].compare ("MaxNalSize") == 0) {
pSvcParam.uiMaxNalSize = atoi (strTag[1].c_str());
} else if (strTag[0].compare ("SpsPpsIDStrategy") == 0) {
pSvcParam.iSpsPpsIdStrategy = atoi (strTag[1].c_str());
int32_t iValue = atoi (strTag[1].c_str());
switch (iValue) {
case 0:
pSvcParam.eSpsPpsIdStrategy = CONSTANT_ID;
break;
case 0x01:
pSvcParam.eSpsPpsIdStrategy = INCREASING_ID;
break;
case 0x02:
pSvcParam.eSpsPpsIdStrategy = SPS_LISTING;
break;
case 0x03:
pSvcParam.eSpsPpsIdStrategy = SPS_LISTING_AND_PPS_INCREASING;
break;
case 0x06:
pSvcParam.eSpsPpsIdStrategy = SPS_PPS_LISTING;
break;
default:
pSvcParam.eSpsPpsIdStrategy = CONSTANT_ID;
break;
}
} else if (strTag[0].compare ("EnableScalableSEI") == 0) {
pSvcParam.bEnableSSEI = atoi (strTag[1].c_str()) ? true : false;
} else if (strTag[0].compare ("EnableFrameCropping") == 0) {
@ -420,9 +440,29 @@ int ParseCommandLine (int argc, char** argv, SSourcePicture* pSrcPic, SEncParamE
else if (!strcmp (pCommand, "-nalsize") && (n < argc))
pSvcParam.uiMaxNalSize = atoi (argv[n++]);
else if (!strcmp (pCommand, "-spsid") && (n < argc))
pSvcParam.iSpsPpsIdStrategy = atoi (argv[n++]);
else if (!strcmp (pCommand, "-spsid") && (n < argc)) {
int32_t iValue = atoi (argv[n++]);
switch (iValue) {
case 0:
pSvcParam.eSpsPpsIdStrategy = CONSTANT_ID;
break;
case 0x01:
pSvcParam.eSpsPpsIdStrategy = INCREASING_ID;
break;
case 0x02:
pSvcParam.eSpsPpsIdStrategy = SPS_LISTING;
break;
case 0x03:
pSvcParam.eSpsPpsIdStrategy = SPS_LISTING_AND_PPS_INCREASING;
break;
case 0x06:
pSvcParam.eSpsPpsIdStrategy = SPS_PPS_LISTING;
break;
default:
pSvcParam.eSpsPpsIdStrategy = CONSTANT_ID;
break;
}
}
else if (!strcmp (pCommand, "-cabac") && (n < argc))
pSvcParam.iEntropyCodingModeFlag = atoi (argv[n++]);
@ -591,7 +631,7 @@ int FillSpecificParameters (SEncParamExt& sParam) {
sParam.bEnableLongTermReference = 0; // long term reference control
sParam.iLtrMarkPeriod = 30;
sParam.uiIntraPeriod = 320; // period of Intra frame
sParam.iSpsPpsIdStrategy = INCREASING_ID;
sParam.eSpsPpsIdStrategy = INCREASING_ID;
sParam.bPrefixNalAddingCtrl = 0;
sParam.iComplexityMode = MEDIUM_COMPLEXITY;
int iIndexLayer = 0;

View File

@ -162,7 +162,7 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
param.bEnableAdaptiveQuant = true; // adaptive quantization control
param.bEnableFrameSkip = true; // frame skipping
param.bEnableLongTermReference = false; // long term reference control
param.iSpsPpsIdStrategy = INCREASING_ID; // pSps pPps id addition control
param.eSpsPpsIdStrategy = INCREASING_ID; // pSps pPps id addition control
param.bPrefixNalAddingCtrl = false; // prefix NAL adding control
param.iSpatialLayerNum = 1; // number of dependency(Spatial/CGS) layers used to be encoded
param.iTemporalLayerNum = 1; // number of temporal layer specified
@ -350,9 +350,17 @@ typedef struct TagWelsSvcCodingParam: SEncParamExt {
bPrefixNalAddingCtrl = pCodingParam.bPrefixNalAddingCtrl;
iSpsPpsIdStrategy =
pCodingParam.iSpsPpsIdStrategy;//For SVC meeting application, to avoid mosaic issue caused by cross-IDR reference.
if ( (CONSTANT_ID == pCodingParam.eSpsPpsIdStrategy)
|| (INCREASING_ID == pCodingParam.eSpsPpsIdStrategy)
|| (SPS_LISTING == pCodingParam.eSpsPpsIdStrategy)
|| (SPS_LISTING_AND_PPS_INCREASING == pCodingParam.eSpsPpsIdStrategy)
|| (SPS_PPS_LISTING == pCodingParam.eSpsPpsIdStrategy)) {
eSpsPpsIdStrategy =
pCodingParam.eSpsPpsIdStrategy;//For SVC meeting application, to avoid mosaic issue caused by cross-IDR reference.
//SHOULD enable this feature.
} else {
// keep the default value
}
SSpatialLayerInternal* pDlp = &sDependencyLayers[0];
SSpatialLayerConfig* pSpatialLayer = &sSpatialLayers[0];

View File

@ -86,7 +86,7 @@ typedef struct TagParaSetOffset {
int32_t iPpsIdList[MAX_DQ_LAYER_NUM][MAX_PPS_COUNT]; //index0: max pps types; index1: for differnt IDRs, if only index0=1, index1 can reach MAX_PPS_COUNT
#if _DEBUG
int32_t iSpsPpsIdStrategy;
int32_t eSpsPpsIdStrategy;
#endif
uint32_t uiInUseSpsNum;

View File

@ -349,7 +349,7 @@ int32_t WelsWritePpsSyntax (SWelsPPS* pPps, SBitStringAux* pBitStringAux, SParaS
#if _DEBUG
//SParaSetOffset use, 110421
if ((pPSOVector != NULL) && (INCREASING_ID & pPSOVector->iSpsPpsIdStrategy)) {
if ((pPSOVector != NULL) && (INCREASING_ID & pPSOVector->eSpsPpsIdStrategy)) {
const int32_t kiTmpSpsIdInBs = pPps->iSpsId +
pPSOVector->sParaSetOffsetVariable[kiParameterSetType].iParaSetIdDelta[pPps->iSpsId];
const int32_t tmp_pps_id_in_bs = pPps->iPpsId +

View File

@ -323,10 +323,10 @@ int32_t ParamValidationExt (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPa
pCodingParam->bDeblockingParallelFlag = true;
}
if (pCodingParam->iSpatialLayerNum > 1 && (SPS_LISTING & pCodingParam->iSpsPpsIdStrategy)) {
if (pCodingParam->iSpatialLayerNum > 1 && (SPS_LISTING & pCodingParam->eSpsPpsIdStrategy)) {
WelsLog (pLogCtx, WELS_LOG_INFO,
"ParamValidationExt(), iSpsPpsIdStrategy adjusted to CONSTANT_ID");
pCodingParam->iSpsPpsIdStrategy = CONSTANT_ID;
"ParamValidationExt(), eSpsPpsIdStrategy adjusted to CONSTANT_ID");
pCodingParam->eSpsPpsIdStrategy = CONSTANT_ID;
}
for (i = 0; i < pCodingParam->iSpatialLayerNum; ++ i) {
@ -674,9 +674,9 @@ static inline int32_t AcquireLayersNals (sWelsEncCtx** ppCtx, SWelsSvcCodingPara
// count parasets
iCountNumNals += 1 + iNumDependencyLayers + (iCountNumLayers << 1) +
iCountNumLayers // plus iCountNumLayers for reserved application
+ ((SPS_LISTING & pParam->iSpsPpsIdStrategy) ? MAX_SPS_COUNT : 0) //for Sps
+ (((SPS_LISTING & pParam->iSpsPpsIdStrategy) && (iNumDependencyLayers > 1)) ? MAX_SPS_COUNT : 0) //for SubsetSps
+ ((SPS_PPS_LISTING == pParam->iSpsPpsIdStrategy) ? MAX_PPS_COUNT : 0);
+ ((SPS_LISTING & pParam->eSpsPpsIdStrategy) ? MAX_SPS_COUNT : 0) //for Sps
+ (((SPS_LISTING & pParam->eSpsPpsIdStrategy) && (iNumDependencyLayers > 1)) ? MAX_SPS_COUNT : 0) //for SubsetSps
+ ((SPS_PPS_LISTING == pParam->eSpsPpsIdStrategy) ? MAX_PPS_COUNT : 0);
// to check number of layers / nals / slices dependencies, 12/8/2010
if (iCountNumLayers > MAX_LAYER_NUM_OF_FRAME) {
@ -1172,7 +1172,7 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p
// for dynamically malloc for parameter sets memory instead of maximal items for standard to reduce size, 3/18/2010
// SPS
if (! (SPS_LISTING & pParam->iSpsPpsIdStrategy)) {
if (! (SPS_LISTING & pParam->eSpsPpsIdStrategy)) {
(*ppCtx)->pSpsArray = (SWelsSPS*)pMa->WelsMalloc (sizeof (SWelsSPS), "pSpsArray");
WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pSpsArray), FreeMemorySvc (ppCtx))
if (iDlayerCount > 1) {
@ -1180,7 +1180,7 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p
WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pSubsetArray), FreeMemorySvc (ppCtx))
}
} else {
// pParam->iSpsPpsIdStrategy == SPS_LISTING_AND_PPS_INCREASING
// pParam->eSpsPpsIdStrategy == SPS_LISTING_AND_PPS_INCREASING
// new memory
(*ppCtx)->pSpsArray = (SWelsSPS*)pMa->WelsMalloc (MAX_SPS_COUNT * sizeof (SWelsSPS), "pSpsArray");
WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pSpsArray), FreeMemorySvc (ppCtx))
@ -1197,7 +1197,7 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p
}
}
// PPS
if (! (SPS_PPS_LISTING == pParam->iSpsPpsIdStrategy)) {
if (! (SPS_PPS_LISTING == pParam->eSpsPpsIdStrategy)) {
(*ppCtx)->pPPSArray = (SWelsPPS*)pMa->WelsMalloc (iDlayerCount * sizeof (SWelsPPS), "pPPSArray");
WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pPPSArray), FreeMemorySvc (ppCtx))
} else {
@ -1212,7 +1212,7 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p
}
}
if (INCREASING_ID & pParam->iSpsPpsIdStrategy) {
if (INCREASING_ID & pParam->eSpsPpsIdStrategy) {
(*ppCtx)->pPSOVector = & ((*ppCtx)->sPSOVector);
} else {
(*ppCtx)->pPSOVector = NULL;
@ -1229,11 +1229,11 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p
pDqIdc->uiSpatialId = iDlayerIndex;
if (! (SPS_LISTING & pParam->iSpsPpsIdStrategy)) {
if (! (SPS_LISTING & pParam->eSpsPpsIdStrategy)) {
WelsGenerateNewSps (*ppCtx, bUseSubsetSps, iDlayerIndex,
iDlayerCount, iSpsId, pSps, pSubsetSps);
} else {
//SPS_LISTING_AND_PPS_INCREASING == pParam->iSpsPpsIdStrategy
//SPS_LISTING_AND_PPS_INCREASING == pParam->eSpsPpsIdStrategy
//check if the current param can fit in an existing SPS
const int32_t kiFoundSpsId = FindExistingSps ((*ppCtx)->pSvcParam, bUseSubsetSps, iDlayerIndex, iDlayerCount,
bUseSubsetSps ? ((*ppCtx)->sPSOVector.uiInUseSubsetSpsNum) : ((*ppCtx)->sPSOVector.uiInUseSpsNum),
@ -1251,7 +1251,7 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p
}
} else {
//if no, generate a new SPS as usual
if ((SPS_PPS_LISTING == pParam->iSpsPpsIdStrategy) && (MAX_PPS_COUNT <= (*ppCtx)->sPSOVector.uiInUsePpsNum)) {
if ((SPS_PPS_LISTING == pParam->eSpsPpsIdStrategy) && (MAX_PPS_COUNT <= (*ppCtx)->sPSOVector.uiInUsePpsNum)) {
//check if we can generate new SPS or not
WelsLog (& (*ppCtx)->sLogCtx, WELS_LOG_ERROR,
"InitDqLayers(), cannot generate new SPS under the SPS_PPS_LISTING mode!");
@ -1260,7 +1260,7 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p
iSpsId = (!bUseSubsetSps) ? ((*ppCtx)->sPSOVector.uiInUseSpsNum++) : ((*ppCtx)->sPSOVector.uiInUseSubsetSpsNum++);
if (iSpsId >= MAX_SPS_COUNT) {
if (SPS_PPS_LISTING == pParam->iSpsPpsIdStrategy) {
if (SPS_PPS_LISTING == pParam->eSpsPpsIdStrategy) {
WelsLog (& (*ppCtx)->sLogCtx, WELS_LOG_ERROR,
"InitDqLayers(), cannot generate new SPS under the SPS_PPS_LISTING mode!");
return ENC_RETURN_UNSUPPORTED_PARA;
@ -1281,7 +1281,7 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p
}
}
if (! (SPS_PPS_LISTING == pParam->iSpsPpsIdStrategy)) {
if (! (SPS_PPS_LISTING == pParam->eSpsPpsIdStrategy)) {
pPps = & (*ppCtx)->pPPSArray[iPpsId];
// initialize pPps
WelsInitPps (pPps, pSps, pSubsetSps, iPpsId, true, bUseSubsetSps, pParam->iEntropyCodingModeFlag != 0);
@ -1336,11 +1336,11 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p
++ iDlayerIndex;
}
if (SPS_LISTING & pParam->iSpsPpsIdStrategy) {
if (SPS_LISTING & pParam->eSpsPpsIdStrategy) {
(*ppCtx)->iSpsNum = (*ppCtx)->sPSOVector.uiInUseSpsNum;
(*ppCtx)->iSubsetSpsNum = (*ppCtx)->sPSOVector.uiInUseSubsetSpsNum;
}
if (SPS_PPS_LISTING == pParam->iSpsPpsIdStrategy) {
if (SPS_PPS_LISTING == pParam->eSpsPpsIdStrategy) {
(*ppCtx)->iPpsNum = (*ppCtx)->sPSOVector.uiInUsePpsNum;
}
return ENC_RETURN_SUCCESS;
@ -2798,7 +2798,7 @@ void WelsInitCurrentLayer (sWelsEncCtx* pCtx,
int32_t iCurPpsId = pDqIdc->iPpsId;
int32_t iCurSpsId = pDqIdc->iSpsId;
if (SPS_PPS_LISTING == pParam->iSpsPpsIdStrategy) {
if (SPS_PPS_LISTING == pParam->eSpsPpsIdStrategy) {
iCurPpsId = pCtx->sPSOVector.iPpsIdList[pDqIdc->iPpsId][WELS_ABS (pCtx->uiIdrPicId - 1) % MAX_PPS_COUNT];
}
@ -3117,21 +3117,21 @@ int32_t WelsWriteParameterSets (sWelsEncCtx* pCtx, int32_t* pNalLen, int32_t* pN
while (iIdx < pCtx->iSpsNum) {
iNal = pCtx->pOut->iNalIndex;
if (INCREASING_ID == pCtx->pSvcParam->iSpsPpsIdStrategy) {
if (INCREASING_ID == pCtx->pSvcParam->eSpsPpsIdStrategy) {
#if _DEBUG
pCtx->sPSOVector.iSpsPpsIdStrategy = INCREASING_ID;
pCtx->sPSOVector.eSpsPpsIdStrategy = INCREASING_ID;
assert (iIdx < MAX_DQ_LAYER_NUM);
#endif
ParasetIdAdditionIdAdjust (& (pCtx->sPSOVector.sParaSetOffsetVariable[PARA_SET_TYPE_AVCSPS]),
pCtx->pSpsArray[0].uiSpsId,
MAX_SPS_COUNT);
} else if (CONSTANT_ID == pCtx->pSvcParam->iSpsPpsIdStrategy) {
} else if (CONSTANT_ID == pCtx->pSvcParam->eSpsPpsIdStrategy) {
memset (& (pCtx->sPSOVector), 0, sizeof (pCtx->sPSOVector));
}
/* generate sequence parameters set */
iId = (SPS_LISTING & pCtx->pSvcParam->iSpsPpsIdStrategy) ? iIdx : 0;
iId = (SPS_LISTING & pCtx->pSvcParam->eSpsPpsIdStrategy) ? iIdx : 0;
WelsLoadNal (pCtx->pOut, NAL_UNIT_SPS, NRI_PRI_HIGHEST);
WelsWriteSpsNal (&pCtx->pSpsArray[iId], &pCtx->pOut->sBsWrite,
@ -3157,9 +3157,9 @@ int32_t WelsWriteParameterSets (sWelsEncCtx* pCtx, int32_t* pNalLen, int32_t* pN
while (iIdx < pCtx->iSubsetSpsNum) {
iNal = pCtx->pOut->iNalIndex;
if (INCREASING_ID == pCtx->pSvcParam->iSpsPpsIdStrategy) {
if (INCREASING_ID == pCtx->pSvcParam->eSpsPpsIdStrategy) {
#if _DEBUG
pCtx->sPSOVector.iSpsPpsIdStrategy = INCREASING_ID;
pCtx->sPSOVector.eSpsPpsIdStrategy = INCREASING_ID;
assert (iIdx < MAX_DQ_LAYER_NUM);
#endif
@ -3193,7 +3193,7 @@ int32_t WelsWriteParameterSets (sWelsEncCtx* pCtx, int32_t* pNalLen, int32_t* pN
/* write all PPS */
iIdx = 0;
if ((SPS_PPS_LISTING == pCtx->pSvcParam->iSpsPpsIdStrategy) && (pCtx->iPpsNum < MAX_PPS_COUNT)) {
if ((SPS_PPS_LISTING == pCtx->pSvcParam->eSpsPpsIdStrategy) && (pCtx->iPpsNum < MAX_PPS_COUNT)) {
assert (pCtx->iPpsNum <= MAX_DQ_LAYER_NUM);
//Generate PPS LIST
@ -3216,7 +3216,7 @@ int32_t WelsWriteParameterSets (sWelsEncCtx* pCtx, int32_t* pNalLen, int32_t* pN
}
while (iIdx < pCtx->iPpsNum) {
if ((INCREASING_ID & pCtx->pSvcParam->iSpsPpsIdStrategy)) {
if ((INCREASING_ID & pCtx->pSvcParam->eSpsPpsIdStrategy)) {
//para_set_type = 2: PPS, use MAX_PPS_COUNT
ParasetIdAdditionIdAdjust (&pCtx->sPSOVector.sParaSetOffsetVariable[PARA_SET_TYPE_PPS], pCtx->pPPSArray[iIdx].iPpsId,
MAX_PPS_COUNT);
@ -3226,7 +3226,7 @@ int32_t WelsWriteParameterSets (sWelsEncCtx* pCtx, int32_t* pNalLen, int32_t* pN
/* generate picture parameter set */
WelsLoadNal (pCtx->pOut, NAL_UNIT_PPS, NRI_PRI_HIGHEST);
WelsWritePpsSyntax (&pCtx->pPPSArray[iIdx], &pCtx->pOut->sBsWrite,
((SPS_PPS_LISTING != pCtx->pSvcParam->iSpsPpsIdStrategy)) ? (& (pCtx->sPSOVector)) : NULL);
((SPS_PPS_LISTING != pCtx->pSvcParam->eSpsPpsIdStrategy)) ? (& (pCtx->sPSOVector)) : NULL);
WelsUnloadNal (pCtx->pOut);
iReturn = WelsEncodeNal (&pCtx->pOut->sNalList[iNal], NULL,
@ -4124,7 +4124,7 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa
(pOldParam->iMultipleThreadIdc != pNewParam->iMultipleThreadIdc) ||
(pOldParam->bEnableBackgroundDetection != pNewParam->bEnableBackgroundDetection) ||
(pOldParam->bEnableAdaptiveQuant != pNewParam->bEnableAdaptiveQuant) ||
(pOldParam->iSpsPpsIdStrategy != pNewParam->iSpsPpsIdStrategy);
(pOldParam->eSpsPpsIdStrategy != pNewParam->eSpsPpsIdStrategy);
if (pNewParam->iMaxNumRefFrame > pOldParam->iMaxNumRefFrame) {
bNeedReset = true;
}
@ -4173,7 +4173,7 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa
if (bNeedReset) {
SLogContext sLogCtx = (*ppCtx)->sLogCtx;
int32_t iOldSpsPpsIdStrategy = pOldParam->iSpsPpsIdStrategy;
int32_t iOldSpsPpsIdStrategy = pOldParam->eSpsPpsIdStrategy;
SParaSetOffsetVariable sTmpPsoVariable[PARA_SET_TYPE];
int32_t iTmpPpsIdList[MAX_DQ_LAYER_NUM * MAX_PPS_COUNT];
uint16_t uiTmpIdrPicId = (*ppCtx)->uiIdrPicId;//this is for LTR!
@ -4183,7 +4183,7 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa
SExistingParasetList sExistingParasetList;
SExistingParasetList* pExistingParasetList = NULL;
if ((CONSTANT_ID != iOldSpsPpsIdStrategy) && (CONSTANT_ID != pNewParam->iSpsPpsIdStrategy)) {
if ((CONSTANT_ID != iOldSpsPpsIdStrategy) && (CONSTANT_ID != pNewParam->eSpsPpsIdStrategy)) {
for (int32_t k = 0; k < PARA_SET_TYPE; k++) {
memset (((*ppCtx)->sPSOVector.sParaSetOffsetVariable[k].bUsedParaSetIdInBs), 0, MAX_PPS_COUNT * sizeof (bool));
}
@ -4191,7 +4191,7 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa
(PARA_SET_TYPE)*sizeof (SParaSetOffsetVariable)); // confirmed_safe_unsafe_usage
if ((SPS_LISTING & iOldSpsPpsIdStrategy)
&& (SPS_LISTING & pNewParam->iSpsPpsIdStrategy)) {
&& (SPS_LISTING & pNewParam->eSpsPpsIdStrategy)) {
pExistingParasetList = &sExistingParasetList;
sExistingParasetList.uiInUseSpsNum = (*ppCtx)->sPSOVector.uiInUseSpsNum;
sExistingParasetList.uiInUseSubsetSpsNum = (*ppCtx)->sPSOVector.uiInUseSubsetSpsNum;
@ -4200,7 +4200,7 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa
}
if ((SPS_PPS_LISTING == iOldSpsPpsIdStrategy)
&& (SPS_PPS_LISTING == pNewParam->iSpsPpsIdStrategy)) {
&& (SPS_PPS_LISTING == pNewParam->eSpsPpsIdStrategy)) {
pExistingParasetList = &sExistingParasetList;
sExistingParasetList.uiInUseSpsNum = (*ppCtx)->sPSOVector.uiInUseSpsNum;
sExistingParasetList.uiInUseSubsetSpsNum = (*ppCtx)->sPSOVector.uiInUseSubsetSpsNum;
@ -4230,14 +4230,14 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa
//for sEncoderStatistics
(*ppCtx)->sEncoderStatistics = sTempEncoderStatistics;
//load back the needed structure for iSpsPpsIdStrategy
if ((CONSTANT_ID != iOldSpsPpsIdStrategy) && (CONSTANT_ID != pNewParam->iSpsPpsIdStrategy)) {
//load back the needed structure for eSpsPpsIdStrategy
if ((CONSTANT_ID != iOldSpsPpsIdStrategy) && (CONSTANT_ID != pNewParam->eSpsPpsIdStrategy)) {
memcpy ((*ppCtx)->sPSOVector.sParaSetOffsetVariable, sTmpPsoVariable,
(PARA_SET_TYPE)*sizeof (SParaSetOffsetVariable)); // confirmed_safe_unsafe_usage
}
if ((SPS_PPS_LISTING == iOldSpsPpsIdStrategy)
&& (SPS_PPS_LISTING == pNewParam->iSpsPpsIdStrategy)) {
&& (SPS_PPS_LISTING == pNewParam->eSpsPpsIdStrategy)) {
memcpy (((*ppCtx)->sPSOVector.iPpsIdList), iTmpPpsIdList, MAX_DQ_LAYER_NUM * MAX_PPS_COUNT * sizeof (int32_t));
}
} else {
@ -4254,7 +4254,7 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa
pOldParam->fMaxFrameRate = pNewParam->fMaxFrameRate; // maximal frame rate [Hz / fps]
pOldParam->iComplexityMode = pNewParam->iComplexityMode; // color space of input sequence
pOldParam->uiIntraPeriod = pNewParam->uiIntraPeriod; // intra period (multiple of GOP size as desired)
pOldParam->iSpsPpsIdStrategy = pNewParam->iSpsPpsIdStrategy;
pOldParam->eSpsPpsIdStrategy = pNewParam->eSpsPpsIdStrategy;
pOldParam->bPrefixNalAddingCtrl = pNewParam->bPrefixNalAddingCtrl;
pOldParam->iNumRefFrame = pNewParam->iNumRefFrame; // number of reference frame used
pOldParam->uiGopSize = pNewParam->uiGopSize;

View File

@ -730,11 +730,11 @@ int32_t WelsCodeOneSlice (sWelsEncCtx* pEncCtx, const int32_t kiSliceIdx, const
WelsSliceHeaderExtInit (pEncCtx, pCurLayer, pCurSlice);
g_pWelsWriteSliceHeader[pCurSlice->bSliceHeaderExtFlag] (pEncCtx, pBs, pCurLayer, pCurSlice,
((SPS_PPS_LISTING != pEncCtx->pSvcParam->iSpsPpsIdStrategy) ? (&
((SPS_PPS_LISTING != pEncCtx->pSvcParam->eSpsPpsIdStrategy) ? (&
(pEncCtx->sPSOVector.sParaSetOffsetVariable[PARA_SET_TYPE_PPS].iParaSetIdDelta[0])) : NULL));
#if _DEBUG
if (INCREASING_ID & pEncCtx->sPSOVector.iSpsPpsIdStrategy) {
if (INCREASING_ID & pEncCtx->sPSOVector.eSpsPpsIdStrategy) {
const int32_t kiEncoderPpsId = pCurSlice->sSliceHeaderExt.sSliceHeader.pPps->iPpsId;
const int32_t kiTmpPpsIdInBs = kiEncoderPpsId +
pEncCtx->sPSOVector.sParaSetOffsetVariable[PARA_SET_TYPE_PPS].iParaSetIdDelta[ kiEncoderPpsId ];

View File

@ -487,7 +487,7 @@ int CWelsH264SVCEncoder::ForceIntraFrame (bool bIDR) {
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;\
iSpsPpsIdStrategy = %d;bPrefixNalAddingCtrl = %d;bEnableDenoise= %d;bEnableBackgroundDetection= %d;bEnableAdaptiveQuant= %d;bEnableFrameSkip= %d;bEnableLongTermReference= %d;iLtrMarkPeriod= %d;\
eSpsPpsIdStrategy = %d;bPrefixNalAddingCtrl = %d;bEnableDenoise= %d;bEnableBackgroundDetection= %d;bEnableAdaptiveQuant= %d;bEnableFrameSkip= %d;bEnableLongTermReference= %d;iLtrMarkPeriod= %d;\
iComplexityMode = %d;iNumRefFrame = %d;iEntropyCodingModeFlag = %d;uiMaxNalSize = %d;iLTRRefNum = %d;iMultipleThreadIdc = %d;iLoopFilterDisableIdc = %d (offset(alpha/beta): %d,%d)",
pParam->iUsageType,
pParam->iPicWidth,
@ -500,7 +500,7 @@ void CWelsH264SVCEncoder::TraceParamInfo (SEncParamExt* pParam) {
pParam->iSpatialLayerNum,
pParam->fMaxFrameRate,
pParam->uiIntraPeriod,
pParam->iSpsPpsIdStrategy,
pParam->eSpsPpsIdStrategy,
pParam->bPrefixNalAddingCtrl,
pParam->bEnableDenoise,
pParam->bEnableBackgroundDetection,
@ -911,17 +911,41 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) {
}
break;
case ENCODER_OPTION_ENABLE_SPS_PPS_ID_ADDITION: {
int32_t iValue = * ((int32_t*)pOption);
if (((iValue > INCREASING_ID) || (m_pEncContext->pSvcParam->iSpsPpsIdStrategy > INCREASING_ID))
&& m_pEncContext->pSvcParam->iSpsPpsIdStrategy != iValue) {
int32_t iValue = * (static_cast<int32_t*>(pOption));
EParameterSetStrategy eNewStrategy = CONSTANT_ID;
switch (iValue) {
case 0:
eNewStrategy = CONSTANT_ID;
break;
case 0x01:
eNewStrategy = INCREASING_ID;
break;
case 0x02:
eNewStrategy = SPS_LISTING;
break;
case 0x03:
eNewStrategy = SPS_LISTING_AND_PPS_INCREASING;
break;
case 0x06:
eNewStrategy = SPS_PPS_LISTING;
break;
default:
WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR,
" CWelsH264SVCEncoder::SetOption eSpsPpsIdStrategy(%d) not in valid range, unchanged! existing=%d",
iValue, m_pEncContext->pSvcParam->eSpsPpsIdStrategy);
break;
}
if (((eNewStrategy & SPS_LISTING) || (m_pEncContext->pSvcParam->eSpsPpsIdStrategy & SPS_LISTING))
&& m_pEncContext->pSvcParam->eSpsPpsIdStrategy != eNewStrategy) {
WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR,
" CWelsH264SVCEncoder::SetOption iSpsPpsIdStrategy changing in the middle of call is NOT allowed for iSpsPpsIdStrategy>INCREASING_ID: existing setting is %d and the new one is %d",
m_pEncContext->pSvcParam->iSpsPpsIdStrategy, iValue);
" CWelsH264SVCEncoder::SetOption eSpsPpsIdStrategy changing in the middle of call is NOT allowed for eSpsPpsIdStrategy>INCREASING_ID: existing setting is %d and the new one is %d",
m_pEncContext->pSvcParam->eSpsPpsIdStrategy, iValue);
return cmInitParaError;
}
m_pEncContext->pSvcParam->iSpsPpsIdStrategy = iValue;
WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, " CWelsH264SVCEncoder::SetOption iSpsPpsIdStrategy = %d ",
m_pEncContext->pSvcParam->iSpsPpsIdStrategy);
m_pEncContext->pSvcParam->eSpsPpsIdStrategy = eNewStrategy;
WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, " CWelsH264SVCEncoder::SetOption eSpsPpsIdStrategy = %d ",
m_pEncContext->pSvcParam->eSpsPpsIdStrategy);
}
break;
case ENCODER_OPTION_CURRENT_PATH: {

View File

@ -260,7 +260,27 @@ void EncodeDecodeTestAPI::RandomParamExtCombination() {
param_.iNumRefFrame = AUTO_REF_PIC_COUNT;
param_.iMultipleThreadIdc = rand();
param_.iSpsPpsIdStrategy = rand() % 3;
int iValue = rand() % 7;
switch (iValue) {
case 0:
param_.eSpsPpsIdStrategy = CONSTANT_ID;
break;
case 0x01:
param_.eSpsPpsIdStrategy = INCREASING_ID;
break;
case 0x02:
param_.eSpsPpsIdStrategy = SPS_LISTING;
break;
case 0x03:
param_.eSpsPpsIdStrategy = SPS_LISTING_AND_PPS_INCREASING;
break;
case 0x06:
param_.eSpsPpsIdStrategy = SPS_PPS_LISTING;
break;
default:
param_.eSpsPpsIdStrategy = CONSTANT_ID;
break;
}
param_.bPrefixNalAddingCtrl = (rand() % 2 == 0) ? false : true;
param_.bEnableSSEI = (rand() % 2 == 0) ? false : true;
param_.iPaddingFlag = rand() % 2;
@ -2234,7 +2254,7 @@ TEST_F (DecodeCrashTestAPI, DecoderCrashTest) {
param_.iRCMode = RC_BITRATE_MODE;
param_.iTargetBitrate = p.iTarBitrate;
param_.uiIntraPeriod = 0;
param_.iSpsPpsIdStrategy = INCREASING_ID;
param_.eSpsPpsIdStrategy = INCREASING_ID;
param_.bEnableBackgroundDetection = true;
param_.bEnableSceneChangeDetect = true;
param_.bPrefixNalAddingCtrl = true;
@ -2568,21 +2588,21 @@ TEST_F (EncodeDecodeTestAPI, ParameterSetStrategy_SPS_LISTING_AND_PPS_INCREASING
SEncParamExt sParam3;
encoder_->GetDefaultParams (&sParam1);
prepareParam (iSpatialLayerNum, iSliceNum, iWidth, iHeight, fFrameRate, &sParam1);
sParam1.iSpsPpsIdStrategy = SPS_LISTING_AND_PPS_INCREASING;
sParam1.eSpsPpsIdStrategy = SPS_LISTING_AND_PPS_INCREASING;
//prepare param2
memcpy (&sParam2, &sParam1, sizeof (SEncParamExt));
while (sParam2.iPicWidth == sParam1.iPicWidth) {
sParam2.iPicWidth = GetRandWidth();
}
prepareParam (iSpatialLayerNum, iSliceNum, sParam2.iPicWidth, sParam2.iPicHeight, fFrameRate, &sParam2);
sParam2.iSpsPpsIdStrategy = SPS_LISTING_AND_PPS_INCREASING;
sParam2.eSpsPpsIdStrategy = SPS_LISTING_AND_PPS_INCREASING;
//prepare param3
memcpy (&sParam3, &sParam1, sizeof (SEncParamExt));
while (sParam3.iPicHeight == sParam1.iPicHeight) {
sParam3.iPicHeight = GetRandHeight();
}
prepareParam (iSpatialLayerNum, iSliceNum, sParam3.iPicWidth, sParam3.iPicHeight, fFrameRate, &sParam3);
sParam3.iSpsPpsIdStrategy = SPS_LISTING_AND_PPS_INCREASING;
sParam3.eSpsPpsIdStrategy = SPS_LISTING_AND_PPS_INCREASING;
//prepare output if needed
FILE* fEnc = NULL;
@ -2679,12 +2699,12 @@ TEST_F (EncodeDecodeTestAPI, ParameterSetStrategy_SPS_LISTING_AND_PPS_INCREASING
SEncParamExt sParam2;
encoder_->GetDefaultParams (&sParam1);
prepareParam (iSpatialLayerNum, iSliceNum, iWidth, iHeight, fFrameRate, &sParam1);
sParam1.iSpsPpsIdStrategy = SPS_LISTING_AND_PPS_INCREASING;
sParam1.eSpsPpsIdStrategy = SPS_LISTING_AND_PPS_INCREASING;
sParam1.iTemporalLayerNum = 1;
//prepare param2
memcpy (&sParam2, &sParam1, sizeof (SEncParamExt));
prepareParam (iSpatialLayerNum, iSliceNum, sParam2.iPicWidth, sParam2.iPicHeight, fFrameRate, &sParam2);
sParam2.iSpsPpsIdStrategy = SPS_LISTING_AND_PPS_INCREASING;
sParam2.eSpsPpsIdStrategy = SPS_LISTING_AND_PPS_INCREASING;
sParam2.iTemporalLayerNum = 3;
//prepare output if needed
@ -2734,7 +2754,7 @@ TEST_F (EncodeDecodeTestAPI, ParameterSetStrategy_SPS_LISTING_AND_PPS_INCREASING
SEncParamExt sParam2;
encoder_->GetDefaultParams (&sParam1);
prepareParam (iSpatialLayerNum, iSliceNum, iWidth, iHeight, fFrameRate, &sParam1);
sParam1.iSpsPpsIdStrategy = SPS_LISTING_AND_PPS_INCREASING;
sParam1.eSpsPpsIdStrategy = SPS_LISTING_AND_PPS_INCREASING;
//prepare output if needed
FILE* fEnc = NULL;
@ -2760,7 +2780,7 @@ TEST_F (EncodeDecodeTestAPI, ParameterSetStrategy_SPS_LISTING_AND_PPS_INCREASING
} while (vWidthTableIt == vWidthTable.end());
vWidthTable.push_back (sParam2.iPicWidth);
prepareParam (iSpatialLayerNum, iSliceNum, sParam2.iPicWidth, sParam2.iPicHeight, fFrameRate, &sParam2);
sParam2.iSpsPpsIdStrategy = SPS_LISTING_AND_PPS_INCREASING;
sParam2.eSpsPpsIdStrategy = SPS_LISTING_AND_PPS_INCREASING;
rv = encoder_->SetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, &sParam2);
ASSERT_TRUE (rv == cmResultSuccess) << "SetOption Failed sParam2: rv = " << rv << ", sParam2.iPicWidth=" <<
@ -2801,7 +2821,7 @@ TEST_F (EncodeDecodeTestAPI, ParameterSetStrategy_SPS_PPS_LISTING1) {
SEncParamExt sParam1;
encoder_->GetDefaultParams (&sParam1);
prepareParam (iSpatialLayerNum, iSliceNum, iWidth, iHeight, fFrameRate, &sParam1);
sParam1.iSpsPpsIdStrategy = SPS_PPS_LISTING;
sParam1.eSpsPpsIdStrategy = SPS_PPS_LISTING;
//prepare output if needed
FILE* fEnc = NULL;
@ -2866,14 +2886,14 @@ TEST_F (EncodeDecodeTestAPI, ParameterSetStrategy_SPS_PPS_LISTING2) {
SEncParamExt sParam2;
encoder_->GetDefaultParams (&sParam1);
prepareParam (iSpatialLayerNum, iSliceNum, iWidth, iHeight, fFrameRate, &sParam1);
sParam1.iSpsPpsIdStrategy = SPS_PPS_LISTING;
sParam1.eSpsPpsIdStrategy = SPS_PPS_LISTING;
//prepare param2
memcpy (&sParam2, &sParam1, sizeof (SEncParamExt));
while (sParam2.iPicWidth == sParam1.iPicWidth) {
sParam2.iPicWidth = GetRandWidth();
}
prepareParam (iSpatialLayerNum, iSliceNum, sParam2.iPicWidth, sParam2.iPicHeight, fFrameRate, &sParam2);
sParam2.iSpsPpsIdStrategy = SPS_PPS_LISTING;
sParam2.eSpsPpsIdStrategy = SPS_PPS_LISTING;
//prepare output if needed
FILE* fEnc = NULL;
@ -2925,21 +2945,21 @@ TEST_F (EncodeDecodeTestAPI, ParameterSetStrategy_SPS_PPS_LISTING3) {
SEncParamExt sParam3;
encoder_->GetDefaultParams (&sParam1);
prepareParam (iSpatialLayerNum, iSliceNum, iWidth, iHeight, fFrameRate, &sParam1);
sParam1.iSpsPpsIdStrategy = SPS_PPS_LISTING;
sParam1.eSpsPpsIdStrategy = SPS_PPS_LISTING;
//prepare param2
memcpy (&sParam2, &sParam1, sizeof (SEncParamExt));
while (sParam2.iPicWidth == sParam1.iPicWidth) {
sParam2.iPicWidth = GetRandWidth();
}
prepareParam (iSpatialLayerNum, iSliceNum, sParam2.iPicWidth, sParam2.iPicHeight, fFrameRate, &sParam2);
sParam2.iSpsPpsIdStrategy = SPS_PPS_LISTING;
sParam2.eSpsPpsIdStrategy = SPS_PPS_LISTING;
//prepare param3
memcpy (&sParam3, &sParam1, sizeof (SEncParamExt));
while (sParam3.iPicWidth == sParam1.iPicWidth || sParam3.iPicWidth == sParam2.iPicWidth) {
sParam3.iPicWidth = GetRandWidth();
}
prepareParam (iSpatialLayerNum, iSliceNum, sParam3.iPicWidth, sParam3.iPicHeight, fFrameRate, &sParam3);
sParam3.iSpsPpsIdStrategy = SPS_PPS_LISTING;
sParam3.eSpsPpsIdStrategy = SPS_PPS_LISTING;
//prepare output if needed
FILE* fEnc = NULL;