History

avcodec/osq: avoid using too large numbers for shifts and integers in update_residue_parameter()

Fixes: 2.96539e+09 is outside the range of representable values of type 'int' Fixes: Assertion n>=0 && n<=32 failed at libavcodec/get_bits.h:423 Fixes: 62241/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_OSQ_fuzzer-4525761925873664 Fixes: 70406/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_OSQ_fuzzer-6545326804434944

Michael Niedermayer committed 3 years ago

Commit 56c334d1 parent 3cd077e1 file · +7 −3Browse files

Showing the changes to libavcodec (1 of 1 file). Show all

Unified · Split

libavcodec/osq.c+7−3
@@ -161,11 +161,15 @@ static int update_residue_parameter(OSQChannel *cb) · 160 unmodified lines
161161
162162 sum = cb->sum;
163163 x = sum / cb->count;
164− rice_k = av_ceil_log2(x);
164+ rice_k = ceil(log2(x));
165165 if (rice_k >= 30) {
166− rice_k = floor(sum / 1.4426952 + 0.5);
167− if (rice_k < 1)
166+ double f = floor(sum / 1.4426952 + 0.5);
167+ if (f <= 1) {
168168 rice_k = 1;
169+ } else if (f >= 31) {
170+ rice_k = 31;
171+ } else
172+ rice_k = f;
169173 }
170174
171175 return rice_k;

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