annotate liba52/resample_altivec.c @ 28379:296f37c6ff02

Use full internal pathname in doxygen @file directives. Otherwise doxygen complains about ambiguous filenames when files exist under the same name in different subdirectories.
author diego
date Sun, 01 Feb 2009 02:01:31 +0000
parents 943f37a4323d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25483
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 25481
diff changeset
1 /*
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 25481
diff changeset
2 * resample.c
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 25481
diff changeset
3 * Copyright (C) 2004 Romain Dolbeau <romain@dolbeau.org>
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 25481
diff changeset
4 *
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 25481
diff changeset
5 * This file is part of a52dec, a free ATSC A-52 stream decoder.
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 25481
diff changeset
6 * See http://liba52.sourceforge.net/ for updates.
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 25481
diff changeset
7 *
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 25481
diff changeset
8 * File added for use with MPlayer and not part of original a52dec.
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 25481
diff changeset
9 *
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 25481
diff changeset
10 * a52dec is free software; you can redistribute it and/or modify
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 25481
diff changeset
11 * it under the terms of the GNU General Public License as published by
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 25481
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 25481
diff changeset
13 * (at your option) any later version.
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 25481
diff changeset
14 *
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 25481
diff changeset
15 * a52dec is distributed in the hope that it will be useful,
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 25481
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 25481
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 25481
diff changeset
18 * GNU General Public License for more details.
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 25481
diff changeset
19 *
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 25481
diff changeset
20 * You should have received a copy of the GNU General Public License
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 25481
diff changeset
21 * along with this program; if not, write to the Free Software
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 25481
diff changeset
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 25481
diff changeset
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
9e6f7a23b4b1 unaligned store, should fix bug #893
lu_zero
parents: 11849
diff changeset
41 static void unaligned_store(vector signed short value, int off, int16_t *dst)
9e6f7a23b4b1 unaligned store, should fix bug #893
lu_zero
parents: 11849
diff changeset
42 {
9e6f7a23b4b1 unaligned store, should fix bug #893
lu_zero
parents: 11849
diff changeset
43 register vector unsigned char align = vec_lvsr(0, dst),
9e6f7a23b4b1 unaligned store, should fix bug #893
lu_zero
parents: 11849
diff changeset
44 mask = vec_lvsl(0, dst);
9e6f7a23b4b1 unaligned store, should fix bug #893
lu_zero
parents: 11849
diff changeset
45 register vector signed short t0,t1, edges;
9e6f7a23b4b1 unaligned store, should fix bug #893
lu_zero
parents: 11849
diff changeset
46
9e6f7a23b4b1 unaligned store, should fix bug #893
lu_zero
parents: 11849
diff changeset
47 t0 = vec_ld(0+off, dst);
9e6f7a23b4b1 unaligned store, should fix bug #893
lu_zero
parents: 11849
diff changeset
48 t1 = vec_ld(15+off, dst);
9e6f7a23b4b1 unaligned store, should fix bug #893
lu_zero
parents: 11849
diff changeset
49 edges = vec_perm(t1 ,t0, mask);
9e6f7a23b4b1 unaligned store, should fix bug #893
lu_zero
parents: 11849
diff changeset
50 t1 = vec_perm(value, edges, align);
9e6f7a23b4b1 unaligned store, should fix bug #893
lu_zero
parents: 11849
diff changeset
51 t0 = vec_perm(edges, value, align);
9e6f7a23b4b1 unaligned store, should fix bug #893
lu_zero
parents: 11849
diff changeset
52 vec_st(t1, 15+off, dst);
9e6f7a23b4b1 unaligned store, should fix bug #893
lu_zero
parents: 11849
diff changeset
53 vec_st(t0, 0+off, dst);
9e6f7a23b4b1 unaligned store, should fix bug #893
lu_zero
parents: 11849
diff changeset
54 }
9e6f7a23b4b1 unaligned store, should fix bug #893
lu_zero
parents: 11849
diff changeset
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
9e6f7a23b4b1 unaligned store, should fix bug #893
lu_zero
parents: 11849
diff changeset
83 // FIXME can be merged to spare some I/O
9e6f7a23b4b1 unaligned store, should fix bug #893
lu_zero
parents: 11849
diff changeset
84 unaligned_store(r0, 0, s16);
9e6f7a23b4b1 unaligned store, should fix bug #893
lu_zero
parents: 11849
diff changeset
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