Showing the changes to codec/encoder/core/src/slice_multi_threading.cpp (1 of 7 files). Show all
Unified · Split
| @@ -689,18 +689,16 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 688 unmodified lines | ||
| 689 | 689 | SSliceCtx* pSliceCtx = &pCurDq->sSliceEncCtx; |
| 690 | 690 | const int32_t kiPartitionId = iThreadIdx; |
| 691 | 691 | const int32_t kiSliceIdxStep = pEncPEncCtx->iActiveThreadsNum; |
| 692 | − const int32_t kiFirstMbInPartition = pPrivateData->iStartMbIndex; // inclusive | |
| 693 | − const int32_t kiEndMbInPartition = pPrivateData->iEndMbIndex; // exclusive | |
| 694 | − int32_t iAnyMbLeftInPartition = kiEndMbInPartition - kiFirstMbInPartition; | |
| 695 | − SSpatialLayerInternal* pParamInternal = &pCodingParam->sDependencyLayers[kiCurDid]; | |
| 692 | + const int32_t kiFirstMbInPartition = pCurDq->pFirstMbIdxOfPartition[kiPartitionId]; | |
| 693 | + const int32_t kiEndMbIdxInPartition = pCurDq->pEndMbIdxOfPartition[kiPartitionId]; | |
| 694 | + int32_t iAnyMbLeftInPartition = kiEndMbIdxInPartition - kiFirstMbInPartition + 1; | |
| 695 | + SSpatialLayerInternal *pParamInternal = &pCodingParam->sDependencyLayers[kiCurDid]; | |
| 696 | 696 | iSliceIdx = pPrivateData->iSliceIndex; |
| 697 | 697 | SSliceHeaderExt* pStartSliceHeaderExt = &pCurDq->ppSliceInLayer[iSliceIdx]->sSliceHeaderExt; |
| 698 | 698 | pStartSliceHeaderExt->sSliceHeader.iFirstMbInSlice = kiFirstMbInPartition; |
| 699 | − pCurDq->pNumSliceCodedOfPartition[kiPartitionId] = | |
| 700 | − 1; // one pSlice per partition intialized, dynamic slicing inside | |
| 701 | − pCurDq->pLastMbIdxOfPartition[kiPartitionId] = kiEndMbInPartition - 1; | |
| 702 | − | |
| 699 | + pCurDq->pNumSliceCodedOfPartition[kiPartitionId] = 1; | |
| 703 | 700 | pCurDq->pLastCodedMbIdxOfPartition[kiPartitionId] = 0; |
| 701 | + | |
| 704 | 702 | while (iAnyMbLeftInPartition > 0) { |
| 705 | 703 | if (iSliceIdx >= pSliceCtx->iMaxSliceNumConstraint) { |
| 706 | 704 | // TODO: need exception handler for not large enough of MAX_SLICES_NUM related memory usage |
| @@ -777,9 +775,9 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 70 unmodified lines | ||
| 777 | 775 | "[MT] CodingSliceThreadProc(), coding_idx %d, iPartitionId %d, uiSliceIdx %d, iSliceSize %d, count_mb_slice %d, iEndMbInPartition %d, pCurDq->pLastCodedMbIdxOfPartition[%d] %d\n", |
| 778 | 776 | pEncPEncCtx->iCodingIndex, kiPartitionId, iSliceIdx, iSliceSize, |
| 779 | 777 | pCurDq->ppSliceInLayer[iSliceIdx]->iCountMbNumInSlice, |
| 780 | − kiEndMbInPartition, kiPartitionId, pCurDq->pLastCodedMbIdxOfPartition[kiPartitionId]); | |
| 778 | + kiEndMbIdxInPartition, kiPartitionId, pCurDq->pLastCodedMbIdxOfPartition[kiPartitionId]); | |
| 781 | 779 | |
| 782 | − iAnyMbLeftInPartition = kiEndMbInPartition - (1 + pCurDq->pLastCodedMbIdxOfPartition[kiPartitionId]); | |
| 780 | + iAnyMbLeftInPartition = kiEndMbIdxInPartition - pCurDq->pLastCodedMbIdxOfPartition[kiPartitionId]; | |
| 783 | 781 | iSliceIdx += kiSliceIdxStep; |
| 784 | 782 | } |
| 785 | 783 | |
| @@ -838,14 +836,11 @@ int32_t CreateSliceThreads (sWelsEncCtx* pCtx) { · 52 unmodified lines | ||
| 838 | 836 | |
| 839 | 837 | int32_t FiredSliceThreads (sWelsEncCtx* pCtx, SSliceThreadPrivateData* pPriData, WELS_EVENT* pEventsList, |
| 840 | 838 | WELS_EVENT* pMasterEventsList, SFrameBSInfo* pFrameBsInfo, |
| 841 | − const uint32_t uiNumThreads, SSliceCtx* pSliceCtx, const bool bIsDynamicSlicingMode) { | |
| 842 | − int32_t iEndMbIdx = 0; | |
| 839 | + const uint32_t uiNumThreads) { | |
| 843 | 840 | int32_t iIdx = 0; |
| 844 | 841 | const int32_t kiEventCnt = uiNumThreads; |
| 845 | 842 | int32_t iLayerBsIdx = pCtx->pOut->iLayerBsIndex; |
| 846 | 843 | SLayerBSInfo* pLbi = &pFrameBsInfo->sLayerInfo[iLayerBsIdx]; |
| 847 | − SSlice** ppSliceInLayer = pCtx->pCurDqLayer->ppSliceInLayer; | |
| 848 | − | |
| 849 | 844 | |
| 850 | 845 | if (pPriData == NULL || pFrameBsInfo == NULL || pLbi == NULL || kiEventCnt <= 0 || pEventsList == NULL) { |
| 851 | 846 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, |
| @@ -854,17 +849,6 @@ int32_t FiredSliceThreads (sWelsEncCtx* pCtx, SSliceThreadPrivateData* pPriData, · 2 unmodified lines | ||
| 854 | 849 | return 1; |
| 855 | 850 | } |
| 856 | 851 | |
| 857 | − //////////////////////////////////////// | |
| 858 | − if (bIsDynamicSlicingMode) { | |
| 859 | − iEndMbIdx = pSliceCtx->iMbNumInFrame; | |
| 860 | − for (iIdx = kiEventCnt - 1; iIdx >= 0; --iIdx) { | |
| 861 | − const int32_t iFirstMbIdx = ppSliceInLayer[iIdx]->sSliceHeaderExt.sSliceHeader.iFirstMbInSlice; | |
| 862 | − pPriData[iIdx].iStartMbIndex = iFirstMbIdx; | |
| 863 | − pPriData[iIdx].iEndMbIndex = iEndMbIdx; | |
| 864 | − iEndMbIdx = iFirstMbIdx; | |
| 865 | − } | |
| 866 | − } | |
| 867 | − | |
| 868 | 852 | pLbi->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; |
| 869 | 853 | pLbi->uiLayerType = VIDEO_CODING_LAYER; |
| 870 | 854 | pLbi->uiSpatialId = pCtx->uiDependencyId; |
| @@ -876,6 +860,7 @@ int32_t FiredSliceThreads (sWelsEncCtx* pCtx, SSliceThreadPrivateData* pPriData, · 5 unmodified lines | ||
| 876 | 860 | while (iIdx < kiEventCnt) { |
| 877 | 861 | pPriData[iIdx].pFrameBsInfo = pFrameBsInfo; |
| 878 | 862 | pPriData[iIdx].iSliceIndex = iIdx; |
| 863 | + | |
| 879 | 864 | WelsEventSignal (&pEventsList[iIdx]); |
| 880 | 865 | WelsEventSignal (&pMasterEventsList[iIdx]); |
| 881 | 866 | |