Skip to content

rate control: fix int32 overflow in RC_TIMESTAMP_MODE bit budgets - #4063

Open
Nayana-Naik73 wants to merge 1 commit into
cisco:masterfrom
Nayana-Naik73:rc-timestamp-overflow
Open

Nayana-Naik73 wants to merge 1 commit into
cisco:masterfrom
Nayana-Naik73:rc-timestamp-overflow

Conversation

@Nayana-Naik73

Copy link
Copy Markdown

In RC_TIMESTAMP_MODE, WelsRcFrameDelayJudgeTimeStamp sizes the skip and padding buffers as iSpatialBitrate * 50 in int, and RcDecideTargetBitsTimestamp computes iTlayerWeight * kiGopBits in int32 on every P frame, so a 1280x720 encode at 60 Mbps (or 1080p30 at 40 Mbps) hits signed overflow that -fsanitize=undefined reports at ratectl.cpp:1448 and :643. #3982 widened the matching math for the other RC modes, which use the int64 iBitRate, but missed the timestamp path; this widens those intermediates to int64_t the same way and adds HighBitrateTimestampTargetBits next to HighBitrateIdrTargetBits, which fails under UBSan before the change and passes after.

WelsRcFrameDelayJudgeTimeStamp sizes the skip and padding buffers as
iSpatialBitrate * 50 in int arithmetic, which overflows above ~42.9 Mbps.
RcDecideTargetBitsTimestamp computes iTlayerWeight * kiGopBits in int32
for every P frame, which overflows once the average frame exceeds
~1.07 Mbit (above ~32 Mbps at 30 fps with one temporal layer).

Widen both intermediates to int64_t as cisco#3982 did for the other RC modes
and add a timestamp-mode counterpart to HighBitrateIdrTargetBits.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant