annotate liba52/downmix.c @ 579:ba17f7dbe745 libavcodec

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