Mercurial > mplayer.hg
annotate liba52/resample_altivec.c @ 29220:550ea315bdd8
Remove pointless #ifdef around spudec.h #include.
Fixes the build with dvdread disabled.
author | diego |
---|---|
date | Tue, 05 May 2009 17:27:36 +0000 |
parents | 943f37a4323d |
children |
rev | line source |
---|---|
25483 | 1 /* |
2 * resample.c | |
3 * Copyright (C) 2004 Romain Dolbeau <romain@dolbeau.org> | |
4 * | |
5 * This file is part of a52dec, a free ATSC A-52 stream decoder. | |
6 * See http://liba52.sourceforge.net/ for updates. | |
7 * | |
8 * File added for use with MPlayer and not part of original a52dec. | |
9 * | |
10 * a52dec is free software; you can redistribute it and/or modify | |
11 * it under the terms of the GNU General Public License as published by | |
12 * the Free Software Foundation; either version 2 of the License, or | |
13 * (at your option) any later version. | |
14 * | |
15 * a52dec is distributed in the hope that it will be useful, | |
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 * GNU General Public License for more details. | |
19 * | |
20 * You should have received a copy of the GNU General Public License | |
21 * along with this program; if not, write to the Free Software | |
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
23 */ | |
11849
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
24 |
25328
6f0309e575e0
There is a check for altivec.h in configure so use the preprocessor directive
diego
parents:
24996
diff
changeset
|
25 #ifdef HAVE_ALTIVEC_H |
11849
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
26 #include <altivec.h> |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
27 #endif |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
28 |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
29 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
|
30 |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
31 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
|
32 { |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
33 register vector signed short result; |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
34 v1 = vec_subs(v1, magic); |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
35 v2 = vec_subs(v2, magic); |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
36 result = vec_packs(v1, v2); |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
37 |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
38 return result; |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
39 } |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
40 |
24996 | 41 static void unaligned_store(vector signed short value, int off, int16_t *dst) |
42 { | |
43 register vector unsigned char align = vec_lvsr(0, dst), | |
44 mask = vec_lvsl(0, dst); | |
45 register vector signed short t0,t1, edges; | |
46 | |
47 t0 = vec_ld(0+off, dst); | |
48 t1 = vec_ld(15+off, dst); | |
49 edges = vec_perm(t1 ,t0, mask); | |
50 t1 = vec_perm(value, edges, align); | |
51 t0 = vec_perm(edges, value, align); | |
52 vec_st(t1, 15+off, dst); | |
53 vec_st(t0, 0+off, dst); | |
54 } | |
55 | |
11849
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
56 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
|
57 #if 0 |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
58 int i; |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
59 int32_t * f = (int32_t *) _f; |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
60 for (i = 0; i < 256; i++) { |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
61 s16[2*i] = convert (f[i]); |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
62 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
|
63 } |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
64 return 2*256; |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
65 #else |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
66 int i = 0; |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
67 int32_t * f = (int32_t *) _f; |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
68 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
|
69 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
|
70 |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
71 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
|
72 f0 = vec_ld(0, f); |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
73 f4 = vec_ld(16, f); |
25484
943f37a4323d
cosmetics: Remove trailing whitespace, reformat one comment.
diego
parents:
25483
diff
changeset
|
74 |
11849
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
75 f256 = vec_ld(1024, f); |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
76 f260 = vec_ld(1040, f); |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
77 |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
78 reven = convert16_altivec(f0, f4); |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
79 rodd = convert16_altivec(f256, f260); |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
80 |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
81 r0 = vec_mergeh(reven, rodd); |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
82 r1 = vec_mergel(reven, rodd); |
24996 | 83 // FIXME can be merged to spare some I/O |
84 unaligned_store(r0, 0, s16); | |
85 unaligned_store(r1, 16, s16); | |
11849
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
86 |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
87 f += 8; |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
88 s16 += 16; |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
89 } |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
90 return(2*256); |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
91 #endif |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
92 } |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
93 |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
94 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
|
95 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
|
96 |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
97 switch (flags) { |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
98 case A52_CHANNEL: |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
99 case A52_STEREO: |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
100 case A52_DOLBY: |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
101 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
|
102 break; |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
103 |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
104 default: |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
105 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
|
106 break; |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
107 } |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
108 return NULL; |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
109 } |
459ba3f14302
Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents:
diff
changeset
|
110 |