shithub: openh264

Download patch

ref: 01fd220ef9f9c0859d02e35ec7f56cc5596dd137
parent: eb7b149fccc46f78b1a2086b863e5f9456cfab31
parent: d9502aa71de3a1ed2b7fc0e7472ffda1277a1108
author: huili2 <[email protected]>
date: Mon Jan 19 08:31:51 EST 2015

Merge pull request #1739 from sijchen/sps_list3

[Encoder] rename the SpsPpsStrategy to enum

--- a/codec/api/svc/codec_app_def.h
+++ b/codec/api/svc/codec_app_def.h
@@ -432,7 +432,7 @@
   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
--- a/codec/console/enc/src/welsenc.cpp
+++ b/codec/console/enc/src/welsenc.cpp
@@ -233,7 +233,27 @@
       } 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 @@
     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 @@
   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;
--- a/codec/encoder/core/inc/param_svc.h
+++ b/codec/encoder/core/inc/param_svc.h
@@ -162,7 +162,7 @@
     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 @@
 
     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];
--- a/codec/encoder/core/inc/wels_common_basis.h
+++ b/codec/encoder/core/inc/wels_common_basis.h
@@ -86,7 +86,7 @@
   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;
--- a/codec/encoder/core/src/au_set.cpp
+++ b/codec/encoder/core/src/au_set.cpp
@@ -349,7 +349,7 @@
 
 #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 +
--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -323,10 +323,10 @@
     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 @@
   // 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 @@
 
   // 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 @@
       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 @@
     }
   }
   // 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 @@
     }
   }
 
-  if (INCREASING_ID & pParam->iSpsPpsIdStrategy) {
+  if (INCREASING_ID & pParam->eSpsPpsIdStrategy) {
     (*ppCtx)->pPSOVector = & ((*ppCtx)->sPSOVector);
   } else {
     (*ppCtx)->pPSOVector = NULL;
@@ -1229,11 +1229,11 @@
 
     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 @@
         }
       } 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 @@
 
         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 @@
       }
     }
 
-    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 @@
 
     ++ 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 @@
   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,9 +3117,9 @@
   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
 
@@ -3126,12 +3126,12 @@
       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 @@
   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 @@
 
   /* 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 @@
   }
 
   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 @@
     /* 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 @@
                 (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 @@
   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 @@
     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 @@
               (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 @@
       }
 
       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 @@
     //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 @@
     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;
--- a/codec/encoder/core/src/svc_encode_slice.cpp
+++ b/codec/encoder/core/src/svc_encode_slice.cpp
@@ -730,11 +730,11 @@
   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 ];
--- a/codec/encoder/plus/src/welsEncoderExt.cpp
+++ b/codec/encoder/plus/src/welsEncoderExt.cpp
@@ -487,7 +487,7 @@
 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 @@
            pParam->iSpatialLayerNum,
            pParam->fMaxFrameRate,
            pParam->uiIntraPeriod,
-           pParam->iSpsPpsIdStrategy,
+           pParam->eSpsPpsIdStrategy,
            pParam->bPrefixNalAddingCtrl,
            pParam->bEnableDenoise,
            pParam->bEnableBackgroundDetection,
@@ -911,17 +911,41 @@
   }
   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: {
--- a/test/api/encode_decode_api_test.cpp
+++ b/test/api/encode_decode_api_test.cpp
@@ -260,7 +260,27 @@
   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 @@
     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,7 +2588,7 @@
   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) {
@@ -2575,7 +2595,7 @@
     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) {
@@ -2582,7 +2602,7 @@
     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 @@
   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 @@
   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 @@
     } 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 @@
   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,7 +2886,7 @@
   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) {
@@ -2873,7 +2893,7 @@
     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,7 +2945,7 @@
   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) {
@@ -2932,7 +2952,7 @@
     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) {
@@ -2939,7 +2959,7 @@
     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;