ref: 067aa85be0e3e05b290abb384aaa1687315d0283
parent: f40452d3cbe241a990c57b59a166736c02a88aee
author: huade <[email protected]>
date: Tue Dec 20 04:41:06 EST 2016
Multi-thread-fixed:RBC#1708:pSlice instead of ppSliceInLayer in MB RC init/update etc. functions
--- a/codec/encoder/core/inc/svc_enc_frame.h
+++ b/codec/encoder/core/inc/svc_enc_frame.h
@@ -70,6 +70,7 @@
typedef struct TagSliceThreadInfo {
SSlice* pSliceInThread[MAX_THREADS_NUM];// slice buffer for multi thread,
+ // pSliceInThread[0] for single thread
// will not alloated when multi thread is off
int32_t iMaxSliceNumInThread[MAX_THREADS_NUM];
int32_t iEncodedSliceNumInThread[MAX_THREADS_NUM];
@@ -77,8 +78,6 @@
typedef struct TagLayerInfo {
SNalUnitHeaderExt sNalHeaderExt;
-SSlice* pSliceInLayer; // Here SSlice identify to Frame on concept, [iSliceIndex],
- // may need extend list size for sliceMode=SM_SIZELIMITED_SLICE
SSubsetSps* pSubsetSpsP; // current pSubsetSps used, memory alloc in external
SWelsSPS* pSpsP; // current pSps based avc used, memory alloc in external
SWelsPPS* pPpsP; // current pPps used
--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -924,8 +924,6 @@
void FreeSliceInLayer (SDqLayer* pDq, CMemoryAlign* pMa) {
int32_t iIdx = 0;
-
- FreeSliceBuffer (pDq->sLayerInfo.pSliceInLayer, pDq->iMaxSliceNum, pMa, "pSliceInLayer");
for (; iIdx < MAX_THREADS_NUM; iIdx ++) {
FreeSliceBuffer (pDq->sSliceThreadInfo.pSliceInThread[iIdx],
pDq->sSliceThreadInfo.iMaxSliceNumInThread[iIdx],
@@ -3773,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/ratectl.cpp
+++ b/codec/encoder/core/src/ratectl.cpp
@@ -1186,10 +1186,8 @@
}
void WelsRcMbInitGom (sWelsEncCtx* pEncCtx, SMB* pCurMb, SSlice* pSlice) {
- SSlice** ppSliceInLayer = pEncCtx->pCurDqLayer->ppSliceInLayer;
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
- const int32_t kiSliceId = pSlice->uiSliceIdx;
- SRCSlicing* pSOverRc = &ppSliceInLayer[kiSliceId]->sSlicingOverRc;
+ SRCSlicing* pSOverRc = &pSlice->sSlicingOverRc;
SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset;
@@ -1213,11 +1211,8 @@
}
void WelsRcMbInfoUpdateGom (sWelsEncCtx* pEncCtx, SMB* pCurMb, int32_t iCostLuma, SSlice* pSlice) {
- SSlice** ppSliceInLayer = pEncCtx->pCurDqLayer->ppSliceInLayer;
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
- int32_t iSliceId = pSlice->uiSliceIdx;
- SRCSlicing* pSOverRc = &ppSliceInLayer[iSliceId]->sSlicingOverRc;
-
+ SRCSlicing* pSOverRc = &pSlice->sSlicingOverRc;
const int32_t kiComplexityIndex = pSOverRc->iComplexityIndexSlice;
int32_t iCurMbBits = pEncCtx->pFuncList->pfGetBsPosition (pSlice) - pSOverRc->iBsPosSlice;
--- a/codec/encoder/core/src/ref_list_mgr_svc.cpp
+++ b/codec/encoder/core/src/ref_list_mgr_svc.cpp
@@ -707,7 +707,6 @@
* 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];
/*syntax for ref_pic_list_reordering()*/
--- a/codec/encoder/core/src/svc_encode_slice.cpp
+++ b/codec/encoder/core/src/svc_encode_slice.cpp
@@ -948,7 +948,7 @@
iMaxSliceBufferSize,
pMa);
if (ENC_RETURN_SUCCESS != iRet) {
- return iRet;
+ return iRet;
}
iRet = InitSliceMBInfo (pSliceArgument, pSlice,
@@ -1014,14 +1014,14 @@
int32_t iRet = 0;
assert (iThreadNum > 0);
- iMaxSliceNumInThread = (pCtx->iMaxSliceCount / iThreadNum + 1) * 2;
+ //iMaxSliceNumInThread = (pCtx->iMaxSliceCount / iThreadNum + 1) * 2;
+ iMaxSliceNumInThread = pDqLayer->iMaxSliceNum;
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");
+ 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");
@@ -1069,25 +1069,8 @@
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];
+ pDqLayer->ppSliceInLayer[iSliceIdx] = pDqLayer->sSliceThreadInfo.pSliceInThread[0] + iSliceIdx;
}
return ENC_RETURN_SUCCESS;
@@ -1295,7 +1278,7 @@
int32_t iSliceIdx = 0;
const int32_t kiCurDid = pCtx->uiDependencyId;
- SSlice* pLastCodedSlice = pCurLayer->sLayerInfo.pSliceInLayer + (iMaxSliceNumOld - 1);
+ SSlice* pLastCodedSlice = pCurLayer->sSliceThreadInfo.pSliceInThread[0] + (iMaxSliceNumOld - 1);
SSliceArgument* pSliceArgument = & pCtx->pSvcParam->sSpatialLayers[kiCurDid].sSliceArgument;
iRet = CalculateNewSliceNum (pCurLayer,
pLastCodedSlice,
@@ -1308,7 +1291,7 @@
iRet = ReallocateSliceList (pCtx,
pSliceArgument,
- pCurLayer->sLayerInfo.pSliceInLayer,
+ pCurLayer->sSliceThreadInfo.pSliceInThread[0],
iMaxSliceNumOld,
iMaxSliceNumNew);
if (ENC_RETURN_SUCCESS != iRet) {
@@ -1325,7 +1308,7 @@
pCurLayer->ppSliceInLayer = ppSlice;
for (iSliceIdx = 0; iSliceIdx < iMaxSliceNumNew; iSliceIdx++) {
- pCurLayer->ppSliceInLayer[iSliceIdx] = &pCurLayer->sLayerInfo.pSliceInLayer[iSliceIdx];
+ pCurLayer->ppSliceInLayer[iSliceIdx] = pCurLayer->sSliceThreadInfo.pSliceInThread[0] + iSliceIdx;
}
if (pCtx->iMaxSliceCount < iMaxSliceNumNew) {
@@ -1332,7 +1315,8 @@
pCtx->iMaxSliceCount = iMaxSliceNumNew;
}
- pCurLayer->sSliceEncCtx.iMaxSliceNumConstraint = iMaxSliceNumNew;
+ pCurLayer->sSliceEncCtx.iMaxSliceNumConstraint = iMaxSliceNumNew;
+ pCurLayer->sSliceThreadInfo.iMaxSliceNumInThread[0] = iMaxSliceNumNew;
pCurLayer->iMaxSliceNum = iMaxSliceNumNew;
return ENC_RETURN_SUCCESS;
}
--- a/codec/encoder/core/src/wels_task_encoder.cpp
+++ b/codec/encoder/core/src/wels_task_encoder.cpp
@@ -222,7 +222,7 @@
m_iSliceIdx,
m_pSlice->uiSliceConsumeTime,
m_iSliceSize,
- m_pCtx->pCurDqLayer->ppSliceInLayer[m_iSliceIdx]->sSliceHeaderExt.sSliceHeader.iFirstMbInSlice,
+ m_pSlice->sSliceHeaderExt.sSliceHeader.iFirstMbInSlice,
m_pSlice->iCountMbNumInSlice,
(m_pSlice->uiSliceConsumeTime + m_iSliceStart));
}