annotate libac3/downmix.c @ 92:1d3eb6cdc6b5 libavcodec

added pcm codecs
author glantau
date Sun, 23 Sep 2001 17:16:51 +0000
parents 5aa6292a1660
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
1 /*
986e461dc072 Initial revision
glantau
parents:
diff changeset
2 *
986e461dc072 Initial revision
glantau
parents:
diff changeset
3 * downmix.c
986e461dc072 Initial revision
glantau
parents:
diff changeset
4 *
986e461dc072 Initial revision
glantau
parents:
diff changeset
5 * Copyright (C) Aaron Holtzman - Sept 1999
986e461dc072 Initial revision
glantau
parents:
diff changeset
6 *
986e461dc072 Initial revision
glantau
parents:
diff changeset
7 * Originally based on code by Yuqing Deng.
986e461dc072 Initial revision
glantau
parents:
diff changeset
8 *
986e461dc072 Initial revision
glantau
parents:
diff changeset
9 * This file is part of ac3dec, a free Dolby AC-3 stream decoder.
986e461dc072 Initial revision
glantau
parents:
diff changeset
10 *
986e461dc072 Initial revision
glantau
parents:
diff changeset
11 * ac3dec is free software; you can redistribute it and/or modify
986e461dc072 Initial revision
glantau
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
986e461dc072 Initial revision
glantau
parents:
diff changeset
13 * the Free Software Foundation; either version 2, or (at your option)
986e461dc072 Initial revision
glantau
parents:
diff changeset
14 * any later version.
986e461dc072 Initial revision
glantau
parents:
diff changeset
15 *
986e461dc072 Initial revision
glantau
parents:
diff changeset
16 * ac3dec is distributed in the hope that it will be useful,
986e461dc072 Initial revision
glantau
parents:
diff changeset
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
986e461dc072 Initial revision
glantau
parents:
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
986e461dc072 Initial revision
glantau
parents:
diff changeset
19 * GNU General Public License for more details.
986e461dc072 Initial revision
glantau
parents:
diff changeset
20 *
986e461dc072 Initial revision
glantau
parents:
diff changeset
21 * You should have received a copy of the GNU General Public License
986e461dc072 Initial revision
glantau
parents:
diff changeset
22 * along with GNU Make; see the file COPYING. If not, write to
986e461dc072 Initial revision
glantau
parents:
diff changeset
23 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
986e461dc072 Initial revision
glantau
parents:
diff changeset
24 *
986e461dc072 Initial revision
glantau
parents:
diff changeset
25 *
986e461dc072 Initial revision
glantau
parents:
diff changeset
26 */
986e461dc072 Initial revision
glantau
parents:
diff changeset
27
64
5aa6292a1660 win32 fixes
glantau
parents: 0
diff changeset
28 #include "../common.h"
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
29 #include <math.h>
986e461dc072 Initial revision
glantau
parents:
diff changeset
30 #include "ac3.h"
986e461dc072 Initial revision
glantau
parents:
diff changeset
31 #include "ac3_internal.h"
986e461dc072 Initial revision
glantau
parents:
diff changeset
32
986e461dc072 Initial revision
glantau
parents:
diff changeset
33
986e461dc072 Initial revision
glantau
parents:
diff changeset
34 #define CONVERT(acmod,output) (((output) << 3) + (acmod))
986e461dc072 Initial revision
glantau
parents:
diff changeset
35
986e461dc072 Initial revision
glantau
parents:
diff changeset
36 int downmix_init (int input, int flags, float * level, float clev, float slev)
986e461dc072 Initial revision
glantau
parents:
diff changeset
37 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
38 static uint8_t table[11][8] = {
986e461dc072 Initial revision
glantau
parents:
diff changeset
39 {AC3_CHANNEL, AC3_DOLBY, AC3_STEREO, AC3_STEREO,
986e461dc072 Initial revision
glantau
parents:
diff changeset
40 AC3_STEREO, AC3_STEREO, AC3_STEREO, AC3_STEREO},
986e461dc072 Initial revision
glantau
parents:
diff changeset
41 {AC3_MONO, AC3_MONO, AC3_MONO, AC3_MONO,
986e461dc072 Initial revision
glantau
parents:
diff changeset
42 AC3_MONO, AC3_MONO, AC3_MONO, AC3_MONO},
986e461dc072 Initial revision
glantau
parents:
diff changeset
43 {AC3_CHANNEL, AC3_DOLBY, AC3_STEREO, AC3_STEREO,
986e461dc072 Initial revision
glantau
parents:
diff changeset
44 AC3_STEREO, AC3_STEREO, AC3_STEREO, AC3_STEREO},
986e461dc072 Initial revision
glantau
parents:
diff changeset
45 {AC3_CHANNEL, AC3_DOLBY, AC3_STEREO, AC3_3F,
986e461dc072 Initial revision
glantau
parents:
diff changeset
46 AC3_STEREO, AC3_3F, AC3_STEREO, AC3_3F},
986e461dc072 Initial revision
glantau
parents:
diff changeset
47 {AC3_CHANNEL, AC3_DOLBY, AC3_STEREO, AC3_STEREO,
986e461dc072 Initial revision
glantau
parents:
diff changeset
48 AC3_2F1R, AC3_2F1R, AC3_2F1R, AC3_2F1R},
986e461dc072 Initial revision
glantau
parents:
diff changeset
49 {AC3_CHANNEL, AC3_DOLBY, AC3_STEREO, AC3_STEREO,
986e461dc072 Initial revision
glantau
parents:
diff changeset
50 AC3_2F1R, AC3_3F1R, AC3_2F1R, AC3_3F1R},
986e461dc072 Initial revision
glantau
parents:
diff changeset
51 {AC3_CHANNEL, AC3_DOLBY, AC3_STEREO, AC3_3F,
986e461dc072 Initial revision
glantau
parents:
diff changeset
52 AC3_2F2R, AC3_2F2R, AC3_2F2R, AC3_2F2R},
986e461dc072 Initial revision
glantau
parents:
diff changeset
53 {AC3_CHANNEL, AC3_DOLBY, AC3_STEREO, AC3_3F,
986e461dc072 Initial revision
glantau
parents:
diff changeset
54 AC3_2F2R, AC3_3F2R, AC3_2F2R, AC3_3F2R},
986e461dc072 Initial revision
glantau
parents:
diff changeset
55 {AC3_CHANNEL1, AC3_MONO, AC3_MONO, AC3_MONO,
986e461dc072 Initial revision
glantau
parents:
diff changeset
56 AC3_MONO, AC3_MONO, AC3_MONO, AC3_MONO},
986e461dc072 Initial revision
glantau
parents:
diff changeset
57 {AC3_CHANNEL2, AC3_MONO, AC3_MONO, AC3_MONO,
986e461dc072 Initial revision
glantau
parents:
diff changeset
58 AC3_MONO, AC3_MONO, AC3_MONO, AC3_MONO},
986e461dc072 Initial revision
glantau
parents:
diff changeset
59 {AC3_CHANNEL, AC3_DOLBY, AC3_STEREO, AC3_DOLBY,
986e461dc072 Initial revision
glantau
parents:
diff changeset
60 AC3_DOLBY, AC3_DOLBY, AC3_DOLBY, AC3_DOLBY}
986e461dc072 Initial revision
glantau
parents:
diff changeset
61 };
986e461dc072 Initial revision
glantau
parents:
diff changeset
62 int output;
986e461dc072 Initial revision
glantau
parents:
diff changeset
63
986e461dc072 Initial revision
glantau
parents:
diff changeset
64 output = flags & AC3_CHANNEL_MASK;
986e461dc072 Initial revision
glantau
parents:
diff changeset
65 if (output > AC3_DOLBY)
986e461dc072 Initial revision
glantau
parents:
diff changeset
66 return -1;
986e461dc072 Initial revision
glantau
parents:
diff changeset
67
986e461dc072 Initial revision
glantau
parents:
diff changeset
68 output = table[output][input & 7];
986e461dc072 Initial revision
glantau
parents:
diff changeset
69
986e461dc072 Initial revision
glantau
parents:
diff changeset
70 if ((output == AC3_STEREO) &&
986e461dc072 Initial revision
glantau
parents:
diff changeset
71 ((input == AC3_DOLBY) || ((input == AC3_3F) && (clev == LEVEL_3DB))))
986e461dc072 Initial revision
glantau
parents:
diff changeset
72 output = AC3_DOLBY;
986e461dc072 Initial revision
glantau
parents:
diff changeset
73
986e461dc072 Initial revision
glantau
parents:
diff changeset
74 if (flags & AC3_ADJUST_LEVEL)
986e461dc072 Initial revision
glantau
parents:
diff changeset
75 switch (CONVERT (input & 7, output)) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
76
986e461dc072 Initial revision
glantau
parents:
diff changeset
77 case CONVERT (AC3_3F, AC3_MONO):
986e461dc072 Initial revision
glantau
parents:
diff changeset
78 *level *= LEVEL_3DB / (1 + clev);
986e461dc072 Initial revision
glantau
parents:
diff changeset
79 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
80
986e461dc072 Initial revision
glantau
parents:
diff changeset
81 case CONVERT (AC3_STEREO, AC3_MONO):
986e461dc072 Initial revision
glantau
parents:
diff changeset
82 case CONVERT (AC3_2F2R, AC3_2F1R):
986e461dc072 Initial revision
glantau
parents:
diff changeset
83 case CONVERT (AC3_3F2R, AC3_3F1R):
986e461dc072 Initial revision
glantau
parents:
diff changeset
84 level_3db:
986e461dc072 Initial revision
glantau
parents:
diff changeset
85 *level *= LEVEL_3DB;
986e461dc072 Initial revision
glantau
parents:
diff changeset
86 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
87
986e461dc072 Initial revision
glantau
parents:
diff changeset
88 case CONVERT (AC3_3F2R, AC3_2F1R):
986e461dc072 Initial revision
glantau
parents:
diff changeset
89 if (clev < LEVEL_PLUS3DB - 1)
986e461dc072 Initial revision
glantau
parents:
diff changeset
90 goto level_3db;
986e461dc072 Initial revision
glantau
parents:
diff changeset
91 // break thru
986e461dc072 Initial revision
glantau
parents:
diff changeset
92 case CONVERT (AC3_3F, AC3_STEREO):
986e461dc072 Initial revision
glantau
parents:
diff changeset
93 case CONVERT (AC3_3F1R, AC3_2F1R):
986e461dc072 Initial revision
glantau
parents:
diff changeset
94 case CONVERT (AC3_3F1R, AC3_2F2R):
986e461dc072 Initial revision
glantau
parents:
diff changeset
95 case CONVERT (AC3_3F2R, AC3_2F2R):
986e461dc072 Initial revision
glantau
parents:
diff changeset
96 *level /= 1 + clev;
986e461dc072 Initial revision
glantau
parents:
diff changeset
97 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
98
986e461dc072 Initial revision
glantau
parents:
diff changeset
99 case CONVERT (AC3_2F1R, AC3_MONO):
986e461dc072 Initial revision
glantau
parents:
diff changeset
100 *level *= LEVEL_PLUS3DB / (2 + slev);
986e461dc072 Initial revision
glantau
parents:
diff changeset
101 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
102
986e461dc072 Initial revision
glantau
parents:
diff changeset
103 case CONVERT (AC3_2F1R, AC3_STEREO):
986e461dc072 Initial revision
glantau
parents:
diff changeset
104 case CONVERT (AC3_3F1R, AC3_3F):
986e461dc072 Initial revision
glantau
parents:
diff changeset
105 *level /= 1 + slev * LEVEL_3DB;
986e461dc072 Initial revision
glantau
parents:
diff changeset
106 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
107
986e461dc072 Initial revision
glantau
parents:
diff changeset
108 case CONVERT (AC3_3F1R, AC3_MONO):
986e461dc072 Initial revision
glantau
parents:
diff changeset
109 *level *= LEVEL_3DB / (1 + clev + 0.5 * slev);
986e461dc072 Initial revision
glantau
parents:
diff changeset
110 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
111
986e461dc072 Initial revision
glantau
parents:
diff changeset
112 case CONVERT (AC3_3F1R, AC3_STEREO):
986e461dc072 Initial revision
glantau
parents:
diff changeset
113 *level /= 1 + clev + slev * LEVEL_3DB;
986e461dc072 Initial revision
glantau
parents:
diff changeset
114 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
115
986e461dc072 Initial revision
glantau
parents:
diff changeset
116 case CONVERT (AC3_2F2R, AC3_MONO):
986e461dc072 Initial revision
glantau
parents:
diff changeset
117 *level *= LEVEL_3DB / (1 + slev);
986e461dc072 Initial revision
glantau
parents:
diff changeset
118 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
119
986e461dc072 Initial revision
glantau
parents:
diff changeset
120 case CONVERT (AC3_2F2R, AC3_STEREO):
986e461dc072 Initial revision
glantau
parents:
diff changeset
121 case CONVERT (AC3_3F2R, AC3_3F):
986e461dc072 Initial revision
glantau
parents:
diff changeset
122 *level /= (1 + slev);
986e461dc072 Initial revision
glantau
parents:
diff changeset
123 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
124
986e461dc072 Initial revision
glantau
parents:
diff changeset
125 case CONVERT (AC3_3F2R, AC3_MONO):
986e461dc072 Initial revision
glantau
parents:
diff changeset
126 *level *= LEVEL_3DB / (1 + clev + slev);
986e461dc072 Initial revision
glantau
parents:
diff changeset
127 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
128
986e461dc072 Initial revision
glantau
parents:
diff changeset
129 case CONVERT (AC3_3F2R, AC3_STEREO):
986e461dc072 Initial revision
glantau
parents:
diff changeset
130 *level /= 1 + clev + slev;
986e461dc072 Initial revision
glantau
parents:
diff changeset
131 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
132
986e461dc072 Initial revision
glantau
parents:
diff changeset
133 case CONVERT (AC3_MONO, AC3_DOLBY):
986e461dc072 Initial revision
glantau
parents:
diff changeset
134 *level *= LEVEL_PLUS3DB;
986e461dc072 Initial revision
glantau
parents:
diff changeset
135 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
136
986e461dc072 Initial revision
glantau
parents:
diff changeset
137 case CONVERT (AC3_3F, AC3_DOLBY):
986e461dc072 Initial revision
glantau
parents:
diff changeset
138 case CONVERT (AC3_2F1R, AC3_DOLBY):
986e461dc072 Initial revision
glantau
parents:
diff changeset
139 *level *= 1 / (1 + LEVEL_3DB);
986e461dc072 Initial revision
glantau
parents:
diff changeset
140 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
141
986e461dc072 Initial revision
glantau
parents:
diff changeset
142 case CONVERT (AC3_3F1R, AC3_DOLBY):
986e461dc072 Initial revision
glantau
parents:
diff changeset
143 case CONVERT (AC3_2F2R, AC3_DOLBY):
986e461dc072 Initial revision
glantau
parents:
diff changeset
144 *level *= 1 / (1 + 2 * LEVEL_3DB);
986e461dc072 Initial revision
glantau
parents:
diff changeset
145 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
146
986e461dc072 Initial revision
glantau
parents:
diff changeset
147 case CONVERT (AC3_3F2R, AC3_DOLBY):
986e461dc072 Initial revision
glantau
parents:
diff changeset
148 *level *= 1 / (1 + 3 * LEVEL_3DB);
986e461dc072 Initial revision
glantau
parents:
diff changeset
149 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
150 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
151
986e461dc072 Initial revision
glantau
parents:
diff changeset
152 return output;
986e461dc072 Initial revision
glantau
parents:
diff changeset
153 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
154
986e461dc072 Initial revision
glantau
parents:
diff changeset
155 static void mix1to1 (float * samples, float level, float bias)
986e461dc072 Initial revision
glantau
parents:
diff changeset
156 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
157 int i;
986e461dc072 Initial revision
glantau
parents:
diff changeset
158
986e461dc072 Initial revision
glantau
parents:
diff changeset
159 for (i = 0; i < 256; i++)
986e461dc072 Initial revision
glantau
parents:
diff changeset
160 samples[i] = samples[i] * level + bias;
986e461dc072 Initial revision
glantau
parents:
diff changeset
161 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
162
986e461dc072 Initial revision
glantau
parents:
diff changeset
163 static void move1to1 (float * src, float * dest, float level, float bias)
986e461dc072 Initial revision
glantau
parents:
diff changeset
164 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
165 int i;
986e461dc072 Initial revision
glantau
parents:
diff changeset
166
986e461dc072 Initial revision
glantau
parents:
diff changeset
167 for (i = 0; i < 256; i++)
986e461dc072 Initial revision
glantau
parents:
diff changeset
168 dest[i] = src[i] * level + bias;
986e461dc072 Initial revision
glantau
parents:
diff changeset
169 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
170
986e461dc072 Initial revision
glantau
parents:
diff changeset
171 static void mix2to1 (float * samples, float level, float bias)
986e461dc072 Initial revision
glantau
parents:
diff changeset
172 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
173 int i;
986e461dc072 Initial revision
glantau
parents:
diff changeset
174
986e461dc072 Initial revision
glantau
parents:
diff changeset
175 for (i = 0; i < 256; i++)
986e461dc072 Initial revision
glantau
parents:
diff changeset
176 samples[i] = (samples[i] + samples[i + 256]) * level + bias;
986e461dc072 Initial revision
glantau
parents:
diff changeset
177 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
178
986e461dc072 Initial revision
glantau
parents:
diff changeset
179 static void move2to1 (float * src, float * dest, float level, float bias)
986e461dc072 Initial revision
glantau
parents:
diff changeset
180 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
181 int i;
986e461dc072 Initial revision
glantau
parents:
diff changeset
182
986e461dc072 Initial revision
glantau
parents:
diff changeset
183 for (i = 0; i < 256; i++)
986e461dc072 Initial revision
glantau
parents:
diff changeset
184 dest[i] = (src[i] + src[i + 256]) * level + bias;
986e461dc072 Initial revision
glantau
parents:
diff changeset
185 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
186
986e461dc072 Initial revision
glantau
parents:
diff changeset
187 static void mix3to1 (float * samples, float level, float clev, float bias)
986e461dc072 Initial revision
glantau
parents:
diff changeset
188 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
189 int i;
986e461dc072 Initial revision
glantau
parents:
diff changeset
190
986e461dc072 Initial revision
glantau
parents:
diff changeset
191 for (i = 0; i < 256; i++)
986e461dc072 Initial revision
glantau
parents:
diff changeset
192 samples[i] = ((samples[i] + samples[i + 512]) * level +
986e461dc072 Initial revision
glantau
parents:
diff changeset
193 samples[i + 256] * clev + bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
194 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
195
986e461dc072 Initial revision
glantau
parents:
diff changeset
196 static void mix21to1 (float * samples, float level, float slev, float bias)
986e461dc072 Initial revision
glantau
parents:
diff changeset
197 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
198 int i;
986e461dc072 Initial revision
glantau
parents:
diff changeset
199
986e461dc072 Initial revision
glantau
parents:
diff changeset
200 for (i = 0; i < 256; i++)
986e461dc072 Initial revision
glantau
parents:
diff changeset
201 samples[i] = ((samples[i] + samples[i + 256]) * level +
986e461dc072 Initial revision
glantau
parents:
diff changeset
202 samples[i + 512] * slev + bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
203 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
204
986e461dc072 Initial revision
glantau
parents:
diff changeset
205 static void mix31to1 (float * samples, float level, float clev, float slev,
986e461dc072 Initial revision
glantau
parents:
diff changeset
206 float bias)
986e461dc072 Initial revision
glantau
parents:
diff changeset
207 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
208 int i;
986e461dc072 Initial revision
glantau
parents:
diff changeset
209
986e461dc072 Initial revision
glantau
parents:
diff changeset
210 for (i = 0; i < 256; i++)
986e461dc072 Initial revision
glantau
parents:
diff changeset
211 samples[i] = ((samples[i] + samples[i + 512]) * level +
986e461dc072 Initial revision
glantau
parents:
diff changeset
212 samples[i + 256] * clev + samples[i + 768] * slev +
986e461dc072 Initial revision
glantau
parents:
diff changeset
213 bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
214 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
215
986e461dc072 Initial revision
glantau
parents:
diff changeset
216 static void mix22to1 (float * samples, float level, float slev, float bias)
986e461dc072 Initial revision
glantau
parents:
diff changeset
217 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
218 int i;
986e461dc072 Initial revision
glantau
parents:
diff changeset
219
986e461dc072 Initial revision
glantau
parents:
diff changeset
220 for (i = 0; i < 256; i++)
986e461dc072 Initial revision
glantau
parents:
diff changeset
221 samples[i] = ((samples[i] + samples[i + 256]) * level +
986e461dc072 Initial revision
glantau
parents:
diff changeset
222 (samples[i + 512] + samples[i + 768]) * slev + bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
223 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
224
986e461dc072 Initial revision
glantau
parents:
diff changeset
225 static void mix32to1 (float * samples, float level, float clev, float slev,
986e461dc072 Initial revision
glantau
parents:
diff changeset
226 float bias)
986e461dc072 Initial revision
glantau
parents:
diff changeset
227 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
228 int i;
986e461dc072 Initial revision
glantau
parents:
diff changeset
229
986e461dc072 Initial revision
glantau
parents:
diff changeset
230 for (i = 0; i < 256; i++)
986e461dc072 Initial revision
glantau
parents:
diff changeset
231 samples[i] = ((samples[i] + samples[i + 512]) * level +
986e461dc072 Initial revision
glantau
parents:
diff changeset
232 samples[i + 256] * clev +
986e461dc072 Initial revision
glantau
parents:
diff changeset
233 (samples[i + 768] + samples[i + 1024]) * slev + bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
234 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
235
986e461dc072 Initial revision
glantau
parents:
diff changeset
236 static void mix1to2 (float * src, float * dest, float level, float bias)
986e461dc072 Initial revision
glantau
parents:
diff changeset
237 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
238 int i;
986e461dc072 Initial revision
glantau
parents:
diff changeset
239
986e461dc072 Initial revision
glantau
parents:
diff changeset
240 for (i = 0; i < 256; i++)
986e461dc072 Initial revision
glantau
parents:
diff changeset
241 dest[i] = src[i] = src[i] * level + bias;
986e461dc072 Initial revision
glantau
parents:
diff changeset
242 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
243
986e461dc072 Initial revision
glantau
parents:
diff changeset
244 static void mix3to2 (float * samples, float level, float clev, float bias)
986e461dc072 Initial revision
glantau
parents:
diff changeset
245 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
246 int i;
986e461dc072 Initial revision
glantau
parents:
diff changeset
247 float common;
986e461dc072 Initial revision
glantau
parents:
diff changeset
248
986e461dc072 Initial revision
glantau
parents:
diff changeset
249 for (i = 0; i < 256; i++) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
250 common = samples[i + 256] * clev + bias;
986e461dc072 Initial revision
glantau
parents:
diff changeset
251 samples[i] = samples[i] * level + common;
986e461dc072 Initial revision
glantau
parents:
diff changeset
252 samples[i + 256] = samples[i + 512] * level + common;
986e461dc072 Initial revision
glantau
parents:
diff changeset
253 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
254 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
255
986e461dc072 Initial revision
glantau
parents:
diff changeset
256 static void mix21to2 (float * left, float * right, float level, float slev,
986e461dc072 Initial revision
glantau
parents:
diff changeset
257 float bias)
986e461dc072 Initial revision
glantau
parents:
diff changeset
258 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
259 int i;
986e461dc072 Initial revision
glantau
parents:
diff changeset
260 float common;
986e461dc072 Initial revision
glantau
parents:
diff changeset
261
986e461dc072 Initial revision
glantau
parents:
diff changeset
262 for (i = 0; i < 256; i++) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
263 common = right[i + 256] * slev + bias;
986e461dc072 Initial revision
glantau
parents:
diff changeset
264 left[i] = left[i] * level + common;
986e461dc072 Initial revision
glantau
parents:
diff changeset
265 right[i] = right[i] * level + common;
986e461dc072 Initial revision
glantau
parents:
diff changeset
266 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
267 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
268
986e461dc072 Initial revision
glantau
parents:
diff changeset
269 static void mix11to1 (float * front, float * rear, float level, float slev,
986e461dc072 Initial revision
glantau
parents:
diff changeset
270 float bias)
986e461dc072 Initial revision
glantau
parents:
diff changeset
271 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
272 int i;
986e461dc072 Initial revision
glantau
parents:
diff changeset
273
986e461dc072 Initial revision
glantau
parents:
diff changeset
274 for (i = 0; i < 256; i++)
986e461dc072 Initial revision
glantau
parents:
diff changeset
275 front[i] = front[i] * level + rear[i] * slev + bias;
986e461dc072 Initial revision
glantau
parents:
diff changeset
276 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
277
986e461dc072 Initial revision
glantau
parents:
diff changeset
278 static void mix31to2 (float * samples, float level, float clev, float slev,
986e461dc072 Initial revision
glantau
parents:
diff changeset
279 float bias)
986e461dc072 Initial revision
glantau
parents:
diff changeset
280 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
281 int i;
986e461dc072 Initial revision
glantau
parents:
diff changeset
282 float common;
986e461dc072 Initial revision
glantau
parents:
diff changeset
283
986e461dc072 Initial revision
glantau
parents:
diff changeset
284 for (i = 0; i < 256; i++) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
285 common = samples[i + 256] * clev + samples[i + 768] * slev + bias;
986e461dc072 Initial revision
glantau
parents:
diff changeset
286 samples[i] = samples[i] * level + common;
986e461dc072 Initial revision
glantau
parents:
diff changeset
287 samples[i + 256] = samples[i + 512] * level + common;
986e461dc072 Initial revision
glantau
parents:
diff changeset
288 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
289 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
290
986e461dc072 Initial revision
glantau
parents:
diff changeset
291 static void mix32to2 (float * samples, float level, float clev, float slev,
986e461dc072 Initial revision
glantau
parents:
diff changeset
292 float bias)
986e461dc072 Initial revision
glantau
parents:
diff changeset
293 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
294 int i;
986e461dc072 Initial revision
glantau
parents:
diff changeset
295 float common;
986e461dc072 Initial revision
glantau
parents:
diff changeset
296
986e461dc072 Initial revision
glantau
parents:
diff changeset
297 for (i = 0; i < 256; i++) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
298 common = samples[i + 256] * clev + bias;
986e461dc072 Initial revision
glantau
parents:
diff changeset
299 samples[i] = samples[i] * level + common + samples[i + 768] * slev;
986e461dc072 Initial revision
glantau
parents:
diff changeset
300 samples[i + 256] = (samples[i + 512] * level + common +
986e461dc072 Initial revision
glantau
parents:
diff changeset
301 samples[i + 1024] * slev);
986e461dc072 Initial revision
glantau
parents:
diff changeset
302 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
303 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
304
986e461dc072 Initial revision
glantau
parents:
diff changeset
305 static void mix21toS (float * samples, float level, float level3db, float bias)
986e461dc072 Initial revision
glantau
parents:
diff changeset
306 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
307 int i;
986e461dc072 Initial revision
glantau
parents:
diff changeset
308 float surround;
986e461dc072 Initial revision
glantau
parents:
diff changeset
309
986e461dc072 Initial revision
glantau
parents:
diff changeset
310 for (i = 0; i < 256; i++) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
311 surround = samples[i + 512] * level3db;
986e461dc072 Initial revision
glantau
parents:
diff changeset
312 samples[i] = samples[i] * level - surround + bias;
986e461dc072 Initial revision
glantau
parents:
diff changeset
313 samples[i + 256] = samples[i + 256] * level + surround + bias;
986e461dc072 Initial revision
glantau
parents:
diff changeset
314 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
315 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
316
986e461dc072 Initial revision
glantau
parents:
diff changeset
317 static void mix22toS (float * samples, float level, float level3db, float bias)
986e461dc072 Initial revision
glantau
parents:
diff changeset
318 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
319 int i;
986e461dc072 Initial revision
glantau
parents:
diff changeset
320 float surround;
986e461dc072 Initial revision
glantau
parents:
diff changeset
321
986e461dc072 Initial revision
glantau
parents:
diff changeset
322 for (i = 0; i < 256; i++) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
323 surround = (samples[i + 512] + samples[i + 768]) * level3db;
986e461dc072 Initial revision
glantau
parents:
diff changeset
324 samples[i] = samples[i] * level - surround + bias;
986e461dc072 Initial revision
glantau
parents:
diff changeset
325 samples[i + 256] = samples[i + 256] * level + surround + bias;
986e461dc072 Initial revision
glantau
parents:
diff changeset
326 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
327 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
328
986e461dc072 Initial revision
glantau
parents:
diff changeset
329 static void mix31toS (float * samples, float level, float level3db, float bias)
986e461dc072 Initial revision
glantau
parents:
diff changeset
330 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
331 int i;
986e461dc072 Initial revision
glantau
parents:
diff changeset
332 float common, surround;
986e461dc072 Initial revision
glantau
parents:
diff changeset
333
986e461dc072 Initial revision
glantau
parents:
diff changeset
334 for (i = 0; i < 256; i++) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
335 common = samples[i + 256] * level3db + bias;
986e461dc072 Initial revision
glantau
parents:
diff changeset
336 surround = samples[i + 768] * level3db;
986e461dc072 Initial revision
glantau
parents:
diff changeset
337 samples[i] = samples[i] * level + common - surround;
986e461dc072 Initial revision
glantau
parents:
diff changeset
338 samples[i + 256] = samples[i + 512] * level + common + surround;
986e461dc072 Initial revision
glantau
parents:
diff changeset
339 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
340 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
341
986e461dc072 Initial revision
glantau
parents:
diff changeset
342 static void mix32toS (float * samples, float level, float level3db, float bias)
986e461dc072 Initial revision
glantau
parents:
diff changeset
343 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
344 int i;
986e461dc072 Initial revision
glantau
parents:
diff changeset
345 float common, surround;
986e461dc072 Initial revision
glantau
parents:
diff changeset
346
986e461dc072 Initial revision
glantau
parents:
diff changeset
347 for (i = 0; i < 256; i++) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
348 common = samples[i + 256] * level3db + bias;
986e461dc072 Initial revision
glantau
parents:
diff changeset
349 surround = (samples[i + 768] + samples[i + 1024]) * level3db;
986e461dc072 Initial revision
glantau
parents:
diff changeset
350 samples[i] = samples[i] * level + common - surround;
986e461dc072 Initial revision
glantau
parents:
diff changeset
351 samples[i + 256] = samples[i + 512] * level + common + surround;
986e461dc072 Initial revision
glantau
parents:
diff changeset
352 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
353 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
354
986e461dc072 Initial revision
glantau
parents:
diff changeset
355 void downmix (float * samples, int acmod, int output, float level, float bias,
986e461dc072 Initial revision
glantau
parents:
diff changeset
356 float clev, float slev)
986e461dc072 Initial revision
glantau
parents:
diff changeset
357 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
358 switch (CONVERT (acmod, output & AC3_CHANNEL_MASK)) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
359
986e461dc072 Initial revision
glantau
parents:
diff changeset
360 case CONVERT (AC3_3F2R, AC3_3F2R):
986e461dc072 Initial revision
glantau
parents:
diff changeset
361 mix1to1 (samples + 1024, level, bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
362 case CONVERT (AC3_3F1R, AC3_3F1R):
986e461dc072 Initial revision
glantau
parents:
diff changeset
363 case CONVERT (AC3_2F2R, AC3_2F2R):
986e461dc072 Initial revision
glantau
parents:
diff changeset
364 mix1to1 (samples + 768, level, bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
365 case CONVERT (AC3_3F, AC3_3F):
986e461dc072 Initial revision
glantau
parents:
diff changeset
366 case CONVERT (AC3_2F1R, AC3_2F1R):
986e461dc072 Initial revision
glantau
parents:
diff changeset
367 mix_3to3:
986e461dc072 Initial revision
glantau
parents:
diff changeset
368 mix1to1 (samples + 512, level, bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
369 case CONVERT (AC3_CHANNEL, AC3_CHANNEL):
986e461dc072 Initial revision
glantau
parents:
diff changeset
370 case CONVERT (AC3_STEREO, AC3_STEREO):
986e461dc072 Initial revision
glantau
parents:
diff changeset
371 case CONVERT (AC3_STEREO, AC3_DOLBY):
986e461dc072 Initial revision
glantau
parents:
diff changeset
372 mix_2to2:
986e461dc072 Initial revision
glantau
parents:
diff changeset
373 mix1to1 (samples + 256, level, bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
374 case CONVERT (AC3_CHANNEL, AC3_CHANNEL1):
986e461dc072 Initial revision
glantau
parents:
diff changeset
375 case CONVERT (AC3_MONO, AC3_MONO):
986e461dc072 Initial revision
glantau
parents:
diff changeset
376 mix1to1 (samples, level, bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
377 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
378
986e461dc072 Initial revision
glantau
parents:
diff changeset
379 case CONVERT (AC3_CHANNEL, AC3_CHANNEL2):
986e461dc072 Initial revision
glantau
parents:
diff changeset
380 mix_1to1_b:
986e461dc072 Initial revision
glantau
parents:
diff changeset
381 mix1to1 (samples + 256, level, bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
382 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
383
986e461dc072 Initial revision
glantau
parents:
diff changeset
384 case CONVERT (AC3_STEREO, AC3_MONO):
986e461dc072 Initial revision
glantau
parents:
diff changeset
385 mix_2to1:
986e461dc072 Initial revision
glantau
parents:
diff changeset
386 mix2to1 (samples, level * LEVEL_3DB, bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
387 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
388
986e461dc072 Initial revision
glantau
parents:
diff changeset
389 case CONVERT (AC3_2F1R, AC3_MONO):
986e461dc072 Initial revision
glantau
parents:
diff changeset
390 if (slev == 0)
986e461dc072 Initial revision
glantau
parents:
diff changeset
391 goto mix_2to1;
986e461dc072 Initial revision
glantau
parents:
diff changeset
392 mix21to1 (samples, level * LEVEL_3DB, level * slev * LEVEL_3DB, bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
393 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
394
986e461dc072 Initial revision
glantau
parents:
diff changeset
395 case CONVERT (AC3_2F2R, AC3_MONO):
986e461dc072 Initial revision
glantau
parents:
diff changeset
396 if (slev == 0)
986e461dc072 Initial revision
glantau
parents:
diff changeset
397 goto mix_2to1;
986e461dc072 Initial revision
glantau
parents:
diff changeset
398 mix22to1 (samples, level * LEVEL_3DB, level * slev * LEVEL_3DB, bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
399 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
400
986e461dc072 Initial revision
glantau
parents:
diff changeset
401 case CONVERT (AC3_3F, AC3_MONO):
986e461dc072 Initial revision
glantau
parents:
diff changeset
402 mix_3to1:
986e461dc072 Initial revision
glantau
parents:
diff changeset
403 mix3to1 (samples, level * LEVEL_3DB, level * clev * LEVEL_PLUS3DB,
986e461dc072 Initial revision
glantau
parents:
diff changeset
404 bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
405 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
406
986e461dc072 Initial revision
glantau
parents:
diff changeset
407 case CONVERT (AC3_3F1R, AC3_MONO):
986e461dc072 Initial revision
glantau
parents:
diff changeset
408 if (slev == 0)
986e461dc072 Initial revision
glantau
parents:
diff changeset
409 goto mix_3to1;
986e461dc072 Initial revision
glantau
parents:
diff changeset
410 mix31to1 (samples, level * LEVEL_3DB, level * clev * LEVEL_PLUS3DB,
986e461dc072 Initial revision
glantau
parents:
diff changeset
411 level * slev * LEVEL_3DB, bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
412 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
413
986e461dc072 Initial revision
glantau
parents:
diff changeset
414 case CONVERT (AC3_3F2R, AC3_MONO):
986e461dc072 Initial revision
glantau
parents:
diff changeset
415 if (slev == 0)
986e461dc072 Initial revision
glantau
parents:
diff changeset
416 goto mix_3to1;
986e461dc072 Initial revision
glantau
parents:
diff changeset
417 mix32to1 (samples, level * LEVEL_3DB, level * clev * LEVEL_PLUS3DB,
986e461dc072 Initial revision
glantau
parents:
diff changeset
418 level * slev * LEVEL_3DB, bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
419 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
420
986e461dc072 Initial revision
glantau
parents:
diff changeset
421 case CONVERT (AC3_CHANNEL, AC3_MONO):
986e461dc072 Initial revision
glantau
parents:
diff changeset
422 mix2to1 (samples, level * LEVEL_6DB, bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
423 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
424
986e461dc072 Initial revision
glantau
parents:
diff changeset
425 case CONVERT (AC3_MONO, AC3_DOLBY):
986e461dc072 Initial revision
glantau
parents:
diff changeset
426 mix1to2 (samples, samples + 256, level * LEVEL_3DB, bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
427 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
428
986e461dc072 Initial revision
glantau
parents:
diff changeset
429 case CONVERT (AC3_3F, AC3_DOLBY):
986e461dc072 Initial revision
glantau
parents:
diff changeset
430 clev = LEVEL_3DB;
986e461dc072 Initial revision
glantau
parents:
diff changeset
431 case CONVERT (AC3_3F, AC3_STEREO):
986e461dc072 Initial revision
glantau
parents:
diff changeset
432 mix_3to2:
986e461dc072 Initial revision
glantau
parents:
diff changeset
433 mix3to2 (samples, level, level * clev, bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
434 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
435
986e461dc072 Initial revision
glantau
parents:
diff changeset
436 case CONVERT (AC3_2F1R, AC3_DOLBY):
986e461dc072 Initial revision
glantau
parents:
diff changeset
437 mix21toS (samples, level, level * LEVEL_3DB, bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
438 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
439
986e461dc072 Initial revision
glantau
parents:
diff changeset
440 case CONVERT (AC3_3F1R, AC3_DOLBY):
986e461dc072 Initial revision
glantau
parents:
diff changeset
441 mix31toS (samples, level, level * LEVEL_3DB, bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
442 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
443
986e461dc072 Initial revision
glantau
parents:
diff changeset
444 case CONVERT (AC3_2F2R, AC3_DOLBY):
986e461dc072 Initial revision
glantau
parents:
diff changeset
445 mix22toS (samples, level, level * LEVEL_3DB, bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
446 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
447
986e461dc072 Initial revision
glantau
parents:
diff changeset
448 case CONVERT (AC3_3F2R, AC3_DOLBY):
986e461dc072 Initial revision
glantau
parents:
diff changeset
449 mix32toS (samples, level, level * LEVEL_3DB, bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
450 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
451
986e461dc072 Initial revision
glantau
parents:
diff changeset
452 case CONVERT (AC3_2F1R, AC3_STEREO):
986e461dc072 Initial revision
glantau
parents:
diff changeset
453 if (slev == 0)
986e461dc072 Initial revision
glantau
parents:
diff changeset
454 goto mix_2to2;
986e461dc072 Initial revision
glantau
parents:
diff changeset
455 mix21to2 (samples, samples + 256, level, level * slev * LEVEL_3DB,
986e461dc072 Initial revision
glantau
parents:
diff changeset
456 bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
457 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
458
986e461dc072 Initial revision
glantau
parents:
diff changeset
459 case CONVERT (AC3_3F1R, AC3_STEREO):
986e461dc072 Initial revision
glantau
parents:
diff changeset
460 if (slev == 0)
986e461dc072 Initial revision
glantau
parents:
diff changeset
461 goto mix_3to2;
986e461dc072 Initial revision
glantau
parents:
diff changeset
462 mix31to2 (samples, level, level * clev, level * slev * LEVEL_3DB,
986e461dc072 Initial revision
glantau
parents:
diff changeset
463 bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
464 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
465
986e461dc072 Initial revision
glantau
parents:
diff changeset
466 case CONVERT (AC3_2F2R, AC3_STEREO):
986e461dc072 Initial revision
glantau
parents:
diff changeset
467 if (slev == 0)
986e461dc072 Initial revision
glantau
parents:
diff changeset
468 goto mix_2to2;
986e461dc072 Initial revision
glantau
parents:
diff changeset
469 mix11to1 (samples, samples + 512, level, level * slev, bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
470 mix11to1 (samples + 256, samples + 768, level, level * slev, bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
471 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
472
986e461dc072 Initial revision
glantau
parents:
diff changeset
473 case CONVERT (AC3_3F2R, AC3_STEREO):
986e461dc072 Initial revision
glantau
parents:
diff changeset
474 if (slev == 0)
986e461dc072 Initial revision
glantau
parents:
diff changeset
475 goto mix_3to2;
986e461dc072 Initial revision
glantau
parents:
diff changeset
476 mix32to2 (samples, level, level * clev, level * slev, bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
477 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
478
986e461dc072 Initial revision
glantau
parents:
diff changeset
479 case CONVERT (AC3_3F1R, AC3_3F):
986e461dc072 Initial revision
glantau
parents:
diff changeset
480 if (slev == 0)
986e461dc072 Initial revision
glantau
parents:
diff changeset
481 goto mix_3to3;
986e461dc072 Initial revision
glantau
parents:
diff changeset
482 mix21to2 (samples, samples + 512, level, level * slev * LEVEL_3DB,
986e461dc072 Initial revision
glantau
parents:
diff changeset
483 bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
484
986e461dc072 Initial revision
glantau
parents:
diff changeset
485 case CONVERT (AC3_3F2R, AC3_3F):
986e461dc072 Initial revision
glantau
parents:
diff changeset
486 if (slev == 0)
986e461dc072 Initial revision
glantau
parents:
diff changeset
487 goto mix_3to3;
986e461dc072 Initial revision
glantau
parents:
diff changeset
488 mix11to1 (samples, samples + 768, level, level * slev, bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
489 mix11to1 (samples + 512, samples + 1024, level, level * slev, bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
490 goto mix_1to1_b;
986e461dc072 Initial revision
glantau
parents:
diff changeset
491
986e461dc072 Initial revision
glantau
parents:
diff changeset
492 case CONVERT (AC3_2F1R, AC3_2F2R):
986e461dc072 Initial revision
glantau
parents:
diff changeset
493 mix1to2 (samples + 512, samples + 768, level * LEVEL_3DB, bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
494 goto mix_2to2;
986e461dc072 Initial revision
glantau
parents:
diff changeset
495
986e461dc072 Initial revision
glantau
parents:
diff changeset
496 case CONVERT (AC3_3F1R, AC3_3F2R):
986e461dc072 Initial revision
glantau
parents:
diff changeset
497 mix1to2 (samples + 768, samples + 1024, level * LEVEL_3DB, bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
498 goto mix_3to3;
986e461dc072 Initial revision
glantau
parents:
diff changeset
499
986e461dc072 Initial revision
glantau
parents:
diff changeset
500 case CONVERT (AC3_2F2R, AC3_2F1R):
986e461dc072 Initial revision
glantau
parents:
diff changeset
501 mix2to1 (samples + 512, level * LEVEL_3DB, bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
502 goto mix_2to2;
986e461dc072 Initial revision
glantau
parents:
diff changeset
503
986e461dc072 Initial revision
glantau
parents:
diff changeset
504 case CONVERT (AC3_3F2R, AC3_3F1R):
986e461dc072 Initial revision
glantau
parents:
diff changeset
505 mix2to1 (samples + 768, level * LEVEL_3DB, bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
506 goto mix_3to3;
986e461dc072 Initial revision
glantau
parents:
diff changeset
507
986e461dc072 Initial revision
glantau
parents:
diff changeset
508 case CONVERT (AC3_3F1R, AC3_2F2R):
986e461dc072 Initial revision
glantau
parents:
diff changeset
509 mix3to2 (samples, level, level * clev, bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
510 mix1to2 (samples + 768, samples + 512, level * LEVEL_3DB, bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
511 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
512
986e461dc072 Initial revision
glantau
parents:
diff changeset
513 case CONVERT (AC3_3F1R, AC3_2F1R):
986e461dc072 Initial revision
glantau
parents:
diff changeset
514 mix3to2 (samples, level, level * clev, bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
515 move1to1 (samples + 768, samples + 512, level, bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
516 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
517
986e461dc072 Initial revision
glantau
parents:
diff changeset
518 case CONVERT (AC3_3F2R, AC3_2F1R):
986e461dc072 Initial revision
glantau
parents:
diff changeset
519 mix3to2 (samples, level, level * clev, bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
520 move2to1 (samples + 768, samples + 512, level * LEVEL_3DB, bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
521 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
522
986e461dc072 Initial revision
glantau
parents:
diff changeset
523 case CONVERT (AC3_3F2R, AC3_2F2R):
986e461dc072 Initial revision
glantau
parents:
diff changeset
524 mix3to2 (samples, level, level * clev, bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
525 move1to1 (samples + 768, samples + 512, level, bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
526 move1to1 (samples + 1024, samples + 768, level, bias);
986e461dc072 Initial revision
glantau
parents:
diff changeset
527 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
528
986e461dc072 Initial revision
glantau
parents:
diff changeset
529 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
530 }