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