diff mbox series

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

Message ID DB6PR0101MB22147D55DF0E316DC047D3A78FDD9@DB6PR0101MB2214.eurprd01.prod.exchangelabs.com
State Accepted
Commit 415f012359364a77e8394436f222b74a8641a3ee
Headers show
Series [FFmpeg-devel] avcodec/ffv1enc: Fix undefined left shifts of negative numbers | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_armv7_RPi4 success Make finished
andriy/make_fate_armv7_RPi4 success Make fate finished

Commit Message

Andreas Rheinhardt May 30, 2022, 4:34 p.m. UTC
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@outlook.com>
---
 libavcodec/ffv1enc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Michael Niedermayer May 30, 2022, 5:45 p.m. UTC | #1
On Mon, May 30, 2022 at 06:34:10PM +0200, Andreas Rheinhardt wrote:
> 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@outlook.com>
> ---
>  libavcodec/ffv1enc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

LGTM maybe it fixes the fate box

Locally alpha is more broken than this, there are multiple other places where
FPEs are generated. And if i change the compiler flags so it doesnt generate
FPEs randomly with -mfp-trap-mode=n then gcc just gives internal compiler
errors

thx

[...]
diff mbox series

Patch

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];