annotate liba52/downmix.c @ 3910:db1d556fcf58

runtime cpudetect the liba52 way part 2 (downmix.c)
author michael
date Sun, 30 Dec 2001 21:53:56 +0000
parents 848d848521b9
children ef2abfbbd1df
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1 /*
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
2 * downmix.c
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
3 * Copyright (C) 2000-2001 Michel Lespinasse <walken@zoy.org>
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
4 * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
5 *
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
6 * This file is part of a52dec, a free ATSC A-52 stream decoder.
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
7 * See http://liba52.sourceforge.net/ for updates.
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
8 *
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
9 * a52dec is free software; you can redistribute it and/or modify
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
12 * (at your option) any later version.
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
13 *
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
14 * a52dec is distributed in the hope that it will be useful,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
17 * GNU General Public License for more details.
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
18 *
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
20 * along with this program; if not, write to the Free Software
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
3625
84ff13d4540c sse opt of mix32toS()
michael
parents: 3624
diff changeset
22 *
84ff13d4540c sse opt of mix32toS()
michael
parents: 3624
diff changeset
23 * SSE optimizations from Michael Niedermayer (michaelni@gmx.at)
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
24 */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
25
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
26 #include "config.h"
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
27
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
28 #include <string.h>
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
29 #include <inttypes.h>
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
30
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
31 #include "a52.h"
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
32 #include "a52_internal.h"
3910
db1d556fcf58 runtime cpudetect the liba52 way part 2 (downmix.c)
michael
parents: 3904
diff changeset
33 #include "mm_accel.h"
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
34
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
35 #define CONVERT(acmod,output) (((output) << 3) + (acmod))
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
36
3904
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
37
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
38 void (*downmix)(sample_t * samples, int acmod, int output, sample_t bias,
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
39 sample_t clev, sample_t slev)= NULL;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
40 void (*upmix)(sample_t * samples, int acmod, int output)= NULL;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
41
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
42 static void downmix_SSE (sample_t * samples, int acmod, int output, sample_t bias,
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
43 sample_t clev, sample_t slev);
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
44 static void downmix_C (sample_t * samples, int acmod, int output, sample_t bias,
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
45 sample_t clev, sample_t slev);
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
46 static void upmix_MMX (sample_t * samples, int acmod, int output);
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
47 static void upmix_C (sample_t * samples, int acmod, int output);
3910
db1d556fcf58 runtime cpudetect the liba52 way part 2 (downmix.c)
michael
parents: 3904
diff changeset
48
db1d556fcf58 runtime cpudetect the liba52 way part 2 (downmix.c)
michael
parents: 3904
diff changeset
49 void downmix_accel_init(uint32_t mm_accel)
db1d556fcf58 runtime cpudetect the liba52 way part 2 (downmix.c)
michael
parents: 3904
diff changeset
50 {
db1d556fcf58 runtime cpudetect the liba52 way part 2 (downmix.c)
michael
parents: 3904
diff changeset
51 upmix= upmix_C;
db1d556fcf58 runtime cpudetect the liba52 way part 2 (downmix.c)
michael
parents: 3904
diff changeset
52 downmix= downmix_C;
db1d556fcf58 runtime cpudetect the liba52 way part 2 (downmix.c)
michael
parents: 3904
diff changeset
53 #ifdef ARCH_X86
db1d556fcf58 runtime cpudetect the liba52 way part 2 (downmix.c)
michael
parents: 3904
diff changeset
54 if(mm_accel & MM_ACCEL_X86_MMX) upmix= upmix_MMX;
db1d556fcf58 runtime cpudetect the liba52 way part 2 (downmix.c)
michael
parents: 3904
diff changeset
55 if(mm_accel & MM_ACCEL_X86_SSE) downmix= downmix_SSE;
db1d556fcf58 runtime cpudetect the liba52 way part 2 (downmix.c)
michael
parents: 3904
diff changeset
56 #endif
db1d556fcf58 runtime cpudetect the liba52 way part 2 (downmix.c)
michael
parents: 3904
diff changeset
57 }
db1d556fcf58 runtime cpudetect the liba52 way part 2 (downmix.c)
michael
parents: 3904
diff changeset
58
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
59 int downmix_init (int input, int flags, sample_t * level,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
60 sample_t clev, sample_t slev)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
61 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
62 static uint8_t table[11][8] = {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
63 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
64 A52_STEREO, A52_STEREO, A52_STEREO, A52_STEREO},
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
65 {A52_MONO, A52_MONO, A52_MONO, A52_MONO,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
66 A52_MONO, A52_MONO, A52_MONO, A52_MONO},
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
67 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
68 A52_STEREO, A52_STEREO, A52_STEREO, A52_STEREO},
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
69 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_3F,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
70 A52_STEREO, A52_3F, A52_STEREO, A52_3F},
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
71 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
72 A52_2F1R, A52_2F1R, A52_2F1R, A52_2F1R},
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
73 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
74 A52_2F1R, A52_3F1R, A52_2F1R, A52_3F1R},
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
75 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_3F,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
76 A52_2F2R, A52_2F2R, A52_2F2R, A52_2F2R},
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
77 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_3F,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
78 A52_2F2R, A52_3F2R, A52_2F2R, A52_3F2R},
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
79 {A52_CHANNEL1, A52_MONO, A52_MONO, A52_MONO,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
80 A52_MONO, A52_MONO, A52_MONO, A52_MONO},
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
81 {A52_CHANNEL2, A52_MONO, A52_MONO, A52_MONO,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
82 A52_MONO, A52_MONO, A52_MONO, A52_MONO},
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
83 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_DOLBY,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
84 A52_DOLBY, A52_DOLBY, A52_DOLBY, A52_DOLBY}
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
85 };
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
86 int output;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
87
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
88 output = flags & A52_CHANNEL_MASK;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
89 if (output > A52_DOLBY)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
90 return -1;
3738
5c1da9bc17a3 memset(?, 0, 256*sizeof(float)) in MMX
michael
parents: 3679
diff changeset
91
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
92 output = table[output][input & 7];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
93
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
94 if ((output == A52_STEREO) &&
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
95 ((input == A52_DOLBY) || ((input == A52_3F) && (clev == LEVEL_3DB))))
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
96 output = A52_DOLBY;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
97
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
98 if (flags & A52_ADJUST_LEVEL)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
99 switch (CONVERT (input & 7, output)) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
100
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
101 case CONVERT (A52_3F, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
102 *level *= LEVEL_3DB / (1 + clev);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
103 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
104
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
105 case CONVERT (A52_STEREO, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
106 case CONVERT (A52_2F2R, A52_2F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
107 case CONVERT (A52_3F2R, A52_3F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
108 level_3db:
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
109 *level *= LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
110 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
111
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
112 case CONVERT (A52_3F2R, A52_2F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
113 if (clev < LEVEL_PLUS3DB - 1)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
114 goto level_3db;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
115 /* break thru */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
116 case CONVERT (A52_3F, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
117 case CONVERT (A52_3F1R, A52_2F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
118 case CONVERT (A52_3F1R, A52_2F2R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
119 case CONVERT (A52_3F2R, A52_2F2R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
120 *level /= 1 + clev;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
121 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
122
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
123 case CONVERT (A52_2F1R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
124 *level *= LEVEL_PLUS3DB / (2 + slev);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
125 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
126
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
127 case CONVERT (A52_2F1R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
128 case CONVERT (A52_3F1R, A52_3F):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
129 *level /= 1 + slev * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
130 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
131
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
132 case CONVERT (A52_3F1R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
133 *level *= LEVEL_3DB / (1 + clev + 0.5 * slev);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
134 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
135
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
136 case CONVERT (A52_3F1R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
137 *level /= 1 + clev + slev * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
138 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
139
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
140 case CONVERT (A52_2F2R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
141 *level *= LEVEL_3DB / (1 + slev);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
142 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
143
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
144 case CONVERT (A52_2F2R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
145 case CONVERT (A52_3F2R, A52_3F):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
146 *level /= 1 + slev;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
147 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
148
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
149 case CONVERT (A52_3F2R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
150 *level *= LEVEL_3DB / (1 + clev + slev);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
151 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
152
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
153 case CONVERT (A52_3F2R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
154 *level /= 1 + clev + slev;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
155 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
156
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
157 case CONVERT (A52_MONO, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
158 *level *= LEVEL_PLUS3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
159 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
160
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
161 case CONVERT (A52_3F, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
162 case CONVERT (A52_2F1R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
163 *level *= 1 / (1 + LEVEL_3DB);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
164 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
165
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
166 case CONVERT (A52_3F1R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
167 case CONVERT (A52_2F2R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
168 *level *= 1 / (1 + 2 * LEVEL_3DB);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
169 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
170
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
171 case CONVERT (A52_3F2R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
172 *level *= 1 / (1 + 3 * LEVEL_3DB);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
173 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
174 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
175
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
176 return output;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
177 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
178
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
179 int downmix_coeff (sample_t * coeff, int acmod, int output, sample_t level,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
180 sample_t clev, sample_t slev)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
181 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
182 switch (CONVERT (acmod, output & A52_CHANNEL_MASK)) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
183
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
184 case CONVERT (A52_CHANNEL, A52_CHANNEL):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
185 case CONVERT (A52_MONO, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
186 case CONVERT (A52_STEREO, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
187 case CONVERT (A52_3F, A52_3F):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
188 case CONVERT (A52_2F1R, A52_2F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
189 case CONVERT (A52_3F1R, A52_3F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
190 case CONVERT (A52_2F2R, A52_2F2R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
191 case CONVERT (A52_3F2R, A52_3F2R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
192 case CONVERT (A52_STEREO, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
193 coeff[0] = coeff[1] = coeff[2] = coeff[3] = coeff[4] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
194 return 0;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
195
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
196 case CONVERT (A52_CHANNEL, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
197 coeff[0] = coeff[1] = level * LEVEL_6DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
198 return 3;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
199
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
200 case CONVERT (A52_STEREO, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
201 coeff[0] = coeff[1] = level * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
202 return 3;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
203
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
204 case CONVERT (A52_3F, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
205 coeff[0] = coeff[2] = level * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
206 coeff[1] = level * clev * LEVEL_PLUS3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
207 return 7;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
208
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
209 case CONVERT (A52_2F1R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
210 coeff[0] = coeff[1] = level * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
211 coeff[2] = level * slev * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
212 return 7;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
213
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
214 case CONVERT (A52_2F2R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
215 coeff[0] = coeff[1] = level * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
216 coeff[2] = coeff[3] = level * slev * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
217 return 15;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
218
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
219 case CONVERT (A52_3F1R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
220 coeff[0] = coeff[2] = level * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
221 coeff[1] = level * clev * LEVEL_PLUS3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
222 coeff[3] = level * slev * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
223 return 15;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
224
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
225 case CONVERT (A52_3F2R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
226 coeff[0] = coeff[2] = level * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
227 coeff[1] = level * clev * LEVEL_PLUS3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
228 coeff[3] = coeff[4] = level * slev * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
229 return 31;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
230
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
231 case CONVERT (A52_MONO, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
232 coeff[0] = level * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
233 return 0;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
234
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
235 case CONVERT (A52_3F, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
236 clev = LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
237 case CONVERT (A52_3F, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
238 case CONVERT (A52_3F1R, A52_2F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
239 case CONVERT (A52_3F2R, A52_2F2R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
240 coeff[0] = coeff[2] = coeff[3] = coeff[4] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
241 coeff[1] = level * clev;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
242 return 7;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
243
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
244 case CONVERT (A52_2F1R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
245 slev = 1;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
246 case CONVERT (A52_2F1R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
247 coeff[0] = coeff[1] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
248 coeff[2] = level * slev * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
249 return 7;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
250
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
251 case CONVERT (A52_3F1R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
252 clev = LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
253 slev = 1;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
254 case CONVERT (A52_3F1R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
255 coeff[0] = coeff[2] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
256 coeff[1] = level * clev;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
257 coeff[3] = level * slev * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
258 return 15;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
259
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
260 case CONVERT (A52_2F2R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
261 slev = LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
262 case CONVERT (A52_2F2R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
263 coeff[0] = coeff[1] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
264 coeff[2] = coeff[3] = level * slev;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
265 return 15;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
266
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
267 case CONVERT (A52_3F2R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
268 clev = LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
269 case CONVERT (A52_3F2R, A52_2F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
270 slev = LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
271 case CONVERT (A52_3F2R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
272 coeff[0] = coeff[2] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
273 coeff[1] = level * clev;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
274 coeff[3] = coeff[4] = level * slev;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
275 return 31;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
276
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
277 case CONVERT (A52_3F1R, A52_3F):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
278 coeff[0] = coeff[1] = coeff[2] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
279 coeff[3] = level * slev * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
280 return 13;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
281
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
282 case CONVERT (A52_3F2R, A52_3F):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
283 coeff[0] = coeff[1] = coeff[2] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
284 coeff[3] = coeff[4] = level * slev;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
285 return 29;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
286
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
287 case CONVERT (A52_2F2R, A52_2F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
288 coeff[0] = coeff[1] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
289 coeff[2] = coeff[3] = level * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
290 return 12;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
291
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
292 case CONVERT (A52_3F2R, A52_3F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
293 coeff[0] = coeff[1] = coeff[2] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
294 coeff[3] = coeff[4] = level * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
295 return 24;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
296
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
297 case CONVERT (A52_2F1R, A52_2F2R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
298 coeff[0] = coeff[1] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
299 coeff[2] = level * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
300 return 0;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
301
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
302 case CONVERT (A52_3F1R, A52_2F2R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
303 coeff[0] = coeff[2] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
304 coeff[1] = level * clev;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
305 coeff[3] = level * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
306 return 7;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
307
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
308 case CONVERT (A52_3F1R, A52_3F2R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
309 coeff[0] = coeff[1] = coeff[2] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
310 coeff[3] = level * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
311 return 0;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
312
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
313 case CONVERT (A52_CHANNEL, A52_CHANNEL1):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
314 coeff[0] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
315 coeff[1] = 0;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
316 return 0;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
317
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
318 case CONVERT (A52_CHANNEL, A52_CHANNEL2):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
319 coeff[0] = 0;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
320 coeff[1] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
321 return 0;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
322 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
323
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
324 return -1; /* NOTREACHED */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
325 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
326
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
327 static void mix2to1 (sample_t * dest, sample_t * src, sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
328 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
329 int i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
330
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
331 for (i = 0; i < 256; i++)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
332 dest[i] += src[i] + bias;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
333 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
334
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
335 static void mix3to1 (sample_t * samples, sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
336 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
337 int i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
338
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
339 for (i = 0; i < 256; i++)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
340 samples[i] += samples[i + 256] + samples[i + 512] + bias;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
341 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
342
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
343 static void mix4to1 (sample_t * samples, sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
344 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
345 int i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
346
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
347 for (i = 0; i < 256; i++)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
348 samples[i] += (samples[i + 256] + samples[i + 512] +
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
349 samples[i + 768] + bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
350 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
351
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
352 static void mix5to1 (sample_t * samples, sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
353 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
354 int i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
355
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
356 for (i = 0; i < 256; i++)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
357 samples[i] += (samples[i + 256] + samples[i + 512] +
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
358 samples[i + 768] + samples[i + 1024] + bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
359 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
360
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
361 static void mix3to2 (sample_t * samples, sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
362 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
363 int i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
364 sample_t common;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
365
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
366 for (i = 0; i < 256; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
367 common = samples[i + 256] + bias;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
368 samples[i] += common;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
369 samples[i + 256] = samples[i + 512] + common;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
370 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
371 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
372
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
373 static void mix21to2 (sample_t * left, sample_t * right, sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
374 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
375 int i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
376 sample_t common;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
377
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
378 for (i = 0; i < 256; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
379 common = right[i + 256] + bias;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
380 left[i] += common;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
381 right[i] += common;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
382 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
383 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
384
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
385 static void mix21toS (sample_t * samples, sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
386 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
387 int i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
388 sample_t surround;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
389
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
390 for (i = 0; i < 256; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
391 surround = samples[i + 512];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
392 samples[i] += bias - surround;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
393 samples[i + 256] += bias + surround;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
394 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
395 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
396
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
397 static void mix31to2 (sample_t * samples, sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
398 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
399 int i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
400 sample_t common;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
401
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
402 for (i = 0; i < 256; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
403 common = samples[i + 256] + samples[i + 768] + bias;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
404 samples[i] += common;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
405 samples[i + 256] = samples[i + 512] + common;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
406 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
407 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
408
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
409 static void mix31toS (sample_t * samples, sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
410 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
411 int i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
412 sample_t common, surround;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
413
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
414 for (i = 0; i < 256; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
415 common = samples[i + 256] + bias;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
416 surround = samples[i + 768];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
417 samples[i] += common - surround;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
418 samples[i + 256] = samples[i + 512] + common + surround;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
419 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
420 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
421
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
422 static void mix22toS (sample_t * samples, sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
423 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
424 int i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
425 sample_t surround;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
426
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
427 for (i = 0; i < 256; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
428 surround = samples[i + 512] + samples[i + 768];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
429 samples[i] += bias - surround;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
430 samples[i + 256] += bias + surround;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
431 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
432 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
433
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
434 static void mix32to2 (sample_t * samples, sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
435 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
436 int i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
437 sample_t common;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
438
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
439 for (i = 0; i < 256; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
440 common = samples[i + 256] + bias;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
441 samples[i] += common + samples[i + 768];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
442 samples[i + 256] = common + samples[i + 512] + samples[i + 1024];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
443 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
444 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
445
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
446 static void mix32toS (sample_t * samples, sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
447 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
448 int i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
449 sample_t common, surround;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
450
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
451 for (i = 0; i < 256; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
452 common = samples[i + 256] + bias;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
453 surround = samples[i + 768] + samples[i + 1024];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
454 samples[i] += common - surround;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
455 samples[i + 256] = samples[i + 512] + common + surround;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
456 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
457 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
458
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
459 static void move2to1 (sample_t * src, sample_t * dest, sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
460 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
461 int i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
462
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
463 for (i = 0; i < 256; i++)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
464 dest[i] = src[i] + src[i + 256] + bias;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
465 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
466
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
467 static void zero (sample_t * samples)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
468 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
469 int i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
470 for (i = 0; i < 256; i++)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
471 samples[i] = 0;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
472 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
473
3904
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
474 static void downmix_C (sample_t * samples, int acmod, int output, sample_t bias,
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
475 sample_t clev, sample_t slev)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
476 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
477 switch (CONVERT (acmod, output & A52_CHANNEL_MASK)) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
478
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
479 case CONVERT (A52_CHANNEL, A52_CHANNEL2):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
480 memcpy (samples, samples + 256, 256 * sizeof (sample_t));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
481 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
482
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
483 case CONVERT (A52_CHANNEL, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
484 case CONVERT (A52_STEREO, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
485 mix_2to1:
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
486 mix2to1 (samples, samples + 256, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
487 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
488
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
489 case CONVERT (A52_2F1R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
490 if (slev == 0)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
491 goto mix_2to1;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
492 case CONVERT (A52_3F, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
493 mix_3to1:
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
494 mix3to1 (samples, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
495 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
496
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
497 case CONVERT (A52_3F1R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
498 if (slev == 0)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
499 goto mix_3to1;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
500 case CONVERT (A52_2F2R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
501 if (slev == 0)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
502 goto mix_2to1;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
503 mix4to1 (samples, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
504 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
505
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
506 case CONVERT (A52_3F2R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
507 if (slev == 0)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
508 goto mix_3to1;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
509 mix5to1 (samples, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
510 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
511
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
512 case CONVERT (A52_MONO, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
513 memcpy (samples + 256, samples, 256 * sizeof (sample_t));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
514 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
515
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
516 case CONVERT (A52_3F, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
517 case CONVERT (A52_3F, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
518 mix_3to2:
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
519 mix3to2 (samples, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
520 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
521
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
522 case CONVERT (A52_2F1R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
523 if (slev == 0)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
524 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
525 mix21to2 (samples, samples + 256, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
526 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
527
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
528 case CONVERT (A52_2F1R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
529 mix21toS (samples, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
530 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
531
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
532 case CONVERT (A52_3F1R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
533 if (slev == 0)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
534 goto mix_3to2;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
535 mix31to2 (samples, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
536 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
537
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
538 case CONVERT (A52_3F1R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
539 mix31toS (samples, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
540 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
541
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
542 case CONVERT (A52_2F2R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
543 if (slev == 0)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
544 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
545 mix2to1 (samples, samples + 512, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
546 mix2to1 (samples + 256, samples + 768, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
547 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
548
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
549 case CONVERT (A52_2F2R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
550 mix22toS (samples, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
551 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
552
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
553 case CONVERT (A52_3F2R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
554 if (slev == 0)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
555 goto mix_3to2;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
556 mix32to2 (samples, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
557 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
558
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
559 case CONVERT (A52_3F2R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
560 mix32toS (samples, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
561 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
562
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
563 case CONVERT (A52_3F1R, A52_3F):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
564 if (slev == 0)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
565 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
566 mix21to2 (samples, samples + 512, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
567 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
568
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
569 case CONVERT (A52_3F2R, A52_3F):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
570 if (slev == 0)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
571 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
572 mix2to1 (samples, samples + 768, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
573 mix2to1 (samples + 512, samples + 1024, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
574 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
575
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
576 case CONVERT (A52_3F1R, A52_2F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
577 mix3to2 (samples, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
578 memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
579 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
580
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
581 case CONVERT (A52_2F2R, A52_2F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
582 mix2to1 (samples + 512, samples + 768, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
583 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
584
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
585 case CONVERT (A52_3F2R, A52_2F1R):
3678
265680bbdcfd mix3to2 in SSE
michael
parents: 3677
diff changeset
586 mix3to2 (samples, bias); //FIXME possible bug? (output doesnt seem to be used)
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
587 move2to1 (samples + 768, samples + 512, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
588 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
589
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
590 case CONVERT (A52_3F2R, A52_3F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
591 mix2to1 (samples + 768, samples + 1024, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
592 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
593
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
594 case CONVERT (A52_2F1R, A52_2F2R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
595 memcpy (samples + 768, samples + 512, 256 * sizeof (sample_t));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
596 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
597
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
598 case CONVERT (A52_3F1R, A52_2F2R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
599 mix3to2 (samples, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
600 memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
601 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
602
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
603 case CONVERT (A52_3F2R, A52_2F2R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
604 mix3to2 (samples, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
605 memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
606 memcpy (samples + 768, samples + 1024, 256 * sizeof (sample_t));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
607 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
608
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
609 case CONVERT (A52_3F1R, A52_3F2R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
610 memcpy (samples + 1027, samples + 768, 256 * sizeof (sample_t));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
611 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
612 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
613 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
614
3904
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
615 static void upmix_C (sample_t * samples, int acmod, int output)
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
616 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
617 switch (CONVERT (acmod, output & A52_CHANNEL_MASK)) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
618
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
619 case CONVERT (A52_CHANNEL, A52_CHANNEL2):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
620 memcpy (samples + 256, samples, 256 * sizeof (sample_t));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
621 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
622
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
623 case CONVERT (A52_3F2R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
624 zero (samples + 1024);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
625 case CONVERT (A52_3F1R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
626 case CONVERT (A52_2F2R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
627 zero (samples + 768);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
628 case CONVERT (A52_3F, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
629 case CONVERT (A52_2F1R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
630 zero (samples + 512);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
631 case CONVERT (A52_CHANNEL, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
632 case CONVERT (A52_STEREO, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
633 zero (samples + 256);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
634 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
635
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
636 case CONVERT (A52_3F2R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
637 case CONVERT (A52_3F2R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
638 zero (samples + 1024);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
639 case CONVERT (A52_3F1R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
640 case CONVERT (A52_3F1R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
641 zero (samples + 768);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
642 case CONVERT (A52_3F, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
643 case CONVERT (A52_3F, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
644 mix_3to2:
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
645 memcpy (samples + 512, samples + 256, 256 * sizeof (sample_t));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
646 zero (samples + 256);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
647 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
648
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
649 case CONVERT (A52_2F2R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
650 case CONVERT (A52_2F2R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
651 zero (samples + 768);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
652 case CONVERT (A52_2F1R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
653 case CONVERT (A52_2F1R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
654 zero (samples + 512);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
655 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
656
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
657 case CONVERT (A52_3F2R, A52_3F):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
658 zero (samples + 1024);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
659 case CONVERT (A52_3F1R, A52_3F):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
660 case CONVERT (A52_2F2R, A52_2F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
661 zero (samples + 768);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
662 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
663
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
664 case CONVERT (A52_3F2R, A52_3F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
665 zero (samples + 1024);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
666 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
667
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
668 case CONVERT (A52_3F2R, A52_2F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
669 zero (samples + 1024);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
670 case CONVERT (A52_3F1R, A52_2F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
671 mix_31to21:
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
672 memcpy (samples + 768, samples + 512, 256 * sizeof (sample_t));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
673 goto mix_3to2;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
674
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
675 case CONVERT (A52_3F2R, A52_2F2R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
676 memcpy (samples + 1024, samples + 768, 256 * sizeof (sample_t));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
677 goto mix_31to21;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
678 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
679 }
3904
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
680
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
681 #ifdef ARCH_X86
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
682 static void mix2to1_SSE (sample_t * dest, sample_t * src, sample_t bias)
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
683 {
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
684 asm volatile(
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
685 "movlps %2, %%xmm7 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
686 "shufps $0x00, %%xmm7, %%xmm7 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
687 "movl $-1024, %%esi \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
688 "1: \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
689 "movaps (%0, %%esi), %%xmm0 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
690 "movaps 16(%0, %%esi), %%xmm1 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
691 "addps (%1, %%esi), %%xmm0 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
692 "addps 16(%1, %%esi), %%xmm1 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
693 "addps %%xmm7, %%xmm0 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
694 "addps %%xmm7, %%xmm1 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
695 "movaps %%xmm0, (%1, %%esi) \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
696 "movaps %%xmm1, 16(%1, %%esi) \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
697 "addl $32, %%esi \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
698 " jnz 1b \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
699 :: "r" (src+256), "r" (dest+256), "m" (bias)
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
700 : "%esi"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
701 );
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
702 }
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
703
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
704 static void mix3to1_SSE (sample_t * samples, sample_t bias)
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
705 {
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
706 asm volatile(
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
707 "movlps %1, %%xmm7 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
708 "shufps $0x00, %%xmm7, %%xmm7 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
709 "movl $-1024, %%esi \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
710 "1: \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
711 "movaps (%0, %%esi), %%xmm0 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
712 "movaps 1024(%0, %%esi), %%xmm1 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
713 "addps 2048(%0, %%esi), %%xmm0 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
714 "addps %%xmm7, %%xmm1 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
715 "addps %%xmm1, %%xmm0 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
716 "movaps %%xmm0, (%0, %%esi) \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
717 "addl $16, %%esi \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
718 " jnz 1b \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
719 :: "r" (samples+256), "m" (bias)
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
720 : "%esi"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
721 );
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
722 }
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
723
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
724 static void mix4to1_SSE (sample_t * samples, sample_t bias)
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
725 {
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
726 asm volatile(
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
727 "movlps %1, %%xmm7 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
728 "shufps $0x00, %%xmm7, %%xmm7 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
729 "movl $-1024, %%esi \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
730 "1: \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
731 "movaps (%0, %%esi), %%xmm0 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
732 "movaps 1024(%0, %%esi), %%xmm1 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
733 "addps 2048(%0, %%esi), %%xmm0 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
734 "addps 3072(%0, %%esi), %%xmm1 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
735 "addps %%xmm7, %%xmm0 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
736 "addps %%xmm1, %%xmm0 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
737 "movaps %%xmm0, (%0, %%esi) \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
738 "addl $16, %%esi \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
739 " jnz 1b \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
740 :: "r" (samples+256), "m" (bias)
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
741 : "%esi"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
742 );
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
743 }
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
744
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
745 static void mix5to1_SSE (sample_t * samples, sample_t bias)
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
746 {
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
747 asm volatile(
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
748 "movlps %1, %%xmm7 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
749 "shufps $0x00, %%xmm7, %%xmm7 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
750 "movl $-1024, %%esi \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
751 "1: \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
752 "movaps (%0, %%esi), %%xmm0 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
753 "movaps 1024(%0, %%esi), %%xmm1 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
754 "addps 2048(%0, %%esi), %%xmm0 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
755 "addps 3072(%0, %%esi), %%xmm1 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
756 "addps %%xmm7, %%xmm0 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
757 "addps 4096(%0, %%esi), %%xmm1 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
758 "addps %%xmm1, %%xmm0 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
759 "movaps %%xmm0, (%0, %%esi) \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
760 "addl $16, %%esi \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
761 " jnz 1b \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
762 :: "r" (samples+256), "m" (bias)
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
763 : "%esi"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
764 );
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
765 }
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
766
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
767 static void mix3to2_SSE (sample_t * samples, sample_t bias)
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
768 {
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
769 asm volatile(
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
770 "movlps %1, %%xmm7 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
771 "shufps $0x00, %%xmm7, %%xmm7 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
772 "movl $-1024, %%esi \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
773 "1: \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
774 "movaps 1024(%0, %%esi), %%xmm0 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
775 "addps %%xmm7, %%xmm0 \n\t" //common
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
776 "movaps (%0, %%esi), %%xmm1 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
777 "movaps 2048(%0, %%esi), %%xmm2 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
778 "addps %%xmm0, %%xmm1 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
779 "addps %%xmm0, %%xmm2 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
780 "movaps %%xmm1, (%0, %%esi) \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
781 "movaps %%xmm2, 1024(%0, %%esi) \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
782 "addl $16, %%esi \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
783 " jnz 1b \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
784 :: "r" (samples+256), "m" (bias)
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
785 : "%esi"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
786 );
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
787 }
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
788
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
789 static void mix21to2_SSE (sample_t * left, sample_t * right, sample_t bias)
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
790 {
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
791 asm volatile(
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
792 "movlps %2, %%xmm7 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
793 "shufps $0x00, %%xmm7, %%xmm7 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
794 "movl $-1024, %%esi \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
795 "1: \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
796 "movaps 1024(%1, %%esi), %%xmm0 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
797 "addps %%xmm7, %%xmm0 \n\t" //common
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
798 "movaps (%0, %%esi), %%xmm1 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
799 "movaps (%1, %%esi), %%xmm2 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
800 "addps %%xmm0, %%xmm1 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
801 "addps %%xmm0, %%xmm2 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
802 "movaps %%xmm1, (%0, %%esi) \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
803 "movaps %%xmm2, (%1, %%esi) \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
804 "addl $16, %%esi \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
805 " jnz 1b \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
806 :: "r" (left+256), "r" (right+256), "m" (bias)
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
807 : "%esi"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
808 );
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
809 }
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
810
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
811 static void mix21toS_SSE (sample_t * samples, sample_t bias)
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
812 {
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
813 asm volatile(
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
814 "movlps %1, %%xmm7 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
815 "shufps $0x00, %%xmm7, %%xmm7 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
816 "movl $-1024, %%esi \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
817 "1: \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
818 "movaps 2048(%0, %%esi), %%xmm0 \n\t" // surround
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
819 "movaps (%0, %%esi), %%xmm1 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
820 "movaps 1024(%0, %%esi), %%xmm2 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
821 "addps %%xmm7, %%xmm1 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
822 "addps %%xmm7, %%xmm2 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
823 "subps %%xmm0, %%xmm1 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
824 "addps %%xmm0, %%xmm2 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
825 "movaps %%xmm1, (%0, %%esi) \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
826 "movaps %%xmm2, 1024(%0, %%esi) \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
827 "addl $16, %%esi \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
828 " jnz 1b \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
829 :: "r" (samples+256), "m" (bias)
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
830 : "%esi"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
831 );
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
832 }
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
833
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
834 static void mix31to2_SSE (sample_t * samples, sample_t bias)
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
835 {
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
836 asm volatile(
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
837 "movlps %1, %%xmm7 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
838 "shufps $0x00, %%xmm7, %%xmm7 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
839 "movl $-1024, %%esi \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
840 "1: \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
841 "movaps 1024(%0, %%esi), %%xmm0 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
842 "addps 3072(%0, %%esi), %%xmm0 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
843 "addps %%xmm7, %%xmm0 \n\t" // common
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
844 "movaps (%0, %%esi), %%xmm1 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
845 "movaps 2048(%0, %%esi), %%xmm2 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
846 "addps %%xmm0, %%xmm1 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
847 "addps %%xmm0, %%xmm2 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
848 "movaps %%xmm1, (%0, %%esi) \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
849 "movaps %%xmm2, 1024(%0, %%esi) \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
850 "addl $16, %%esi \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
851 " jnz 1b \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
852 :: "r" (samples+256), "m" (bias)
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
853 : "%esi"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
854 );
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
855 }
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
856
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
857 static void mix31toS_SSE (sample_t * samples, sample_t bias)
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
858 {
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
859 asm volatile(
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
860 "movlps %1, %%xmm7 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
861 "shufps $0x00, %%xmm7, %%xmm7 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
862 "movl $-1024, %%esi \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
863 "1: \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
864 "movaps 1024(%0, %%esi), %%xmm0 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
865 "movaps 3072(%0, %%esi), %%xmm3 \n\t" // surround
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
866 "addps %%xmm7, %%xmm0 \n\t" // common
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
867 "movaps (%0, %%esi), %%xmm1 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
868 "movaps 2048(%0, %%esi), %%xmm2 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
869 "addps %%xmm0, %%xmm1 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
870 "addps %%xmm0, %%xmm2 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
871 "subps %%xmm3, %%xmm1 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
872 "addps %%xmm3, %%xmm2 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
873 "movaps %%xmm1, (%0, %%esi) \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
874 "movaps %%xmm2, 1024(%0, %%esi) \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
875 "addl $16, %%esi \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
876 " jnz 1b \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
877 :: "r" (samples+256), "m" (bias)
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
878 : "%esi"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
879 );
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
880 }
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
881
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
882 static void mix22toS_SSE (sample_t * samples, sample_t bias)
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
883 {
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
884 asm volatile(
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
885 "movlps %1, %%xmm7 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
886 "shufps $0x00, %%xmm7, %%xmm7 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
887 "movl $-1024, %%esi \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
888 "1: \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
889 "movaps 2048(%0, %%esi), %%xmm0 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
890 "addps 3072(%0, %%esi), %%xmm0 \n\t" // surround
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
891 "movaps (%0, %%esi), %%xmm1 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
892 "movaps 1024(%0, %%esi), %%xmm2 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
893 "addps %%xmm7, %%xmm1 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
894 "addps %%xmm7, %%xmm2 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
895 "subps %%xmm0, %%xmm1 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
896 "addps %%xmm0, %%xmm2 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
897 "movaps %%xmm1, (%0, %%esi) \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
898 "movaps %%xmm2, 1024(%0, %%esi) \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
899 "addl $16, %%esi \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
900 " jnz 1b \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
901 :: "r" (samples+256), "m" (bias)
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
902 : "%esi"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
903 );
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
904 }
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
905
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
906 static void mix32to2_SSE (sample_t * samples, sample_t bias)
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
907 {
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
908 asm volatile(
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
909 "movlps %1, %%xmm7 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
910 "shufps $0x00, %%xmm7, %%xmm7 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
911 "movl $-1024, %%esi \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
912 "1: \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
913 "movaps 1024(%0, %%esi), %%xmm0 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
914 "addps %%xmm7, %%xmm0 \n\t" // common
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
915 "movaps %%xmm0, %%xmm1 \n\t" // common
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
916 "addps (%0, %%esi), %%xmm0 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
917 "addps 2048(%0, %%esi), %%xmm1 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
918 "addps 3072(%0, %%esi), %%xmm0 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
919 "addps 4096(%0, %%esi), %%xmm1 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
920 "movaps %%xmm0, (%0, %%esi) \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
921 "movaps %%xmm1, 1024(%0, %%esi) \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
922 "addl $16, %%esi \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
923 " jnz 1b \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
924 :: "r" (samples+256), "m" (bias)
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
925 : "%esi"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
926 );
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
927 }
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
928
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
929 static void mix32toS_SSE (sample_t * samples, sample_t bias)
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
930 {
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
931 asm volatile(
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
932 "movlps %1, %%xmm7 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
933 "shufps $0x00, %%xmm7, %%xmm7 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
934 "movl $-1024, %%esi \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
935 "1: \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
936 "movaps 1024(%0, %%esi), %%xmm0 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
937 "movaps 3072(%0, %%esi), %%xmm2 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
938 "addps %%xmm7, %%xmm0 \n\t" // common
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
939 "addps 4096(%0, %%esi), %%xmm2 \n\t" // surround
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
940 "movaps (%0, %%esi), %%xmm1 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
941 "movaps 2048(%0, %%esi), %%xmm3 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
942 "subps %%xmm2, %%xmm1 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
943 "addps %%xmm2, %%xmm3 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
944 "addps %%xmm0, %%xmm1 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
945 "addps %%xmm0, %%xmm3 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
946 "movaps %%xmm1, (%0, %%esi) \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
947 "movaps %%xmm3, 1024(%0, %%esi) \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
948 "addl $16, %%esi \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
949 " jnz 1b \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
950 :: "r" (samples+256), "m" (bias)
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
951 : "%esi"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
952 );
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
953 }
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
954
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
955 static void move2to1_SSE (sample_t * src, sample_t * dest, sample_t bias)
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
956 {
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
957 asm volatile(
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
958 "movlps %2, %%xmm7 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
959 "shufps $0x00, %%xmm7, %%xmm7 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
960 "movl $-1024, %%esi \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
961 "1: \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
962 "movaps (%0, %%esi), %%xmm0 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
963 "movaps 16(%0, %%esi), %%xmm1 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
964 "addps 1024(%0, %%esi), %%xmm0 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
965 "addps 1040(%0, %%esi), %%xmm1 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
966 "addps %%xmm7, %%xmm0 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
967 "addps %%xmm7, %%xmm1 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
968 "movaps %%xmm0, (%1, %%esi) \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
969 "movaps %%xmm1, 16(%1, %%esi) \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
970 "addl $32, %%esi \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
971 " jnz 1b \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
972 :: "r" (src+256), "r" (dest+256), "m" (bias)
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
973 : "%esi"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
974 );
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
975 }
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
976
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
977 static void zero_MMX(sample_t * samples)
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
978 {
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
979 asm volatile(
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
980 "movl $-1024, %%esi \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
981 "pxor %%mm0, %%mm0 \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
982 "1: \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
983 "movq %%mm0, (%0, %%esi) \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
984 "movq %%mm0, 8(%0, %%esi) \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
985 "movq %%mm0, 16(%0, %%esi) \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
986 "movq %%mm0, 24(%0, %%esi) \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
987 "addl $32, %%esi \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
988 " jnz 1b \n\t"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
989 "emms"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
990 :: "r" (samples+256)
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
991 : "%esi"
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
992 );
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
993 }
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
994
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
995
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
996 static void downmix_SSE (sample_t * samples, int acmod, int output, sample_t bias,
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
997 sample_t clev, sample_t slev)
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
998 {
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
999 switch (CONVERT (acmod, output & A52_CHANNEL_MASK)) {
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1000
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1001 case CONVERT (A52_CHANNEL, A52_CHANNEL2):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1002 memcpy (samples, samples + 256, 256 * sizeof (sample_t));
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1003 break;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1004
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1005 case CONVERT (A52_CHANNEL, A52_MONO):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1006 case CONVERT (A52_STEREO, A52_MONO):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1007 mix_2to1_SSE:
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1008 mix2to1_SSE (samples, samples + 256, bias);
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1009 break;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1010
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1011 case CONVERT (A52_2F1R, A52_MONO):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1012 if (slev == 0)
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1013 goto mix_2to1_SSE;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1014 case CONVERT (A52_3F, A52_MONO):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1015 mix_3to1_SSE:
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1016 mix3to1_SSE (samples, bias);
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1017 break;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1018
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1019 case CONVERT (A52_3F1R, A52_MONO):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1020 if (slev == 0)
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1021 goto mix_3to1_SSE;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1022 case CONVERT (A52_2F2R, A52_MONO):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1023 if (slev == 0)
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1024 goto mix_2to1_SSE;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1025 mix4to1_SSE (samples, bias);
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1026 break;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1027
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1028 case CONVERT (A52_3F2R, A52_MONO):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1029 if (slev == 0)
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1030 goto mix_3to1_SSE;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1031 mix5to1_SSE (samples, bias);
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1032 break;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1033
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1034 case CONVERT (A52_MONO, A52_DOLBY):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1035 memcpy (samples + 256, samples, 256 * sizeof (sample_t));
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1036 break;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1037
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1038 case CONVERT (A52_3F, A52_STEREO):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1039 case CONVERT (A52_3F, A52_DOLBY):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1040 mix_3to2_SSE:
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1041 mix3to2_SSE (samples, bias);
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1042 break;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1043
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1044 case CONVERT (A52_2F1R, A52_STEREO):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1045 if (slev == 0)
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1046 break;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1047 mix21to2_SSE (samples, samples + 256, bias);
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1048 break;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1049
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1050 case CONVERT (A52_2F1R, A52_DOLBY):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1051 mix21toS_SSE (samples, bias);
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1052 break;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1053
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1054 case CONVERT (A52_3F1R, A52_STEREO):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1055 if (slev == 0)
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1056 goto mix_3to2_SSE;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1057 mix31to2_SSE (samples, bias);
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1058 break;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1059
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1060 case CONVERT (A52_3F1R, A52_DOLBY):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1061 mix31toS_SSE (samples, bias);
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1062 break;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1063
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1064 case CONVERT (A52_2F2R, A52_STEREO):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1065 if (slev == 0)
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1066 break;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1067 mix2to1_SSE (samples, samples + 512, bias);
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1068 mix2to1_SSE (samples + 256, samples + 768, bias);
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1069 break;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1070
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1071 case CONVERT (A52_2F2R, A52_DOLBY):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1072 mix22toS_SSE (samples, bias);
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1073 break;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1074
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1075 case CONVERT (A52_3F2R, A52_STEREO):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1076 if (slev == 0)
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1077 goto mix_3to2_SSE;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1078 mix32to2_SSE (samples, bias);
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1079 break;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1080
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1081 case CONVERT (A52_3F2R, A52_DOLBY):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1082 mix32toS_SSE (samples, bias);
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1083 break;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1084
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1085 case CONVERT (A52_3F1R, A52_3F):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1086 if (slev == 0)
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1087 break;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1088 mix21to2_SSE (samples, samples + 512, bias);
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1089 break;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1090
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1091 case CONVERT (A52_3F2R, A52_3F):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1092 if (slev == 0)
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1093 break;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1094 mix2to1_SSE (samples, samples + 768, bias);
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1095 mix2to1_SSE (samples + 512, samples + 1024, bias);
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1096 break;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1097
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1098 case CONVERT (A52_3F1R, A52_2F1R):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1099 mix3to2_SSE (samples, bias);
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1100 memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t));
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1101 break;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1102
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1103 case CONVERT (A52_2F2R, A52_2F1R):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1104 mix2to1_SSE (samples + 512, samples + 768, bias);
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1105 break;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1106
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1107 case CONVERT (A52_3F2R, A52_2F1R):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1108 mix3to2_SSE (samples, bias); //FIXME possible bug? (output doesnt seem to be used)
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1109 move2to1_SSE (samples + 768, samples + 512, bias);
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1110 break;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1111
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1112 case CONVERT (A52_3F2R, A52_3F1R):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1113 mix2to1_SSE (samples + 768, samples + 1024, bias);
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1114 break;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1115
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1116 case CONVERT (A52_2F1R, A52_2F2R):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1117 memcpy (samples + 768, samples + 512, 256 * sizeof (sample_t));
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1118 break;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1119
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1120 case CONVERT (A52_3F1R, A52_2F2R):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1121 mix3to2_SSE (samples, bias);
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1122 memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t));
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1123 break;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1124
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1125 case CONVERT (A52_3F2R, A52_2F2R):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1126 mix3to2_SSE (samples, bias);
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1127 memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t));
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1128 memcpy (samples + 768, samples + 1024, 256 * sizeof (sample_t));
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1129 break;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1130
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1131 case CONVERT (A52_3F1R, A52_3F2R):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1132 memcpy (samples + 1027, samples + 768, 256 * sizeof (sample_t));
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1133 break;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1134 }
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1135 }
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1136
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1137 static void upmix_MMX (sample_t * samples, int acmod, int output)
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1138 {
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1139 switch (CONVERT (acmod, output & A52_CHANNEL_MASK)) {
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1140
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1141 case CONVERT (A52_CHANNEL, A52_CHANNEL2):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1142 memcpy (samples + 256, samples, 256 * sizeof (sample_t));
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1143 break;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1144
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1145 case CONVERT (A52_3F2R, A52_MONO):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1146 zero_MMX (samples + 1024);
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1147 case CONVERT (A52_3F1R, A52_MONO):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1148 case CONVERT (A52_2F2R, A52_MONO):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1149 zero_MMX (samples + 768);
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1150 case CONVERT (A52_3F, A52_MONO):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1151 case CONVERT (A52_2F1R, A52_MONO):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1152 zero_MMX (samples + 512);
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1153 case CONVERT (A52_CHANNEL, A52_MONO):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1154 case CONVERT (A52_STEREO, A52_MONO):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1155 zero_MMX (samples + 256);
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1156 break;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1157
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1158 case CONVERT (A52_3F2R, A52_STEREO):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1159 case CONVERT (A52_3F2R, A52_DOLBY):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1160 zero_MMX (samples + 1024);
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1161 case CONVERT (A52_3F1R, A52_STEREO):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1162 case CONVERT (A52_3F1R, A52_DOLBY):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1163 zero_MMX (samples + 768);
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1164 case CONVERT (A52_3F, A52_STEREO):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1165 case CONVERT (A52_3F, A52_DOLBY):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1166 mix_3to2_MMX:
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1167 memcpy (samples + 512, samples + 256, 256 * sizeof (sample_t));
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1168 zero_MMX (samples + 256);
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1169 break;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1170
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1171 case CONVERT (A52_2F2R, A52_STEREO):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1172 case CONVERT (A52_2F2R, A52_DOLBY):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1173 zero_MMX (samples + 768);
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1174 case CONVERT (A52_2F1R, A52_STEREO):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1175 case CONVERT (A52_2F1R, A52_DOLBY):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1176 zero_MMX (samples + 512);
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1177 break;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1178
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1179 case CONVERT (A52_3F2R, A52_3F):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1180 zero_MMX (samples + 1024);
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1181 case CONVERT (A52_3F1R, A52_3F):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1182 case CONVERT (A52_2F2R, A52_2F1R):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1183 zero_MMX (samples + 768);
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1184 break;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1185
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1186 case CONVERT (A52_3F2R, A52_3F1R):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1187 zero_MMX (samples + 1024);
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1188 break;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1189
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1190 case CONVERT (A52_3F2R, A52_2F1R):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1191 zero_MMX (samples + 1024);
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1192 case CONVERT (A52_3F1R, A52_2F1R):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1193 mix_31to21_MMX:
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1194 memcpy (samples + 768, samples + 512, 256 * sizeof (sample_t));
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1195 goto mix_3to2_MMX;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1196
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1197 case CONVERT (A52_3F2R, A52_2F2R):
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1198 memcpy (samples + 1024, samples + 768, 256 * sizeof (sample_t));
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1199 goto mix_31to21_MMX;
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1200 }
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1201 }
848d848521b9 runtime cpudetect
michael
parents: 3741
diff changeset
1202 #endif //ARCH_X86