shithub: openh264

Download patch

ref: 7e113c189a19d6d0c760a58cf30f2b2dba2689d4
parent: 71750df1cc651fc435e7e19aed6f9cf111e9d76e
author: huade <huashi@cisco.com>
date: Wed Dec 21 12:21:34 EST 2016

Multi-thread-fixed:RBC#1723:change slice idx type from unint32_t to int32_t

--- a/codec/encoder/core/inc/slice.h
+++ b/codec/encoder/core/inc/slice.h
@@ -184,7 +184,7 @@
 uint8_t         uiMvcNum;
 uint8_t         sScaleShift;
 
-uint32_t        uiSliceIdx;
+int32_t         iSliceIdx;
 uint32_t        uiThreadIdx;
 bool            bSliceHeaderExtFlag; // Indicate which slice header is used, avc or ext?
 uint8_t         uiLastMbQp;             // stored qp for last mb coded, maybe more efficient for mb skip detection etc.
--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -3682,7 +3682,7 @@
       }
 
       WelsLoadNal (pCtx->pOut, eNalType, eNalRefIdc);
-      assert (0 == (int) pCurSlice->uiSliceIdx);
+      assert (0 == (int) pCurSlice->iSliceIdx);
       pCtx->iEncoderError   = SetSliceBoundaryInfo(pCtx->pCurDqLayer, pCurSlice, 0);
       WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS)
 
@@ -3809,7 +3809,6 @@
         iLayerSize = AppendSliceToFrameBs (pCtx, pLayerBsInfo, kiPartitionCnt);
       } else { // for non-dynamic-slicing mode single threading branch..
         const bool bNeedPrefix = pCtx->bNeedPrefixNalFlag;
-
         int32_t iSliceIdx    = 0;
         uint32_t uiTheadIdx  = 0;
         SSlice* pCurSlice    = NULL;
@@ -3830,7 +3829,7 @@
           WelsLoadNal (pCtx->pOut, eNalType, eNalRefIdc);
 
           pCurSlice = &pCtx->pCurDqLayer->sSliceThreadInfo.pSliceInThread[uiTheadIdx][iSliceIdx];
-          assert (iSliceIdx == (int) pCurSlice->uiSliceIdx);
+          assert (iSliceIdx == pCurSlice->iSliceIdx);
           pCtx->iEncoderError   = SetSliceBoundaryInfo(pCtx->pCurDqLayer, pCurSlice, iSliceIdx);
           WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS)
 
@@ -4574,7 +4573,7 @@
     WelsLoadNal (pCtx->pOut, keNalType, keNalRefIdc);
 
     pCurSlice = &pCtx->pCurDqLayer->sSliceThreadInfo.pSliceInThread[uiTheadIdx][iSliceIdx];
-    assert (iSliceIdx == (int) pCurSlice->uiSliceIdx);
+    assert (iSliceIdx == pCurSlice->iSliceIdx);
 
     iReturn = WelsCodeOneSlice (pCtx, pCurSlice, keNalType);
     WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS)
@@ -4601,7 +4600,8 @@
 #endif//SLICE_INFO_OUTPUT
 
     ++ iNalIdxInLayer;
-    iSliceIdx += kiSliceStep; //if uiSliceIdx is not continuous
+
+    iSliceIdx += kiSliceStep; //if iSliceIdx is not continuous
     iAnyMbLeftInPartition = iEndMbIdxInPartition - pCurLayer->pLastCodedMbIdxOfPartition[kiPartitionId];
   }
 
--- a/codec/encoder/core/src/slice_multi_threading.cpp
+++ b/codec/encoder/core/src/slice_multi_threading.cpp
@@ -237,8 +237,8 @@
       return;
     }
     iRunLen[iSliceIdx] = iNumMbAssigning;
-    MT_TRACE_LOG (& (pCtx->sLogCtx), WELS_LOG_DEBUG,
-                  "[MT] DynamicAdjustSlicing(), uiSliceIdx= %d, iSliceComplexRatio= %.2f, slice_run_org= %d, slice_run_adj= %d",
+    MT_TRACE_LOG (&(pCtx->sLogCtx), WELS_LOG_DEBUG,
+                  "[MT] DynamicAdjustSlicing(), iSliceIdx= %d, iSliceComplexRatio= %.2f, slice_run_org= %d, slice_run_adj= %d",
                   iSliceIdx, ppSliceInLayer[iSliceIdx]->iSliceComplexRatio * 1.0f / INT_MULTIPLY,
                   ppSliceInLayer[iSliceIdx]->iCountMbNumInSlice,
                   iNumMbAssigning);
@@ -262,7 +262,6 @@
   int32_t iThreadNum            = 0;
   int32_t iIdx                  = 0;
   int32_t iReturn               = ENC_RETURN_SUCCESS;
-  int32_t iMaxSliceNumInThread  = 0;
 
   if (NULL == ppCtx || NULL == pCodingParam || NULL == *ppCtx || iCountBsLen <= 0)
     return 1;
@@ -275,8 +274,6 @@
   iThreadNum           = pPara->iMultipleThreadIdc;
 
   assert (iThreadNum > 0);
-  iMaxSliceNumInThread = ((*ppCtx)->iMaxSliceCount / iThreadNum + 1) * 2;
-  iMaxSliceNumInThread =  WELS_MIN ((*ppCtx)->iMaxSliceCount, (int) iMaxSliceNumInThread);
 
   pSmt = (SSliceThreading*)pMa->WelsMalloc (sizeof (SSliceThreading), "SSliceThreading");
   WELS_VERIFY_RETURN_IF (1, (NULL == pSmt))
@@ -636,7 +633,7 @@
 
         WelsLoadNalForSlice (pSliceBs, eNalType, eNalRefIdc);
         pCurSlice = pEncPEncCtx->pCurDqLayer->ppSliceInLayer[iSliceIdx];
-        assert (iSliceIdx == (int) pCurSlice->uiSliceIdx);
+        assert (iSliceIdx == (int) pCurSlice->iSliceIdx);
         iReturn = SetSliceBoundaryInfo(pEncPEncCtx->pCurDqLayer, pCurSlice, iSliceIdx);
         if (ENC_RETURN_SUCCESS != iReturn) {
           uiThrdRet = iReturn;
@@ -653,7 +650,7 @@
                                         iEventIdx);
         }
 
-        assert (iSliceIdx == (int) pSlice->uiSliceIdx);
+        assert (iSliceIdx == pSlice->iSliceIdx);
         iReturn = WelsCodeOneSlice (pEncPEncCtx, pSlice, eNalType);
         if (ENC_RETURN_SUCCESS != iReturn) {
           uiThrdRet = iReturn;
@@ -677,7 +674,7 @@
         if (bDsaFlag) {
           pSlice->uiSliceConsumeTime = (uint32_t) (WelsTime() - iSliceStart);
           MT_TRACE_LOG (& (pEncPEncCtx->sLogCtx), WELS_LOG_INFO,
-                        "[MT] CodingSliceThreadProc(), coding_idx %d, uiSliceIdx %d, uiSliceConsumeTime %d, iSliceSize %d, iFirstMbInSlice %d, count_num_mb_in_slice %d",
+                        "[MT] CodingSliceThreadProc(), coding_idx %d, iSliceIdx %d, uiSliceConsumeTime %d, iSliceSize %d, iFirstMbInSlice %d, count_num_mb_in_slice %d",
                         pEncPEncCtx->iCodingIndex, iSliceIdx,
                         pSlice->uiSliceConsumeTime, iSliceSize,
                         pSlice->sSliceHeaderExt.sSliceHeader.iFirstMbInSlice,
@@ -750,7 +747,7 @@
 
           WelsLoadNalForSlice (pSliceBs, eNalType, eNalRefIdc);
 
-          assert (iSliceIdx == (int) pSlice->uiSliceIdx);
+          assert (iSliceIdx == pSlice->iSliceIdx);
           iReturn = WelsCodeOneSlice (pEncPEncCtx, pSlice, eNalType);
           if (ENC_RETURN_SUCCESS != iReturn) {
             uiThrdRet = iReturn;
@@ -786,8 +783,8 @@
                   );
 #endif//SLICE_INFO_OUTPUT
 
-          MT_TRACE_LOG (& (pEncPEncCtx->sLogCtx), WELS_LOG_INFO,
-                        "[MT] CodingSliceThreadProc(), coding_idx %d, iPartitionId %d, uiSliceIdx %d, iSliceSize %d, count_mb_slice %d, iEndMbInPartition %d, pCurDq->pLastCodedMbIdxOfPartition[%d] %d\n",
+          MT_TRACE_LOG (&(pEncPEncCtx->sLogCtx), WELS_LOG_INFO,
+                        "[MT] CodingSliceThreadProc(), coding_idx %d, iPartitionId %d, iSliceIdx %d, iSliceSize %d, count_mb_slice %d, iEndMbInPartition %d, pCurDq->pLastCodedMbIdxOfPartition[%d] %d\n",
                         pEncPEncCtx->iCodingIndex, kiPartitionId, iSliceIdx, iSliceSize,
                         pSlice->iCountMbNumInSlice,
                         kiEndMbIdxInPartition, kiPartitionId, pCurDq->pLastCodedMbIdxOfPartition[kiPartitionId]);
--- a/codec/encoder/core/src/svc_enc_slice_segment.cpp
+++ b/codec/encoder/core/src/svc_enc_slice_segment.cpp
@@ -125,7 +125,7 @@
 bool CheckFixedSliceNumMultiSliceSetting (const int32_t kiMbNumInFrame, SSliceArgument* pSliceArg) {
   int32_t* pSlicesAssignList    = (int32_t*) & (pSliceArg->uiSliceMbNum[0]);
   const uint32_t kuiSliceNum    = pSliceArg->uiSliceNum;
-  uint32_t uiSliceIdx           = 0;
+  int32_t uiSliceIdx            = 0;
   const int32_t kiMbNumPerSlice = kiMbNumInFrame / kuiSliceNum;
   int32_t iNumMbLeft            = kiMbNumInFrame;
 
--- a/codec/encoder/core/src/svc_encode_slice.cpp
+++ b/codec/encoder/core/src/svc_encode_slice.cpp
@@ -527,7 +527,7 @@
   int32_t iNextMbIdx            = kiSliceFirstMbXY;
   const int32_t kiTotalNumMb    = pCurLayer->iMbWidth * pCurLayer->iMbHeight;
   int32_t iCurMbIdx             = 0, iNumMbCoded = 0;
-  const int32_t kiSliceIdx      = pSlice->uiSliceIdx;
+  const int32_t kiSliceIdx      = pSlice->iSliceIdx;
   const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset;
 
   SWelsMD sMd;
@@ -595,7 +595,7 @@
   int32_t iNextMbIdx            = kiSliceFirstMbXY;
   const int32_t kiTotalNumMb    = pCurLayer->iMbWidth * pCurLayer->iMbHeight;
   int32_t iCurMbIdx             = 0, iNumMbCoded = 0;
-  const int32_t kiSliceIdx      = pSlice->uiSliceIdx;
+  const int32_t kiSliceIdx      = pSlice->iSliceIdx;
   const int32_t kiPartitionId   = (kiSliceIdx % pEncCtx->iActiveThreadsNum);
   const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset;
   int32_t iEncReturn = ENC_RETURN_SUCCESS;
@@ -953,8 +953,8 @@
       return ENC_RETURN_MEMALLOCERR;
     }
 
-    pSlice->uiSliceIdx = iSliceIdx;
-    pSlice->uiThreadIdx = 0;
+    pSlice->iSliceIdx          = iSliceIdx;
+    pSlice->uiThreadIdx        = 0;
     pSlice->iCountMbNumInSlice = 0;
     pSlice->sSliceHeaderExt.sSliceHeader.iFirstMbInSlice = 0;
 
@@ -976,37 +976,7 @@
   }
   return ENC_RETURN_SUCCESS;
 }
-/*
-int32_t InitOneSliceInThread (sWelsEncCtx* pCtx,
-                              SSlice*& pSlice,
-                              const int32_t kiThreadIdx,
-                              const int32_t kiDlayerIdx,
-                              const int32_t kiSliceIdx) {
-  SDqLayer* pDqLayer                  = pCtx->pCurDqLayer;
-  SSliceArgument* pSliceArgument      = & pCtx->pSvcParam->sSpatialLayers[kiDlayerIdx].sSliceArgument;
-  const int32_t kiMBWidth             = pDqLayer->iMbWidth;
-  const int32_t kiMBHeight            = pDqLayer->iMbHeight;
-  const int32_t kiCodedNumInThread    = pDqLayer->sSliceThreadInfo.iEncodedSliceNumInThread[kiThreadIdx];
-  const int32_t kiMaxSliceNumInThread = pDqLayer->sSliceThreadInfo.iMaxSliceNumInThread[kiThreadIdx];
-  int32_t iRet                        = 0;
 
-  if (kiCodedNumInThread >= kiMaxSliceNumInThread) {
-    iRet = ReallocateSliceInThread(pCtx, pDqLayer, kiDlayerIdx, kiThreadIdx);
-    if (ENC_RETURN_SUCCESS != iRet) {
-      return iRet;
-    }
-  }
-
-  pSlice = pDqLayer->sSliceThreadInfo.pSliceInThread [kiThreadIdx] + kiCodedNumInThread;
-  // Initialize slice bs buffer info
-  pSlice->sSliceBs.uiBsPos   = 0;
-  pSlice->sSliceBs.iNalIndex = 0;
-  pSlice->sSliceBs.pBsBuffer = pCtx->pSliceThreading->pThreadBsBuffer[kiThreadIdx];
-
-  return ENC_RETURN_SUCCESS;
-}
-*/
-
 int32_t InitSliceThreadInfo (sWelsEncCtx* pCtx,
                              SDqLayer* pDqLayer,
                              const int32_t kiDlayerIndex,
@@ -1045,7 +1015,7 @@
   }
 
   for (; iIdx < MAX_THREADS_NUM; iIdx++) {
-    pSliceThreadInfo->iMaxSliceNumInThread[iIdx]     = iMaxSliceNumInThread;
+    pSliceThreadInfo->iMaxSliceNumInThread[iIdx]     = 0;
     pSliceThreadInfo->iEncodedSliceNumInThread[iIdx] = 0;
     pSliceThreadInfo->pSliceInThread[iIdx]           = NULL;
   }
@@ -1185,7 +1155,7 @@
       return ENC_RETURN_MEMALLOCERR;
     }
 
-    pSlice->uiSliceIdx = iSliceIdx;
+    pSlice->iSliceIdx = iSliceIdx;
     pSlice->uiThreadIdx = 0;
     pSlice->iCountMbNumInSlice = 0;
     pSlice->sSliceHeaderExt.sSliceHeader.iFirstMbInSlice = 0;
@@ -1244,41 +1214,6 @@
   return ENC_RETURN_SUCCESS;
 }
 
-/*
-int32_t ReallocateSliceInThread (sWelsEncCtx* pCtx,
-                                 SDqLayer* pDqLayer,
-                                 const int32_t kiDlayerIdx,
-                                 const int32_t kiThreadIndex) {
-
-  int32_t iMaxSliceNumInThread   = pDqLayer->sSliceThreadInfo.iMaxSliceNumInThread[kiThreadIndex];
-  int32_t iMaxSliceNumUpdate     = 0;
-  int32_t iRet                   = 0;
-  SSlice* pLastCodedSlice        = pDqLayer->sSliceThreadInfo.pSliceInThread[kiThreadIndex] + (iMaxSliceNumInThread - 1);
-  SSliceArgument* pSliceArgument = & pCtx->pSvcParam->sSpatialLayers[kiDlayerIdx].sSliceArgument;
-
-  iRet = CalculateNewSliceNum (pDqLayer,
-                               pLastCodedSlice,
-                               iMaxSliceNumInThread,
-                               iMaxSliceNumUpdate);
-
-  if (ENC_RETURN_SUCCESS != iRet) {
-    return iRet;
-  }
-
-  iRet = ReallocateSliceList (pCtx,
-                              pSliceArgument,
-                              pDqLayer->sSliceThreadInfo.pSliceInThread[kiThreadIndex],
-                              iMaxSliceNumInThread,
-                              iMaxSliceNumUpdate);
-  if (ENC_RETURN_SUCCESS != iRet) {
-    return iRet;
-  }
-
-  return ENC_RETURN_SUCCESS;
-}
-*/
-
-
 int32_t ReallocSliceBuffer (sWelsEncCtx* pCtx) {
 
   CMemoryAlign* pMA        = pCtx->pMemAlign;
@@ -1356,7 +1291,7 @@
   pCurLayer->iMaxSliceNum = iMaxSliceNumNew;
   return ENC_RETURN_SUCCESS;
 }
-/*
+
 int32_t ReOrderSliceInLayer (SDqLayer* pCurLayer,
                              const int32_t kiThreadNum,
                              const int32_t kiPartitionNum) {
@@ -1385,8 +1320,8 @@
         return ENC_RETURN_UNEXPECTED;
       }
 
-      iPartitionID    = pSliceInThread->uiSliceIdx % kiPartitionNum;
-      iActualSliceIdx = aiPartitionOffset[iPartitionID] + pSliceInThread->uiSliceIdx / kiPartitionNum;
+      iPartitionID    = pSliceInThread->iSliceIdx % kiPartitionNum;
+      iActualSliceIdx = aiPartitionOffset[iPartitionID] + pSliceInThread->iSliceIdx / kiPartitionNum;
       pCurLayer->ppSliceInLayer[iActualSliceIdx] = pSliceInThread;
     }
   }
@@ -1401,7 +1336,7 @@
       return ENC_RETURN_UNEXPECTED;
     }
 
-    if ( iSliceIdx != pCurLayer->ppSliceInLayer[iSliceIdx]->uiSliceIdx) {
+    if ( iSliceIdx != pCurLayer->ppSliceInLayer[iSliceIdx]->iSliceIdx) {
       return ENC_RETURN_UNEXPECTED;
     }
   }
@@ -1417,10 +1352,11 @@
   int32_t iCodedSliceNum  = 0;
   int32_t iThreadIdx      = 0;
   int32_t iRet            = 0;
+  int32_t iThreadNum      = 1; //TODO: should be equal to pCurLayer->iMaxSliceNum;
   SSliceArgument* pSliceArgument = & pCtx->pSvcParam->sSpatialLayers[kiDlayerIndex].sSliceArgument;
   int32_t iPartitionNum   = (SM_SIZELIMITED_SLICE == pSliceArgument->uiSliceMode) ? pCtx->iActiveThreadsNum : 1;
 
-  for ( ; iThreadIdx < pCtx->iActiveThreadsNum; iThreadIdx++) {
+  for ( ; iThreadIdx < iThreadNum; iThreadIdx++) {
     iCodedSliceNum += pCurLayer->sSliceThreadInfo.iMaxSliceNumInThread[iThreadIdx];
   }
 
@@ -1442,7 +1378,7 @@
   }
 
   //update ppSliceInLayer based on pSliceInThread, reordering based on slice index
-  iRet = ReOrderSliceInLayer (pCurLayer, pCtx->iActiveThreadsNum, iPartitionNum);
+  iRet = ReOrderSliceInLayer (pCurLayer, iThreadNum, iPartitionNum);
   if (ENC_RETURN_SUCCESS != iRet) {
     WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR,
              "CWelsH264SVCEncoder::SliceLayerInfoUpdate: ReOrderSliceInLayer failed");
@@ -1458,7 +1394,6 @@
 
   return ENC_RETURN_SUCCESS;
 }
-*/
 
 int32_t WelsCodeOneSlice (sWelsEncCtx* pEncCtx, SSlice* pCurSlice, const int32_t kiNalType) {
   SDqLayer* pCurLayer                   = pEncCtx->pCurDqLayer;
@@ -1559,7 +1494,7 @@
   uint32_t uiLen = 0;
   int32_t iPosBitOffset = 0;
   const int32_t  kiActiveThreadsNum = pEncCtx->iActiveThreadsNum;
-  const int32_t  kiPartitaionId = pCurSlice->uiSliceIdx % kiActiveThreadsNum;
+  const int32_t  kiPartitaionId = pCurSlice->iSliceIdx % kiActiveThreadsNum;
   const int32_t  kiEndMbIdxOfPartition = pEncCtx->pCurDqLayer->pEndMbIdxOfPartition[kiPartitaionId];
 
   const bool    kbCurMbNotFirstMbOfCurSlice      = ((iCurMbIdx > 0) && (pSliceCtx->pOverallMbMap[iCurMbIdx] ==
@@ -1580,8 +1515,8 @@
       && kbCurMbNotLastMbOfCurPartition) { //decide to add new pSlice
 
     WelsLog (&pEncCtx->sLogCtx, WELS_LOG_DETAIL,
-             "DynSlcJudgeSliceBoundaryStepBack: AddSliceBoundary: iCurMbIdx=%d, uiLen=%d, uiSliceIdx=%d", iCurMbIdx, uiLen,
-             pCurSlice->uiSliceIdx);
+             "DynSlcJudgeSliceBoundaryStepBack: AddSliceBoundary: iCurMbIdx=%d, uiLen=%d, iSliceIdx=%d", iCurMbIdx, uiLen,
+             pCurSlice->iSliceIdx);
 
     if (pEncCtx->pSvcParam->iMultipleThreadIdc > 1) {
       WelsMutexLock (&pEncCtx->pSliceThreading->mutexSliceNumUpdate);
@@ -1594,7 +1529,7 @@
     //      and will also extend when reallocated,
     //  tmp change is:  iMaxSliceNumConstraint is alway set to be MAXSLICENUM, will not change even reallocate
     const bool kbSliceNumNotExceedConstraint = pSliceCtx->iSliceNumInFrame < pEncCtx->pCurDqLayer->iMaxSliceNum;
-    const bool kbSliceIdxNotExceedConstraint = ((int) pCurSlice->uiSliceIdx + kiActiveThreadsNum) < pEncCtx->pCurDqLayer->iMaxSliceNum;
+    const bool kbSliceIdxNotExceedConstraint = ((int) pCurSlice->iSliceIdx + kiActiveThreadsNum) < pEncCtx->pCurDqLayer->iMaxSliceNum;
     const bool kbSliceNumReachConstraint     = (pSliceCtx->iSliceNumInFrame == pEncCtx->pCurDqLayer->iMaxSliceNum);
 
     //DYNAMIC_SLICING_ONE_THREAD: judge jump_avoiding_pack_exceed
@@ -1654,7 +1589,7 @@
   const int32_t kiTotalNumMb = pCurLayer->iMbWidth * pCurLayer->iMbHeight;
   const int32_t kiMvdInterTableStride = pEncCtx->iMvdCostTableStride;
   uint16_t* pMvdCostTable = &pEncCtx->pMvdCostTable[pEncCtx->iMvdCostTableSize];
-  const int32_t kiSliceIdx = pSlice->uiSliceIdx;
+  const int32_t kiSliceIdx = pSlice->iSliceIdx;
   const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset;
   int32_t iEncReturn = ENC_RETURN_SUCCESS;
   SDynamicSlicingStack sDss;
@@ -1750,7 +1685,7 @@
   int32_t iCurMbIdx = -1;
   const int32_t kiMvdInterTableStride = pEncCtx->iMvdCostTableStride;
   uint16_t* pMvdCostTable = &pEncCtx->pMvdCostTable[pEncCtx->iMvdCostTableSize];
-  const int32_t kiSliceIdx = pSlice->uiSliceIdx;
+  const int32_t kiSliceIdx = pSlice->iSliceIdx;
   const int32_t kiPartitionId = (kiSliceIdx % pEncCtx->iActiveThreadsNum);
   const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset;
   int32_t iEncReturn = ENC_RETURN_SUCCESS;
--- a/codec/encoder/core/src/svc_set_mb_syn_cavlc.cpp
+++ b/codec/encoder/core/src/svc_set_mb_syn_cavlc.cpp
@@ -302,7 +302,7 @@
     }
 
     /* Step 4: Check the left buffer */
-    return CheckBitstreamBuffer (pSlice->uiSliceIdx, pEncCtx, pBs);
+    return CheckBitstreamBuffer (pSlice->iSliceIdx, pEncCtx, pBs);
   }
 }
 
--- a/codec/encoder/core/src/wels_task_encoder.cpp
+++ b/codec/encoder/core/src/wels_task_encoder.cpp
@@ -167,7 +167,7 @@
 
   WelsLoadNalForSlice (m_pSliceBs, m_eNalType, m_eNalRefIdc);
 
-  assert (m_iSliceIdx == (int) m_pSlice->uiSliceIdx);
+  assert (m_iSliceIdx == (int) m_pSlice->iSliceIdx);
   int32_t iReturn = WelsCodeOneSlice (m_pCtx, m_pSlice, m_eNalType);
   if (ENC_RETURN_SUCCESS != iReturn) {
     return iReturn;
@@ -284,7 +284,7 @@
 
     WelsLoadNalForSlice (m_pSliceBs, m_eNalType, m_eNalRefIdc);
 
-    assert (iLocalSliceIdx == (int) m_pSlice->uiSliceIdx);
+    assert (iLocalSliceIdx == (int) m_pSlice->iSliceIdx);
     int32_t iReturn = WelsCodeOneSlice (m_pCtx, m_pSlice, m_eNalType);
     if (ENC_RETURN_SUCCESS != iReturn) {
       return iReturn;