changeset 24996:9e6f7a23b4b1

unaligned store, should fix bug #893
author lu_zero
date Sun, 11 Nov 2007 20:58:02 +0000
parents e52b23ec0bba
children e429129fa02b
files liba52/resample_altivec.c
diffstat 1 files changed, 18 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/liba52/resample_altivec.c	Sun Nov 11 20:10:19 2007 +0000
+++ b/liba52/resample_altivec.c	Sun Nov 11 20:58:02 2007 +0000
@@ -17,6 +17,21 @@
   return result;
 }
 
+static void unaligned_store(vector signed short value, int off, int16_t *dst)
+{
+    register vector unsigned char align = vec_lvsr(0, dst),
+                                  mask = vec_lvsl(0, dst);
+    register vector signed short t0,t1, edges;
+
+    t0 = vec_ld(0+off, dst);
+    t1 = vec_ld(15+off, dst);
+    edges = vec_perm(t1 ,t0, mask);
+    t1 = vec_perm(value, edges, align);
+    t0 = vec_perm(edges, value, align);
+    vec_st(t1, 15+off, dst);
+    vec_st(t0, 0+off, dst);
+}
+
 static int a52_resample_STEREO_to_2_altivec(float * _f, int16_t * s16){
 #if 0
   int i;
@@ -44,9 +59,9 @@
 
     r0 = vec_mergeh(reven, rodd);
     r1 = vec_mergel(reven, rodd);
-    
-    vec_st(r0, 0, s16);
-    vec_st(r1, 16, s16);
+    // FIXME can be merged to spare some I/O
+    unaligned_store(r0, 0, s16);
+    unaligned_store(r1, 16, s16);
 
     f += 8;
     s16 += 16;