diff mbox series

[FFmpeg-devel] lavu/riscv: fix off-by-one in bit-magnitude clip

Message ID 20220915182648.30369-1-remi@remlab.net
State Accepted
Commit 6df3ad9687c41d17094ae5d16b4904f50338e0c4
Headers show
Series [FFmpeg-devel] lavu/riscv: fix off-by-one in bit-magnitude clip | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Rémi Denis-Courmont Sept. 15, 2022, 6:26 p.m. UTC
From: Rémi Denis-Courmont <remi@remlab.net>

---
 libavutil/riscv/intmath.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libavutil/riscv/intmath.h b/libavutil/riscv/intmath.h
index 3263a79dc4..45bce9a0e7 100644
--- a/libavutil/riscv/intmath.h
+++ b/libavutil/riscv/intmath.h
@@ -61,8 +61,8 @@  static av_always_inline av_const int32_t av_clipl_int32_rvi(int64_t a)
 #define av_clip_intp2 av_clip_intp2_rvi
 static av_always_inline av_const int av_clip_intp2_rvi(int a, int p)
 {
-    const int shift = 32 - p;
-    int b = (a << shift) >> shift;
+    const int shift = 31 - p;
+    int b = ((int)(((unsigned)a) << shift)) >> shift;
 
     if (a != b)
         b = (a >> 31) ^ ((1 << p) - 1);