fix Rc int32_t bitrate overflow
This commit is contained in:
parent
2dbb757d30
commit
d3c8ade8d0
@ -116,6 +116,10 @@
|
||||
#define WELS_ROUND(x) ((int32_t)(0.5+(x)))
|
||||
#endif//WELS_ROUND
|
||||
|
||||
#ifndef WELS_ROUND64
|
||||
#define WELS_ROUND64(x) ((int64_t)(0.5+(x)))
|
||||
#endif//WELS_ROUND
|
||||
|
||||
#ifndef WELS_DIV_ROUND
|
||||
#define WELS_DIV_ROUND(x,y) ((int32_t)((y)==0?((x)/((y)+1)):(((y)/2+(x))/(y))))
|
||||
#endif//WELS_DIV_ROUND
|
||||
|
@ -159,7 +159,7 @@ int32_t iBitRate;
|
||||
int32_t iPreviousBitrate;
|
||||
int32_t iPreviousGopSize;
|
||||
double fFrameRate;
|
||||
int32_t iBitsPerFrame; // *INT_MULTIPLY
|
||||
int64_t iBitsPerFrame; // *INT_MULTIPLY
|
||||
double dPreviousFps;
|
||||
|
||||
// bits allocation and status
|
||||
|
@ -230,7 +230,7 @@ void RcUpdateBitrateFps (sWelsEncCtx* pEncCtx) {
|
||||
SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId];
|
||||
const int32_t kiGopSize = (1 << pDLayerParamInternal->iDecompositionStages);
|
||||
const int32_t kiHighestTid = pDLayerParamInternal->iHighestTemporalId;
|
||||
int32_t input_iBitsPerFrame = WELS_ROUND (pDLayerParam->iSpatialBitrate * INT_MULTIPLY /
|
||||
int64_t input_iBitsPerFrame = WELS_ROUND64 (((int64_t)pDLayerParam->iSpatialBitrate) * INT_MULTIPLY /
|
||||
pDLayerParamInternal->fInputFrameRate);
|
||||
const int32_t kiGopBits = WELS_DIV_ROUND (input_iBitsPerFrame * kiGopSize, INT_MULTIPLY);
|
||||
int32_t i;
|
||||
@ -255,7 +255,7 @@ void RcUpdateBitrateFps (sWelsEncCtx* pEncCtx) {
|
||||
|
||||
//change remaining bits
|
||||
if (pWelsSvcRc->iBitsPerFrame > REMAIN_BITS_TH)
|
||||
pWelsSvcRc->iRemainingBits = pWelsSvcRc->iRemainingBits * input_iBitsPerFrame / pWelsSvcRc->iBitsPerFrame;
|
||||
pWelsSvcRc->iRemainingBits = (int32_t) (pWelsSvcRc->iRemainingBits * input_iBitsPerFrame / pWelsSvcRc->iBitsPerFrame);
|
||||
pWelsSvcRc->iBitsPerFrame = input_iBitsPerFrame;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user