remove redundant code for mb qp calculation
Showing the changes to codec/encoder/core/src/ratectl.cpp (1 of 2 files). Show all
Unified · Split
| @@ -562,14 +562,15 @@ void RcCalculateMbQp (sWelsEncCtx* pEncCtx, SMB* pCurMb, const int32_t kiSliceId · 561 unmodified lines | ||
| 562 | 562 | SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; |
| 563 | 563 | SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[kiSliceId]; |
| 564 | 564 | int32_t iLumaQp = pSOverRc->iCalculatedQpSlice; |
| 565 | − | |
| 565 | + SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; | |
| 566 | + const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset; | |
| 566 | 567 | #ifndef _NOT_USE_AQ_FOR_TEST_ |
| 567 | 568 | if (pEncCtx->pSvcParam->bEnableAdaptiveQuant) { |
| 568 | 569 | iLumaQp = (int8_t)WELS_CLIP3 (iLumaQp + |
| 569 | 570 | pEncCtx->pVaa->sAdaptiveQuantParam.pMotionTextureIndexToDeltaQp[pCurMb->iMbXY], pWelsSvcRc->iMinQp, 51); |
| 570 | 571 | } |
| 571 | 572 | #endif |
| 572 | − pCurMb->uiChromaQp = g_kuiChromaQpTable[iLumaQp]; | |
| 573 | + pCurMb->uiChromaQp = g_kuiChromaQpTable[CLIP3_QP_0_51 (iLumaQp + kuiChromaQpIndexOffset)]; | |
| 573 | 574 | pCurMb->uiLumaQp = iLumaQp; |
| 574 | 575 | } |
| 575 | 576 | |
| @@ -873,12 +874,16 @@ void WelsRcMbInitGom (void* pCtx, SMB* pCurMb, SSlice* pSlice) { · 297 unmodified lines | ||
| 873 | 874 | const int32_t kiSliceId = pSlice->uiSliceIdx; |
| 874 | 875 | SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[kiSliceId]; |
| 875 | 876 | SBitStringAux* bs = pSlice->pSliceBsa; |
| 876 | − | |
| 877 | + SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; | |
| 878 | + const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset; | |
| 877 | 879 | |
| 878 | 880 | pSOverRc->iBsPosSlice = BsGetBitsPos (bs); |
| 879 | 881 | |
| 880 | − if (pEncCtx->eSliceType == I_SLICE) | |
| 882 | + if (pEncCtx->eSliceType == I_SLICE) { | |
| 883 | + pCurMb->uiLumaQp = pEncCtx->iGlobalQp; | |
| 884 | + pCurMb->uiChromaQp = g_kuiChromaQpTable[CLIP3_QP_0_51 (pCurMb->uiLumaQp + kuiChromaQpIndexOffset)]; | |
| 881 | 885 | return; |
| 886 | + } | |
| 882 | 887 | //calculate gom qp and target bits at the beginning of gom |
| 883 | 888 | if (0 == (pCurMb->iMbXY % pWelsSvcRc->iNumberMbGom)) { |
| 884 | 889 | if (pCurMb->iMbXY != pSOverRc->iStartMbSlice) { |
| @@ -915,7 +920,6 @@ void WelsRcPictureInitDisable (void* pCtx) { · 30 unmodified lines | ||
| 915 | 920 | sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx; |
| 916 | 921 | SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; |
| 917 | 922 | SDLayerParam* pDLayerParam = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId]; |
| 918 | − | |
| 919 | 923 | const int32_t kiQp = pDLayerParam->iDLayerQp; |
| 920 | 924 | |
| 921 | 925 | pEncCtx->iGlobalQp = RcCalculateCascadingQp (pEncCtx, kiQp); |
| @@ -936,6 +940,8 @@ void WelsRcPictureInfoUpdateDisable (void* pCtx, int32_t layer_size) { · 14 unmodified lines | ||
| 936 | 940 | void WelsRcMbInitDisable (void* pCtx, SMB* pCurMb, SSlice* pSlice) { |
| 937 | 941 | sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx; |
| 938 | 942 | int32_t iLumaQp = pEncCtx->iGlobalQp; |
| 943 | + SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; | |
| 944 | + const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset; | |
| 939 | 945 | |
| 940 | 946 | if (pEncCtx->pSvcParam->bEnableAdaptiveQuant && (pEncCtx->eSliceType == P_SLICE)) { |
| 941 | 947 | iLumaQp = (int8_t)WELS_CLIP3 (iLumaQp + |
| @@ -943,7 +949,7 @@ void WelsRcMbInitDisable (void* pCtx, SMB* pCurMb, SSlice* pSlice) { · 1 unmodified line | ||
| 943 | 949 | } else { |
| 944 | 950 | iLumaQp = WELS_CLIP3 (iLumaQp, FIX_MIN_QP_MODE, FIX_MAX_QP_MODE); |
| 945 | 951 | } |
| 946 | − pCurMb->uiChromaQp = g_kuiChromaQpTable[iLumaQp]; | |
| 952 | + pCurMb->uiChromaQp = g_kuiChromaQpTable[CLIP3_QP_0_51 (iLumaQp + kuiChromaQpIndexOffset)]; | |
| 947 | 953 | pCurMb->uiLumaQp = iLumaQp; |
| 948 | 954 | } |
| 949 | 955 | |