Showing the changes to codec/encoder/core/src/slice_multi_threading.cpp (1 of 26 files). Show all
Unified · Split
| @@ -360,11 +360,12 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 359 unmodified lines | |||
| 360 | 360 | ||
| 361 | iIdx = 0; | 361 | iIdx = 0; |
| 362 | while (iIdx < iNumSpatialLayers) { | 362 | while (iIdx < iNumSpatialLayers) { |
| 363 | SSliceConfig* pMso = &pPara->sSpatialLayers[iIdx].sSliceCfg; | 363 | SSliceArgument* pSliceArgument = &pPara->sSpatialLayers[iIdx].sSliceArgument; |
| 364 | const int32_t kiSliceNum = pMso->sSliceArgument.uiSliceNum; | 364 | const int32_t kiSliceNum = pSliceArgument->uiSliceNum; |
| 365 | if (((pMso->uiSliceMode == SM_FIXEDSLCNUM_SLICE) || (pMso->uiSliceMode == SM_AUTO_SLICE)) | 365 | if ((pSliceArgument->uiSliceMode == SM_FIXEDSLCNUM_SLICE) |
| 366 | && pPara->iMultipleThreadIdc > 1 | 366 | && (pPara->bUseLoadBalancing) |
| 367 | && pPara->iMultipleThreadIdc >= kiSliceNum) { | 367 | && (pPara->iMultipleThreadIdc > 1) |
| 368 | && (pPara->iMultipleThreadIdc >= kiSliceNum)) { | ||
| 368 | pSmt->pSliceConsumeTime[iIdx] = (uint32_t*)pMa->WelsMallocz (kiSliceNum * sizeof (uint32_t), "pSliceConsumeTime[]"); | 369 | pSmt->pSliceConsumeTime[iIdx] = (uint32_t*)pMa->WelsMallocz (kiSliceNum * sizeof (uint32_t), "pSliceConsumeTime[]"); |
| 369 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pSliceConsumeTime[iIdx]), FreeMemorySvc (ppCtx)) | 370 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pSliceConsumeTime[iIdx]), FreeMemorySvc (ppCtx)) |
| 370 | pSmt->pSliceComplexRatio[iIdx] = (int32_t*)pMa->WelsMalloc (kiSliceNum * sizeof (int32_t), "pSliceComplexRatio[]"); | 371 | pSmt->pSliceComplexRatio[iIdx] = (int32_t*)pMa->WelsMalloc (kiSliceNum * sizeof (int32_t), "pSliceComplexRatio[]"); |
| @@ -374,8 +375,7 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 3 unmodified lines | |||
| 374 | pSmt->pSliceComplexRatio[iIdx] = NULL; | 375 | pSmt->pSliceComplexRatio[iIdx] = NULL; |
| 375 | } | 376 | } |
| 376 | 377 | ||
| 377 | if ( pMso->uiSliceMode == SM_FIXEDSLCNUM_SLICE || pMso->uiSliceMode == SM_RASTER_SLICE | 378 | if ( pSliceArgument->uiSliceMode == SM_FIXEDSLCNUM_SLICE || pSliceArgument->uiSliceMode == SM_RASTER_SLICE) { |
| 378 | || pMso->uiSliceMode == SM_ROWMB_SLICE || pMso->uiSliceMode == SM_AUTO_SLICE) { | ||
| 379 | bWillUseTaskManage = true; | 379 | bWillUseTaskManage = true; |
| 380 | } | 380 | } |
| 381 | ++ iIdx; | 381 | ++ iIdx; |
| @@ -576,7 +576,7 @@ int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32 · 194 unmodified lines | |||
| 576 | SWelsSvcCodingParam* pCodingParam = pCtx->pSvcParam; | 576 | SWelsSvcCodingParam* pCodingParam = pCtx->pSvcParam; |
| 577 | SSpatialLayerConfig* pDlp = &pCodingParam->sSpatialLayers[pCtx->uiDependencyId]; | 577 | SSpatialLayerConfig* pDlp = &pCodingParam->sSpatialLayers[pCtx->uiDependencyId]; |
| 578 | SWelsSliceBs* pSliceBs = NULL; | 578 | SWelsSliceBs* pSliceBs = NULL; |
| 579 | const bool kbIsDynamicSlicingMode = (pDlp->sSliceCfg.uiSliceMode == SM_DYN_SLICE); | 579 | const bool kbIsDynamicSlicingMode = (pDlp->sSliceArgument.uiSliceMode == SM_SIZELIMITED_SLICE); |
| 580 | 580 | ||
| 581 | int32_t iLayerSize = 0; | 581 | int32_t iLayerSize = 0; |
| 582 | int32_t iNalIdxBase = pLbi->iNalCount; | 582 | int32_t iNalIdxBase = pLbi->iNalCount; |
| @@ -613,7 +613,7 @@ int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32 · 30 unmodified lines | |||
| 613 | ++ iSliceIdx; | 613 | ++ iSliceIdx; |
| 614 | ++ pSliceBs; | 614 | ++ pSliceBs; |
| 615 | } | 615 | } |
| 616 | } else { // for SM_DYN_SLICE | 616 | } else { // for SM_SIZELIMITED_SLICE |
| 617 | const int32_t kiPartitionCnt = iSliceCount; | 617 | const int32_t kiPartitionCnt = iSliceCount; |
| 618 | int32_t iPartitionIdx = 0; | 618 | int32_t iPartitionIdx = 0; |
| 619 | 619 | ||
| @@ -744,17 +744,16 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 124 unmodified lines | |||
| 744 | eNalRefIdc = pEncPEncCtx->eNalPriority; | 744 | eNalRefIdc = pEncPEncCtx->eNalPriority; |
| 745 | bNeedPrefix = pEncPEncCtx->bNeedPrefixNalFlag; | 745 | bNeedPrefix = pEncPEncCtx->bNeedPrefixNalFlag; |
| 746 | 746 | ||
| 747 | if (pParamD->sSliceCfg.uiSliceMode != SM_DYN_SLICE) { | 747 | if (pParamD->sSliceArgument.uiSliceMode != SM_SIZELIMITED_SLICE) { |
| 748 | int64_t iSliceStart = 0; | 748 | int64_t iSliceStart = 0; |
| 749 | bool bDsaFlag = false; | 749 | bool bDsaFlag = false; |
| 750 | iSliceIdx = pPrivateData->iSliceIndex; | 750 | iSliceIdx = pPrivateData->iSliceIndex; |
| 751 | pSlice = &pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx]; | 751 | pSlice = &pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx]; |
| 752 | pSliceBs = &pEncPEncCtx->pSliceBs[iSliceIdx]; | 752 | pSliceBs = &pEncPEncCtx->pSliceBs[iSliceIdx]; |
| 753 | 753 | ||
| 754 | bDsaFlag = (((pParamD->sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE) | 754 | bDsaFlag = ((pParamD->sSliceArgument.uiSliceMode == SM_FIXEDSLCNUM_SLICE) && |
| 755 | || (pParamD->sSliceCfg.uiSliceMode == SM_AUTO_SLICE)) && | ||
| 756 | pCodingParam->iMultipleThreadIdc > 1 && | 755 | pCodingParam->iMultipleThreadIdc > 1 && |
| 757 | pCodingParam->iMultipleThreadIdc >= pParamD->sSliceCfg.sSliceArgument.uiSliceNum); | 756 | pCodingParam->iMultipleThreadIdc >= pParamD->sSliceArgument.uiSliceNum); |
| 758 | if (bDsaFlag) | 757 | if (bDsaFlag) |
| 759 | iSliceStart = WelsTime(); | 758 | iSliceStart = WelsTime(); |
| 760 | 759 | ||
| @@ -838,7 +837,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 77 unmodified lines | |||
| 838 | &pEncPEncCtx->pSliceThreading->pSliceCodedEvent[iEventIdx]); // mean finished coding current pSlice | 837 | &pEncPEncCtx->pSliceThreading->pSliceCodedEvent[iEventIdx]); // mean finished coding current pSlice |
| 839 | WelsEventSignal ( | 838 | WelsEventSignal ( |
| 840 | &pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent); | 839 | &pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent); |
| 841 | } else { // for SM_DYN_SLICE parallelization | 840 | } else { // for SM_SIZELIMITED_SLICE parallelization |
| 842 | SSliceCtx* pSliceCtx = pCurDq->pSliceEncCtx; | 841 | SSliceCtx* pSliceCtx = pCurDq->pSliceEncCtx; |
| 843 | const int32_t kiPartitionId = iThreadIdx; | 842 | const int32_t kiPartitionId = iThreadIdx; |
| 844 | const int32_t kiSliceIdxStep = pEncPEncCtx->iActiveThreadsNum; | 843 | const int32_t kiSliceIdxStep = pEncPEncCtx->iActiveThreadsNum; |
| @@ -1090,9 +1089,9 @@ int32_t AdjustEnhanceLayer (sWelsEncCtx* pCtx, int32_t iCurDid) { · 245 unmodified lines | |||
| 1090 | // if using spatial base layer for complexity estimation | 1089 | // if using spatial base layer for complexity estimation |
| 1091 | 1090 | ||
| 1092 | const bool kbModelingFromSpatial = (pCtx->pCurDqLayer->pRefLayer != NULL && iCurDid > 0) | 1091 | const bool kbModelingFromSpatial = (pCtx->pCurDqLayer->pRefLayer != NULL && iCurDid > 0) |
| 1093 | && (pCtx->pSvcParam->sSpatialLayers[iCurDid - 1].sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE | 1092 | && (pCtx->pSvcParam->sSpatialLayers[iCurDid - 1].sSliceArgument.uiSliceMode == SM_FIXEDSLCNUM_SLICE |
| 1094 | && pCtx->pSvcParam->iMultipleThreadIdc >= pCtx->pSvcParam->sSpatialLayers[iCurDid - | 1093 | && pCtx->pSvcParam->iMultipleThreadIdc >= pCtx->pSvcParam->sSpatialLayers[iCurDid - |
| 1095 | 1].sSliceCfg.sSliceArgument.uiSliceNum); | 1094 | 1].sSliceArgument.uiSliceNum); |
| 1096 | 1095 | ||
| 1097 | if (kbModelingFromSpatial) { // using spatial base layer for complexity estimation | 1096 | if (kbModelingFromSpatial) { // using spatial base layer for complexity estimation |
| 1098 | // do not need adjust due to not different at both slices of consumed time | 1097 | // do not need adjust due to not different at both slices of consumed time |
| @@ -1156,13 +1155,13 @@ void TrackSliceConsumeTime (sWelsEncCtx* pCtx, int32_t* pDidList, const int32_t · 57 unmodified lines | |||
| 1156 | while (iSpatialIdx < iSpatialNum) { | 1155 | while (iSpatialIdx < iSpatialNum) { |
| 1157 | const int32_t kiDid = pDidList[iSpatialIdx]; | 1156 | const int32_t kiDid = pDidList[iSpatialIdx]; |
| 1158 | SSpatialLayerInternal* pDlp = &pPara->sDependencyLayers[kiDid]; | 1157 | SSpatialLayerInternal* pDlp = &pPara->sDependencyLayers[kiDid]; |
| 1159 | SSliceConfig* pMso = &pDlp->sSliceCfg; | 1158 | SSliceConfig* pSliceArgument = &pDlp->sSliceArgument; |
| 1160 | SDqLayer* pCurDq = pCtx->ppDqLayerList[kiDid]; | 1159 | SDqLayer* pCurDq = pCtx->ppDqLayerList[kiDid]; |
| 1161 | SSliceCtx* pSliceCtx = pCurDq->pSliceEncCtx; | 1160 | SSliceCtx* pSliceCtx = pCurDq->pSliceEncCtx; |
| 1162 | const uint32_t kuiCountSliceNum = pSliceCtx->iSliceNumInFrame; | 1161 | const uint32_t kuiCountSliceNum = pSliceCtx->iSliceNumInFrame; |
| 1163 | if (pCtx->pSliceThreading) { | 1162 | if (pCtx->pSliceThreading) { |
| 1164 | if (pCtx->pSliceThreading->pFSliceDiff | 1163 | if (pCtx->pSliceThreading->pFSliceDiff |
| 1165 | && ((pMso->uiSliceMode == SM_FIXEDSLCNUM_SLICE) || (pMso->uiSliceMode == SM_AUTO_SLICE)) | 1164 | && ((pSliceArgument->uiSliceMode == SM_FIXEDSLCNUM_SLICE) || (pSliceArgument->uiSliceMode == SM_AUTO_SLICE)) |
| 1166 | && pPara->iMultipleThreadIdc > 1 | 1165 | && pPara->iMultipleThreadIdc > 1 |
| 1167 | && pPara->iMultipleThreadIdc >= kuiCountSliceNum) { | 1166 | && pPara->iMultipleThreadIdc >= kuiCountSliceNum) { |
| 1168 | uint32_t i = 0; | 1167 | uint32_t i = 0; |