[Encoder] remove macros to clear codes
Showing the changes to codec/encoder/core/src/encoder_ext.cpp (1 of 5 files). Show all
Unified · Split
| @@ -54,9 +54,7 @@ · 53 unmodified lines | ||
| 54 | 54 | #if defined(MT_ENABLED) |
| 55 | 55 | #include "slice_multi_threading.h" |
| 56 | 56 | #endif//MT_ENABLED |
| 57 | −#if defined(DYNAMIC_SLICE_ASSIGN) || defined(MT_DEBUG) | |
| 58 | 57 | #include "measure_time.h" |
| 59 | −#endif//DYNAMIC_SLICE_ASSIGN | |
| 60 | 58 | |
| 61 | 59 | namespace WelsSVCEnc { |
| 62 | 60 | |
| @@ -467,9 +465,6 @@ static inline int32_t AcquireLayersNals (sWelsEncCtx** ppCtx, SWelsSvcCodingPara · 404 unmodified lines | ||
| 467 | 465 | int32_t iCountNumNals = 0; |
| 468 | 466 | int32_t iNumDependencyLayers = 0; |
| 469 | 467 | 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 | |
| 473 | 468 | |
| 474 | 469 | if (NULL == pParam || NULL == ppCtx || NULL == *ppCtx) |
| 475 | 470 | return 1; |
| @@ -491,12 +486,7 @@ static inline int32_t AcquireLayersNals (sWelsEncCtx** ppCtx, SWelsSvcCodingPara · 15 unmodified lines | ||
| 491 | 486 | if (iDIndex == 0) |
| 492 | 487 | iCountNumNals += MAX_SLICES_NUM; |
| 493 | 488 | // 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 | |
| 498 | 489 | assert (iCountNumNals - iOrgNumNals <= MAX_NAL_UNITS_IN_LAYER); |
| 499 | −#endif//MT_ENABLED && PACKING_ONE_SLICE_PER_LAYER | |
| 500 | 490 | } else { /*if ( SM_SINGLE_SLICE != pDLayer->sSliceCfg.uiSliceMode )*/ |
| 501 | 491 | const int32_t kiNumOfSlice = GetInitialSliceNum ((pDLayer->iFrameWidth + 0x0f) >> 4, |
| 502 | 492 | (pDLayer->iFrameHeight + 0x0f) >> 4, |
| @@ -507,12 +497,7 @@ static inline int32_t AcquireLayersNals (sWelsEncCtx** ppCtx, SWelsSvcCodingPara · 4 unmodified lines | ||
| 507 | 497 | // plus prefix NALs |
| 508 | 498 | if (iDIndex == 0) |
| 509 | 499 | 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 | |
| 514 | 500 | assert (iCountNumNals - iOrgNumNals <= MAX_NAL_UNITS_IN_LAYER); |
| 515 | −#endif//MT_ENALBED && PACKING_ONE_SLICE_PER_LAYER | |
| 516 | 501 | if (kiNumOfSlice > MAX_SLICES_NUM) { |
| 517 | 502 | WelsLog (*ppCtx, WELS_LOG_ERROR, |
| 518 | 503 | "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 | ||
| 520 | 505 | return 1; |
| 521 | 506 | } |
| 522 | 507 | } |
| 523 | −#if !defined(MT_ENABLED) || !defined(PACKING_ONE_SLICE_PER_LAYER) | |
| 508 | + | |
| 524 | 509 | if (iCountNumNals - iOrgNumNals > MAX_NAL_UNITS_IN_LAYER) { |
| 525 | 510 | 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); | |
| 528 | 513 | return 1; |
| 529 | 514 | } |
| 530 | −#endif//!MT_ENABLED) || !PACKING_ONE_SLICE_PER_LAYER | |
| 531 | 515 | |
| 532 | 516 | iCountNumLayers ++; |
| 533 | 517 | |
| @@ -536,9 +520,6 @@ static inline int32_t AcquireLayersNals (sWelsEncCtx** ppCtx, SWelsSvcCodingPara · 2 unmodified lines | ||
| 536 | 520 | |
| 537 | 521 | iCountNumNals += 1 + iNumDependencyLayers + (iCountNumLayers << 1) + |
| 538 | 522 | 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 | |
| 542 | 523 | |
| 543 | 524 | // to check number of layers / nals / slices dependencies, 12/8/2010 |
| 544 | 525 | #if !defined(MT_ENABLED) |
| @@ -548,19 +529,11 @@ static inline int32_t AcquireLayersNals (sWelsEncCtx** ppCtx, SWelsSvcCodingPara · 3 unmodified lines | ||
| 548 | 529 | return 1; |
| 549 | 530 | } |
| 550 | 531 | #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 | |
| 558 | 532 | if (iCountNumLayers > MAX_LAYER_NUM_OF_FRAME) { |
| 559 | 533 | WelsLog (*ppCtx, WELS_LOG_ERROR, "AcquireLayersNals(), iCountNumLayers(%d) > MAX_LAYER_NUM_OF_FRAME(%d)!", |
| 560 | 534 | iCountNumLayers, MAX_LAYER_NUM_OF_FRAME); |
| 561 | 535 | return 1; |
| 562 | 536 | } |
| 563 | −#endif//PACKING_ONE_SLICE_PER_LAYER | |
| 564 | 537 | #endif//!MT_ENABLED |
| 565 | 538 | |
| 566 | 539 | if (NULL != pCountLayers) |
| @@ -1770,14 +1743,9 @@ int32_t InitSliceSettings (SWelsSvcCodingParam* pCodingParam, const int32_t kiCp · 1203 unmodified lines | ||
| 1770 | 1743 | const int32_t kiMbHeight = (pDlp->iFrameHeight + 15) >> 4; |
| 1771 | 1744 | const int32_t kiMbNumInFrame = kiMbWidth * kiMbHeight; |
| 1772 | 1745 | #if defined(MT_ENABLED) |
| 1773 | −#if defined(DYNAMIC_SLICE_ASSIGN) | |
| 1774 | 1746 | int32_t iSliceNum = (SM_FIXEDSLCNUM_SLICE == pMso->uiSliceMode |
| 1775 | 1747 | || SM_DYN_SLICE == pMso->uiSliceMode) ? kiCpuCores : |
| 1776 | 1748 | 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 | |
| 1781 | 1749 | #else//!MT_ENABLED |
| 1782 | 1750 | int16_t iSliceNum = pSlcArg->uiSliceNum; // uiSliceNum per input has been validated at ParamValidationExt() |
| 1783 | 1751 | #endif//MT_ENABLED |
| @@ -2215,7 +2183,6 @@ void WelsUninitEncoderExt (sWelsEncCtx** ppCtx) { · 431 unmodified lines | ||
| 2215 | 2183 | res); |
| 2216 | 2184 | (*ppCtx)->pSliceThreading->pThreadHandles[iThreadIdx] = 0; |
| 2217 | 2185 | } |
| 2218 | −#if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE) | |
| 2219 | 2186 | if ((*ppCtx)->pSliceThreading->pUpdateMbListThrdHandles[iThreadIdx]) { |
| 2220 | 2187 | res = WelsThreadCancel ((*ppCtx)->pSliceThreading->pUpdateMbListThrdHandles[iThreadIdx]); |
| 2221 | 2188 | WelsLog (*ppCtx, WELS_LOG_INFO, "WelsUninitEncoderExt(), WelsThreadCancel(pUpdateMbListThrdHandles%d) return %d..\n", |
| @@ -2225,7 +2192,6 @@ void WelsUninitEncoderExt (sWelsEncCtx** ppCtx) { · 3 unmodified lines | ||
| 2225 | 2192 | iThreadIdx, res); |
| 2226 | 2193 | (*ppCtx)->pSliceThreading->pUpdateMbListThrdHandles[iThreadIdx] = 0; |
| 2227 | 2194 | } |
| 2228 | −#endif//DYNAMIC_SLICE_ASSIGN && TRY_SLICING_BALANCE | |
| 2229 | 2195 | ++ iThreadIdx; |
| 2230 | 2196 | } |
| 2231 | 2197 | #endif//WIN32 |
| @@ -2306,10 +2272,8 @@ int32_t PicPartitionNumDecision (sWelsEncCtx* pCtx) { · 74 unmodified lines | ||
| 2306 | 2272 | #ifdef MT_ENABLED |
| 2307 | 2273 | if (pCtx->pSvcParam->iMultipleThreadIdc > 1) { |
| 2308 | 2274 | iPartitionNum = pCtx->pSvcParam->iCountThreadsNum; |
| 2309 | −#if !defined(FIXED_PARTITION_ASSIGN) | |
| 2310 | 2275 | if (P_SLICE == pCtx->eSliceType) |
| 2311 | 2276 | iPartitionNum = 1; |
| 2312 | −#endif//!FIXED_PARTITION_ASSIGN | |
| 2313 | 2277 | } |
| 2314 | 2278 | return iPartitionNum; |
| 2315 | 2279 | #else |
| @@ -2946,71 +2910,6 @@ int32_t WritePadding (sWelsEncCtx* pCtx, int32_t iLen, int32_t& iSize) { · 630 unmodified lines | ||
| 2946 | 2910 | return ENC_RETURN_SUCCESS; |
| 2947 | 2911 | } |
| 2948 | 2912 | |
| 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 | − | |
| 3014 | 2913 | /* |
| 3015 | 2914 | * Force coding IDR as follows |
| 3016 | 2915 | */ |
| @@ -3072,9 +2971,9 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 55 unmodified lines | ||
| 3072 | 2971 | SPicture* fsnr = NULL; |
| 3073 | 2972 | #endif//ENABLE_FRAME_DUMP || ENABLE_PSNR_CALC |
| 3074 | 2973 | SPicture* pEncPic = NULL; // to be decided later |
| 3075 | −#if defined(MT_ENABLED) && (defined(DYNAMIC_SLICE_ASSIGN) || defined(MT_DEBUG)) | |
| 2974 | +#if defined(MT_ENABLED) | |
| 3076 | 2975 | int32_t did_list[MAX_DEPENDENCY_LAYER] = {0}; |
| 3077 | −#endif//MT_ENABLED && DYNAMIC_SLICE_ASSIGN | |
| 2976 | +#endif//MT_ENABLED | |
| 3078 | 2977 | int32_t iLayerNum = 0; |
| 3079 | 2978 | int32_t iLayerSize = 0; |
| 3080 | 2979 | 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 | ||
| 3164 | 3063 | iCurWidth = param_d->iFrameWidth; |
| 3165 | 3064 | iCurHeight = param_d->iFrameHeight; |
| 3166 | 3065 | |
| 3167 | −#if defined(MT_ENABLED) && (defined(DYNAMIC_SLICE_ASSIGN) || defined(MT_DEBUG)) | |
| 3066 | +#if defined(MT_ENABLED) | |
| 3168 | 3067 | did_list[iSpatialIdx] = iCurDid; |
| 3169 | −#endif//MT_ENABLED && DYNAMIC_SLICE_ASSIGN | |
| 3068 | +#endif//MT_ENABLED | |
| 3170 | 3069 | |
| 3171 | 3070 | // Encoding this picture might mulitiple sQualityStat layers potentially be encoded as followed |
| 3172 | 3071 | |
| 3173 | 3072 | switch (param_d->sSliceCfg.uiSliceMode) { |
| 3174 | 3073 | case SM_FIXEDSLCNUM_SLICE: { |
| 3175 | −#if defined(MT_ENABLED) && defined(DYNAMIC_SLICE_ASSIGN) | |
| 3074 | +#if defined(MT_ENABLED) | |
| 3176 | 3075 | if ((iCurDid > 0) && (pSvcParam->iMultipleThreadIdc > 1) && |
| 3177 | 3076 | (pSvcParam->sDependencyLayers[iCurDid].sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE |
| 3178 | 3077 | && pSvcParam->iMultipleThreadIdc >= pSvcParam->sDependencyLayers[iCurDid].sSliceCfg.sSliceArgument.uiSliceNum) |
| 3179 | 3078 | ) |
| 3180 | 3079 | AdjustEnhanceLayer (pCtx, iCurDid); |
| 3181 | −#endif//MT_ENABLED && DYNAMIC_SLICE_ASSIGN | |
| 3080 | +#endif//MT_ENABLED | |
| 3182 | 3081 | break; |
| 3183 | 3082 | } |
| 3184 | 3083 | case SM_DYN_SLICE: { |
| @@ -3307,13 +3206,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 122 unmodified lines | ||
| 3307 | 3206 | // THREAD_FULLY_FIRE_MODE/THREAD_PICK_UP_MODE for any mode of non-SM_DYN_SLICE |
| 3308 | 3207 | if ((SM_DYN_SLICE != param_d->sSliceCfg.uiSliceMode) && (pSvcParam->iMultipleThreadIdc > 1)) { |
| 3309 | 3208 | 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 | |
| 3317 | 3210 | WelsLog (pCtx, WELS_LOG_ERROR, |
| 3318 | 3211 | "WelsEncoderEncodeExt(), iLayerNum(%d) overflow(max:%d) at iDid= %d uiSliceMode= %d, iSliceCount= %d!", |
| 3319 | 3212 | 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 | ||
| 3327 | 3220 | } |
| 3328 | 3221 | |
| 3329 | 3222 | 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) | |
| 3339 | 3224 | int64_t t_bs_append = 0; |
| 3340 | −#endif//PACKING_ONE_SLICE_PER_LAYER | |
| 3225 | +#endif | |
| 3341 | 3226 | |
| 3342 | 3227 | pCtx->iActiveThreadsNum = iSliceCount; |
| 3343 | 3228 | // to fire slice coding threads |
| @@ -3357,16 +3242,6 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 13 unmodified lines | ||
| 3357 | 3242 | WELS_VERIFY_RETURN_IFNEQ(pCtx->iEncoderError, ENC_RETURN_SUCCESS) |
| 3358 | 3243 | |
| 3359 | 3244 | // 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 | |
| 3370 | 3245 | #if defined(MT_DEBUG) |
| 3371 | 3246 | t_bs_append = WelsTime(); |
| 3372 | 3247 | #endif//MT_DEBUG |
| @@ -3383,20 +3258,10 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 10 unmodified lines | ||
| 3383 | 3258 | t_bs_append, pCtx->iCodingIndex, iCurDid, 0); |
| 3384 | 3259 | } |
| 3385 | 3260 | #endif//MT_DEBUG |
| 3386 | −#endif//PACKING_ONE_SLICE_PER_LAYER | |
| 3387 | 3261 | } else { //THREAD_PICK_UP_MODE |
| 3388 | 3262 | int32_t iNumThreadsRunning = 0; |
| 3389 | 3263 | int32_t iNumThreadsScheduled = 0; |
| 3390 | 3264 | 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 | |
| 3400 | 3265 | |
| 3401 | 3266 | pCtx->iActiveThreadsNum = pSvcParam->iCountThreadsNum; |
| 3402 | 3267 | iNumThreadsScheduled = pCtx->iActiveThreadsNum; |
| @@ -3428,9 +3293,6 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 25 unmodified lines | ||
| 3428 | 3293 | // pick up succeeding slice for threading |
| 3429 | 3294 | // thread_id equal to iEventId per implementation here |
| 3430 | 3295 | 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 | |
| 3434 | 3296 | WelsEventSignal (&pCtx->pSliceThreading->pReadySliceCodingEvent[iEventId]); |
| 3435 | 3297 | |
| 3436 | 3298 | ++ iIndexOfSliceToBeCoded; |
| @@ -3452,9 +3314,6 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 15 unmodified lines | ||
| 3452 | 3314 | if (iIndexOfSliceToBeCoded >= iSliceCount) |
| 3453 | 3315 | break; |
| 3454 | 3316 | 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 | |
| 3458 | 3317 | WelsEventSignal (pCtx->pSliceThreading->pReadySliceCodingEvent[iThreadIdx]); |
| 3459 | 3318 | |
| 3460 | 3319 | ++ iIndexOfSliceToBeCoded; |
| @@ -3468,31 +3327,14 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 7 unmodified lines | ||
| 3468 | 3327 | #endif//_WIN32 |
| 3469 | 3328 | }//while(1) |
| 3470 | 3329 | |
| 3471 | −// all slices are finished coding here | |
| 3330 | + // all slices are finished coding here | |
| 3472 | 3331 | // 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 | |
| 3483 | 3332 | iLayerSize = AppendSliceToFrameBs (pCtx, pLayerBsInfo, iSliceCount); |
| 3484 | −#endif//PACKING_ONE_SLICE_PER_LAYER | |
| 3485 | 3333 | } |
| 3486 | 3334 | } |
| 3487 | 3335 | // THREAD_FULLY_FIRE_MODE && SM_DYN_SLICE |
| 3488 | 3336 | else if ((SM_DYN_SLICE == param_d->sSliceCfg.uiSliceMode) && (pSvcParam->iMultipleThreadIdc > 1)) { |
| 3489 | 3337 | 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 | |
| 3496 | 3338 | |
| 3497 | 3339 | // to fire slice coding threads |
| 3498 | 3340 | 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 | ||
| 3507 | 3349 | WelsMultipleEventsWaitAllBlocking (kiPartitionCnt, &pCtx->pSliceThreading->pSliceCodedEvent[0]); |
| 3508 | 3350 | WELS_VERIFY_RETURN_IFNEQ(pCtx->iEncoderError, ENC_RETURN_SUCCESS) |
| 3509 | 3351 | |
| 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 | |
| 3516 | 3352 | iLayerSize = AppendSliceToFrameBs (pCtx, pLayerBsInfo, kiPartitionCnt); |
| 3517 | −#endif//PACKING_ONE_SLICE_PER_LAYER | |
| 3518 | 3353 | } else // for non-dynamic-slicing mode single threading branch.. |
| 3519 | 3354 | #endif//MT_ENABLED |
| 3520 | 3355 | { |
| @@ -3681,16 +3516,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 160 unmodified lines | ||
| 3681 | 3516 | } |
| 3682 | 3517 | #endif//STAT_OUTPUT |
| 3683 | 3518 | |
| 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; | |
| 3694 | 3521 | |
| 3695 | 3522 | pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; |
| 3696 | 3523 | |
| @@ -3722,7 +3549,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 25 unmodified lines | ||
| 3722 | 3549 | ++ iLayerNum; |
| 3723 | 3550 | } |
| 3724 | 3551 | |
| 3725 | −#if defined(MT_ENABLED) && defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE) | |
| 3552 | +#if defined(MT_ENABLED) | |
| 3726 | 3553 | if (param_d->sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE && pSvcParam->iMultipleThreadIdc > 1 && |
| 3727 | 3554 | pSvcParam->iMultipleThreadIdc >= param_d->sSliceCfg.sSliceArgument.uiSliceNum) { |
| 3728 | 3555 | CalcSliceComplexRatio (pCtx->pSliceThreading->pSliceComplexRatio[iCurDid], pCtx->pCurDqLayer->pSliceEncCtx, |
| @@ -3731,7 +3558,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 2 unmodified lines | ||
| 3731 | 3558 | TrackSliceComplexities (pCtx, iCurDid); |
| 3732 | 3559 | #endif//#if defined(MT_DEBUG) |
| 3733 | 3560 | } |
| 3734 | −#endif//MT_ENABLED && DYNAMIC_SLICE_ASSIGN && TRY_SLICING_BALANCE | |
| 3561 | +#endif//MT_ENABLED | |
| 3735 | 3562 | |
| 3736 | 3563 | ++ iSpatialIdx; |
| 3737 | 3564 | |
| @@ -3762,7 +3589,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 24 unmodified lines | ||
| 3762 | 3589 | TrackSliceConsumeTime (pCtx, did_list, iSpatialNum); |
| 3763 | 3590 | #endif//MT_ENABLED && MT_DEBUG |
| 3764 | 3591 | |
| 3765 | −#if defined(MT_ENABLED) && defined(DYNAMIC_SLICE_ASSIGN) | |
| 3592 | +#if defined(MT_ENABLED) | |
| 3766 | 3593 | if (pSvcParam->iMultipleThreadIdc > 1 && did_list[0] == BASE_DEPENDENCY_ID |
| 3767 | 3594 | && pSvcParam->sDependencyLayers[0].sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE |
| 3768 | 3595 | && pSvcParam->iMultipleThreadIdc >= pSvcParam->sDependencyLayers[0].sSliceCfg.sSliceArgument.uiSliceNum |
| @@ -3771,7 +3598,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 2 unmodified lines | ||
| 3771 | 3598 | 1]].sSliceCfg.sSliceArgument.uiSliceNum) { |
| 3772 | 3599 | AdjustBaseLayer (pCtx); |
| 3773 | 3600 | } |
| 3774 | −#endif//DYNAMIC_SLICE_ASSIGN | |
| 3601 | +#endif | |
| 3775 | 3602 | |
| 3776 | 3603 | #ifdef ENABLE_FRAME_DUMP |
| 3777 | 3604 | DumpRecFrame (fsnr, &pSvcParam->sDependencyLayers[pSvcParam->iSpatialLayerNum - |