Mercurial > mplayer.hg
comparison liba52/resample_altivec.c @ 11849:459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
author | alex |
---|---|
date | Sun, 25 Jan 2004 18:29:11 +0000 |
parents | |
children | 9e6f7a23b4b1 |
comparison
equal
deleted
inserted
replaced
11848:63fecc69c3fb | 11849:459ba3f14302 |
---|---|
1 // this code is based on a52dec/libao/audio_out_oss.c | |
2 // AltiVec support Copyright (c) 2004 Romain Dolbeau <romain@dolbeau.org> | |
3 | |
4 #ifndef SYS_DARWIN | |
5 #include <altivec.h> | |
6 #endif | |
7 | |
8 const vector signed int magic = {0x43c00000,0x43c00000,0x43c00000,0x43c00000}; | |
9 | |
10 static inline vector signed short convert16_altivec(vector signed int v1, vector signed int v2) | |
11 { | |
12 register vector signed short result; | |
13 v1 = vec_subs(v1, magic); | |
14 v2 = vec_subs(v2, magic); | |
15 result = vec_packs(v1, v2); | |
16 | |
17 return result; | |
18 } | |
19 | |
20 static int a52_resample_STEREO_to_2_altivec(float * _f, int16_t * s16){ | |
21 #if 0 | |
22 int i; | |
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]); | |
27 } | |
28 return 2*256; | |
29 #else | |
30 int i = 0; | |
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; | |
34 | |
35 for (i = 0; i < 256; i+= 8) { | |
36 f0 = vec_ld(0, f); | |
37 f4 = vec_ld(16, f); | |
38 | |
39 f256 = vec_ld(1024, f); | |
40 f260 = vec_ld(1040, f); | |
41 | |
42 reven = convert16_altivec(f0, f4); | |
43 rodd = convert16_altivec(f256, f260); | |
44 | |
45 r0 = vec_mergeh(reven, rodd); | |
46 r1 = vec_mergel(reven, rodd); | |
47 | |
48 vec_st(r0, 0, s16); | |
49 vec_st(r1, 16, s16); | |
50 | |
51 f += 8; | |
52 s16 += 16; | |
53 } | |
54 return(2*256); | |
55 #endif | |
56 } | |
57 | |
58 static void* a52_resample_altivec(int flags, int ch){ | |
59 fprintf(stderr, "Checking for AltiVec resampler : 0x%08x, %d\n", flags, ch); | |
60 | |
61 switch (flags) { | |
62 case A52_CHANNEL: | |
63 case A52_STEREO: | |
64 case A52_DOLBY: | |
65 if(ch==2) return a52_resample_STEREO_to_2_altivec; | |
66 break; | |
67 | |
68 default: | |
69 fprintf(stderr, "Unsupported flags: 0x%08x (%d channels)\n", flags, ch); | |
70 break; | |
71 } | |
72 return NULL; | |
73 } | |
74 |