r726: Implementing ability to add textural info to the labels
[cinelerra_cv/mob.git] / libmpeg3 / audio / layer2.c
blob07675c1754f301ec3170957e4f8cab4b93ff934c
1 /*
2 * most other tables are calculated on program start (which is (of course)
3 * not ISO-conform) ..
4 * Layer-3 huffman table is in huffman.h
5 */
7 #include "mpeg3private.h"
8 #include "mpeg3protos.h"
9 #include "tables.h"
11 static struct al_table alloc_0[] = {
12 {4,0},{5,3},{3,-3},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},{9,-255},{10,-511},
13 {11,-1023},{12,-2047},{13,-4095},{14,-8191},{15,-16383},{16,-32767},
14 {4,0},{5,3},{3,-3},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},{9,-255},{10,-511},
15 {11,-1023},{12,-2047},{13,-4095},{14,-8191},{15,-16383},{16,-32767},
16 {4,0},{5,3},{3,-3},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},{9,-255},{10,-511},
17 {11,-1023},{12,-2047},{13,-4095},{14,-8191},{15,-16383},{16,-32767},
18 {4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},
19 {9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767},
20 {4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},
21 {9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767},
22 {4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},
23 {9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767},
24 {4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},
25 {9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767},
26 {4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},
27 {9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767},
28 {4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},
29 {9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767},
30 {4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},
31 {9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767},
32 {4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},
33 {9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767},
34 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
35 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
36 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
37 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
38 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
39 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
40 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
41 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
42 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
43 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
44 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
45 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
46 {2,0},{5,3},{7,5},{16,-32767},
47 {2,0},{5,3},{7,5},{16,-32767},
48 {2,0},{5,3},{7,5},{16,-32767},
49 {2,0},{5,3},{7,5},{16,-32767} };
51 static struct al_table alloc_1[] = {
52 {4,0},{5,3},{3,-3},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},{9,-255},{10,-511},
53 {11,-1023},{12,-2047},{13,-4095},{14,-8191},{15,-16383},{16,-32767},
54 {4,0},{5,3},{3,-3},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},{9,-255},{10,-511},
55 {11,-1023},{12,-2047},{13,-4095},{14,-8191},{15,-16383},{16,-32767},
56 {4,0},{5,3},{3,-3},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},{9,-255},{10,-511},
57 {11,-1023},{12,-2047},{13,-4095},{14,-8191},{15,-16383},{16,-32767},
58 {4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},
59 {9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767},
60 {4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},
61 {9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767},
62 {4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},
63 {9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767},
64 {4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},
65 {9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767},
66 {4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},
67 {9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767},
68 {4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},
69 {9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767},
70 {4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},
71 {9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767},
72 {4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},
73 {9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767},
74 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
75 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
76 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
77 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
78 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
79 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
80 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
81 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
82 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
83 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
84 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
85 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
86 {2,0},{5,3},{7,5},{16,-32767},
87 {2,0},{5,3},{7,5},{16,-32767},
88 {2,0},{5,3},{7,5},{16,-32767},
89 {2,0},{5,3},{7,5},{16,-32767},
90 {2,0},{5,3},{7,5},{16,-32767},
91 {2,0},{5,3},{7,5},{16,-32767},
92 {2,0},{5,3},{7,5},{16,-32767} };
94 static struct al_table alloc_2[] = {
95 {4,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},{9,-255},
96 {10,-511},{11,-1023},{12,-2047},{13,-4095},{14,-8191},{15,-16383},
97 {4,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},{9,-255},
98 {10,-511},{11,-1023},{12,-2047},{13,-4095},{14,-8191},{15,-16383},
99 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
100 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
101 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
102 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
103 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
104 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63} };
106 static struct al_table alloc_3[] = {
107 {4,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},{9,-255},
108 {10,-511},{11,-1023},{12,-2047},{13,-4095},{14,-8191},{15,-16383},
109 {4,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},{9,-255},
110 {10,-511},{11,-1023},{12,-2047},{13,-4095},{14,-8191},{15,-16383},
111 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
112 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
113 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
114 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
115 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
116 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
117 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
118 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
119 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
120 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63} };
122 static struct al_table alloc_4[] = {
123 {4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},
124 {9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{14,-8191},
125 {4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},
126 {9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{14,-8191},
127 {4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},
128 {9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{14,-8191},
129 {4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},
130 {9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{14,-8191},
131 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
132 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
133 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
134 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
135 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
136 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
137 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
138 {2,0},{5,3},{7,5},{10,9},
139 {2,0},{5,3},{7,5},{10,9},
140 {2,0},{5,3},{7,5},{10,9},
141 {2,0},{5,3},{7,5},{10,9},
142 {2,0},{5,3},{7,5},{10,9},
143 {2,0},{5,3},{7,5},{10,9},
144 {2,0},{5,3},{7,5},{10,9},
145 {2,0},{5,3},{7,5},{10,9},
146 {2,0},{5,3},{7,5},{10,9},
147 {2,0},{5,3},{7,5},{10,9},
148 {2,0},{5,3},{7,5},{10,9},
149 {2,0},{5,3},{7,5},{10,9},
150 {2,0},{5,3},{7,5},{10,9},
151 {2,0},{5,3},{7,5},{10,9},
152 {2,0},{5,3},{7,5},{10,9},
153 {2,0},{5,3},{7,5},{10,9},
154 {2,0},{5,3},{7,5},{10,9},
155 {2,0},{5,3},{7,5},{10,9},
156 {2,0},{5,3},{7,5},{10,9} };
159 static int select_table(mpeg3_layer_t *audio)
161 static int translate[3][2][16] =
162 {{{ 0,2,2,2,2,2,2,0,0,0,1,1,1,1,1,0},
163 { 0,2,2,0,0,0,1,1,1,1,1,1,1,1,1,0}},
164 {{ 0,2,2,2,2,2,2,0,0,0,0,0,0,0,0,0},
165 { 0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0}},
166 {{ 0,3,3,3,3,3,3,0,0,0,1,1,1,1,1,0},
167 { 0,3,3,0,0,0,1,1,1,1,1,1,1,1,1,0}}};
168 int table, sblim;
169 static struct al_table *tables[5] =
170 {alloc_0, alloc_1, alloc_2, alloc_3, alloc_4};
171 static int sblims[5] = {27, 30, 8, 12, 30};
173 if(audio->lsf)
174 table = 4;
175 else
176 table = translate[audio->sampling_frequency_code][2 - audio->channels][audio->bitrate_index];
177 sblim = sblims[table];
179 audio->alloc = tables[table];
180 audio->II_sblimit = sblim;
181 return 0;
184 static int step_one(mpeg3_layer_t *audio, unsigned int *bit_alloc, int *scale)
186 int stereo = audio->channels - 1;
187 int sblimit = audio->II_sblimit;
188 int jsbound = audio->jsbound;
189 int sblimit2 = audio->II_sblimit << stereo;
190 struct al_table *alloc1 = audio->alloc;
191 int i, result = 0;
192 unsigned int *scfsi_buf = audio->layer2_scfsi_buf;
193 unsigned int *scfsi, *bita;
194 int sc, step;
196 bita = bit_alloc;
197 if(stereo)
199 /* Stereo */
200 for(i = jsbound; i; i--, alloc1 += (1 << step))
202 *bita++ = (char)mpeg3bits_getbits(audio->stream, step = alloc1->bits);
203 *bita++ = (char)mpeg3bits_getbits(audio->stream, step);
205 for(i = sblimit - jsbound; i; i--, alloc1 += (1 << step))
207 bita[0] = (char)mpeg3bits_getbits(audio->stream, step = alloc1->bits);
208 bita[1] = bita[0];
209 bita += 2;
211 bita = bit_alloc;
212 scfsi = scfsi_buf;
213 for(i = sblimit2; i; i--)
214 if(*bita++) *scfsi++ = (char)mpeg3bits_getbits(audio->stream, 2);
216 else
218 /* mono */
219 for(i = sblimit; i; i--, alloc1 += (1 << step))
220 *bita++ = (char)mpeg3bits_getbits(audio->stream, step = alloc1->bits);
222 bita = bit_alloc;
223 scfsi = scfsi_buf;
224 for(i = sblimit; i; i--) if (*bita++) *scfsi++ = (char)mpeg3bits_getbits(audio->stream, 2);
227 bita = bit_alloc;
228 scfsi = scfsi_buf;
229 for(i = sblimit2; i; i--)
231 if(*bita++)
232 switch(*scfsi++)
234 case 0:
235 *scale++ = mpeg3bits_getbits(audio->stream, 6);
236 *scale++ = mpeg3bits_getbits(audio->stream, 6);
237 *scale++ = mpeg3bits_getbits(audio->stream, 6);
238 break;
239 case 1 :
240 *scale++ = sc = mpeg3bits_getbits(audio->stream, 6);
241 *scale++ = sc;
242 *scale++ = mpeg3bits_getbits(audio->stream, 6);
243 break;
244 case 2:
245 *scale++ = sc = mpeg3bits_getbits(audio->stream, 6);
246 *scale++ = sc;
247 *scale++ = sc;
248 break;
249 default: /* case 3 */
250 *scale++ = mpeg3bits_getbits(audio->stream, 6);
251 *scale++ = sc = mpeg3bits_getbits(audio->stream, 6);
252 *scale++ = sc;
253 break;
256 return result;
259 static int step_two(mpeg3_layer_t *audio, unsigned int *bit_alloc, float fraction[2][4][SBLIMIT], int *scale, int x1)
261 int i, j, k, ba, result = 0;
262 int channels = audio->channels;
263 int sblimit = audio->II_sblimit;
264 int jsbound = audio->jsbound;
265 struct al_table *alloc2, *alloc1 = audio->alloc;
266 unsigned int *bita = bit_alloc;
267 int d1, step, test;
269 for(i = 0; i < jsbound; i++, alloc1 += (1 << step))
271 step = alloc1->bits;
272 for(j = 0; j < channels; j++)
274 if(ba = *bita++)
276 k = (alloc2 = alloc1 + ba)->bits;
277 if((d1 = alloc2->d) < 0)
279 float cm = mpeg3_muls[k][scale[x1]];
281 fraction[j][0][i] = ((float)((int)mpeg3bits_getbits(audio->stream, k) + d1)) * cm;
282 fraction[j][1][i] = ((float)((int)mpeg3bits_getbits(audio->stream, k) + d1)) * cm;
283 fraction[j][2][i] = ((float)((int)mpeg3bits_getbits(audio->stream, k) + d1)) * cm;
285 else
287 static int *table[] =
288 {0, 0, 0, mpeg3_grp_3tab, 0, mpeg3_grp_5tab, 0, 0, 0, mpeg3_grp_9tab};
289 unsigned int idx, *tab, m = scale[x1];
291 idx = (unsigned int)mpeg3bits_getbits(audio->stream, k);
292 tab = (unsigned int*)(table[d1] + idx + idx + idx);
293 fraction[j][0][i] = mpeg3_muls[*tab++][m];
294 fraction[j][1][i] = mpeg3_muls[*tab++][m];
295 fraction[j][2][i] = mpeg3_muls[*tab][m];
297 scale += 3;
299 else
300 fraction[j][0][i] = fraction[j][1][i] = fraction[j][2][i] = 0.0;
304 for(i = jsbound; i < sblimit; i++, alloc1 += (1 << step))
306 step = alloc1->bits;
307 /* channel 1 and channel 2 bitalloc are the same */
308 bita++;
309 if((ba = *bita++))
311 k=(alloc2 = alloc1+ba)->bits;
312 if((d1 = alloc2->d) < 0)
314 float cm;
316 cm = mpeg3_muls[k][scale[x1 + 3]];
317 fraction[1][0][i] = (fraction[0][0][i] = (float)((int)mpeg3bits_getbits(audio->stream, k) + d1)) * cm;
318 fraction[1][1][i] = (fraction[0][1][i] = (float)((int)mpeg3bits_getbits(audio->stream, k) + d1)) * cm;
319 fraction[1][2][i] = (fraction[0][2][i] = (float)((int)mpeg3bits_getbits(audio->stream, k) + d1)) * cm;
320 cm = mpeg3_muls[k][scale[x1]];
321 fraction[0][0][i] *= cm;
322 fraction[0][1][i] *= cm;
323 fraction[0][2][i] *= cm;
325 else
327 static int *table[] = {0, 0, 0, mpeg3_grp_3tab, 0, mpeg3_grp_5tab, 0, 0, 0, mpeg3_grp_9tab};
328 unsigned int idx, *tab, m1, m2;
330 m1 = scale[x1];
331 m2 = scale[x1+3];
332 idx = (unsigned int)mpeg3bits_getbits(audio->stream, k);
333 tab = (unsigned int*)(table[d1] + idx + idx + idx);
334 fraction[0][0][i] = mpeg3_muls[*tab][m1];
335 fraction[1][0][i] = mpeg3_muls[*tab++][m2];
336 fraction[0][1][i] = mpeg3_muls[*tab][m1];
337 fraction[1][1][i] = mpeg3_muls[*tab++][m2];
338 fraction[0][2][i] = mpeg3_muls[*tab][m1];
339 fraction[1][2][i] = mpeg3_muls[*tab][m2];
341 scale += 6;
343 else
345 fraction[0][0][i] = fraction[0][1][i] = fraction[0][2][i] =
346 fraction[1][0][i] = fraction[1][1][i] = fraction[1][2][i] = 0.0;
349 should we use individual scalefac for channel 2 or
350 is the current way the right one , where we just copy channel 1 to
351 channel 2 ??
352 The current 'strange' thing is, that we throw away the scalefac
353 values for the second channel ...!!
354 -> changed .. now we use the scalefac values of channel one !!
358 if(sblimit > SBLIMIT) sblimit = SBLIMIT;
360 for(i = sblimit; i < SBLIMIT; i++)
361 for(j = 0; j < channels; j++)
362 fraction[j][0][i] = fraction[j][1][i] = fraction[j][2][i] = 0.0;
364 return result;
367 int mpeg3audio_dolayer2(mpeg3_layer_t *audio,
368 char *frame,
369 int frame_size,
370 float **output,
371 int render)
373 int i, j, result = 0;
374 int channels = audio->channels;
375 float fraction[2][4][SBLIMIT]; /* pick_table clears unused subbands */
376 unsigned int bit_alloc[64];
377 int scale[192];
378 int single = audio->single;
379 int output_position = 0;
382 frame += 4;
383 /* Set up bitstream to use buffer */
384 mpeg3bits_use_ptr(audio->stream, frame);
388 if(audio->error_protection)
389 mpeg3bits_getbits(audio->stream, 16);
391 select_table(audio);
393 audio->jsbound = (audio->mode == MPG_MD_JOINT_STEREO) ?
394 (audio->mode_ext << 2) + 4 : audio->II_sblimit;
396 if(channels == 1 || single == 3)
397 single = 0;
399 result |= step_one(audio, bit_alloc, scale);
401 for(i = 0; i < SCALE_BLOCK && !result; i++)
403 result |= step_two(audio, bit_alloc, fraction, scale, i >> 2);
405 for(j = 0; j < 3; j++)
407 if(single >= 0)
409 /* Monaural */
410 if(render)
411 mpeg3audio_synth_stereo(audio,
412 fraction[0][j],
414 output[0],
415 &(output_position));
416 else
417 output_position += 32;
419 else
421 /* Stereo */
422 int p1 = output_position;
423 if(render)
425 //printf(__FUNCTION__ " 3\n");
426 mpeg3audio_synth_stereo(audio,
427 fraction[0][j],
429 output[0],
430 &p1);
431 //printf(__FUNCTION__ " 4\n");
432 mpeg3audio_synth_stereo(audio,
433 fraction[1][j],
435 output[1],
436 &(output_position));
437 //printf(__FUNCTION__ " 5\n");
439 else
440 output_position += 32;
446 return output_position;