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