Mercurial > libavcodec.hg
annotate liba52/downmix.c @ 3798:6e7b9a44800c libavcodec
vorbis.h -> vorbis_data.c
move tables from vorbis.h to a C file so they can be used later in
vorbis_enc.c
author | ods15 |
---|---|
date | Sat, 30 Sep 2006 18:47:15 +0000 |
parents | 0b546eab515d |
children |
rev | line source |
---|---|
332 | 1 /* |
2 * downmix.c | |
1072 | 3 * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org> |
332 | 4 * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca> |
5 * | |
6 * This file is part of a52dec, a free ATSC A-52 stream decoder. | |
7 * See http://liba52.sourceforge.net/ for updates. | |
8 * | |
9 * a52dec is free software; you can redistribute it and/or modify | |
10 * it under the terms of the GNU General Public License as published by | |
11 * the Free Software Foundation; either version 2 of the License, or | |
12 * (at your option) any later version. | |
13 * | |
14 * a52dec is distributed in the hope that it will be useful, | |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 * GNU General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Public License | |
20 * along with this program; if not, write to the Free Software | |
3036
0b546eab515d
Update licensing information: The FSF changed postal address.
diego
parents:
1412
diff
changeset
|
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
332 | 22 */ |
23 #include "a52.h" | |
24 #include "a52_internal.h" | |
25 | |
26 #define CONVERT(acmod,output) (((output) << 3) + (acmod)) | |
27 | |
1072 | 28 int a52_downmix_init (int input, int flags, level_t * level, |
29 level_t clev, level_t slev) | |
332 | 30 { |
31 static uint8_t table[11][8] = { | |
32 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO, | |
33 A52_STEREO, A52_STEREO, A52_STEREO, A52_STEREO}, | |
34 {A52_MONO, A52_MONO, A52_MONO, A52_MONO, | |
35 A52_MONO, A52_MONO, A52_MONO, A52_MONO}, | |
36 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO, | |
37 A52_STEREO, A52_STEREO, A52_STEREO, A52_STEREO}, | |
38 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_3F, | |
39 A52_STEREO, A52_3F, A52_STEREO, A52_3F}, | |
40 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO, | |
41 A52_2F1R, A52_2F1R, A52_2F1R, A52_2F1R}, | |
42 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO, | |
43 A52_2F1R, A52_3F1R, A52_2F1R, A52_3F1R}, | |
44 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_3F, | |
45 A52_2F2R, A52_2F2R, A52_2F2R, A52_2F2R}, | |
46 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_3F, | |
47 A52_2F2R, A52_3F2R, A52_2F2R, A52_3F2R}, | |
48 {A52_CHANNEL1, A52_MONO, A52_MONO, A52_MONO, | |
49 A52_MONO, A52_MONO, A52_MONO, A52_MONO}, | |
50 {A52_CHANNEL2, A52_MONO, A52_MONO, A52_MONO, | |
51 A52_MONO, A52_MONO, A52_MONO, A52_MONO}, | |
52 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_DOLBY, | |
53 A52_DOLBY, A52_DOLBY, A52_DOLBY, A52_DOLBY} | |
54 }; | |
55 int output; | |
56 | |
57 output = flags & A52_CHANNEL_MASK; | |
58 if (output > A52_DOLBY) | |
59 return -1; | |
60 | |
61 output = table[output][input & 7]; | |
62 | |
1072 | 63 if (output == A52_STEREO && |
64 (input == A52_DOLBY || (input == A52_3F && clev == LEVEL (LEVEL_3DB)))) | |
332 | 65 output = A52_DOLBY; |
66 | |
1072 | 67 if (flags & A52_ADJUST_LEVEL) { |
68 level_t adjust; | |
69 | |
332 | 70 switch (CONVERT (input & 7, output)) { |
71 | |
72 case CONVERT (A52_3F, A52_MONO): | |
1072 | 73 adjust = DIV (LEVEL_3DB, LEVEL (1) + clev); |
332 | 74 break; |
75 | |
76 case CONVERT (A52_STEREO, A52_MONO): | |
77 case CONVERT (A52_2F2R, A52_2F1R): | |
78 case CONVERT (A52_3F2R, A52_3F1R): | |
79 level_3db: | |
1072 | 80 adjust = LEVEL (LEVEL_3DB); |
332 | 81 break; |
82 | |
83 case CONVERT (A52_3F2R, A52_2F1R): | |
1072 | 84 if (clev < LEVEL (LEVEL_PLUS3DB - 1)) |
332 | 85 goto level_3db; |
86 /* break thru */ | |
87 case CONVERT (A52_3F, A52_STEREO): | |
88 case CONVERT (A52_3F1R, A52_2F1R): | |
89 case CONVERT (A52_3F1R, A52_2F2R): | |
90 case CONVERT (A52_3F2R, A52_2F2R): | |
1072 | 91 adjust = DIV (1, LEVEL (1) + clev); |
332 | 92 break; |
93 | |
94 case CONVERT (A52_2F1R, A52_MONO): | |
1072 | 95 adjust = DIV (LEVEL_PLUS3DB, LEVEL (2) + slev); |
332 | 96 break; |
97 | |
98 case CONVERT (A52_2F1R, A52_STEREO): | |
99 case CONVERT (A52_3F1R, A52_3F): | |
1072 | 100 adjust = DIV (1, LEVEL (1) + MUL_C (slev, LEVEL_3DB)); |
332 | 101 break; |
102 | |
103 case CONVERT (A52_3F1R, A52_MONO): | |
1072 | 104 adjust = DIV (LEVEL_3DB, LEVEL (1) + clev + MUL_C (slev, 0.5)); |
332 | 105 break; |
106 | |
107 case CONVERT (A52_3F1R, A52_STEREO): | |
1072 | 108 adjust = DIV (1, LEVEL (1) + clev + MUL_C (slev, LEVEL_3DB)); |
332 | 109 break; |
110 | |
111 case CONVERT (A52_2F2R, A52_MONO): | |
1072 | 112 adjust = DIV (LEVEL_3DB, LEVEL (1) + slev); |
332 | 113 break; |
114 | |
115 case CONVERT (A52_2F2R, A52_STEREO): | |
116 case CONVERT (A52_3F2R, A52_3F): | |
1072 | 117 adjust = DIV (1, LEVEL (1) + slev); |
332 | 118 break; |
119 | |
120 case CONVERT (A52_3F2R, A52_MONO): | |
1072 | 121 adjust = DIV (LEVEL_3DB, LEVEL (1) + clev + slev); |
332 | 122 break; |
123 | |
124 case CONVERT (A52_3F2R, A52_STEREO): | |
1072 | 125 adjust = DIV (1, LEVEL (1) + clev + slev); |
332 | 126 break; |
127 | |
128 case CONVERT (A52_MONO, A52_DOLBY): | |
1072 | 129 adjust = LEVEL (LEVEL_PLUS3DB); |
332 | 130 break; |
131 | |
132 case CONVERT (A52_3F, A52_DOLBY): | |
133 case CONVERT (A52_2F1R, A52_DOLBY): | |
1072 | 134 adjust = LEVEL (1 / (1 + LEVEL_3DB)); |
332 | 135 break; |
136 | |
137 case CONVERT (A52_3F1R, A52_DOLBY): | |
138 case CONVERT (A52_2F2R, A52_DOLBY): | |
1072 | 139 adjust = LEVEL (1 / (1 + 2 * LEVEL_3DB)); |
332 | 140 break; |
141 | |
142 case CONVERT (A52_3F2R, A52_DOLBY): | |
1072 | 143 adjust = LEVEL (1 / (1 + 3 * LEVEL_3DB)); |
332 | 144 break; |
1072 | 145 |
146 default: | |
147 return output; | |
332 | 148 } |
149 | |
1072 | 150 *level = MUL_L (*level, adjust); |
151 } | |
152 | |
332 | 153 return output; |
154 } | |
155 | |
1072 | 156 int a52_downmix_coeff (level_t * coeff, int acmod, int output, level_t level, |
157 level_t clev, level_t slev) | |
332 | 158 { |
1072 | 159 level_t level_3db; |
160 | |
161 level_3db = MUL_C (level, LEVEL_3DB); | |
162 | |
332 | 163 switch (CONVERT (acmod, output & A52_CHANNEL_MASK)) { |
164 | |
165 case CONVERT (A52_CHANNEL, A52_CHANNEL): | |
166 case CONVERT (A52_MONO, A52_MONO): | |
167 case CONVERT (A52_STEREO, A52_STEREO): | |
168 case CONVERT (A52_3F, A52_3F): | |
169 case CONVERT (A52_2F1R, A52_2F1R): | |
170 case CONVERT (A52_3F1R, A52_3F1R): | |
171 case CONVERT (A52_2F2R, A52_2F2R): | |
172 case CONVERT (A52_3F2R, A52_3F2R): | |
173 case CONVERT (A52_STEREO, A52_DOLBY): | |
174 coeff[0] = coeff[1] = coeff[2] = coeff[3] = coeff[4] = level; | |
175 return 0; | |
176 | |
177 case CONVERT (A52_CHANNEL, A52_MONO): | |
1072 | 178 coeff[0] = coeff[1] = MUL_C (level, LEVEL_6DB); |
332 | 179 return 3; |
180 | |
181 case CONVERT (A52_STEREO, A52_MONO): | |
1072 | 182 coeff[0] = coeff[1] = level_3db; |
332 | 183 return 3; |
184 | |
185 case CONVERT (A52_3F, A52_MONO): | |
1072 | 186 coeff[0] = coeff[2] = level_3db; |
187 coeff[1] = MUL_C (MUL_L (level_3db, clev), LEVEL_PLUS6DB); | |
332 | 188 return 7; |
189 | |
190 case CONVERT (A52_2F1R, A52_MONO): | |
1072 | 191 coeff[0] = coeff[1] = level_3db; |
192 coeff[2] = MUL_L (level_3db, slev); | |
332 | 193 return 7; |
194 | |
195 case CONVERT (A52_2F2R, A52_MONO): | |
1072 | 196 coeff[0] = coeff[1] = level_3db; |
197 coeff[2] = coeff[3] = MUL_L (level_3db, slev); | |
332 | 198 return 15; |
199 | |
200 case CONVERT (A52_3F1R, A52_MONO): | |
1072 | 201 coeff[0] = coeff[2] = level_3db; |
202 coeff[1] = MUL_C (MUL_L (level_3db, clev), LEVEL_PLUS6DB); | |
203 coeff[3] = MUL_L (level_3db, slev); | |
332 | 204 return 15; |
205 | |
206 case CONVERT (A52_3F2R, A52_MONO): | |
1072 | 207 coeff[0] = coeff[2] = level_3db; |
208 coeff[1] = MUL_C (MUL_L (level_3db, clev), LEVEL_PLUS6DB); | |
209 coeff[3] = coeff[4] = MUL_L (level_3db, slev); | |
332 | 210 return 31; |
211 | |
212 case CONVERT (A52_MONO, A52_DOLBY): | |
1072 | 213 coeff[0] = level_3db; |
332 | 214 return 0; |
215 | |
216 case CONVERT (A52_3F, A52_DOLBY): | |
1072 | 217 coeff[0] = coeff[2] = coeff[3] = coeff[4] = level; |
218 coeff[1] = level_3db; | |
219 return 7; | |
220 | |
332 | 221 case CONVERT (A52_3F, A52_STEREO): |
222 case CONVERT (A52_3F1R, A52_2F1R): | |
223 case CONVERT (A52_3F2R, A52_2F2R): | |
224 coeff[0] = coeff[2] = coeff[3] = coeff[4] = level; | |
1072 | 225 coeff[1] = MUL_L (level, clev); |
332 | 226 return 7; |
227 | |
228 case CONVERT (A52_2F1R, A52_DOLBY): | |
1072 | 229 coeff[0] = coeff[1] = level; |
230 coeff[2] = level_3db; | |
231 return 7; | |
232 | |
332 | 233 case CONVERT (A52_2F1R, A52_STEREO): |
234 coeff[0] = coeff[1] = level; | |
1072 | 235 coeff[2] = MUL_L (level_3db, slev); |
332 | 236 return 7; |
237 | |
238 case CONVERT (A52_3F1R, A52_DOLBY): | |
1072 | 239 coeff[0] = coeff[2] = level; |
240 coeff[1] = coeff[3] = level_3db; | |
241 return 15; | |
242 | |
332 | 243 case CONVERT (A52_3F1R, A52_STEREO): |
244 coeff[0] = coeff[2] = level; | |
1072 | 245 coeff[1] = MUL_L (level, clev); |
246 coeff[3] = MUL_L (level_3db, slev); | |
332 | 247 return 15; |
248 | |
249 case CONVERT (A52_2F2R, A52_DOLBY): | |
1072 | 250 coeff[0] = coeff[1] = level; |
251 coeff[2] = coeff[3] = level_3db; | |
252 return 15; | |
253 | |
332 | 254 case CONVERT (A52_2F2R, A52_STEREO): |
255 coeff[0] = coeff[1] = level; | |
1072 | 256 coeff[2] = coeff[3] = MUL_L (level, slev); |
332 | 257 return 15; |
258 | |
259 case CONVERT (A52_3F2R, A52_DOLBY): | |
1072 | 260 coeff[0] = coeff[2] = level; |
261 coeff[1] = coeff[3] = coeff[4] = level_3db; | |
262 return 31; | |
263 | |
332 | 264 case CONVERT (A52_3F2R, A52_2F1R): |
1072 | 265 coeff[0] = coeff[2] = level; |
266 coeff[1] = MUL_L (level, clev); | |
267 coeff[3] = coeff[4] = level_3db; | |
268 return 31; | |
269 | |
332 | 270 case CONVERT (A52_3F2R, A52_STEREO): |
271 coeff[0] = coeff[2] = level; | |
1072 | 272 coeff[1] = MUL_L (level, clev); |
273 coeff[3] = coeff[4] = MUL_L (level, slev); | |
332 | 274 return 31; |
275 | |
276 case CONVERT (A52_3F1R, A52_3F): | |
277 coeff[0] = coeff[1] = coeff[2] = level; | |
1072 | 278 coeff[3] = MUL_L (level_3db, slev); |
332 | 279 return 13; |
280 | |
281 case CONVERT (A52_3F2R, A52_3F): | |
282 coeff[0] = coeff[1] = coeff[2] = level; | |
1072 | 283 coeff[3] = coeff[4] = MUL_L (level, slev); |
332 | 284 return 29; |
285 | |
286 case CONVERT (A52_2F2R, A52_2F1R): | |
287 coeff[0] = coeff[1] = level; | |
1072 | 288 coeff[2] = coeff[3] = level_3db; |
332 | 289 return 12; |
290 | |
291 case CONVERT (A52_3F2R, A52_3F1R): | |
292 coeff[0] = coeff[1] = coeff[2] = level; | |
1072 | 293 coeff[3] = coeff[4] = level_3db; |
332 | 294 return 24; |
295 | |
296 case CONVERT (A52_2F1R, A52_2F2R): | |
297 coeff[0] = coeff[1] = level; | |
1072 | 298 coeff[2] = level_3db; |
332 | 299 return 0; |
300 | |
301 case CONVERT (A52_3F1R, A52_2F2R): | |
302 coeff[0] = coeff[2] = level; | |
1072 | 303 coeff[1] = MUL_L (level, clev); |
304 coeff[3] = level_3db; | |
332 | 305 return 7; |
306 | |
307 case CONVERT (A52_3F1R, A52_3F2R): | |
308 coeff[0] = coeff[1] = coeff[2] = level; | |
1072 | 309 coeff[3] = level_3db; |
332 | 310 return 0; |
311 | |
312 case CONVERT (A52_CHANNEL, A52_CHANNEL1): | |
313 coeff[0] = level; | |
314 coeff[1] = 0; | |
315 return 0; | |
316 | |
317 case CONVERT (A52_CHANNEL, A52_CHANNEL2): | |
318 coeff[0] = 0; | |
319 coeff[1] = level; | |
320 return 0; | |
321 } | |
322 | |
323 return -1; /* NOTREACHED */ | |
324 } | |
325 | |
326 static void mix2to1 (sample_t * dest, sample_t * src, sample_t bias) | |
327 { | |
328 int i; | |
329 | |
330 for (i = 0; i < 256; i++) | |
1072 | 331 dest[i] += BIAS (src[i]); |
332 | 332 } |
333 | |
334 static void mix3to1 (sample_t * samples, sample_t bias) | |
335 { | |
336 int i; | |
337 | |
338 for (i = 0; i < 256; i++) | |
1072 | 339 samples[i] += BIAS (samples[i + 256] + samples[i + 512]); |
332 | 340 } |
341 | |
342 static void mix4to1 (sample_t * samples, sample_t bias) | |
343 { | |
344 int i; | |
345 | |
346 for (i = 0; i < 256; i++) | |
1072 | 347 samples[i] += BIAS (samples[i + 256] + samples[i + 512] + |
348 samples[i + 768]); | |
332 | 349 } |
350 | |
351 static void mix5to1 (sample_t * samples, sample_t bias) | |
352 { | |
353 int i; | |
354 | |
355 for (i = 0; i < 256; i++) | |
1072 | 356 samples[i] += BIAS (samples[i + 256] + samples[i + 512] + |
357 samples[i + 768] + samples[i + 1024]); | |
332 | 358 } |
359 | |
360 static void mix3to2 (sample_t * samples, sample_t bias) | |
361 { | |
362 int i; | |
363 sample_t common; | |
364 | |
365 for (i = 0; i < 256; i++) { | |
1072 | 366 common = BIAS (samples[i + 256]); |
332 | 367 samples[i] += common; |
368 samples[i + 256] = samples[i + 512] + common; | |
369 } | |
370 } | |
371 | |
372 static void mix21to2 (sample_t * left, sample_t * right, sample_t bias) | |
373 { | |
374 int i; | |
375 sample_t common; | |
376 | |
377 for (i = 0; i < 256; i++) { | |
1072 | 378 common = BIAS (right[i + 256]); |
332 | 379 left[i] += common; |
380 right[i] += common; | |
381 } | |
382 } | |
383 | |
384 static void mix21toS (sample_t * samples, sample_t bias) | |
385 { | |
386 int i; | |
387 sample_t surround; | |
388 | |
389 for (i = 0; i < 256; i++) { | |
390 surround = samples[i + 512]; | |
1072 | 391 samples[i] += BIAS (-surround); |
392 samples[i + 256] += BIAS (surround); | |
332 | 393 } |
394 } | |
395 | |
396 static void mix31to2 (sample_t * samples, sample_t bias) | |
397 { | |
398 int i; | |
399 sample_t common; | |
400 | |
401 for (i = 0; i < 256; i++) { | |
1072 | 402 common = BIAS (samples[i + 256] + samples[i + 768]); |
332 | 403 samples[i] += common; |
404 samples[i + 256] = samples[i + 512] + common; | |
405 } | |
406 } | |
407 | |
408 static void mix31toS (sample_t * samples, sample_t bias) | |
409 { | |
410 int i; | |
411 sample_t common, surround; | |
412 | |
413 for (i = 0; i < 256; i++) { | |
1072 | 414 common = BIAS (samples[i + 256]); |
332 | 415 surround = samples[i + 768]; |
416 samples[i] += common - surround; | |
417 samples[i + 256] = samples[i + 512] + common + surround; | |
418 } | |
419 } | |
420 | |
421 static void mix22toS (sample_t * samples, sample_t bias) | |
422 { | |
423 int i; | |
424 sample_t surround; | |
425 | |
426 for (i = 0; i < 256; i++) { | |
427 surround = samples[i + 512] + samples[i + 768]; | |
1072 | 428 samples[i] += BIAS (-surround); |
429 samples[i + 256] += BIAS (surround); | |
332 | 430 } |
431 } | |
432 | |
433 static void mix32to2 (sample_t * samples, sample_t bias) | |
434 { | |
435 int i; | |
436 sample_t common; | |
437 | |
438 for (i = 0; i < 256; i++) { | |
1072 | 439 common = BIAS (samples[i + 256]); |
332 | 440 samples[i] += common + samples[i + 768]; |
441 samples[i + 256] = common + samples[i + 512] + samples[i + 1024]; | |
442 } | |
443 } | |
444 | |
445 static void mix32toS (sample_t * samples, sample_t bias) | |
446 { | |
447 int i; | |
448 sample_t common, surround; | |
449 | |
450 for (i = 0; i < 256; i++) { | |
1072 | 451 common = BIAS (samples[i + 256]); |
332 | 452 surround = samples[i + 768] + samples[i + 1024]; |
453 samples[i] += common - surround; | |
454 samples[i + 256] = samples[i + 512] + common + surround; | |
455 } | |
456 } | |
457 | |
458 static void move2to1 (sample_t * src, sample_t * dest, sample_t bias) | |
459 { | |
460 int i; | |
461 | |
462 for (i = 0; i < 256; i++) | |
1072 | 463 dest[i] = BIAS (src[i] + src[i + 256]); |
332 | 464 } |
465 | |
466 static void zero (sample_t * samples) | |
467 { | |
468 int i; | |
469 | |
470 for (i = 0; i < 256; i++) | |
471 samples[i] = 0; | |
472 } | |
473 | |
474 void a52_downmix (sample_t * samples, int acmod, int output, sample_t bias, | |
1072 | 475 level_t clev, level_t slev) |
332 | 476 { |
477 switch (CONVERT (acmod, output & A52_CHANNEL_MASK)) { | |
478 | |
479 case CONVERT (A52_CHANNEL, A52_CHANNEL2): | |
480 memcpy (samples, samples + 256, 256 * sizeof (sample_t)); | |
481 break; | |
482 | |
483 case CONVERT (A52_CHANNEL, A52_MONO): | |
484 case CONVERT (A52_STEREO, A52_MONO): | |
485 mix_2to1: | |
486 mix2to1 (samples, samples + 256, bias); | |
487 break; | |
488 | |
489 case CONVERT (A52_2F1R, A52_MONO): | |
490 if (slev == 0) | |
491 goto mix_2to1; | |
492 case CONVERT (A52_3F, A52_MONO): | |
493 mix_3to1: | |
494 mix3to1 (samples, bias); | |
495 break; | |
496 | |
497 case CONVERT (A52_3F1R, A52_MONO): | |
498 if (slev == 0) | |
499 goto mix_3to1; | |
500 case CONVERT (A52_2F2R, A52_MONO): | |
501 if (slev == 0) | |
502 goto mix_2to1; | |
503 mix4to1 (samples, bias); | |
504 break; | |
505 | |
506 case CONVERT (A52_3F2R, A52_MONO): | |
507 if (slev == 0) | |
508 goto mix_3to1; | |
509 mix5to1 (samples, bias); | |
510 break; | |
511 | |
512 case CONVERT (A52_MONO, A52_DOLBY): | |
513 memcpy (samples + 256, samples, 256 * sizeof (sample_t)); | |
514 break; | |
515 | |
516 case CONVERT (A52_3F, A52_STEREO): | |
517 case CONVERT (A52_3F, A52_DOLBY): | |
518 mix_3to2: | |
519 mix3to2 (samples, bias); | |
520 break; | |
521 | |
522 case CONVERT (A52_2F1R, A52_STEREO): | |
523 if (slev == 0) | |
524 break; | |
525 mix21to2 (samples, samples + 256, bias); | |
526 break; | |
527 | |
528 case CONVERT (A52_2F1R, A52_DOLBY): | |
529 mix21toS (samples, bias); | |
530 break; | |
531 | |
532 case CONVERT (A52_3F1R, A52_STEREO): | |
533 if (slev == 0) | |
534 goto mix_3to2; | |
535 mix31to2 (samples, bias); | |
536 break; | |
537 | |
538 case CONVERT (A52_3F1R, A52_DOLBY): | |
539 mix31toS (samples, bias); | |
540 break; | |
541 | |
542 case CONVERT (A52_2F2R, A52_STEREO): | |
543 if (slev == 0) | |
544 break; | |
545 mix2to1 (samples, samples + 512, bias); | |
546 mix2to1 (samples + 256, samples + 768, bias); | |
547 break; | |
548 | |
549 case CONVERT (A52_2F2R, A52_DOLBY): | |
550 mix22toS (samples, bias); | |
551 break; | |
552 | |
553 case CONVERT (A52_3F2R, A52_STEREO): | |
554 if (slev == 0) | |
555 goto mix_3to2; | |
556 mix32to2 (samples, bias); | |
557 break; | |
558 | |
559 case CONVERT (A52_3F2R, A52_DOLBY): | |
560 mix32toS (samples, bias); | |
561 break; | |
562 | |
563 case CONVERT (A52_3F1R, A52_3F): | |
564 if (slev == 0) | |
565 break; | |
566 mix21to2 (samples, samples + 512, bias); | |
567 break; | |
568 | |
569 case CONVERT (A52_3F2R, A52_3F): | |
570 if (slev == 0) | |
571 break; | |
572 mix2to1 (samples, samples + 768, bias); | |
573 mix2to1 (samples + 512, samples + 1024, bias); | |
574 break; | |
575 | |
576 case CONVERT (A52_3F1R, A52_2F1R): | |
577 mix3to2 (samples, bias); | |
578 memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t)); | |
579 break; | |
580 | |
581 case CONVERT (A52_2F2R, A52_2F1R): | |
582 mix2to1 (samples + 512, samples + 768, bias); | |
583 break; | |
584 | |
585 case CONVERT (A52_3F2R, A52_2F1R): | |
586 mix3to2 (samples, bias); | |
587 move2to1 (samples + 768, samples + 512, bias); | |
588 break; | |
589 | |
590 case CONVERT (A52_3F2R, A52_3F1R): | |
591 mix2to1 (samples + 768, samples + 1024, bias); | |
592 break; | |
593 | |
594 case CONVERT (A52_2F1R, A52_2F2R): | |
595 memcpy (samples + 768, samples + 512, 256 * sizeof (sample_t)); | |
596 break; | |
597 | |
598 case CONVERT (A52_3F1R, A52_2F2R): | |
599 mix3to2 (samples, bias); | |
600 memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t)); | |
601 break; | |
602 | |
603 case CONVERT (A52_3F2R, A52_2F2R): | |
604 mix3to2 (samples, bias); | |
605 memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t)); | |
606 memcpy (samples + 768, samples + 1024, 256 * sizeof (sample_t)); | |
607 break; | |
608 | |
609 case CONVERT (A52_3F1R, A52_3F2R): | |
1072 | 610 memcpy (samples + 1024, samples + 768, 256 * sizeof (sample_t)); |
332 | 611 break; |
612 } | |
613 } | |
614 | |
615 void a52_upmix (sample_t * samples, int acmod, int output) | |
616 { | |
617 switch (CONVERT (acmod, output & A52_CHANNEL_MASK)) { | |
618 | |
619 case CONVERT (A52_CHANNEL, A52_CHANNEL2): | |
620 memcpy (samples + 256, samples, 256 * sizeof (sample_t)); | |
621 break; | |
622 | |
623 case CONVERT (A52_3F2R, A52_MONO): | |
624 zero (samples + 1024); | |
625 case CONVERT (A52_3F1R, A52_MONO): | |
626 case CONVERT (A52_2F2R, A52_MONO): | |
627 zero (samples + 768); | |
628 case CONVERT (A52_3F, A52_MONO): | |
629 case CONVERT (A52_2F1R, A52_MONO): | |
630 zero (samples + 512); | |
631 case CONVERT (A52_CHANNEL, A52_MONO): | |
632 case CONVERT (A52_STEREO, A52_MONO): | |
633 zero (samples + 256); | |
634 break; | |
635 | |
636 case CONVERT (A52_3F2R, A52_STEREO): | |
637 case CONVERT (A52_3F2R, A52_DOLBY): | |
638 zero (samples + 1024); | |
639 case CONVERT (A52_3F1R, A52_STEREO): | |
640 case CONVERT (A52_3F1R, A52_DOLBY): | |
641 zero (samples + 768); | |
642 case CONVERT (A52_3F, A52_STEREO): | |
643 case CONVERT (A52_3F, A52_DOLBY): | |
644 mix_3to2: | |
645 memcpy (samples + 512, samples + 256, 256 * sizeof (sample_t)); | |
646 zero (samples + 256); | |
647 break; | |
648 | |
649 case CONVERT (A52_2F2R, A52_STEREO): | |
650 case CONVERT (A52_2F2R, A52_DOLBY): | |
651 zero (samples + 768); | |
652 case CONVERT (A52_2F1R, A52_STEREO): | |
653 case CONVERT (A52_2F1R, A52_DOLBY): | |
654 zero (samples + 512); | |
655 break; | |
656 | |
657 case CONVERT (A52_3F2R, A52_3F): | |
658 zero (samples + 1024); | |
659 case CONVERT (A52_3F1R, A52_3F): | |
660 case CONVERT (A52_2F2R, A52_2F1R): | |
661 zero (samples + 768); | |
662 break; | |
663 | |
664 case CONVERT (A52_3F2R, A52_3F1R): | |
665 zero (samples + 1024); | |
666 break; | |
667 | |
668 case CONVERT (A52_3F2R, A52_2F1R): | |
669 zero (samples + 1024); | |
670 case CONVERT (A52_3F1R, A52_2F1R): | |
671 mix_31to21: | |
672 memcpy (samples + 768, samples + 512, 256 * sizeof (sample_t)); | |
673 goto mix_3to2; | |
674 | |
675 case CONVERT (A52_3F2R, A52_2F2R): | |
676 memcpy (samples + 1024, samples + 768, 256 * sizeof (sample_t)); | |
677 goto mix_31to21; | |
678 } | |
679 } |