diff mbox series

[FFmpeg-devel,03/18] swscale/ppc/swscale_altivec: Fix build with -O0

Message ID AS8P250MB0744006F4A297D1ED7089F138F3B2@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit 72f4f1dafbddb266b53695e4c8b5e2df4927c1ba
Headers show
Series [FFmpeg-devel,01/18] avcodec/mips/ac3dsp_mips: Add missing includes | 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

Andreas Rheinhardt March 28, 2024, 11:10 p.m. UTC
In this case GCC does not treat a const variable initialized
to the compile-time constant "3" as a compile-time constant
and errors out because the argument is not a literal value.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
A similar issue exists in libswscale/ppc/swscale_vsx.c,
but fixing this would be more involved (making templates
out of always-inline functions...).

 libswscale/ppc/swscale_altivec.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/libswscale/ppc/swscale_altivec.c b/libswscale/ppc/swscale_altivec.c
index 1630355f51..8e35e0372f 100644
--- a/libswscale/ppc/swscale_altivec.c
+++ b/libswscale/ppc/swscale_altivec.c
@@ -107,6 +107,8 @@ 
 
 #endif /* HAVE_BIGENDIAN */
 
+#define SHIFT  3
+
 #define output_pixel(pos, val, bias, signedness) \
     if (big_endian) { \
         AV_WB16(pos, bias + av_clip_ ## signedness ## 16(val >> shift)); \
@@ -149,12 +151,11 @@  yuv2plane1_float_bswap_u(const int32_t *src, uint32_t *dest, int dstW, int start
 static void yuv2plane1_float_altivec(const int32_t *src, float *dest, int dstW)
 {
     const int dst_u = -(uintptr_t)dest & 3;
-    const int shift = 3;
-    const int add = (1 << (shift - 1));
+    const int add = (1 << (SHIFT - 1));
     const int clip = (1 << 16) - 1;
     const float fmult = 1.0f / 65535.0f;
     const vec_u32 vadd = (vec_u32) {add, add, add, add};
-    const vec_u32 vshift = (vec_u32) vec_splat_u32(shift);
+    const vec_u32 vshift = (vec_u32) vec_splat_u32(SHIFT);
     const vec_u32 vlargest = (vec_u32) {clip, clip, clip, clip};
     const vec_f vmul = (vec_f) {fmult, fmult, fmult, fmult};
     const vec_f vzero = (vec_f) {0, 0, 0, 0};
@@ -182,12 +183,11 @@  static void yuv2plane1_float_altivec(const int32_t *src, float *dest, int dstW)
 static void yuv2plane1_float_bswap_altivec(const int32_t *src, uint32_t *dest, int dstW)
 {
     const int dst_u = -(uintptr_t)dest & 3;
-    const int shift = 3;
-    const int add = (1 << (shift - 1));
+    const int add = (1 << (SHIFT - 1));
     const int clip = (1 << 16) - 1;
     const float fmult = 1.0f / 65535.0f;
     const vec_u32 vadd = (vec_u32) {add, add, add, add};
-    const vec_u32 vshift = (vec_u32) vec_splat_u32(shift);
+    const vec_u32 vshift = (vec_u32) vec_splat_u32(SHIFT);
     const vec_u32 vlargest = (vec_u32) {clip, clip, clip, clip};
     const vec_f vmul = (vec_f) {fmult, fmult, fmult, fmult};
     const vec_f vzero = (vec_f) {0, 0, 0, 0};