ref: 6f347d17f173d2a44659a3ce9b8e12dc7777fd32
parent: 0d84eadcf30acffe1d1620d079715441542f3ce5
author: huade <[email protected]>
date: Wed Dec 21 09:34:41 EST 2016
Multi-thread-fixed:RBC#1712:add pFirstMbIdxInSlice/pCountMbNumInSlice in layer structure
--- a/codec/encoder/core/inc/svc_enc_frame.h
+++ b/codec/encoder/core/inc/svc_enc_frame.h
@@ -119,6 +119,9 @@
int32_t* pFirstMbIdxOfPartition; // for dynamic slicing mode
int32_t* pEndMbIdxOfPartition; // for dynamic slicing mode
+int32_t* pFirstMbIdxOfSlice;
+int32_t* pCountMbNumInSlice;
+
bool bNeedAdjustingSlicing;
SFeatureSearchPreparation* pFeatureSearchPreparation;
--- a/codec/encoder/core/src/ref_list_mgr_svc.cpp
+++ b/codec/encoder/core/src/ref_list_mgr_svc.cpp
@@ -708,7 +708,7 @@
*/
void WelsUpdateRefSyntax (sWelsEncCtx* pCtx, const int32_t iPOC, const int32_t uiFrameType) {
int32_t iAbsDiffPicNumMinus1 = -1;
- SSpatialLayerInternal* pParamD = &pCtx->pSvcParam->sDependencyLayers[pCtx->uiDependencyId];
+ 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;
@@ -911,7 +911,6 @@
SLTRState* pLtr = &pCtx->pLtr[pCtx->uiDependencyId];
int32_t iMaxTid = WELS_LOG2 (pCtx->pSvcParam->uiGopSize);
int32_t iMaxActualLtrIdx = -1;
-
SSpatialLayerInternal* pParamD = &pCtx->pSvcParam->sDependencyLayers[pCtx->uiDependencyId];
if (pCtx->pSvcParam->bEnableLongTermReference)
iMaxActualLtrIdx = pCtx->pSvcParam->iNumRefFrame - STR_ROOM - 1 - WELS_MAX (iMaxTid , 1);
--- a/codec/encoder/core/src/svc_enc_slice_segment.cpp
+++ b/codec/encoder/core/src/svc_enc_slice_segment.cpp
@@ -663,6 +663,8 @@
SSliceHeaderExt* pSliceHeaderExt = &ppSliceInLayer[iSliceIdx]->sSliceHeaderExt;
pSliceHeaderExt->sSliceHeader.iFirstMbInSlice = iFirstMbIdx;
ppSliceInLayer[iSliceIdx]->iCountMbNumInSlice = kiSliceRun;
+ pCurDq->pFirstMbIdxOfSlice[iSliceIdx] = iFirstMbIdx;
+ pCurDq->pCountMbNumInSlice[iSliceIdx] = kiSliceRun;
WelsSetMemMultiplebytes_c(pSliceCtx->pOverallMbMap + iFirstMbIdx, iSliceIdx,
kiSliceRun, sizeof(uint16_t));
--- a/codec/encoder/core/src/svc_encode_slice.cpp
+++ b/codec/encoder/core/src/svc_encode_slice.cpp
@@ -1061,6 +1061,18 @@
return ENC_RETURN_MEMALLOCERR;
}
+ pDqLayer->pFirstMbIdxOfSlice = (int32_t*)pMa->WelsMallocz (sizeof (int32_t*) * iMaxSliceNum, "pFirstMbIdxOfSlice");
+ if (NULL == pDqLayer->pFirstMbIdxOfSlice) {
+ WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::InitSliceInLayer() pDqLayer->pFirstMbIdxOfSlice is NULL");
+ return ENC_RETURN_MEMALLOCERR;
+ }
+
+ pDqLayer->pCountMbNumInSlice = (int32_t*)pMa->WelsMallocz (sizeof (int32_t*) * iMaxSliceNum, "pCountMbNumInSlice");
+ if (NULL == pDqLayer->pCountMbNumInSlice) {
+ WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::InitSliceInLayer() pDqLayer->pCountMbNumInSlice is NULL");
+ return ENC_RETURN_MEMALLOCERR;
+ }
+
InitSliceThreadInfo (pCtx,
pDqLayer,
kiDlayerIndex,
@@ -1278,6 +1290,8 @@
int32_t iSliceIdx = 0;
const int32_t kiCurDid = pCtx->uiDependencyId;
+ int32_t* pFirstMbIdxofSlice = NULL;
+ int32_t* pCountMbNumInSlice = NULL;
SSlice* pLastCodedSlice = pCurLayer->sSliceThreadInfo.pSliceInThread[0] + (iMaxSliceNumOld - 1);
SSliceArgument* pSliceArgument = & pCtx->pSvcParam->sSpatialLayers[kiCurDid].sSliceArgument;
iRet = CalculateNewSliceNum (pCurLayer,
@@ -1306,6 +1320,28 @@
}
pMA->WelsFree (pCurLayer->ppSliceInLayer, "ppSliceInLayer");
pCurLayer->ppSliceInLayer = ppSlice;
+
+ // update for pFirstMbIdxInSlice
+ pFirstMbIdxofSlice = (int32_t*)pMA->WelsMallocz (sizeof (int32_t*) * iMaxSliceNumNew, "pFirstMbIdxofSlice");
+ if (NULL == pFirstMbIdxofSlice) {
+ WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::ReallocSliceBuffer: pFirstMbIdxofSlice is NULL");
+ return ENC_RETURN_MEMALLOCERR;
+ }
+ memset (pFirstMbIdxofSlice, 0, sizeof(int32_t) * iMaxSliceNumNew);
+ memcpy (pFirstMbIdxofSlice, pCurLayer->pFirstMbIdxOfSlice, sizeof (int32_t) * iMaxSliceNumOld);
+ pMA->WelsFree (pCurLayer->pFirstMbIdxOfSlice, "pFirstMbIdxofSlice");
+ pCurLayer->pFirstMbIdxOfSlice = pFirstMbIdxofSlice;
+
+ // update for pCountMbNumInSlice
+ pCountMbNumInSlice = (int32_t*)pMA->WelsMallocz (sizeof (int32_t*) * iMaxSliceNumNew, "pCountMbNumInSlice");
+ if (NULL == pCountMbNumInSlice) {
+ WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::ReallocSliceBuffer: pCountMbNumInSlice is NULL");
+ return ENC_RETURN_MEMALLOCERR;
+ }
+ memset (pCountMbNumInSlice, 0, sizeof(int32_t) * iMaxSliceNumNew);
+ memcpy (pCountMbNumInSlice, pCurLayer->pCountMbNumInSlice, sizeof (int32_t) * iMaxSliceNumOld);
+ pMA->WelsFree (pCurLayer->pCountMbNumInSlice, "pCountMbNumInSlice");
+ pCurLayer->pCountMbNumInSlice = pCountMbNumInSlice;
for (iSliceIdx = 0; iSliceIdx < iMaxSliceNumNew; iSliceIdx++) {
pCurLayer->ppSliceInLayer[iSliceIdx] = pCurLayer->sSliceThreadInfo.pSliceInThread[0] + iSliceIdx;