annotate liba52/downmix.c @ 3529:a86166b495a6

sse opt
author michael
date Sun, 16 Dec 2001 15:43:15 +0000
parents 35b18ed357c2
children 0e4ff1cac6a2
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
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
22 */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
23
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
24 #include "config.h"
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
25
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
26 #include <string.h>
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
27 #include <inttypes.h>
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
28
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
29 #include "a52.h"
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
30 #include "a52_internal.h"
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
31
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
32 #define CONVERT(acmod,output) (((output) << 3) + (acmod))
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
33
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
34 int downmix_init (int input, int flags, sample_t * level,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
35 sample_t clev, sample_t slev)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
36 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
37 static uint8_t table[11][8] = {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
38 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
39 A52_STEREO, A52_STEREO, A52_STEREO, A52_STEREO},
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
40 {A52_MONO, A52_MONO, A52_MONO, A52_MONO,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
41 A52_MONO, A52_MONO, A52_MONO, A52_MONO},
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
42 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
43 A52_STEREO, A52_STEREO, A52_STEREO, A52_STEREO},
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
44 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_3F,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
45 A52_STEREO, A52_3F, A52_STEREO, A52_3F},
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
46 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
47 A52_2F1R, A52_2F1R, A52_2F1R, A52_2F1R},
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_3F1R, A52_2F1R, A52_3F1R},
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
50 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_3F,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
51 A52_2F2R, A52_2F2R, A52_2F2R, A52_2F2R},
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_3F2R, A52_2F2R, A52_3F2R},
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
54 {A52_CHANNEL1, A52_MONO, A52_MONO, A52_MONO,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
55 A52_MONO, A52_MONO, A52_MONO, A52_MONO},
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
56 {A52_CHANNEL2, 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_CHANNEL, A52_DOLBY, A52_STEREO, A52_DOLBY,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
59 A52_DOLBY, A52_DOLBY, A52_DOLBY, A52_DOLBY}
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
60 };
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
61 int output;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
62
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
63 output = flags & A52_CHANNEL_MASK;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
64 if (output > A52_DOLBY)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
65 return -1;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
66
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
67 output = table[output][input & 7];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
68
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
69 if ((output == A52_STEREO) &&
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
70 ((input == A52_DOLBY) || ((input == A52_3F) && (clev == LEVEL_3DB))))
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
71 output = A52_DOLBY;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
72
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
73 if (flags & A52_ADJUST_LEVEL)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
74 switch (CONVERT (input & 7, output)) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
75
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
76 case CONVERT (A52_3F, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
77 *level *= LEVEL_3DB / (1 + clev);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
78 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
79
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
80 case CONVERT (A52_STEREO, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
81 case CONVERT (A52_2F2R, A52_2F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
82 case CONVERT (A52_3F2R, A52_3F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
83 level_3db:
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
84 *level *= LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
85 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
86
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
87 case CONVERT (A52_3F2R, A52_2F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
88 if (clev < LEVEL_PLUS3DB - 1)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
89 goto level_3db;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
90 /* break thru */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
91 case CONVERT (A52_3F, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
92 case CONVERT (A52_3F1R, A52_2F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
93 case CONVERT (A52_3F1R, A52_2F2R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
94 case CONVERT (A52_3F2R, A52_2F2R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
95 *level /= 1 + clev;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
96 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
97
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
98 case CONVERT (A52_2F1R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
99 *level *= LEVEL_PLUS3DB / (2 + slev);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
100 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
101
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
102 case CONVERT (A52_2F1R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
103 case CONVERT (A52_3F1R, A52_3F):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
104 *level /= 1 + slev * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
105 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
106
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
107 case CONVERT (A52_3F1R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
108 *level *= LEVEL_3DB / (1 + clev + 0.5 * slev);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
109 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
110
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
111 case CONVERT (A52_3F1R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
112 *level /= 1 + clev + slev * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
113 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
114
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
115 case CONVERT (A52_2F2R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
116 *level *= LEVEL_3DB / (1 + slev);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
117 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
118
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
119 case CONVERT (A52_2F2R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
120 case CONVERT (A52_3F2R, A52_3F):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
121 *level /= 1 + slev;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
122 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
123
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
124 case CONVERT (A52_3F2R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
125 *level *= LEVEL_3DB / (1 + clev + slev);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
126 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
127
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
128 case CONVERT (A52_3F2R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
129 *level /= 1 + clev + slev;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
130 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
131
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
132 case CONVERT (A52_MONO, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
133 *level *= LEVEL_PLUS3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
134 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
135
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
136 case CONVERT (A52_3F, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
137 case CONVERT (A52_2F1R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
138 *level *= 1 / (1 + LEVEL_3DB);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
139 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
140
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
141 case CONVERT (A52_3F1R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
142 case CONVERT (A52_2F2R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
143 *level *= 1 / (1 + 2 * LEVEL_3DB);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
144 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
145
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
146 case CONVERT (A52_3F2R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
147 *level *= 1 / (1 + 3 * LEVEL_3DB);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
148 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
149 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
150
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
151 return output;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
152 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
153
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
154 int downmix_coeff (sample_t * coeff, int acmod, int output, sample_t level,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
155 sample_t clev, sample_t slev)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
156 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
157 switch (CONVERT (acmod, output & A52_CHANNEL_MASK)) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
158
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
159 case CONVERT (A52_CHANNEL, A52_CHANNEL):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
160 case CONVERT (A52_MONO, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
161 case CONVERT (A52_STEREO, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
162 case CONVERT (A52_3F, A52_3F):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
163 case CONVERT (A52_2F1R, A52_2F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
164 case CONVERT (A52_3F1R, A52_3F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
165 case CONVERT (A52_2F2R, A52_2F2R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
166 case CONVERT (A52_3F2R, A52_3F2R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
167 case CONVERT (A52_STEREO, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
168 coeff[0] = coeff[1] = coeff[2] = coeff[3] = coeff[4] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
169 return 0;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
170
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
171 case CONVERT (A52_CHANNEL, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
172 coeff[0] = coeff[1] = level * LEVEL_6DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
173 return 3;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
174
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
175 case CONVERT (A52_STEREO, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
176 coeff[0] = coeff[1] = level * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
177 return 3;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
178
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
179 case CONVERT (A52_3F, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
180 coeff[0] = coeff[2] = level * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
181 coeff[1] = level * clev * LEVEL_PLUS3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
182 return 7;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
183
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
184 case CONVERT (A52_2F1R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
185 coeff[0] = coeff[1] = level * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
186 coeff[2] = level * slev * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
187 return 7;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
188
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
189 case CONVERT (A52_2F2R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
190 coeff[0] = coeff[1] = level * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
191 coeff[2] = coeff[3] = level * slev * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
192 return 15;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
193
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
194 case CONVERT (A52_3F1R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
195 coeff[0] = coeff[2] = level * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
196 coeff[1] = level * clev * LEVEL_PLUS3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
197 coeff[3] = level * slev * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
198 return 15;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
199
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
200 case CONVERT (A52_3F2R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
201 coeff[0] = coeff[2] = level * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
202 coeff[1] = level * clev * LEVEL_PLUS3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
203 coeff[3] = coeff[4] = level * slev * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
204 return 31;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
205
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
206 case CONVERT (A52_MONO, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
207 coeff[0] = level * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
208 return 0;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
209
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
210 case CONVERT (A52_3F, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
211 clev = LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
212 case CONVERT (A52_3F, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
213 case CONVERT (A52_3F1R, A52_2F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
214 case CONVERT (A52_3F2R, A52_2F2R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
215 coeff[0] = coeff[2] = coeff[3] = coeff[4] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
216 coeff[1] = level * clev;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
217 return 7;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
218
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
219 case CONVERT (A52_2F1R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
220 slev = 1;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
221 case CONVERT (A52_2F1R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
222 coeff[0] = coeff[1] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
223 coeff[2] = level * slev * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
224 return 7;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
225
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
226 case CONVERT (A52_3F1R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
227 clev = LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
228 slev = 1;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
229 case CONVERT (A52_3F1R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
230 coeff[0] = coeff[2] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
231 coeff[1] = level * clev;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
232 coeff[3] = level * slev * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
233 return 15;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
234
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
235 case CONVERT (A52_2F2R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
236 slev = LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
237 case CONVERT (A52_2F2R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
238 coeff[0] = coeff[1] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
239 coeff[2] = coeff[3] = level * slev;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
240 return 15;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
241
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
242 case CONVERT (A52_3F2R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
243 clev = LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
244 case CONVERT (A52_3F2R, A52_2F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
245 slev = LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
246 case CONVERT (A52_3F2R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
247 coeff[0] = coeff[2] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
248 coeff[1] = level * clev;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
249 coeff[3] = coeff[4] = level * slev;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
250 return 31;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
251
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
252 case CONVERT (A52_3F1R, A52_3F):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
253 coeff[0] = coeff[1] = coeff[2] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
254 coeff[3] = level * slev * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
255 return 13;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
256
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
257 case CONVERT (A52_3F2R, A52_3F):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
258 coeff[0] = coeff[1] = coeff[2] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
259 coeff[3] = coeff[4] = level * slev;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
260 return 29;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
261
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
262 case CONVERT (A52_2F2R, A52_2F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
263 coeff[0] = coeff[1] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
264 coeff[2] = coeff[3] = level * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
265 return 12;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
266
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
267 case CONVERT (A52_3F2R, A52_3F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
268 coeff[0] = coeff[1] = coeff[2] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
269 coeff[3] = coeff[4] = level * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
270 return 24;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
271
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
272 case CONVERT (A52_2F1R, A52_2F2R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
273 coeff[0] = coeff[1] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
274 coeff[2] = level * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
275 return 0;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
276
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
277 case CONVERT (A52_3F1R, A52_2F2R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
278 coeff[0] = coeff[2] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
279 coeff[1] = level * clev;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
280 coeff[3] = level * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
281 return 7;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
282
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
283 case CONVERT (A52_3F1R, A52_3F2R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
284 coeff[0] = coeff[1] = coeff[2] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
285 coeff[3] = level * LEVEL_3DB;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
286 return 0;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
287
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
288 case CONVERT (A52_CHANNEL, A52_CHANNEL1):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
289 coeff[0] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
290 coeff[1] = 0;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
291 return 0;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
292
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
293 case CONVERT (A52_CHANNEL, A52_CHANNEL2):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
294 coeff[0] = 0;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
295 coeff[1] = level;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
296 return 0;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
297 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
298
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
299 return -1; /* NOTREACHED */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
300 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
301
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
302 static void mix2to1 (sample_t * dest, sample_t * src, sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
303 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
304 int i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
305
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
306 for (i = 0; i < 256; i++)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
307 dest[i] += src[i] + bias;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
308 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
309
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
310 static void mix3to1 (sample_t * samples, sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
311 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
312 int i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
313
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
314 for (i = 0; i < 256; i++)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
315 samples[i] += samples[i + 256] + samples[i + 512] + bias;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
316 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
317
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
318 static void mix4to1 (sample_t * samples, sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
319 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
320 int i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
321
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
322 for (i = 0; i < 256; i++)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
323 samples[i] += (samples[i + 256] + samples[i + 512] +
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
324 samples[i + 768] + bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
325 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
326
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
327 static void mix5to1 (sample_t * samples, sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
328 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
329 int i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
330
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
331 for (i = 0; i < 256; i++)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
332 samples[i] += (samples[i + 256] + samples[i + 512] +
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
333 samples[i + 768] + samples[i + 1024] + bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
334 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
335
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
336 static void mix3to2 (sample_t * samples, sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
337 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
338 int i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
339 sample_t common;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
340
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
341 for (i = 0; i < 256; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
342 common = samples[i + 256] + bias;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
343 samples[i] += common;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
344 samples[i + 256] = samples[i + 512] + common;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
345 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
346 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
347
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
348 static void mix21to2 (sample_t * left, sample_t * right, sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
349 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
350 int i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
351 sample_t common;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
352
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
353 for (i = 0; i < 256; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
354 common = right[i + 256] + bias;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
355 left[i] += common;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
356 right[i] += common;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
357 }
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 mix21toS (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 sample_t surround;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
364
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
365 for (i = 0; i < 256; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
366 surround = samples[i + 512];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
367 samples[i] += bias - surround;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
368 samples[i + 256] += bias + surround;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
369 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
370 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
371
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
372 static void mix31to2 (sample_t * samples, sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
373 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
374 int i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
375 sample_t common;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
376
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
377 for (i = 0; i < 256; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
378 common = samples[i + 256] + samples[i + 768] + bias;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
379 samples[i] += common;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
380 samples[i + 256] = samples[i + 512] + common;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
381 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
382 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
383
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
384 static void mix31toS (sample_t * samples, sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
385 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
386 int i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
387 sample_t common, surround;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
388
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
389 for (i = 0; i < 256; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
390 common = samples[i + 256] + bias;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
391 surround = samples[i + 768];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
392 samples[i] += common - surround;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
393 samples[i + 256] = samples[i + 512] + common + surround;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
394 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
395 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
396
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
397 static void mix22toS (sample_t * samples, sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
398 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
399 int i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
400 sample_t surround;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
401
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
402 for (i = 0; i < 256; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
403 surround = samples[i + 512] + samples[i + 768];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
404 samples[i] += bias - surround;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
405 samples[i + 256] += bias + surround;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
406 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
407 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
408
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
409 static void mix32to2 (sample_t * samples, sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
410 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
411 int i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
412 sample_t common;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
413
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
414 for (i = 0; i < 256; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
415 common = samples[i + 256] + bias;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
416 samples[i] += common + samples[i + 768];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
417 samples[i + 256] = common + samples[i + 512] + samples[i + 1024];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
418 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
419 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
420
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
421 static void mix32toS (sample_t * samples, sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
422 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
423 int i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
424 sample_t common, surround;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
425
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
426 for (i = 0; i < 256; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
427 common = samples[i + 256] + bias;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
428 surround = samples[i + 768] + samples[i + 1024];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
429 samples[i] += common - surround;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
430 samples[i + 256] = samples[i + 512] + common + surround;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
431 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
432 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
433
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
434 static void move2to1 (sample_t * src, sample_t * dest, sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
435 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
436 int i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
437
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
438 for (i = 0; i < 256; i++)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
439 dest[i] = src[i] + src[i + 256] + bias;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
440 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
441
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
442 static void zero (sample_t * samples)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
443 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
444 int i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
445
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
446 for (i = 0; i < 256; i++)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
447 samples[i] = 0;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
448 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
449
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
450 void downmix (sample_t * samples, int acmod, int output, sample_t bias,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
451 sample_t clev, sample_t slev)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
452 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
453 switch (CONVERT (acmod, output & A52_CHANNEL_MASK)) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
454
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
455 case CONVERT (A52_CHANNEL, A52_CHANNEL2):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
456 memcpy (samples, samples + 256, 256 * sizeof (sample_t));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
457 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
458
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
459 case CONVERT (A52_CHANNEL, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
460 case CONVERT (A52_STEREO, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
461 mix_2to1:
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
462 mix2to1 (samples, samples + 256, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
463 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
464
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
465 case CONVERT (A52_2F1R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
466 if (slev == 0)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
467 goto mix_2to1;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
468 case CONVERT (A52_3F, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
469 mix_3to1:
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
470 mix3to1 (samples, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
471 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
472
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
473 case CONVERT (A52_3F1R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
474 if (slev == 0)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
475 goto mix_3to1;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
476 case CONVERT (A52_2F2R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
477 if (slev == 0)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
478 goto mix_2to1;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
479 mix4to1 (samples, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
480 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
481
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
482 case CONVERT (A52_3F2R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
483 if (slev == 0)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
484 goto mix_3to1;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
485 mix5to1 (samples, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
486 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
487
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
488 case CONVERT (A52_MONO, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
489 memcpy (samples + 256, samples, 256 * sizeof (sample_t));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
490 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
491
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
492 case CONVERT (A52_3F, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
493 case CONVERT (A52_3F, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
494 mix_3to2:
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
495 mix3to2 (samples, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
496 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
497
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
498 case CONVERT (A52_2F1R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
499 if (slev == 0)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
500 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
501 mix21to2 (samples, samples + 256, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
502 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
503
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
504 case CONVERT (A52_2F1R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
505 mix21toS (samples, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
506 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
507
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
508 case CONVERT (A52_3F1R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
509 if (slev == 0)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
510 goto mix_3to2;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
511 mix31to2 (samples, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
512 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
513
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
514 case CONVERT (A52_3F1R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
515 mix31toS (samples, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
516 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
517
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
518 case CONVERT (A52_2F2R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
519 if (slev == 0)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
520 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
521 mix2to1 (samples, samples + 512, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
522 mix2to1 (samples + 256, samples + 768, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
523 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
524
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
525 case CONVERT (A52_2F2R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
526 mix22toS (samples, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
527 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
528
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
529 case CONVERT (A52_3F2R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
530 if (slev == 0)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
531 goto mix_3to2;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
532 mix32to2 (samples, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
533 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
534
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
535 case CONVERT (A52_3F2R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
536 mix32toS (samples, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
537 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
538
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
539 case CONVERT (A52_3F1R, A52_3F):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
540 if (slev == 0)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
541 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
542 mix21to2 (samples, samples + 512, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
543 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
544
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
545 case CONVERT (A52_3F2R, A52_3F):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
546 if (slev == 0)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
547 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
548 mix2to1 (samples, samples + 768, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
549 mix2to1 (samples + 512, samples + 1024, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
550 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
551
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
552 case CONVERT (A52_3F1R, A52_2F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
553 mix3to2 (samples, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
554 memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
555 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
556
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
557 case CONVERT (A52_2F2R, A52_2F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
558 mix2to1 (samples + 512, samples + 768, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
559 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
560
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
561 case CONVERT (A52_3F2R, A52_2F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
562 mix3to2 (samples, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
563 move2to1 (samples + 768, samples + 512, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
564 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
565
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
566 case CONVERT (A52_3F2R, A52_3F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
567 mix2to1 (samples + 768, samples + 1024, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
568 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
569
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
570 case CONVERT (A52_2F1R, A52_2F2R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
571 memcpy (samples + 768, samples + 512, 256 * sizeof (sample_t));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
572 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
573
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
574 case CONVERT (A52_3F1R, A52_2F2R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
575 mix3to2 (samples, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
576 memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
577 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
578
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
579 case CONVERT (A52_3F2R, A52_2F2R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
580 mix3to2 (samples, bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
581 memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
582 memcpy (samples + 768, samples + 1024, 256 * sizeof (sample_t));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
583 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
584
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
585 case CONVERT (A52_3F1R, A52_3F2R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
586 memcpy (samples + 1027, samples + 768, 256 * sizeof (sample_t));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
587 break;
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
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
591 void upmix (sample_t * samples, int acmod, int output)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
592 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
593 switch (CONVERT (acmod, output & A52_CHANNEL_MASK)) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
594
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
595 case CONVERT (A52_CHANNEL, A52_CHANNEL2):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
596 memcpy (samples + 256, samples, 256 * sizeof (sample_t));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
597 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
598
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
599 case CONVERT (A52_3F2R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
600 zero (samples + 1024);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
601 case CONVERT (A52_3F1R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
602 case CONVERT (A52_2F2R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
603 zero (samples + 768);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
604 case CONVERT (A52_3F, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
605 case CONVERT (A52_2F1R, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
606 zero (samples + 512);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
607 case CONVERT (A52_CHANNEL, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
608 case CONVERT (A52_STEREO, A52_MONO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
609 zero (samples + 256);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
610 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
611
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
612 case CONVERT (A52_3F2R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
613 case CONVERT (A52_3F2R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
614 zero (samples + 1024);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
615 case CONVERT (A52_3F1R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
616 case CONVERT (A52_3F1R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
617 zero (samples + 768);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
618 case CONVERT (A52_3F, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
619 case CONVERT (A52_3F, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
620 mix_3to2:
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
621 memcpy (samples + 512, samples + 256, 256 * sizeof (sample_t));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
622 zero (samples + 256);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
623 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
624
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
625 case CONVERT (A52_2F2R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
626 case CONVERT (A52_2F2R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
627 zero (samples + 768);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
628 case CONVERT (A52_2F1R, A52_STEREO):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
629 case CONVERT (A52_2F1R, A52_DOLBY):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
630 zero (samples + 512);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
631 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
632
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
633 case CONVERT (A52_3F2R, A52_3F):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
634 zero (samples + 1024);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
635 case CONVERT (A52_3F1R, A52_3F):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
636 case CONVERT (A52_2F2R, A52_2F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
637 zero (samples + 768);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
638 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
639
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
640 case CONVERT (A52_3F2R, A52_3F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
641 zero (samples + 1024);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
642 break;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
643
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
644 case CONVERT (A52_3F2R, A52_2F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
645 zero (samples + 1024);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
646 case CONVERT (A52_3F1R, A52_2F1R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
647 mix_31to21:
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
648 memcpy (samples + 768, samples + 512, 256 * sizeof (sample_t));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
649 goto mix_3to2;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
650
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
651 case CONVERT (A52_3F2R, A52_2F2R):
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
652 memcpy (samples + 1024, samples + 768, 256 * sizeof (sample_t));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
653 goto mix_31to21;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
654 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
655 }