[FFmpeg-cvslog] ppc: fix Altivec build with old compilers

Mans Rullgard git at videolan.org
Tue Oct 9 13:10:46 CEST 2012


ffmpeg | branch: master | Mans Rullgard <mans at mansr.com> | Mon Oct  8 23:01:02 2012 +0100| [f79364b2c30aaaec9f0b1500a74da5a859c2ff37] | committer: Mans Rullgard

ppc: fix Altivec build with old compilers

The vec_splat() intrinsic requires a constant argument for the
element number, and the code relies on the compiler unrolling
the loop to provide this.  Manually unrolling the loop avoids
this reliance and works with all compilers.

Signed-off-by: Mans Rullgard <mans at mansr.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f79364b2c30aaaec9f0b1500a74da5a859c2ff37
---

 libavcodec/ppc/fmtconvert_altivec.c |   19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/libavcodec/ppc/fmtconvert_altivec.c b/libavcodec/ppc/fmtconvert_altivec.c
index 129891a..68e5e00 100644
--- a/libavcodec/ppc/fmtconvert_altivec.c
+++ b/libavcodec/ppc/fmtconvert_altivec.c
@@ -83,6 +83,12 @@ static void float_to_int16_altivec(int16_t *dst, const float *src, long len)
     }
 }
 
+#define VSTE_INC(dst, v, elem, inc) do {                \
+        vector signed short s = vec_splat(v, elem);     \
+        vec_ste(s, 0, dst);                             \
+        dst += inc;                                     \
+    } while (0)
+
 static void float_to_int16_stride_altivec(int16_t *dst, const float *src,
                                           long len, int stride)
 {
@@ -91,11 +97,14 @@ static void float_to_int16_stride_altivec(int16_t *dst, const float *src,
 
     for (i = 0; i < len - 7; i += 8) {
         d = float_to_int16_one_altivec(src + i);
-        for (j = 0; j < 8; j++) {
-            s = vec_splat(d, j);
-            vec_ste(s, 0, dst);
-            dst += stride;
-        }
+        VSTE_INC(dst, d, 0, stride);
+        VSTE_INC(dst, d, 1, stride);
+        VSTE_INC(dst, d, 2, stride);
+        VSTE_INC(dst, d, 3, stride);
+        VSTE_INC(dst, d, 4, stride);
+        VSTE_INC(dst, d, 5, stride);
+        VSTE_INC(dst, d, 6, stride);
+        VSTE_INC(dst, d, 7, stride);
     }
 }
 



More information about the ffmpeg-cvslog mailing list