History

refactor code to eliminate potential div by 0

lyao2 committed 12 years ago

Commit 21deadd1 parent ba7dca81 file · +1 −2Browse files

Showing the changes to codec/encoder/core/src/ratectl.cpp (1 of 1 file). Show all

Unified · Split

codec/encoder/core/src/ratectl.cpp+1−2
@@ -694,12 +694,11 @@ void RcVBufferCalculationSkip (sWelsEncCtx* pEncCtx) { · 693 unmodified lines
694694 //condition 1: whole pBuffer fullness
695695 pWelsSvcRc->iBufferFullnessSkip += (pWelsSvcRc->iFrameDqBits - kiOutputBits);
696696 //condition 2: VGOP bits constraint
697− const int32_t kiVGopBits = WELS_DIV_ROUND (pWelsSvcRc->iBitsPerFrame * VGOP_SIZE, INT_MULTIPLY);
698697 int32_t iVGopBitsPred = 0;
699698 for (int32_t i = pWelsSvcRc->iFrameCodedInVGop + 1; i < VGOP_SIZE; i++)
700699 iVGopBitsPred += pTOverRc[pWelsSvcRc->iTlOfFrames[i]].iMinBitsTl;
701700 iVGopBitsPred -= pWelsSvcRc->iRemainingBits;
702− double dIncPercent = iVGopBitsPred * 100.0 / kiVGopBits - (double)VGOP_BITS_PERCENTAGE_DIFF;
701+ double dIncPercent = iVGopBitsPred * 100.0 * INT_MULTIPLY / (pWelsSvcRc->iBitsPerFrame * VGOP_SIZE) - (double)VGOP_BITS_PERCENTAGE_DIFF;
703702
704703 if ((pWelsSvcRc->iBufferFullnessSkip > pWelsSvcRc->iBufferSizeSkip
705704 && pWelsSvcRc->iAverageFrameQp > pWelsSvcRc->iSkipQpValue)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t