shithub: openh264

Download patch

ref: 1005d639536edd36273f5ff51ce40df313675a28
parent: d26ebeec2c8e98339f85bfb5e9823c90da1ffd53
author: [email protected] <[email protected]>
date: Fri Apr 7 06:59:59 EDT 2017

clean unused multi-thread old functions

--- a/codec/common/src/WelsThreadPool.cpp
+++ b/codec/common/src/WelsThreadPool.cpp
@@ -94,7 +94,7 @@
     }
   }
 
-  //fprintf(stdout, "m_iRefCount=%d, pSink=%x, iMaxThreadNum=%d\n", m_iRefCount, pSink, iMaxThreadNum);
+  //fprintf(stdout, "m_iRefCount=%d, iMaxThreadNum=%d\n", m_iRefCount, m_iMaxThreadNum);
 
   ++ m_iRefCount;
   //fprintf(stdout, "m_iRefCount2=%d\n", m_iRefCount);
@@ -134,10 +134,10 @@
 
   RemoveThreadFromBusyList (pThread);
   AddThreadToIdleQueue (pThread);
-  //fprintf(stdout, "CWelsThreadPool::OnTaskStop 1: Task %x at Thread %x Finished, m_pSink=%x\n", pTask, pThread, m_pSink);
 
   if (pTask->GetSink()) {
     pTask->GetSink()->OnTaskExecuted();
+    //fprintf(stdout, "CWelsThreadPool::OnTaskStop 1: Task %x at Thread %x Finished, m_pSink=%x\n", pTask, pThread, pTask->GetSink());
   }
   //if (m_pSink) {
   //  m_pSink->OnTaskExecuted (pTask);
@@ -328,7 +328,6 @@
 }
 
 int32_t  CWelsThreadPool::GetWaitedTaskNum() {
-  //fprintf(stdout, "CWelsThreadPool::m_cWaitedTasks=%d\n", m_cWaitedTasks->size());
   return m_cWaitedTasks->size();
 }
 
--- a/codec/encoder/core/inc/mt_defs.h
+++ b/codec/encoder/core/inc/mt_defs.h
@@ -74,8 +74,6 @@
 WELS_EVENT                      pReadySliceCodingEvent[MAX_THREADS_NUM];        // events for slice coding ready, [iThreadIdx]
 WELS_EVENT                      pUpdateMbListEvent[MAX_THREADS_NUM];            // signal to update mb list neighbor for various slices
 WELS_EVENT                      pFinUpdateMbListEvent[MAX_THREADS_NUM]; // signal to indicate finish updating mb list
-WELS_EVENT                      pExitEncodeEvent[MAX_THREADS_NUM];                      // event for exit encoding event
-WELS_EVENT                      pThreadMasterEvent[MAX_THREADS_NUM];    // event for indicating that some event has been signalled to the thread
 
 WELS_MUTEX                      mutexSliceNumUpdate;    // for dynamic slicing mode MT
 
--- a/codec/encoder/core/inc/slice_multi_threading.h
+++ b/codec/encoder/core/inc/slice_multi_threading.h
@@ -74,13 +74,6 @@
 WELS_THREAD_ROUTINE_TYPE UpdateMbListThreadProc (void* arg);
 #endif//!_WIN32
 
-WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg);
-
-int32_t CreateSliceThreads (sWelsEncCtx* pCtx);
-
-int32_t FiredSliceThreads (sWelsEncCtx* pCtx, SSliceThreadPrivateData* pPriData, WELS_EVENT* pEventsList,
-                           WELS_EVENT* pMasterEventsList, SFrameBSInfo* pFrameBsInfo, const uint32_t kuiNumThreads);
-
 int32_t DynamicDetectCpuCores();
 
 
--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -2238,8 +2238,7 @@
     while (iThreadIdx < iThreadCount) {
       int res = 0;
       if ((*ppCtx)->pSliceThreading->pThreadHandles[iThreadIdx]) {
-        WelsEventSignal (& (*ppCtx)->pSliceThreading->pExitEncodeEvent[iThreadIdx]);
-        WelsEventSignal (& (*ppCtx)->pSliceThreading->pThreadMasterEvent[iThreadIdx]);
+
         res = WelsThreadJoin ((*ppCtx)->pSliceThreading->pThreadHandles[iThreadIdx]); // waiting thread exit
         WelsLog (& (*ppCtx)->sLogCtx, WELS_LOG_INFO, "WelsUninitEncoderExt(), pthread_join(pThreadHandles%d) return %d..",
                  iThreadIdx,
@@ -3749,24 +3748,6 @@
       else if ((SM_SIZELIMITED_SLICE == pParam->sSliceArgument.uiSliceMode) && (pSvcParam->iMultipleThreadIdc > 1)) {
         const int32_t kiPartitionCnt = pCtx->iActiveThreadsNum;
 
-#if 0 //TODO: temporarily use this to keep old codes for a while, will remove old codes later
-        int32_t iRet = 0;
-        // to fire slice coding threads
-        iRet = FiredSliceThreads (pCtx, &pCtx->pSliceThreading->pThreadPEncCtx[0],
-                                  &pCtx->pSliceThreading->pReadySliceCodingEvent[0],
-                                  &pCtx->pSliceThreading->pThreadMasterEvent[0],
-                                  pFbi, kiPartitionCnt);
-        if (iRet) {
-          WelsLog (pLogCtx, WELS_LOG_ERROR,
-                   "[MT] WelsEncoderEncodeExt(), FiredSliceThreads return(%d) failed and exit encoding frame, iSliceCount= %d, uiSliceMode= %d, iMultipleThreadIdc= %d!!",
-                   iRet, iSliceCount, pParam->sSliceArgument.uiSliceMode, pSvcParam->iMultipleThreadIdc);
-          return ENC_RETURN_UNEXPECTED;
-        }
-
-        WelsMultipleEventsWaitAllBlocking (kiPartitionCnt, &pCtx->pSliceThreading->pSliceCodedEvent[0],
-                                           &pCtx->pSliceThreading->pSliceCodedMasterEvent);
-        WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS)
-#else
         //TODO: use a function to remove duplicate code here and ln3994
         int32_t iLayerBsIdx       = pCtx->pOut->iLayerBsIndex;
         SLayerBSInfo* pLbi        = &pFbi->sLayerInfo[iLayerBsIdx];
@@ -3800,7 +3781,7 @@
                    pParam->sSliceArgument.uiSliceMode, pCtx->iEncoderError);
           return pCtx->iEncoderError;
         }
-#endif
+
         iRet = SliceLayerInfoUpdate (pCtx, pFbi, pLayerBsInfo, pParam->sSliceArgument.uiSliceMode);
         if (iRet) {
           WelsLog (pLogCtx, WELS_LOG_ERROR,
--- a/codec/encoder/core/src/slice_multi_threading.cpp
+++ b/codec/encoder/core/src/slice_multi_threading.cpp
@@ -70,12 +70,6 @@
 #define MT_TRACE_LOG(x, ...)
 #endif
 
-#define WELS_THREAD_SIGNAL_AND_BREAK(CodedEventList, CodedMasterEvent, iEventIdx) {  \
-    WelsEventSignal(&CodedEventList[iEventIdx]);  \
-    WelsEventSignal (&CodedMasterEvent);  \
-    break;  \
-}
-
 namespace WelsEnc {
 void UpdateMbListNeighborParallel (SDqLayer* pCurDq,
                                    SMB* pMbList,
@@ -314,12 +308,6 @@
     pSmt->pThreadPEncCtx[iIdx].iThreadIndex   = iIdx;
     pSmt->pThreadHandles[iIdx]                = 0;
 
-    WelsSnprintf (name, SEM_NAME_MAX, "ee%d%s", iIdx, pSmt->eventNamespace);
-    err = WelsEventOpen (&pSmt->pExitEncodeEvent[iIdx], name);
-    MT_TRACE_LOG (pLogCtx, WELS_LOG_INFO, "[MT] Open pExitEncodeEvent%d named(%s) ret%d err%d", iIdx, name, err, errno);
-    WelsSnprintf (name, SEM_NAME_MAX, "tm%d%s", iIdx, pSmt->eventNamespace);
-    err = WelsEventOpen (&pSmt->pThreadMasterEvent[iIdx], name);
-    MT_TRACE_LOG (pLogCtx, WELS_LOG_INFO, "[MT] Open pThreadMasterEvent%d named(%s) ret%d err%d", iIdx, name, err, errno);
     // length of semaphore name should be system constrained at least on mac 10.7
     WelsSnprintf (name, SEM_NAME_MAX, "ud%d%s", iIdx, pSmt->eventNamespace);
     err = WelsEventOpen (&pSmt->pUpdateMbListEvent[iIdx], name);
@@ -391,10 +379,6 @@
   char ename[SEM_NAME_MAX] = {0};
   while (iIdx < iThreadNum) {
     // length of semaphore name should be system constrained at least on mac 10.7
-    WelsSnprintf (ename, SEM_NAME_MAX, "ee%d%s", iIdx, pSmt->eventNamespace);
-    WelsEventClose (&pSmt->pExitEncodeEvent[iIdx], ename);
-    WelsSnprintf (ename, SEM_NAME_MAX, "tm%d%s", iIdx, pSmt->eventNamespace);
-    WelsEventClose (&pSmt->pThreadMasterEvent[iIdx], ename);
     WelsSnprintf (ename, SEM_NAME_MAX, "sc%d%s", iIdx, pSmt->eventNamespace);
     WelsEventClose (&pSmt->pSliceCodedEvent[iIdx], ename);
     WelsSnprintf (ename, SEM_NAME_MAX, "rc%d%s", iIdx, pSmt->eventNamespace);
@@ -509,343 +493,6 @@
 }
 
 // thread process for coding one pSlice
-WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) {
-  SSliceThreadPrivateData* pPrivateData = (SSliceThreadPrivateData*)arg;
-  sWelsEncCtx* pEncPEncCtx      = NULL;
-  SDqLayer* pCurDq              = NULL;
-  SSlice* pSlice                = NULL;
-  SWelsSliceBs* pSliceBs        = NULL;
-  WELS_EVENT pEventsList[3];
-  int32_t iEventCount           = 0;
-  WELS_THREAD_ERROR_CODE iWaitRet = WELS_THREAD_ERROR_GENERAL;
-  uint32_t uiThrdRet            = 0;
-  int32_t iSliceSize            = 0;
-  int32_t iSliceIdx             = -1;
-  int32_t iThreadIdx            = -1;
-  int32_t iEventIdx             = -1;
-  bool bNeedPrefix              = false;
-  EWelsNalUnitType eNalType     = NAL_UNIT_UNSPEC_0;
-  EWelsNalRefIdc eNalRefIdc     = NRI_PRI_LOWEST;
-  int32_t iReturn = ENC_RETURN_SUCCESS;
-
-  if (NULL == pPrivateData)
-    WELS_THREAD_ROUTINE_RETURN (1);
-
-  pEncPEncCtx   = (sWelsEncCtx*)pPrivateData->pWelsPEncCtx;
-
-  iThreadIdx    = pPrivateData->iThreadIndex;
-  iEventIdx     = iThreadIdx;
-
-  pEventsList[iEventCount++] = pEncPEncCtx->pSliceThreading->pReadySliceCodingEvent[iEventIdx];
-  pEventsList[iEventCount++] = pEncPEncCtx->pSliceThreading->pExitEncodeEvent[iEventIdx];
-  pEventsList[iEventCount++] = pEncPEncCtx->pSliceThreading->pUpdateMbListEvent[iEventIdx];
-
-  WelsThreadSetName ("OpenH264Enc_CodingSliceThreadProc");
-
-  do {
-    MT_TRACE_LOG (& (pEncPEncCtx->sLogCtx), WELS_LOG_INFO,
-                  "[MT] CodingSliceThreadProc(), try to call WelsMultipleEventsWaitSingleBlocking(pEventsList= %p %p %p), pEncPEncCtx= %p!",
-                  pEventsList[0], pEventsList[1], pEventsList[1], (void*)pEncPEncCtx);
-    iWaitRet = WelsMultipleEventsWaitSingleBlocking (iEventCount,
-               &pEventsList[0],
-               &pEncPEncCtx->pSliceThreading->pThreadMasterEvent[iEventIdx],
-               &pEncPEncCtx->pSliceThreading->mutexEvent); // blocking until at least one event is signalled
-    if (WELS_THREAD_ERROR_WAIT_OBJECT_0 == iWaitRet) { // start pSlice coding signal waited
-      //int             iLayerIndex  = pEncPEncCtx->pOut->iLayerBsIndex;
-      //SFrameBSInfo*   pFrameBsInfo = pPrivateData->pFrameBsInfo;
-      //SLayerBSInfo*   pLbi = &pFrameBsInfo->sLayerInfo [iLayerIndex];
-
-      const int32_t kiCurDid            = pEncPEncCtx->uiDependencyId;
-      SWelsSvcCodingParam* pCodingParam = pEncPEncCtx->pSvcParam;
-      SSpatialLayerConfig* pParamD      = &pCodingParam->sSpatialLayers[kiCurDid];
-      SSlice* pCurSlice                 = NULL;
-
-      pCurDq            = pEncPEncCtx->pCurDqLayer;
-      eNalType          = pEncPEncCtx->eNalType;
-      eNalRefIdc        = pEncPEncCtx->eNalPriority;
-      bNeedPrefix       = pEncPEncCtx->bNeedPrefixNalFlag;
-
-      if (pParamD->sSliceArgument.uiSliceMode != SM_SIZELIMITED_SLICE) {
-        int64_t iSliceStart = 0;
-        bool bDsaFlag = false;
-        iSliceIdx     = pPrivateData->iSliceIndex;
-        pSlice        = &pCurDq->sSliceThreadInfo[iThreadIdx].pSliceInThread[iSliceIdx];
-        pSliceBs      = &pSlice->sSliceBs;
-
-        bDsaFlag = ((pParamD->sSliceArgument.uiSliceMode == SM_FIXEDSLCNUM_SLICE) &&
-                    pCodingParam->iMultipleThreadIdc > 1 &&
-                    pCodingParam->iMultipleThreadIdc >= pParamD->sSliceArgument.uiSliceNum);
-        if (bDsaFlag)
-          iSliceStart = WelsTime();
-
-        pSliceBs->uiBsPos       = 0;
-        pSliceBs->iNalIndex     = 0;
-        assert ((void*) (&pSliceBs->sBsWrite) == (void*)pSlice->pSliceBsa);
-        InitBits (&pSliceBs->sBsWrite, pSliceBs->pBsBuffer, pSliceBs->uiSize);
-
-#if MT_DEBUG_BS_WR
-        pSliceBs->bSliceCodedFlag = false;
-#endif//MT_DEBUG_BS_WR
-
-        if (bNeedPrefix) {
-          if (eNalRefIdc != NRI_PRI_LOWEST) {
-            WelsLoadNalForSlice (pSliceBs, NAL_UNIT_PREFIX, eNalRefIdc);
-            WelsWriteSVCPrefixNal (&pSliceBs->sBsWrite, eNalRefIdc, (NAL_UNIT_CODED_SLICE_IDR == eNalType));
-            WelsUnloadNalForSlice (pSliceBs);
-          } else { // No Prefix NAL Unit RBSP syntax here, but need add NAL Unit Header extension
-            WelsLoadNalForSlice (pSliceBs, NAL_UNIT_PREFIX, eNalRefIdc);
-            // No need write any syntax of prefix NAL Unit RBSP here
-            WelsUnloadNalForSlice (pSliceBs);
-          }
-        }
-
-        WelsLoadNalForSlice (pSliceBs, eNalType, eNalRefIdc);
-        pCurSlice = pEncPEncCtx->pCurDqLayer->ppSliceInLayer[iSliceIdx];
-        assert (iSliceIdx == (int) pCurSlice->iSliceIdx);
-        iReturn = SetSliceBoundaryInfo(pEncPEncCtx->pCurDqLayer, pCurSlice, iSliceIdx);
-        if (ENC_RETURN_SUCCESS != iReturn) {
-          uiThrdRet = iReturn;
-          WELS_THREAD_SIGNAL_AND_BREAK (pEncPEncCtx->pSliceThreading->pSliceCodedEvent,
-                                        pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent,
-                                        iEventIdx);
-        }
-
-        iReturn = SetSliceBoundaryInfo(pEncPEncCtx->pCurDqLayer, pSlice, iSliceIdx);
-        if (ENC_RETURN_SUCCESS != iReturn) {
-          uiThrdRet = iReturn;
-          WELS_THREAD_SIGNAL_AND_BREAK (pEncPEncCtx->pSliceThreading->pSliceCodedEvent,
-                                        pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent,
-                                        iEventIdx);
-        }
-
-        assert (iSliceIdx == pSlice->iSliceIdx);
-        iReturn = WelsCodeOneSlice (pEncPEncCtx, pSlice, eNalType);
-        if (ENC_RETURN_SUCCESS != iReturn) {
-          uiThrdRet = iReturn;
-          WELS_THREAD_SIGNAL_AND_BREAK (pEncPEncCtx->pSliceThreading->pSliceCodedEvent,
-                                        pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent,
-                                        iEventIdx);
-        }
-
-        WelsUnloadNalForSlice (pSliceBs);
-
-        iReturn    = WriteSliceBs (pEncPEncCtx, pSliceBs, iSliceIdx, iSliceSize);
-        if (ENC_RETURN_SUCCESS != iReturn) {
-          uiThrdRet = iReturn;
-          WELS_THREAD_SIGNAL_AND_BREAK (pEncPEncCtx->pSliceThreading->pSliceCodedEvent,
-                                        pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent,
-                                        iEventIdx);
-        }
-
-        pEncPEncCtx->pFuncList->pfDeblocking.pfDeblockingFilterSlice (pCurDq, pEncPEncCtx->pFuncList, pSlice);
-
-        if (bDsaFlag) {
-          pSlice->uiSliceConsumeTime = (uint32_t) (WelsTime() - iSliceStart);
-          MT_TRACE_LOG (& (pEncPEncCtx->sLogCtx), WELS_LOG_INFO,
-                        "[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,
-                        pSlice->iCountMbNumInSlice);
-        }
-
-#if defined(SLICE_INFO_OUTPUT)
-        fprintf (stderr,
-                 "@pSlice=%-6d sliceType:%c idc:%d size:%-6d\n",
-                 iSliceIdx,
-                 (pEncPEncCtx->eSliceType == P_SLICE ? 'P' : 'I'),
-                 eNalRefIdc,
-                 iSliceSize
-                );
-#endif//SLICE_INFO_OUTPUT
-
-#if MT_DEBUG_BS_WR
-        pSliceBs->bSliceCodedFlag = true;
-#endif//MT_DEBUG_BS_WR
-
-        WelsEventSignal (
-          &pEncPEncCtx->pSliceThreading->pSliceCodedEvent[iEventIdx]); // mean finished coding current pSlice
-        WelsEventSignal (
-          &pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent);
-      } else { // for SM_SIZELIMITED_SLICE parallelization
-        const int32_t kiPartitionId             = iThreadIdx;
-        const int32_t kiSliceIdxStep            = pEncPEncCtx->iActiveThreadsNum;
-        const int32_t kiFirstMbInPartition      = pCurDq->FirstMbIdxOfPartition[kiPartitionId];
-        const int32_t kiEndMbIdxInPartition     = pCurDq->EndMbIdxOfPartition[kiPartitionId];
-        int32_t iAnyMbLeftInPartition           = kiEndMbIdxInPartition - kiFirstMbInPartition + 1;
-        SSpatialLayerInternal *pParamInternal   = &pCodingParam->sDependencyLayers[kiCurDid];
-        iSliceIdx                               = pPrivateData->iSliceIndex;
-        SSlice* pStartSlice                     = &pCurDq->sSliceThreadInfo[iThreadIdx].pSliceInThread[iSliceIdx];
-        pStartSlice->sSliceHeaderExt.sSliceHeader.iFirstMbInSlice = kiFirstMbInPartition;
-        while (iAnyMbLeftInPartition > 0) {
-          if (iSliceIdx >= pCurDq->iMaxSliceNum) {
-            // TODO: need exception handler for not large enough of MAX_SLICES_NUM related memory usage
-            // No idea about its solution due MAX_SLICES_NUM is fixed lenght in relevent pData structure
-            uiThrdRet = 1;
-            WelsLog (&pEncPEncCtx->sLogCtx, WELS_LOG_WARNING,
-                     "[MT] CodingSliceThreadProc Too many slices: coding_idx %d, iSliceIdx %d, pCurDq->iMaxSliceNum %d",
-                     pParamInternal->iCodingIndex,
-                     iSliceIdx, pCurDq->iMaxSliceNum);
-            WELS_THREAD_SIGNAL_AND_BREAK (pEncPEncCtx->pSliceThreading->pSliceCodedEvent,
-                                          pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent,
-                                          iEventIdx);
-          }
-          pSlice                = &pCurDq->sSliceThreadInfo[iThreadIdx].pSliceInThread[iSliceIdx];
-          pSliceBs              = &pSlice->sSliceBs;
-          pSliceBs->uiBsPos     = 0;
-          pSliceBs->iNalIndex   = 0;
-
-          SetOneSliceBsBufferUnderMultithread (pEncPEncCtx, kiPartitionId, pSlice);
-          InitBits (&pSliceBs->sBsWrite, pSliceBs->pBsBuffer, pSliceBs->uiSize);
-
-          if (bNeedPrefix) {
-            if (eNalRefIdc != NRI_PRI_LOWEST) {
-              WelsLoadNalForSlice (pSliceBs, NAL_UNIT_PREFIX, eNalRefIdc);
-              WelsWriteSVCPrefixNal (&pSliceBs->sBsWrite, eNalRefIdc, (NAL_UNIT_CODED_SLICE_IDR == eNalType));
-              WelsUnloadNalForSlice (pSliceBs);
-            } else { // No Prefix NAL Unit RBSP syntax here, but need add NAL Unit Header extension
-              WelsLoadNalForSlice (pSliceBs, NAL_UNIT_PREFIX, eNalRefIdc);
-              // No need write any syntax of prefix NAL Unit RBSP here
-              WelsUnloadNalForSlice (pSliceBs);
-            }
-          }
-
-          WelsLoadNalForSlice (pSliceBs, eNalType, eNalRefIdc);
-          assert (iSliceIdx == pSlice->iSliceIdx);
-          iReturn = WelsCodeOneSlice (pEncPEncCtx, pSlice, eNalType);
-          if (ENC_RETURN_SUCCESS != iReturn) {
-            uiThrdRet = iReturn;
-            WELS_THREAD_SIGNAL_AND_BREAK (pEncPEncCtx->pSliceThreading->pSliceCodedEvent,
-                                          pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent,
-                                          iEventIdx);
-          }
-
-          WelsUnloadNalForSlice (pSliceBs);
-
-          iReturn    = WriteSliceBs (pEncPEncCtx, pSliceBs, iSliceIdx, iSliceSize);
-          if (ENC_RETURN_SUCCESS != iReturn) {
-            uiThrdRet = iReturn;
-            WelsLog (&pEncPEncCtx->sLogCtx, WELS_LOG_WARNING,
-                     "[MT] CodingSliceThreadProc, WriteSliceBs not successful: coding_idx %d, iSliceIdx %d, BufferSize %d, m_iSliceSize %d, iPayloadSize %d",
-                     pParamInternal->iCodingIndex,
-                     iSliceIdx, pSliceBs->uiSize, iSliceSize, pSliceBs->sNalList[0].iPayloadSize);
-
-            WELS_THREAD_SIGNAL_AND_BREAK (pEncPEncCtx->pSliceThreading->pSliceCodedEvent,
-                                          pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent,
-                                          iEventIdx);
-          }
-
-          pEncPEncCtx->pFuncList->pfDeblocking.pfDeblockingFilterSlice (pCurDq, pEncPEncCtx->pFuncList, pSlice);
-
-#if defined(SLICE_INFO_OUTPUT)
-          fprintf (stderr,
-                   "@pSlice=%-6d sliceType:%c idc:%d size:%-6d\n",
-                   iSliceIdx,
-                   (pEncPEncCtx->eSliceType == P_SLICE ? 'P' : 'I'),
-                   eNalRefIdc,
-                   iSliceSize
-                  );
-#endif//SLICE_INFO_OUTPUT
-
-          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->LastCodedMbIdxOfPartition[%d] %d\n",
-                        pEncPEncCtx->iCodingIndex, kiPartitionId, iSliceIdx, iSliceSize,
-                        pSlice->iCountMbNumInSlice,
-                        kiEndMbIdxInPartition, kiPartitionId, pCurDq->LastCodedMbIdxOfPartition[kiPartitionId]);
-
-          iAnyMbLeftInPartition = kiEndMbIdxInPartition - pCurDq->LastCodedMbIdxOfPartition[kiPartitionId];
-          iSliceIdx += kiSliceIdxStep;
-        }
-
-        if (uiThrdRet) { // any exception??
-          WELS_THREAD_SIGNAL_AND_BREAK (pEncPEncCtx->pSliceThreading->pSliceCodedEvent,
-                                        pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent,
-                                        iEventIdx);
-        }
-
-        WelsEventSignal (&pEncPEncCtx->pSliceThreading->pSliceCodedEvent[iEventIdx]); // mean finished coding current pSlice
-        WelsEventSignal (&pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent);
-      }
-    } else if (WELS_THREAD_ERROR_WAIT_OBJECT_0 + 1 == iWaitRet) { // exit thread signal
-      uiThrdRet = 0;
-      break;
-    } else if (WELS_THREAD_ERROR_WAIT_OBJECT_0 + 2 == iWaitRet) { // update pMb list singal
-      iSliceIdx =
-        iEventIdx; // pPrivateData->iSliceIndex; old threads can not be terminated, pPrivateData is not correct for applicable
-      pCurDq = pEncPEncCtx->pCurDqLayer;
-      UpdateMbListNeighborParallel (pCurDq, pCurDq->sMbDataP, iSliceIdx);
-      WelsEventSignal (
-        &pEncPEncCtx->pSliceThreading->pFinUpdateMbListEvent[iEventIdx]); // mean finished update pMb list for this pSlice
-    } else { // WELS_THREAD_ERROR_WAIT_TIMEOUT, or WELS_THREAD_ERROR_WAIT_FAILED
-      WelsLog (& (pEncPEncCtx->sLogCtx), WELS_LOG_WARNING,
-               "[MT] CodingSliceThreadProc(), waiting pReadySliceCodingEvent[%d] failed(%d) and thread%d terminated!", iEventIdx,
-               iWaitRet, iThreadIdx);
-      uiThrdRet = 1;
-      break;
-    }
-  } while (1);
-
-  //sync multi-threading error
-  WelsMutexLock (&pEncPEncCtx->mutexEncoderError);
-  if (uiThrdRet) pEncPEncCtx->iEncoderError |= uiThrdRet;
-  WelsMutexUnlock (&pEncPEncCtx->mutexEncoderError);
-
-  WELS_THREAD_ROUTINE_RETURN (uiThrdRet);
-}
-
-int32_t CreateSliceThreads (sWelsEncCtx* pCtx) {
-  const int32_t kiThreadCount = pCtx->pSvcParam->iMultipleThreadIdc;
-  int32_t iIdx = 0;
-
-  while (iIdx < kiThreadCount) {
-    if (WelsThreadCreate (&pCtx->pSliceThreading->pThreadHandles[iIdx], CodingSliceThreadProc,
-                          &pCtx->pSliceThreading->pThreadPEncCtx[iIdx], 0)) {
-      return 1;
-    }
-
-
-    ++ iIdx;
-  }
-  MT_TRACE_LOG (& (pCtx->sLogCtx), WELS_LOG_INFO, "CreateSliceThreads() exit..");
-  return 0;
-}
-
-int32_t FiredSliceThreads (sWelsEncCtx* pCtx, SSliceThreadPrivateData* pPriData, WELS_EVENT* pEventsList,
-                           WELS_EVENT* pMasterEventsList, SFrameBSInfo* pFrameBsInfo,
-                           const uint32_t uiNumThreads) {
-  int32_t iIdx              = 0;
-  const int32_t kiEventCnt  = uiNumThreads;
-  int32_t iLayerBsIdx       = pCtx->pOut->iLayerBsIndex;
-  SLayerBSInfo* pLbi        = &pFrameBsInfo->sLayerInfo[iLayerBsIdx];
-
-  if (pPriData == NULL || pFrameBsInfo == NULL || pLbi == NULL || kiEventCnt <= 0 || pEventsList == NULL) {
-    WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR,
-             "FiredSliceThreads(), fail due pPriData == %p ||pFrameBsInfo == %p || pLbi == %p || iEventCnt(%d) <= 0 || pEventsList == %p!!",
-             (void*)pPriData, (void*)pFrameBsInfo, (void*)pLbi, uiNumThreads, (void*)pEventsList);
-    return 1;
-  }
-
-  pLbi->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer;
-  pLbi->uiLayerType   = VIDEO_CODING_LAYER;
-  pLbi->uiSpatialId   = pCtx->uiDependencyId;
-  pLbi->uiTemporalId  = pCtx->uiTemporalId;
-  pLbi->uiQualityId   = 0;
-  pLbi->iNalCount     = 0;
-
-  iIdx = 0;
-  while (iIdx < kiEventCnt) {
-    pPriData[iIdx].pFrameBsInfo = pFrameBsInfo;
-    pPriData[iIdx].iSliceIndex  = iIdx;
-
-    WelsEventSignal (&pEventsList[iIdx]);
-    WelsEventSignal (&pMasterEventsList[iIdx]);
-
-    ++ iIdx;
-  }
-
-  return 0;
-}
-
 int32_t DynamicDetectCpuCores() {
   WelsLogicalProcessInfo  info;
   WelsQueryLogicalProcessInfo (&info);