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 | */ |
| @@ -3077,9 +2976,9 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, void* pDst, const SSourcePictur · 60 unmodified lines | ||
| 3077 | 2976 | SPicture* fsnr = NULL; |
| 3078 | 2977 | #endif//ENABLE_FRAME_DUMP || ENABLE_PSNR_CALC |
| 3079 | 2978 | SPicture* pEncPic = NULL; // to be decided later |
| 3080 | −#if defined(MT_ENABLED) && (defined(DYNAMIC_SLICE_ASSIGN) || defined(MT_DEBUG)) | |
| 2979 | +#if defined(MT_ENABLED) | |
| 3081 | 2980 | int32_t did_list[MAX_DEPENDENCY_LAYER] = {0}; |
| 3082 | −#endif//MT_ENABLED && DYNAMIC_SLICE_ASSIGN | |
| 2981 | +#endif//MT_ENABLED | |
| 3083 | 2982 | int32_t iLayerNum = 0; |
| 3084 | 2983 | int32_t iLayerSize = 0; |
| 3085 | 2984 | int32_t iSpatialNum = 0; // available count number of spatial layers due to frame size changed in this given frame |
| @@ -3169,21 +3068,21 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, void* pDst, const SSourcePictur · 83 unmodified lines | ||
| 3169 | 3068 | iCurWidth = param_d->iFrameWidth; |
| 3170 | 3069 | iCurHeight = param_d->iFrameHeight; |
| 3171 | 3070 | |
| 3172 | −#if defined(MT_ENABLED) && (defined(DYNAMIC_SLICE_ASSIGN) || defined(MT_DEBUG)) | |
| 3071 | +#if defined(MT_ENABLED) | |
| 3173 | 3072 | did_list[iSpatialIdx] = iCurDid; |
| 3174 | −#endif//MT_ENABLED && DYNAMIC_SLICE_ASSIGN | |
| 3073 | +#endif//MT_ENABLED | |
| 3175 | 3074 | |
| 3176 | 3075 | // Encoding this picture might mulitiple sQualityStat layers potentially be encoded as followed |
| 3177 | 3076 | |
| 3178 | 3077 | switch (param_d->sSliceCfg.uiSliceMode) { |
| 3179 | 3078 | case SM_FIXEDSLCNUM_SLICE: { |
| 3180 | −#if defined(MT_ENABLED) && defined(DYNAMIC_SLICE_ASSIGN) | |
| 3079 | +#if defined(MT_ENABLED) | |
| 3181 | 3080 | if ((iCurDid > 0) && (pSvcParam->iMultipleThreadIdc > 1) && |
| 3182 | 3081 | (pSvcParam->sDependencyLayers[iCurDid].sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE |
| 3183 | 3082 | && pSvcParam->iMultipleThreadIdc >= pSvcParam->sDependencyLayers[iCurDid].sSliceCfg.sSliceArgument.uiSliceNum) |
| 3184 | 3083 | ) |
| 3185 | 3084 | AdjustEnhanceLayer (pCtx, iCurDid); |
| 3186 | −#endif//MT_ENABLED && DYNAMIC_SLICE_ASSIGN | |
| 3085 | +#endif//MT_ENABLED | |
| 3187 | 3086 | break; |
| 3188 | 3087 | } |
| 3189 | 3088 | case SM_DYN_SLICE: { |
| @@ -3312,13 +3211,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, void* pDst, const SSourcePictur · 122 unmodified lines | ||
| 3312 | 3211 | // THREAD_FULLY_FIRE_MODE/THREAD_PICK_UP_MODE for any mode of non-SM_DYN_SLICE |
| 3313 | 3212 | if ((SM_DYN_SLICE != param_d->sSliceCfg.uiSliceMode) && (pSvcParam->iMultipleThreadIdc > 1)) { |
| 3314 | 3213 | iSliceCount = GetCurrentSliceNum (pCtx->pCurDqLayer->pSliceEncCtx); |
| 3315 | − if (iLayerNum + | |
| 3316 | −#if defined(PACKING_ONE_SLICE_PER_LAYER) | |
| 3317 | − iSliceCount | |
| 3318 | −#else | |
| 3319 | − 1 | |
| 3320 | −#endif//PACKING_ONE_SLICE_PER_LAYER | |
| 3321 | − >= MAX_LAYER_NUM_OF_FRAME) { // check available layer_bs_info for further writing as followed | |
| 3214 | + if (iLayerNum + 1 >= MAX_LAYER_NUM_OF_FRAME) { // check available layer_bs_info for further writing as followed | |
| 3322 | 3215 | WelsLog (pCtx, WELS_LOG_ERROR, |
| 3323 | 3216 | "WelsEncoderEncodeExt(), iLayerNum(%d) overflow(max:%d) at iDid= %d uiSliceMode= %d, iSliceCount= %d!", |
| 3324 | 3217 | iLayerNum, MAX_LAYER_NUM_OF_FRAME, iCurDid, param_d->sSliceCfg.uiSliceMode, iSliceCount); |
| @@ -3332,17 +3225,9 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, void* pDst, const SSourcePictur · 7 unmodified lines | ||
| 3332 | 3225 | } |
| 3333 | 3226 | |
| 3334 | 3227 | if (pSvcParam->iCountThreadsNum >= iSliceCount) { //THREAD_FULLY_FIRE_MODE |
| 3335 | −#if defined(PACKING_ONE_SLICE_PER_LAYER) | |
| 3336 | − int32_t iSliceIdx = 1; | |
| 3337 | − int32_t iOrgSlicePos[MAX_SLICES_NUM] = {0}; | |
| 3338 | − iOrgSlicePos[0] = pCtx->iPosBsBuffer; | |
| 3339 | − while (uiSliceIdx < iSliceCount) { | |
| 3340 | − iOrgSlicePos[uiSliceIdx] = pCtx->pSliceBs[uiSliceIdx].uiBsPos; | |
| 3341 | − ++ uiSliceIdx; | |
| 3342 | − } | |
| 3343 | −#elif defined(MT_DEBUG) | |
| 3228 | +#if defined(MT_DEBUG) | |
| 3344 | 3229 | int64_t t_bs_append = 0; |
| 3345 | −#endif//PACKING_ONE_SLICE_PER_LAYER | |
| 3230 | +#endif | |
| 3346 | 3231 | |
| 3347 | 3232 | pCtx->iActiveThreadsNum = iSliceCount; |
| 3348 | 3233 | // to fire slice coding threads |
| @@ -3362,16 +3247,6 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, void* pDst, const SSourcePictur · 13 unmodified lines | ||
| 3362 | 3247 | WELS_VERIFY_RETURN_IFNEQ(pCtx->iEncoderError, ENC_RETURN_SUCCESS) |
| 3363 | 3248 | |
| 3364 | 3249 | // append exclusive slice 0 bs to pFrameBs |
| 3365 | −#if defined(PACKING_ONE_SLICE_PER_LAYER) | |
| 3366 | − iLayerSize = pCtx->iPosBsBuffer - iOrgSlicePos[0]; | |
| 3367 | − uiSliceIdx = 1; | |
| 3368 | − while (uiSliceIdx < iSliceCount) { | |
| 3369 | − iLayerSize += pCtx->pSliceBs[uiSliceIdx].uiBsPos - iOrgSlicePos[uiSliceIdx]; | |
| 3370 | − ++ uiSliceIdx; | |
| 3371 | − } | |
| 3372 | − iLayerNum += iSliceCount; // each slice stickly output as layer info for performance improvement directly | |
| 3373 | − pLayerBsInfo += iSliceCount; | |
| 3374 | −#else | |
| 3375 | 3250 | #if defined(MT_DEBUG) |
| 3376 | 3251 | t_bs_append = WelsTime(); |
| 3377 | 3252 | #endif//MT_DEBUG |
| @@ -3388,20 +3263,10 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, void* pDst, const SSourcePictur · 10 unmodified lines | ||
| 3388 | 3263 | t_bs_append, pCtx->iCodingIndex, iCurDid, 0); |
| 3389 | 3264 | } |
| 3390 | 3265 | #endif//MT_DEBUG |
| 3391 | −#endif//PACKING_ONE_SLICE_PER_LAYER | |
| 3392 | 3266 | } else { //THREAD_PICK_UP_MODE |
| 3393 | 3267 | int32_t iNumThreadsRunning = 0; |
| 3394 | 3268 | int32_t iNumThreadsScheduled = 0; |
| 3395 | 3269 | int32_t iIndexOfSliceToBeCoded = 0; |
| 3396 | −#if defined(PACKING_ONE_SLICE_PER_LAYER) | |
| 3397 | − int32_t iSliceIdx = 1; | |
| 3398 | − int32_t iOrgSlicePos[MAX_SLICES_NUM] = {0}; | |
| 3399 | − iOrgSlicePos[0] = pCtx->iPosBsBuffer; | |
| 3400 | − while (uiSliceIdx < iSliceCount) { | |
| 3401 | − iOrgSlicePos[uiSliceIdx] = pCtx->pSliceBs[uiSliceIdx].uiBsPos; | |
| 3402 | − ++ uiSliceIdx; | |
| 3403 | − } | |
| 3404 | −#endif//PACKING_ONE_SLICE_PER_LAYER | |
| 3405 | 3270 | |
| 3406 | 3271 | pCtx->iActiveThreadsNum = pSvcParam->iCountThreadsNum; |
| 3407 | 3272 | iNumThreadsScheduled = pCtx->iActiveThreadsNum; |
| @@ -3433,9 +3298,6 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, void* pDst, const SSourcePictur · 25 unmodified lines | ||
| 3433 | 3298 | // pick up succeeding slice for threading |
| 3434 | 3299 | // thread_id equal to iEventId per implementation here |
| 3435 | 3300 | pCtx->pSliceThreading->pThreadPEncCtx[iEventId].iSliceIndex = iIndexOfSliceToBeCoded; |
| 3436 | −#ifdef PACKING_ONE_SLICE_PER_LAYER | |
| 3437 | − pCtx->pSliceThreading->pThreadPEncCtx[iEventId].pLayerBs = pLayerBsInfo + iIndexOfSliceToBeCoded; | |
| 3438 | −#endif//PACKING_ONE_SLICE_PER_LAYER | |
| 3439 | 3301 | WelsEventSignal (&pCtx->pSliceThreading->pReadySliceCodingEvent[iEventId]); |
| 3440 | 3302 | |
| 3441 | 3303 | ++ iIndexOfSliceToBeCoded; |
| @@ -3457,9 +3319,6 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, void* pDst, const SSourcePictur · 15 unmodified lines | ||
| 3457 | 3319 | if (iIndexOfSliceToBeCoded >= iSliceCount) |
| 3458 | 3320 | break; |
| 3459 | 3321 | pCtx->pSliceThreading->pThreadPEncCtx[iThreadIdx].iSliceIndex = iIndexOfSliceToBeCoded; |
| 3460 | −#ifdef PACKING_ONE_SLICE_PER_LAYER | |
| 3461 | − pCtx->pSliceThreading->pThreadPEncCtx[iThreadIdx].pLayerBs = pLayerBsInfo + iIndexOfSliceToBeCoded; | |
| 3462 | −#endif//PACKING_ONE_SLICE_PER_LAYER | |
| 3463 | 3322 | WelsEventSignal (pCtx->pSliceThreading->pReadySliceCodingEvent[iThreadIdx]); |
| 3464 | 3323 | |
| 3465 | 3324 | ++ iIndexOfSliceToBeCoded; |
| @@ -3473,31 +3332,14 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, void* pDst, const SSourcePictur · 7 unmodified lines | ||
| 3473 | 3332 | #endif//_WIN32 |
| 3474 | 3333 | }//while(1) |
| 3475 | 3334 | |
| 3476 | −// all slices are finished coding here | |
| 3335 | + // all slices are finished coding here | |
| 3477 | 3336 | // append exclusive slice 0 bs to pFrameBs |
| 3478 | −#if defined(PACKING_ONE_SLICE_PER_LAYER) | |
| 3479 | − iLayerSize = pCtx->iPosBsBuffer - iOrgSlicePos[0]; | |
| 3480 | − uiSliceIdx = 1; | |
| 3481 | − while (uiSliceIdx < iSliceCount) { | |
| 3482 | − iLayerSize += pCtx->pSliceBs[uiSliceIdx].uiBsPos - iOrgSlicePos[uiSliceIdx]; | |
| 3483 | − ++ uiSliceIdx; | |
| 3484 | − } | |
| 3485 | − iLayerNum += iSliceCount; // each slice stickly output as layer info for performance improvement directly | |
| 3486 | − pLayerBsInfo += iSliceCount; | |
| 3487 | −#else | |
| 3488 | 3337 | iLayerSize = AppendSliceToFrameBs (pCtx, pLayerBsInfo, iSliceCount); |
| 3489 | −#endif//PACKING_ONE_SLICE_PER_LAYER | |
| 3490 | 3338 | } |
| 3491 | 3339 | } |
| 3492 | 3340 | // THREAD_FULLY_FIRE_MODE && SM_DYN_SLICE |
| 3493 | 3341 | else if ((SM_DYN_SLICE == param_d->sSliceCfg.uiSliceMode) && (pSvcParam->iMultipleThreadIdc > 1)) { |
| 3494 | 3342 | const int32_t kiPartitionCnt = pCtx->iActiveThreadsNum; //pSvcParam->iCountThreadsNum; |
| 3495 | −#if defined(PACKING_ONE_SLICE_PER_LAYER) | |
| 3496 | − ResetCountBsSizeInPartitions (pCtx->pSliceThreading->pCountBsSizeInPartition, kiPartitionCnt); | |
| 3497 | − pCtx->pCurDqLayer->pSliceEncCtx->iMaxSliceNumConstraint = WELS_MIN (MAX_SLICES_NUM, | |
| 3498 | − DynamicMaxSliceNumConstraint (MAX_LAYER_NUM_OF_FRAME, iLayerNum, 1 + /*( num_qlayer - 1) +*/ (((iCurDid == 0) | |
| 3499 | − && (pSvcParam->uiGopSize > 1)) ? 1 : 0))); | |
| 3500 | −#endif//PACKING_ONE_SLICE_PER_LAYER | |
| 3501 | 3343 | |
| 3502 | 3344 | // to fire slice coding threads |
| 3503 | 3345 | err = FiredSliceThreads (&pCtx->pSliceThreading->pThreadPEncCtx[0], &pCtx->pSliceThreading->pReadySliceCodingEvent[0], |
| @@ -3512,14 +3354,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, void* pDst, const SSourcePictur · 8 unmodified lines | ||
| 3512 | 3354 | WelsMultipleEventsWaitAllBlocking (kiPartitionCnt, &pCtx->pSliceThreading->pSliceCodedEvent[0]); |
| 3513 | 3355 | WELS_VERIFY_RETURN_IFNEQ(pCtx->iEncoderError, ENC_RETURN_SUCCESS) |
| 3514 | 3356 | |
| 3515 | −#if defined(PACKING_ONE_SLICE_PER_LAYER) | |
| 3516 | − iSliceCount = PostProcDynamicSlicingBsWriting (pCtx, pLayerBsInfo, &iLayerSize, kiPartitionCnt); | |
| 3517 | − assert (iLayerNum + iSliceCount < MAX_LAYER_NUM_OF_FRAME); | |
| 3518 | − pLayerBsInfo += iSliceCount; | |
| 3519 | − iLayerNum += iSliceCount; | |
| 3520 | −#else | |
| 3521 | 3357 | iLayerSize = AppendSliceToFrameBs (pCtx, pLayerBsInfo, kiPartitionCnt); |
| 3522 | −#endif//PACKING_ONE_SLICE_PER_LAYER | |
| 3523 | 3358 | } else // for non-dynamic-slicing mode single threading branch.. |
| 3524 | 3359 | #endif//MT_ENABLED |
| 3525 | 3360 | { |
| @@ -3686,16 +3521,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, void* pDst, const SSourcePictur · 160 unmodified lines | ||
| 3686 | 3521 | } |
| 3687 | 3522 | #endif//STAT_OUTPUT |
| 3688 | 3523 | |
| 3689 | −#if defined(MT_ENABLED) && defined(PACKING_ONE_SLICE_PER_LAYER) | |
| 3690 | − if (pSvcParam->iMultipleThreadIdc <= 1 || SM_SINGLE_SLICE == param_d->sSliceCfg.uiSliceMode) // sigle thread actually used | |
| 3691 | −#else | |
| 3692 | − if (1) | |
| 3693 | −#endif//MT_ENABLED && PACKING_ONE_SLICE_PER_LAYER | |
| 3694 | − { | |
| 3695 | − ++ iLayerNum; | |
| 3696 | − ++ pLayerBsInfo; | |
| 3697 | − } | |
| 3698 | − | |
| 3524 | + ++ iLayerNum; | |
| 3525 | + ++ pLayerBsInfo; | |
| 3699 | 3526 | |
| 3700 | 3527 | pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; |
| 3701 | 3528 | |
| @@ -3727,7 +3554,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, void* pDst, const SSourcePictur · 25 unmodified lines | ||
| 3727 | 3554 | ++ iLayerNum; |
| 3728 | 3555 | } |
| 3729 | 3556 | |
| 3730 | −#if defined(MT_ENABLED) && defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE) | |
| 3557 | +#if defined(MT_ENABLED) | |
| 3731 | 3558 | if (param_d->sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE && pSvcParam->iMultipleThreadIdc > 1 && |
| 3732 | 3559 | pSvcParam->iMultipleThreadIdc >= param_d->sSliceCfg.sSliceArgument.uiSliceNum) { |
| 3733 | 3560 | CalcSliceComplexRatio (pCtx->pSliceThreading->pSliceComplexRatio[iCurDid], pCtx->pCurDqLayer->pSliceEncCtx, |
| @@ -3736,7 +3563,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, void* pDst, const SSourcePictur · 2 unmodified lines | ||
| 3736 | 3563 | TrackSliceComplexities (pCtx, iCurDid); |
| 3737 | 3564 | #endif//#if defined(MT_DEBUG) |
| 3738 | 3565 | } |
| 3739 | −#endif//MT_ENABLED && DYNAMIC_SLICE_ASSIGN && TRY_SLICING_BALANCE | |
| 3566 | +#endif//MT_ENABLED | |
| 3740 | 3567 | |
| 3741 | 3568 | ++ iSpatialIdx; |
| 3742 | 3569 | |
| @@ -3767,7 +3594,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, void* pDst, const SSourcePictur · 24 unmodified lines | ||
| 3767 | 3594 | TrackSliceConsumeTime (pCtx, did_list, iSpatialNum); |
| 3768 | 3595 | #endif//MT_ENABLED && MT_DEBUG |
| 3769 | 3596 | |
| 3770 | −#if defined(MT_ENABLED) && defined(DYNAMIC_SLICE_ASSIGN) | |
| 3597 | +#if defined(MT_ENABLED) | |
| 3771 | 3598 | if (pSvcParam->iMultipleThreadIdc > 1 && did_list[0] == BASE_DEPENDENCY_ID |
| 3772 | 3599 | && pSvcParam->sDependencyLayers[0].sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE |
| 3773 | 3600 | && pSvcParam->iMultipleThreadIdc >= pSvcParam->sDependencyLayers[0].sSliceCfg.sSliceArgument.uiSliceNum |
| @@ -3776,7 +3603,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, void* pDst, const SSourcePictur · 2 unmodified lines | ||
| 3776 | 3603 | 1]].sSliceCfg.sSliceArgument.uiSliceNum) { |
| 3777 | 3604 | AdjustBaseLayer (pCtx); |
| 3778 | 3605 | } |
| 3779 | −#endif//DYNAMIC_SLICE_ASSIGN | |
| 3606 | +#endif | |
| 3780 | 3607 | |
| 3781 | 3608 | #ifdef ENABLE_FRAME_DUMP |
| 3782 | 3609 | DumpRecFrame (fsnr, &pSvcParam->sDependencyLayers[pSvcParam->iSpatialLayerNum - |