1 // this code is based on a52dec/libao/audio_out_oss.c
2 // AltiVec support Copyright (c) 2004 Romain Dolbeau <romain@dolbeau.org>
8 const vector
signed int magic
= {0x43c00000,0x43c00000,0x43c00000,0x43c00000};
10 static inline vector
signed short convert16_altivec(vector
signed int v1
, vector
signed int v2
)
12 register vector
signed short result
;
13 v1
= vec_subs(v1
, magic
);
14 v2
= vec_subs(v2
, magic
);
15 result
= vec_packs(v1
, v2
);
20 static int a52_resample_STEREO_to_2_altivec(float * _f
, int16_t * s16
){
23 int32_t * f
= (int32_t *) _f
;
24 for (i
= 0; i
< 256; i
++) {
25 s16
[2*i
] = convert (f
[i
]);
26 s16
[2*i
+1] = convert (f
[i
+256]);
31 int32_t * f
= (int32_t *) _f
;
32 register vector
signed int f0
, f4
, f256
, f260
;
33 register vector
signed short reven
, rodd
, r0
, r1
;
35 for (i
= 0; i
< 256; i
+= 8) {
39 f256
= vec_ld(1024, f
);
40 f260
= vec_ld(1040, f
);
42 reven
= convert16_altivec(f0
, f4
);
43 rodd
= convert16_altivec(f256
, f260
);
45 r0
= vec_mergeh(reven
, rodd
);
46 r1
= vec_mergel(reven
, rodd
);
58 static void* a52_resample_altivec(int flags
, int ch
){
59 fprintf(stderr
, "Checking for AltiVec resampler : 0x%08x, %d\n", flags
, ch
);
65 if(ch
==2) return a52_resample_STEREO_to_2_altivec
;
69 fprintf(stderr
, "Unsupported flags: 0x%08x (%d channels)\n", flags
, ch
);