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

Michael Niedermayer michael at niedermayer.cc
Mon May 30 22:09:11 EEST 2022


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 at niedermayer.cc>
---
 libavcodec/ffv1enc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

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



More information about the ffmpeg-devel mailing list