refactor slice level rc structure

This commit is contained in:
huade
2016-02-23 16:49:37 +08:00
parent 2754129064
commit 7bcb3ba4f4
4 changed files with 66 additions and 78 deletions

View File

@@ -140,21 +140,6 @@ enum {
TIME_WINDOW_TOTAL =2 TIME_WINDOW_TOTAL =2
}; };
typedef struct TagRCSlicing {
int32_t iComplexityIndexSlice;
int32_t iCalculatedQpSlice;
int32_t iStartMbSlice;
int32_t iEndMbSlice;
int32_t iTotalQpSlice;
int32_t iTotalMbSlice;
int32_t iTargetBitsSlice;
int32_t iBsPosSlice;
int32_t iFrameBitsSlice;
int32_t iGomBitsSlice;
int32_t iGomTargetBits;
//int32_t gom_coded_mb;
} SRCSlicing;
typedef struct TagRCTemporal { typedef struct TagRCTemporal {
int32_t iMinBitsTl; int32_t iMinBitsTl;
int32_t iMaxBitsTl; int32_t iMaxBitsTl;
@@ -238,7 +223,6 @@ int32_t iPaddingSize;
int32_t iPaddingBitrateStat; int32_t iPaddingBitrateStat;
bool bSkipFlag; bool bSkipFlag;
SRCSlicing* pSlicingOverRc;
SRCTemporal* pTemporalOverRc; SRCTemporal* pTemporalOverRc;
//for scc //for scc

View File

@@ -80,6 +80,21 @@ bool bLongTermRefFlag;
bool bAdaptiveRefPicMarkingModeFlag; bool bAdaptiveRefPicMarkingModeFlag;
} SRefPicMarking; } SRefPicMarking;
// slice level rc statistic info
typedef struct TagRCSlicing {
int32_t iComplexityIndexSlice;
int32_t iCalculatedQpSlice;
int32_t iStartMbSlice;
int32_t iEndMbSlice;
int32_t iTotalQpSlice;
int32_t iTotalMbSlice;
int32_t iTargetBitsSlice;
int32_t iBsPosSlice;
int32_t iFrameBitsSlice;
int32_t iGomBitsSlice;
int32_t iGomTargetBits;
//int32_t gom_coded_mb;
} SRCSlicing;
/* Header of slice syntax elements, refer to Page 63 in JVT X201wcm */ /* Header of slice syntax elements, refer to Page 63 in JVT X201wcm */
typedef struct TagSliceHeader { typedef struct TagSliceHeader {
@@ -187,6 +202,8 @@ int32_t iMbSkipRun;
int32_t iCountMbNumInSlice; int32_t iCountMbNumInSlice;
uint32_t uiSliceConsumeTime; uint32_t uiSliceConsumeTime;
int32_t iSliceComplexRatio; int32_t iSliceComplexRatio;
SRCSlicing sSlicingOverRc; //slice level rc statistic info
} SSlice, *PSlice; } SSlice, *PSlice;
} }

View File

@@ -4834,6 +4834,9 @@ int32_t DynSliceRealloc (sWelsEncCtx* pCtx,
SSlice* pBaseSlice = &pCurLayer->sLayerInfo.pSliceInLayer[0]; SSlice* pBaseSlice = &pCurLayer->sLayerInfo.pSliceInLayer[0];
SSliceHeaderExt* pBaseSHExt = &pBaseSlice->sSliceHeaderExt; SSliceHeaderExt* pBaseSHExt = &pBaseSlice->sSliceHeaderExt;
SSlice* pSliceIdx = &pSlice[uiSliceIdx]; SSlice* pSliceIdx = &pSlice[uiSliceIdx];
const int32_t kiCurDid = pCtx->uiDependencyId;
const int32_t kiBitsPerMb = WELS_DIV_ROUND (pCtx->pWelsSvcRc[kiCurDid].iTargetBits * INT_MULTIPLY,
pCtx->pWelsSvcRc[kiCurDid].iNumberMbFrame);
while (uiSliceIdx < iMaxSliceNum) { while (uiSliceIdx < iMaxSliceNum) {
SSliceHeaderExt* pSHExt = &pSliceIdx->sSliceHeaderExt; SSliceHeaderExt* pSHExt = &pSliceIdx->sSliceHeaderExt;
pSliceIdx->uiSliceIdx = uiSliceIdx; pSliceIdx->uiSliceIdx = uiSliceIdx;
@@ -4858,41 +4861,22 @@ int32_t DynSliceRealloc (sWelsEncCtx* pCtx,
memcpy (&pSHExt->sSliceHeader.sRefReordering, &pBaseSHExt->sSliceHeader.sRefReordering, memcpy (&pSHExt->sSliceHeader.sRefReordering, &pBaseSHExt->sSliceHeader.sRefReordering,
sizeof (SRefPicListReorderSyntax)); sizeof (SRefPicListReorderSyntax));
pSliceIdx->sSlicingOverRc.iComplexityIndexSlice = 0;
pSliceIdx->sSlicingOverRc.iCalculatedQpSlice = pCtx->iGlobalQp;
pSliceIdx->sSlicingOverRc.iTotalQpSlice = 0;
pSliceIdx->sSlicingOverRc.iTotalMbSlice = 0;
pSliceIdx->sSlicingOverRc.iTargetBitsSlice = WELS_DIV_ROUND (kiBitsPerMb *
pCurLayer->sLayerInfo.pSliceInLayer[uiSliceIdx].iCountMbNumInSlice,
INT_MULTIPLY);
pSliceIdx->sSlicingOverRc.iFrameBitsSlice = 0;
pSliceIdx->sSlicingOverRc.iGomBitsSlice = 0;
pSliceIdx++; pSliceIdx++;
uiSliceIdx++; uiSliceIdx++;
} }
pMA->WelsFree (pCurLayer->sLayerInfo.pSliceInLayer, "Slice"); pMA->WelsFree (pCurLayer->sLayerInfo.pSliceInLayer, "Slice");
pCurLayer->sLayerInfo.pSliceInLayer = pSlice; pCurLayer->sLayerInfo.pSliceInLayer = pSlice;
//deal with rate control variables
const int32_t kiCurDid = pCtx->uiDependencyId;
SRCSlicing* pSlcingOverRc = (SRCSlicing*)pMA->WelsMallocz (iMaxSliceNum * sizeof (SRCSlicing), "SlicingOverRC");
if (NULL == pSlcingOverRc) {
WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR,
"CWelsH264SVCEncoder::DynSliceRealloc: realloc pSlcingOverRc not successful");
return ENC_RETURN_MEMALLOCERR;
}
memcpy (pSlcingOverRc, pCtx->pWelsSvcRc[kiCurDid].pSlicingOverRc, sizeof (SRCSlicing) * iMaxSliceNumOld);
uiSliceIdx = iMaxSliceNumOld;
SRCSlicing* pSORC = &pSlcingOverRc[uiSliceIdx];
const int32_t kiBitsPerMb = WELS_DIV_ROUND (pCtx->pWelsSvcRc[kiCurDid].iTargetBits * INT_MULTIPLY,
pCtx->pWelsSvcRc[kiCurDid].iNumberMbFrame);
while (uiSliceIdx < iMaxSliceNum) {
pSORC->iComplexityIndexSlice = 0;
pSORC->iCalculatedQpSlice = pCtx->iGlobalQp;
pSORC->iTotalQpSlice = 0;
pSORC->iTotalMbSlice = 0;
pSORC->iTargetBitsSlice = WELS_DIV_ROUND (kiBitsPerMb *
pCurLayer->sLayerInfo.pSliceInLayer[uiSliceIdx].iCountMbNumInSlice,
INT_MULTIPLY);
pSORC->iFrameBitsSlice = 0;
pSORC->iGomBitsSlice = 0;
pSORC ++;
uiSliceIdx ++;
}
pMA->WelsFree (pCtx->pWelsSvcRc[kiCurDid].pSlicingOverRc, "SlicingOverRC");
pCtx->pWelsSvcRc[kiCurDid].pSlicingOverRc = pSlcingOverRc;
if (pCtx->iMaxSliceCount < iMaxSliceNum) if (pCtx->iMaxSliceCount < iMaxSliceNum)
pCtx->iMaxSliceCount = iMaxSliceNum; pCtx->iMaxSliceCount = iMaxSliceNum;
pCurLayer->sSliceEncCtx.iMaxSliceNumConstraint = iMaxSliceNum; pCurLayer->sSliceEncCtx.iMaxSliceNumConstraint = iMaxSliceNum;

View File

@@ -59,7 +59,6 @@ const int32_t g_kiQpToQstepTable[52] = {
}; //WELS_ROUND(INT_MULTIPLY*pow (2.0, (iQP - 4.0) / 6.0)) }; //WELS_ROUND(INT_MULTIPLY*pow (2.0, (iQP - 4.0) / 6.0))
void RcInitLayerMemory (SWelsSvcRc* pWelsSvcRc, CMemoryAlign* pMA, const int32_t kiMaxTl) { void RcInitLayerMemory (SWelsSvcRc* pWelsSvcRc, CMemoryAlign* pMA, const int32_t kiMaxTl) {
const int32_t kiSliceNum = pWelsSvcRc->iSliceNum;
const int32_t kiGomSize = pWelsSvcRc->iGomSize; const int32_t kiGomSize = pWelsSvcRc->iGomSize;
const int32_t kiGomSizeD = kiGomSize * sizeof (double); const int32_t kiGomSizeD = kiGomSize * sizeof (double);
const int32_t kiGomSizeI = kiGomSize * sizeof (int32_t); const int32_t kiGomSizeI = kiGomSize * sizeof (int32_t);
@@ -79,14 +78,9 @@ void RcInitLayerMemory (SWelsSvcRc* pWelsSvcRc, CMemoryAlign* pMA, const int32_t
pBaseMem += kiGomSizeI; pBaseMem += kiGomSizeI;
pWelsSvcRc->pGomCost = (int32_t*)pBaseMem; pWelsSvcRc->pGomCost = (int32_t*)pBaseMem;
pWelsSvcRc->pSlicingOverRc = (SRCSlicing*)pMA->WelsMalloc (sizeof (SRCSlicing) * kiSliceNum, "SlicingOverRC");
} }
void RcFreeLayerMemory (SWelsSvcRc* pWelsSvcRc, CMemoryAlign* pMA) { void RcFreeLayerMemory (SWelsSvcRc* pWelsSvcRc, CMemoryAlign* pMA) {
if (pWelsSvcRc != NULL && pWelsSvcRc->pSlicingOverRc != NULL) {
pMA->WelsFree (pWelsSvcRc->pSlicingOverRc, "SlicingOverRC");
pWelsSvcRc->pSlicingOverRc = NULL;
}
if (pWelsSvcRc != NULL && pWelsSvcRc->pTemporalOverRc != NULL) { if (pWelsSvcRc != NULL && pWelsSvcRc->pTemporalOverRc != NULL) {
pMA->WelsFree (pWelsSvcRc->pTemporalOverRc, "pWelsSvcRc->pTemporalOverRc"); pMA->WelsFree (pWelsSvcRc->pTemporalOverRc, "pWelsSvcRc->pTemporalOverRc");
pWelsSvcRc->pTemporalOverRc = NULL; pWelsSvcRc->pTemporalOverRc = NULL;
@@ -517,12 +511,13 @@ void RcCalculatePictureQp (sWelsEncCtx* pEncCtx) {
void RcInitSliceInformation (sWelsEncCtx* pEncCtx) { void RcInitSliceInformation (sWelsEncCtx* pEncCtx) {
SSlice* pSliceInLayer = pEncCtx->pCurDqLayer->sLayerInfo.pSliceInLayer; SSlice* pSliceInLayer = pEncCtx->pCurDqLayer->sLayerInfo.pSliceInLayer;
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[0]; SRCSlicing* pSOverRc = &pSliceInLayer[0].sSlicingOverRc;
const int32_t kiSliceNum = pWelsSvcRc->iSliceNum; const int32_t kiSliceNum = pWelsSvcRc->iSliceNum;
const int32_t kiBitsPerMb = WELS_DIV_ROUND (static_cast<int64_t> (pWelsSvcRc->iTargetBits) * INT_MULTIPLY, const int32_t kiBitsPerMb = WELS_DIV_ROUND (static_cast<int64_t> (pWelsSvcRc->iTargetBits) * INT_MULTIPLY,
pWelsSvcRc->iNumberMbFrame); pWelsSvcRc->iNumberMbFrame);
for (int32_t i = 0; i < kiSliceNum; i++) { for (int32_t i = 0; i < kiSliceNum; i++) {
pSOverRc = &pSliceInLayer[i].sSlicingOverRc;
pSOverRc->iStartMbSlice = pSOverRc->iStartMbSlice =
pSOverRc->iEndMbSlice = pSliceInLayer[i].sSliceHeaderExt.sSliceHeader.iFirstMbInSlice; pSOverRc->iEndMbSlice = pSliceInLayer[i].sSliceHeaderExt.sSliceHeader.iFirstMbInSlice;
pSOverRc->iEndMbSlice += (pSliceInLayer[i].iCountMbNumInSlice - 1); pSOverRc->iEndMbSlice += (pSliceInLayer[i].iCountMbNumInSlice - 1);
@@ -531,7 +526,6 @@ void RcInitSliceInformation (sWelsEncCtx* pEncCtx) {
pSOverRc->iTargetBitsSlice = WELS_DIV_ROUND (kiBitsPerMb * pSliceInLayer[i].iCountMbNumInSlice, INT_MULTIPLY); pSOverRc->iTargetBitsSlice = WELS_DIV_ROUND (kiBitsPerMb * pSliceInLayer[i].iCountMbNumInSlice, INT_MULTIPLY);
pSOverRc->iFrameBitsSlice = 0; pSOverRc->iFrameBitsSlice = 0;
pSOverRc->iGomBitsSlice = 0; pSOverRc->iGomBitsSlice = 0;
++ pSOverRc;
} }
} }
@@ -560,8 +554,9 @@ void RcDecideTargetBits (sWelsEncCtx* pEncCtx) {
void RcInitGomParameters (sWelsEncCtx* pEncCtx) { void RcInitGomParameters (sWelsEncCtx* pEncCtx) {
SSlice* pSliceInLayer = pEncCtx->pCurDqLayer->sLayerInfo.pSliceInLayer;
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[0]; SRCSlicing* pSOverRc = &pSliceInLayer[0].sSlicingOverRc;
const int32_t kiSliceNum = pWelsSvcRc->iSliceNum; const int32_t kiSliceNum = pWelsSvcRc->iSliceNum;
const int32_t kiGlobalQp = pEncCtx->iGlobalQp; const int32_t kiGlobalQp = pEncCtx->iGlobalQp;
@@ -569,17 +564,19 @@ void RcInitGomParameters (sWelsEncCtx* pEncCtx) {
pWelsSvcRc->iMinFrameQp = 51; pWelsSvcRc->iMinFrameQp = 51;
pWelsSvcRc->iMaxFrameQp = 0; pWelsSvcRc->iMaxFrameQp = 0;
for (int32_t i = 0; i < kiSliceNum; ++i) { for (int32_t i = 0; i < kiSliceNum; ++i) {
pSOverRc = &pSliceInLayer[i].sSlicingOverRc;
pSOverRc->iComplexityIndexSlice = 0; pSOverRc->iComplexityIndexSlice = 0;
pSOverRc->iCalculatedQpSlice = kiGlobalQp; pSOverRc->iCalculatedQpSlice = kiGlobalQp;
++ pSOverRc;
} }
memset (pWelsSvcRc->pGomComplexity, 0, pWelsSvcRc->iGomSize * sizeof (double)); memset (pWelsSvcRc->pGomComplexity, 0, pWelsSvcRc->iGomSize * sizeof (double));
memset (pWelsSvcRc->pGomCost, 0, pWelsSvcRc->iGomSize * sizeof (int32_t)); memset (pWelsSvcRc->pGomCost, 0, pWelsSvcRc->iGomSize * sizeof (int32_t));
} }
void RcCalculateMbQp (sWelsEncCtx* pEncCtx, SMB* pCurMb, const int32_t kiSliceId) { void RcCalculateMbQp (sWelsEncCtx* pEncCtx, SMB* pCurMb, const int32_t kiSliceId) {
SSlice* pSliceInLayer = pEncCtx->pCurDqLayer->sLayerInfo.pSliceInLayer;
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[kiSliceId]; SRCSlicing* pSOverRc = &pSliceInLayer[kiSliceId].sSlicingOverRc;
int32_t iLumaQp = pSOverRc->iCalculatedQpSlice; int32_t iLumaQp = pSOverRc->iCalculatedQpSlice;
SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
SRCTemporal* pTOverRc = &pWelsSvcRc->pTemporalOverRc[pEncCtx->uiTemporalId]; SRCTemporal* pTOverRc = &pWelsSvcRc->pTemporalOverRc[pEncCtx->uiTemporalId];
@@ -616,9 +613,10 @@ SWelsSvcRc* RcJudgeBaseUsability (sWelsEncCtx* pEncCtx) {
} }
void RcGomTargetBits (sWelsEncCtx* pEncCtx, const int32_t kiSliceId) { void RcGomTargetBits (sWelsEncCtx* pEncCtx, const int32_t kiSliceId) {
SSlice* pSliceInLayer = pEncCtx->pCurDqLayer->sLayerInfo.pSliceInLayer;
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
SWelsSvcRc* pWelsSvcRc_Base = NULL; SWelsSvcRc* pWelsSvcRc_Base = NULL;
SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[kiSliceId]; SRCSlicing* pSOverRc = &pSliceInLayer[kiSliceId].sSlicingOverRc;
int32_t iAllocateBits = 0; int32_t iAllocateBits = 0;
int32_t iSumSad = 0; int32_t iSumSad = 0;
@@ -653,8 +651,9 @@ void RcGomTargetBits (sWelsEncCtx* pEncCtx, const int32_t kiSliceId) {
void RcCalculateGomQp (sWelsEncCtx* pEncCtx, SMB* pCurMb, int32_t iSliceId) { void RcCalculateGomQp (sWelsEncCtx* pEncCtx, SMB* pCurMb, int32_t iSliceId) {
SSlice* pSliceInLayer = pEncCtx->pCurDqLayer->sLayerInfo.pSliceInLayer;
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[iSliceId]; SRCSlicing* pSOverRc = &pSliceInLayer[iSliceId].sSlicingOverRc;
int64_t iBitsRatio = 1; int64_t iBitsRatio = 1;
int64_t iLeftBits = pSOverRc->iTargetBitsSlice - pSOverRc->iFrameBitsSlice; int64_t iLeftBits = pSOverRc->iTargetBitsSlice - pSOverRc->iFrameBitsSlice;
@@ -928,17 +927,18 @@ void RcTraceFrameBits (sWelsEncCtx* pEncCtx, long long uiTimeStamp) {
} }
void RcUpdatePictureQpBits (sWelsEncCtx* pEncCtx, int32_t iCodedBits) { void RcUpdatePictureQpBits (sWelsEncCtx* pEncCtx, int32_t iCodedBits) {
SSlice* pSliceInLayer = pEncCtx->pCurDqLayer->sLayerInfo.pSliceInLayer;
SRCSlicing* pSOverRc = &pSliceInLayer[0].sSlicingOverRc;
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[0];
SSliceCtx* pCurSliceCtx = &pEncCtx->pCurDqLayer->sSliceEncCtx; SSliceCtx* pCurSliceCtx = &pEncCtx->pCurDqLayer->sSliceEncCtx;
int32_t iTotalQp = 0, iTotalMb = 0; int32_t iTotalQp = 0, iTotalMb = 0;
int32_t i; int32_t i;
if (pEncCtx->eSliceType == P_SLICE) { if (pEncCtx->eSliceType == P_SLICE) {
for (i = 0; i < pCurSliceCtx->iSliceNumInFrame; i++) { for (i = 0; i < pCurSliceCtx->iSliceNumInFrame; i++) {
pSOverRc = &pSliceInLayer[i].sSlicingOverRc;
iTotalQp += pSOverRc->iTotalQpSlice; iTotalQp += pSOverRc->iTotalQpSlice;
iTotalMb += pSOverRc->iTotalMbSlice; iTotalMb += pSOverRc->iTotalMbSlice;
++ pSOverRc;
} }
if (iTotalMb > 0) if (iTotalMb > 0)
pWelsSvcRc->iAverageFrameQp = WELS_DIV_ROUND (INT_MULTIPLY * iTotalQp, iTotalMb * INT_MULTIPLY); pWelsSvcRc->iAverageFrameQp = WELS_DIV_ROUND (INT_MULTIPLY * iTotalQp, iTotalMb * INT_MULTIPLY);
@@ -1071,9 +1071,10 @@ void WelsRcPictureInfoUpdateGom (sWelsEncCtx* pEncCtx, int32_t iLayerSize) {
} }
void WelsRcMbInitGom (sWelsEncCtx* pEncCtx, SMB* pCurMb, SSlice* pSlice) { void WelsRcMbInitGom (sWelsEncCtx* pEncCtx, SMB* pCurMb, SSlice* pSlice) {
SSlice* pSliceInLayer = pEncCtx->pCurDqLayer->sLayerInfo.pSliceInLayer;
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
const int32_t kiSliceId = pSlice->uiSliceIdx; const int32_t kiSliceId = pSlice->uiSliceIdx;
SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[kiSliceId]; SRCSlicing* pSOverRc = &pSliceInLayer[kiSliceId].sSlicingOverRc;
SBitStringAux* bs = pSlice->pSliceBsa; SBitStringAux* bs = pSlice->pSliceBsa;
SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset; const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset;
@@ -1097,10 +1098,12 @@ void WelsRcMbInitGom (sWelsEncCtx* pEncCtx, SMB* pCurMb, SSlice* pSlice) {
} }
void WelsRcMbInfoUpdateGom (sWelsEncCtx* pEncCtx, SMB* pCurMb, int32_t iCostLuma, SSlice* pSlice) { void WelsRcMbInfoUpdateGom (sWelsEncCtx* pEncCtx, SMB* pCurMb, int32_t iCostLuma, SSlice* pSlice) {
SSlice* pSliceInLayer = pEncCtx->pCurDqLayer->sLayerInfo.pSliceInLayer;
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
SBitStringAux* bs = pSlice->pSliceBsa; SBitStringAux* bs = pSlice->pSliceBsa;
int32_t iSliceId = pSlice->uiSliceIdx; int32_t iSliceId = pSlice->uiSliceIdx;
SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[iSliceId]; SRCSlicing* pSOverRc = &pSliceInLayer[iSliceId].sSlicingOverRc;
const int32_t kiComplexityIndex = pSOverRc->iComplexityIndexSlice; const int32_t kiComplexityIndex = pSOverRc->iComplexityIndexSlice;
int32_t iCurMbBits = BsGetBitsPos (bs) - pSOverRc->iBsPosSlice; int32_t iCurMbBits = BsGetBitsPos (bs) - pSOverRc->iBsPosSlice;