History

Convert tabs to spaces in vertically aligned code

Martin Storsjö committed 11 years ago

Commit 51efa571 parent 723044864 files · +2746 −2751Browse files

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

Unified · Split

codec/encoder/core/src/slice_multi_threading.cpp+166−166
@@ -73,17 +73,17 @@ namespace WelsEnc { · 72 unmodified lines
7373 void UpdateMbListNeighborParallel (SSliceCtx* pSliceCtx,
7474 SMB* pMbList,
7575 const int32_t uiSliceIdc) {
76− const uint16_t* kpMbMap = pSliceCtx->pOverallMbMap;
77− const int32_t kiMbWidth = pSliceCtx->iMbWidth;
78− int32_t iIdx = pSliceCtx->pFirstMbInSlice[uiSliceIdc];
79− const int32_t kiEndMbInSlice = iIdx + pSliceCtx->pCountMbNumInSlice[uiSliceIdc] - 1;
76+ const uint16_t* kpMbMap = pSliceCtx->pOverallMbMap;
77+ const int32_t kiMbWidth = pSliceCtx->iMbWidth;
78+ int32_t iIdx = pSliceCtx->pFirstMbInSlice[uiSliceIdc];
79+ const int32_t kiEndMbInSlice = iIdx + pSliceCtx->pCountMbNumInSlice[uiSliceIdc] - 1;
8080
8181 do {
82− SMB* pMb = &pMbList[iIdx];
83− uint32_t uiNeighborAvailFlag = 0;
84− const int32_t kiMbXY = pMb->iMbXY;
85− const int32_t kiMbX = pMb->iMbX;
86− const int32_t kiMbY = pMb->iMbY;
82+ SMB* pMb = &pMbList[iIdx];
83+ uint32_t uiNeighborAvailFlag = 0;
84+ const int32_t kiMbXY = pMb->iMbXY;
85+ const int32_t kiMbX = pMb->iMbX;
86+ const int32_t kiMbY = pMb->iMbY;
8787 bool bLeft;
8888 bool bTop;
8989 bool bLeftTop;
@@ -112,21 +112,21 @@ void UpdateMbListNeighborParallel (SSliceCtx* pSliceCtx, · 22 unmodified lines
112112 if (bRightTop) {
113113 uiNeighborAvailFlag |= TOPRIGHT_MB_POS;
114114 }
115− pMb->uiNeighborAvail = (uint8_t)uiNeighborAvailFlag;
116− pMb->uiSliceIdc = uiSliceIdc;
115+ pMb->uiNeighborAvail = (uint8_t)uiNeighborAvailFlag;
116+ pMb->uiSliceIdc = uiSliceIdc;
117117
118118 ++ iIdx;
119119 } while (iIdx <= kiEndMbInSlice);
120120 }
121121
122122 void CalcSliceComplexRatio (void* pRatio, SSliceCtx* pSliceCtx, uint32_t* pSliceConsume) {
123− int32_t* pRatioList = (int32_t*)pRatio;
123+ int32_t* pRatioList = (int32_t*)pRatio;
124124 int32_t iAvI[MAX_SLICES_NUM];
125− int32_t iSumAv = 0;
126− uint32_t* pSliceTime = (uint32_t*)pSliceConsume;
127− int32_t* pCountMbInSlice = (int32_t*)pSliceCtx->pCountMbNumInSlice;
128− const int32_t kiSliceCount = pSliceCtx->iSliceNumInFrame;
129− int32_t iSliceIdx = 0;
125+ int32_t iSumAv = 0;
126+ uint32_t* pSliceTime = (uint32_t*)pSliceConsume;
127+ int32_t* pCountMbInSlice = (int32_t*)pSliceCtx->pCountMbNumInSlice;
128+ const int32_t kiSliceCount = pSliceCtx->iSliceNumInFrame;
129+ int32_t iSliceIdx = 0;
130130
131131 WelsEmms();
132132
@@ -145,10 +145,10 @@ void CalcSliceComplexRatio (void* pRatio, SSliceCtx* pSliceCtx, uint32_t* pSlice · 12 unmodified lines
145145 }
146146
147147 int32_t NeedDynamicAdjust (void* pConsumeTime, const int32_t iSliceNum) {
148− uint32_t* pSliceConsume = (uint32_t*)pConsumeTime;
149− uint32_t uiTotalConsume = 0;
150− int32_t iSliceIdx = 0;
151− int32_t iNeedAdj = false;
148+ uint32_t* pSliceConsume = (uint32_t*)pConsumeTime;
149+ uint32_t uiTotalConsume = 0;
150+ int32_t iSliceIdx = 0;
151+ int32_t iNeedAdj = false;
152152
153153 WelsEmms();
154154
@@ -164,9 +164,9 @@ int32_t NeedDynamicAdjust (void* pConsumeTime, const int32_t iSliceNum) { · 9 unmodified lines
164164 }
165165
166166 iSliceIdx = 0;
167− float fThr = EPSN; // threshold for various cores cases
168− float fRmse = .0f; // root mean square error of pSlice consume ratios
169− const float kfMeanRatio = 1.0f / iSliceNum;
167+ float fThr = EPSN; // threshold for various cores cases
168+ float fRmse = .0f; // root mean square error of pSlice consume ratios
169+ const float kfMeanRatio = 1.0f / iSliceNum;
170170 do {
171171 const float fRatio = 1.0f * pSliceConsume[iSliceIdx] / uiTotalConsume;
172172 const float fDiffRatio = fRatio - kfMeanRatio;
@@ -195,15 +195,15 @@ void DynamicAdjustSlicing (sWelsEncCtx* pCtx, · 22 unmodified lines
195195 SDqLayer* pCurDqLayer,
196196 void* pComplexRatio,
197197 int32_t iCurDid) {
198− SSliceCtx* pSliceCtx = pCurDqLayer->pSliceEncCtx;
199− const int32_t kiCountSliceNum = pSliceCtx->iSliceNumInFrame;
200− const int32_t kiCountNumMb = pSliceCtx->iMbNumInFrame;
201− int32_t iMinimalMbNum = pSliceCtx->iMbWidth; // in theory we need only 1 SMB, here let it as one SMB row required
202− int32_t iMaximalMbNum = 0; // dynamically assign later
203− int32_t* pSliceComplexRatio = (int32_t*)pComplexRatio;
204− int32_t iMbNumLeft = kiCountNumMb;
205− int32_t iRunLen[MAX_THREADS_NUM] = {0};
206− int32_t iSliceIdx = 0;
198+ SSliceCtx* pSliceCtx = pCurDqLayer->pSliceEncCtx;
199+ const int32_t kiCountSliceNum = pSliceCtx->iSliceNumInFrame;
200+ const int32_t kiCountNumMb = pSliceCtx->iMbNumInFrame;
201+ int32_t iMinimalMbNum = pSliceCtx->iMbWidth; // in theory we need only 1 SMB, here let it as one SMB row required
202+ int32_t iMaximalMbNum = 0; // dynamically assign later
203+ int32_t* pSliceComplexRatio = (int32_t*)pComplexRatio;
204+ int32_t iMbNumLeft = kiCountNumMb;
205+ int32_t iRunLen[MAX_THREADS_NUM] = {0};
206+ int32_t iSliceIdx = 0;
207207
208208 int32_t iNumMbInEachGom = 0;
209209 SWelsSvcRc* pWelsSvcRc = &pCtx->pWelsSvcRc[iCurDid];
@@ -271,8 +271,8 @@ void DynamicAdjustSlicing (sWelsEncCtx* pCtx, · 61 unmodified lines
271271
272272
273273 if (DynamicAdjustSlicePEncCtxAll (pSliceCtx, iRunLen) == 0) {
274− const int32_t kiThreadNum = pCtx->pSvcParam->iCountThreadsNum;
275− int32_t iThreadIdx = 0;
274+ const int32_t kiThreadNum = pCtx->pSvcParam->iCountThreadsNum;
275+ int32_t iThreadIdx = 0;
276276 do {
277277 WelsEventSignal (&pCtx->pSliceThreading->pUpdateMbListEvent[iThreadIdx]);
278278 WelsEventSignal (&pCtx->pSliceThreading->pThreadMasterEvent[iThreadIdx]);
@@ -286,16 +286,16 @@ void DynamicAdjustSlicing (sWelsEncCtx* pCtx, · 7 unmodified lines
286286
287287 int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingParam, const int32_t iCountBsLen,
288288 const int32_t iTargetSpatialBsSize) {
289− CMemoryAlign* pMa = NULL;
289+ CMemoryAlign* pMa = NULL;
290290 SWelsSvcCodingParam* pPara = NULL;
291− SSliceThreading* pSmt = NULL;
292− SWelsSliceBs* pSliceB = NULL;
293− uint8_t* pBsBase = NULL;
294− int32_t iNumSpatialLayers = 0;
295− int32_t iThreadNum = 0;
296− int32_t iIdx = 0;
291+ SSliceThreading* pSmt = NULL;
292+ SWelsSliceBs* pSliceB = NULL;
293+ uint8_t* pBsBase = NULL;
294+ int32_t iNumSpatialLayers = 0;
295+ int32_t iThreadNum = 0;
296+ int32_t iIdx = 0;
297297 int32_t iSliceBsBufferSize = 0;
298− int16_t iMaxSliceNum = 1;
298+ int16_t iMaxSliceNum = 1;
299299 int32_t iReturn = ENC_RETURN_SUCCESS;
300300
301301 if (NULL == ppCtx || NULL == pCodingParam || NULL == *ppCtx || iCountBsLen <= 0)
@@ -333,8 +333,8 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 31 unmodified lines
333333 pSmt->pSliceComplexRatio[iIdx] = (int32_t*)pMa->WelsMalloc (kiSliceNum * sizeof (int32_t), "pSliceComplexRatio[]");
334334 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pSliceComplexRatio[iIdx]), FreeMemorySvc (ppCtx))
335335 } else {
336− pSmt->pSliceConsumeTime[iIdx] = NULL;
337− pSmt->pSliceComplexRatio[iIdx] = NULL;
336+ pSmt->pSliceConsumeTime[iIdx] = NULL;
337+ pSmt->pSliceComplexRatio[iIdx] = NULL;
338338 }
339339 ++ iIdx;
340340 }
@@ -358,10 +358,10 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 17 unmodified lines
358358
359359 iIdx = 0;
360360 while (iIdx < iThreadNum) {
361− pSmt->pThreadPEncCtx[iIdx].pWelsPEncCtx = (void*) *ppCtx;
362− pSmt->pThreadPEncCtx[iIdx].iSliceIndex = iIdx;
363− pSmt->pThreadPEncCtx[iIdx].iThreadIndex = iIdx;
364− pSmt->pThreadHandles[iIdx] = 0;
361+ pSmt->pThreadPEncCtx[iIdx].pWelsPEncCtx = (void*) *ppCtx;
362+ pSmt->pThreadPEncCtx[iIdx].iSliceIndex = iIdx;
363+ pSmt->pThreadPEncCtx[iIdx].iThreadIndex = iIdx;
364+ pSmt->pThreadHandles[iIdx] = 0;
365365
366366 WelsSnprintf (name, SEM_NAME_MAX, "ee%d%s", iIdx, pSmt->eventNamespace);
367367 err = WelsEventOpen (&pSmt->pExitEncodeEvent[iIdx], name);
@@ -395,9 +395,9 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 27 unmodified lines
395395 (*ppCtx)->pSliceBs = (SWelsSliceBs*)pMa->WelsMalloc (sizeof (SWelsSliceBs) * iMaxSliceNum, "pSliceBs");
396396 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pSliceBs), FreeMemorySvc (ppCtx))
397397
398− pBsBase = (*ppCtx)->pFrameBs + iCountBsLen;
399− pSliceB = (*ppCtx)->pSliceBs;
400− iSliceBsBufferSize = iTargetSpatialBsSize;
398+ pBsBase = (*ppCtx)->pFrameBs + iCountBsLen;
399+ pSliceB = (*ppCtx)->pSliceBs;
400+ iSliceBsBufferSize = iTargetSpatialBsSize;
401401 iIdx = 0;
402402 while (iIdx < iMaxSliceNum) {
403403 pSliceB->pBsBuffer = (uint8_t*)pMa->WelsMalloc (iSliceBsBufferSize, "pSliceB->pBsBuffer");
@@ -406,12 +406,12 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 2 unmodified lines
406406 pSliceB->uiSize = iSliceBsBufferSize;
407407
408408 if (iIdx > 0) {
409− pSliceB->pBs = pBsBase;
410− pSliceB->uiBsPos = 0;
411− pBsBase += iSliceBsBufferSize;
409+ pSliceB->pBs = pBsBase;
410+ pSliceB->uiBsPos = 0;
411+ pBsBase += iSliceBsBufferSize;
412412 } else {
413− pSliceB->pBs = NULL;
414− pSliceB->uiBsPos = 0;
413+ pSliceB->pBs = NULL;
414+ pSliceB->uiBsPos = 0;
415415 }
416416 ++ pSliceB;
417417 ++ iIdx;
@@ -431,22 +431,22 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 13 unmodified lines
431431 }
432432
433433 void ReleaseMtResource (sWelsEncCtx** ppCtx) {
434− SWelsSliceBs* pSliceB = NULL;
435− SWelsSvcCodingParam* pCodingParam = NULL;
436− SSliceThreading* pSmt = NULL;
437− CMemoryAlign* pMa = NULL;
438− int32_t iIdx = 0;
439− int32_t iThreadNum = 0;
440− int16_t uiSliceNum = 0;
434+ SWelsSliceBs* pSliceB = NULL;
435+ SWelsSvcCodingParam* pCodingParam = NULL;
436+ SSliceThreading* pSmt = NULL;
437+ CMemoryAlign* pMa = NULL;
438+ int32_t iIdx = 0;
439+ int32_t iThreadNum = 0;
440+ int16_t uiSliceNum = 0;
441441
442442 if (NULL == ppCtx || NULL == *ppCtx)
443443 return;
444444
445− pMa = (*ppCtx)->pMemAlign;
446− pCodingParam = (*ppCtx)->pSvcParam;
447− uiSliceNum = (*ppCtx)->iMaxSliceCount;
448− iThreadNum = (*ppCtx)->pSvcParam->iCountThreadsNum;
449− pSmt = (*ppCtx)->pSliceThreading;
445+ pMa = (*ppCtx)->pMemAlign;
446+ pCodingParam = (*ppCtx)->pSvcParam;
447+ uiSliceNum = (*ppCtx)->iMaxSliceCount;
448+ iThreadNum = (*ppCtx)->pSvcParam->iCountThreadsNum;
449+ pSmt = (*ppCtx)->pSliceThreading;
450450
451451 if (NULL == pSmt)
452452 return;
@@ -520,19 +520,19 @@ void ReleaseMtResource (sWelsEncCtx** ppCtx) { · 67 unmodified lines
520520 }
521521
522522 int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32_t iSliceCount) {
523− SWelsSvcCodingParam* pCodingParam = pCtx->pSvcParam;
524− SSpatialLayerConfig* pDlp = &pCodingParam->sSpatialLayers[pCtx->uiDependencyId];
525− SWelsSliceBs* pSliceBs = NULL;
526− const bool kbIsDynamicSlicingMode = (pDlp->sSliceCfg.uiSliceMode == SM_DYN_SLICE);
523+ SWelsSvcCodingParam* pCodingParam = pCtx->pSvcParam;
524+ SSpatialLayerConfig* pDlp = &pCodingParam->sSpatialLayers[pCtx->uiDependencyId];
525+ SWelsSliceBs* pSliceBs = NULL;
526+ const bool kbIsDynamicSlicingMode = (pDlp->sSliceCfg.uiSliceMode == SM_DYN_SLICE);
527527
528− int32_t iLayerSize = 0;
529− int32_t iNalIdxBase = pLbi->iNalCount;
530− int32_t iSliceIdx = 0;
528+ int32_t iLayerSize = 0;
529+ int32_t iNalIdxBase = pLbi->iNalCount;
530+ int32_t iSliceIdx = 0;
531531
532532 if (!kbIsDynamicSlicingMode) {
533− pSliceBs = &pCtx->pSliceBs[0];
534− iLayerSize = pSliceBs->uiBsPos; // assign with base pSlice first
535− iSliceIdx = 1; // pSlice 0 bs has been written to pFrameBs yet by now, so uiSliceIdx base should be 1
533+ pSliceBs = &pCtx->pSliceBs[0];
534+ iLayerSize = pSliceBs->uiBsPos; // assign with base pSlice first
535+ iSliceIdx = 1; // pSlice 0 bs has been written to pFrameBs yet by now, so uiSliceIdx base should be 1
536536 while (iSliceIdx < iSliceCount) {
537537 ++ pSliceBs;
538538 if (pSliceBs != NULL && pSliceBs->uiBsPos > 0) {
@@ -552,14 +552,14 @@ int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32 · 13 unmodified lines
552552 pLbi->pNalLengthInByte[iNalIdxBase + iNalIdx] = pSliceBs->iNalLen[iNalIdx];
553553 ++ iNalIdx;
554554 }
555− pLbi->iNalCount += iCountNal;
556− iNalIdxBase += iCountNal;
555+ pLbi->iNalCount += iCountNal;
556+ iNalIdxBase += iCountNal;
557557 }
558558 ++ iSliceIdx;
559559 }
560− } else { // for SM_DYN_SLICE
561− const int32_t kiPartitionCnt = iSliceCount;
562− int32_t iPartitionIdx = 0;
560+ } else { // for SM_DYN_SLICE
561+ const int32_t kiPartitionCnt = iSliceCount;
562+ int32_t iPartitionIdx = 0;
563563
564564 // due partition_0 has been written to pFrameBsBuffer
565565 // so iLayerSize need add it
@@ -584,8 +584,8 @@ int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32 · 18 unmodified lines
584584 pLbi->pNalLengthInByte[iNalIdxBase + iNalIdx] = pSliceBs->iNalLen[iNalIdx];
585585 ++ iNalIdx;
586586 }
587− pLbi->iNalCount += iCountNal;
588− iNalIdxBase += iCountNal;
587+ pLbi->iNalCount += iCountNal;
588+ iNalIdxBase += iCountNal;
589589 } else {
590590 iLayerSize += pSliceBs->uiBsPos;
591591 }
@@ -603,17 +603,17 @@ int32_t AppendSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, const int32 · 11 unmodified lines
603603
604604 int32_t WriteSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, uint8_t* pFrameBsBuffer, const int32_t iSliceIdx,
605605 int32_t& iSliceSize) {
606− SWelsSliceBs* pSliceBs = &pCtx->pSliceBs[iSliceIdx];
606+ SWelsSliceBs* pSliceBs = &pCtx->pSliceBs[iSliceIdx];
607607 SNalUnitHeaderExt* pNalHdrExt = &pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt;
608− uint8_t* pDst = pFrameBsBuffer;
609− const int32_t kiNalCnt = pSliceBs->iNalIndex;
610− int32_t iNalIdx = 0;
608+ uint8_t* pDst = pFrameBsBuffer;
609+ const int32_t kiNalCnt = pSliceBs->iNalIndex;
610+ int32_t iNalIdx = 0;
611611 int32_t iNalSize = 0;
612− const int32_t iFirstSlice = (iSliceIdx == 0);
613− int32_t iNalBase = iFirstSlice ? 0 : pLbi->iNalCount;
612+ const int32_t iFirstSlice = (iSliceIdx == 0);
613+ int32_t iNalBase = iFirstSlice ? 0 : pLbi->iNalCount;
614614 int32_t iReturn = ENC_RETURN_SUCCESS;
615615 const int32_t kiWrittenLength = pCtx->iPosBsBuffer;
616− iSliceSize = 0;
616+ iSliceSize = 0;
617617
618618 while (iNalIdx < kiNalCnt) {
619619 iNalSize = 0;
@@ -630,26 +630,26 @@ int32_t WriteSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, uint8_t* pFr · 10 unmodified lines
630630 pSliceBs->uiBsPos = iSliceSize;
631631 if (iFirstSlice) {
632632 // pBsBuffer has been updated at coding_slice_0_in_encoder_mother_thread()
633− pLbi->uiLayerType = VIDEO_CODING_LAYER;
634− pLbi->uiSpatialId = pNalHdrExt->uiDependencyId;
635− pLbi->uiTemporalId = pNalHdrExt->uiTemporalId;
636− pLbi->uiQualityId = 0;
637− pLbi->iNalCount = kiNalCnt;
633+ pLbi->uiLayerType = VIDEO_CODING_LAYER;
634+ pLbi->uiSpatialId = pNalHdrExt->uiDependencyId;
635+ pLbi->uiTemporalId = pNalHdrExt->uiTemporalId;
636+ pLbi->uiQualityId = 0;
637+ pLbi->iNalCount = kiNalCnt;
638638 } else {
639− pLbi->iNalCount += kiNalCnt;
639+ pLbi->iNalCount += kiNalCnt;
640640 }
641641
642642 return ENC_RETURN_SUCCESS;
643643 }
644644
645645 int32_t WriteSliceBs (sWelsEncCtx* pCtx, uint8_t* pSliceBsBuf, const int32_t iSliceIdx, int32_t& iSliceSize) {
646− SWelsSliceBs* pSliceBs = &pCtx->pSliceBs[iSliceIdx];
646+ SWelsSliceBs* pSliceBs = &pCtx->pSliceBs[iSliceIdx];
647647 SNalUnitHeaderExt* pNalHdrExt = &pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt;
648− uint8_t* pDst = pSliceBsBuf;
649− int32_t* pNalLen = &pSliceBs->iNalLen[0];
650− const int32_t kiNalCnt = pSliceBs->iNalIndex;
651− int32_t iNalIdx = 0;
652− int32_t iNalSize = 0;
648+ uint8_t* pDst = pSliceBsBuf;
649+ int32_t* pNalLen = &pSliceBs->iNalLen[0];
650+ const int32_t kiNalCnt = pSliceBs->iNalIndex;
651+ int32_t iNalIdx = 0;
652+ int32_t iNalSize = 0;
653653 int32_t iReturn = ENC_RETURN_SUCCESS;
654654 const int32_t kiWrittenLength = (int32_t) (pSliceBs->sBsWrite.pCurBuf - pSliceBs->sBsWrite.pStartBuf);
655655
@@ -675,34 +675,34 @@ int32_t WriteSliceBs (sWelsEncCtx* pCtx, uint8_t* pSliceBsBuf, const int32_t iSl · 19 unmodified lines
675675
676676 // thread process for coding one pSlice
677677 WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) {
678− SSliceThreadPrivateData* pPrivateData = (SSliceThreadPrivateData*)arg;
679− sWelsEncCtx* pEncPEncCtx = NULL;
680− SDqLayer* pCurDq = NULL;
681− SSlice* pSlice = NULL;
682− SWelsSliceBs* pSliceBs = NULL;
678+ SSliceThreadPrivateData* pPrivateData = (SSliceThreadPrivateData*)arg;
679+ sWelsEncCtx* pEncPEncCtx = NULL;
680+ SDqLayer* pCurDq = NULL;
681+ SSlice* pSlice = NULL;
682+ SWelsSliceBs* pSliceBs = NULL;
683683 WELS_EVENT pEventsList[3];
684− int32_t iEventCount = 0;
685− WELS_THREAD_ERROR_CODE iWaitRet = WELS_THREAD_ERROR_GENERAL;
686− uint32_t uiThrdRet = 0;
687− int32_t iSliceSize = 0;
688− int32_t iSliceIdx = -1;
689− int32_t iThreadIdx = -1;
690− int32_t iEventIdx = -1;
691− bool bNeedPrefix = false;
692− EWelsNalUnitType eNalType = NAL_UNIT_UNSPEC_0;
693− EWelsNalRefIdc eNalRefIdc = NRI_PRI_LOWEST;
684+ int32_t iEventCount = 0;
685+ WELS_THREAD_ERROR_CODE iWaitRet = WELS_THREAD_ERROR_GENERAL;
686+ uint32_t uiThrdRet = 0;
687+ int32_t iSliceSize = 0;
688+ int32_t iSliceIdx = -1;
689+ int32_t iThreadIdx = -1;
690+ int32_t iEventIdx = -1;
691+ bool bNeedPrefix = false;
692+ EWelsNalUnitType eNalType = NAL_UNIT_UNSPEC_0;
693+ EWelsNalRefIdc eNalRefIdc = NRI_PRI_LOWEST;
694694 int32_t iReturn = ENC_RETURN_SUCCESS;
695695
696696 if (NULL == pPrivateData)
697697 WELS_THREAD_ROUTINE_RETURN (1);
698698
699− pEncPEncCtx = (sWelsEncCtx*)pPrivateData->pWelsPEncCtx;
699+ pEncPEncCtx = (sWelsEncCtx*)pPrivateData->pWelsPEncCtx;
700700
701− iThreadIdx = pPrivateData->iThreadIndex;
702− iEventIdx = iThreadIdx;
701+ iThreadIdx = pPrivateData->iThreadIndex;
702+ iEventIdx = iThreadIdx;
703703
704− pEventsList[iEventCount++] = pEncPEncCtx->pSliceThreading->pReadySliceCodingEvent[iEventIdx];
705− pEventsList[iEventCount++] = pEncPEncCtx->pSliceThreading->pExitEncodeEvent[iEventIdx];
704+ pEventsList[iEventCount++] = pEncPEncCtx->pSliceThreading->pReadySliceCodingEvent[iEventIdx];
705+ pEventsList[iEventCount++] = pEncPEncCtx->pSliceThreading->pExitEncodeEvent[iEventIdx];
706706 pEventsList[iEventCount++] = pEncPEncCtx->pSliceThreading->pUpdateMbListEvent[iEventIdx];
707707
708708 WelsThreadSetName ("OpenH264Enc_CodingSliceThreadProc");
@@ -716,32 +716,32 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 7 unmodified lines
716716 &pEncPEncCtx->pSliceThreading->pThreadMasterEvent[iEventIdx]); // blocking until at least one event is signalled
717717 if (WELS_THREAD_ERROR_WAIT_OBJECT_0 == iWaitRet) { // start pSlice coding signal waited
718718 SLayerBSInfo* pLbi = pPrivateData->pLayerBs;
719− const int32_t kiCurDid = pEncPEncCtx->uiDependencyId;
720− const int32_t kiCurTid = pEncPEncCtx->uiTemporalId;
721− SWelsSvcCodingParam* pCodingParam = pEncPEncCtx->pSvcParam;
722− SSpatialLayerConfig* pParamD = &pCodingParam->sSpatialLayers[kiCurDid];
719+ const int32_t kiCurDid = pEncPEncCtx->uiDependencyId;
720+ const int32_t kiCurTid = pEncPEncCtx->uiTemporalId;
721+ SWelsSvcCodingParam* pCodingParam = pEncPEncCtx->pSvcParam;
722+ SSpatialLayerConfig* pParamD = &pCodingParam->sSpatialLayers[kiCurDid];
723723
724− pCurDq = pEncPEncCtx->pCurDqLayer;
725− eNalType = pEncPEncCtx->eNalType;
726− eNalRefIdc = pEncPEncCtx->eNalPriority;
727− bNeedPrefix = pEncPEncCtx->bNeedPrefixNalFlag;
724+ pCurDq = pEncPEncCtx->pCurDqLayer;
725+ eNalType = pEncPEncCtx->eNalType;
726+ eNalRefIdc = pEncPEncCtx->eNalPriority;
727+ bNeedPrefix = pEncPEncCtx->bNeedPrefixNalFlag;
728728
729729 if (pParamD->sSliceCfg.uiSliceMode != SM_DYN_SLICE) {
730730 int64_t iSliceStart = 0;
731731 bool bDsaFlag = false;
732− iSliceIdx = pPrivateData->iSliceIndex;
733− pSlice = &pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx];
734− pSliceBs = &pEncPEncCtx->pSliceBs[iSliceIdx];
732+ iSliceIdx = pPrivateData->iSliceIndex;
733+ pSlice = &pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx];
734+ pSliceBs = &pEncPEncCtx->pSliceBs[iSliceIdx];
735735
736− bDsaFlag = (((pParamD->sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE)
736+ bDsaFlag = (((pParamD->sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE)
737737 || (pParamD->sSliceCfg.uiSliceMode == SM_AUTO_SLICE)) &&
738738 pCodingParam->iMultipleThreadIdc > 1 &&
739739 pCodingParam->iMultipleThreadIdc >= pParamD->sSliceCfg.sSliceArgument.uiSliceNum);
740740 if (bDsaFlag)
741741 iSliceStart = WelsTime();
742742
743− pSliceBs->uiBsPos = 0;
744− pSliceBs->iNalIndex = 0;
743+ pSliceBs->uiBsPos = 0;
744+ pSliceBs->iNalIndex = 0;
745745 assert ((void*) (&pSliceBs->sBsWrite) == (void*)pSlice->pSliceBsa);
746746 InitBits (&pSliceBs->sBsWrite, pSliceBs->pBsBuffer, pSliceBs->uiSize);
747747
@@ -825,21 +825,21 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 77 unmodified lines
825825 &pEncPEncCtx->pSliceThreading->pSliceCodedEvent[iEventIdx]); // mean finished coding current pSlice
826826 WelsEventSignal (
827827 &pEncPEncCtx->pSliceThreading->pSliceCodedMasterEvent);
828− } else { // for SM_DYN_SLICE parallelization
829− SSliceCtx* pSliceCtx = pCurDq->pSliceEncCtx;
830− const int32_t kiPartitionId = iThreadIdx;
831− const int32_t kiSliceIdxStep = pEncPEncCtx->iActiveThreadsNum;
832− const int32_t kiFirstMbInPartition = pPrivateData->iStartMbIndex; // inclusive
833− const int32_t kiEndMbInPartition = pPrivateData->iEndMbIndex; // exclusive
834− int32_t iAnyMbLeftInPartition = kiEndMbInPartition - kiFirstMbInPartition;
828+ } else { // for SM_DYN_SLICE parallelization
829+ SSliceCtx* pSliceCtx = pCurDq->pSliceEncCtx;
830+ const int32_t kiPartitionId = iThreadIdx;
831+ const int32_t kiSliceIdxStep = pEncPEncCtx->iActiveThreadsNum;
832+ const int32_t kiFirstMbInPartition = pPrivateData->iStartMbIndex; // inclusive
833+ const int32_t kiEndMbInPartition = pPrivateData->iEndMbIndex; // exclusive
834+ int32_t iAnyMbLeftInPartition = kiEndMbInPartition - kiFirstMbInPartition;
835835
836836 iSliceIdx = pPrivateData->iSliceIndex;
837837
838− pSliceCtx->pFirstMbInSlice[iSliceIdx] = kiFirstMbInPartition;
839− pCurDq->pNumSliceCodedOfPartition[kiPartitionId] = 1; // one pSlice per partition intialized, dynamic slicing inside
840− pCurDq->pLastMbIdxOfPartition[kiPartitionId] = kiEndMbInPartition - 1;
838+ pSliceCtx->pFirstMbInSlice[iSliceIdx] = kiFirstMbInPartition;
839+ pCurDq->pNumSliceCodedOfPartition[kiPartitionId] = 1; // one pSlice per partition intialized, dynamic slicing inside
840+ pCurDq->pLastMbIdxOfPartition[kiPartitionId] = kiEndMbInPartition - 1;
841841
842− pCurDq->pLastCodedMbIdxOfPartition[kiPartitionId] = 0;
842+ pCurDq->pLastCodedMbIdxOfPartition[kiPartitionId] = 0;
843843
844844 while (iAnyMbLeftInPartition > 0) {
845845 if (iSliceIdx >= pSliceCtx->iMaxSliceNumConstraint) {
@@ -849,11 +849,11 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 3 unmodified lines
849849 break;
850850 }
851851
852− pSlice = &pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx];
853− pSliceBs = &pEncPEncCtx->pSliceBs[iSliceIdx];
852+ pSlice = &pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx];
853+ pSliceBs = &pEncPEncCtx->pSliceBs[iSliceIdx];
854854
855− pSliceBs->uiBsPos = 0;
856− pSliceBs->iNalIndex = 0;
855+ pSliceBs->uiBsPos = 0;
856+ pSliceBs->iNalIndex = 0;
857857 InitBits (&pSliceBs->sBsWrite, pSliceBs->pBsBuffer, pSliceBs->uiSize);
858858
859859 if (bNeedPrefix) {
@@ -978,8 +978,8 @@ int32_t CreateSliceThreads (sWelsEncCtx* pCtx) { · 118 unmodified lines
978978 int32_t FiredSliceThreads (sWelsEncCtx* pCtx, SSliceThreadPrivateData* pPriData, WELS_EVENT* pEventsList,
979979 WELS_EVENT* pMasterEventsList, SLayerBSInfo* pLbi,
980980 const uint32_t uiNumThreads, SSliceCtx* pSliceCtx, const bool bIsDynamicSlicingMode) {
981− int32_t iEndMbIdx = 0;
982− int32_t iIdx = 0;
981+ int32_t iEndMbIdx = 0;
982+ int32_t iIdx = 0;
983983 const int32_t kiEventCnt = uiNumThreads;
984984
985985 if (pPriData == NULL || pLbi == NULL || kiEventCnt <= 0 || pEventsList == NULL) {
@@ -993,10 +993,10 @@ int32_t FiredSliceThreads (sWelsEncCtx* pCtx, SSliceThreadPrivateData* pPriData, · 7 unmodified lines
993993 if (bIsDynamicSlicingMode) {
994994 iEndMbIdx = pSliceCtx->iMbNumInFrame;
995995 for (iIdx = kiEventCnt - 1; iIdx >= 0; --iIdx) {
996− const int32_t iFirstMbIdx = pSliceCtx->pFirstMbInSlice[iIdx];
997− pPriData[iIdx].iStartMbIndex = iFirstMbIdx;
998− pPriData[iIdx].iEndMbIndex = iEndMbIdx;
999− iEndMbIdx = iFirstMbIdx;
996+ const int32_t iFirstMbIdx = pSliceCtx->pFirstMbInSlice[iIdx];
997+ pPriData[iIdx].iStartMbIndex = iFirstMbIdx;
998+ pPriData[iIdx].iEndMbIndex = iEndMbIdx;
999+ iEndMbIdx = iFirstMbIdx;
10001000 }
10011001 }
10021002
@@ -1021,8 +1021,8 @@ int32_t DynamicDetectCpuCores() { · 18 unmodified lines
10211021 }
10221022
10231023 int32_t AdjustBaseLayer (sWelsEncCtx* pCtx) {
1024− SDqLayer* pCurDq = pCtx->ppDqLayerList[0];
1025− int32_t iNeedAdj = 1;
1024+ SDqLayer* pCurDq = pCtx->ppDqLayerList[0];
1025+ int32_t iNeedAdj = 1;
10261026 #ifdef MT_DEBUG
10271027 int64_t iT0 = WelsTime();
10281028 #endif//MT_DEBUG
@@ -1121,10 +1121,10 @@ void TrackSliceConsumeTime (sWelsEncCtx* pCtx, int32_t* pDidList, const int32_t · 92 unmodified lines
11211121
11221122 pPara = pCtx->pSvcParam;
11231123 while (iSpatialIdx < iSpatialNum) {
1124− const int32_t kiDid = pDidList[iSpatialIdx];
1125− SSpatialLayerInternal* pDlp = &pPara->sDependencyLayers[kiDid];
1126− SSliceConfig* pMso = &pDlp->sSliceCfg;
1127− SDqLayer* pCurDq = pCtx->ppDqLayerList[kiDid];
1124+ const int32_t kiDid = pDidList[iSpatialIdx];
1125+ SSpatialLayerInternal* pDlp = &pPara->sDependencyLayers[kiDid];
1126+ SSliceConfig* pMso = &pDlp->sSliceCfg;
1127+ SDqLayer* pCurDq = pCtx->ppDqLayerList[kiDid];
11281128 SSliceCtx* pSliceCtx = pCurDq->pSliceEncCtx;
11291129 const uint32_t kuiCountSliceNum = pSliceCtx->iSliceNumInFrame;
11301130 if (pCtx->pSliceThreading) {

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