Showing the changes to codec/encoder/core/src/slice_multi_threading.cpp (1 of 10 files). Show all
Unified · Split
| @@ -80,7 +80,7 @@ namespace WelsEnc { · 79 unmodified lines | |||
| 80 | void UpdateMbListNeighborParallel (SDqLayer* pCurDq, | 80 | void UpdateMbListNeighborParallel (SDqLayer* pCurDq, |
| 81 | SMB* pMbList, | 81 | SMB* pMbList, |
| 82 | const int32_t uiSliceIdc) { | 82 | const int32_t uiSliceIdc) { |
| 83 | SSliceCtx* pSliceCtx = pCurDq->pSliceEncCtx; | 83 | SSliceCtx* pSliceCtx = &pCurDq->sSliceEncCtx; |
| 84 | const uint16_t* kpMbMap = pSliceCtx->pOverallMbMap; | 84 | const uint16_t* kpMbMap = pSliceCtx->pOverallMbMap; |
| 85 | const int32_t kiMbWidth = pSliceCtx->iMbWidth; | 85 | const int32_t kiMbWidth = pSliceCtx->iMbWidth; |
| 86 | int32_t iIdx = pSliceCtx->pFirstMbInSlice[uiSliceIdc]; | 86 | int32_t iIdx = pSliceCtx->pFirstMbInSlice[uiSliceIdc]; |
| @@ -203,7 +203,7 @@ void DynamicAdjustSlicing (sWelsEncCtx* pCtx, · 116 unmodified lines | |||
| 203 | SDqLayer* pCurDqLayer, | 203 | SDqLayer* pCurDqLayer, |
| 204 | void* pComplexRatio, | 204 | void* pComplexRatio, |
| 205 | int32_t iCurDid) { | 205 | int32_t iCurDid) { |
| 206 | SSliceCtx* pSliceCtx = pCurDqLayer->pSliceEncCtx; | 206 | SSliceCtx* pSliceCtx = &pCurDqLayer->sSliceEncCtx; |
| 207 | const int32_t kiCountSliceNum = pSliceCtx->iSliceNumInFrame; | 207 | const int32_t kiCountSliceNum = pSliceCtx->iSliceNumInFrame; |
| 208 | const int32_t kiCountNumMb = pSliceCtx->iMbNumInFrame; | 208 | const int32_t kiCountNumMb = pSliceCtx->iMbNumInFrame; |
| 209 | int32_t iMinimalMbNum = | 209 | int32_t iMinimalMbNum = |
| @@ -818,7 +818,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 608 unmodified lines | |||
| 818 | "[MT] CodingSliceThreadProc(), coding_idx %d, uiSliceIdx %d, pSliceConsumeTime %d, iSliceSize %d, pFirstMbInSlice %d, count_num_mb_in_slice %d", | 818 | "[MT] CodingSliceThreadProc(), coding_idx %d, uiSliceIdx %d, pSliceConsumeTime %d, iSliceSize %d, pFirstMbInSlice %d, count_num_mb_in_slice %d", |
| 819 | pEncPEncCtx->iCodingIndex, iSliceIdx, | 819 | pEncPEncCtx->iCodingIndex, iSliceIdx, |
| 820 | pEncPEncCtx->pSliceThreading->pSliceConsumeTime[pEncPEncCtx->uiDependencyId][iSliceIdx], iSliceSize, | 820 | pEncPEncCtx->pSliceThreading->pSliceConsumeTime[pEncPEncCtx->uiDependencyId][iSliceIdx], iSliceSize, |
| 821 | pCurDq->pSliceEncCtx->pFirstMbInSlice[iSliceIdx], pCurDq->pSliceEncCtx->pCountMbNumInSlice[iSliceIdx]); | 821 | pCurDq->sSliceEncCtx.pFirstMbInSlice[iSliceIdx], pCurDq->sSliceEncCtx.pCountMbNumInSlice[iSliceIdx]); |
| 822 | } | 822 | } |
| 823 | 823 | ||
| 824 | #if defined(SLICE_INFO_OUTPUT) | 824 | #if defined(SLICE_INFO_OUTPUT) |
| @@ -840,7 +840,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 15 unmodified lines | |||
| 840 | WelsEventSignal ( | 840 | WelsEventSignal ( |
| 841 | &pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent); | 841 | &pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent); |
| 842 | } else { // for SM_SIZELIMITED_SLICE parallelization | 842 | } else { // for SM_SIZELIMITED_SLICE parallelization |
| 843 | SSliceCtx* pSliceCtx = pCurDq->pSliceEncCtx; | 843 | SSliceCtx* pSliceCtx = &pCurDq->sSliceEncCtx; |
| 844 | const int32_t kiPartitionId = iThreadIdx; | 844 | const int32_t kiPartitionId = iThreadIdx; |
| 845 | const int32_t kiSliceIdxStep = pEncPEncCtx->iActiveThreadsNum; | 845 | const int32_t kiSliceIdxStep = pEncPEncCtx->iActiveThreadsNum; |
| 846 | const int32_t kiFirstMbInPartition = pPrivateData->iStartMbIndex; // inclusive | 846 | const int32_t kiFirstMbInPartition = pPrivateData->iStartMbIndex; // inclusive |
| @@ -938,7 +938,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 91 unmodified lines | |||
| 938 | 938 | ||
| 939 | MT_TRACE_LOG (pEncPEncCtx, WELS_LOG_INFO, | 939 | MT_TRACE_LOG (pEncPEncCtx, WELS_LOG_INFO, |
| 940 | "[MT] CodingSliceThreadProc(), coding_idx %d, iPartitionId %d, uiSliceIdx %d, iSliceSize %d, count_mb_slice %d, iEndMbInPartition %d, pCurDq->pLastCodedMbIdxOfPartition[%d] %d\n", | 940 | "[MT] CodingSliceThreadProc(), coding_idx %d, iPartitionId %d, uiSliceIdx %d, iSliceSize %d, count_mb_slice %d, iEndMbInPartition %d, pCurDq->pLastCodedMbIdxOfPartition[%d] %d\n", |
| 941 | pEncPEncCtx->iCodingIndex, kiPartitionId, iSliceIdx, iSliceSize, pCurDq->pSliceEncCtx->pCountMbNumInSlice[iSliceIdx], | 941 | pEncPEncCtx->iCodingIndex, kiPartitionId, iSliceIdx, iSliceSize, pCurDq->sSliceEncCtx.pCountMbNumInSlice[iSliceIdx], |
| 942 | kiEndMbInPartition, kiPartitionId, pCurDq->pLastCodedMbIdxOfPartition[kiPartitionId]); | 942 | kiEndMbInPartition, kiPartitionId, pCurDq->pLastCodedMbIdxOfPartition[kiPartitionId]); |
| 943 | 943 | ||
| 944 | iAnyMbLeftInPartition = kiEndMbInPartition - (1 + pCurDq->pLastCodedMbIdxOfPartition[kiPartitionId]); | 944 | iAnyMbLeftInPartition = kiEndMbInPartition - (1 + pCurDq->pLastCodedMbIdxOfPartition[kiPartitionId]); |
| @@ -1062,10 +1062,10 @@ int32_t AdjustBaseLayer (sWelsEncCtx* pCtx) { · 117 unmodified lines | |||
| 1062 | #endif//MT_DEBUG | 1062 | #endif//MT_DEBUG |
| 1063 | 1063 | ||
| 1064 | pCtx->pCurDqLayer = pCurDq; | 1064 | pCtx->pCurDqLayer = pCurDq; |
| 1065 | memcpy ((pCtx->pSliceThreading->pSliceConsumeTime[0]), (pCurDq->pSliceEncCtx->pSliceConsumeTime), | 1065 | memcpy ((pCtx->pSliceThreading->pSliceConsumeTime[0]), (pCurDq->sSliceEncCtx.pSliceConsumeTime), |
| 1066 | pCurDq->pSliceEncCtx->iSliceNumInFrame * sizeof (uint32_t)); | 1066 | pCurDq->sSliceEncCtx.iSliceNumInFrame * sizeof (uint32_t)); |
| 1067 | // do not need adjust due to not different at both slices of consumed time | 1067 | // do not need adjust due to not different at both slices of consumed time |
| 1068 | iNeedAdj = NeedDynamicAdjust (pCtx->pSliceThreading->pSliceConsumeTime[0], pCurDq->pSliceEncCtx->iSliceNumInFrame); | 1068 | iNeedAdj = NeedDynamicAdjust (pCtx->pSliceThreading->pSliceConsumeTime[0], pCurDq->sSliceEncCtx.iSliceNumInFrame); |
| 1069 | if (iNeedAdj) | 1069 | if (iNeedAdj) |
| 1070 | DynamicAdjustSlicing (pCtx, | 1070 | DynamicAdjustSlicing (pCtx, |
| 1071 | pCurDq, | 1071 | pCurDq, |
| @@ -1095,13 +1095,13 @@ int32_t AdjustEnhanceLayer (sWelsEncCtx* pCtx, int32_t iCurDid) { · 23 unmodified lines | |||
| 1095 | && (pCtx->pSvcParam->sSpatialLayers[iCurDid - 1].sSliceArgument.uiSliceMode == SM_FIXEDSLCNUM_SLICE | 1095 | && (pCtx->pSvcParam->sSpatialLayers[iCurDid - 1].sSliceArgument.uiSliceMode == SM_FIXEDSLCNUM_SLICE |
| 1096 | && pCtx->pSvcParam->iMultipleThreadIdc >= pCtx->pSvcParam->sSpatialLayers[iCurDid - | 1096 | && pCtx->pSvcParam->iMultipleThreadIdc >= pCtx->pSvcParam->sSpatialLayers[iCurDid - |
| 1097 | 1].sSliceArgument.uiSliceNum); | 1097 | 1].sSliceArgument.uiSliceNum); |
| 1098 | memcpy ((pCtx->pSliceThreading->pSliceConsumeTime[iCurDid]), (pCtx->pCurDqLayer->pSliceEncCtx->pSliceConsumeTime), | 1098 | memcpy ((pCtx->pSliceThreading->pSliceConsumeTime[iCurDid]), (pCtx->pCurDqLayer->sSliceEncCtx.pSliceConsumeTime), |
| 1099 | pCtx->pCurDqLayer->pSliceEncCtx->iSliceNumInFrame * sizeof (uint32_t)); | 1099 | pCtx->pCurDqLayer->sSliceEncCtx.iSliceNumInFrame * sizeof (uint32_t)); |
| 1100 | 1100 | ||
| 1101 | if (kbModelingFromSpatial) { // using spatial base layer for complexity estimation | 1101 | if (kbModelingFromSpatial) { // using spatial base layer for complexity estimation |
| 1102 | // do not need adjust due to not different at both slices of consumed time | 1102 | // do not need adjust due to not different at both slices of consumed time |
| 1103 | iNeedAdj = NeedDynamicAdjust (pCtx->pSliceThreading->pSliceConsumeTime[iCurDid - 1], | 1103 | iNeedAdj = NeedDynamicAdjust (pCtx->pSliceThreading->pSliceConsumeTime[iCurDid - 1], |
| 1104 | pCtx->pCurDqLayer->pSliceEncCtx->iSliceNumInFrame); | 1104 | pCtx->pCurDqLayer->sSliceEncCtx.iSliceNumInFrame); |
| 1105 | if (iNeedAdj) | 1105 | if (iNeedAdj) |
| 1106 | DynamicAdjustSlicing (pCtx, | 1106 | DynamicAdjustSlicing (pCtx, |
| 1107 | pCtx->pCurDqLayer, | 1107 | pCtx->pCurDqLayer, |
| @@ -1111,7 +1111,7 @@ int32_t AdjustEnhanceLayer (sWelsEncCtx* pCtx, int32_t iCurDid) { · 3 unmodified lines | |||
| 1111 | } else { // use temporal layer for complexity estimation | 1111 | } else { // use temporal layer for complexity estimation |
| 1112 | // do not need adjust due to not different at both slices of consumed time | 1112 | // do not need adjust due to not different at both slices of consumed time |
| 1113 | iNeedAdj = NeedDynamicAdjust (pCtx->pSliceThreading->pSliceConsumeTime[iCurDid], | 1113 | iNeedAdj = NeedDynamicAdjust (pCtx->pSliceThreading->pSliceConsumeTime[iCurDid], |
| 1114 | pCtx->pCurDqLayer->pSliceEncCtx->iSliceNumInFrame); | 1114 | pCtx->pCurDqLayer->sSliceEncCtx.iSliceNumInFrame); |
| 1115 | if (iNeedAdj) | 1115 | if (iNeedAdj) |
| 1116 | DynamicAdjustSlicing (pCtx, | 1116 | DynamicAdjustSlicing (pCtx, |
| 1117 | pCtx->pCurDqLayer, | 1117 | pCtx->pCurDqLayer, |
| @@ -1136,7 +1136,7 @@ int32_t AdjustEnhanceLayer (sWelsEncCtx* pCtx, int32_t iCurDid) { · 18 unmodified lines | |||
| 1136 | 1136 | ||
| 1137 | #if defined(MT_DEBUG) | 1137 | #if defined(MT_DEBUG) |
| 1138 | void TrackSliceComplexities (sWelsEncCtx* pCtx, const int32_t iCurDid) { | 1138 | void TrackSliceComplexities (sWelsEncCtx* pCtx, const int32_t iCurDid) { |
| 1139 | const int32_t kiCountSliceNum = pCtx->pCurDqLayer->pSliceEncCtx->iSliceNumInFrame; | 1139 | const int32_t kiCountSliceNum = pCtx->pCurDqLayer->sSliceEncCtx.iSliceNumInFrame; |
| 1140 | if (kiCountSliceNum > 0) { | 1140 | if (kiCountSliceNum > 0) { |
| 1141 | int32_t iSliceIdx = 0; | 1141 | int32_t iSliceIdx = 0; |
| 1142 | do { | 1142 | do { |
| @@ -1162,7 +1162,7 @@ void TrackSliceConsumeTime (sWelsEncCtx* pCtx, int32_t* pDidList, const int32_t · 19 unmodified lines | |||
| 1162 | SSpatialLayerInternal* pDlp = &pPara->sDependencyLayers[kiDid]; | 1162 | SSpatialLayerInternal* pDlp = &pPara->sDependencyLayers[kiDid]; |
| 1163 | SSliceConfig* pSliceArgument = &pDlp->sSliceArgument; | 1163 | SSliceConfig* pSliceArgument = &pDlp->sSliceArgument; |
| 1164 | SDqLayer* pCurDq = pCtx->ppDqLayerList[kiDid]; | 1164 | SDqLayer* pCurDq = pCtx->ppDqLayerList[kiDid]; |
| 1165 | SSliceCtx* pSliceCtx = pCurDq->pSliceEncCtx; | 1165 | SSliceCtx* pSliceCtx = &pCurDq->sSliceEncCtx; |
| 1166 | const uint32_t kuiCountSliceNum = pSliceCtx->iSliceNumInFrame; | 1166 | const uint32_t kuiCountSliceNum = pSliceCtx->iSliceNumInFrame; |
| 1167 | if (pCtx->pSliceThreading) { | 1167 | if (pCtx->pSliceThreading) { |
| 1168 | if (pCtx->pSliceThreading->pFSliceDiff | 1168 | if (pCtx->pSliceThreading->pFSliceDiff |