History

Multi-thread-fixed:RBC#1680:ppSliceInLayer instead of pSliceInLayer for all slice buffer management

huade committed 9 years ago

Commit 8ff579b1 parent 01e31ff11 files · +162 −153Browse files

Showing the changes to codec/encoder/core/src/slice_multi_threading.cpp (1 of 11 files). Show all

Unified · Split

codec/encoder/core/src/slice_multi_threading.cpp+45−41
@@ -81,7 +81,7 @@ void UpdateMbListNeighborParallel (SDqLayer* pCurDq, · 80 unmodified lines
81 SMB* pMbList,81 SMB* pMbList,
82 const int32_t uiSliceIdc) {82 const int32_t uiSliceIdc) {
83 SSliceCtx* pSliceCtx = &pCurDq->sSliceEncCtx;83 SSliceCtx* pSliceCtx = &pCurDq->sSliceEncCtx;
84 SSlice* pUpdateSlice = &pCurDq->sLayerInfo.pSliceInLayer[uiSliceIdc];84 SSlice* pUpdateSlice = pCurDq->ppSliceInLayer[uiSliceIdc];
85 const int32_t kiMbWidth = pSliceCtx->iMbWidth;85 const int32_t kiMbWidth = pSliceCtx->iMbWidth;
86 int32_t iIdx = pUpdateSlice->sSliceHeaderExt.sSliceHeader.iFirstMbInSlice;86 int32_t iIdx = pUpdateSlice->sSliceHeaderExt.sSliceHeader.iFirstMbInSlice;
87 const int32_t kiEndMbInSlice = iIdx + pUpdateSlice->iCountMbNumInSlice - 1;87 const int32_t kiEndMbInSlice = iIdx + pUpdateSlice->iCountMbNumInSlice - 1;
@@ -94,7 +94,7 @@ void UpdateMbListNeighborParallel (SDqLayer* pCurDq, · 6 unmodified lines
94 94
95void CalcSliceComplexRatio (SDqLayer* pCurDq) {95void CalcSliceComplexRatio (SDqLayer* pCurDq) {
96 SSliceCtx* pSliceCtx = &pCurDq->sSliceEncCtx;96 SSliceCtx* pSliceCtx = &pCurDq->sSliceEncCtx;
97 SSlice* pSliceInLayer = pCurDq->sLayerInfo.pSliceInLayer;97 SSlice** ppSliceInLayer = pCurDq->ppSliceInLayer;
98 int32_t iSumAv = 0;98 int32_t iSumAv = 0;
99 const int32_t kiSliceCount = pSliceCtx->iSliceNumInFrame;99 const int32_t kiSliceCount = pSliceCtx->iSliceNumInFrame;
100 int32_t iSliceIdx = 0;100 int32_t iSliceIdx = 0;
@@ -103,23 +103,24 @@ void CalcSliceComplexRatio (SDqLayer* pCurDq) { · 2 unmodified lines
103 WelsEmms();103 WelsEmms();
104 104
105 while (iSliceIdx < kiSliceCount) {105 while (iSliceIdx < kiSliceCount) {
106 iAvI[iSliceIdx] = WELS_DIV_ROUND (INT_MULTIPLY * pSliceInLayer[iSliceIdx].iCountMbNumInSlice,106 iAvI[iSliceIdx] = WELS_DIV_ROUND (INT_MULTIPLY * ppSliceInLayer[iSliceIdx]->iCountMbNumInSlice,
107 pSliceInLayer[iSliceIdx].uiSliceConsumeTime);107 ppSliceInLayer[iSliceIdx]->uiSliceConsumeTime);
108 MT_TRACE_LOG (NULL, WELS_LOG_DEBUG, "[MT] CalcSliceComplexRatio(), uiSliceConsumeTime[%d]= %d us, slice_run= %d",108 MT_TRACE_LOG (NULL, WELS_LOG_DEBUG, "[MT] CalcSliceComplexRatio(), uiSliceConsumeTime[%d]= %d us, slice_run= %d",
109 iSliceIdx,109 iSliceIdx,
110 pSliceInLayer[iSliceIdx].uiSliceConsumeTime, pSliceInLayer[iSliceIdx].iCountMbNumInSlice);110 ppSliceInLayer[iSliceIdx]->uiSliceConsumeTime, ppSliceInLayer[iSliceIdx]->iCountMbNumInSlice);
111 iSumAv += iAvI[iSliceIdx];111 iSumAv += iAvI[iSliceIdx];
112 112
113 ++ iSliceIdx;113 ++ iSliceIdx;
114 }114 }
115 while (-- iSliceIdx >= 0) {115 while (-- iSliceIdx >= 0) {
116 pSliceInLayer[iSliceIdx].iSliceComplexRatio = WELS_DIV_ROUND (INT_MULTIPLY * iAvI[iSliceIdx], iSumAv);116 ppSliceInLayer[iSliceIdx]->iSliceComplexRatio = WELS_DIV_ROUND (INT_MULTIPLY * iAvI[iSliceIdx], iSumAv);
117 }117 }
118}118}
119 119
120int32_t NeedDynamicAdjust (SSlice* pSliceInLayer, const int32_t iSliceNum) {120int32_t NeedDynamicAdjust (SSlice** ppSliceInLayer, const int32_t iSliceNum) {
121 if (NULL == pSliceInLayer)121 if ( NULL == ppSliceInLayer ) {
122 return false;122 return false;
123 }
123 124
124 uint32_t uiTotalConsume = 0;125 uint32_t uiTotalConsume = 0;
125 int32_t iSliceIdx = 0;126 int32_t iSliceIdx = 0;
@@ -128,7 +129,10 @@ int32_t NeedDynamicAdjust (SSlice* pSliceInLayer, const int32_t iSliceNum) { · 2 unmodified lines
128 WelsEmms();129 WelsEmms();
129 130
130 while (iSliceIdx < iSliceNum) {131 while (iSliceIdx < iSliceNum) {
131 uiTotalConsume += pSliceInLayer[iSliceIdx].uiSliceConsumeTime;132 if ( NULL == ppSliceInLayer[iSliceIdx] ) {
133 return false;
134 }
135 uiTotalConsume += ppSliceInLayer[iSliceIdx]->uiSliceConsumeTime;
132 iSliceIdx ++;136 iSliceIdx ++;
133 }137 }
134 if (uiTotalConsume == 0) {138 if (uiTotalConsume == 0) {
@@ -143,7 +147,7 @@ int32_t NeedDynamicAdjust (SSlice* pSliceInLayer, const int32_t iSliceNum) { · 8 unmodified lines
143 float fRmse = .0f; // root mean square error of pSlice consume ratios147 float fRmse = .0f; // root mean square error of pSlice consume ratios
144 const float kfMeanRatio = 1.0f / iSliceNum;148 const float kfMeanRatio = 1.0f / iSliceNum;
145 do {149 do {
146 const float fRatio = 1.0f * pSliceInLayer[iSliceIdx].uiSliceConsumeTime / uiTotalConsume;150 const float fRatio = 1.0f * ppSliceInLayer[iSliceIdx]->uiSliceConsumeTime / uiTotalConsume;
147 const float fDiffRatio = fRatio - kfMeanRatio;151 const float fDiffRatio = fRatio - kfMeanRatio;
148 fRmse += (fDiffRatio * fDiffRatio);152 fRmse += (fDiffRatio * fDiffRatio);
149 ++ iSliceIdx;153 ++ iSliceIdx;
@@ -170,7 +174,7 @@ void DynamicAdjustSlicing (sWelsEncCtx* pCtx, · 20 unmodified lines
170 SDqLayer* pCurDqLayer,174 SDqLayer* pCurDqLayer,
171 int32_t iCurDid) {175 int32_t iCurDid) {
172 SSliceCtx* pSliceCtx = &pCurDqLayer->sSliceEncCtx;176 SSliceCtx* pSliceCtx = &pCurDqLayer->sSliceEncCtx;
173 SSlice* pSliceInLayer = pCurDqLayer->sLayerInfo.pSliceInLayer;177 SSlice** ppSliceInLayer = pCurDqLayer->ppSliceInLayer;
174 const int32_t kiCountSliceNum = pSliceCtx->iSliceNumInFrame;178 const int32_t kiCountSliceNum = pSliceCtx->iSliceNumInFrame;
175 const int32_t kiCountNumMb = pSliceCtx->iMbNumInFrame;179 const int32_t kiCountNumMb = pSliceCtx->iMbNumInFrame;
176 int32_t iMinimalMbNum =180 int32_t iMinimalMbNum =
@@ -212,7 +216,7 @@ void DynamicAdjustSlicing (sWelsEncCtx* pCtx, · 35 unmodified lines
212 216
213 iSliceIdx = 0;217 iSliceIdx = 0;
214 while (iSliceIdx + 1 < kiCountSliceNum) {218 while (iSliceIdx + 1 < kiCountSliceNum) {
215 int32_t iNumMbAssigning = WELS_DIV_ROUND (kiCountNumMb * pSliceInLayer[iSliceIdx].iSliceComplexRatio, INT_MULTIPLY);219 int32_t iNumMbAssigning = WELS_DIV_ROUND (kiCountNumMb * ppSliceInLayer[iSliceIdx]->iSliceComplexRatio, INT_MULTIPLY);
216 220
217 // GOM boundary aligned221 // GOM boundary aligned
218 if (pCtx->pSvcParam->iRCMode != RC_OFF_MODE) {222 if (pCtx->pSvcParam->iRCMode != RC_OFF_MODE) {
@@ -235,8 +239,8 @@ void DynamicAdjustSlicing (sWelsEncCtx* pCtx, · 16 unmodified lines
235 iRunLen[iSliceIdx] = iNumMbAssigning;239 iRunLen[iSliceIdx] = iNumMbAssigning;
236 MT_TRACE_LOG (& (pCtx->sLogCtx), WELS_LOG_DEBUG,240 MT_TRACE_LOG (& (pCtx->sLogCtx), WELS_LOG_DEBUG,
237 "[MT] DynamicAdjustSlicing(), uiSliceIdx= %d, iSliceComplexRatio= %.2f, slice_run_org= %d, slice_run_adj= %d",241 "[MT] DynamicAdjustSlicing(), uiSliceIdx= %d, iSliceComplexRatio= %.2f, slice_run_org= %d, slice_run_adj= %d",
238 iSliceIdx, pSliceInLayer[iSliceIdx].iSliceComplexRatio * 1.0f / INT_MULTIPLY,242 iSliceIdx, ppSliceInLayer[iSliceIdx]->iSliceComplexRatio * 1.0f / INT_MULTIPLY,
239 pSliceInLayer[iSliceIdx].iCountMbNumInSlice,243 ppSliceInLayer[iSliceIdx]->iCountMbNumInSlice,
240 iNumMbAssigning);244 iNumMbAssigning);
241 ++ iSliceIdx;245 ++ iSliceIdx;
242 iMaximalMbNum = iMbNumLeft - (kiCountSliceNum - iSliceIdx - 1) * iMinimalMbNum; // get maximal num_mb in left parts246 iMaximalMbNum = iMbNumLeft - (kiCountSliceNum - iSliceIdx - 1) * iMinimalMbNum; // get maximal num_mb in left parts
@@ -244,9 +248,8 @@ void DynamicAdjustSlicing (sWelsEncCtx* pCtx, · 1 unmodified line
244 iRunLen[iSliceIdx] = iMbNumLeft;248 iRunLen[iSliceIdx] = iMbNumLeft;
245 MT_TRACE_LOG (& (pCtx->sLogCtx), WELS_LOG_DEBUG,249 MT_TRACE_LOG (& (pCtx->sLogCtx), WELS_LOG_DEBUG,
246 "[MT] DynamicAdjustSlicing(), iSliceIdx= %d, pSliceComplexRatio= %.2f, slice_run_org= %d, slice_run_adj= %d",250 "[MT] DynamicAdjustSlicing(), iSliceIdx= %d, pSliceComplexRatio= %.2f, slice_run_org= %d, slice_run_adj= %d",
247 iSliceIdx, pSliceInLayer[iSliceIdx].iSliceComplexRatio * 1.0f / INT_MULTIPLY,251 iSliceIdx, ppSliceInLayer[iSliceIdx]->iSliceComplexRatio * 1.0f / INT_MULTIPLY,
248 pSliceInLayer[iSliceIdx].iCountMbNumInSlice, iMbNumLeft);252 ppSliceInLayer[iSliceIdx]->iCountMbNumInSlice, iMbNumLeft);
249
250 pCurDqLayer->bNeedAdjustingSlicing = !DynamicAdjustSlicePEncCtxAll (pCurDqLayer, iRunLen);253 pCurDqLayer->bNeedAdjustingSlicing = !DynamicAdjustSlicePEncCtxAll (pCurDqLayer, iRunLen);
251}254}
252 255
@@ -438,7 +441,7 @@ void ReleaseMtResource (sWelsEncCtx** ppCtx) { · 185 unmodified lines
438int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32_t iSliceCount) {441int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32_t iSliceCount) {
439 SWelsSvcCodingParam* pCodingParam = pCtx->pSvcParam;442 SWelsSvcCodingParam* pCodingParam = pCtx->pSvcParam;
440 SSpatialLayerConfig* pDlp = &pCodingParam->sSpatialLayers[pCtx->uiDependencyId];443 SSpatialLayerConfig* pDlp = &pCodingParam->sSpatialLayers[pCtx->uiDependencyId];
441 SSlice* pSliceInlayer = pCtx->pCurDqLayer->sLayerInfo.pSliceInLayer;444 SSlice** ppSliceInlayer = pCtx->pCurDqLayer->ppSliceInLayer;
442 SWelsSliceBs* pSliceBs = NULL;445 SWelsSliceBs* pSliceBs = NULL;
443 const bool kbIsDynamicSlicingMode = (pDlp->sSliceArgument.uiSliceMode == SM_SIZELIMITED_SLICE);446 const bool kbIsDynamicSlicingMode = (pDlp->sSliceArgument.uiSliceMode == SM_SIZELIMITED_SLICE);
444 447
@@ -449,7 +452,7 @@ int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32 · 4 unmodified lines
449 if (!kbIsDynamicSlicingMode) {452 if (!kbIsDynamicSlicingMode) {
450 iNalIdxBase = pLbi->iNalCount = 0;453 iNalIdxBase = pLbi->iNalCount = 0;
451 while (iSliceIdx < iSliceCount) {454 while (iSliceIdx < iSliceCount) {
452 pSliceBs = &pSliceInlayer[iSliceIdx].sSliceBs;455 pSliceBs = &ppSliceInlayer[iSliceIdx]->sSliceBs;
453 if (pSliceBs != NULL && pSliceBs->uiBsPos > 0) {456 if (pSliceBs != NULL && pSliceBs->uiBsPos > 0) {
454 int32_t iNalIdx = 0;457 int32_t iNalIdx = 0;
455 const int32_t iCountNal = pSliceBs->iNalIndex;458 const int32_t iCountNal = pSliceBs->iNalIndex;
@@ -484,7 +487,7 @@ int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32 · 28 unmodified lines
484 487
485 iSliceIdx = iPartitionIdx;488 iSliceIdx = iPartitionIdx;
486 while (iIdx < kiCountSlicesCoded) {489 while (iIdx < kiCountSlicesCoded) {
487 pSliceBs = &pSliceInlayer[iSliceIdx].sSliceBs;490 pSliceBs = &ppSliceInlayer[iSliceIdx]->sSliceBs;
488 if (pSliceBs != NULL && pSliceBs->uiBsPos > 0) {491 if (pSliceBs != NULL && pSliceBs->uiBsPos > 0) {
489 memmove (pCtx->pFrameBs + pCtx->iPosBsBuffer, pSliceBs->pBs, pSliceBs->uiBsPos); // confirmed_safe_unsafe_usage492 memmove (pCtx->pFrameBs + pCtx->iPosBsBuffer, pSliceBs->pBs, pSliceBs->uiBsPos); // confirmed_safe_unsafe_usage
490 pCtx->iPosBsBuffer += pSliceBs->uiBsPos;493 pCtx->iPosBsBuffer += pSliceBs->uiBsPos;
@@ -600,7 +603,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 109 unmodified lines
600 int64_t iSliceStart = 0;603 int64_t iSliceStart = 0;
601 bool bDsaFlag = false;604 bool bDsaFlag = false;
602 iSliceIdx = pPrivateData->iSliceIndex;605 iSliceIdx = pPrivateData->iSliceIndex;
603 pSlice = &pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx];606 pSlice = pCurDq->ppSliceInLayer[iSliceIdx];
604 pSliceBs = &pSlice->sSliceBs;607 pSliceBs = &pSlice->sSliceBs;
605 608
606 bDsaFlag = ((pParamD->sSliceArgument.uiSliceMode == SM_FIXEDSLCNUM_SLICE) &&609 bDsaFlag = ((pParamD->sSliceArgument.uiSliceMode == SM_FIXEDSLCNUM_SLICE) &&
@@ -653,14 +656,14 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 46 unmodified lines
653 pEncPEncCtx->pFuncList->pfDeblocking.pfDeblockingFilterSlice (pCurDq, pEncPEncCtx->pFuncList, iSliceIdx);656 pEncPEncCtx->pFuncList->pfDeblocking.pfDeblockingFilterSlice (pCurDq, pEncPEncCtx->pFuncList, iSliceIdx);
654 657
655 if (bDsaFlag) {658 if (bDsaFlag) {
656 pEncPEncCtx->pCurDqLayer->sLayerInfo.pSliceInLayer[iSliceIdx].uiSliceConsumeTime = (uint32_t) (659 pEncPEncCtx->pCurDqLayer->ppSliceInLayer[iSliceIdx]->uiSliceConsumeTime = (uint32_t) (
657 WelsTime() - iSliceStart);660 WelsTime() - iSliceStart);
658 MT_TRACE_LOG (& (pEncPEncCtx->sLogCtx), WELS_LOG_INFO,661 MT_TRACE_LOG (& (pEncPEncCtx->sLogCtx), WELS_LOG_INFO,
659 "[MT] CodingSliceThreadProc(), coding_idx %d, uiSliceIdx %d, uiSliceConsumeTime %d, iSliceSize %d, iFirstMbInSlice %d, count_num_mb_in_slice %d",662 "[MT] CodingSliceThreadProc(), coding_idx %d, uiSliceIdx %d, uiSliceConsumeTime %d, iSliceSize %d, iFirstMbInSlice %d, count_num_mb_in_slice %d",
660 pEncPEncCtx->iCodingIndex, iSliceIdx,663 pEncPEncCtx->iCodingIndex, iSliceIdx,
661 pEncPEncCtx->pCurDqLayer->sLayerInfo.pSliceInLayer[iSliceIdx].uiSliceConsumeTime, iSliceSize,664 pEncPEncCtx->pCurDqLayer->ppSliceInLayer[iSliceIdx]->uiSliceConsumeTime, iSliceSize,
662 pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx].sSliceHeaderExt.sSliceHeader.iFirstMbInSlice,665 pCurDq->ppSliceInLayer[iSliceIdx]->sSliceHeaderExt.sSliceHeader.iFirstMbInSlice,
663 pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx].iCountMbNumInSlice);666 pCurDq->ppSliceInLayer[iSliceIdx]->iCountMbNumInSlice);
664 }667 }
665 668
666#if defined(SLICE_INFO_OUTPUT)669#if defined(SLICE_INFO_OUTPUT)
@@ -690,7 +693,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 23 unmodified lines
690 int32_t iAnyMbLeftInPartition = kiEndMbInPartition - kiFirstMbInPartition;693 int32_t iAnyMbLeftInPartition = kiEndMbInPartition - kiFirstMbInPartition;
691 SSpatialLayerInternal* pParamInternal = &pCodingParam->sDependencyLayers[kiCurDid];694 SSpatialLayerInternal* pParamInternal = &pCodingParam->sDependencyLayers[kiCurDid];
692 iSliceIdx = pPrivateData->iSliceIndex;695 iSliceIdx = pPrivateData->iSliceIndex;
693 SSliceHeaderExt* pStartSliceHeaderExt = &pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx].sSliceHeaderExt;696 SSliceHeaderExt* pStartSliceHeaderExt = &pCurDq->ppSliceInLayer[iSliceIdx]->sSliceHeaderExt;
694 pStartSliceHeaderExt->sSliceHeader.iFirstMbInSlice = kiFirstMbInPartition;697 pStartSliceHeaderExt->sSliceHeader.iFirstMbInSlice = kiFirstMbInPartition;
695 pCurDq->pNumSliceCodedOfPartition[kiPartitionId] =698 pCurDq->pNumSliceCodedOfPartition[kiPartitionId] =
696 1; // one pSlice per partition intialized, dynamic slicing inside699 1; // one pSlice per partition intialized, dynamic slicing inside
@@ -712,7 +715,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 15 unmodified lines
712 }715 }
713 716
714 SetOneSliceBsBufferUnderMultithread (pEncPEncCtx, kiPartitionId, iSliceIdx);717 SetOneSliceBsBufferUnderMultithread (pEncPEncCtx, kiPartitionId, iSliceIdx);
715 pSlice = &pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx];718 pSlice = pCurDq->ppSliceInLayer[iSliceIdx];
716 pSliceBs = &pSlice->sSliceBs;719 pSliceBs = &pSlice->sSliceBs;
717 720
718 pSliceBs->uiBsPos = 0;721 pSliceBs->uiBsPos = 0;
@@ -772,7 +775,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 53 unmodified lines
772 MT_TRACE_LOG (& (pEncPEncCtx->sLogCtx), WELS_LOG_INFO,775 MT_TRACE_LOG (& (pEncPEncCtx->sLogCtx), WELS_LOG_INFO,
773 "[MT] CodingSliceThreadProc(), coding_idx %d, iPartitionId %d, uiSliceIdx %d, iSliceSize %d, count_mb_slice %d, iEndMbInPartition %d, pCurDq->pLastCodedMbIdxOfPartition[%d] %d\n",776 "[MT] CodingSliceThreadProc(), coding_idx %d, iPartitionId %d, uiSliceIdx %d, iSliceSize %d, count_mb_slice %d, iEndMbInPartition %d, pCurDq->pLastCodedMbIdxOfPartition[%d] %d\n",
774 pEncPEncCtx->iCodingIndex, kiPartitionId, iSliceIdx, iSliceSize,777 pEncPEncCtx->iCodingIndex, kiPartitionId, iSliceIdx, iSliceSize,
775 pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx].iCountMbNumInSlice,778 pCurDq->ppSliceInLayer[iSliceIdx]->iCountMbNumInSlice,
776 kiEndMbInPartition, kiPartitionId, pCurDq->pLastCodedMbIdxOfPartition[kiPartitionId]);779 kiEndMbInPartition, kiPartitionId, pCurDq->pLastCodedMbIdxOfPartition[kiPartitionId]);
777 780
778 iAnyMbLeftInPartition = kiEndMbInPartition - (1 + pCurDq->pLastCodedMbIdxOfPartition[kiPartitionId]);781 iAnyMbLeftInPartition = kiEndMbInPartition - (1 + pCurDq->pLastCodedMbIdxOfPartition[kiPartitionId]);
@@ -840,7 +843,7 @@ int32_t FiredSliceThreads (sWelsEncCtx* pCtx, SSliceThreadPrivateData* pPriData, · 61 unmodified lines
840 const int32_t kiEventCnt = uiNumThreads;843 const int32_t kiEventCnt = uiNumThreads;
841 int32_t iLayerBsIdx = pCtx->pOut->iLayerBsIndex;844 int32_t iLayerBsIdx = pCtx->pOut->iLayerBsIndex;
842 SLayerBSInfo* pLbi = &pFrameBsInfo->sLayerInfo[iLayerBsIdx];845 SLayerBSInfo* pLbi = &pFrameBsInfo->sLayerInfo[iLayerBsIdx];
843 SSlice* pSliceInLayer = pCtx->pCurDqLayer->sLayerInfo.pSliceInLayer;846 SSlice** ppSliceInLayer = pCtx->pCurDqLayer->ppSliceInLayer;
844 847
845 848
846 if (pPriData == NULL || pFrameBsInfo == NULL || pLbi == NULL || kiEventCnt <= 0 || pEventsList == NULL) {849 if (pPriData == NULL || pFrameBsInfo == NULL || pLbi == NULL || kiEventCnt <= 0 || pEventsList == NULL) {
@@ -854,7 +857,7 @@ int32_t FiredSliceThreads (sWelsEncCtx* pCtx, SSliceThreadPrivateData* pPriData, · 7 unmodified lines
854 if (bIsDynamicSlicingMode) {857 if (bIsDynamicSlicingMode) {
855 iEndMbIdx = pSliceCtx->iMbNumInFrame;858 iEndMbIdx = pSliceCtx->iMbNumInFrame;
856 for (iIdx = kiEventCnt - 1; iIdx >= 0; --iIdx) {859 for (iIdx = kiEventCnt - 1; iIdx >= 0; --iIdx) {
857 const int32_t iFirstMbIdx = pSliceInLayer[iIdx].sSliceHeaderExt.sSliceHeader.iFirstMbInSlice;860 const int32_t iFirstMbIdx = ppSliceInLayer[iIdx]->sSliceHeaderExt.sSliceHeader.iFirstMbInSlice;
858 pPriData[iIdx].iStartMbIndex = iFirstMbIdx;861 pPriData[iIdx].iStartMbIndex = iFirstMbIdx;
859 pPriData[iIdx].iEndMbIndex = iEndMbIdx;862 pPriData[iIdx].iEndMbIndex = iEndMbIdx;
860 iEndMbIdx = iFirstMbIdx;863 iEndMbIdx = iFirstMbIdx;
@@ -897,7 +900,8 @@ int32_t AdjustBaseLayer (sWelsEncCtx* pCtx) { · 36 unmodified lines
897 pCtx->pCurDqLayer = pCurDq;900 pCtx->pCurDqLayer = pCurDq;
898 901
899 // do not need adjust due to not different at both slices of consumed time902 // do not need adjust due to not different at both slices of consumed time
900 iNeedAdj = NeedDynamicAdjust (pCtx->ppDqLayerList[0]->sLayerInfo.pSliceInLayer, pCurDq->sSliceEncCtx.iSliceNumInFrame);903 iNeedAdj = NeedDynamicAdjust (pCtx->ppDqLayerList[0]->ppSliceInLayer
904 , pCurDq->sSliceEncCtx.iSliceNumInFrame);
901 if (iNeedAdj)905 if (iNeedAdj)
902 DynamicAdjustSlicing (pCtx,906 DynamicAdjustSlicing (pCtx,
903 pCurDq,907 pCurDq,
@@ -929,7 +933,7 @@ int32_t AdjustEnhanceLayer (sWelsEncCtx* pCtx, int32_t iCurDid) { · 25 unmodified lines
929 933
930 if (kbModelingFromSpatial) { // using spatial base layer for complexity estimation934 if (kbModelingFromSpatial) { // using spatial base layer for complexity estimation
931 // do not need adjust due to not different at both slices of consumed time935 // do not need adjust due to not different at both slices of consumed time
932 iNeedAdj = NeedDynamicAdjust (pCtx->ppDqLayerList[iCurDid - 1]->sLayerInfo.pSliceInLayer,936 iNeedAdj = NeedDynamicAdjust (pCtx->ppDqLayerList[iCurDid - 1]->ppSliceInLayer,
933 pCtx->pCurDqLayer->sSliceEncCtx.iSliceNumInFrame);937 pCtx->pCurDqLayer->sSliceEncCtx.iSliceNumInFrame);
934 if (iNeedAdj)938 if (iNeedAdj)
935 DynamicAdjustSlicing (pCtx,939 DynamicAdjustSlicing (pCtx,
@@ -938,7 +942,7 @@ int32_t AdjustEnhanceLayer (sWelsEncCtx* pCtx, int32_t iCurDid) { · 2 unmodified lines
938 );942 );
939 } else { // use temporal layer for complexity estimation943 } else { // use temporal layer for complexity estimation
940 // do not need adjust due to not different at both slices of consumed time944 // do not need adjust due to not different at both slices of consumed time
941 iNeedAdj = NeedDynamicAdjust (pCtx->ppDqLayerList[iCurDid]->sLayerInfo.pSliceInLayer,945 iNeedAdj = NeedDynamicAdjust (pCtx->ppDqLayerList[iCurDid]->ppSliceInLayer,
942 pCtx->pCurDqLayer->sSliceEncCtx.iSliceNumInFrame);946 pCtx->pCurDqLayer->sSliceEncCtx.iSliceNumInFrame);
943 if (iNeedAdj)947 if (iNeedAdj)
944 DynamicAdjustSlicing (pCtx,948 DynamicAdjustSlicing (pCtx,
@@ -964,12 +968,12 @@ int32_t AdjustEnhanceLayer (sWelsEncCtx* pCtx, int32_t iCurDid) { · 19 unmodified lines
964#if defined(MT_DEBUG)968#if defined(MT_DEBUG)
965void TrackSliceComplexities (sWelsEncCtx* pCtx, const int32_t iCurDid) {969void TrackSliceComplexities (sWelsEncCtx* pCtx, const int32_t iCurDid) {
966 const int32_t kiCountSliceNum = pCtx->pCurDqLayer->sSliceEncCtx.iSliceNumInFrame;970 const int32_t kiCountSliceNum = pCtx->pCurDqLayer->sSliceEncCtx.iSliceNumInFrame;
967 SSlice* pSliceInLayer = pCtx->pCurDqLayer->sLayerInfo.pSliceInLayer;971 SSlice** ppSliceInLayer = pCtx->pCurDqLayer->ppSliceInLayer;
968 if (kiCountSliceNum > 0) {972 if (kiCountSliceNum > 0) {
969 int32_t iSliceIdx = 0;973 int32_t iSliceIdx = 0;
970 do {974 do {
971 fprintf (pCtx->pSliceThreading->pFSliceDiff, "%6.3f complexity pRatio at iDid %d pSlice %d\n",975 fprintf (pCtx->pSliceThreading->pFSliceDiff, "%6.3f complexity pRatio at iDid %d pSlice %d\n",
972 pSliceInLayer[iSliceIdx].iSliceComplexRatio, iCurDid, iSliceIdx);976 ppSliceInLayer[iSliceIdx]->iSliceComplexRatio, iCurDid, iSliceIdx);
973 ++ iSliceIdx;977 ++ iSliceIdx;
974 } while (iSliceIdx < kiCountSliceNum);978 } while (iSliceIdx < kiCountSliceNum);
975 }979 }
@@ -987,9 +991,9 @@ void TrackSliceConsumeTime (sWelsEncCtx* pCtx, int32_t* pDidList, const int32_t · 11 unmodified lines
987 pPara = pCtx->pSvcParam;991 pPara = pCtx->pSvcParam;
988 while (iSpatialIdx < iSpatialNum) {992 while (iSpatialIdx < iSpatialNum) {
989 const int32_t kiDid = pDidList[iSpatialIdx];993 const int32_t kiDid = pDidList[iSpatialIdx];
990 SSliceArgument* pSliceArgument = &pPara->sSpatialLayers[kiDid].sSliceArgument;994 SSliceArgument* pSliceArgument = &pPara->sSpatialLayers[kiDid].sSliceArgument;
991 SDqLayer* pCurDq = pCtx->ppDqLayerList[kiDid];995 SDqLayer* pCurDq = pCtx->ppDqLayerList[kiDid];
992 SSlice* pSliceInLayer = pCurDq->sLayerInfo.pSliceInLayer;996 SSlice** ppSliceInLayer = pCurDq->ppSliceInLayer;
993 SSliceCtx* pSliceCtx = &pCurDq->sSliceEncCtx;997 SSliceCtx* pSliceCtx = &pCurDq->sSliceEncCtx;
994 const uint32_t kuiCountSliceNum = pSliceCtx->iSliceNumInFrame;998 const uint32_t kuiCountSliceNum = pSliceCtx->iSliceNumInFrame;
995 if (pCtx->pSliceThreading) {999 if (pCtx->pSliceThreading) {
@@ -1002,9 +1006,9 @@ void TrackSliceConsumeTime (sWelsEncCtx* pCtx, int32_t* pDidList, const int32_t · 6 unmodified lines
1002 int32_t iMaxI = 0;1006 int32_t iMaxI = 0;
1003 while (i < kuiCountSliceNum) {1007 while (i < kuiCountSliceNum) {
1004 fprintf (pCtx->pSliceThreading->pFSliceDiff, "%6d us consume_time coding_idx %d iDid %d pSlice %d\n",1008 fprintf (pCtx->pSliceThreading->pFSliceDiff, "%6d us consume_time coding_idx %d iDid %d pSlice %d\n",
1005 pSliceInLayer[i].uiSliceConsumeTime, pCtx->iCodingIndex, kiDid, i /*/ 1000*/);1009 ppSliceInLayer[i]->uiSliceConsumeTime, pCtx->iCodingIndex, kiDid, i /*/ 1000*/);
1006 if (pSliceInLayer[i].uiSliceConsumeTime > uiMaxT) {1010 if (ppSliceInLayer[i]->uiSliceConsumeTime > uiMaxT) {
1007 uiMaxT = pSliceInLayer[i].uiSliceConsumeTime;1011 uiMaxT = ppSliceInLayer[i]->uiSliceConsumeTime;
1008 iMaxI = i;1012 iMaxI = i;
1009 }1013 }
1010 ++ i;1014 ++ i;
@@ -1019,7 +1023,7 @@ void TrackSliceConsumeTime (sWelsEncCtx* pCtx, int32_t* pDidList, const int32_t · 8 unmodified lines
1019#endif//#if defined(MT_DEBUG)1023#endif//#if defined(MT_DEBUG)
1020 1024
1021void SetOneSliceBsBufferUnderMultithread (sWelsEncCtx* pCtx, const int32_t kiThreadIdx, const int32_t iSliceIdx) {1025void SetOneSliceBsBufferUnderMultithread (sWelsEncCtx* pCtx, const int32_t kiThreadIdx, const int32_t iSliceIdx) {
1022 SWelsSliceBs* pSliceBs = &pCtx->pCurDqLayer->sLayerInfo.pSliceInLayer[iSliceIdx].sSliceBs;1026 SWelsSliceBs* pSliceBs = &pCtx->pCurDqLayer->ppSliceInLayer[iSliceIdx]->sSliceBs;
1023 pSliceBs->pBsBuffer = pCtx->pSliceThreading->pThreadBsBuffer[kiThreadIdx];1027 pSliceBs->pBsBuffer = pCtx->pSliceThreading->pThreadBsBuffer[kiThreadIdx];
1024 pSliceBs->uiBsPos = 0;1028 pSliceBs->uiBsPos = 0;
1025}1029}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t