[FFmpeg-devel] [PATCH] avcodec/ffv1enc: Fix undefined left shifts of negative numbers

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Mon May 30 19:34:10 EEST 2022


Maybe this fixes the FPE encountered here:
https://fate.ffmpeg.org/report.cgi?slot=alpha-debian-qemu-gcc-4.7&time=20220530144951

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
 libavcodec/ffv1enc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index 311f377b1e..9849082e44 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -143,7 +143,7 @@ static void find_best_state(uint8_t best_state[256][256],
     uint32_t l2tab[256];
 
     for (i = 1; i < 256; i++)
-        l2tab[i] = log2(i / 256.0) * ((-1<<31) / 8);
+        l2tab[i] = -log2(i / 256.0) * ((1U << 31) / 8);
 
     for (i = 0; i < 256; i++) {
         uint64_t best_len[256];
-- 
2.32.0



More information about the ffmpeg-devel mailing list