History

Merge pull request #369 from sijchen/mt_refactor3

[Encoder] remove macros to clear codes

Ethan Hugg committed 12 years ago

Commit 6e9df662 parents 33017fa 10a4fb05 files · +35 −520Browse files

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

Unified · Split

codec/encoder/core/src/encoder_ext.cpp+19−192
@@ -54,9 +54,7 @@ · 53 unmodified lines
5454 #if defined(MT_ENABLED)
5555 #include "slice_multi_threading.h"
5656 #endif//MT_ENABLED
57−#if defined(DYNAMIC_SLICE_ASSIGN) || defined(MT_DEBUG)
5857 #include "measure_time.h"
59−#endif//DYNAMIC_SLICE_ASSIGN
6058
6159 namespace WelsSVCEnc {
6260
@@ -467,9 +465,6 @@ static inline int32_t AcquireLayersNals (sWelsEncCtx** ppCtx, SWelsSvcCodingPara · 404 unmodified lines
467465 int32_t iCountNumNals = 0;
468466 int32_t iNumDependencyLayers = 0;
469467 int32_t iDIndex = 0;
470−#if defined(MT_ENABLED) && defined(PACKING_ONE_SLICE_PER_LAYER)
471− int32_t iNumLayersPack = 0;
472−#endif//MT_ENABLED && PACKING_ONE_SLICE_PER_LAYER
473468
474469 if (NULL == pParam || NULL == ppCtx || NULL == *ppCtx)
475470 return 1;
@@ -491,12 +486,7 @@ static inline int32_t AcquireLayersNals (sWelsEncCtx** ppCtx, SWelsSvcCodingPara · 15 unmodified lines
491486 if (iDIndex == 0)
492487 iCountNumNals += MAX_SLICES_NUM;
493488 // MAX_SLICES_NUM < MAX_LAYER_NUM_OF_FRAME ensured at svc_enc_slice_segment.h
494−#if defined(MT_ENABLED) && defined(PACKING_ONE_SLICE_PER_LAYER)
495− assert (MAX_SLICES_NUM < MAX_LAYER_NUM_OF_FRAME);
496− // iNumLayersPack += MAX_SLICES_NUM; // do not count it for dynamic slicing mode
497−#else//!MT_ENABLED || !PACKING_ONE_SLICE_PER_LAYER
498489 assert (iCountNumNals - iOrgNumNals <= MAX_NAL_UNITS_IN_LAYER);
499−#endif//MT_ENABLED && PACKING_ONE_SLICE_PER_LAYER
500490 } else { /*if ( SM_SINGLE_SLICE != pDLayer->sSliceCfg.uiSliceMode )*/
501491 const int32_t kiNumOfSlice = GetInitialSliceNum ((pDLayer->iFrameWidth + 0x0f) >> 4,
502492 (pDLayer->iFrameHeight + 0x0f) >> 4,
@@ -507,12 +497,7 @@ static inline int32_t AcquireLayersNals (sWelsEncCtx** ppCtx, SWelsSvcCodingPara · 4 unmodified lines
507497 // plus prefix NALs
508498 if (iDIndex == 0)
509499 iCountNumNals += kiNumOfSlice;
510−#if defined(MT_ENABLED) && defined(PACKING_ONE_SLICE_PER_LAYER)
511− assert (num_of_slice <= MAX_SLICES_NUM && MAX_SLICES_NUM < MAX_LAYER_NUM_OF_FRAME);
512− iNumLayersPack += num_of_slice;
513−#else//!MT_ENABLED || !PACKING_ONE_SLICE_PER_LAYER
514500 assert (iCountNumNals - iOrgNumNals <= MAX_NAL_UNITS_IN_LAYER);
515−#endif//MT_ENALBED && PACKING_ONE_SLICE_PER_LAYER
516501 if (kiNumOfSlice > MAX_SLICES_NUM) {
517502 WelsLog (*ppCtx, WELS_LOG_ERROR,
518503 "AcquireLayersNals(), num_of_slice(%d) > MAX_SLICES_NUM(%d) per (iDid= %d, qid= %d) settings!\n",
@@ -520,14 +505,13 @@ static inline int32_t AcquireLayersNals (sWelsEncCtx** ppCtx, SWelsSvcCodingPara · 1 unmodified line
520505 return 1;
521506 }
522507 }
523−#if !defined(MT_ENABLED) || !defined(PACKING_ONE_SLICE_PER_LAYER)
508+
524509 if (iCountNumNals - iOrgNumNals > MAX_NAL_UNITS_IN_LAYER) {
525510 WelsLog (*ppCtx, WELS_LOG_ERROR,
526− "AcquireLayersNals(), num_of_nals(%d) > MAX_NAL_UNITS_IN_LAYER(%d) per (iDid= %d, qid= %d) settings!\n",
527− (iCountNumNals - iOrgNumNals), MAX_NAL_UNITS_IN_LAYER, iDIndex, 0);
511+ "AcquireLayersNals(), num_of_nals(%d) > MAX_NAL_UNITS_IN_LAYER(%d) per (iDid= %d, qid= %d) settings!\n",
512+ (iCountNumNals - iOrgNumNals), MAX_NAL_UNITS_IN_LAYER, iDIndex, 0);
528513 return 1;
529514 }
530−#endif//!MT_ENABLED) || !PACKING_ONE_SLICE_PER_LAYER
531515
532516 iCountNumLayers ++;
533517
@@ -536,9 +520,6 @@ static inline int32_t AcquireLayersNals (sWelsEncCtx** ppCtx, SWelsSvcCodingPara · 2 unmodified lines
536520
537521 iCountNumNals += 1 + iNumDependencyLayers + (iCountNumLayers << 1) +
538522 iCountNumLayers; // plus iCountNumLayers for reserved application
539−#if defined(MT_ENABLED) && defined(PACKING_ONE_SLICE_PER_LAYER)
540− iNumLayersPack += 1 + iNumDependencyLayers + (iCountNumLayers << 1);
541−#endif//MT_ENABLED && PACKING_ONE_SLICE_PER_LAYER
542523
543524 // to check number of layers / nals / slices dependencies, 12/8/2010
544525 #if !defined(MT_ENABLED)
@@ -548,19 +529,11 @@ static inline int32_t AcquireLayersNals (sWelsEncCtx** ppCtx, SWelsSvcCodingPara · 3 unmodified lines
548529 return 1;
549530 }
550531 #else//MT_ENABLED
551−#if defined(PACKING_ONE_SLICE_PER_LAYER)
552− if (iNumLayersPack > MAX_LAYER_NUM_OF_FRAME) {
553− WelsLog (*ppCtx, WELS_LOG_ERROR, "AcquireLayersNals(), num_layers_pack_overall(%d) > MAX_LAYER_NUM_OF_FRAME(%d)!",
554− iNumLayersPack, MAX_LAYER_NUM_OF_FRAME);
555− return 1;
556− }
557−#else//!PACKING_ONE_SLICE_PER_LAYER
558532 if (iCountNumLayers > MAX_LAYER_NUM_OF_FRAME) {
559533 WelsLog (*ppCtx, WELS_LOG_ERROR, "AcquireLayersNals(), iCountNumLayers(%d) > MAX_LAYER_NUM_OF_FRAME(%d)!",
560534 iCountNumLayers, MAX_LAYER_NUM_OF_FRAME);
561535 return 1;
562536 }
563−#endif//PACKING_ONE_SLICE_PER_LAYER
564537 #endif//!MT_ENABLED
565538
566539 if (NULL != pCountLayers)
@@ -1770,14 +1743,9 @@ int32_t InitSliceSettings (SWelsSvcCodingParam* pCodingParam, const int32_t kiCp · 1203 unmodified lines
17701743 const int32_t kiMbHeight = (pDlp->iFrameHeight + 15) >> 4;
17711744 const int32_t kiMbNumInFrame = kiMbWidth * kiMbHeight;
17721745 #if defined(MT_ENABLED)
1773−#if defined(DYNAMIC_SLICE_ASSIGN)
17741746 int32_t iSliceNum = (SM_FIXEDSLCNUM_SLICE == pMso->uiSliceMode
17751747 || SM_DYN_SLICE == pMso->uiSliceMode) ? kiCpuCores :
17761748 pSlcArg->uiSliceNum; // uiSliceNum per input has been validated at ParamValidationExt()
1777−#else//!DYNAMIC_SLICE_ASSIGN
1778− int32_t iSliceNum = (SM_DYN_SLICE == pMso->uiSliceMode) ? kiCpuCores :
1779− pSlcArg->uiSliceNum; // uiSliceNum per input has been validated at ParamValidationExt()
1780−#endif//DYNAMIC_SLICE_ASSIGN
17811749 #else//!MT_ENABLED
17821750 int16_t iSliceNum = pSlcArg->uiSliceNum; // uiSliceNum per input has been validated at ParamValidationExt()
17831751 #endif//MT_ENABLED
@@ -2215,7 +2183,6 @@ void WelsUninitEncoderExt (sWelsEncCtx** ppCtx) { · 431 unmodified lines
22152183 res);
22162184 (*ppCtx)->pSliceThreading->pThreadHandles[iThreadIdx] = 0;
22172185 }
2218−#if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE)
22192186 if ((*ppCtx)->pSliceThreading->pUpdateMbListThrdHandles[iThreadIdx]) {
22202187 res = WelsThreadCancel ((*ppCtx)->pSliceThreading->pUpdateMbListThrdHandles[iThreadIdx]);
22212188 WelsLog (*ppCtx, WELS_LOG_INFO, "WelsUninitEncoderExt(), WelsThreadCancel(pUpdateMbListThrdHandles%d) return %d..\n",
@@ -2225,7 +2192,6 @@ void WelsUninitEncoderExt (sWelsEncCtx** ppCtx) { · 3 unmodified lines
22252192 iThreadIdx, res);
22262193 (*ppCtx)->pSliceThreading->pUpdateMbListThrdHandles[iThreadIdx] = 0;
22272194 }
2228−#endif//DYNAMIC_SLICE_ASSIGN && TRY_SLICING_BALANCE
22292195 ++ iThreadIdx;
22302196 }
22312197 #endif//WIN32
@@ -2306,10 +2272,8 @@ int32_t PicPartitionNumDecision (sWelsEncCtx* pCtx) { · 74 unmodified lines
23062272 #ifdef MT_ENABLED
23072273 if (pCtx->pSvcParam->iMultipleThreadIdc > 1) {
23082274 iPartitionNum = pCtx->pSvcParam->iCountThreadsNum;
2309−#if !defined(FIXED_PARTITION_ASSIGN)
23102275 if (P_SLICE == pCtx->eSliceType)
23112276 iPartitionNum = 1;
2312−#endif//!FIXED_PARTITION_ASSIGN
23132277 }
23142278 return iPartitionNum;
23152279 #else
@@ -2946,71 +2910,6 @@ int32_t WritePadding (sWelsEncCtx* pCtx, int32_t iLen, int32_t& iSize) { · 630 unmodified lines
29462910 return ENC_RETURN_SUCCESS;
29472911 }
29482912
2949−/*
2950− * post process of dynamic slicing bs writing in case PACKING_ONE_SLICE_PER_LAYER
2951− * include: count bs size of over all the slices in layer,
2952− * return: count number of slices in layer
2953− */
2954−#if defined(MT_ENABLED) && defined(PACKING_ONE_SLICE_PER_LAYER)
2955−int32_t PostProcDynamicSlicingBsWriting (sWelsEncCtx* pCtx, SLayerBSInfo* pLayerBsInfo, int32_t* pLayerSize,
2956− const int32_t kiPartitionCnt) {
2957− SDqLayer* pCurDq = pCtx->pCurDqLayer;
2958− int32_t iPartitionIdx = 0;
2959− int32_t iCheckingIdx = 0;
2960− int32_t iSwappingIdx = -1;
2961− int32_t iSliceCount = 0;
2962− int32_t iLayerSize = 0;
2963−
2964− // count number of slices in layer and layer size
2965− while (iPartitionIdx < kiPartitionCnt) {
2966− const int32_t coded_slice_cnt = pCurDq->pNumSliceCodedOfPartition[iPartitionIdx];
2967− iLayerSize += pCtx->pSliceThreading->pCountBsSizeInPartition[iPartitionIdx];
2968− iSliceCount += coded_slice_cnt;
2969− ++ iPartitionIdx;
2970− }
2971− *pLayerSize = iLayerSize;
2972−
2973− // reordering pLayerBs pointers, but do not ensure raster scan order of picture
2974− // just maintain discontinuous items,i.e,
2975− // input:
2976− // partition 1: uiSliceIdx: 0 2 4 6
2977− // partition 2: uiSliceIdx: 1 3 5 7 9 11 13
2978− // output:
2979− // uiSliceIdx: 0 1 2 3 4 5 6 7 8 9 10
2980− iCheckingIdx = 0;
2981− while (true) {
2982− bool bMatchFlag = false;
2983− iPartitionIdx = 0;
2984− while (iPartitionIdx < kiPartitionCnt) {
2985− const int32_t coded_slice_cnt = pCurDq->pNumSliceCodedOfPartition[iPartitionIdx];
2986− // iCheckingIdx need convert to iIndex of iPartitionIdx based to avoid linear searching
2987− // belong this partition and not exceed the number of slices coded in partition
2988− if (iPartitionIdx == (iCheckingIdx % kiPartitionCnt)
2989− && iCheckingIdx / kiPartitionCnt < coded_slice_cnt) {
2990− if (iSwappingIdx >= 0) {
2991− // memory swapping
2992− memmove (pLayerBsInfo + iSwappingIdx, LayerBsInfo + iCheckingIdx, sizeof (SLayerBSInfo)); // confirmed_safe_unsafe_usage
2993− ++ iSwappingIdx; // record iSwappingIdx
2994− }
2995− ++ iCheckingIdx;
2996− bMatchFlag = true;
2997− break;
2998− }
2999− ++ iPartitionIdx;
3000− }
3001− if (!bMatchFlag) {
3002− if (iSwappingIdx < 0)
3003− iSwappingIdx = iCheckingIdx;
3004− ++ iCheckingIdx;
3005− }
3006− if (iSwappingIdx >= iSliceCount)
3007− break;
3008− }
3009−
3010− return iSliceCount;
3011−}
3012−#endif//MT_ENABLED && PACKING_ONE_SLICE_PER_LAYER
3013−
30142913 /*
30152914 * Force coding IDR as follows
30162915 */
@@ -3072,9 +2971,9 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 55 unmodified lines
30722971 SPicture* fsnr = NULL;
30732972 #endif//ENABLE_FRAME_DUMP || ENABLE_PSNR_CALC
30742973 SPicture* pEncPic = NULL; // to be decided later
3075−#if defined(MT_ENABLED) && (defined(DYNAMIC_SLICE_ASSIGN) || defined(MT_DEBUG))
2974+#if defined(MT_ENABLED)
30762975 int32_t did_list[MAX_DEPENDENCY_LAYER] = {0};
3077−#endif//MT_ENABLED && DYNAMIC_SLICE_ASSIGN
2976+#endif//MT_ENABLED
30782977 int32_t iLayerNum = 0;
30792978 int32_t iLayerSize = 0;
30802979 int32_t iSpatialNum = 0; // available count number of spatial layers due to frame size changed in this given frame
@@ -3164,21 +3063,21 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 83 unmodified lines
31643063 iCurWidth = param_d->iFrameWidth;
31653064 iCurHeight = param_d->iFrameHeight;
31663065
3167−#if defined(MT_ENABLED) && (defined(DYNAMIC_SLICE_ASSIGN) || defined(MT_DEBUG))
3066+#if defined(MT_ENABLED)
31683067 did_list[iSpatialIdx] = iCurDid;
3169−#endif//MT_ENABLED && DYNAMIC_SLICE_ASSIGN
3068+#endif//MT_ENABLED
31703069
31713070 // Encoding this picture might mulitiple sQualityStat layers potentially be encoded as followed
31723071
31733072 switch (param_d->sSliceCfg.uiSliceMode) {
31743073 case SM_FIXEDSLCNUM_SLICE: {
3175−#if defined(MT_ENABLED) && defined(DYNAMIC_SLICE_ASSIGN)
3074+#if defined(MT_ENABLED)
31763075 if ((iCurDid > 0) && (pSvcParam->iMultipleThreadIdc > 1) &&
31773076 (pSvcParam->sDependencyLayers[iCurDid].sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE
31783077 && pSvcParam->iMultipleThreadIdc >= pSvcParam->sDependencyLayers[iCurDid].sSliceCfg.sSliceArgument.uiSliceNum)
31793078 )
31803079 AdjustEnhanceLayer (pCtx, iCurDid);
3181−#endif//MT_ENABLED && DYNAMIC_SLICE_ASSIGN
3080+#endif//MT_ENABLED
31823081 break;
31833082 }
31843083 case SM_DYN_SLICE: {
@@ -3307,13 +3206,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 122 unmodified lines
33073206 // THREAD_FULLY_FIRE_MODE/THREAD_PICK_UP_MODE for any mode of non-SM_DYN_SLICE
33083207 if ((SM_DYN_SLICE != param_d->sSliceCfg.uiSliceMode) && (pSvcParam->iMultipleThreadIdc > 1)) {
33093208 iSliceCount = GetCurrentSliceNum (pCtx->pCurDqLayer->pSliceEncCtx);
3310− if (iLayerNum +
3311−#if defined(PACKING_ONE_SLICE_PER_LAYER)
3312− iSliceCount
3313−#else
3314− 1
3315−#endif//PACKING_ONE_SLICE_PER_LAYER
3316− >= MAX_LAYER_NUM_OF_FRAME) { // check available layer_bs_info for further writing as followed
3209+ if (iLayerNum + 1 >= MAX_LAYER_NUM_OF_FRAME) { // check available layer_bs_info for further writing as followed
33173210 WelsLog (pCtx, WELS_LOG_ERROR,
33183211 "WelsEncoderEncodeExt(), iLayerNum(%d) overflow(max:%d) at iDid= %d uiSliceMode= %d, iSliceCount= %d!",
33193212 iLayerNum, MAX_LAYER_NUM_OF_FRAME, iCurDid, param_d->sSliceCfg.uiSliceMode, iSliceCount);
@@ -3327,17 +3220,9 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 7 unmodified lines
33273220 }
33283221
33293222 if (pSvcParam->iCountThreadsNum >= iSliceCount) { //THREAD_FULLY_FIRE_MODE
3330−#if defined(PACKING_ONE_SLICE_PER_LAYER)
3331− int32_t iSliceIdx = 1;
3332− int32_t iOrgSlicePos[MAX_SLICES_NUM] = {0};
3333− iOrgSlicePos[0] = pCtx->iPosBsBuffer;
3334− while (uiSliceIdx < iSliceCount) {
3335− iOrgSlicePos[uiSliceIdx] = pCtx->pSliceBs[uiSliceIdx].uiBsPos;
3336− ++ uiSliceIdx;
3337− }
3338−#elif defined(MT_DEBUG)
3223+#if defined(MT_DEBUG)
33393224 int64_t t_bs_append = 0;
3340−#endif//PACKING_ONE_SLICE_PER_LAYER
3225+#endif
33413226
33423227 pCtx->iActiveThreadsNum = iSliceCount;
33433228 // to fire slice coding threads
@@ -3357,16 +3242,6 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 13 unmodified lines
33573242 WELS_VERIFY_RETURN_IFNEQ(pCtx->iEncoderError, ENC_RETURN_SUCCESS)
33583243
33593244 // append exclusive slice 0 bs to pFrameBs
3360−#if defined(PACKING_ONE_SLICE_PER_LAYER)
3361− iLayerSize = pCtx->iPosBsBuffer - iOrgSlicePos[0];
3362− uiSliceIdx = 1;
3363− while (uiSliceIdx < iSliceCount) {
3364− iLayerSize += pCtx->pSliceBs[uiSliceIdx].uiBsPos - iOrgSlicePos[uiSliceIdx];
3365− ++ uiSliceIdx;
3366− }
3367− iLayerNum += iSliceCount; // each slice stickly output as layer info for performance improvement directly
3368− pLayerBsInfo += iSliceCount;
3369−#else
33703245 #if defined(MT_DEBUG)
33713246 t_bs_append = WelsTime();
33723247 #endif//MT_DEBUG
@@ -3383,20 +3258,10 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 10 unmodified lines
33833258 t_bs_append, pCtx->iCodingIndex, iCurDid, 0);
33843259 }
33853260 #endif//MT_DEBUG
3386−#endif//PACKING_ONE_SLICE_PER_LAYER
33873261 } else { //THREAD_PICK_UP_MODE
33883262 int32_t iNumThreadsRunning = 0;
33893263 int32_t iNumThreadsScheduled = 0;
33903264 int32_t iIndexOfSliceToBeCoded = 0;
3391−#if defined(PACKING_ONE_SLICE_PER_LAYER)
3392− int32_t iSliceIdx = 1;
3393− int32_t iOrgSlicePos[MAX_SLICES_NUM] = {0};
3394− iOrgSlicePos[0] = pCtx->iPosBsBuffer;
3395− while (uiSliceIdx < iSliceCount) {
3396− iOrgSlicePos[uiSliceIdx] = pCtx->pSliceBs[uiSliceIdx].uiBsPos;
3397− ++ uiSliceIdx;
3398− }
3399−#endif//PACKING_ONE_SLICE_PER_LAYER
34003265
34013266 pCtx->iActiveThreadsNum = pSvcParam->iCountThreadsNum;
34023267 iNumThreadsScheduled = pCtx->iActiveThreadsNum;
@@ -3428,9 +3293,6 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 25 unmodified lines
34283293 // pick up succeeding slice for threading
34293294 // thread_id equal to iEventId per implementation here
34303295 pCtx->pSliceThreading->pThreadPEncCtx[iEventId].iSliceIndex = iIndexOfSliceToBeCoded;
3431−#ifdef PACKING_ONE_SLICE_PER_LAYER
3432− pCtx->pSliceThreading->pThreadPEncCtx[iEventId].pLayerBs = pLayerBsInfo + iIndexOfSliceToBeCoded;
3433−#endif//PACKING_ONE_SLICE_PER_LAYER
34343296 WelsEventSignal (&pCtx->pSliceThreading->pReadySliceCodingEvent[iEventId]);
34353297
34363298 ++ iIndexOfSliceToBeCoded;
@@ -3452,9 +3314,6 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 15 unmodified lines
34523314 if (iIndexOfSliceToBeCoded >= iSliceCount)
34533315 break;
34543316 pCtx->pSliceThreading->pThreadPEncCtx[iThreadIdx].iSliceIndex = iIndexOfSliceToBeCoded;
3455−#ifdef PACKING_ONE_SLICE_PER_LAYER
3456− pCtx->pSliceThreading->pThreadPEncCtx[iThreadIdx].pLayerBs = pLayerBsInfo + iIndexOfSliceToBeCoded;
3457−#endif//PACKING_ONE_SLICE_PER_LAYER
34583317 WelsEventSignal (pCtx->pSliceThreading->pReadySliceCodingEvent[iThreadIdx]);
34593318
34603319 ++ iIndexOfSliceToBeCoded;
@@ -3468,31 +3327,14 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 7 unmodified lines
34683327 #endif//_WIN32
34693328 }//while(1)
34703329
3471−// all slices are finished coding here
3330+ // all slices are finished coding here
34723331 // append exclusive slice 0 bs to pFrameBs
3473−#if defined(PACKING_ONE_SLICE_PER_LAYER)
3474− iLayerSize = pCtx->iPosBsBuffer - iOrgSlicePos[0];
3475− uiSliceIdx = 1;
3476− while (uiSliceIdx < iSliceCount) {
3477− iLayerSize += pCtx->pSliceBs[uiSliceIdx].uiBsPos - iOrgSlicePos[uiSliceIdx];
3478− ++ uiSliceIdx;
3479− }
3480− iLayerNum += iSliceCount; // each slice stickly output as layer info for performance improvement directly
3481− pLayerBsInfo += iSliceCount;
3482−#else
34833332 iLayerSize = AppendSliceToFrameBs (pCtx, pLayerBsInfo, iSliceCount);
3484−#endif//PACKING_ONE_SLICE_PER_LAYER
34853333 }
34863334 }
34873335 // THREAD_FULLY_FIRE_MODE && SM_DYN_SLICE
34883336 else if ((SM_DYN_SLICE == param_d->sSliceCfg.uiSliceMode) && (pSvcParam->iMultipleThreadIdc > 1)) {
34893337 const int32_t kiPartitionCnt = pCtx->iActiveThreadsNum; //pSvcParam->iCountThreadsNum;
3490−#if defined(PACKING_ONE_SLICE_PER_LAYER)
3491− ResetCountBsSizeInPartitions (pCtx->pSliceThreading->pCountBsSizeInPartition, kiPartitionCnt);
3492− pCtx->pCurDqLayer->pSliceEncCtx->iMaxSliceNumConstraint = WELS_MIN (MAX_SLICES_NUM,
3493− DynamicMaxSliceNumConstraint (MAX_LAYER_NUM_OF_FRAME, iLayerNum, 1 + /*( num_qlayer - 1) +*/ (((iCurDid == 0)
3494− && (pSvcParam->uiGopSize > 1)) ? 1 : 0)));
3495−#endif//PACKING_ONE_SLICE_PER_LAYER
34963338
34973339 // to fire slice coding threads
34983340 err = FiredSliceThreads (&pCtx->pSliceThreading->pThreadPEncCtx[0], &pCtx->pSliceThreading->pReadySliceCodingEvent[0],
@@ -3507,14 +3349,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 8 unmodified lines
35073349 WelsMultipleEventsWaitAllBlocking (kiPartitionCnt, &pCtx->pSliceThreading->pSliceCodedEvent[0]);
35083350 WELS_VERIFY_RETURN_IFNEQ(pCtx->iEncoderError, ENC_RETURN_SUCCESS)
35093351
3510−#if defined(PACKING_ONE_SLICE_PER_LAYER)
3511− iSliceCount = PostProcDynamicSlicingBsWriting (pCtx, pLayerBsInfo, &iLayerSize, kiPartitionCnt);
3512− assert (iLayerNum + iSliceCount < MAX_LAYER_NUM_OF_FRAME);
3513− pLayerBsInfo += iSliceCount;
3514− iLayerNum += iSliceCount;
3515−#else
35163352 iLayerSize = AppendSliceToFrameBs (pCtx, pLayerBsInfo, kiPartitionCnt);
3517−#endif//PACKING_ONE_SLICE_PER_LAYER
35183353 } else // for non-dynamic-slicing mode single threading branch..
35193354 #endif//MT_ENABLED
35203355 {
@@ -3681,16 +3516,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 160 unmodified lines
36813516 }
36823517 #endif//STAT_OUTPUT
36833518
3684−#if defined(MT_ENABLED) && defined(PACKING_ONE_SLICE_PER_LAYER)
3685− if (pSvcParam->iMultipleThreadIdc <= 1 || SM_SINGLE_SLICE == param_d->sSliceCfg.uiSliceMode) // sigle thread actually used
3686−#else
3687− if (1)
3688−#endif//MT_ENABLED && PACKING_ONE_SLICE_PER_LAYER
3689− {
3690− ++ iLayerNum;
3691− ++ pLayerBsInfo;
3692− }
3693−
3519+ ++ iLayerNum;
3520+ ++ pLayerBsInfo;
36943521
36953522 pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer;
36963523
@@ -3722,7 +3549,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 25 unmodified lines
37223549 ++ iLayerNum;
37233550 }
37243551
3725−#if defined(MT_ENABLED) && defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE)
3552+#if defined(MT_ENABLED)
37263553 if (param_d->sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE && pSvcParam->iMultipleThreadIdc > 1 &&
37273554 pSvcParam->iMultipleThreadIdc >= param_d->sSliceCfg.sSliceArgument.uiSliceNum) {
37283555 CalcSliceComplexRatio (pCtx->pSliceThreading->pSliceComplexRatio[iCurDid], pCtx->pCurDqLayer->pSliceEncCtx,
@@ -3731,7 +3558,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 2 unmodified lines
37313558 TrackSliceComplexities (pCtx, iCurDid);
37323559 #endif//#if defined(MT_DEBUG)
37333560 }
3734−#endif//MT_ENABLED && DYNAMIC_SLICE_ASSIGN && TRY_SLICING_BALANCE
3561+#endif//MT_ENABLED
37353562
37363563 ++ iSpatialIdx;
37373564
@@ -3762,7 +3589,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 24 unmodified lines
37623589 TrackSliceConsumeTime (pCtx, did_list, iSpatialNum);
37633590 #endif//MT_ENABLED && MT_DEBUG
37643591
3765−#if defined(MT_ENABLED) && defined(DYNAMIC_SLICE_ASSIGN)
3592+#if defined(MT_ENABLED)
37663593 if (pSvcParam->iMultipleThreadIdc > 1 && did_list[0] == BASE_DEPENDENCY_ID
37673594 && pSvcParam->sDependencyLayers[0].sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE
37683595 && pSvcParam->iMultipleThreadIdc >= pSvcParam->sDependencyLayers[0].sSliceCfg.sSliceArgument.uiSliceNum
@@ -3771,7 +3598,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 2 unmodified lines
37713598 1]].sSliceCfg.sSliceArgument.uiSliceNum) {
37723599 AdjustBaseLayer (pCtx);
37733600 }
3774−#endif//DYNAMIC_SLICE_ASSIGN
3601+#endif
37753602
37763603 #ifdef ENABLE_FRAME_DUMP
37773604 DumpRecFrame (fsnr, &pSvcParam->sDependencyLayers[pSvcParam->iSpatialLayerNum -

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