History

fix Rc int32_t bitrate overflow

dong zhang committed 12 years ago

Commit d3c8ade1 parent 2dbb7573 files · +7 −3Browse files

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

Unified · Split

codec/encoder/core/src/ratectl.cpp+2−2
@@ -230,7 +230,7 @@ void RcUpdateBitrateFps (sWelsEncCtx* pEncCtx) { · 229 unmodified lines
230230 SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId];
231231 const int32_t kiGopSize = (1 << pDLayerParamInternal->iDecompositionStages);
232232 const int32_t kiHighestTid = pDLayerParamInternal->iHighestTemporalId;
233− int32_t input_iBitsPerFrame = WELS_ROUND (pDLayerParam->iSpatialBitrate * INT_MULTIPLY /
233+ int64_t input_iBitsPerFrame = WELS_ROUND64 (((int64_t)pDLayerParam->iSpatialBitrate) * INT_MULTIPLY /
234234 pDLayerParamInternal->fInputFrameRate);
235235 const int32_t kiGopBits = WELS_DIV_ROUND (input_iBitsPerFrame * kiGopSize, INT_MULTIPLY);
236236 int32_t i;
@@ -255,7 +255,7 @@ void RcUpdateBitrateFps (sWelsEncCtx* pEncCtx) { · 18 unmodified lines
255255
256256 //change remaining bits
257257 if (pWelsSvcRc->iBitsPerFrame > REMAIN_BITS_TH)
258− pWelsSvcRc->iRemainingBits = pWelsSvcRc->iRemainingBits * input_iBitsPerFrame / pWelsSvcRc->iBitsPerFrame;
258+ pWelsSvcRc->iRemainingBits = (int32_t) (pWelsSvcRc->iRemainingBits * input_iBitsPerFrame / pWelsSvcRc->iBitsPerFrame);
259259 pWelsSvcRc->iBitsPerFrame = input_iBitsPerFrame;
260260 }
261261

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