annotate liba52/downmix.c @ 3814:8c210c467a3f

not "us", but "en" - missed previously
author gabucino
date Thu, 27 Dec 2001 23:38:49 +0000
parents 99ac808d97c0
children 848d848521b9
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"
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
33
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
34 #define CONVERT(acmod,output) (((output) << 3) + (acmod))
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
35
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
36 int downmix_init (int input, int flags, sample_t * level,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
37 sample_t clev, sample_t slev)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
38 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
39 static uint8_t table[11][8] = {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
40 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
41 A52_STEREO, A52_STEREO, A52_STEREO, A52_STEREO},
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
42 {A52_MONO, A52_MONO, A52_MONO, A52_MONO,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
43 A52_MONO, A52_MONO, A52_MONO, A52_MONO},
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
44 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
45 A52_STEREO, A52_STEREO, A52_STEREO, A52_STEREO},
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
46 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_3F,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
47 A52_STEREO, A52_3F, A52_STEREO, A52_3F},
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
48 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
49 A52_2F1R, A52_2F1R, A52_2F1R, A52_2F1R},
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
50 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
51 A52_2F1R, A52_3F1R, A52_2F1R, A52_3F1R},
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
52 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_3F,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
53 A52_2F2R, A52_2F2R, A52_2F2R, A52_2F2R},
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
54 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_3F,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
55 A52_2F2R, A52_3F2R, A52_2F2R, A52_3F2R},
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
56 {A52_CHANNEL1, A52_MONO, A52_MONO, A52_MONO,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
57 A52_MONO, A52_MONO, A52_MONO, A52_MONO},
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
58 {A52_CHANNEL2, A52_MONO, A52_MONO, A52_MONO,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
59 A52_MONO, A52_MONO, A52_MONO, A52_MONO},
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
60 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_DOLBY,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
61 A52_DOLBY, A52_DOLBY, A52_DOLBY, A52_DOLBY}
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
62 };
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
63 int output;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
64
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
65 output = flags & A52_CHANNEL_MASK;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
66 if (output > A52_DOLBY)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
67 return -1;
3738
5c1da9bc17a3 memset(?, 0, 256*sizeof(float)) in MMX
michael
parents: 3679
diff changeset
68
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
69 output = table[output][input & 7];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
70
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
71 if ((output == A52_STEREO) &&
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
72 ((input == A52_DOLBY) || ((input == A52_3F) && (clev == LEVEL_3DB))))
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
73 output = A52_DOLBY;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
74
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
75 if (flags & A52_ADJUST_LEVEL)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
76 switch (CONVERT (input & 7, output)) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
77
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
78 case CONVERT (A52_3F, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
79 *level *= LEVEL_3DB / (1 + clev);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
80 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
81
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
82 case CONVERT (A52_STEREO, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
83 case CONVERT (A52_2F2R, A52_2F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
84 case CONVERT (A52_3F2R, A52_3F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
85 level_3db:
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
86 *level *= LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
87 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
88
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
89 case CONVERT (A52_3F2R, A52_2F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
90 if (clev < LEVEL_PLUS3DB - 1)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
91 goto level_3db;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
92 /* break thru */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
93 case CONVERT (A52_3F, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
94 case CONVERT (A52_3F1R, A52_2F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
95 case CONVERT (A52_3F1R, A52_2F2R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
96 case CONVERT (A52_3F2R, A52_2F2R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
97 *level /= 1 + clev;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
98 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
99
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
100 case CONVERT (A52_2F1R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
101 *level *= LEVEL_PLUS3DB / (2 + slev);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
102 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
103
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
104 case CONVERT (A52_2F1R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
105 case CONVERT (A52_3F1R, A52_3F):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
106 *level /= 1 + slev * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
107 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
108
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
109 case CONVERT (A52_3F1R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
110 *level *= LEVEL_3DB / (1 + clev + 0.5 * slev);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
111 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
112
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
113 case CONVERT (A52_3F1R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
114 *level /= 1 + clev + slev * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
115 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
116
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
117 case CONVERT (A52_2F2R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
118 *level *= LEVEL_3DB / (1 + slev);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
119 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
120
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
121 case CONVERT (A52_2F2R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
122 case CONVERT (A52_3F2R, A52_3F):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
123 *level /= 1 + slev;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
124 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
125
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
126 case CONVERT (A52_3F2R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
127 *level *= LEVEL_3DB / (1 + clev + slev);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
128 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
129
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
130 case CONVERT (A52_3F2R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
131 *level /= 1 + clev + slev;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
132 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
133
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
134 case CONVERT (A52_MONO, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
135 *level *= LEVEL_PLUS3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
136 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
137
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
138 case CONVERT (A52_3F, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
139 case CONVERT (A52_2F1R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
140 *level *= 1 / (1 + LEVEL_3DB);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
141 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
142
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
143 case CONVERT (A52_3F1R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
144 case CONVERT (A52_2F2R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
145 *level *= 1 / (1 + 2 * LEVEL_3DB);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
146 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
147
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
148 case CONVERT (A52_3F2R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
149 *level *= 1 / (1 + 3 * LEVEL_3DB);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
150 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
151 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
152
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
153 return output;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
154 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
155
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
156 int downmix_coeff (sample_t * coeff, int acmod, int output, sample_t level,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
157 sample_t clev, sample_t slev)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
158 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
159 switch (CONVERT (acmod, output & A52_CHANNEL_MASK)) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
160
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
161 case CONVERT (A52_CHANNEL, A52_CHANNEL):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
162 case CONVERT (A52_MONO, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
163 case CONVERT (A52_STEREO, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
164 case CONVERT (A52_3F, A52_3F):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
165 case CONVERT (A52_2F1R, A52_2F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
166 case CONVERT (A52_3F1R, A52_3F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
167 case CONVERT (A52_2F2R, A52_2F2R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
168 case CONVERT (A52_3F2R, A52_3F2R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
169 case CONVERT (A52_STEREO, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
170 coeff[0] = coeff[1] = coeff[2] = coeff[3] = coeff[4] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
171 return 0;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
172
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
173 case CONVERT (A52_CHANNEL, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
174 coeff[0] = coeff[1] = level * LEVEL_6DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
175 return 3;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
176
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
177 case CONVERT (A52_STEREO, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
178 coeff[0] = coeff[1] = level * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
179 return 3;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
180
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
181 case CONVERT (A52_3F, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
182 coeff[0] = coeff[2] = level * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
183 coeff[1] = level * clev * LEVEL_PLUS3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
184 return 7;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
185
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
186 case CONVERT (A52_2F1R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
187 coeff[0] = coeff[1] = level * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
188 coeff[2] = level * slev * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
189 return 7;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
190
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
191 case CONVERT (A52_2F2R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
192 coeff[0] = coeff[1] = level * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
193 coeff[2] = coeff[3] = level * slev * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
194 return 15;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
195
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
196 case CONVERT (A52_3F1R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
197 coeff[0] = coeff[2] = level * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
198 coeff[1] = level * clev * LEVEL_PLUS3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
199 coeff[3] = level * slev * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
200 return 15;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
201
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
202 case CONVERT (A52_3F2R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
203 coeff[0] = coeff[2] = level * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
204 coeff[1] = level * clev * LEVEL_PLUS3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
205 coeff[3] = coeff[4] = level * slev * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
206 return 31;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
207
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
208 case CONVERT (A52_MONO, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
209 coeff[0] = level * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
210 return 0;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
211
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
212 case CONVERT (A52_3F, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
213 clev = LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
214 case CONVERT (A52_3F, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
215 case CONVERT (A52_3F1R, A52_2F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
216 case CONVERT (A52_3F2R, A52_2F2R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
217 coeff[0] = coeff[2] = coeff[3] = coeff[4] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
218 coeff[1] = level * clev;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
219 return 7;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
220
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
221 case CONVERT (A52_2F1R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
222 slev = 1;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
223 case CONVERT (A52_2F1R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
224 coeff[0] = coeff[1] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
225 coeff[2] = level * slev * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
226 return 7;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
227
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
228 case CONVERT (A52_3F1R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
229 clev = LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
230 slev = 1;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
231 case CONVERT (A52_3F1R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
232 coeff[0] = coeff[2] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
233 coeff[1] = level * clev;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
234 coeff[3] = level * slev * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
235 return 15;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
236
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
237 case CONVERT (A52_2F2R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
238 slev = LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
239 case CONVERT (A52_2F2R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
240 coeff[0] = coeff[1] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
241 coeff[2] = coeff[3] = level * slev;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
242 return 15;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
243
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
244 case CONVERT (A52_3F2R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
245 clev = LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
246 case CONVERT (A52_3F2R, A52_2F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
247 slev = LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
248 case CONVERT (A52_3F2R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
249 coeff[0] = coeff[2] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
250 coeff[1] = level * clev;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
251 coeff[3] = coeff[4] = level * slev;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
252 return 31;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
253
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
254 case CONVERT (A52_3F1R, A52_3F):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
255 coeff[0] = coeff[1] = coeff[2] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
256 coeff[3] = level * slev * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
257 return 13;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
258
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
259 case CONVERT (A52_3F2R, A52_3F):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
260 coeff[0] = coeff[1] = coeff[2] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
261 coeff[3] = coeff[4] = level * slev;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
262 return 29;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
263
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
264 case CONVERT (A52_2F2R, A52_2F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
265 coeff[0] = coeff[1] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
266 coeff[2] = coeff[3] = level * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
267 return 12;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
268
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
269 case CONVERT (A52_3F2R, A52_3F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
270 coeff[0] = coeff[1] = coeff[2] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
271 coeff[3] = coeff[4] = level * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
272 return 24;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
273
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
274 case CONVERT (A52_2F1R, A52_2F2R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
275 coeff[0] = coeff[1] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
276 coeff[2] = level * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
277 return 0;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
278
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
279 case CONVERT (A52_3F1R, A52_2F2R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
280 coeff[0] = coeff[2] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
281 coeff[1] = level * clev;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
282 coeff[3] = level * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
283 return 7;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
284
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
285 case CONVERT (A52_3F1R, A52_3F2R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
286 coeff[0] = coeff[1] = coeff[2] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
287 coeff[3] = level * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
288 return 0;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
289
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
290 case CONVERT (A52_CHANNEL, A52_CHANNEL1):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
291 coeff[0] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
292 coeff[1] = 0;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
293 return 0;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
294
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
295 case CONVERT (A52_CHANNEL, A52_CHANNEL2):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
296 coeff[0] = 0;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
297 coeff[1] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
298 return 0;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
299 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
300
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
301 return -1; /* NOTREACHED */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
302 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
303
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
304 static void mix2to1 (sample_t * dest, sample_t * src, sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
305 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
306 int i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
307
3675
a6f4cce5001a mix2to1 in SSE
michael
parents: 3625
diff changeset
308 #ifdef HAVE_SSE
a6f4cce5001a mix2to1 in SSE
michael
parents: 3625
diff changeset
309 asm volatile(
a6f4cce5001a mix2to1 in SSE
michael
parents: 3625
diff changeset
310 "movlps %2, %%xmm7 \n\t"
a6f4cce5001a mix2to1 in SSE
michael
parents: 3625
diff changeset
311 "shufps $0x00, %%xmm7, %%xmm7 \n\t"
a6f4cce5001a mix2to1 in SSE
michael
parents: 3625
diff changeset
312 "movl $-1024, %%esi \n\t"
a6f4cce5001a mix2to1 in SSE
michael
parents: 3625
diff changeset
313 "1: \n\t"
a6f4cce5001a mix2to1 in SSE
michael
parents: 3625
diff changeset
314 "movaps (%0, %%esi), %%xmm0 \n\t"
a6f4cce5001a mix2to1 in SSE
michael
parents: 3625
diff changeset
315 "movaps 16(%0, %%esi), %%xmm1 \n\t"
a6f4cce5001a mix2to1 in SSE
michael
parents: 3625
diff changeset
316 "addps (%1, %%esi), %%xmm0 \n\t"
a6f4cce5001a mix2to1 in SSE
michael
parents: 3625
diff changeset
317 "addps 16(%1, %%esi), %%xmm1 \n\t"
a6f4cce5001a mix2to1 in SSE
michael
parents: 3625
diff changeset
318 "addps %%xmm7, %%xmm0 \n\t"
a6f4cce5001a mix2to1 in SSE
michael
parents: 3625
diff changeset
319 "addps %%xmm7, %%xmm1 \n\t"
a6f4cce5001a mix2to1 in SSE
michael
parents: 3625
diff changeset
320 "movaps %%xmm0, (%1, %%esi) \n\t"
a6f4cce5001a mix2to1 in SSE
michael
parents: 3625
diff changeset
321 "movaps %%xmm1, 16(%1, %%esi) \n\t"
a6f4cce5001a mix2to1 in SSE
michael
parents: 3625
diff changeset
322 "addl $32, %%esi \n\t"
a6f4cce5001a mix2to1 in SSE
michael
parents: 3625
diff changeset
323 " jnz 1b \n\t"
a6f4cce5001a mix2to1 in SSE
michael
parents: 3625
diff changeset
324 :: "r" (src+256), "r" (dest+256), "m" (bias)
a6f4cce5001a mix2to1 in SSE
michael
parents: 3625
diff changeset
325 : "%esi"
a6f4cce5001a mix2to1 in SSE
michael
parents: 3625
diff changeset
326 );
a6f4cce5001a mix2to1 in SSE
michael
parents: 3625
diff changeset
327 #else
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
328 for (i = 0; i < 256; i++)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
329 dest[i] += src[i] + bias;
3675
a6f4cce5001a mix2to1 in SSE
michael
parents: 3625
diff changeset
330 #endif
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
331 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
332
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
333 static void mix3to1 (sample_t * samples, sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
334 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
335 int i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
336
3679
f74f4524de6a mix3to1 in SSE
michael
parents: 3678
diff changeset
337 #ifdef HAVE_SSE
f74f4524de6a mix3to1 in SSE
michael
parents: 3678
diff changeset
338 asm volatile(
f74f4524de6a mix3to1 in SSE
michael
parents: 3678
diff changeset
339 "movlps %1, %%xmm7 \n\t"
f74f4524de6a mix3to1 in SSE
michael
parents: 3678
diff changeset
340 "shufps $0x00, %%xmm7, %%xmm7 \n\t"
f74f4524de6a mix3to1 in SSE
michael
parents: 3678
diff changeset
341 "movl $-1024, %%esi \n\t"
f74f4524de6a mix3to1 in SSE
michael
parents: 3678
diff changeset
342 "1: \n\t"
f74f4524de6a mix3to1 in SSE
michael
parents: 3678
diff changeset
343 "movaps (%0, %%esi), %%xmm0 \n\t"
f74f4524de6a mix3to1 in SSE
michael
parents: 3678
diff changeset
344 "movaps 1024(%0, %%esi), %%xmm1 \n\t"
f74f4524de6a mix3to1 in SSE
michael
parents: 3678
diff changeset
345 "addps 2048(%0, %%esi), %%xmm0 \n\t"
f74f4524de6a mix3to1 in SSE
michael
parents: 3678
diff changeset
346 "addps %%xmm7, %%xmm1 \n\t"
f74f4524de6a mix3to1 in SSE
michael
parents: 3678
diff changeset
347 "addps %%xmm1, %%xmm0 \n\t"
f74f4524de6a mix3to1 in SSE
michael
parents: 3678
diff changeset
348 "movaps %%xmm0, (%0, %%esi) \n\t"
f74f4524de6a mix3to1 in SSE
michael
parents: 3678
diff changeset
349 "addl $16, %%esi \n\t"
f74f4524de6a mix3to1 in SSE
michael
parents: 3678
diff changeset
350 " jnz 1b \n\t"
f74f4524de6a mix3to1 in SSE
michael
parents: 3678
diff changeset
351 :: "r" (samples+256), "m" (bias)
f74f4524de6a mix3to1 in SSE
michael
parents: 3678
diff changeset
352 : "%esi"
f74f4524de6a mix3to1 in SSE
michael
parents: 3678
diff changeset
353 );
f74f4524de6a mix3to1 in SSE
michael
parents: 3678
diff changeset
354 #else
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
355 for (i = 0; i < 256; i++)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
356 samples[i] += samples[i + 256] + samples[i + 512] + bias;
3679
f74f4524de6a mix3to1 in SSE
michael
parents: 3678
diff changeset
357 #endif
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
358 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
359
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
360 static void mix4to1 (sample_t * samples, sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
361 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
362 int i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
363
3679
f74f4524de6a mix3to1 in SSE
michael
parents: 3678
diff changeset
364 #ifdef HAVE_SSE
3677
2a36c3d11dbd mix5to1 & mix4to1 in SSE
michael
parents: 3675
diff changeset
365 asm volatile(
2a36c3d11dbd mix5to1 & mix4to1 in SSE
michael
parents: 3675
diff changeset
366 "movlps %1, %%xmm7 \n\t"
2a36c3d11dbd mix5to1 & mix4to1 in SSE
michael
parents: 3675
diff changeset
367 "shufps $0x00, %%xmm7, %%xmm7 \n\t"
2a36c3d11dbd mix5to1 & mix4to1 in SSE
michael
parents: 3675
diff changeset
368 "movl $-1024, %%esi \n\t"
2a36c3d11dbd mix5to1 & mix4to1 in SSE
michael
parents: 3675
diff changeset
369 "1: \n\t"
2a36c3d11dbd mix5to1 & mix4to1 in SSE
michael
parents: 3675
diff changeset
370 "movaps (%0, %%esi), %%xmm0 \n\t"
2a36c3d11dbd mix5to1 & mix4to1 in SSE
michael
parents: 3675
diff changeset
371 "movaps 1024(%0, %%esi), %%xmm1 \n\t"
2a36c3d11dbd mix5to1 & mix4to1 in SSE
michael
parents: 3675
diff changeset
372 "addps 2048(%0, %%esi), %%xmm0 \n\t"
2a36c3d11dbd mix5to1 & mix4to1 in SSE
michael
parents: 3675
diff changeset
373 "addps 3072(%0, %%esi), %%xmm1 \n\t"
2a36c3d11dbd mix5to1 & mix4to1 in SSE
michael
parents: 3675
diff changeset
374 "addps %%xmm7, %%xmm0 \n\t"
2a36c3d11dbd mix5to1 & mix4to1 in SSE
michael
parents: 3675
diff changeset
375 "addps %%xmm1, %%xmm0 \n\t"
2a36c3d11dbd mix5to1 & mix4to1 in SSE
michael
parents: 3675
diff changeset
376 "movaps %%xmm0, (%0, %%esi) \n\t"
2a36c3d11dbd mix5to1 & mix4to1 in SSE
michael
parents: 3675
diff changeset
377 "addl $16, %%esi \n\t"
2a36c3d11dbd mix5to1 & mix4to1 in SSE
michael
parents: 3675
diff changeset
378 " jnz 1b \n\t"
2a36c3d11dbd mix5to1 & mix4to1 in SSE
michael
parents: 3675
diff changeset
379 :: "r" (samples+256), "m" (bias)
2a36c3d11dbd mix5to1 & mix4to1 in SSE
michael
parents: 3675
diff changeset
380 : "%esi"
2a36c3d11dbd mix5to1 & mix4to1 in SSE
michael
parents: 3675
diff changeset
381 );
2a36c3d11dbd mix5to1 & mix4to1 in SSE
michael
parents: 3675
diff changeset
382 #else
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
383 for (i = 0; i < 256; i++)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
384 samples[i] += (samples[i + 256] + samples[i + 512] +
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
385 samples[i + 768] + bias);
3677
2a36c3d11dbd mix5to1 & mix4to1 in SSE
michael
parents: 3675
diff changeset
386 #endif
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
387 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
388
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
389 static void mix5to1 (sample_t * samples, sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
390 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
391 int i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
392
3677
2a36c3d11dbd mix5to1 & mix4to1 in SSE
michael
parents: 3675
diff changeset
393 #ifdef HAVE_SSE
2a36c3d11dbd mix5to1 & mix4to1 in SSE
michael
parents: 3675
diff changeset
394 asm volatile(
2a36c3d11dbd mix5to1 & mix4to1 in SSE
michael
parents: 3675
diff changeset
395 "movlps %1, %%xmm7 \n\t"
2a36c3d11dbd mix5to1 & mix4to1 in SSE
michael
parents: 3675
diff changeset
396 "shufps $0x00, %%xmm7, %%xmm7 \n\t"
2a36c3d11dbd mix5to1 & mix4to1 in SSE
michael
parents: 3675
diff changeset
397 "movl $-1024, %%esi \n\t"
2a36c3d11dbd mix5to1 & mix4to1 in SSE
michael
parents: 3675
diff changeset
398 "1: \n\t"
2a36c3d11dbd mix5to1 & mix4to1 in SSE
michael
parents: 3675
diff changeset
399 "movaps (%0, %%esi), %%xmm0 \n\t"
2a36c3d11dbd mix5to1 & mix4to1 in SSE
michael
parents: 3675
diff changeset
400 "movaps 1024(%0, %%esi), %%xmm1 \n\t"
2a36c3d11dbd mix5to1 & mix4to1 in SSE
michael
parents: 3675
diff changeset
401 "addps 2048(%0, %%esi), %%xmm0 \n\t"
2a36c3d11dbd mix5to1 & mix4to1 in SSE
michael
parents: 3675
diff changeset
402 "addps 3072(%0, %%esi), %%xmm1 \n\t"
2a36c3d11dbd mix5to1 & mix4to1 in SSE
michael
parents: 3675
diff changeset
403 "addps %%xmm7, %%xmm0 \n\t"
2a36c3d11dbd mix5to1 & mix4to1 in SSE
michael
parents: 3675
diff changeset
404 "addps 4096(%0, %%esi), %%xmm1 \n\t"
2a36c3d11dbd mix5to1 & mix4to1 in SSE
michael
parents: 3675
diff changeset
405 "addps %%xmm1, %%xmm0 \n\t"
2a36c3d11dbd mix5to1 & mix4to1 in SSE
michael
parents: 3675
diff changeset
406 "movaps %%xmm0, (%0, %%esi) \n\t"
2a36c3d11dbd mix5to1 & mix4to1 in SSE
michael
parents: 3675
diff changeset
407 "addl $16, %%esi \n\t"
2a36c3d11dbd mix5to1 & mix4to1 in SSE
michael
parents: 3675
diff changeset
408 " jnz 1b \n\t"
2a36c3d11dbd mix5to1 & mix4to1 in SSE
michael
parents: 3675
diff changeset
409 :: "r" (samples+256), "m" (bias)
2a36c3d11dbd mix5to1 & mix4to1 in SSE
michael
parents: 3675
diff changeset
410 : "%esi"
2a36c3d11dbd mix5to1 & mix4to1 in SSE
michael
parents: 3675
diff changeset
411 );
2a36c3d11dbd mix5to1 & mix4to1 in SSE
michael
parents: 3675
diff changeset
412 #else
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
413 for (i = 0; i < 256; i++)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
414 samples[i] += (samples[i + 256] + samples[i + 512] +
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
415 samples[i + 768] + samples[i + 1024] + bias);
3677
2a36c3d11dbd mix5to1 & mix4to1 in SSE
michael
parents: 3675
diff changeset
416 #endif
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
417 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
418
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
419 static void mix3to2 (sample_t * samples, sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
420 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
421 int i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
422 sample_t common;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
423
3678
265680bbdcfd mix3to2 in SSE
michael
parents: 3677
diff changeset
424 #ifdef HAVE_SSE
265680bbdcfd mix3to2 in SSE
michael
parents: 3677
diff changeset
425 asm volatile(
265680bbdcfd mix3to2 in SSE
michael
parents: 3677
diff changeset
426 "movlps %1, %%xmm7 \n\t"
265680bbdcfd mix3to2 in SSE
michael
parents: 3677
diff changeset
427 "shufps $0x00, %%xmm7, %%xmm7 \n\t"
265680bbdcfd mix3to2 in SSE
michael
parents: 3677
diff changeset
428 "movl $-1024, %%esi \n\t"
265680bbdcfd mix3to2 in SSE
michael
parents: 3677
diff changeset
429 "1: \n\t"
265680bbdcfd mix3to2 in SSE
michael
parents: 3677
diff changeset
430 "movaps 1024(%0, %%esi), %%xmm0 \n\t"
265680bbdcfd mix3to2 in SSE
michael
parents: 3677
diff changeset
431 "addps %%xmm7, %%xmm0 \n\t" //common
265680bbdcfd mix3to2 in SSE
michael
parents: 3677
diff changeset
432 "movaps (%0, %%esi), %%xmm1 \n\t"
265680bbdcfd mix3to2 in SSE
michael
parents: 3677
diff changeset
433 "movaps 2048(%0, %%esi), %%xmm2 \n\t"
265680bbdcfd mix3to2 in SSE
michael
parents: 3677
diff changeset
434 "addps %%xmm0, %%xmm1 \n\t"
265680bbdcfd mix3to2 in SSE
michael
parents: 3677
diff changeset
435 "addps %%xmm0, %%xmm2 \n\t"
265680bbdcfd mix3to2 in SSE
michael
parents: 3677
diff changeset
436 "movaps %%xmm1, (%0, %%esi) \n\t"
265680bbdcfd mix3to2 in SSE
michael
parents: 3677
diff changeset
437 "movaps %%xmm2, 1024(%0, %%esi) \n\t"
265680bbdcfd mix3to2 in SSE
michael
parents: 3677
diff changeset
438 "addl $16, %%esi \n\t"
265680bbdcfd mix3to2 in SSE
michael
parents: 3677
diff changeset
439 " jnz 1b \n\t"
265680bbdcfd mix3to2 in SSE
michael
parents: 3677
diff changeset
440 :: "r" (samples+256), "m" (bias)
265680bbdcfd mix3to2 in SSE
michael
parents: 3677
diff changeset
441 : "%esi"
265680bbdcfd mix3to2 in SSE
michael
parents: 3677
diff changeset
442 );
265680bbdcfd mix3to2 in SSE
michael
parents: 3677
diff changeset
443 #else
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
444 for (i = 0; i < 256; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
445 common = samples[i + 256] + bias;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
446 samples[i] += common;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
447 samples[i + 256] = samples[i + 512] + common;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
448 }
3678
265680bbdcfd mix3to2 in SSE
michael
parents: 3677
diff changeset
449 #endif
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
450 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
451
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
452 static void mix21to2 (sample_t * left, sample_t * right, sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
453 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
454 int i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
455 sample_t common;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
456
3739
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
457 #ifdef HAVE_SSE
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
458 asm volatile(
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
459 "movlps %2, %%xmm7 \n\t"
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
460 "shufps $0x00, %%xmm7, %%xmm7 \n\t"
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
461 "movl $-1024, %%esi \n\t"
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
462 "1: \n\t"
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
463 "movaps 1024(%1, %%esi), %%xmm0 \n\t"
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
464 "addps %%xmm7, %%xmm0 \n\t" //common
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
465 "movaps (%0, %%esi), %%xmm1 \n\t"
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
466 "movaps (%1, %%esi), %%xmm2 \n\t"
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
467 "addps %%xmm0, %%xmm1 \n\t"
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
468 "addps %%xmm0, %%xmm2 \n\t"
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
469 "movaps %%xmm1, (%0, %%esi) \n\t"
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
470 "movaps %%xmm2, (%1, %%esi) \n\t"
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
471 "addl $16, %%esi \n\t"
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
472 " jnz 1b \n\t"
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
473 :: "r" (left+256), "r" (right+256), "m" (bias)
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
474 : "%esi"
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
475 );
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
476 #else
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
477 for (i = 0; i < 256; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
478 common = right[i + 256] + bias;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
479 left[i] += common;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
480 right[i] += common;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
481 }
3739
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
482 #endif
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
483 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
484
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
485 static void mix21toS (sample_t * samples, sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
486 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
487 int i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
488 sample_t surround;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
489
3739
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
490 #ifdef HAVE_SSE
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
491 asm volatile(
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
492 "movlps %1, %%xmm7 \n\t"
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
493 "shufps $0x00, %%xmm7, %%xmm7 \n\t"
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
494 "movl $-1024, %%esi \n\t"
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
495 "1: \n\t"
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
496 "movaps 2048(%0, %%esi), %%xmm0 \n\t" // surround
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
497 "movaps (%0, %%esi), %%xmm1 \n\t"
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
498 "movaps 1024(%0, %%esi), %%xmm2 \n\t"
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
499 "addps %%xmm7, %%xmm1 \n\t"
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
500 "addps %%xmm7, %%xmm2 \n\t"
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
501 "subps %%xmm0, %%xmm1 \n\t"
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
502 "addps %%xmm0, %%xmm2 \n\t"
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
503 "movaps %%xmm1, (%0, %%esi) \n\t"
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
504 "movaps %%xmm2, 1024(%0, %%esi) \n\t"
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
505 "addl $16, %%esi \n\t"
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
506 " jnz 1b \n\t"
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
507 :: "r" (samples+256), "m" (bias)
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
508 : "%esi"
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
509 );
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
510 #else
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
511 for (i = 0; i < 256; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
512 surround = samples[i + 512];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
513 samples[i] += bias - surround;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
514 samples[i + 256] += bias + surround;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
515 }
3739
b6040dbc751a mix21to2 & mix21toS in SSE
michael
parents: 3738
diff changeset
516 #endif
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
517 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
518
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
519 static void mix31to2 (sample_t * samples, sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
520 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
521 int i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
522 sample_t common;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
523
3740
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
524 #ifdef HAVE_SSE
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
525 asm volatile(
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
526 "movlps %1, %%xmm7 \n\t"
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
527 "shufps $0x00, %%xmm7, %%xmm7 \n\t"
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
528 "movl $-1024, %%esi \n\t"
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
529 "1: \n\t"
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
530 "movaps 1024(%0, %%esi), %%xmm0 \n\t"
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
531 "addps 3072(%0, %%esi), %%xmm0 \n\t"
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
532 "addps %%xmm7, %%xmm0 \n\t" // common
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
533 "movaps (%0, %%esi), %%xmm1 \n\t"
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
534 "movaps 2048(%0, %%esi), %%xmm2 \n\t"
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
535 "addps %%xmm0, %%xmm1 \n\t"
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
536 "addps %%xmm0, %%xmm2 \n\t"
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
537 "movaps %%xmm1, (%0, %%esi) \n\t"
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
538 "movaps %%xmm2, 1024(%0, %%esi) \n\t"
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
539 "addl $16, %%esi \n\t"
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
540 " jnz 1b \n\t"
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
541 :: "r" (samples+256), "m" (bias)
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
542 : "%esi"
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
543 );
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
544 #else
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
545 for (i = 0; i < 256; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
546 common = samples[i + 256] + samples[i + 768] + bias;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
547 samples[i] += common;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
548 samples[i + 256] = samples[i + 512] + common;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
549 }
3740
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
550 #endif
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
551 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
552
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
553 static void mix31toS (sample_t * samples, sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
554 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
555 int i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
556 sample_t common, surround;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
557
3740
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
558 #ifdef HAVE_SSE
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
559 asm volatile(
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
560 "movlps %1, %%xmm7 \n\t"
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
561 "shufps $0x00, %%xmm7, %%xmm7 \n\t"
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
562 "movl $-1024, %%esi \n\t"
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
563 "1: \n\t"
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
564 "movaps 1024(%0, %%esi), %%xmm0 \n\t"
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
565 "movaps 3072(%0, %%esi), %%xmm3 \n\t" // surround
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
566 "addps %%xmm7, %%xmm0 \n\t" // common
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
567 "movaps (%0, %%esi), %%xmm1 \n\t"
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
568 "movaps 2048(%0, %%esi), %%xmm2 \n\t"
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
569 "addps %%xmm0, %%xmm1 \n\t"
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
570 "addps %%xmm0, %%xmm2 \n\t"
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
571 "subps %%xmm3, %%xmm1 \n\t"
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
572 "addps %%xmm3, %%xmm2 \n\t"
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
573 "movaps %%xmm1, (%0, %%esi) \n\t"
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
574 "movaps %%xmm2, 1024(%0, %%esi) \n\t"
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
575 "addl $16, %%esi \n\t"
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
576 " jnz 1b \n\t"
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
577 :: "r" (samples+256), "m" (bias)
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
578 : "%esi"
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
579 );
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
580 #else
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
581 for (i = 0; i < 256; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
582 common = samples[i + 256] + bias;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
583 surround = samples[i + 768];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
584 samples[i] += common - surround;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
585 samples[i + 256] = samples[i + 512] + common + surround;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
586 }
3740
dcbdad3fc5cd mix31to2 & mix31toS in SSE
michael
parents: 3739
diff changeset
587 #endif
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
588 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
589
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
590 static void mix22toS (sample_t * samples, sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
591 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
592 int i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
593 sample_t surround;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
594
3741
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
595 #ifdef HAVE_SSE
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
596 asm volatile(
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
597 "movlps %1, %%xmm7 \n\t"
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
598 "shufps $0x00, %%xmm7, %%xmm7 \n\t"
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
599 "movl $-1024, %%esi \n\t"
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
600 "1: \n\t"
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
601 "movaps 2048(%0, %%esi), %%xmm0 \n\t"
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
602 "addps 3072(%0, %%esi), %%xmm0 \n\t" // surround
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
603 "movaps (%0, %%esi), %%xmm1 \n\t"
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
604 "movaps 1024(%0, %%esi), %%xmm2 \n\t"
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
605 "addps %%xmm7, %%xmm1 \n\t"
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
606 "addps %%xmm7, %%xmm2 \n\t"
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
607 "subps %%xmm0, %%xmm1 \n\t"
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
608 "addps %%xmm0, %%xmm2 \n\t"
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
609 "movaps %%xmm1, (%0, %%esi) \n\t"
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
610 "movaps %%xmm2, 1024(%0, %%esi) \n\t"
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
611 "addl $16, %%esi \n\t"
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
612 " jnz 1b \n\t"
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
613 :: "r" (samples+256), "m" (bias)
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
614 : "%esi"
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
615 );
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
616 #else
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
617 for (i = 0; i < 256; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
618 surround = samples[i + 512] + samples[i + 768];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
619 samples[i] += bias - surround;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
620 samples[i + 256] += bias + surround;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
621 }
3741
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
622 #endif
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
623 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
624
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
625 static void mix32to2 (sample_t * samples, sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
626 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
627 int i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
628 sample_t common;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
629
3624
0e4ff1cac6a2 sse opt of mix32to2()
michael
parents: 3394
diff changeset
630 #ifdef HAVE_SSE
0e4ff1cac6a2 sse opt of mix32to2()
michael
parents: 3394
diff changeset
631 asm volatile(
0e4ff1cac6a2 sse opt of mix32to2()
michael
parents: 3394
diff changeset
632 "movlps %1, %%xmm7 \n\t"
0e4ff1cac6a2 sse opt of mix32to2()
michael
parents: 3394
diff changeset
633 "shufps $0x00, %%xmm7, %%xmm7 \n\t"
0e4ff1cac6a2 sse opt of mix32to2()
michael
parents: 3394
diff changeset
634 "movl $-1024, %%esi \n\t"
0e4ff1cac6a2 sse opt of mix32to2()
michael
parents: 3394
diff changeset
635 "1: \n\t"
0e4ff1cac6a2 sse opt of mix32to2()
michael
parents: 3394
diff changeset
636 "movaps 1024(%0, %%esi), %%xmm0 \n\t"
0e4ff1cac6a2 sse opt of mix32to2()
michael
parents: 3394
diff changeset
637 "addps %%xmm7, %%xmm0 \n\t" // common
0e4ff1cac6a2 sse opt of mix32to2()
michael
parents: 3394
diff changeset
638 "movaps %%xmm0, %%xmm1 \n\t" // common
0e4ff1cac6a2 sse opt of mix32to2()
michael
parents: 3394
diff changeset
639 "addps (%0, %%esi), %%xmm0 \n\t"
0e4ff1cac6a2 sse opt of mix32to2()
michael
parents: 3394
diff changeset
640 "addps 2048(%0, %%esi), %%xmm1 \n\t"
0e4ff1cac6a2 sse opt of mix32to2()
michael
parents: 3394
diff changeset
641 "addps 3072(%0, %%esi), %%xmm0 \n\t"
0e4ff1cac6a2 sse opt of mix32to2()
michael
parents: 3394
diff changeset
642 "addps 4096(%0, %%esi), %%xmm1 \n\t"
0e4ff1cac6a2 sse opt of mix32to2()
michael
parents: 3394
diff changeset
643 "movaps %%xmm0, (%0, %%esi) \n\t"
0e4ff1cac6a2 sse opt of mix32to2()
michael
parents: 3394
diff changeset
644 "movaps %%xmm1, 1024(%0, %%esi) \n\t"
0e4ff1cac6a2 sse opt of mix32to2()
michael
parents: 3394
diff changeset
645 "addl $16, %%esi \n\t"
0e4ff1cac6a2 sse opt of mix32to2()
michael
parents: 3394
diff changeset
646 " jnz 1b \n\t"
0e4ff1cac6a2 sse opt of mix32to2()
michael
parents: 3394
diff changeset
647 :: "r" (samples+256), "m" (bias)
0e4ff1cac6a2 sse opt of mix32to2()
michael
parents: 3394
diff changeset
648 : "%esi"
0e4ff1cac6a2 sse opt of mix32to2()
michael
parents: 3394
diff changeset
649 );
0e4ff1cac6a2 sse opt of mix32to2()
michael
parents: 3394
diff changeset
650 #else
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
651 for (i = 0; i < 256; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
652 common = samples[i + 256] + bias;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
653 samples[i] += common + samples[i + 768];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
654 samples[i + 256] = common + samples[i + 512] + samples[i + 1024];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
655 }
3624
0e4ff1cac6a2 sse opt of mix32to2()
michael
parents: 3394
diff changeset
656 #endif
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
657 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
658
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
659 static void mix32toS (sample_t * samples, sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
660 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
661 int i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
662 sample_t common, surround;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
663
3625
84ff13d4540c sse opt of mix32toS()
michael
parents: 3624
diff changeset
664 #ifdef HAVE_SSE
84ff13d4540c sse opt of mix32toS()
michael
parents: 3624
diff changeset
665 asm volatile(
84ff13d4540c sse opt of mix32toS()
michael
parents: 3624
diff changeset
666 "movlps %1, %%xmm7 \n\t"
84ff13d4540c sse opt of mix32toS()
michael
parents: 3624
diff changeset
667 "shufps $0x00, %%xmm7, %%xmm7 \n\t"
84ff13d4540c sse opt of mix32toS()
michael
parents: 3624
diff changeset
668 "movl $-1024, %%esi \n\t"
84ff13d4540c sse opt of mix32toS()
michael
parents: 3624
diff changeset
669 "1: \n\t"
84ff13d4540c sse opt of mix32toS()
michael
parents: 3624
diff changeset
670 "movaps 1024(%0, %%esi), %%xmm0 \n\t"
84ff13d4540c sse opt of mix32toS()
michael
parents: 3624
diff changeset
671 "movaps 3072(%0, %%esi), %%xmm2 \n\t"
84ff13d4540c sse opt of mix32toS()
michael
parents: 3624
diff changeset
672 "addps %%xmm7, %%xmm0 \n\t" // common
84ff13d4540c sse opt of mix32toS()
michael
parents: 3624
diff changeset
673 "addps 4096(%0, %%esi), %%xmm2 \n\t" // surround
84ff13d4540c sse opt of mix32toS()
michael
parents: 3624
diff changeset
674 "movaps (%0, %%esi), %%xmm1 \n\t"
84ff13d4540c sse opt of mix32toS()
michael
parents: 3624
diff changeset
675 "movaps 2048(%0, %%esi), %%xmm3 \n\t"
84ff13d4540c sse opt of mix32toS()
michael
parents: 3624
diff changeset
676 "subps %%xmm2, %%xmm1 \n\t"
84ff13d4540c sse opt of mix32toS()
michael
parents: 3624
diff changeset
677 "addps %%xmm2, %%xmm3 \n\t"
84ff13d4540c sse opt of mix32toS()
michael
parents: 3624
diff changeset
678 "addps %%xmm0, %%xmm1 \n\t"
84ff13d4540c sse opt of mix32toS()
michael
parents: 3624
diff changeset
679 "addps %%xmm0, %%xmm3 \n\t"
84ff13d4540c sse opt of mix32toS()
michael
parents: 3624
diff changeset
680 "movaps %%xmm1, (%0, %%esi) \n\t"
84ff13d4540c sse opt of mix32toS()
michael
parents: 3624
diff changeset
681 "movaps %%xmm3, 1024(%0, %%esi) \n\t"
84ff13d4540c sse opt of mix32toS()
michael
parents: 3624
diff changeset
682 "addl $16, %%esi \n\t"
84ff13d4540c sse opt of mix32toS()
michael
parents: 3624
diff changeset
683 " jnz 1b \n\t"
84ff13d4540c sse opt of mix32toS()
michael
parents: 3624
diff changeset
684 :: "r" (samples+256), "m" (bias)
84ff13d4540c sse opt of mix32toS()
michael
parents: 3624
diff changeset
685 : "%esi"
84ff13d4540c sse opt of mix32toS()
michael
parents: 3624
diff changeset
686 );
84ff13d4540c sse opt of mix32toS()
michael
parents: 3624
diff changeset
687 #else
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
688 for (i = 0; i < 256; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
689 common = samples[i + 256] + bias;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
690 surround = samples[i + 768] + samples[i + 1024];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
691 samples[i] += common - surround;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
692 samples[i + 256] = samples[i + 512] + common + surround;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
693 }
3625
84ff13d4540c sse opt of mix32toS()
michael
parents: 3624
diff changeset
694 #endif
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
695 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
696
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
697 static void move2to1 (sample_t * src, sample_t * dest, sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
698 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
699 int i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
700
3741
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
701 #ifdef HAVE_SSE
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
702 asm volatile(
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
703 "movlps %2, %%xmm7 \n\t"
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
704 "shufps $0x00, %%xmm7, %%xmm7 \n\t"
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
705 "movl $-1024, %%esi \n\t"
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
706 "1: \n\t"
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
707 "movaps (%0, %%esi), %%xmm0 \n\t"
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
708 "movaps 16(%0, %%esi), %%xmm1 \n\t"
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
709 "addps 1024(%0, %%esi), %%xmm0 \n\t"
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
710 "addps 1040(%0, %%esi), %%xmm1 \n\t"
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
711 "addps %%xmm7, %%xmm0 \n\t"
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
712 "addps %%xmm7, %%xmm1 \n\t"
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
713 "movaps %%xmm0, (%1, %%esi) \n\t"
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
714 "movaps %%xmm1, 16(%1, %%esi) \n\t"
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
715 "addl $32, %%esi \n\t"
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
716 " jnz 1b \n\t"
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
717 :: "r" (src+256), "r" (dest+256), "m" (bias)
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
718 : "%esi"
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
719 );
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
720 #else
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
721 for (i = 0; i < 256; i++)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
722 dest[i] = src[i] + src[i + 256] + bias;
3741
99ac808d97c0 mix22toS & move2to1 in SSE
michael
parents: 3740
diff changeset
723 #endif
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
724 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
725
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
726 static void zero (sample_t * samples)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
727 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
728 int i;
3738
5c1da9bc17a3 memset(?, 0, 256*sizeof(float)) in MMX
michael
parents: 3679
diff changeset
729 #ifdef HAVE_MMX
5c1da9bc17a3 memset(?, 0, 256*sizeof(float)) in MMX
michael
parents: 3679
diff changeset
730 asm volatile(
5c1da9bc17a3 memset(?, 0, 256*sizeof(float)) in MMX
michael
parents: 3679
diff changeset
731 "movl $-1024, %%esi \n\t"
5c1da9bc17a3 memset(?, 0, 256*sizeof(float)) in MMX
michael
parents: 3679
diff changeset
732 "pxor %%mm0, %%mm0 \n\t"
5c1da9bc17a3 memset(?, 0, 256*sizeof(float)) in MMX
michael
parents: 3679
diff changeset
733 "1: \n\t"
5c1da9bc17a3 memset(?, 0, 256*sizeof(float)) in MMX
michael
parents: 3679
diff changeset
734 "movq %%mm0, (%0, %%esi) \n\t"
5c1da9bc17a3 memset(?, 0, 256*sizeof(float)) in MMX
michael
parents: 3679
diff changeset
735 "movq %%mm0, 8(%0, %%esi) \n\t"
5c1da9bc17a3 memset(?, 0, 256*sizeof(float)) in MMX
michael
parents: 3679
diff changeset
736 "movq %%mm0, 16(%0, %%esi) \n\t"
5c1da9bc17a3 memset(?, 0, 256*sizeof(float)) in MMX
michael
parents: 3679
diff changeset
737 "movq %%mm0, 24(%0, %%esi) \n\t"
5c1da9bc17a3 memset(?, 0, 256*sizeof(float)) in MMX
michael
parents: 3679
diff changeset
738 "addl $32, %%esi \n\t"
5c1da9bc17a3 memset(?, 0, 256*sizeof(float)) in MMX
michael
parents: 3679
diff changeset
739 " jnz 1b \n\t"
5c1da9bc17a3 memset(?, 0, 256*sizeof(float)) in MMX
michael
parents: 3679
diff changeset
740 "emms"
5c1da9bc17a3 memset(?, 0, 256*sizeof(float)) in MMX
michael
parents: 3679
diff changeset
741 :: "r" (samples+256)
5c1da9bc17a3 memset(?, 0, 256*sizeof(float)) in MMX
michael
parents: 3679
diff changeset
742 : "%esi"
5c1da9bc17a3 memset(?, 0, 256*sizeof(float)) in MMX
michael
parents: 3679
diff changeset
743 );
5c1da9bc17a3 memset(?, 0, 256*sizeof(float)) in MMX
michael
parents: 3679
diff changeset
744 #else
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
745 for (i = 0; i < 256; i++)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
746 samples[i] = 0;
3738
5c1da9bc17a3 memset(?, 0, 256*sizeof(float)) in MMX
michael
parents: 3679
diff changeset
747 #endif
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
748 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
749
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
750 void downmix (sample_t * samples, int acmod, int output, sample_t bias,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
751 sample_t clev, sample_t slev)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
752 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
753 switch (CONVERT (acmod, output & A52_CHANNEL_MASK)) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
754
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
755 case CONVERT (A52_CHANNEL, A52_CHANNEL2):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
756 memcpy (samples, samples + 256, 256 * sizeof (sample_t));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
757 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
758
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
759 case CONVERT (A52_CHANNEL, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
760 case CONVERT (A52_STEREO, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
761 mix_2to1:
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
762 mix2to1 (samples, samples + 256, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
763 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
764
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
765 case CONVERT (A52_2F1R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
766 if (slev == 0)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
767 goto mix_2to1;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
768 case CONVERT (A52_3F, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
769 mix_3to1:
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
770 mix3to1 (samples, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
771 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
772
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
773 case CONVERT (A52_3F1R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
774 if (slev == 0)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
775 goto mix_3to1;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
776 case CONVERT (A52_2F2R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
777 if (slev == 0)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
778 goto mix_2to1;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
779 mix4to1 (samples, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
780 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
781
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
782 case CONVERT (A52_3F2R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
783 if (slev == 0)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
784 goto mix_3to1;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
785 mix5to1 (samples, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
786 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
787
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
788 case CONVERT (A52_MONO, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
789 memcpy (samples + 256, samples, 256 * sizeof (sample_t));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
790 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
791
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
792 case CONVERT (A52_3F, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
793 case CONVERT (A52_3F, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
794 mix_3to2:
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
795 mix3to2 (samples, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
796 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
797
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
798 case CONVERT (A52_2F1R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
799 if (slev == 0)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
800 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
801 mix21to2 (samples, samples + 256, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
802 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
803
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
804 case CONVERT (A52_2F1R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
805 mix21toS (samples, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
806 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
807
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
808 case CONVERT (A52_3F1R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
809 if (slev == 0)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
810 goto mix_3to2;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
811 mix31to2 (samples, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
812 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
813
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
814 case CONVERT (A52_3F1R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
815 mix31toS (samples, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
816 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
817
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
818 case CONVERT (A52_2F2R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
819 if (slev == 0)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
820 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
821 mix2to1 (samples, samples + 512, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
822 mix2to1 (samples + 256, samples + 768, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
823 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
824
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
825 case CONVERT (A52_2F2R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
826 mix22toS (samples, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
827 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
828
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
829 case CONVERT (A52_3F2R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
830 if (slev == 0)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
831 goto mix_3to2;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
832 mix32to2 (samples, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
833 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
834
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
835 case CONVERT (A52_3F2R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
836 mix32toS (samples, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
837 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
838
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
839 case CONVERT (A52_3F1R, A52_3F):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
840 if (slev == 0)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
841 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
842 mix21to2 (samples, samples + 512, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
843 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
844
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
845 case CONVERT (A52_3F2R, A52_3F):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
846 if (slev == 0)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
847 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
848 mix2to1 (samples, samples + 768, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
849 mix2to1 (samples + 512, samples + 1024, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
850 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
851
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
852 case CONVERT (A52_3F1R, A52_2F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
853 mix3to2 (samples, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
854 memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
855 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
856
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
857 case CONVERT (A52_2F2R, A52_2F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
858 mix2to1 (samples + 512, samples + 768, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
859 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
860
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
861 case CONVERT (A52_3F2R, A52_2F1R):
3678
265680bbdcfd mix3to2 in SSE
michael
parents: 3677
diff changeset
862 mix3to2 (samples, bias); //FIXME possible bug? (output doesnt seem to be used)
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
863 move2to1 (samples + 768, samples + 512, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
864 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
865
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
866 case CONVERT (A52_3F2R, A52_3F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
867 mix2to1 (samples + 768, samples + 1024, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
868 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
869
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
870 case CONVERT (A52_2F1R, A52_2F2R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
871 memcpy (samples + 768, samples + 512, 256 * sizeof (sample_t));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
872 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
873
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
874 case CONVERT (A52_3F1R, A52_2F2R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
875 mix3to2 (samples, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
876 memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
877 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
878
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
879 case CONVERT (A52_3F2R, A52_2F2R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
880 mix3to2 (samples, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
881 memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
882 memcpy (samples + 768, samples + 1024, 256 * sizeof (sample_t));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
883 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
884
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
885 case CONVERT (A52_3F1R, A52_3F2R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
886 memcpy (samples + 1027, samples + 768, 256 * sizeof (sample_t));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
887 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
888 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
889 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
890
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
891 void upmix (sample_t * samples, int acmod, int output)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
892 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
893 switch (CONVERT (acmod, output & A52_CHANNEL_MASK)) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
894
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
895 case CONVERT (A52_CHANNEL, A52_CHANNEL2):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
896 memcpy (samples + 256, samples, 256 * sizeof (sample_t));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
897 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
898
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
899 case CONVERT (A52_3F2R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
900 zero (samples + 1024);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
901 case CONVERT (A52_3F1R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
902 case CONVERT (A52_2F2R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
903 zero (samples + 768);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
904 case CONVERT (A52_3F, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
905 case CONVERT (A52_2F1R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
906 zero (samples + 512);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
907 case CONVERT (A52_CHANNEL, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
908 case CONVERT (A52_STEREO, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
909 zero (samples + 256);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
910 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
911
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
912 case CONVERT (A52_3F2R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
913 case CONVERT (A52_3F2R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
914 zero (samples + 1024);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
915 case CONVERT (A52_3F1R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
916 case CONVERT (A52_3F1R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
917 zero (samples + 768);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
918 case CONVERT (A52_3F, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
919 case CONVERT (A52_3F, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
920 mix_3to2:
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
921 memcpy (samples + 512, samples + 256, 256 * sizeof (sample_t));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
922 zero (samples + 256);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
923 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
924
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
925 case CONVERT (A52_2F2R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
926 case CONVERT (A52_2F2R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
927 zero (samples + 768);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
928 case CONVERT (A52_2F1R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
929 case CONVERT (A52_2F1R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
930 zero (samples + 512);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
931 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
932
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
933 case CONVERT (A52_3F2R, A52_3F):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
934 zero (samples + 1024);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
935 case CONVERT (A52_3F1R, A52_3F):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
936 case CONVERT (A52_2F2R, A52_2F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
937 zero (samples + 768);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
938 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
939
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
940 case CONVERT (A52_3F2R, A52_3F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
941 zero (samples + 1024);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
942 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
943
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
944 case CONVERT (A52_3F2R, A52_2F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
945 zero (samples + 1024);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
946 case CONVERT (A52_3F1R, A52_2F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
947 mix_31to21:
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
948 memcpy (samples + 768, samples + 512, 256 * sizeof (sample_t));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
949 goto mix_3to2;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
950
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
951 case CONVERT (A52_3F2R, A52_2F2R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
952 memcpy (samples + 1024, samples + 768, 256 * sizeof (sample_t));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
953 goto mix_31to21;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
954 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
955 }