ref: ce0d371c98fa5150de31faa71d47ce000629943f
parent: 1113afbfade3aeada23b90cc56157ddcb559fe15
parent: 31120dd88cbc73ef9208c60af601f9204663fedf
author: huili2 <[email protected]>
date: Mon May 26 11:15:26 EDT 2014
Merge pull request #895 from ruil2/enc_rc_1 remove redundant code for mb qp calculation
--- a/codec/encoder/core/src/ratectl.cpp
+++ b/codec/encoder/core/src/ratectl.cpp
@@ -562,7 +562,8 @@
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[kiSliceId];
int32_t iLumaQp = pSOverRc->iCalculatedQpSlice;
-
+ SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
+ const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset;
#ifndef _NOT_USE_AQ_FOR_TEST_
if (pEncCtx->pSvcParam->bEnableAdaptiveQuant) {
iLumaQp = (int8_t)WELS_CLIP3 (iLumaQp +
@@ -569,7 +570,7 @@
pEncCtx->pVaa->sAdaptiveQuantParam.pMotionTextureIndexToDeltaQp[pCurMb->iMbXY], pWelsSvcRc->iMinQp, 51);
}
#endif
- pCurMb->uiChromaQp = g_kuiChromaQpTable[iLumaQp];
+ pCurMb->uiChromaQp = g_kuiChromaQpTable[CLIP3_QP_0_51 (iLumaQp + kuiChromaQpIndexOffset)];
pCurMb->uiLumaQp = iLumaQp;
}
@@ -873,12 +874,16 @@
const int32_t kiSliceId = pSlice->uiSliceIdx;
SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[kiSliceId];
SBitStringAux* bs = pSlice->pSliceBsa;
+ SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
+ const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset;
-
pSOverRc->iBsPosSlice = BsGetBitsPos (bs);
- if (pEncCtx->eSliceType == I_SLICE)
+ if (pEncCtx->eSliceType == I_SLICE) {
+ pCurMb->uiLumaQp = pEncCtx->iGlobalQp;
+ pCurMb->uiChromaQp = g_kuiChromaQpTable[CLIP3_QP_0_51 (pCurMb->uiLumaQp + kuiChromaQpIndexOffset)];
return;
+ }
//calculate gom qp and target bits at the beginning of gom
if (0 == (pCurMb->iMbXY % pWelsSvcRc->iNumberMbGom)) {
if (pCurMb->iMbXY != pSOverRc->iStartMbSlice) {
@@ -915,7 +920,6 @@
sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx;
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
SDLayerParam* pDLayerParam = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId];
-
const int32_t kiQp = pDLayerParam->iDLayerQp;
pEncCtx->iGlobalQp = RcCalculateCascadingQp (pEncCtx, kiQp);
@@ -936,6 +940,8 @@
void WelsRcMbInitDisable (void* pCtx, SMB* pCurMb, SSlice* pSlice) {
sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx;
int32_t iLumaQp = pEncCtx->iGlobalQp;
+ SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
+ const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset;
if (pEncCtx->pSvcParam->bEnableAdaptiveQuant && (pEncCtx->eSliceType == P_SLICE)) {
iLumaQp = (int8_t)WELS_CLIP3 (iLumaQp +
@@ -943,7 +949,7 @@
} else {
iLumaQp = WELS_CLIP3 (iLumaQp, FIX_MIN_QP_MODE, FIX_MAX_QP_MODE);
}
- pCurMb->uiChromaQp = g_kuiChromaQpTable[iLumaQp];
+ pCurMb->uiChromaQp = g_kuiChromaQpTable[CLIP3_QP_0_51 (iLumaQp + kuiChromaQpIndexOffset)];
pCurMb->uiLumaQp = iLumaQp;
}
--- a/codec/encoder/core/src/svc_encode_slice.cpp
+++ b/codec/encoder/core/src/svc_encode_slice.cpp
@@ -477,7 +477,7 @@
const int32_t kiTotalNumMb = pCurLayer->iMbWidth * pCurLayer->iMbHeight;
int32_t iCurMbIdx = 0, iNumMbCoded = 0;
const int32_t kiSliceIdx = pSlice->uiSliceIdx;
- const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset;
+
SWelsMD sMd;
int32_t iEncReturn = ENC_RETURN_SUCCESS;
@@ -484,9 +484,6 @@
for (; ;) {
iCurMbIdx = iNextMbIdx;
pCurMb = &pMbList[ iCurMbIdx ];
- pCurMb->uiLumaQp = pEncCtx->iGlobalQp;
- pCurMb->uiChromaQp = g_kuiChromaQpTable[CLIP3_QP_0_51 (pCurMb->uiLumaQp + kuiChromaQpIndexOffset)];
-
pEncCtx->pFuncList->pfRc.pfWelsRcMbInit (pEncCtx, pCurMb, pSlice);
sMd.iLambda = g_kiQpCostTable[pCurMb->uiLumaQp];
@@ -543,9 +540,6 @@
for (; ;) {
iCurMbIdx = iNextMbIdx;
pCurMb = &pMbList[ iCurMbIdx ];
- pCurMb->uiLumaQp = pEncCtx->iGlobalQp;
- pCurMb->uiChromaQp = g_kuiChromaQpTable[CLIP3_QP_0_51 (pCurMb->uiLumaQp + kuiChromaQpIndexOffset)];
-
pEncCtx->pFuncList->pfRc.pfWelsRcMbInit (pEncCtx, pCurMb, pSlice);
// if already reaches the largest number of slices, set QPs to the upper bound
if (pSlice->bDynamicSlicingSliceSizeCtrlFlag) {