openh264 icon indicating copy to clipboard operation
openh264 copied to clipboard

There is an exception in the encoder'ratecontrol

Open skzxcc opened this issue 2 years ago • 1 comments

` void RcGomTargetBits (sWelsEncCtx* pEncCtx, SSlice* pSlice) { SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; SWelsSvcRc* pWelsSvcRc_Base = NULL; SRCSlicing* pSOverRc = &pSlice->sSlicingOverRc;

int32_t iAllocateBits = 0; int32_t iSumSad = 0; int32_t iLastGomIndex = 0; int32_t iLeftBits = 0; const int32_t kiComplexityIndex = pSOverRc->iComplexityIndexSlice; int32_t i;

iLastGomIndex = pSOverRc->iEndMbSlice / pWelsSvcRc->iNumberMbGom; iLeftBits = pSOverRc->iTargetBitsSlice - pSOverRc->iFrameBitsSlice; if (iLeftBits <= 0) { pSOverRc->iGomTargetBits = 0; return; } else if (kiComplexityIndex >= iLastGomIndex) { iAllocateBits = iLeftBits; } else { pWelsSvcRc_Base = RcJudgeBaseUsability (pEncCtx); pWelsSvcRc_Base = (pWelsSvcRc_Base) ? pWelsSvcRc_Base : pWelsSvcRc; for (i = kiComplexityIndex + 1; i <= iLastGomIndex; i++) { iSumSad += pWelsSvcRc_Base->pCurrentFrameGomSad[i]; }

if (0 == iSumSad)
  iAllocateBits = WELS_DIV_ROUND (iLeftBits, (iLastGomIndex - kiComplexityIndex));
else
  iAllocateBits = WELS_DIV_ROUND ((int64_t)iLeftBits * pWelsSvcRc_Base->pCurrentFrameGomSad[kiComplexityIndex + 1],
                                  iSumSad);

} pSOverRc->iGomTargetBits = iAllocateBits; } `

Why does iAllocateBits depend on pWelsSvcRc_Base->pCurrentFrameGomSad[kiComplexityIndex + 1] instead of pWelsSvcRc_Base->pCurrentFrameGomSad[kiComplexityIndex] ?

skzxcc avatar Feb 16 '23 03:02 skzxcc

It is an internal RC algorithm considering the remaining parts of current frame complexity. Do you actually have such exception reported? Please give detailed steps and tools for us to debug.

huili2 avatar Feb 28 '23 00:02 huili2