ref: 4ca5d946b73de0cc1eec598fcf482b1786ddf13f
parent: 8ff579bc9fd33692aa8139f06eb1060dc0a43f84
author: huade <huashi@cisco.com>
date: Mon Dec 19 12:23:53 EST 2016
Multi-thread-fixed:RBC#1681#1682:remove slice related function to svc_encode_slice.cpp
--- a/codec/encoder/core/inc/svc_encode_slice.h
+++ b/codec/encoder/core/inc/svc_encode_slice.h
@@ -80,7 +80,7 @@
int32_t WelsISliceMdEnc (sWelsEncCtx* pEncCtx, SSlice* pSlice); // for intra non-dynamic slice
int32_t WelsISliceMdEncDynamic (sWelsEncCtx* pEncCtx, SSlice* pSlice); // for intra dynamic slice
-//slice buffer init, allocate and free process
+//slice buffer init, allocate/re-allocate and free process
int32_t AllocMbCacheAligned (SMbCache* pMbCache, CMemoryAlign* pMa);
void FreeMbCache (SMbCache* pMbCache, CMemoryAlign* pMa);
@@ -87,8 +87,7 @@
int32_t InitSliceMBInfo (SSliceArgument* pSliceArgument,
SSlice* pSlice,
const int32_t kiMBWidth,
- const int32_t kiMBHeight,
- CMemoryAlign* pMa);
+ const int32_t kiMBHeight);
int32_t AllocateSliceMBBuffer (SSlice* pSlice, CMemoryAlign* pMa);
@@ -98,10 +97,41 @@
const int32_t iMaxSliceBufferSize,
CMemoryAlign* pMa);
-void FreeSliceBuffer(SSlice*& pSliceList,
- const int32_t kiMaxSliceNum,
- CMemoryAlign* pMa,
- const char* kpTag);
+void FreeSliceBuffer (SSlice*& pSliceList,
+ const int32_t kiMaxSliceNum,
+ CMemoryAlign* pMa,
+ const char* kpTag);
+
+int32_t InitSliceList (sWelsEncCtx* pCtx,
+ SDqLayer* pDqLayer,
+ SSlice*& pSliceList,
+ const int32_t kiMaxSliceNum,
+ const int32_t kiDlayerIndex,
+ CMemoryAlign* pMa);
+
+int32_t InitOneSliceInThread (sWelsEncCtx* pCtx,
+ SSlice*& pSlice,
+ const int32_t kiThreadIdx,
+ const int32_t kiDlayerIdx,
+ const int32_t kiSliceIdx);
+
+int32_t InitSliceInLayer (sWelsEncCtx* pCtx,
+ SDqLayer* pDqLayer,
+ const int32_t kiDlayerIndex,
+ CMemoryAlign* pMa);
+
+int32_t ReallocateSliceList (sWelsEncCtx* pCtx,
+ SSliceArgument* pSliceArgument,
+ SSlice*& pSliceList,
+ const int32_t kiMaxSliceNumOld,
+ const int32_t kiMaxSliceNumNew);
+
+int32_t ReallocateSliceInThread (sWelsEncCtx* pCtx,
+ SDqLayer* pDqLayer,
+ const int32_t kiDlayerIdx,
+ const int32_t kiThreadIndex);
+
+int32_t ReallocSliceBuffer (sWelsEncCtx* pCtx);
//slice encoding process
int32_t WelsCodePSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice);
--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -921,6 +921,7 @@
return 0;
}
+
void FreeSliceInLayer (SDqLayer* pDq, CMemoryAlign* pMa) {
int32_t iIdx = 0;
@@ -989,149 +990,6 @@
}
-
-static inline int32_t InitSliceList (sWelsEncCtx** ppCtx,
- SDqLayer* pDqLayer,
- SSlice* pSliceList,
- const int32_t kiMaxSliceNum,
- const int32_t kiDlayerIndex,
- CMemoryAlign* pMa) {
- const int32_t kiMBWidth = pDqLayer->iMbWidth;
- const int32_t kiMBHeight = pDqLayer->iMbHeight;
- SSliceArgument* pSliceArgument = & (*ppCtx)->pSvcParam->sSpatialLayers[kiDlayerIndex].sSliceArgument;
- int32_t iMaxSliceBufferSize = (*ppCtx)->iSliceBufferSize[kiDlayerIndex];
- int32_t iSliceIdx = 0;
- int32_t iRet = 0;
-
- //SM_SINGLE_SLICE mode using single-thread bs writer pOut->sBsWrite
- //even though multi-thread is on for other layers
- bool bIndependenceBsBuffer = ((*ppCtx)->pSvcParam->iMultipleThreadIdc > 1 &&
- SM_SINGLE_SLICE != pSliceArgument->uiSliceMode) ? true : false;
-
- if (iMaxSliceBufferSize <= 0 || kiMBWidth <= 0 || kiMBHeight <= 0) {
- return ENC_RETURN_UNEXPECTED;
- }
-
- while (iSliceIdx < kiMaxSliceNum) {
- SSlice* pSlice = pSliceList + iSliceIdx;
- if (NULL == pSlice)
- return ENC_RETURN_MEMALLOCERR;
-
- pSlice->uiSliceIdx = iSliceIdx;
-
- iRet = InitSliceBsBuffer (pSlice,
- & (*ppCtx)->pOut->sBsWrite,
- bIndependenceBsBuffer,
- iMaxSliceBufferSize,
- pMa);
- if (ENC_RETURN_SUCCESS != iRet)
- return iRet;
-
- iRet = InitSliceMBInfo (pSliceArgument, pSlice,
- kiMBWidth, kiMBHeight,
- pMa);
-
- if (ENC_RETURN_SUCCESS != iRet)
- return iRet;
-
- iRet = AllocateSliceMBBuffer (pSlice, pMa);
-
- if (ENC_RETURN_SUCCESS != iRet)
- return iRet;
-
- ++ iSliceIdx;
- }
- return ENC_RETURN_SUCCESS;
-}
-
-static inline int32_t InitSliceThreadInfo (sWelsEncCtx** ppCtx,
- SDqLayer* pDqLayer,
- const int32_t kiDlayerIndex,
- CMemoryAlign* pMa) {
-
- SSliceThreadInfo* pSliceThreadInfo = &pDqLayer->sSliceThreadInfo;
- int32_t iThreadNum = (*ppCtx)->pSvcParam->iMultipleThreadIdc;
- int32_t iMaxSliceNumInThread = 0;
- int32_t iIdx = 0;
- int32_t iRet = 0;
-
- assert (iThreadNum > 0);
- iMaxSliceNumInThread = ((*ppCtx)->iMaxSliceCount / iThreadNum + 1) * 2;
- iMaxSliceNumInThread = WELS_MIN ((*ppCtx)->iMaxSliceCount, (int) iMaxSliceNumInThread);
-
- while (iIdx < iThreadNum) {
- pSliceThreadInfo->iMaxSliceNumInThread[iIdx] = iMaxSliceNumInThread;
- pSliceThreadInfo->iEncodedSliceNumInThread[iIdx] = 0;
- pSliceThreadInfo->pSliceInThread[iIdx] = (SSlice*)pMa->WelsMallocz (sizeof (SSlice) *
- iMaxSliceNumInThread, "pSliceInThread");
- if(NULL == pSliceThreadInfo->pSliceInThread[iIdx]) {
- return ENC_RETURN_MEMALLOCERR;
- }
- iRet = InitSliceList (ppCtx,
- pDqLayer,
- pSliceThreadInfo->pSliceInThread[iIdx],
- iMaxSliceNumInThread,
- kiDlayerIndex,
- pMa);
- if (ENC_RETURN_SUCCESS != iRet) {
- return iRet;
- }
-
- iIdx++;
- }
-
- for (; iIdx < MAX_THREADS_NUM; iIdx++) {
- pSliceThreadInfo->iMaxSliceNumInThread[iIdx] = iMaxSliceNumInThread;
- pSliceThreadInfo->iEncodedSliceNumInThread[iIdx] = 0;
- pSliceThreadInfo->pSliceInThread[iIdx] = NULL;
- }
- return ENC_RETURN_SUCCESS;
-}
-
-static inline int32_t InitSliceInLayer (sWelsEncCtx** ppCtx,
- SDqLayer* pDqLayer,
- const int32_t kiDlayerIndex,
- CMemoryAlign* pMa) {
-
- //SWelsSvcCodingParam* pParam = (*ppCtx)->pSvcParam;
- int32_t iRet = 0;
- int32_t iSliceIdx = 0;
- int32_t iMaxSliceNum = pDqLayer->iMaxSliceNum;
-
-
- pDqLayer->ppSliceInLayer = (SSlice**)pMa->WelsMallocz (sizeof (SSlice*) * iMaxSliceNum, "ppSliceInLayer");
- if(NULL == pDqLayer->ppSliceInLayer) {
- return ENC_RETURN_MEMALLOCERR;
- }
-
- InitSliceThreadInfo (ppCtx,
- pDqLayer,
- kiDlayerIndex,
- pMa);
- if (ENC_RETURN_SUCCESS != iRet) {
- return iRet;
- }
- pDqLayer->sLayerInfo.pSliceInLayer = (SSlice*)pMa->WelsMallocz (sizeof (SSlice) * iMaxSliceNum, "pSliceInLayer");
- if(NULL == pDqLayer->sLayerInfo.pSliceInLayer) {
- return ENC_RETURN_MEMALLOCERR;
- }
- InitSliceList (ppCtx,
- pDqLayer,
- pDqLayer->sLayerInfo.pSliceInLayer,
- iMaxSliceNum,
- kiDlayerIndex,
- pMa);
- if (ENC_RETURN_SUCCESS != iRet) {
- return iRet;
- }
-
- for (iSliceIdx = 0; iSliceIdx < iMaxSliceNum; iSliceIdx++) {
- pDqLayer->ppSliceInLayer[iSliceIdx] = &pDqLayer->sLayerInfo.pSliceInLayer[iSliceIdx];
- }
-
- return ENC_RETURN_SUCCESS;
-}
-
/*!
* \brief initialize ppDqLayerList and slicepEncCtx_list due to count number of layers available
* \pParam pCtx sWelsEncCtx*
@@ -1236,7 +1094,7 @@
iMaxSliceNum = kiSliceNum;
pDqLayer->iMaxSliceNum = iMaxSliceNum;
- iResult = InitSliceInLayer (ppCtx, pDqLayer, iDlayerIndex, pMa);
+ iResult = InitSliceInLayer (*ppCtx, pDqLayer, iDlayerIndex, pMa);
if (iResult) {
WelsLog (& (*ppCtx)->sLogCtx, WELS_LOG_WARNING, "InitDqLayers(), InitSliceInLayer failed(%d)!", iResult);
FreeDqLayer (pDqLayer, pMa);
@@ -3880,6 +3738,8 @@
return pCtx->iEncoderError;
}
+ //TO DO: add update ppSliceInLayer module based on pSliceInThread[ThreadNum]
+ // UpdateSliceInLayerInfo(); // reordering
iLayerSize = AppendSliceToFrameBs (pCtx, pLayerBsInfo, iSliceCount);
}
// THREAD_FULLY_FIRE_MODE && SM_SIZELIMITED_SLICE
@@ -3922,6 +3782,9 @@
return pCtx->iEncoderError;
}
+ //TO DO: add update ppSliceInLayer module based on pSliceInThread[ThreadNum]
+ // UpdateSliceInLayerInfo(); // reordering
+
iLayerSize = AppendSliceToFrameBs (pCtx, pLayerBsInfo, kiPartitionCnt);
} else { // for non-dynamic-slicing mode single threading branch..
const bool bNeedPrefix = pCtx->bNeedPrefixNalFlag;
@@ -4567,7 +4430,7 @@
SWelsNalRaw* pNalList = (SWelsNalRaw*)pMA->WelsMallocz (iCountNals * sizeof (SWelsNalRaw), "pOut->sNalList");
if (NULL == pNalList) {
- WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::DynSliceRealloc: pNalList is NULL");
+ WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::FrameBsRealloc: pNalList is NULL");
return ENC_RETURN_MEMALLOCERR;
}
memcpy (pNalList, pCtx->pOut->sNalList, sizeof (SWelsNalRaw) * pCtx->pOut->iCountNals);
@@ -4576,7 +4439,7 @@
int32_t* pNalLen = (int32_t*)pMA->WelsMallocz (iCountNals * sizeof (int32_t), "pOut->pNalLen");
if (NULL == pNalLen) {
- WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::DynSliceRealloc: pNalLen is NULL");
+ WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::FrameBsRealloc: pNalLen is NULL");
return ENC_RETURN_MEMALLOCERR;
}
memcpy (pNalLen, pCtx->pOut->pNalLen, sizeof (int32_t) * pCtx->pOut->iCountNals);
@@ -4597,87 +4460,6 @@
}
-int32_t SliceBufferRealloc (sWelsEncCtx* pCtx) {
- CMemoryAlign* pMA = pCtx->pMemAlign;
- SDqLayer* pCurLayer = pCtx->pCurDqLayer;
- int32_t iMaxSliceNumOld = pCurLayer->sSliceEncCtx.iMaxSliceNumConstraint;
- int32_t iMaxSliceNum = iMaxSliceNumOld;
- iMaxSliceNum *= SLICE_NUM_EXPAND_COEF;
-
- SSlice* pSlice = (SSlice*)pMA->WelsMallocz (sizeof (SSlice) * iMaxSliceNum, "Slice");
- if (NULL == pSlice) {
- WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::DynSliceRealloc: pSlice is NULL");
- return ENC_RETURN_MEMALLOCERR;
- }
- memcpy (pSlice, pCurLayer->sLayerInfo.pSliceInLayer, sizeof (SSlice) * iMaxSliceNumOld);
- int32_t uiSliceIdx;
- uiSliceIdx = iMaxSliceNumOld;
- SSlice* pBaseSlice = &pCurLayer->sLayerInfo.pSliceInLayer[0];
- SSliceHeaderExt* pBaseSHExt = &pBaseSlice->sSliceHeaderExt;
- SSlice* pSliceIdx = &pSlice[uiSliceIdx];
- const int32_t kiCurDid = pCtx->uiDependencyId;
- const int32_t kiBitsPerMb = WELS_DIV_ROUND (pCtx->pWelsSvcRc[kiCurDid].iTargetBits * INT_MULTIPLY,
- pCtx->pWelsSvcRc[kiCurDid].iNumberMbFrame);
- while (uiSliceIdx < iMaxSliceNum) {
- SSliceHeaderExt* pSHExt = &pSliceIdx->sSliceHeaderExt;
- pSliceIdx->uiSliceIdx = uiSliceIdx;
- if (pCtx->pSvcParam->iMultipleThreadIdc > 1)
- pSliceIdx->pSliceBsa = &pSliceIdx->sSliceBs.sBsWrite;
- else
- pSliceIdx->pSliceBsa = &pCtx->pOut->sBsWrite;
- if (AllocMbCacheAligned (&pSliceIdx->sMbCacheInfo, pMA)) {
- WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR,
- "CWelsH264SVCEncoder::DynSliceRealloc: realloc MbCache not successful at slice_idx=%d (max-slice=%d)",
- uiSliceIdx, iMaxSliceNum);
- return ENC_RETURN_MEMALLOCERR;
- }
-
- pSliceIdx->bSliceHeaderExtFlag = pBaseSlice->bSliceHeaderExtFlag;
- pSHExt->sSliceHeader.iPpsId = pBaseSHExt->sSliceHeader.iPpsId;
- pSHExt->sSliceHeader.pPps = pBaseSHExt->sSliceHeader.pPps;
- pSHExt->sSliceHeader.iSpsId = pBaseSHExt->sSliceHeader.iSpsId;
- pSHExt->sSliceHeader.pSps = pBaseSHExt->sSliceHeader.pSps;
- pSHExt->sSliceHeader.uiRefCount = pCtx->iNumRef0;
- memcpy (&pSHExt->sSliceHeader.sRefMarking, &pBaseSHExt->sSliceHeader.sRefMarking, sizeof (SRefPicMarking));
- memcpy (&pSHExt->sSliceHeader.sRefReordering, &pBaseSHExt->sSliceHeader.sRefReordering,
- sizeof (SRefPicListReorderSyntax));
-
- pSliceIdx->sSlicingOverRc.iComplexityIndexSlice = 0;
- pSliceIdx->sSlicingOverRc.iCalculatedQpSlice = pCtx->iGlobalQp;
- pSliceIdx->sSlicingOverRc.iTotalQpSlice = 0;
- pSliceIdx->sSlicingOverRc.iTotalMbSlice = 0;
- pSliceIdx->sSlicingOverRc.iTargetBitsSlice = WELS_DIV_ROUND (kiBitsPerMb *
- pSlice[uiSliceIdx].iCountMbNumInSlice,
- INT_MULTIPLY);
- pSliceIdx->sSlicingOverRc.iFrameBitsSlice = 0;
- pSliceIdx->sSlicingOverRc.iGomBitsSlice = 0;
-
- pSliceIdx++;
- uiSliceIdx++;
- }
- pMA->WelsFree (pCurLayer->sLayerInfo.pSliceInLayer, "Slice");
- pCurLayer->sLayerInfo.pSliceInLayer = pSlice;
-
- // update for ppsliceInlayer
- SSlice** ppSlice = (SSlice**)pMA->WelsMallocz (sizeof (SSlice*) * iMaxSliceNum, "ppSlice");
- if (NULL == ppSlice) {
- WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::DynSliceRealloc: ppSlice is NULL");
- return ENC_RETURN_MEMALLOCERR;
- }
- pMA->WelsFree (pCurLayer->ppSliceInLayer, "ppSliceInLayer");
- pCurLayer->ppSliceInLayer = ppSlice;
-
- for(uiSliceIdx = 0; uiSliceIdx < iMaxSliceNum; uiSliceIdx++){
- pCurLayer->ppSliceInLayer[uiSliceIdx] = &pCurLayer->sLayerInfo.pSliceInLayer[uiSliceIdx];
- }
-
- if (pCtx->iMaxSliceCount < iMaxSliceNum)
- pCtx->iMaxSliceCount = iMaxSliceNum;
- pCurLayer->sSliceEncCtx.iMaxSliceNumConstraint = iMaxSliceNum;
- pCurLayer->iMaxSliceNum = iMaxSliceNum;
- return ENC_RETURN_SUCCESS;
-}
-
int32_t DynSliceRealloc (sWelsEncCtx* pCtx,
SFrameBSInfo* pFrameBsInfo,
SLayerBSInfo* pLayerBsInfo) {
@@ -4684,10 +4466,15 @@
int32_t iRet = 0;
iRet = FrameBsRealloc (pCtx, pFrameBsInfo, pLayerBsInfo);
- if (ENC_RETURN_SUCCESS != iRet)
+
+ if(ENC_RETURN_SUCCESS != iRet) {
return iRet;
+ }
- iRet = SliceBufferRealloc (pCtx);
+ iRet = ReallocSliceBuffer (pCtx);
+ if (ENC_RETURN_SUCCESS != iRet) {
+ return iRet;
+ }
return iRet;
}
--- a/codec/encoder/core/src/ref_list_mgr_svc.cpp
+++ b/codec/encoder/core/src/ref_list_mgr_svc.cpp
@@ -700,7 +700,8 @@
void WelsUpdateRefSyntax (sWelsEncCtx* pCtx, const int32_t iPOC, const int32_t uiFrameType) {
int32_t iAbsDiffPicNumMinus1 = -1;
- SSlice** pSliceList = NULL;
+
+ SSlice** ppSliceList = NULL;
SSpatialLayerInternal* pParamD = &pCtx->pSvcParam->sDependencyLayers[pCtx->uiDependencyId];
/*syntax for ref_pic_list_reordering()*/
if (pCtx->iNumRef0 > 0) {
@@ -714,9 +715,8 @@
}
}
- pSliceList = pCtx->pCurDqLayer->ppSliceInLayer;
- WelsUpdateSliceHeaderSyntax (pCtx, iAbsDiffPicNumMinus1, pSliceList, uiFrameType);
-
+ ppSliceList = pCtx->pCurDqLayer->ppSliceInLayer;
+ WelsUpdateSliceHeaderSyntax (pCtx, iAbsDiffPicNumMinus1, ppSliceList, uiFrameType);
}
static inline void UpdateOriginalPicInfo (SPicture* pOrigPic, SPicture* pReconPic) {
--- a/codec/encoder/core/src/slice_multi_threading.cpp
+++ b/codec/encoder/core/src/slice_multi_threading.cpp
@@ -132,6 +132,7 @@
if ( NULL == ppSliceInLayer[iSliceIdx] ) {
return false;
}
+
uiTotalConsume += ppSliceInLayer[iSliceIdx]->uiSliceConsumeTime;
iSliceIdx ++;
}
--- a/codec/encoder/core/src/svc_enc_slice_segment.cpp
+++ b/codec/encoder/core/src/svc_enc_slice_segment.cpp
@@ -492,6 +492,7 @@
return 0;
}
+
/*!
* \brief Uninitialize Wels SSlice context (Single/multiple slices and FMO)
*
--- a/codec/encoder/core/src/svc_encode_slice.cpp
+++ b/codec/encoder/core/src/svc_encode_slice.cpp
@@ -818,8 +818,7 @@
int32_t InitSliceMBInfo (SSliceArgument* pSliceArgument,
SSlice* pSlice,
const int32_t kiMBWidth,
- const int32_t kiMBHeight,
- CMemoryAlign* pMa) {
+ const int32_t kiMBHeight) {
SSliceHeader* pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader;
const int32_t* kpSlicesAssignList = (int32_t*) & (pSliceArgument->uiSliceMbNum[0]);
const int32_t kiCountNumMbInFrame = kiMBWidth * kiMBHeight;
@@ -841,8 +840,9 @@
iMbIdx += kpSlicesAssignList[i];
}
- if (iMbIdx >= kiCountNumMbInFrame)
+ if (iMbIdx >= kiCountNumMbInFrame) {
return ENC_RETURN_UNEXPECTED;
+ }
iFirstMBInSlice = iMbIdx;
iMbNumInSlice = kpSlicesAssignList[kiSliceIdx];
@@ -912,15 +912,426 @@
}
}
+int32_t InitSliceList (sWelsEncCtx* pCtx,
+ SDqLayer* pDqLayer,
+ SSlice*& pSliceList,
+ const int32_t kiMaxSliceNum,
+ const int32_t kiDlayerIndex,
+ CMemoryAlign* pMa) {
+ const int32_t kiMBWidth = pDqLayer->iMbWidth;
+ const int32_t kiMBHeight = pDqLayer->iMbHeight;
+ SSliceArgument* pSliceArgument = & pCtx->pSvcParam->sSpatialLayers[kiDlayerIndex].sSliceArgument;
+ int32_t iMaxSliceBufferSize = (pCtx)->iSliceBufferSize[kiDlayerIndex];
+ int32_t iSliceIdx = 0;
+ int32_t iRet = 0;
+
+ //SM_SINGLE_SLICE mode using single-thread bs writer pOut->sBsWrite
+ //even though multi-thread is on for other layers
+ bool bIndependenceBsBuffer = (pCtx->pSvcParam->iMultipleThreadIdc > 1 &&
+ SM_SINGLE_SLICE != pSliceArgument->uiSliceMode) ? true : false;
+
+ if (iMaxSliceBufferSize <= 0 || kiMBWidth <= 0 || kiMBHeight <= 0) {
+ return ENC_RETURN_UNEXPECTED;
+ }
+
+ while (iSliceIdx < kiMaxSliceNum) {
+ SSlice* pSlice = pSliceList + iSliceIdx;
+ if (NULL == pSlice) {
+ return ENC_RETURN_MEMALLOCERR;
+ }
+
+ pSlice->uiSliceIdx = iSliceIdx;
+
+ iRet = InitSliceBsBuffer (pSlice,
+ & pCtx->pOut->sBsWrite,
+ bIndependenceBsBuffer,
+ iMaxSliceBufferSize,
+ pMa);
+ if (ENC_RETURN_SUCCESS != iRet) {
+ return iRet;
+ }
+
+ iRet = InitSliceMBInfo (pSliceArgument, pSlice,
+ kiMBWidth, kiMBHeight);
+
+ if (ENC_RETURN_SUCCESS != iRet) {
+ return iRet;
+ }
+ iRet = AllocateSliceMBBuffer (pSlice, pMa);
+
+ if (ENC_RETURN_SUCCESS != iRet) {
+ return iRet;
+ }
+ ++ iSliceIdx;
+ }
+ 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];
+
+ // init slice MB info
+ iRet = InitSliceMBInfo (pSliceArgument, pSlice, kiMBWidth, kiMBHeight);
+ if (ENC_RETURN_SUCCESS != iRet) {
+ return iRet;
+ }
+ return ENC_RETURN_SUCCESS;
+}
+*/
+
+int32_t InitSliceThreadInfo (sWelsEncCtx* pCtx,
+ SDqLayer* pDqLayer,
+ const int32_t kiDlayerIndex,
+ CMemoryAlign* pMa) {
+
+ SSliceThreadInfo* pSliceThreadInfo = &pDqLayer->sSliceThreadInfo;
+ int32_t iThreadNum = pCtx->pSvcParam->iMultipleThreadIdc;
+ int32_t iMaxSliceNumInThread = 0;
+ int32_t iIdx = 0;
+ int32_t iRet = 0;
+
+ assert (iThreadNum > 0);
+ iMaxSliceNumInThread = (pCtx->iMaxSliceCount / iThreadNum + 1) * 2;
+ iMaxSliceNumInThread = WELS_MIN (pCtx->iMaxSliceCount, (int) iMaxSliceNumInThread);
+
+ while (iIdx < iThreadNum) {
+ pSliceThreadInfo->iMaxSliceNumInThread[iIdx] = iMaxSliceNumInThread;
+ pSliceThreadInfo->iEncodedSliceNumInThread[iIdx] = 0;
+ pSliceThreadInfo->pSliceInThread[iIdx] = (SSlice*)pMa->WelsMallocz (sizeof (SSlice) *
+ iMaxSliceNumInThread, "pSliceInThread");
+ if (NULL == pSliceThreadInfo->pSliceInThread[iIdx]) {
+ WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR,
+ "CWelsH264SVCEncoder::InitSliceThreadInfo: pSliceThreadInfo->pSliceInThread[iIdx] is NULL");
+ return ENC_RETURN_MEMALLOCERR;
+ }
+ iRet = InitSliceList (pCtx,
+ pDqLayer,
+ pSliceThreadInfo->pSliceInThread[iIdx],
+ iMaxSliceNumInThread,
+ kiDlayerIndex,
+ pMa);
+ if (ENC_RETURN_SUCCESS != iRet) {
+ return iRet;
+ }
+ iIdx++;
+ }
+
+ for (; iIdx < MAX_THREADS_NUM; iIdx++) {
+ pSliceThreadInfo->iMaxSliceNumInThread[iIdx] = iMaxSliceNumInThread;
+ pSliceThreadInfo->iEncodedSliceNumInThread[iIdx] = 0;
+ pSliceThreadInfo->pSliceInThread[iIdx] = NULL;
+ }
+ return ENC_RETURN_SUCCESS;
+}
+
+int32_t InitSliceInLayer (sWelsEncCtx* pCtx,
+ SDqLayer* pDqLayer,
+ const int32_t kiDlayerIndex,
+ CMemoryAlign* pMa) {
+ int32_t iRet = 0;
+ int32_t iSliceIdx = 0;
+ int32_t iMaxSliceNum = pDqLayer->iMaxSliceNum;
+
+ pDqLayer->ppSliceInLayer = (SSlice**)pMa->WelsMallocz (sizeof (SSlice*) * iMaxSliceNum, "ppSliceInLayer");
+ if (NULL == pDqLayer->ppSliceInLayer) {
+ WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::InitSliceInLayer() pDqLayer->ppSliceInLayer is NULL");
+ return ENC_RETURN_MEMALLOCERR;
+ }
+
+ InitSliceThreadInfo (pCtx,
+ pDqLayer,
+ kiDlayerIndex,
+ pMa);
+ if (ENC_RETURN_SUCCESS != iRet) {
+ return iRet;
+ }
+
+ pDqLayer->sLayerInfo.pSliceInLayer = (SSlice*)pMa->WelsMallocz (sizeof (SSlice) * iMaxSliceNum, "pSliceInLayer");
+ if (NULL == pDqLayer->sLayerInfo.pSliceInLayer) {
+ WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR,
+ "CWelsH264SVCEncoder::InitSliceInLayer: pDqLayer->sLayerInfo.pSliceInLayeris NULL");
+ return ENC_RETURN_MEMALLOCERR;
+ }
+
+ iRet = InitSliceList (pCtx,
+ pDqLayer,
+ pDqLayer->sLayerInfo.pSliceInLayer,
+ iMaxSliceNum,
+ kiDlayerIndex,
+ pMa);
+ if (ENC_RETURN_SUCCESS != iRet) {
+ return iRet;
+ }
+
+ for (iSliceIdx = 0; iSliceIdx < iMaxSliceNum; iSliceIdx++) {
+ pDqLayer->ppSliceInLayer[iSliceIdx] = &pDqLayer->sLayerInfo.pSliceInLayer[iSliceIdx];
+ }
+
+ return ENC_RETURN_SUCCESS;
+}
+
+static inline int32_t InitSliceHeadWithBase (SSlice* pSlice, SSlice* pBaseSlice, const uint8_t kuiRefCount) {
+ SSliceHeaderExt* pBaseSHExt = &pBaseSlice->sSliceHeaderExt;
+ SSliceHeaderExt* pSHExt = &pSlice->sSliceHeaderExt;
+
+ if (NULL == pSlice || NULL == pBaseSlice)
+ return ENC_RETURN_INVALIDINPUT;
+
+ pSlice->bSliceHeaderExtFlag = pBaseSlice->bSliceHeaderExtFlag;
+ pSHExt->sSliceHeader.iPpsId = pBaseSHExt->sSliceHeader.iPpsId;
+ pSHExt->sSliceHeader.pPps = pBaseSHExt->sSliceHeader.pPps;
+ pSHExt->sSliceHeader.iSpsId = pBaseSHExt->sSliceHeader.iSpsId;
+ pSHExt->sSliceHeader.pSps = pBaseSHExt->sSliceHeader.pSps;
+ pSHExt->sSliceHeader.uiRefCount = kuiRefCount;
+ memcpy (&pSHExt->sSliceHeader.sRefMarking, &pBaseSHExt->sSliceHeader.sRefMarking, sizeof (SRefPicMarking));
+ memcpy (&pSHExt->sSliceHeader.sRefReordering, &pBaseSHExt->sSliceHeader.sRefReordering,
+ sizeof (SRefPicListReorderSyntax));
+ return ENC_RETURN_SUCCESS;
+
+}
+static inline int32_t InitSliceRC (SSlice* pSlice, const int32_t kiGlobalQp, const int32_t kiBitsPerMb) {
+
+ if (NULL == pSlice || kiGlobalQp < 0 || kiBitsPerMb < 0)
+ return ENC_RETURN_INVALIDINPUT;
+
+ pSlice->sSlicingOverRc.iComplexityIndexSlice = 0;
+ pSlice->sSlicingOverRc.iCalculatedQpSlice = kiGlobalQp;
+ pSlice->sSlicingOverRc.iTotalQpSlice = 0;
+ pSlice->sSlicingOverRc.iTotalMbSlice = 0;
+ pSlice->sSlicingOverRc.iTargetBitsSlice = WELS_DIV_ROUND (kiBitsPerMb *
+ pSlice->iCountMbNumInSlice,
+ INT_MULTIPLY);
+ pSlice->sSlicingOverRc.iFrameBitsSlice = 0;
+ pSlice->sSlicingOverRc.iGomBitsSlice = 0;
+
+ return ENC_RETURN_SUCCESS;
+}
+
+int32_t ReallocateSliceList (sWelsEncCtx* pCtx,
+ SSliceArgument* pSliceArgument,
+ SSlice*& pSliceList,
+ const int32_t kiMaxSliceNumOld,
+ const int32_t kiMaxSliceNumNew) {
+ CMemoryAlign* pMA = pCtx->pMemAlign;
+ SDqLayer* pCurLayer = pCtx->pCurDqLayer;
+ SSlice* pBaseSlice = NULL;
+ SSlice* pNewSliceList = NULL;
+ SSlice* pSlice = NULL;
+ int32_t iSliceIdx = 0;
+ int32_t iRet = 0;
+ const int32_t kiCurDid = pCtx->uiDependencyId;
+ int32_t iMaxSliceBufferSize = (pCtx)->iSliceBufferSize[kiCurDid];
+ int32_t iBitsPerMb = WELS_DIV_ROUND (pCtx->pWelsSvcRc[kiCurDid].iTargetBits * INT_MULTIPLY,
+ pCtx->pWelsSvcRc[kiCurDid].iNumberMbFrame);
+ bool bIndependenceBsBuffer = (pCtx->pSvcParam->iMultipleThreadIdc > 1 &&
+ SM_SINGLE_SLICE != pSliceArgument->uiSliceMode) ? true : false;
+
+ if (NULL == pSliceList || NULL == pSliceArgument) {
+ return ENC_RETURN_INVALIDINPUT;
+ }
+
+ pNewSliceList = (SSlice*)pMA->WelsMallocz (sizeof (SSlice) * kiMaxSliceNumNew, "Slice");
+ if (NULL == pNewSliceList) {
+ WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::ReallocateSliceList: pNewSliceList is NULL");
+ return ENC_RETURN_MEMALLOCERR;
+ }
+
+ memcpy (pNewSliceList, pSliceList, sizeof (SSlice) * kiMaxSliceNumOld);
+ iSliceIdx = kiMaxSliceNumOld;
+ pBaseSlice = &pSliceList[0];
+
+ for (; iSliceIdx < kiMaxSliceNumNew; iSliceIdx++) {
+ pSlice = pNewSliceList + iSliceIdx;
+ if (NULL == pSlice) {
+ FreeSliceBuffer(pNewSliceList, kiMaxSliceNumNew, pMA, "ReallocateSliceList()::InitSliceBsBuffer()");
+ return ENC_RETURN_MEMALLOCERR;
+ }
+
+ pSlice->uiSliceIdx = iSliceIdx;
+
+ iRet = InitSliceBsBuffer (pSlice,
+ & pCtx->pOut->sBsWrite,
+ bIndependenceBsBuffer,
+ iMaxSliceBufferSize,
+ pMA);
+ if (ENC_RETURN_SUCCESS != iRet) {
+ FreeSliceBuffer(pNewSliceList, kiMaxSliceNumNew, pMA, "ReallocateSliceList()::InitSliceBsBuffer()");
+ return iRet;
+ }
+
+ iRet = AllocateSliceMBBuffer (pSlice, pMA);
+ if (ENC_RETURN_SUCCESS != iRet) {
+ FreeSliceBuffer(pNewSliceList, kiMaxSliceNumNew, pMA, "ReallocateSliceList()::InitSliceBsBuffer()");
+ return iRet;
+ }
+
+ iRet = InitSliceMBInfo (pSliceArgument,
+ pSlice,
+ pCurLayer->iMbWidth,
+ pCurLayer->iMbHeight);
+ if (ENC_RETURN_SUCCESS != iRet) {
+ FreeSliceBuffer(pNewSliceList, kiMaxSliceNumNew, pMA, "ReallocateSliceList()::InitSliceBsBuffer()");
+ return iRet;
+ }
+
+ iRet = InitSliceHeadWithBase (pSlice, pBaseSlice, pCtx->iNumRef0);
+ if (ENC_RETURN_SUCCESS != iRet) {
+ FreeSliceBuffer(pNewSliceList, kiMaxSliceNumNew, pMA, "ReallocateSliceList()::InitSliceBsBuffer()");
+ return iRet;
+ }
+
+ iRet = InitSliceRC (pSlice, pCtx->iGlobalQp, iBitsPerMb);
+ if (ENC_RETURN_SUCCESS != iRet) {
+ FreeSliceBuffer(pNewSliceList, kiMaxSliceNumNew, pMA, "ReallocateSliceList()::InitSliceBsBuffer()");
+ return iRet;
+ }
+ }
+
+ pMA->WelsFree (pSliceList, "Slice");
+ pSliceList = pNewSliceList;
+
+ return ENC_RETURN_SUCCESS;
+
+}
+
+int32_t CalculateNewSliceNum (SDqLayer* pDqLayer,
+ SSlice* pLastCodedSlice,
+ const int32_t iMaxSliceNumOld,
+ int32_t& iMaxSliceNumNew) {
+ int32_t CodedMBNum = 0;
+
+ if (NULL == pLastCodedSlice)
+ return ENC_RETURN_INVALIDINPUT;
+
+ CodedMBNum = pLastCodedSlice->sSliceHeaderExt.sSliceHeader.iFirstMbInSlice +
+ pLastCodedSlice->iCountMbNumInSlice;
+ if (CodedMBNum <= 0) {
+ return ENC_RETURN_UNEXPECTED;
+ }
+ //iMaxSliceNumNew = iMaxSliceNumOld * (pDqLayer->iMbWidth * pDqLayer->iMbHeight / CodedMBNum + 1);
+ //TO DO, will used above logic later, here keep origin logic in order to pass ut
+ iMaxSliceNumNew = iMaxSliceNumOld;
+ iMaxSliceNumNew *= SLICE_NUM_EXPAND_COEF;
+ 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;
+ SDqLayer* pCurLayer = pCtx->pCurDqLayer;
+ SSlice** ppSlice = NULL;
+ int32_t iMaxSliceNumOld = pCurLayer->sSliceEncCtx.iMaxSliceNumConstraint;
+ int32_t iMaxSliceNumNew = 0;
+ int32_t iRet = 0;
+ int32_t iSliceIdx = 0;
+ const int32_t kiCurDid = pCtx->uiDependencyId;
+
+ SSlice* pLastCodedSlice = pCurLayer->sLayerInfo.pSliceInLayer + (iMaxSliceNumOld - 1);
+ SSliceArgument* pSliceArgument = & pCtx->pSvcParam->sSpatialLayers[kiCurDid].sSliceArgument;
+ iRet = CalculateNewSliceNum (pCurLayer,
+ pLastCodedSlice,
+ iMaxSliceNumOld,
+ iMaxSliceNumNew);
+
+ if (ENC_RETURN_SUCCESS != iRet) {
+ return iRet;
+ }
+
+ iRet = ReallocateSliceList (pCtx,
+ pSliceArgument,
+ pCurLayer->sLayerInfo.pSliceInLayer,
+ iMaxSliceNumOld,
+ iMaxSliceNumNew);
+ if (ENC_RETURN_SUCCESS != iRet) {
+ return iRet;
+ }
+
+ // update for ppsliceInlayer
+ ppSlice = (SSlice**)pMA->WelsMallocz (sizeof (SSlice*) * iMaxSliceNumNew, "ppSlice");
+ if (NULL == ppSlice) {
+ WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::ReallocSliceBuffer: ppSlice is NULL");
+ return ENC_RETURN_MEMALLOCERR;
+ }
+ pMA->WelsFree (pCurLayer->ppSliceInLayer, "ppSliceInLayer");
+ pCurLayer->ppSliceInLayer = ppSlice;
+
+ for (iSliceIdx = 0; iSliceIdx < iMaxSliceNumNew; iSliceIdx++) {
+ pCurLayer->ppSliceInLayer[iSliceIdx] = &pCurLayer->sLayerInfo.pSliceInLayer[iSliceIdx];
+ }
+
+ if (pCtx->iMaxSliceCount < iMaxSliceNumNew) {
+ pCtx->iMaxSliceCount = iMaxSliceNumNew;
+ }
+
+ pCurLayer->sSliceEncCtx.iMaxSliceNumConstraint = iMaxSliceNumNew;
+ pCurLayer->iMaxSliceNum = iMaxSliceNumNew;
+ return ENC_RETURN_SUCCESS;
+}
+
int32_t WelsCodeOneSlice (sWelsEncCtx* pEncCtx, const int32_t kiSliceIdx, const int32_t kiNalType) {
SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
SNalUnitHeaderExt* pNalHeadExt = &pCurLayer->sLayerInfo.sNalHeaderExt;
SSlice* pCurSlice = pCurLayer->ppSliceInLayer[kiSliceIdx];
SBitStringAux* pBs = pCurSlice->pSliceBsa;
- const int32_t kiDynamicSliceFlag =
- (pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId].sSliceArgument.uiSliceMode
- ==
- SM_SIZELIMITED_SLICE);
+ const int32_t kiDynamicSliceFlag = (pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId].sSliceArgument.uiSliceMode
+ == SM_SIZELIMITED_SLICE);
assert (kiSliceIdx == (int) pCurSlice->uiSliceIdx);
--- a/codec/encoder/core/src/wels_task_encoder.cpp
+++ b/codec/encoder/core/src/wels_task_encoder.cpp
@@ -56,7 +56,7 @@
namespace WelsEnc {
CWelsSliceEncodingTask::CWelsSliceEncodingTask (WelsCommon::IWelsTaskSink* pSink, sWelsEncCtx* pCtx,
- const int32_t iSliceIdx) : CWelsBaseTask(pSink), m_eTaskResult (ENC_RETURN_SUCCESS) {
+ const int32_t iSliceIdx) : CWelsBaseTask (pSink), m_eTaskResult (ENC_RETURN_SUCCESS) {
m_pCtx = pCtx;
m_iSliceIdx = iSliceIdx;
}
@@ -111,6 +111,8 @@
"[MT] CWelsSliceEncodingTask InitTask(), Cannot find available thread for m_iSliceIdx = %d", m_iSliceIdx);
return ENC_RETURN_UNEXPECTED;
}
+
+ // InitOneSliceInThread();
SetOneSliceBsBufferUnderMultithread (m_pCtx, m_iThreadIdx, m_iSliceIdx);
m_pSlice = m_pCtx->pCurDqLayer->ppSliceInLayer[m_iSliceIdx];
@@ -147,7 +149,7 @@
#if MT_DEBUG_BS_WR
m_pSliceBs->bSliceCodedFlag = false;
#endif//MT_DEBUG_BS_WR
- SSpatialLayerInternal *pParamInternal = &m_pCtx->pSvcParam->sDependencyLayers[m_pCtx->uiDependencyId];
+ SSpatialLayerInternal* pParamInternal = &m_pCtx->pSvcParam->sDependencyLayers[m_pCtx->uiDependencyId];
if (m_bNeedPrefix) {
if (m_eNalRefIdc != NRI_PRI_LOWEST) {
WelsLoadNalForSlice (m_pSliceBs, NAL_UNIT_PREFIX, m_eNalRefIdc);
@@ -211,10 +213,11 @@
void CWelsLoadBalancingSlicingEncodingTask::FinishTask() {
CWelsSliceEncodingTask::FinishTask();
- SSpatialLayerInternal *pParamInternal = &m_pCtx->pSvcParam->sDependencyLayers[m_pCtx->uiDependencyId];
+ SSpatialLayerInternal* pParamInternal = &m_pCtx->pSvcParam->sDependencyLayers[m_pCtx->uiDependencyId];
m_pSlice->uiSliceConsumeTime = (uint32_t) (WelsTime() - m_iSliceStart);
WelsLog (&m_pCtx->sLogCtx, WELS_LOG_DEBUG,
- "[MT] CWelsLoadBalancingSlicingEncodingTask()FinishTask, coding_idx %d, um_iSliceIdx %d, uiSliceConsumeTime %d, m_iSliceSize %d, iFirstMbInSlice %d, count_num_mb_in_slice %d at time=%" PRId64,
+ "[MT] CWelsLoadBalancingSlicingEncodingTask()FinishTask, coding_idx %d, um_iSliceIdx %d, uiSliceConsumeTime %d, m_iSliceSize %d, iFirstMbInSlice %d, count_num_mb_in_slice %d at time=%"
+ PRId64,
pParamInternal->iCodingIndex,
m_iSliceIdx,
m_pSlice->uiSliceConsumeTime,
@@ -231,12 +234,11 @@
SSliceCtx* pSliceCtx = &pCurDq->sSliceEncCtx;
const int32_t kiSliceIdxStep = m_pCtx->iActiveThreadsNum;
-
- SSpatialLayerInternal *pParamInternal = &m_pCtx->pSvcParam->sDependencyLayers[m_pCtx->uiDependencyId];
+ SSpatialLayerInternal* pParamInternal = &m_pCtx->pSvcParam->sDependencyLayers[m_pCtx->uiDependencyId];
SSliceHeaderExt* pStartSliceHeaderExt = &pCurDq->ppSliceInLayer[m_iSliceIdx]->sSliceHeaderExt;
//deal with partition: TODO: here SSliceThreadPrivateData is just for parition info and actually has little relationship with threadbuffer, and iThreadIndex is not used in threadpool model, need renaming after removing old logic to avoid confusion
- const int32_t kiPartitionId = m_iSliceIdx%kiSliceIdxStep;
+ const int32_t kiPartitionId = m_iSliceIdx % kiSliceIdxStep;
SSliceThreadPrivateData* pPrivateData = & (m_pCtx->pSliceThreading->pThreadPEncCtx[kiPartitionId]);
const int32_t kiFirstMbInPartition = pPrivateData->iStartMbIndex; // inclusive
const int32_t kiEndMbInPartition = pPrivateData->iEndMbIndex; // exclusive
@@ -285,7 +287,7 @@
return iReturn;
}
WelsUnloadNalForSlice (m_pSliceBs);
-
+
iReturn = WriteSliceBs (m_pCtx, m_pSliceBs, iLocalSliceIdx, m_iSliceSize);
if (ENC_RETURN_SUCCESS != iReturn) {
WelsLog (&m_pCtx->sLogCtx, WELS_LOG_WARNING,
@@ -318,7 +320,8 @@
}
-CWelsUpdateMbMapTask::CWelsUpdateMbMapTask (WelsCommon::IWelsTaskSink* pSink, sWelsEncCtx* pCtx, const int32_t iSliceIdx): CWelsBaseTask(pSink) {
+CWelsUpdateMbMapTask::CWelsUpdateMbMapTask (WelsCommon::IWelsTaskSink* pSink, sWelsEncCtx* pCtx,
+ const int32_t iSliceIdx): CWelsBaseTask (pSink) {
m_pCtx = pCtx;
m_iSliceIdx = iSliceIdx;
}