ref: 83305d81478976b97ce9533bff716d661605df89
parent: 067aa85be0e3e05b290abb384aaa1687315d0283
author: huade <[email protected]>
date: Tue Dec 20 05:25:28 EST 2016
Multi-thread-fixed:RBC#1709:pSlice instead of ppSliceInLayer in SetOneSliceBsBufferUnderMultithread
--- a/codec/encoder/core/inc/slice_multi_threading.h
+++ b/codec/encoder/core/inc/slice_multi_threading.h
@@ -97,7 +97,7 @@
void TrackSliceConsumeTime (sWelsEncCtx* pCtx, int32_t* pDidList, const int32_t kiSpatialNum);
#endif//defined(MT_DEBUG)
-void SetOneSliceBsBufferUnderMultithread(sWelsEncCtx* pCtx, const int32_t kiThreadIdx, const int32_t iSliceIdx);
+void SetOneSliceBsBufferUnderMultithread(sWelsEncCtx* pCtx, const int32_t kiThreadIdx, SSlice* pSlice);
int32_t WriteSliceBs (sWelsEncCtx* pCtx,SWelsSliceBs* pSliceBs,const int32_t iSliceIdx,int32_t& iSliceSize);
}
--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -3760,9 +3760,9 @@
while (iIdx < kiPartitionCnt) {
pCtx->pSliceThreading->pThreadPEncCtx[iIdx].pFrameBsInfo = pFbi;
pCtx->pSliceThreading->pThreadPEncCtx[iIdx].iSliceIndex = iIdx;
- SetOneSliceBsBufferUnderMultithread (pCtx, iIdx, iIdx);
++ iIdx;
}
+
pCtx->pTaskManage->ExecuteTasks();
if (pCtx->iEncoderError) {
@@ -3771,6 +3771,9 @@
pParam->sSliceArgument.uiSliceMode, pCtx->iEncoderError);
return pCtx->iEncoderError;
}
+
+ //TO DO: add update ppSliceInLayer module based on pSliceInThread[ThreadNum]
+ // UpdateSliceInLayerInfo(); // reordering
//TO DO: add update ppSliceInLayer module based on pSliceInThread[ThreadNum]
// UpdateSliceInLayerInfo(); // reordering
--- a/codec/encoder/core/src/ref_list_mgr_svc.cpp
+++ b/codec/encoder/core/src/ref_list_mgr_svc.cpp
@@ -707,8 +707,8 @@
* update syntax for reference base related
*/
void WelsUpdateRefSyntax (sWelsEncCtx* pCtx, const int32_t iPOC, const int32_t uiFrameType) {
- int32_t iAbsDiffPicNumMinus1 = -1;
- SSpatialLayerInternal* pParamD = &pCtx->pSvcParam->sDependencyLayers[pCtx->uiDependencyId];
+ int32_t iAbsDiffPicNumMinus1 = -1;
+ SSpatialLayerInternal* pParamD = &pCtx->pSvcParam->sDependencyLayers[pCtx->uiDependencyId];
/*syntax for ref_pic_list_reordering()*/
if (pCtx->iNumRef0 > 0) {
iAbsDiffPicNumMinus1 = pParamD->iFrameNum - (pCtx->pRefList0[0]->iFrameNum) - 1;
--- a/codec/encoder/core/src/slice_multi_threading.cpp
+++ b/codec/encoder/core/src/slice_multi_threading.cpp
@@ -715,12 +715,12 @@
iEventIdx);
}
- SetOneSliceBsBufferUnderMultithread (pEncPEncCtx, kiPartitionId, iSliceIdx);
- pSlice = pCurDq->ppSliceInLayer[iSliceIdx];
+ pSlice = pCurDq->ppSliceInLayer[iSliceIdx];
pSliceBs = &pSlice->sSliceBs;
-
pSliceBs->uiBsPos = 0;
pSliceBs->iNalIndex = 0;
+
+ SetOneSliceBsBufferUnderMultithread (pEncPEncCtx, kiPartitionId, pSlice);
InitBits (&pSliceBs->sBsWrite, pSliceBs->pBsBuffer, pSliceBs->uiSize);
if (bNeedPrefix) {
@@ -876,9 +876,9 @@
while (iIdx < kiEventCnt) {
pPriData[iIdx].pFrameBsInfo = pFrameBsInfo;
pPriData[iIdx].iSliceIndex = iIdx;
- SetOneSliceBsBufferUnderMultithread (pCtx, iIdx, iIdx);
WelsEventSignal (&pEventsList[iIdx]);
WelsEventSignal (&pMasterEventsList[iIdx]);
+
++ iIdx;
}
@@ -1023,8 +1023,8 @@
}
#endif//#if defined(MT_DEBUG)
-void SetOneSliceBsBufferUnderMultithread (sWelsEncCtx* pCtx, const int32_t kiThreadIdx, const int32_t iSliceIdx) {
- SWelsSliceBs* pSliceBs = &pCtx->pCurDqLayer->ppSliceInLayer[iSliceIdx]->sSliceBs;
+void SetOneSliceBsBufferUnderMultithread (sWelsEncCtx* pCtx, const int32_t kiThreadIdx, SSlice* pSlice) {
+ SWelsSliceBs* pSliceBs = &pSlice->sSliceBs;
pSliceBs->pBsBuffer = pCtx->pSliceThreading->pThreadBsBuffer[kiThreadIdx];
pSliceBs->uiBsPos = 0;
}
--- a/codec/encoder/core/src/wels_task_encoder.cpp
+++ b/codec/encoder/core/src/wels_task_encoder.cpp
@@ -113,14 +113,14 @@
}
// InitOneSliceInThread();
- SetOneSliceBsBufferUnderMultithread (m_pCtx, m_iThreadIdx, m_iSliceIdx);
-
- m_pSlice = m_pCtx->pCurDqLayer->ppSliceInLayer[m_iSliceIdx];
+ m_pSlice = m_pCtx->pCurDqLayer->ppSliceInLayer[m_iSliceIdx];
m_pSliceBs = &m_pSlice->sSliceBs;
m_pSliceBs->uiBsPos = 0;
m_pSliceBs->iNalIndex = 0;
+ SetOneSliceBsBufferUnderMultithread (m_pCtx, m_iThreadIdx, m_pSlice);
+
assert ((void*) (&m_pSliceBs->sBsWrite) == (void*)m_pSlice->pSliceBsa);
InitBits (&m_pSliceBs->sBsWrite, m_pSliceBs->pBsBuffer, m_pSliceBs->uiSize);
//printf ("CWelsSliceEncodingTask_InitTask slice %d\n", m_iSliceIdx);
@@ -262,12 +262,13 @@
return ENC_RETURN_KNOWN_ISSUE;
}
- SetOneSliceBsBufferUnderMultithread (m_pCtx, m_iThreadIdx, iLocalSliceIdx);
m_pSlice = pCurDq->ppSliceInLayer[iLocalSliceIdx];
m_pSliceBs = &m_pSlice->sSliceBs;
m_pSliceBs->uiBsPos = 0;
m_pSliceBs->iNalIndex = 0;
+
+ SetOneSliceBsBufferUnderMultithread (m_pCtx, m_iThreadIdx, m_pSlice);
InitBits (&m_pSliceBs->sBsWrite, m_pSliceBs->pBsBuffer, m_pSliceBs->uiSize);
if (m_bNeedPrefix) {