History

remove macros to clear codes

sijchen committed 12 years ago

Commit 10a4fb01 parent 3c29c925 files · +35 −520Browse files

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

Unified · Split

codec/encoder/core/src/slice_multi_threading.cpp+8−203
@@ -63,9 +63,7 @@ · 62 unmodified lines
6363 #include "cpu.h"
6464 #endif//X86_ASM
6565
66−#if defined(DYNAMIC_SLICE_ASSIGN) || defined(MT_DEBUG)
6766 #include "measure_time.h"
68−#endif//DYNAMIC_SLICE_ASSIGN
6967 namespace WelsSVCEnc {
7068 void UpdateMbListNeighborParallel (SSliceCtx* pSliceCtx,
7169 SMB* pMbList,
@@ -144,12 +142,8 @@ void CalcSliceComplexRatio (void* pRatio, SSliceCtx* pSliceCtx, uint32_t* pSlice · 72 unmodified lines
144142 }
145143 }
146144
147−#if defined(MT_ENABLED) && defined(DYNAMIC_SLICE_ASSIGN) && defined(NOT_ABSOLUTE_BALANCING)
145+#if defined(MT_ENABLED)
148146 int32_t NeedDynamicAdjust (void* pConsumeTime, const int32_t iSliceNum) {
149−#if !defined(USE_RMSE_SLICE_COMPLEXITY_RATIO_FOR_BALANCING)
150− const float fRatioLower = TOLERANT_BALANCING_RATIO_LOWER (uiSliceNum);
151− const float fRatioUpper = TOLERANT_BALANCING_RATIO_UPPER (uiSliceNum);
152−#endif//USE_RMSE_SLICE_COMPLEXITY_RATIO_FOR_BALANCING
153147 uint32_t* pSliceConsume = (uint32_t*)pConsumeTime;
154148 uint32_t uiTotalConsume = 0;
155149 int32_t iSliceIdx = 0;
@@ -172,7 +166,6 @@ int32_t NeedDynamicAdjust (void* pConsumeTime, const int32_t iSliceNum) { · 16 unmodified lines
172166 }
173167
174168 iSliceIdx = 0;
175−#if defined(USE_RMSE_SLICE_COMPLEXITY_RATIO_FOR_BALANCING)
176169 float fThr = EPSN; // threshold for various cores cases
177170 float fRmse = .0f; // root mean square error of pSlice consume ratios
178171 const float kfMeanRatio = 1.0f / iSliceNum;
@@ -198,27 +191,11 @@ int32_t NeedDynamicAdjust (void* pConsumeTime, const int32_t iSliceNum) { · 19 unmodified lines
198191 "[MT] NeedDynamicAdjust(), herein adjustment decision is made (iNeedAdj= %d) by: fRmse of pSlice complexity ratios %.6f, the corresponding threshold %.6f, iCountSliceNum %d\n",
199192 iNeedAdj, fRmse, fThr, iSliceNum);
200193 #endif//ENABLE_TRACE_MT
201−#else
202− do {
203− const float kfRatio = 1.0f * pSliceConsume[uiSliceIdx] / uiTotalConsume;
204− if (kfRatio + EPSN < fRatioLower || kfRatio > ratio_upper + EPSN) {
205−#if defined(ENABLE_TRACE_MT)
206− WelsLog (NULL, WELS_LOG_DEBUG,
207− "[MT] NeedDynamicAdjust(), herein adjustment decision is made by pSlice consume time not balanced at all, uiSliceIdx= %d, comp_ratio= %.6f, pSliceConsumeTime= %d, total_consume_time= %d, iCountSliceNum= %d\n",
208− uiSliceIdx, kfRatio, pSliceConsume[uiSliceIdx], uiTotalConsume, uiSliceNum);
209−#endif//ENABLE_TRACE_MT
210− iNeedAdj = true;
211− break;
212− }
213− ++ uiSliceIdx;
214− } while (uiSliceIdx + 1 < uiSliceNum);
215−#endif//USE_RMSE_SLICE_COMPLEXITY_RATIO_FOR_BALANCING
216194
217195 return iNeedAdj;
218196 }
219−#endif//..
197+#endif
220198
221−#if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE)
222199 void DynamicAdjustSlicing (sWelsEncCtx* pCtx,
223200 SDqLayer* pCurDqLayer,
224201 void* pComplexRatio,
@@ -320,20 +297,7 @@ void DynamicAdjustSlicing (sWelsEncCtx* pCtx, · 95 unmodified lines
320297 WelsMultipleEventsWaitAllBlocking (kiThreadNum, &pCtx->pSliceThreading->pFinUpdateMbListEvent[0]);
321298 }
322299 }
323−#endif//#if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE)
324300
325−#ifdef PACKING_ONE_SLICE_PER_LAYER
326−void ResetEnvMt (sWelsEncCtx* pCtx) {
327− const int16_t kiSliceCount = pCtx->iMaxSliceCount;
328− int32_t iIdx = 0;
329−
330− while (iIdx < kiSliceCount) {
331− SWelsSliceBs* pSliceBs = &pCtx->pSliceBs[iIdx];
332− pSliceBs->uiBsPos = 0;
333− ++ iIdx;
334− }
335−}
336−#endif//PACKING_ONE_SLICE_PER_LAYER
337301
338302 int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingParam, const int32_t iCountBsLen,
339303 const int32_t iTargetSpatialBsSize) {
@@ -378,7 +342,6 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 38 unmodified lines
378342 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pFinSliceCodingEvent), FreeMemorySvc (ppCtx))
379343 #endif//_WIN32
380344
381−#if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE)
382345 #if defined(__GNUC__)
383346 pSmt->pUpdateMbListThrdHandles = (WELS_THREAD_HANDLE*)pMa->WelsMalloc (sizeof (WELS_THREAD_HANDLE) * iThreadNum,
384347 "pUpdateMbListThrdHandles");
@@ -390,14 +353,12 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 5 unmodified lines
390353 pSmt->pFinUpdateMbListEvent = (WELS_EVENT*)pMa->WelsMalloc (sizeof (WELS_EVENT) * iThreadNum, "pFinUpdateMbListEvent");
391354 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pFinUpdateMbListEvent), FreeMemorySvc (ppCtx))
392355 #endif//_WIN32
393−#endif//#if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE)
394356
395357 #ifdef _WIN32
396358 pSmt->pExitEncodeEvent = (WELS_EVENT*)pMa->WelsMalloc (sizeof (WELS_EVENT) * iThreadNum, "pExitEncodeEvent");
397359 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pExitEncodeEvent), FreeMemorySvc (ppCtx))
398360 #endif//_WIN32
399361
400−#if defined(DYNAMIC_SLICE_ASSIGN) || defined(MT_DEBUG)
401362 iIdx = 0;
402363 while (iIdx < iNumSpatialLayers) {
403364 SSliceConfig* pMso = &pPara->sDependencyLayers[iIdx].sSliceCfg;
@@ -406,20 +367,15 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 2 unmodified lines
406367 && pPara->iMultipleThreadIdc >= kiSliceNum) {
407368 pSmt->pSliceConsumeTime[iIdx] = (uint32_t*)pMa->WelsMallocz (kiSliceNum * sizeof (uint32_t), "pSliceConsumeTime[]");
408369 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pSliceConsumeTime[iIdx]), FreeMemorySvc (ppCtx))
409−#if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE)
410370 pSmt->pSliceComplexRatio[iIdx] = (float*)pMa->WelsMalloc (kiSliceNum * sizeof (float), "pSliceComplexRatio[]");
411371 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pSliceComplexRatio[iIdx]), FreeMemorySvc (ppCtx))
412−#endif//TRY_SLICING_BALANCE
413372 } else {
414373 pSmt->pSliceConsumeTime[iIdx] = NULL;
415−#if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE)
416374 pSmt->pSliceComplexRatio[iIdx] = NULL;
417−#endif//TRY_SLICING_BALANCE
418375 }
419376 ++ iIdx;
420377 }
421378 // NULL for pSliceConsumeTime[iIdx]: iIdx from iNumSpatialLayers to MAX_DEPENDENCY_LAYERS
422−#endif//#if defined(DYNAMIC_SLICE_ASSIGN) || defined(MT_DEBUG)
423379
424380 #ifdef MT_DEBUG
425381 // file handle for MT debug
@@ -447,7 +403,6 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 21 unmodified lines
447403 pSmt->pThreadPEncCtx[iIdx].iThreadIndex = iIdx;
448404 pSmt->pThreadHandles[iIdx] = 0;
449405
450−#if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE)
451406 #ifdef _WIN32
452407 WelsEventInit (&pSmt->pUpdateMbListEvent[iIdx]);
453408 WelsEventInit (&pSmt->pFinUpdateMbListEvent[iIdx]);
@@ -464,7 +419,6 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 10 unmodified lines
464419 WelsLog ((*ppCtx), WELS_LOG_INFO, "[MT] Open pFinUpdateMbListEvent%d named(%s) ret%d err%d\n", iIdx, name, err, errno);
465420 #endif
466421 #endif//_WIN32
467−#endif//#if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE)
468422
469423 #ifdef _WIN32
470424 WelsEventInit (&pSmt->pSliceCodedEvent[iIdx]);
@@ -488,11 +442,6 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 17 unmodified lines
488442 ++ iIdx;
489443 }
490444
491−#ifdef PACKING_ONE_SLICE_PER_LAYER
492− pSmt->pCountBsSizeInPartition = (uint32_t*)pMa->WelsMalloc (sizeof (uint32_t) * iThreadNum, "pCountBsSizeInPartition");
493− WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pCountBsSizeInPartition), FreeMemorySvc (ppCtx))
494−#endif//PACKING_ONE_SLICE_PER_LAYER
495−
496445 (*ppCtx)->pSliceBs = (SWelsSliceBs*)pMa->WelsMalloc (sizeof (SWelsSliceBs) * iMaxSliceNum, "pSliceBs");
497446 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pSliceBs), FreeMemorySvc (ppCtx))
498447
@@ -566,12 +515,10 @@ void ReleaseMtResource (sWelsEncCtx** ppCtx) { · 67 unmodified lines
566515 WelsEventDestroy (&pSmt->pFinSliceCodingEvent[iIdx]);
567516 if (pSmt->pExitEncodeEvent != NULL)
568517 WelsEventDestroy (&pSmt->pExitEncodeEvent[iIdx]);
569−#if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE)
570518 if (pSmt->pUpdateMbListEvent != NULL)
571519 WelsEventDestroy (&pSmt->pUpdateMbListEvent[iIdx]);
572520 if (pSmt->pFinUpdateMbListEvent != NULL)
573521 WelsEventDestroy (&pSmt->pFinUpdateMbListEvent[iIdx]);
574−#endif//DYNAMIC_SLICE_ASSIGN && TRY_SLICING_BALANCE
575522 #else
576523 char ename[SEM_NAME_MAX] = {0};
577524 // length of semaphore name should be system constrained at least on mac 10.7
@@ -579,12 +526,10 @@ void ReleaseMtResource (sWelsEncCtx** ppCtx) { · 1 unmodified line
579526 WelsEventClose (pSmt->pSliceCodedEvent[iIdx], ename);
580527 WelsSnprintf (ename, SEM_NAME_MAX, "rc%d%p", iIdx, (void*) (*ppCtx));
581528 WelsEventClose (pSmt->pReadySliceCodingEvent[iIdx], ename);
582−#if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE)
583529 WelsSnprintf (ename, SEM_NAME_MAX, "ud%d%p", iIdx, (void*) (*ppCtx));
584530 WelsEventClose (pSmt->pUpdateMbListEvent[iIdx], ename);
585531 WelsSnprintf (ename, SEM_NAME_MAX, "fu%d%p", iIdx, (void*) (*ppCtx));
586532 WelsEventClose (pSmt->pFinUpdateMbListEvent[iIdx], ename);
587−#endif//DYNAMIC_SLICE_ASSIGN && TRY_SLICING_BALANCE
588533 #endif//_WIN32
589534
590535 ++ iIdx;
@@ -609,13 +554,6 @@ void ReleaseMtResource (sWelsEncCtx** ppCtx) { · 18 unmodified lines
609554 }
610555 #endif//_WIN32
611556
612−#ifdef PACKING_ONE_SLICE_PER_LAYER
613− if (NULL != pSmt->pCountBsSizeInPartition) {
614− pMa->WelsFree (pSmt->pCountBsSizeInPartition, "pCountBsSizeInPartition");
615− pSmt->pCountBsSizeInPartition = NULL;
616− }
617−#endif//PACKING_ONE_SLICE_PER_LAYER
618−
619557 WelsMutexDestroy (&pSmt->mutexSliceNumUpdate);
620558 WelsMutexDestroy (&((*ppCtx)->mutexEncoderError));
621559
@@ -643,24 +581,18 @@ void ReleaseMtResource (sWelsEncCtx** ppCtx) { · 21 unmodified lines
643581 pMa->WelsFree ((*ppCtx)->pSliceBs, "pSliceBs");
644582 (*ppCtx)->pSliceBs = NULL;
645583 }
646−#if defined(DYNAMIC_SLICE_ASSIGN) || defined(MT_DEBUG)
647584 iIdx = 0;
648585 while (iIdx < pCodingParam->iSpatialLayerNum) {
649586 if (pSmt->pSliceConsumeTime[iIdx]) {
650587 pMa->WelsFree (pSmt->pSliceConsumeTime[iIdx], "pSliceConsumeTime[]");
651588 pSmt->pSliceConsumeTime[iIdx] = NULL;
652589 }
653−#if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE)
654590 if (pSmt->pSliceComplexRatio[iIdx] != NULL) {
655591 pMa->WelsFree (pSmt->pSliceComplexRatio[iIdx], "pSliceComplexRatio[]");
656592 pSmt->pSliceComplexRatio[iIdx] = NULL;
657593 }
658−#endif//TRY_SLICING_BALANCE
659594 ++ iIdx;
660595 }
661−#endif//#if defined(DYNAMIC_SLICE_ASSIGN) || defined(MT_DEBUG)
662−
663−#if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE)
664596
665597 #ifdef _WIN32
666598 if (pSmt->pUpdateMbListEvent != NULL) {
@@ -678,8 +610,6 @@ void ReleaseMtResource (sWelsEncCtx** ppCtx) { · 11 unmodified lines
678610 }
679611 #endif//_WIN32
680612
681−#endif//#if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE)
682−
683613 #ifdef MT_DEBUG
684614 // file handle for debug
685615 if (pSmt->pFSliceDiff) {
@@ -781,12 +711,8 @@ int32_t WriteSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, uint8_t* pFr · 95 unmodified lines
781711 const int32_t kiNalCnt = pSliceBs->iNalIndex;
782712 int32_t iNalIdx = 0;
783713 int32_t iNalSize = 0;
784−#if !defined(PACKING_ONE_SLICE_PER_LAYER)
785714 const int32_t iFirstSlice = (iSliceIdx == 0);
786715 int32_t iNalBase = iFirstSlice ? 0 : pLbi->iNalCount;
787−#else
788− int32_t iNalBase = 0;
789−#endif//!PACKING_ONE_SLICE_PER_LAYER
790716 int32_t iReturn = ENC_RETURN_SUCCESS;
791717 const int32_t kiWrittenLength = pCtx->iPosBsBuffer;
792718 iSliceSize = 0;
@@ -803,7 +729,6 @@ int32_t WriteSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, uint8_t* pFr · 10 unmodified lines
803729 ++ iNalIdx;
804730 }
805731
806−#if !defined(PACKING_ONE_SLICE_PER_LAYER)
807732 pSliceBs->uiBsPos = iSliceSize;
808733 if (iFirstSlice) {
809734 // pBsBuffer has been updated at coding_slice_0_in_encoder_mother_thread()
@@ -816,14 +741,6 @@ int32_t WriteSliceToFrameBs (sWelsEncCtx* pCtx, SLayerBSInfo* pLbi, uint8_t* pFr · 6 unmodified lines
816741 } else {
817742 pLbi->iNalCount += kiNalCnt;
818743 }
819−#else
820− pLbi->uiLayerType = VIDEO_CODING_LAYER;
821− pLbi->uiSpatialId = pNalHdrExt->uiDependencyId;
822− pLbi->uiTemporalId = pNalHdrExt->uiTemporalId;
823− pLbi->uiQualityId = 0;
824− pLbi->uiPriorityId = 0;
825− pLbi->iNalCount = kiNalCnt;
826−#endif//PACKING_ONE_SLICE_PER_LAYER
827744
828745 return ENC_RETURN_SUCCESS;
829746 }
@@ -858,7 +775,6 @@ int32_t WriteSliceBs (sWelsEncCtx* pCtx, uint8_t* pSliceBsBuf, const int32_t iSl · 28 unmodified lines
858775 return iReturn;
859776 }
860777
861−#if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE)
862778 #if defined(__GNUC__) && !defined(_WIN32)
863779 WELS_THREAD_ROUTINE_TYPE UpdateMbListThreadProc (void* arg) {
864780 SSliceThreadPrivateData* pPrivateData = (SSliceThreadPrivateData*)arg;
@@ -899,7 +815,6 @@ WELS_THREAD_ROUTINE_TYPE UpdateMbListThreadProc (void* arg) { · 34 unmodified lines
899815 WELS_THREAD_ROUTINE_RETURN (uiThrdRet);
900816 }
901817 #endif//__GNUC__
902−#endif//#if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE)
903818
904819 // thread process for coding one pSlice
905820 WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) {
@@ -936,9 +851,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 30 unmodified lines
936851 #ifdef _WIN32
937852 pEventsList[iEventCount++] = pEncPEncCtx->pSliceThreading->pReadySliceCodingEvent[iEventIdx];
938853 pEventsList[iEventCount++] = pEncPEncCtx->pSliceThreading->pExitEncodeEvent[iEventIdx];
939−#if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE)
940854 pEventsList[iEventCount++] = pEncPEncCtx->pSliceThreading->pUpdateMbListEvent[iEventIdx];
941−#endif//#if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE)
942855 #endif//_WIN32
943856
944857 do {
@@ -973,17 +886,13 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 28 unmodified lines
973886 pSlice = &pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx];
974887 pSliceBs = &pEncPEncCtx->pSliceBs[iSliceIdx];
975888
976−#if defined(DYNAMIC_SLICE_ASSIGN) || defined(MT_DEBUG)
977889 bDsaFlag = (pParamD->sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE &&
978890 pCodingParam->iMultipleThreadIdc > 1 &&
979891 pCodingParam->iMultipleThreadIdc >= pParamD->sSliceCfg.sSliceArgument.uiSliceNum);
980892 if (bDsaFlag)
981893 iSliceStart = WelsTime();
982−#endif//DYNAMIC_SLICE_ASSIGN || MT_DEBUG
983894
984−#if !defined(PACKING_ONE_SLICE_PER_LAYER)
985895 pSliceBs->uiBsPos = 0;
986−#endif//!PACKING_ONE_SLICE_PER_LAYER
987896 pSliceBs->iNalIndex = 0;
988897 assert ((void*) (&pSliceBs->sBsWrite) == (void*)pSlice->pSliceBsa);
989898 InitBits (&pSliceBs->sBsWrite, pSliceBs->pBsBuffer, pSliceBs->uiSize);
@@ -1014,7 +923,6 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 24 unmodified lines
1014923
1015924 WelsUnloadNalForSlice (pSliceBs);
1016925
1017−#if !defined(PACKING_ONE_SLICE_PER_LAYER)
1018926 if (0 == iSliceIdx) {
1019927 pLbi->pBsBuf = pEncPEncCtx->pFrameBs + pEncPEncCtx->iPosBsBuffer;
1020928 iReturn = WriteSliceToFrameBs (pEncPEncCtx, pLbi, pLbi->pBsBuf, iSliceIdx, iSliceSize);
@@ -1031,25 +939,6 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 10 unmodified lines
1031939 break;
1032940 }
1033941 }
1034−#else// PACKING_ONE_SLICE_PER_LAYER
1035− if (0 == iSliceIdx) {
1036− pLbi->pBsBuf = pEncPEncCtx->pFrameBs + pEncPEncCtx->iPosBsBuffer;
1037− iReturn = WriteSliceToFrameBs (pEncPEncCtx, pLbi, pLbi->pBsBuf, iSliceIdx, &iSliceSize);
1038− if (ENC_RETURN_SUCCESS!=iReturn) {
1039− uiThrdRet = iReturn;
1040− break;
1041− }
1042− pEncPEncCtx->iPosBsBuffer += iSliceSize;
1043− } else {
1044− pLbi->pBsBuf = pSliceBs->bs + pSliceBs->uiBsPos;
1045− iReturn = WriteSliceToFrameBs (pEncPEncCtx, pLbi, pLbi->pBsBuf, iSliceIdx, &iSliceSize);
1046− if (ENC_RETURN_SUCCESS!=iReturn) {
1047− uiThrdRet = iReturn;
1048− break;
1049− }
1050− pSliceBs->uiBsPos += iSliceSize;
1051− }
1052−#endif//!PACKING_ONE_SLICE_PER_LAYER
1053942
1054943 if (pCurDq->bDeblockingParallelFlag && pSlice->sSliceHeaderExt.sSliceHeader.uiDisableDeblockingFilterIdc != 1
1055944 #if !defined(ENABLE_FRAME_DUMP)
@@ -1060,7 +949,6 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 4 unmodified lines
1060949 DeblockingFilterSliceAvcbase (pCurDq, pEncPEncCtx->pFuncList, iSliceIdx);
1061950 }
1062951
1063−#if defined(DYNAMIC_SLICE_ASSIGN) || defined(MT_DEBUG)
1064952 if (bDsaFlag) {
1065953 pEncPEncCtx->pSliceThreading->pSliceConsumeTime[pEncPEncCtx->uiDependencyId][iSliceIdx] = (uint32_t) (
1066954 WelsTime() - iSliceStart);
@@ -1072,7 +960,6 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 5 unmodified lines
1072960 pCurDq->pSliceEncCtx->pFirstMbInSlice[iSliceIdx], pCurDq->pSliceEncCtx->pCountMbNumInSlice[iSliceIdx]);
1073961 #endif//ENABLE_TRACE_MT
1074962 }
1075−#endif//DYNAMIC_SLICE_ASSIGN || MT_DEBUG
1076963
1077964 #if defined(SLICE_INFO_OUTPUT)
1078965 fprintf (stderr,
@@ -1095,9 +982,6 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 16 unmodified lines
1095982 WelsEventSignal (pEncPEncCtx->pSliceThreading->pSliceCodedEvent[iEventIdx]); // mean finished coding current pSlice
1096983 #endif//WIN32
1097984 } else { // for SM_DYN_SLICE parallelization
1098−#ifdef PACKING_ONE_SLICE_PER_LAYER
1099− SLayerBSInfo* pLbiPacking = NULL;
1100−#endif//PACKING_ONE_SLICE_PER_LAYER
1101985 SSliceCtx* pSliceCtx = pCurDq->pSliceEncCtx;
1102986 const int32_t kiPartitionId = iThreadIdx;
1103987 const int32_t kiSliceIdxStep = pEncPEncCtx->iActiveThreadsNum;
@@ -1124,9 +1008,7 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 20 unmodified lines
11241008 pSlice = &pCurDq->sLayerInfo.pSliceInLayer[iSliceIdx];
11251009 pSliceBs = &pEncPEncCtx->pSliceBs[iSliceIdx];
11261010
1127−#if !defined(PACKING_ONE_SLICE_PER_LAYER)
11281011 pSliceBs->uiBsPos = 0;
1129−#endif//!PACKING_ONE_SLICE_PER_LAYER
11301012 pSliceBs->iNalIndex = 0;
11311013 InitBits (&pSliceBs->sBsWrite, pSliceBs->pBsBuffer, pSliceBs->uiSize);
11321014
@@ -1152,7 +1034,6 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 19 unmodified lines
11521034
11531035 WelsUnloadNalForSlice (pSliceBs);
11541036
1155−#if !defined(PACKING_ONE_SLICE_PER_LAYER)
11561037 if (0 == kiPartitionId) {
11571038 if (0 == iSliceIdx)
11581039 pLbi->pBsBuf = pEncPEncCtx->pFrameBs + pEncPEncCtx->iPosBsBuffer;
@@ -1170,28 +1051,6 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 11 unmodified lines
11701051 break;
11711052 }
11721053 }
1173−#else// PACKING_ONE_SLICE_PER_LAYER
1174− pLbiPacking = pLbi + (iSliceIdx - kiPartitionId);
1175−
1176− if (0 == kiPartitionId) {
1177− pLbiPacking->pBsBuf = pEncPEncCtx->pFrameBs + pEncPEncCtx->iPosBsBuffer;
1178− iReturn = WriteSliceToFrameBs (pEncPEncCtx, pLbiPacking, pLbiPacking->pBsBuf, iSliceIdx, iSliceSize);
1179− if (ENC_RETURN_SUCCESS!=iReturn) {
1180− uiThrdRet = iReturn;
1181− break;
1182− }
1183− pEncPEncCtx->iPosBsBuffer += iSliceSize;
1184− } else {
1185− pLbiPacking->pBsBuf = pSliceBs->bs + pSliceBs->uiBsPos;
1186− iReturn = WriteSliceToFrameBs (pEncPEncCtx, pLbiPacking, pLbiPacking->pBsBuf, iSliceIdx, iSliceSize);
1187− if (ENC_RETURN_SUCCESS!=iReturn) {
1188− uiThrdRet = iReturn;
1189− break;
1190− }
1191− pSliceBs->uiBsPos += iSliceSize;
1192− }
1193− pEncPEncCtx->pSliceThreading->pCountBsSizeInPartition[kiPartitionId] += iSliceSize;
1194−#endif//!PACKING_ONE_SLICE_PER_LAYER
11951054
11961055 if (pCurDq->bDeblockingParallelFlag && pSlice->sSliceHeaderExt.sSliceHeader.uiDisableDeblockingFilterIdc != 1
11971056 #if !defined(ENABLE_FRAME_DUMP)
@@ -1238,7 +1097,6 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 40 unmodified lines
12381097 uiThrdRet = 0;
12391098 break;
12401099 }
1241−#if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE)
12421100 else if (WELS_THREAD_ERROR_WAIT_OBJECT_0 + 2 == iWaitRet) { // update pMb list singal
12431101 iSliceIdx =
12441102 iEventIdx; // pPrivateData->iSliceIndex; old threads can not be terminated, pPrivateData is not correct for applicable
@@ -1247,7 +1105,6 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 2 unmodified lines
12471105 WelsEventSignal (
12481106 &pEncPEncCtx->pSliceThreading->pFinUpdateMbListEvent[iEventIdx]); // mean finished update pMb list for this pSlice
12491107 }
1250−#endif//#if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE)
12511108 #endif//WIN32
12521109 else { // WELS_THREAD_ERROR_WAIT_TIMEOUT, or WELS_THREAD_ERROR_WAIT_FAILED
12531110 WelsLog (pEncPEncCtx, WELS_LOG_WARNING,
@@ -1299,12 +1156,10 @@ int32_t CreateSliceThreads (sWelsEncCtx* pCtx) { · 45 unmodified lines
12991156 // We need extra threads for update_mb_list_proc on __GNUC__ like OS (mac/linux)
13001157 // due to WelsMultipleEventsWaitSingleBlocking implememtation can not work well
13011158 // in case waiting pUpdateMbListEvent and pReadySliceCodingEvent events at the same time
1302−#if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE)
13031159 #if defined(__GNUC__) && !defined(_WIN32)
13041160 WelsThreadCreate (&pCtx->pSliceThreading->pUpdateMbListThrdHandles[iIdx], UpdateMbListThreadProc,
13051161 &pCtx->pSliceThreading->pThreadPEncCtx[iIdx], 0);
13061162 #endif//__GNUC__
1307−#endif//#if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE)
13081163
13091164 ++ iIdx;
13101165 }
@@ -1314,14 +1169,6 @@ int32_t CreateSliceThreads (sWelsEncCtx* pCtx) { · 3 unmodified lines
13141169 return 0;
13151170 }
13161171
1317−#ifdef PACKING_ONE_SLICE_PER_LAYER
1318−void ResetCountBsSizeInPartitions (uint32_t* pCountBsSizeList, const int32_t iPartitionCnt) {
1319− if (pCountBsSizeList != NULL && iPartitionCnt > 0) {
1320− memset (pCountBsSizeList, 0, sizeof (pCountBsSizeList[0]) * iPartitionCnt);
1321− }
1322−}
1323−#endif//PACKING_ONE_SLICE_PER_LAYER
1324−
13251172 #ifdef _WIN32
13261173 int32_t FiredSliceThreads (SSliceThreadPrivateData* pPriData, WELS_EVENT* pEventsList, SLayerBSInfo* pLbi,
13271174 const uint32_t uiNumThreads, SSliceCtx* pSliceCtx, const bool bIsDynamicSlicingMode)
@@ -1341,33 +1188,6 @@ int32_t FiredSliceThreads (SSliceThreadPrivateData* pPriData, WELS_EVENT** pEven · 13 unmodified lines
13411188 return 1;
13421189 }
13431190
1344−#if defined(PACKING_ONE_SLICE_PER_LAYER)
1345− ////////////////////////////////////////
1346− if (bIsDynamicSlicingMode) {
1347− iEndMbIdx = pSliceCtx->iMbNumInFrame;
1348− for (iIdx = kiEventCnt - 1; iIdx >= 0; --iIdx) {
1349− const int32_t kiFirstMbIdx = pSliceCtx->pFirstMbInSlice[iIdx];
1350− pPriData[iIdx].iStartMbIndex = kiFirstMbIdx;
1351− pPriData[iIdx].iEndMbIndex = iEndMbIdx;
1352− iEndMbIdx = kiFirstMbIdx;
1353− }
1354− }
1355−
1356− iIdx = 0;
1357− while (iIdx < kiEventCnt) {
1358− pPriData[iIdx].pLayerBs = pLbi;
1359− pPriData[iIdx].iSliceIndex = iIdx;
1360−#ifdef _WIN32
1361− if (pEventsList[iIdx])
1362− WelsEventSignal (&pEventsList[iIdx]);
1363−#else
1364− WelsEventSignal (pEventsList[iIdx]);
1365−#endif//WIN32
1366− ++ pLbi;
1367− ++ iIdx;
1368− }
1369− ////////////////////////////////////////
1370−#else
13711191 ////////////////////////////////////////
13721192 if (bIsDynamicSlicingMode) {
13731193 iEndMbIdx = pSliceCtx->iMbNumInFrame;
@@ -1391,8 +1211,6 @@ int32_t FiredSliceThreads (SSliceThreadPrivateData* pPriData, WELS_EVENT** pEven · 17 unmodified lines
13911211 #endif//WIN32
13921212 ++ iIdx;
13931213 }
1394− ////////////////////////////////////////
1395−#endif//PACKING_ONE_SLICE_PER_LAYER
13961214
13971215 return 0;
13981216 }
@@ -1403,28 +1221,23 @@ int32_t DynamicDetectCpuCores() { · 4 unmodified lines
14031221 return info.ProcessorCount;
14041222 }
14051223
1406−#if defined(MT_ENABLED) && defined(DYNAMIC_SLICE_ASSIGN)
1407−
1224+#if defined(MT_ENABLED)
14081225 int32_t AdjustBaseLayer (sWelsEncCtx* pCtx) {
14091226 SDqLayer* pCurDq = pCtx->ppDqLayerList[0];
14101227 int32_t iNeedAdj = 1;
14111228 #ifdef MT_DEBUG
14121229 int64_t iT0 = WelsTime();
14131230 #endif//MT_DEBUG
1414−#ifdef TRY_SLICING_BALANCE
14151231
14161232 pCtx->pCurDqLayer = pCurDq;
14171233
1418−#ifdef NOT_ABSOLUTE_BALANCING
14191234 // do not need adjust due to not different at both slices of consumed time
14201235 iNeedAdj = NeedDynamicAdjust (pCtx->pSliceThreading->pSliceConsumeTime[0], pCurDq->pSliceEncCtx->iSliceNumInFrame);
14211236 if (iNeedAdj)
1422−#endif//NOT_ABSOLUTE_BALANCING
14231237 DynamicAdjustSlicing (pCtx,
14241238 pCurDq,
14251239 pCtx->pSliceThreading->pSliceComplexRatio[0],
14261240 0);
1427−#endif//TRY_SLICING_BALANCE
14281241 #ifdef MT_DEBUG
14291242 iT0 = WelsTime() - iT0;
14301243 if (pCtx->pSliceThreading->pFSliceDiff) {
@@ -1455,33 +1268,25 @@ int32_t AdjustEnhanceLayer (sWelsEncCtx* pCtx, int32_t iCurDid) { · 24 unmodified lines
14551268 1].sSliceCfg.sSliceArgument.uiSliceNum);
14561269
14571270 if (kbModelingFromSpatial) { // using spatial base layer for complexity estimation
1458−#ifdef TRY_SLICING_BALANCE
1459−#ifdef NOT_ABSOLUTE_BALANCING
14601271 // do not need adjust due to not different at both slices of consumed time
14611272 iNeedAdj = NeedDynamicAdjust (pCtx->pSliceThreading->pSliceConsumeTime[iCurDid - 1],
14621273 pCtx->pCurDqLayer->pSliceEncCtx->iSliceNumInFrame);
14631274 if (iNeedAdj)
1464−#endif//NOT_ABSOLUTE_BALANCING
14651275 DynamicAdjustSlicing (pCtx,
14661276 pCtx->pCurDqLayer,
14671277 pCtx->pSliceThreading->pSliceComplexRatio[iCurDid - 1],
14681278 iCurDid
14691279 );
1470−#endif//TRY_SLICING_BALANCE
14711280 } else { // use temporal layer for complexity estimation
1472−#ifdef TRY_SLICING_BALANCE
1473−#ifdef NOT_ABSOLUTE_BALANCING
14741281 // do not need adjust due to not different at both slices of consumed time
14751282 iNeedAdj = NeedDynamicAdjust (pCtx->pSliceThreading->pSliceConsumeTime[iCurDid],
14761283 pCtx->pCurDqLayer->pSliceEncCtx->iSliceNumInFrame);
14771284 if (iNeedAdj)
1478−#endif//NOT_ABSOLUTE_BALANCING
14791285 DynamicAdjustSlicing (pCtx,
14801286 pCtx->pCurDqLayer,
14811287 pCtx->pSliceThreading->pSliceComplexRatio[iCurDid],
14821288 iCurDid
14831289 );
1484−#endif//TRY_SLICING_BALANCE
14851290 }
14861291
14871292 #ifdef MT_DEBUG
@@ -1500,11 +1305,11 @@ int32_t AdjustEnhanceLayer (sWelsEncCtx* pCtx, int32_t iCurDid) { · 12 unmodified lines
15001305 return iNeedAdj;
15011306 }
15021307
1503−#endif//#if defined(MT_ENABLED) && defined(DYNAMIC_SLICE_ASSIGN)
1308+#endif//#if defined(MT_ENABLED)
15041309
15051310 #if defined(MT_ENABLED)
15061311
1507−#if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE) && defined(MT_DEBUG)
1312+#if defined(MT_DEBUG)
15081313 void TrackSliceComplexities (sWelsEncCtx* pCtx, const int32_t iCurDid) {
15091314 const int32_t kiCountSliceNum = pCtx->pCurDqLayer->pSliceEncCtx->iSliceNumInFrame;
15101315 if (kiCountSliceNum > 0) {
@@ -1516,9 +1321,9 @@ void TrackSliceComplexities (sWelsEncCtx* pCtx, const int32_t iCurDid) { · 5 unmodified lines
15161321 } while (iSliceIdx < kiCountSliceNum);
15171322 }
15181323 }
1519−#endif//#if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE)
1324+#endif
15201325
1521−#if defined(DYNAMIC_SLICE_ASSIGN) && defined(MT_DEBUG)
1326+#if defined(MT_DEBUG)
15221327 void TrackSliceConsumeTime (sWelsEncCtx* pCtx, int32_t* pDidList, const int32_t iSpatialNum) {
15231328 SWelsSvcCodingParam* pPara = NULL;
15241329 int32_t iSpatialIdx = 0;
@@ -1557,7 +1362,7 @@ void TrackSliceConsumeTime (sWelsEncCtx* pCtx, int32_t* pDidList, const int32_t · 32 unmodified lines
15571362 ++ iSpatialIdx;
15581363 }
15591364 }
1560−#endif//#if defined(DYNAMIC_SLICE_ASSIGN) || defined(MT_DEBUG)
1365+#endif//#if defined(MT_DEBUG)
15611366
15621367 #endif//MT_ENABLED
15631368 }

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