mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-08 13:22:53 +02:00
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
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 56c334d732
)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
5faff14b90
commit
354d5b9737
@ -160,11 +160,15 @@ static int update_residue_parameter(OSQChannel *cb)
|
|||||||
|
|
||||||
sum = cb->sum;
|
sum = cb->sum;
|
||||||
x = sum / cb->count;
|
x = sum / cb->count;
|
||||||
rice_k = av_ceil_log2(x);
|
rice_k = ceil(log2(x));
|
||||||
if (rice_k >= 30) {
|
if (rice_k >= 30) {
|
||||||
rice_k = floor(sum / 1.4426952 + 0.5);
|
double f = floor(sum / 1.4426952 + 0.5);
|
||||||
if (rice_k < 1)
|
if (f <= 1) {
|
||||||
rice_k = 1;
|
rice_k = 1;
|
||||||
|
} else if (f >= 31) {
|
||||||
|
rice_k = 31;
|
||||||
|
} else
|
||||||
|
rice_k = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rice_k;
|
return rice_k;
|
||||||
|
Loading…
Reference in New Issue
Block a user