Showing the changes to codec/encoder/core/src/slice_multi_threading.cpp (1 of 57 files). Show all
Unified · Split
| @@ -56,7 +56,7 @@ · 55 unmodified lines | |||
| 56 | #include "svc_encode_slice.h" | 56 | #include "svc_encode_slice.h" |
| 57 | #include "deblocking.h" | 57 | #include "deblocking.h" |
| 58 | #include "svc_enc_golomb.h" | 58 | #include "svc_enc_golomb.h" |
| 59 | #include "crt_util_safe_x.h" // for safe crt like calls | 59 | #include "crt_util_safe_x.h" // for safe crt like calls |
| 60 | #include "rc.h" | 60 | #include "rc.h" |
| 61 | 61 | ||
| 62 | #include "cpu.h" | 62 | #include "cpu.h" |
| @@ -225,7 +225,7 @@ void DynamicAdjustSlicing (sWelsEncCtx* pCtx, · 162 unmodified lines | |||
| 225 | iMinimalMbNum = iNumMbInEachGom; | 225 | iMinimalMbNum = iNumMbInEachGom; |
| 226 | } | 226 | } |
| 227 | 227 | ||
| 228 | if (kiCountSliceNum < 2 || (kiCountSliceNum & 0x01)) // we need suppose uiSliceNum is even for multiple threading | 228 | if (kiCountSliceNum < 2 || (kiCountSliceNum & 0x01)) // we need suppose uiSliceNum is even for multiple threading |
| 229 | return; | 229 | return; |
| 230 | 230 | ||
| 231 | iMaximalMbNum = kiCountNumMb - (kiCountSliceNum - 1) * iMinimalMbNum; | 231 | iMaximalMbNum = kiCountNumMb - (kiCountSliceNum - 1) * iMinimalMbNum; |
| @@ -252,7 +252,7 @@ void DynamicAdjustSlicing (sWelsEncCtx* pCtx, · 20 unmodified lines | |||
| 252 | assert (iNumMbAssigning > 0); | 252 | assert (iNumMbAssigning > 0); |
| 253 | 253 | ||
| 254 | iMbNumLeft -= iNumMbAssigning; | 254 | iMbNumLeft -= iNumMbAssigning; |
| 255 | if (iMbNumLeft <= 0) { // error due to we can not support slice_skip now yet, do not adjust this time | 255 | if (iMbNumLeft <= 0) { // error due to we can not support slice_skip now yet, do not adjust this time |
| 256 | assert (0); | 256 | assert (0); |
| 257 | return; | 257 | return; |
| 258 | } | 258 | } |
| @@ -543,7 +543,7 @@ int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32 · 284 unmodified lines | |||
| 543 | assert (pSliceBs->bSliceCodedFlag); | 543 | assert (pSliceBs->bSliceCodedFlag); |
| 544 | #endif//MT_DEBUG_BS_WR | 544 | #endif//MT_DEBUG_BS_WR |
| 545 | 545 | ||
| 546 | memmove (pCtx->pFrameBs + pCtx->iPosBsBuffer, pSliceBs->pBs, pSliceBs->uiBsPos); // confirmed_safe_unsafe_usage | 546 | memmove (pCtx->pFrameBs + pCtx->iPosBsBuffer, pSliceBs->pBs, pSliceBs->uiBsPos); // confirmed_safe_unsafe_usage |
| 547 | pCtx->iPosBsBuffer += pSliceBs->uiBsPos; | 547 | pCtx->iPosBsBuffer += pSliceBs->uiBsPos; |
| 548 | 548 | ||
| 549 | iLayerSize += pSliceBs->uiBsPos; | 549 | iLayerSize += pSliceBs->uiBsPos; |
| @@ -575,7 +575,7 @@ int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32 · 25 unmodified lines | |||
| 575 | int32_t iNalIdx = 0; | 575 | int32_t iNalIdx = 0; |
| 576 | const int32_t iCountNal = pSliceBs->iNalIndex; | 576 | const int32_t iCountNal = pSliceBs->iNalIndex; |
| 577 | 577 | ||
| 578 | memmove (pCtx->pFrameBs + pCtx->iPosBsBuffer, pSliceBs->pBs, pSliceBs->uiBsPos); // confirmed_safe_unsafe_usage | 578 | memmove (pCtx->pFrameBs + pCtx->iPosBsBuffer, pSliceBs->pBs, pSliceBs->uiBsPos); // confirmed_safe_unsafe_usage |
| 579 | pCtx->iPosBsBuffer += pSliceBs->uiBsPos; | 579 | pCtx->iPosBsBuffer += pSliceBs->uiBsPos; |
| 580 | 580 | ||
| 581 | iLayerSize += pSliceBs->uiBsPos; | 581 | iLayerSize += pSliceBs->uiBsPos; |
| @@ -714,7 +714,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 132 unmodified lines | |||
| 714 | iWaitRet = WelsMultipleEventsWaitSingleBlocking (iEventCount, | 714 | iWaitRet = WelsMultipleEventsWaitSingleBlocking (iEventCount, |
| 715 | &pEventsList[0], | 715 | &pEventsList[0], |
| 716 | &pEncPEncCtx->pSliceThreading->pThreadMasterEvent[iEventIdx]); // blocking until at least one event is signalled | 716 | &pEncPEncCtx->pSliceThreading->pThreadMasterEvent[iEventIdx]); // blocking until at least one event is signalled |
| 717 | if (WELS_THREAD_ERROR_WAIT_OBJECT_0 == iWaitRet) { // start pSlice coding signal waited | 717 | if (WELS_THREAD_ERROR_WAIT_OBJECT_0 == iWaitRet) { // start pSlice coding signal waited |
| 718 | SLayerBSInfo* pLbi = pPrivateData->pLayerBs; | 718 | SLayerBSInfo* pLbi = pPrivateData->pLayerBs; |
| 719 | const int32_t kiCurDid = pEncPEncCtx->uiDependencyId; | 719 | const int32_t kiCurDid = pEncPEncCtx->uiDependencyId; |
| 720 | const int32_t kiCurTid = pEncPEncCtx->uiTemporalId; | 720 | const int32_t kiCurTid = pEncPEncCtx->uiTemporalId; |
| @@ -822,7 +822,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 101 unmodified lines | |||
| 822 | #endif//MT_DEBUG_BS_WR | 822 | #endif//MT_DEBUG_BS_WR |
| 823 | 823 | ||
| 824 | WelsEventSignal ( | 824 | WelsEventSignal ( |
| 825 | &pEncPEncCtx->pSliceThreading->pSliceCodedEvent[iEventIdx]); // mean finished coding current pSlice | 825 | &pEncPEncCtx->pSliceThreading->pSliceCodedEvent[iEventIdx]); // mean finished coding current pSlice |
| 826 | WelsEventSignal ( | 826 | WelsEventSignal ( |
| 827 | &pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent); | 827 | &pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent); |
| 828 | } else { // for SM_DYN_SLICE parallelization | 828 | } else { // for SM_DYN_SLICE parallelization |
| @@ -925,10 +925,10 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 96 unmodified lines | |||
| 925 | iSliceIdx += kiSliceIdxStep; | 925 | iSliceIdx += kiSliceIdxStep; |
| 926 | } | 926 | } |
| 927 | 927 | ||
| 928 | if (uiThrdRet) // any exception?? | 928 | if (uiThrdRet) // any exception?? |
| 929 | break; | 929 | break; |
| 930 | 930 | ||
| 931 | WelsEventSignal (&pEncPEncCtx->pSliceThreading->pSliceCodedEvent[iEventIdx]); // mean finished coding current pSlice | 931 | WelsEventSignal (&pEncPEncCtx->pSliceThreading->pSliceCodedEvent[iEventIdx]); // mean finished coding current pSlice |
| 932 | WelsEventSignal (&pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent); | 932 | WelsEventSignal (&pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent); |
| 933 | } | 933 | } |
| 934 | } else if (WELS_THREAD_ERROR_WAIT_OBJECT_0 + 1 == iWaitRet) { // exit thread signal | 934 | } else if (WELS_THREAD_ERROR_WAIT_OBJECT_0 + 1 == iWaitRet) { // exit thread signal |
| @@ -940,7 +940,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 5 unmodified lines | |||
| 940 | pCurDq = pEncPEncCtx->pCurDqLayer; | 940 | pCurDq = pEncPEncCtx->pCurDqLayer; |
| 941 | UpdateMbListNeighborParallel (pCurDq->pSliceEncCtx, pCurDq->sMbDataP, iSliceIdx); | 941 | UpdateMbListNeighborParallel (pCurDq->pSliceEncCtx, pCurDq->sMbDataP, iSliceIdx); |
| 942 | WelsEventSignal ( | 942 | WelsEventSignal ( |
| 943 | &pEncPEncCtx->pSliceThreading->pFinUpdateMbListEvent[iEventIdx]); // mean finished update pMb list for this pSlice | 943 | &pEncPEncCtx->pSliceThreading->pFinUpdateMbListEvent[iEventIdx]); // mean finished update pMb list for this pSlice |
| 944 | } else { // WELS_THREAD_ERROR_WAIT_TIMEOUT, or WELS_THREAD_ERROR_WAIT_FAILED | 944 | } else { // WELS_THREAD_ERROR_WAIT_TIMEOUT, or WELS_THREAD_ERROR_WAIT_FAILED |
| 945 | WelsLog (& (pEncPEncCtx->sLogCtx), WELS_LOG_WARNING, | 945 | WelsLog (& (pEncPEncCtx->sLogCtx), WELS_LOG_WARNING, |
| 946 | "[MT] CodingSliceThreadProc(), waiting pReadySliceCodingEvent[%d] failed(%d) and thread%d terminated!", iEventIdx, | 946 | "[MT] CodingSliceThreadProc(), waiting pReadySliceCodingEvent[%d] failed(%d) and thread%d terminated!", iEventIdx, |
| @@ -1061,7 +1061,7 @@ int32_t AdjustEnhanceLayer (sWelsEncCtx* pCtx, int32_t iCurDid) { · 114 unmodified lines | |||
| 1061 | && pCtx->pSvcParam->iMultipleThreadIdc >= pCtx->pSvcParam->sSpatialLayers[iCurDid - | 1061 | && pCtx->pSvcParam->iMultipleThreadIdc >= pCtx->pSvcParam->sSpatialLayers[iCurDid - |
| 1062 | 1].sSliceCfg.sSliceArgument.uiSliceNum); | 1062 | 1].sSliceCfg.sSliceArgument.uiSliceNum); |
| 1063 | 1063 | ||
| 1064 | if (kbModelingFromSpatial) { // using spatial base layer for complexity estimation | 1064 | if (kbModelingFromSpatial) { // using spatial base layer for complexity estimation |
| 1065 | // do not need adjust due to not different at both slices of consumed time | 1065 | // do not need adjust due to not different at both slices of consumed time |
| 1066 | iNeedAdj = NeedDynamicAdjust (pCtx->pSliceThreading->pSliceConsumeTime[iCurDid - 1], | 1066 | iNeedAdj = NeedDynamicAdjust (pCtx->pSliceThreading->pSliceConsumeTime[iCurDid - 1], |
| 1067 | pCtx->pCurDqLayer->pSliceEncCtx->iSliceNumInFrame); | 1067 | pCtx->pCurDqLayer->pSliceEncCtx->iSliceNumInFrame); |
| @@ -1071,7 +1071,7 @@ int32_t AdjustEnhanceLayer (sWelsEncCtx* pCtx, int32_t iCurDid) { · 3 unmodified lines | |||
| 1071 | pCtx->pSliceThreading->pSliceComplexRatio[iCurDid - 1], | 1071 | pCtx->pSliceThreading->pSliceComplexRatio[iCurDid - 1], |
| 1072 | iCurDid | 1072 | iCurDid |
| 1073 | ); | 1073 | ); |
| 1074 | } else { // use temporal layer for complexity estimation | 1074 | } else { // use temporal layer for complexity estimation |
| 1075 | // do not need adjust due to not different at both slices of consumed time | 1075 | // do not need adjust due to not different at both slices of consumed time |
| 1076 | iNeedAdj = NeedDynamicAdjust (pCtx->pSliceThreading->pSliceConsumeTime[iCurDid], | 1076 | iNeedAdj = NeedDynamicAdjust (pCtx->pSliceThreading->pSliceConsumeTime[iCurDid], |
| 1077 | pCtx->pCurDqLayer->pSliceEncCtx->iSliceNumInFrame); | 1077 | pCtx->pCurDqLayer->pSliceEncCtx->iSliceNumInFrame); |