History

remove pSliceComplexRatio from SliceThreading

huade committed 10 years ago

Commit f263f071 parent aeb55e05 files · +17 −43Browse files

Showing the changes to codec/encoder/core/src/slice_multi_threading.cpp (1 of 5 files). Show all

Unified · Split

codec/encoder/core/src/slice_multi_threading.cpp+14−38
@@ -128,10 +128,9 @@ void UpdateMbListNeighborParallel (SDqLayer* pCurDq, · 127 unmodified lines
128128 } while (iIdx <= kiEndMbInSlice);
129129 }
130130
131−void CalcSliceComplexRatio (void* pRatio, SDqLayer* pCurDq) {
131+void CalcSliceComplexRatio (SDqLayer* pCurDq) {
132132 SSliceCtx* pSliceCtx = &pCurDq->sSliceEncCtx;
133133 SSlice* pSliceInLayer = pCurDq->sLayerInfo.pSliceInLayer;
134− int32_t* pRatioList = (int32_t*)pRatio;
135134 int32_t iSumAv = 0;
136135 int32_t* pCountMbInSlice = (int32_t*)pSliceCtx->pCountMbNumInSlice;
137136 const int32_t kiSliceCount = pSliceCtx->iSliceNumInFrame;
@@ -150,7 +149,7 @@ void CalcSliceComplexRatio (void* pRatio, SDqLayer* pCurDq) { · 12 unmodified lines
150149 ++ iSliceIdx;
151150 }
152151 while (-- iSliceIdx >= 0) {
153− pRatioList[iSliceIdx] = WELS_DIV_ROUND (INT_MULTIPLY * iAvI[iSliceIdx], iSumAv);
152+ pSliceInLayer[iSliceIdx].iSliceComplexRatio = WELS_DIV_ROUND (INT_MULTIPLY * iAvI[iSliceIdx], iSumAv);
154153 }
155154 }
156155
@@ -205,15 +204,14 @@ int32_t NeedDynamicAdjust (SSlice* pSliceInLayer, const int32_t iSliceNum) { · 48 unmodified lines
205204
206205 void DynamicAdjustSlicing (sWelsEncCtx* pCtx,
207206 SDqLayer* pCurDqLayer,
208− void* pComplexRatio,
209207 int32_t iCurDid) {
210− SSliceCtx* pSliceCtx = &pCurDqLayer->sSliceEncCtx;
208+ SSliceCtx* pSliceCtx = &pCurDqLayer->sSliceEncCtx;
209+ SSlice* pSliceInLayer = pCurDqLayer->sLayerInfo.pSliceInLayer;
211210 const int32_t kiCountSliceNum = pSliceCtx->iSliceNumInFrame;
212211 const int32_t kiCountNumMb = pSliceCtx->iMbNumInFrame;
213212 int32_t iMinimalMbNum =
214213 pSliceCtx->iMbWidth; // in theory we need only 1 SMB, here let it as one SMB row required
215214 int32_t iMaximalMbNum = 0; // dynamically assign later
216− int32_t* pSliceComplexRatio = (int32_t*)pComplexRatio;
217215 int32_t iMbNumLeft = kiCountNumMb;
218216 int32_t iRunLen[MAX_THREADS_NUM] = {0};
219217 int32_t iSliceIdx = 0;
@@ -249,7 +247,7 @@ void DynamicAdjustSlicing (sWelsEncCtx* pCtx, · 29 unmodified lines
249247
250248 iSliceIdx = 0;
251249 while (iSliceIdx + 1 < kiCountSliceNum) {
252− int32_t iNumMbAssigning = WELS_DIV_ROUND (kiCountNumMb * pSliceComplexRatio[iSliceIdx], INT_MULTIPLY);
250+ int32_t iNumMbAssigning = WELS_DIV_ROUND (kiCountNumMb * pSliceInLayer[iSliceIdx].iSliceComplexRatio, INT_MULTIPLY);
253251
254252 // GOM boundary aligned
255253 if (pCtx->pSvcParam->iRCMode != RC_OFF_MODE) {
@@ -271,16 +269,18 @@ void DynamicAdjustSlicing (sWelsEncCtx* pCtx, · 15 unmodified lines
271269 }
272270 iRunLen[iSliceIdx] = iNumMbAssigning;
273271 MT_TRACE_LOG (pCtx, WELS_LOG_DEBUG,
274− "[MT] DynamicAdjustSlicing(), uiSliceIdx= %d, pSliceComplexRatio= %.2f, slice_run_org= %d, slice_run_adj= %d",
275− iSliceIdx, pSliceComplexRatio[iSliceIdx] * 1.0f / INT_MULTIPLY, pSliceCtx->pCountMbNumInSlice[iSliceIdx],
272+ "[MT] DynamicAdjustSlicing(), uiSliceIdx= %d, iSliceComplexRatio= %.2f, slice_run_org= %d, slice_run_adj= %d",
273+ iSliceIdx, pSliceInLayer[iSliceIdx].iSliceComplexRatio * 1.0f / INT_MULTIPLY,
274+ pSliceCtx->pCountMbNumInSlice[iSliceIdx],
276275 iNumMbAssigning);
277276 ++ iSliceIdx;
278277 iMaximalMbNum = iMbNumLeft - (kiCountSliceNum - iSliceIdx - 1) * iMinimalMbNum; // get maximal num_mb in left parts
279278 }
280279 iRunLen[iSliceIdx] = iMbNumLeft;
281280 MT_TRACE_LOG (pCtx, WELS_LOG_DEBUG,
282− "[MT] DynamicAdjustSlicing(), iSliceIdx= %d, pSliceComplexRatio= %.2f, slice_run_org= %d, slice_run_adj= %d",
283− iSliceIdx, pSliceComplexRatio[iSliceIdx] * 1.0f / INT_MULTIPLY, pSliceCtx->pCountMbNumInSlice[iSliceIdx], iMbNumLeft);
281+ "[MT] DynamicAdjustSlicing(), iSliceIdx= %d, iSliceComplexRatio= %.2f, slice_run_org= %d, slice_run_adj= %d",
282+ iSliceIdx, pSliceInLayer[iSliceIdx].iSliceComplexRatio * 1.0f / INT_MULTIPLY,
283+ pSliceCtx->pCountMbNumInSlice[iSliceIdx], iMbNumLeft);
284284
285285
286286 if (DynamicAdjustSlicePEncCtxAll (pCurDqLayer, iRunLen) == 0) {
@@ -367,18 +367,7 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 80 unmodified lines
367367 iIdx = 0;
368368 while (iIdx < iNumSpatialLayers) {
369369 SSliceArgument* pSliceArgument = &pPara->sSpatialLayers[iIdx].sSliceArgument;
370− const int32_t kiSliceNum = pSliceArgument->uiSliceNum;
371− if ((pSliceArgument->uiSliceMode == SM_FIXEDSLCNUM_SLICE)
372− && (pPara->bUseLoadBalancing)
373− && (pPara->iMultipleThreadIdc > 1)
374− && (pPara->iMultipleThreadIdc >= kiSliceNum)) {
375− pSmt->pSliceComplexRatio[iIdx] = (int32_t*)pMa->WelsMalloc (kiSliceNum * sizeof (int32_t), "pSliceComplexRatio[]");
376− WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pSliceComplexRatio[iIdx]), FreeMemorySvc (ppCtx))
377− } else {
378− pSmt->pSliceComplexRatio[iIdx] = NULL;
379− }
380−
381− if (pSliceArgument->uiSliceMode == SM_FIXEDSLCNUM_SLICE || pSliceArgument->uiSliceMode == SM_RASTER_SLICE) {
370+ if (pSliceArgument->uiSliceMode == SM_FIXEDSLCNUM_SLICE || pSliceArgument->uiSliceMode == SM_RASTER_SLICE) {
382371 bWillUseTaskManage = true;
383372 }
384373 ++ iIdx;
@@ -474,7 +463,6 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 89 unmodified lines
474463
475464 void ReleaseMtResource (sWelsEncCtx** ppCtx) {
476465 SWelsSliceBs* pSliceB = NULL;
477− SWelsSvcCodingParam* pCodingParam = NULL;
478466 SSliceThreading* pSmt = NULL;
479467 CMemoryAlign* pMa = NULL;
480468 int32_t iIdx = 0;
@@ -485,7 +473,6 @@ void ReleaseMtResource (sWelsEncCtx** ppCtx) { · 4 unmodified lines
485473 return;
486474
487475 pMa = (*ppCtx)->pMemAlign;
488− pCodingParam = (*ppCtx)->pSvcParam;
489476 uiSliceNum = (*ppCtx)->iMaxSliceCount;
490477 iThreadNum = (*ppCtx)->pSvcParam->iCountThreadsNum;
491478 pSmt = (*ppCtx)->pSliceThreading;
@@ -550,15 +537,6 @@ void ReleaseMtResource (sWelsEncCtx** ppCtx) { · 58 unmodified lines
550537 (*ppCtx)->pTaskManage = NULL;
551538 }
552539
553− iIdx = 0;
554− while (iIdx < pCodingParam->iSpatialLayerNum) {
555− if (pSmt->pSliceComplexRatio[iIdx] != NULL) {
556− pMa->WelsFree (pSmt->pSliceComplexRatio[iIdx], "pSliceComplexRatio[]");
557− pSmt->pSliceComplexRatio[iIdx] = NULL;
558− }
559− ++ iIdx;
560− }
561−
562540 #ifdef MT_DEBUG
563541 // file handle for debug
564542 if (pSmt->pFSliceDiff) {
@@ -1067,7 +1045,6 @@ int32_t AdjustBaseLayer (sWelsEncCtx* pCtx) { · 502 unmodified lines
10671045 if (iNeedAdj)
10681046 DynamicAdjustSlicing (pCtx,
10691047 pCurDq,
1070− pCtx->pSliceThreading->pSliceComplexRatio[0],
10711048 0);
10721049 #ifdef MT_DEBUG
10731050 iT0 = WelsTime() - iT0;
@@ -1101,7 +1078,6 @@ int32_t AdjustEnhanceLayer (sWelsEncCtx* pCtx, int32_t iCurDid) { · 27 unmodified lines
11011078 if (iNeedAdj)
11021079 DynamicAdjustSlicing (pCtx,
11031080 pCtx->pCurDqLayer,
1104− pCtx->pSliceThreading->pSliceComplexRatio[iCurDid - 1],
11051081 iCurDid
11061082 );
11071083 } else { // use temporal layer for complexity estimation
@@ -1111,7 +1087,6 @@ int32_t AdjustEnhanceLayer (sWelsEncCtx* pCtx, int32_t iCurDid) { · 3 unmodified lines
11111087 if (iNeedAdj)
11121088 DynamicAdjustSlicing (pCtx,
11131089 pCtx->pCurDqLayer,
1114− pCtx->pSliceThreading->pSliceComplexRatio[iCurDid],
11151090 iCurDid
11161091 );
11171092 }
@@ -1133,11 +1108,12 @@ int32_t AdjustEnhanceLayer (sWelsEncCtx* pCtx, int32_t iCurDid) { · 15 unmodified lines
11331108 #if defined(MT_DEBUG)
11341109 void TrackSliceComplexities (sWelsEncCtx* pCtx, const int32_t iCurDid) {
11351110 const int32_t kiCountSliceNum = pCtx->pCurDqLayer->sSliceEncCtx.iSliceNumInFrame;
1111+ SSlice* pSliceInLayer = pCtx->pCurDqLayer->sLayerInfo.pSliceInLayer;
11361112 if (kiCountSliceNum > 0) {
11371113 int32_t iSliceIdx = 0;
11381114 do {
11391115 fprintf (pCtx->pSliceThreading->pFSliceDiff, "%6.3f complexity pRatio at iDid %d pSlice %d\n",
1140− pCtx->pSliceThreading->pSliceComplexRatio[iCurDid][iSliceIdx], iCurDid, iSliceIdx);
1116+ pSliceInLayer[iSliceIdx].iSliceComplexRatio, iCurDid, iSliceIdx);
11411117 ++ iSliceIdx;
11421118 } while (iSliceIdx < kiCountSliceNum);
11431119 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t