Showing the changes to codec/encoder/core/src/slice_multi_threading.cpp (1 of 8 files). Show all
Unified · Split
| @@ -85,7 +85,7 @@ void UpdateMbListNeighborParallel (SDqLayer* pCurDq, · 84 unmodified lines | |||
| 85 | const uint16_t* kpMbMap = pSliceCtx->pOverallMbMap; | 85 | const uint16_t* kpMbMap = pSliceCtx->pOverallMbMap; |
| 86 | const int32_t kiMbWidth = pSliceCtx->iMbWidth; | 86 | const int32_t kiMbWidth = pSliceCtx->iMbWidth; |
| 87 | int32_t iIdx = pUpdateSlice->sSliceHeaderExt.sSliceHeader.iFirstMbInSlice; | 87 | int32_t iIdx = pUpdateSlice->sSliceHeaderExt.sSliceHeader.iFirstMbInSlice; |
| 88 | const int32_t kiEndMbInSlice = iIdx + pSliceCtx->pCountMbNumInSlice[uiSliceIdc] - 1; | 88 | const int32_t kiEndMbInSlice = iIdx + pUpdateSlice->iCountMbNumInSlice - 1; |
| 89 | 89 | ||
| 90 | do { | 90 | do { |
| 91 | SMB* pMb = &pMbList[iIdx]; | 91 | SMB* pMb = &pMbList[iIdx]; |
| @@ -132,7 +132,6 @@ void CalcSliceComplexRatio (SDqLayer* pCurDq) { · 40 unmodified lines | |||
| 132 | SSliceCtx* pSliceCtx = &pCurDq->sSliceEncCtx; | 132 | SSliceCtx* pSliceCtx = &pCurDq->sSliceEncCtx; |
| 133 | SSlice* pSliceInLayer = pCurDq->sLayerInfo.pSliceInLayer; | 133 | SSlice* pSliceInLayer = pCurDq->sLayerInfo.pSliceInLayer; |
| 134 | int32_t iSumAv = 0; | 134 | int32_t iSumAv = 0; |
| 135 | int32_t* pCountMbInSlice = (int32_t*)pSliceCtx->pCountMbNumInSlice; | ||
| 136 | const int32_t kiSliceCount = pSliceCtx->iSliceNumInFrame; | 135 | const int32_t kiSliceCount = pSliceCtx->iSliceNumInFrame; |
| 137 | int32_t iSliceIdx = 0; | 136 | int32_t iSliceIdx = 0; |
| 138 | int32_t iAvI[MAX_SLICES_NUM]; | 137 | int32_t iAvI[MAX_SLICES_NUM]; |
| @@ -140,10 +139,11 @@ void CalcSliceComplexRatio (SDqLayer* pCurDq) { · 1 unmodified line | |||
| 140 | WelsEmms(); | 139 | WelsEmms(); |
| 141 | 140 | ||
| 142 | while (iSliceIdx < kiSliceCount) { | 141 | while (iSliceIdx < kiSliceCount) { |
| 143 | iAvI[iSliceIdx] = WELS_DIV_ROUND (INT_MULTIPLY * pCountMbInSlice[iSliceIdx], pSliceInLayer[iSliceIdx].uiSliceConsumeTime); | 142 | iAvI[iSliceIdx] = WELS_DIV_ROUND (INT_MULTIPLY * pSliceInLayer[iSliceIdx].iCountMbNumInSlice, |
| 143 | pSliceInLayer[iSliceIdx].uiSliceConsumeTime); | ||
| 144 | MT_TRACE_LOG (NULL, WELS_LOG_DEBUG, "[MT] CalcSliceComplexRatio(), uiSliceConsumeTime[%d]= %d us, slice_run= %d", | 144 | MT_TRACE_LOG (NULL, WELS_LOG_DEBUG, "[MT] CalcSliceComplexRatio(), uiSliceConsumeTime[%d]= %d us, slice_run= %d", |
| 145 | iSliceIdx, | 145 | iSliceIdx, |
| 146 | pSliceInLayer[iSliceIdx].uiSliceConsumeTime, pCountMbInSlice[iSliceIdx]); | 146 | pSliceInLayer[iSliceIdx].uiSliceConsumeTime, pSliceInLayer[iSliceIdx].iCountMbNumInSlice); |
| 147 | iSumAv += iAvI[iSliceIdx]; | 147 | iSumAv += iAvI[iSliceIdx]; |
| 148 | 148 | ||
| 149 | ++ iSliceIdx; | 149 | ++ iSliceIdx; |
| @@ -271,7 +271,7 @@ void DynamicAdjustSlicing (sWelsEncCtx* pCtx, · 121 unmodified lines | |||
| 271 | MT_TRACE_LOG (pCtx, WELS_LOG_DEBUG, | 271 | MT_TRACE_LOG (pCtx, WELS_LOG_DEBUG, |
| 272 | "[MT] DynamicAdjustSlicing(), uiSliceIdx= %d, iSliceComplexRatio= %.2f, slice_run_org= %d, slice_run_adj= %d", | 272 | "[MT] DynamicAdjustSlicing(), uiSliceIdx= %d, iSliceComplexRatio= %.2f, slice_run_org= %d, slice_run_adj= %d", |
| 273 | iSliceIdx, pSliceInLayer[iSliceIdx].iSliceComplexRatio * 1.0f / INT_MULTIPLY, | 273 | iSliceIdx, pSliceInLayer[iSliceIdx].iSliceComplexRatio * 1.0f / INT_MULTIPLY, |
| 274 | pSliceCtx->pCountMbNumInSlice[iSliceIdx], | 274 | pSliceInLayer[iSliceIdx].iCountMbNumInSlice, |
| 275 | iNumMbAssigning); | 275 | iNumMbAssigning); |
| 276 | ++ iSliceIdx; | 276 | ++ iSliceIdx; |
| 277 | iMaximalMbNum = iMbNumLeft - (kiCountSliceNum - iSliceIdx - 1) * iMinimalMbNum; // get maximal num_mb in left parts | 277 | iMaximalMbNum = iMbNumLeft - (kiCountSliceNum - iSliceIdx - 1) * iMinimalMbNum; // get maximal num_mb in left parts |
| @@ -280,8 +280,7 @@ void DynamicAdjustSlicing (sWelsEncCtx* pCtx, · 2 unmodified lines | |||
| 280 | MT_TRACE_LOG (pCtx, WELS_LOG_DEBUG, | 280 | MT_TRACE_LOG (pCtx, WELS_LOG_DEBUG, |
| 281 | "[MT] DynamicAdjustSlicing(), iSliceIdx= %d, iSliceComplexRatio= %.2f, slice_run_org= %d, slice_run_adj= %d", | 281 | "[MT] DynamicAdjustSlicing(), iSliceIdx= %d, iSliceComplexRatio= %.2f, slice_run_org= %d, slice_run_adj= %d", |
| 282 | iSliceIdx, pSliceInLayer[iSliceIdx].iSliceComplexRatio * 1.0f / INT_MULTIPLY, | 282 | iSliceIdx, pSliceInLayer[iSliceIdx].iSliceComplexRatio * 1.0f / INT_MULTIPLY, |
| 283 | pSliceCtx->pCountMbNumInSlice[iSliceIdx], iMbNumLeft); | 283 | pSliceInLayer[iSliceIdx].iCountMbNumInSlice, iMbNumLeft); |
| 284 | |||
| 285 | 284 | ||
| 286 | if (DynamicAdjustSlicePEncCtxAll (pCurDqLayer, iRunLen) == 0) { | 285 | if (DynamicAdjustSlicePEncCtxAll (pCurDqLayer, iRunLen) == 0) { |
| 287 | const int32_t kiThreadNum = pCtx->pSvcParam->iCountThreadsNum; | 286 | const int32_t kiThreadNum = pCtx->pSvcParam->iCountThreadsNum; |
| @@ -367,7 +366,7 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 79 unmodified lines | |||
| 367 | iIdx = 0; | 366 | iIdx = 0; |
| 368 | while (iIdx < iNumSpatialLayers) { | 367 | while (iIdx < iNumSpatialLayers) { |
| 369 | SSliceArgument* pSliceArgument = &pPara->sSpatialLayers[iIdx].sSliceArgument; | 368 | SSliceArgument* pSliceArgument = &pPara->sSpatialLayers[iIdx].sSliceArgument; |
| 370 | if (pSliceArgument->uiSliceMode == SM_FIXEDSLCNUM_SLICE || pSliceArgument->uiSliceMode == SM_RASTER_SLICE) { | 369 | if (pSliceArgument->uiSliceMode == SM_FIXEDSLCNUM_SLICE || pSliceArgument->uiSliceMode == SM_RASTER_SLICE) { |
| 371 | bWillUseTaskManage = true; | 370 | bWillUseTaskManage = true; |
| 372 | } | 371 | } |
| 373 | ++ iIdx; | 372 | ++ iIdx; |
| @@ -789,7 +788,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 415 unmodified lines | |||
| 789 | pEncPEncCtx->iCodingIndex, iSliceIdx, | 788 | pEncPEncCtx->iCodingIndex, iSliceIdx, |
| 790 | pEncPEncCtx->pCurDqLayer->sLayerInfo.pSliceInLayer[iSliceIdx].uiSliceConsumeTime, iSliceSize, | 789 | pEncPEncCtx->pCurDqLayer->sLayerInfo.pSliceInLayer[iSliceIdx].uiSliceConsumeTime, iSliceSize, |
| 791 | pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx].sSliceHeaderExt.sSliceHeader.iFirstMbInSlice, | 790 | pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx].sSliceHeaderExt.sSliceHeader.iFirstMbInSlice, |
| 792 | pCurDq->sSliceEncCtx.pCountMbNumInSlice[iSliceIdx]); | 791 | pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx].iCountMbNumInSlice); |
| 793 | } | 792 | } |
| 794 | 793 | ||
| 795 | #if defined(SLICE_INFO_OUTPUT) | 794 | #if defined(SLICE_INFO_OUTPUT) |
| @@ -898,7 +897,8 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 102 unmodified lines | |||
| 898 | 897 | ||
| 899 | MT_TRACE_LOG (pEncPEncCtx, WELS_LOG_INFO, | 898 | MT_TRACE_LOG (pEncPEncCtx, WELS_LOG_INFO, |
| 900 | "[MT] CodingSliceThreadProc(), coding_idx %d, iPartitionId %d, uiSliceIdx %d, iSliceSize %d, count_mb_slice %d, iEndMbInPartition %d, pCurDq->pLastCodedMbIdxOfPartition[%d] %d\n", | 899 | "[MT] CodingSliceThreadProc(), coding_idx %d, iPartitionId %d, uiSliceIdx %d, iSliceSize %d, count_mb_slice %d, iEndMbInPartition %d, pCurDq->pLastCodedMbIdxOfPartition[%d] %d\n", |
| 901 | pEncPEncCtx->iCodingIndex, kiPartitionId, iSliceIdx, iSliceSize, pCurDq->sSliceEncCtx.pCountMbNumInSlice[iSliceIdx], | 900 | pEncPEncCtx->iCodingIndex, kiPartitionId, iSliceIdx, iSliceSize, |
| 901 | pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx].iCountMbNumInSlice, | ||
| 902 | kiEndMbInPartition, kiPartitionId, pCurDq->pLastCodedMbIdxOfPartition[kiPartitionId]); | 902 | kiEndMbInPartition, kiPartitionId, pCurDq->pLastCodedMbIdxOfPartition[kiPartitionId]); |
| 903 | 903 | ||
| 904 | iAnyMbLeftInPartition = kiEndMbInPartition - (1 + pCurDq->pLastCodedMbIdxOfPartition[kiPartitionId]); | 904 | iAnyMbLeftInPartition = kiEndMbInPartition - (1 + pCurDq->pLastCodedMbIdxOfPartition[kiPartitionId]); |