ref: fb4c907ecbb3c4af9ac372060a55efa1f0de1f11
parent: 2bb23a79edf98ad2197735d9d558542929aa193b
parent: 21deaddc4820fc2e3ac0eb514bad875c847220ca
author: sijchen <sijchen@cisco.com>
date: Fri Jul 4 06:31:38 EDT 2014
Merge pull request #1076 from lyao2/RCdiv refactor code to eliminate potential div by 0, review at: https://rbcommons.com/s/OpenH264/r/595/
--- a/codec/encoder/core/src/ratectl.cpp
+++ b/codec/encoder/core/src/ratectl.cpp
@@ -694,12 +694,11 @@
//condition 1: whole pBuffer fullness
pWelsSvcRc->iBufferFullnessSkip += (pWelsSvcRc->iFrameDqBits - kiOutputBits);
//condition 2: VGOP bits constraint
- const int32_t kiVGopBits = WELS_DIV_ROUND (pWelsSvcRc->iBitsPerFrame * VGOP_SIZE, INT_MULTIPLY);
int32_t iVGopBitsPred = 0;
for (int32_t i = pWelsSvcRc->iFrameCodedInVGop + 1; i < VGOP_SIZE; i++)
iVGopBitsPred += pTOverRc[pWelsSvcRc->iTlOfFrames[i]].iMinBitsTl;
iVGopBitsPred -= pWelsSvcRc->iRemainingBits;
- double dIncPercent = iVGopBitsPred * 100.0 / kiVGopBits - (double)VGOP_BITS_PERCENTAGE_DIFF;
+ double dIncPercent = iVGopBitsPred * 100.0 * INT_MULTIPLY / (pWelsSvcRc->iBitsPerFrame * VGOP_SIZE) - (double)VGOP_BITS_PERCENTAGE_DIFF;
if ((pWelsSvcRc->iBufferFullnessSkip > pWelsSvcRc->iBufferSizeSkip
&& pWelsSvcRc->iAverageFrameQp > pWelsSvcRc->iSkipQpValue)