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