diff mbox series

[FFmpeg-devel,2/2] avcodec/ffv1enc: Alpha workaround

Message ID 20220530190911.20843-2-michael@niedermayer.cc
State New
Headers show
Series [FFmpeg-devel,1/2] avutil/opt: Alpha workaround | 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

Michael Niedermayer May 30, 2022, 7:09 p.m. UTC
alpha-linux-gnu-gcc-5 (Ubuntu 5.5.0-12ubuntu1) 5.5.0 20171010 with qemu-alpha version 2.11.1(Debian 1:2.11+dfsg-1ubuntu7.39)
trigger a FPE on the first iteration

None of the intermediate values when printed shows an anomaly nor does
casting the final value.
I did not investigate this further by looking at the asm but that would
be probably where to continue looking at this if someone is interrested
in alpha.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/ffv1enc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index 9849082e44..9609877498 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -142,8 +142,10 @@  static void find_best_state(uint8_t best_state[256][256],
     int i, j, k, m;
     uint32_t l2tab[256];
 
-    for (i = 1; i < 256; i++)
+    l2tab[1] = -log2(1 / 256.0) * ((1U << 31) / 8);
+    for (i = 2; i < 256; i++) {
         l2tab[i] = -log2(i / 256.0) * ((1U << 31) / 8);
+    }
 
     for (i = 0; i < 256; i++) {
         uint64_t best_len[256];