Mercurial > mplayer.hg
annotate mp3lib/layer3.c @ 3343:58ab1490a0be
dunnowhat Q/A de biztos jo
author | gabucino |
---|---|
date | Wed, 05 Dec 2001 23:07:05 +0000 |
parents | 03b7e2955a20 |
children | 140fcbd20c18 |
rev | line source |
---|---|
1 | 1 |
2 /* | |
3 * Mpeg Layer-3 audio decoder | |
4 * -------------------------- | |
5 * copyright (c) 1995,1996,1997 by Michael Hipp. | |
6 * All rights reserved. See also 'README' | |
7 * | |
8 * - I'm currently working on that .. needs a few more optimizations, | |
9 * though the code is now fast enough to run in realtime on a 100Mhz 486 | |
10 * - a few personal notes are in german .. | |
11 * | |
12 * used source: | |
13 * mpeg1_iis package | |
14 */ | |
15 | |
16 static real ispow[8207]; | |
17 static real aa_ca[8],aa_cs[8]; | |
18 static real COS1[12][6]; | |
19 static real win[4][36]; | |
20 static real win1[4][36]; | |
21 | |
22 #define GP2MAX (256+118+4) | |
23 static real gainpow2[GP2MAX]; | |
24 | |
1245
03b7e2955a20
Added newest MMX-optimized decore which speedups decoding at least on 13% for any cpu.
nick
parents:
716
diff
changeset
|
25 real COS9[9]; |
1 | 26 static real COS6_1,COS6_2; |
1245
03b7e2955a20
Added newest MMX-optimized decore which speedups decoding at least on 13% for any cpu.
nick
parents:
716
diff
changeset
|
27 real tfcos36[9]; |
1 | 28 static real tfcos12[3]; |
29 #ifdef NEW_DCT9 | |
30 static real cos9[3],cos18[3]; | |
31 #endif | |
32 | |
33 struct bandInfoStruct { | |
34 int longIdx[23]; | |
35 int longDiff[22]; | |
36 int shortIdx[14]; | |
37 int shortDiff[13]; | |
38 }; | |
39 | |
40 int longLimit[9][23]; | |
41 int shortLimit[9][14]; | |
42 | |
43 struct bandInfoStruct bandInfo[9] = { | |
44 | |
45 /* MPEG 1.0 */ | |
46 { {0,4,8,12,16,20,24,30,36,44,52,62,74, 90,110,134,162,196,238,288,342,418,576}, | |
47 {4,4,4,4,4,4,6,6,8, 8,10,12,16,20,24,28,34,42,50,54, 76,158}, | |
48 {0,4*3,8*3,12*3,16*3,22*3,30*3,40*3,52*3,66*3, 84*3,106*3,136*3,192*3}, | |
49 {4,4,4,4,6,8,10,12,14,18,22,30,56} } , | |
50 | |
51 { {0,4,8,12,16,20,24,30,36,42,50,60,72, 88,106,128,156,190,230,276,330,384,576}, | |
52 {4,4,4,4,4,4,6,6,6, 8,10,12,16,18,22,28,34,40,46,54, 54,192}, | |
53 {0,4*3,8*3,12*3,16*3,22*3,28*3,38*3,50*3,64*3, 80*3,100*3,126*3,192*3}, | |
54 {4,4,4,4,6,6,10,12,14,16,20,26,66} } , | |
55 | |
56 { {0,4,8,12,16,20,24,30,36,44,54,66,82,102,126,156,194,240,296,364,448,550,576} , | |
57 {4,4,4,4,4,4,6,6,8,10,12,16,20,24,30,38,46,56,68,84,102, 26} , | |
58 {0,4*3,8*3,12*3,16*3,22*3,30*3,42*3,58*3,78*3,104*3,138*3,180*3,192*3} , | |
59 {4,4,4,4,6,8,12,16,20,26,34,42,12} } , | |
60 | |
61 /* MPEG 2.0 */ | |
62 { {0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576}, | |
63 {6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54 } , | |
64 {0,4*3,8*3,12*3,18*3,24*3,32*3,42*3,56*3,74*3,100*3,132*3,174*3,192*3} , | |
65 {4,4,4,6,6,8,10,14,18,26,32,42,18 } } , | |
66 | |
67 { {0,6,12,18,24,30,36,44,54,66,80,96,114,136,162,194,232,278,330,394,464,540,576}, | |
68 {6,6,6,6,6,6,8,10,12,14,16,18,22,26,32,38,46,52,64,70,76,36 } , | |
69 {0,4*3,8*3,12*3,18*3,26*3,36*3,48*3,62*3,80*3,104*3,136*3,180*3,192*3} , | |
70 {4,4,4,6,8,10,12,14,18,24,32,44,12 } } , | |
71 | |
72 { {0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576}, | |
73 {6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54 }, | |
74 {0,4*3,8*3,12*3,18*3,26*3,36*3,48*3,62*3,80*3,104*3,134*3,174*3,192*3}, | |
75 {4,4,4,6,8,10,12,14,18,24,30,40,18 } } , | |
76 | |
77 /* MPEG 2.5 */ | |
78 { {0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576} , | |
79 {6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54}, | |
80 {0,12,24,36,54,78,108,144,186,240,312,402,522,576}, | |
81 {4,4,4,6,8,10,12,14,18,24,30,40,18} }, | |
82 | |
83 { {0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576} , | |
84 {6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54}, | |
85 {0,12,24,36,54,78,108,144,186,240,312,402,522,576}, | |
86 {4,4,4,6,8,10,12,14,18,24,30,40,18} }, | |
87 | |
88 { {0,12,24,36,48,60,72,88,108,132,160,192,232,280,336,400,476,566,568,570,572,574,576}, | |
89 {12,12,12,12,12,12,16,20,24,28,32,40,48,56,64,76,90,2,2,2,2,2}, | |
90 {0, 24, 48, 72,108,156,216,288,372,480,486,492,498,576}, | |
91 {8,8,8,12,16,20,24,28,36,2,2,2,26} } , | |
92 }; | |
93 | |
94 static int mapbuf0[9][152]; | |
95 static int mapbuf1[9][156]; | |
96 static int mapbuf2[9][44]; | |
97 static int *map[9][3]; | |
98 static int *mapend[9][3]; | |
99 | |
100 static unsigned int n_slen2[512]; /* MPEG 2.0 slen for 'normal' mode */ | |
101 static unsigned int i_slen2[256]; /* MPEG 2.0 slen for intensity stereo */ | |
102 | |
103 static real tan1_1[16],tan2_1[16],tan1_2[16],tan2_2[16]; | |
104 static real pow1_1[2][16],pow2_1[2][16],pow1_2[2][16],pow2_2[2][16]; | |
105 | |
106 /* | |
107 * init tables for layer-3 | |
108 */ | |
109 void init_layer3(int down_sample_sblimit) | |
110 { | |
111 int i,j,k,l; | |
112 | |
113 for(i=-256;i<118+4;i++) | |
1245
03b7e2955a20
Added newest MMX-optimized decore which speedups decoding at least on 13% for any cpu.
nick
parents:
716
diff
changeset
|
114 { |
03b7e2955a20
Added newest MMX-optimized decore which speedups decoding at least on 13% for any cpu.
nick
parents:
716
diff
changeset
|
115 if(_has_mmx) |
03b7e2955a20
Added newest MMX-optimized decore which speedups decoding at least on 13% for any cpu.
nick
parents:
716
diff
changeset
|
116 gainpow2[i+256] = 16384.0 * pow((double)2.0,-0.25 * (double) (i+210) ); |
03b7e2955a20
Added newest MMX-optimized decore which speedups decoding at least on 13% for any cpu.
nick
parents:
716
diff
changeset
|
117 else |
03b7e2955a20
Added newest MMX-optimized decore which speedups decoding at least on 13% for any cpu.
nick
parents:
716
diff
changeset
|
118 gainpow2[i+256] = pow((double)2.0,-0.25 * (double) (i+210) ); |
03b7e2955a20
Added newest MMX-optimized decore which speedups decoding at least on 13% for any cpu.
nick
parents:
716
diff
changeset
|
119 } |
1 | 120 for(i=0;i<8207;i++) |
121 ispow[i] = pow((double)i,(double)4.0/3.0); | |
122 | |
123 for (i=0;i<8;i++) | |
124 { | |
125 static double Ci[8]={-0.6,-0.535,-0.33,-0.185,-0.095,-0.041,-0.0142,-0.0037}; | |
126 double sq=sqrt(1.0+Ci[i]*Ci[i]); | |
127 aa_cs[i] = 1.0/sq; | |
128 aa_ca[i] = Ci[i]/sq; | |
129 } | |
130 | |
131 for(i=0;i<18;i++) | |
132 { | |
133 win[0][i] = win[1][i] = 0.5 * sin( M_PI / 72.0 * (double) (2*(i+0) +1) ) / cos ( M_PI * (double) (2*(i+0) +19) / 72.0 ); | |
134 win[0][i+18] = win[3][i+18] = 0.5 * sin( M_PI / 72.0 * (double) (2*(i+18)+1) ) / cos ( M_PI * (double) (2*(i+18)+19) / 72.0 ); | |
135 } | |
136 for(i=0;i<6;i++) | |
137 { | |
138 win[1][i+18] = 0.5 / cos ( M_PI * (double) (2*(i+18)+19) / 72.0 ); | |
139 win[3][i+12] = 0.5 / cos ( M_PI * (double) (2*(i+12)+19) / 72.0 ); | |
140 win[1][i+24] = 0.5 * sin( M_PI / 24.0 * (double) (2*i+13) ) / cos ( M_PI * (double) (2*(i+24)+19) / 72.0 ); | |
141 win[1][i+30] = win[3][i] = 0.0; | |
142 win[3][i+6 ] = 0.5 * sin( M_PI / 24.0 * (double) (2*i+1) ) / cos ( M_PI * (double) (2*(i+6 )+19) / 72.0 ); | |
143 } | |
144 | |
145 for(i=0;i<9;i++) | |
1245
03b7e2955a20
Added newest MMX-optimized decore which speedups decoding at least on 13% for any cpu.
nick
parents:
716
diff
changeset
|
146 COS9[i] = cos( M_PI / 18.0 * (double) i); |
1 | 147 |
148 for(i=0;i<9;i++) | |
149 tfcos36[i] = 0.5 / cos ( M_PI * (double) (i*2+1) / 36.0 ); | |
150 for(i=0;i<3;i++) | |
151 tfcos12[i] = 0.5 / cos ( M_PI * (double) (i*2+1) / 12.0 ); | |
152 | |
153 COS6_1 = cos( M_PI / 6.0 * (double) 1); | |
154 COS6_2 = cos( M_PI / 6.0 * (double) 2); | |
155 | |
156 #ifdef NEW_DCT9 | |
157 cos9[0] = cos(1.0*M_PI/9.0); | |
158 cos9[1] = cos(5.0*M_PI/9.0); | |
159 cos9[2] = cos(7.0*M_PI/9.0); | |
160 cos18[0] = cos(1.0*M_PI/18.0); | |
161 cos18[1] = cos(11.0*M_PI/18.0); | |
162 cos18[2] = cos(13.0*M_PI/18.0); | |
163 #endif | |
164 | |
165 for(i=0;i<12;i++) | |
166 { | |
167 win[2][i] = 0.5 * sin( M_PI / 24.0 * (double) (2*i+1) ) / cos ( M_PI * (double) (2*i+7) / 24.0 ); | |
168 for(j=0;j<6;j++) | |
169 COS1[i][j] = cos( M_PI / 24.0 * (double) ((2*i+7)*(2*j+1)) ); | |
170 } | |
171 | |
172 for(j=0;j<4;j++) { | |
173 static int len[4] = { 36,36,12,36 }; | |
174 for(i=0;i<len[j];i+=2) | |
175 win1[j][i] = + win[j][i]; | |
176 for(i=1;i<len[j];i+=2) | |
177 win1[j][i] = - win[j][i]; | |
178 } | |
179 | |
180 for(i=0;i<16;i++) | |
181 { | |
182 double t = tan( (double) i * M_PI / 12.0 ); | |
183 tan1_1[i] = t / (1.0+t); | |
184 tan2_1[i] = 1.0 / (1.0 + t); | |
185 tan1_2[i] = M_SQRT2 * t / (1.0+t); | |
186 tan2_2[i] = M_SQRT2 / (1.0 + t); | |
187 | |
188 for(j=0;j<2;j++) { | |
189 double base = pow(2.0,-0.25*(j+1.0)); | |
190 double p1=1.0,p2=1.0; | |
191 if(i > 0) { | |
192 if( i & 1 ) | |
193 p1 = pow(base,(i+1.0)*0.5); | |
194 else | |
195 p2 = pow(base,i*0.5); | |
196 } | |
197 pow1_1[j][i] = p1; | |
198 pow2_1[j][i] = p2; | |
199 pow1_2[j][i] = M_SQRT2 * p1; | |
200 pow2_2[j][i] = M_SQRT2 * p2; | |
201 } | |
202 } | |
203 | |
204 for(j=0;j<9;j++) | |
205 { | |
206 struct bandInfoStruct *bi = &bandInfo[j]; | |
207 int *mp; | |
208 int cb,lwin; | |
209 int *bdf; | |
210 | |
211 mp = map[j][0] = mapbuf0[j]; | |
212 bdf = bi->longDiff; | |
213 for(i=0,cb = 0; cb < 8 ; cb++,i+=*bdf++) { | |
214 *mp++ = (*bdf) >> 1; | |
215 *mp++ = i; | |
216 *mp++ = 3; | |
217 *mp++ = cb; | |
218 } | |
219 bdf = bi->shortDiff+3; | |
220 for(cb=3;cb<13;cb++) { | |
221 int l = (*bdf++) >> 1; | |
222 for(lwin=0;lwin<3;lwin++) { | |
223 *mp++ = l; | |
224 *mp++ = i + lwin; | |
225 *mp++ = lwin; | |
226 *mp++ = cb; | |
227 } | |
228 i += 6*l; | |
229 } | |
230 mapend[j][0] = mp; | |
231 | |
232 mp = map[j][1] = mapbuf1[j]; | |
233 bdf = bi->shortDiff+0; | |
234 for(i=0,cb=0;cb<13;cb++) { | |
235 int l = (*bdf++) >> 1; | |
236 for(lwin=0;lwin<3;lwin++) { | |
237 *mp++ = l; | |
238 *mp++ = i + lwin; | |
239 *mp++ = lwin; | |
240 *mp++ = cb; | |
241 } | |
242 i += 6*l; | |
243 } | |
244 mapend[j][1] = mp; | |
245 | |
246 mp = map[j][2] = mapbuf2[j]; | |
247 bdf = bi->longDiff; | |
248 for(cb = 0; cb < 22 ; cb++) { | |
249 *mp++ = (*bdf++) >> 1; | |
250 *mp++ = cb; | |
251 } | |
252 mapend[j][2] = mp; | |
253 | |
254 } | |
255 | |
256 for(j=0;j<9;j++) { | |
257 for(i=0;i<23;i++) { | |
258 longLimit[j][i] = (bandInfo[j].longIdx[i] - 1 + 8) / 18 + 1; | |
259 if(longLimit[j][i] > (down_sample_sblimit) ) | |
260 longLimit[j][i] = down_sample_sblimit; | |
261 } | |
262 for(i=0;i<14;i++) { | |
263 shortLimit[j][i] = (bandInfo[j].shortIdx[i] - 1) / 18 + 1; | |
264 if(shortLimit[j][i] > (down_sample_sblimit) ) | |
265 shortLimit[j][i] = down_sample_sblimit; | |
266 } | |
267 } | |
268 | |
269 for(i=0;i<5;i++) { | |
270 for(j=0;j<6;j++) { | |
271 for(k=0;k<6;k++) { | |
272 int n = k + j * 6 + i * 36; | |
273 i_slen2[n] = i|(j<<3)|(k<<6)|((long)3<<12); | |
274 } | |
275 } | |
276 } | |
277 for(i=0;i<4;i++) { | |
278 for(j=0;j<4;j++) { | |
279 for(k=0;k<4;k++) { | |
280 int n = k + j * 4 + i * 16; | |
281 i_slen2[n+180] = i|(j<<3)|(k<<6)|((long)4<<12); | |
282 } | |
283 } | |
284 } | |
285 for(i=0;i<4;i++) { | |
286 for(j=0;j<3;j++) { | |
287 int n = j + i * 3; | |
288 i_slen2[n+244] = i|(j<<3) | ((long)5<<12); | |
289 n_slen2[n+500] = i|(j<<3) | ((long)2<<12) | ((long)1<<15); | |
290 } | |
291 } | |
292 | |
293 for(i=0;i<5;i++) { | |
294 for(j=0;j<5;j++) { | |
295 for(k=0;k<4;k++) { | |
296 for(l=0;l<4;l++) { | |
297 int n = l + k * 4 + j * 16 + i * 80; | |
298 n_slen2[n] = i|(j<<3)|(k<<6)|(l<<9)|((long)0<<12); | |
299 } | |
300 } | |
301 } | |
302 } | |
303 for(i=0;i<5;i++) { | |
304 for(j=0;j<5;j++) { | |
305 for(k=0;k<4;k++) { | |
306 int n = k + j * 4 + i * 20; | |
307 n_slen2[n+400] = i|(j<<3)|(k<<6)|((long)1<<12); | |
308 } | |
309 } | |
310 } | |
311 } /* init_layer3() */ | |
312 | |
313 /* ========================== READ FRAME DATA ========================= */ | |
314 | |
315 #if 1 | |
316 LOCAL real Gainpow2(int i){ | |
317 // if(i<0) i=0; else | |
318 // if(i>=GP2MAX) i=GP2MAX-1; | |
319 // return gainpow2[i]; | |
320 return gainpow2[((i)<0)?0:( ((i)<GP2MAX)?(i):(GP2MAX-1) )]; | |
321 } | |
322 #else | |
323 #define Gainpow2(i) gainpow2[((i)<0)?0:( ((i)<GP2MAX)?(i):(GP2MAX-1) )] | |
324 #endif | |
325 | |
326 /* | |
327 * read additional side information | |
328 */ | |
329 static void III_get_side_info_1(struct III_sideinfo *si,int stereo, | |
330 int ms_stereo,long sfreq,int single) | |
331 { | |
332 int ch, gr; | |
333 int powdiff = (single == 3) ? 4 : 0; | |
334 | |
335 si->main_data_begin = getbits(9); | |
336 | |
337 if (stereo == 1) | |
338 si->private_bits = getbits_fast(5); | |
339 else | |
340 si->private_bits = getbits_fast(3); | |
341 | |
342 for (ch=0; ch<stereo; ch++) { | |
343 si->ch[ch].gr[0].scfsi = -1; | |
344 si->ch[ch].gr[1].scfsi = getbits_fast(4); | |
345 } | |
346 | |
347 for (gr=0; gr<2; gr++) { | |
348 for (ch=0; ch<stereo; ch++) { | |
349 register struct gr_info_s *gr_info = &(si->ch[ch].gr[gr]); | |
350 | |
351 gr_info->part2_3_length = getbits(12); | |
352 gr_info->big_values = getbits(9); | |
353 if(gr_info->big_values > 288) { | |
354 printf("\rbig_values too large! \n"); | |
355 gr_info->big_values = 288; | |
356 } | |
357 gr_info->pow2gain = 256 - getbits_fast(8) + powdiff; | |
358 if(ms_stereo) gr_info->pow2gain += 2; | |
359 gr_info->scalefac_compress = getbits_fast(4); | |
360 | |
361 if(get1bit()) { | |
362 /* window-switching flag==1 (block_Type!=0) */ | |
363 int i; | |
364 gr_info->block_type = getbits_fast(2); | |
365 gr_info->mixed_block_flag = get1bit(); | |
366 gr_info->table_select[0] = getbits_fast(5); | |
367 gr_info->table_select[1] = getbits_fast(5); | |
368 /* | |
369 * table_select[2] not needed, because there is no region2, | |
370 * but to satisfy some verifications tools we set it either. | |
371 */ | |
372 gr_info->table_select[2] = 0; | |
373 for(i=0;i<3;i++) | |
374 gr_info->full_gain[i] = gr_info->pow2gain + (getbits_fast(3)<<3); | |
375 | |
376 if(gr_info->block_type == 0) { | |
377 printf("\rBlocktype == 0 and window-switching == 1 not allowed. \n"); | |
378 return; | |
379 } | |
380 /* region_count/start parameters are implicit in this case. */ | |
381 gr_info->region1start = 36>>1; | |
382 gr_info->region2start = 576>>1; | |
383 } else { | |
384 /* window-switching flag==0 (block_Type==0) */ | |
385 int i,r0c,r1c; | |
386 for (i=0; i<3; i++) | |
387 gr_info->table_select[i] = getbits_fast(5); | |
388 r0c = getbits_fast(4); | |
389 r1c = getbits_fast(3); | |
390 gr_info->region1start = bandInfo[sfreq].longIdx[r0c+1] >> 1 ; | |
391 gr_info->region2start = bandInfo[sfreq].longIdx[r0c+1+r1c+1] >> 1; | |
392 gr_info->block_type = 0; | |
393 gr_info->mixed_block_flag = 0; | |
394 } | |
395 gr_info->preflag = get1bit(); | |
396 gr_info->scalefac_scale = get1bit(); | |
397 gr_info->count1table_select = get1bit(); | |
398 } | |
399 } | |
400 } | |
401 | |
402 /* | |
403 * Side Info for MPEG 2.0 / LSF | |
404 */ | |
405 static void III_get_side_info_2(struct III_sideinfo *si,int stereo, | |
406 int ms_stereo,long sfreq,int single) | |
407 { | |
408 int ch; | |
409 int powdiff = (single == 3) ? 4 : 0; | |
410 | |
411 si->main_data_begin = getbits(8); | |
412 if (stereo == 1) | |
413 si->private_bits = get1bit(); | |
414 else | |
415 si->private_bits = getbits_fast(2); | |
416 | |
417 for (ch=0; ch<stereo; ch++) { | |
418 register struct gr_info_s *gr_info = &(si->ch[ch].gr[0]); | |
419 | |
420 gr_info->part2_3_length = getbits(12); | |
421 gr_info->big_values = getbits(9); | |
422 if(gr_info->big_values > 288) { | |
423 printf("\rbig_values too large! \n"); | |
424 gr_info->big_values = 288; | |
425 } | |
426 gr_info->pow2gain = 256 - getbits_fast(8) + powdiff; | |
427 if(ms_stereo) | |
428 gr_info->pow2gain += 2; | |
429 gr_info->scalefac_compress = getbits(9); | |
430 | |
431 if(get1bit()) { | |
432 /* window-switching flag==1 (block_Type!=0) */ | |
433 int i; | |
434 gr_info->block_type = getbits_fast(2); | |
435 gr_info->mixed_block_flag = get1bit(); | |
436 gr_info->table_select[0] = getbits_fast(5); | |
437 gr_info->table_select[1] = getbits_fast(5); | |
438 /* | |
439 * table_select[2] not needed, because there is no region2, | |
440 * but to satisfy some verifications tools we set it either. | |
441 */ | |
442 gr_info->table_select[2] = 0; | |
443 for(i=0;i<3;i++) | |
444 gr_info->full_gain[i] = gr_info->pow2gain + (getbits_fast(3)<<3); | |
445 | |
446 if(gr_info->block_type == 0) { | |
447 printf("\rBlocktype == 0 and window-switching == 1 not allowed. \n"); | |
448 return; | |
449 } | |
450 /* region_count/start parameters are implicit in this case. */ | |
451 /* check this again! */ | |
452 if(gr_info->block_type == 2) | |
453 gr_info->region1start = 36>>1; | |
454 else if(sfreq == 8) | |
455 /* check this for 2.5 and sfreq=8 */ | |
456 gr_info->region1start = 108>>1; | |
457 else | |
458 gr_info->region1start = 54>>1; | |
459 gr_info->region2start = 576>>1; | |
460 } else { | |
461 /* window-switching flag==0 (block_Type==0) */ | |
462 int i,r0c,r1c; | |
463 for (i=0; i<3; i++) | |
464 gr_info->table_select[i] = getbits_fast(5); | |
465 r0c = getbits_fast(4); | |
466 r1c = getbits_fast(3); | |
467 gr_info->region1start = bandInfo[sfreq].longIdx[r0c+1] >> 1 ; | |
468 gr_info->region2start = bandInfo[sfreq].longIdx[r0c+1+r1c+1] >> 1; | |
469 gr_info->block_type = 0; | |
470 gr_info->mixed_block_flag = 0; | |
471 } | |
472 gr_info->scalefac_scale = get1bit(); | |
473 gr_info->count1table_select = get1bit(); | |
474 } | |
475 } | |
476 | |
477 /* | |
478 * read scalefactors | |
479 */ | |
480 static int III_get_scale_factors_1(int *scf,struct gr_info_s *gr_info) | |
481 { | |
482 static unsigned char slen[2][16] = { | |
483 {0, 0, 0, 0, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4}, | |
484 {0, 1, 2, 3, 0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 2, 3} | |
485 }; | |
486 int numbits; | |
487 int num0 = slen[0][gr_info->scalefac_compress]; | |
488 int num1 = slen[1][gr_info->scalefac_compress]; | |
489 | |
490 if (gr_info->block_type == 2) { | |
491 int i=18; | |
492 numbits = (num0 + num1) * 18; | |
493 if (gr_info->mixed_block_flag) { | |
494 for (i=8;i;i--) *scf++ = getbits(num0); | |
495 i = 9; | |
496 numbits -= num0; /* num0 * 17 + num1 * 18 */ | |
497 } | |
498 for (;i;i--) *scf++ = getbits(num0); | |
499 for (i = 18; i; i--) *scf++ = getbits(num1); | |
500 *scf++ = 0; *scf++ = 0; *scf++ = 0; /* short[13][0..2] = 0 */ | |
501 } else { | |
502 int i; | |
503 int scfsi = gr_info->scfsi; | |
504 | |
505 if(scfsi < 0) { /* scfsi < 0 => granule == 0 */ | |
506 for(i=11;i;i--) *scf++ = getbits(num0); | |
507 for(i=10;i;i--) *scf++ = getbits(num1); | |
508 numbits = (num0 + num1) * 10 + num0; | |
509 } else { | |
510 numbits = 0; | |
511 if(!(scfsi & 0x8)) { | |
512 for (i=6;i;i--) *scf++ = getbits(num0); | |
513 numbits += num0 * 6; | |
514 } else { | |
515 scf += 6; | |
516 } | |
517 if(!(scfsi & 0x4)) { | |
518 for (i=5;i;i--) *scf++ = getbits(num0); | |
519 numbits += num0 * 5; | |
520 } else { | |
521 scf += 5; | |
522 } | |
523 if(!(scfsi & 0x2)) { | |
524 for(i=5;i;i--) *scf++ = getbits(num1); | |
525 numbits += num1 * 5; | |
526 } else { | |
527 scf += 5; | |
528 } | |
529 if(!(scfsi & 0x1)) { | |
530 for (i=5;i;i--) *scf++ = getbits(num1); | |
531 numbits += num1 * 5; | |
532 } else { | |
533 scf += 5; | |
534 } | |
535 } | |
536 | |
537 *scf++ = 0; /* no l[21] in original sources */ | |
538 } | |
539 return numbits; | |
540 } | |
541 | |
542 static int III_get_scale_factors_2(int *scf,struct gr_info_s *gr_info,int i_stereo) | |
543 { | |
544 unsigned char *pnt; | |
545 int i,j; | |
546 unsigned int slen; | |
547 int n = 0; | |
548 int numbits = 0; | |
549 | |
550 static unsigned char stab[3][6][4] = { | |
551 { { 6, 5, 5,5 } , { 6, 5, 7,3 } , { 11,10,0,0} , | |
552 { 7, 7, 7,0 } , { 6, 6, 6,3 } , { 8, 8,5,0} } , | |
553 { { 9, 9, 9,9 } , { 9, 9,12,6 } , { 18,18,0,0} , | |
554 {12,12,12,0 } , {12, 9, 9,6 } , { 15,12,9,0} } , | |
555 { { 6, 9, 9,9 } , { 6, 9,12,6 } , { 15,18,0,0} , | |
556 { 6,15,12,0 } , { 6,12, 9,6 } , { 6,18,9,0} } }; | |
557 | |
558 if(i_stereo) /* i_stereo AND second channel -> do_layer3() checks this */ | |
559 slen = i_slen2[gr_info->scalefac_compress>>1]; | |
560 else | |
561 slen = n_slen2[gr_info->scalefac_compress]; | |
562 | |
563 gr_info->preflag = (slen>>15) & 0x1; | |
564 | |
565 n = 0; | |
566 if( gr_info->block_type == 2 ) { | |
567 n++; | |
568 if(gr_info->mixed_block_flag) n++; | |
569 } | |
570 | |
571 pnt = stab[n][(slen>>12)&0x7]; | |
572 | |
573 for(i=0;i<4;i++) { | |
574 int num = slen & 0x7; | |
575 slen >>= 3; | |
576 if(num) { | |
577 for(j=0;j<(int)(pnt[i]);j++) *scf++ = getbits_fast(num); | |
578 numbits += pnt[i] * num; | |
579 } | |
580 else { | |
581 for(j=0;j<(int)(pnt[i]);j++) *scf++ = 0; | |
582 } | |
583 } | |
584 | |
585 n = (n << 1) + 1; | |
586 for(i=0;i<n;i++) *scf++ = 0; | |
587 | |
588 return numbits; | |
589 } | |
590 | |
591 static int pretab1[22] = {0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,2,2,3,3,3,2,0}; | |
592 static int pretab2[22] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; | |
593 | |
594 /* | |
595 * don't forget to apply the same changes to III_dequantize_sample_ms() !!! | |
596 */ | |
597 static int III_dequantize_sample(real xr[SBLIMIT][SSLIMIT],int *scf, | |
598 struct gr_info_s *gr_info,int sfreq,int part2bits) | |
599 { | |
600 int shift = 1 + gr_info->scalefac_scale; | |
601 real *xrpnt = (real *) xr; | |
602 int l[3],l3; | |
603 int part2remain = gr_info->part2_3_length - part2bits; | |
604 int *me; | |
605 | |
606 { int bv = gr_info->big_values; | |
607 int region1 = gr_info->region1start; | |
608 int region2 = gr_info->region2start; | |
609 | |
610 l3 = ((576>>1)-bv)>>1; | |
611 /* | |
612 * we may lose the 'odd' bit here !! | |
613 * check this later again | |
614 */ | |
615 if(bv <= region1) { | |
616 l[0] = bv; l[1] = 0; l[2] = 0; | |
617 } else { | |
618 l[0] = region1; | |
619 if(bv <= region2) { | |
620 l[1] = bv - l[0]; l[2] = 0; | |
621 } else { | |
622 l[1] = region2 - l[0]; l[2] = bv - region2; | |
623 } | |
624 } | |
625 } | |
626 | |
627 if(gr_info->block_type == 2) { | |
628 /* | |
629 * decoding with short or mixed mode BandIndex table | |
630 */ | |
631 int i,max[4]; | |
632 int step=0,lwin=0,cb=0; | |
633 register real v = 0.0; | |
634 register int *m,mc; | |
635 | |
636 if(gr_info->mixed_block_flag) { | |
637 max[3] = -1; | |
638 max[0] = max[1] = max[2] = 2; | |
639 m = map[sfreq][0]; | |
640 me = mapend[sfreq][0]; | |
641 } else { | |
642 max[0] = max[1] = max[2] = max[3] = -1; | |
643 /* max[3] not really needed in this case */ | |
644 m = map[sfreq][1]; | |
645 me = mapend[sfreq][1]; | |
646 } | |
647 | |
648 mc = 0; | |
649 for(i=0;i<2;i++) { | |
650 int lp = l[i]; | |
651 struct newhuff *h = ht+gr_info->table_select[i]; | |
652 for(;lp;lp--,mc--) { | |
653 register int x,y; | |
654 if( (!mc) ) { | |
655 mc = *m++; | |
656 xrpnt = ((real *) xr) + (*m++); | |
657 lwin = *m++; | |
658 cb = *m++; | |
659 if(lwin == 3) { | |
660 v = Gainpow2(gr_info->pow2gain + ((*scf++) << shift)); | |
661 step = 1; | |
662 } else { | |
663 v = Gainpow2(gr_info->full_gain[lwin] + ((*scf++) << shift)); | |
664 step = 3; | |
665 } | |
666 } | |
667 { register short *val = h->table; | |
668 while((y=*val++)<0) { | |
669 part2remain--; | |
716 | 670 if(part2remain < 0) return 1; |
1 | 671 if (get1bit()) val-=y; |
672 } | |
673 x = y >> 4; | |
674 y &= 0xf; | |
675 } | |
676 if(x == 15) { | |
677 max[lwin] = cb; | |
678 part2remain -= h->linbits+1; | |
679 x += getbits(h->linbits); | |
680 if(get1bit()) | |
681 *xrpnt = -ispow[x] * v; | |
682 else | |
683 *xrpnt = ispow[x] * v; | |
684 } else if(x) { | |
685 max[lwin] = cb; | |
686 if(get1bit()) | |
687 *xrpnt = -ispow[x] * v; | |
688 else | |
689 *xrpnt = ispow[x] * v; | |
690 part2remain--; | |
691 } else | |
692 *xrpnt = 0.0; | |
693 xrpnt += step; | |
694 if(y == 15) { | |
695 max[lwin] = cb; | |
696 part2remain -= h->linbits+1; | |
697 y += getbits(h->linbits); | |
698 if(get1bit()) | |
699 *xrpnt = -ispow[y] * v; | |
700 else | |
701 *xrpnt = ispow[y] * v; | |
702 } else if(y) { | |
703 max[lwin] = cb; | |
704 if(get1bit()) | |
705 *xrpnt = -ispow[y] * v; | |
706 else | |
707 *xrpnt = ispow[y] * v; | |
708 part2remain--; | |
709 } else | |
710 *xrpnt = 0.0; | |
711 xrpnt += step; | |
712 } | |
713 } | |
714 | |
715 for(;l3 && (part2remain > 0);l3--) { | |
716 struct newhuff *h = htc+gr_info->count1table_select; | |
717 register short *val = h->table,a; | |
718 | |
719 while((a=*val++)<0) { | |
720 part2remain--; | |
721 if(part2remain < 0) { | |
722 part2remain++; | |
723 a = 0; | |
724 break; | |
725 } | |
726 if (get1bit()) val-=a; | |
727 } | |
728 | |
729 for(i=0;i<4;i++) { | |
730 if(!(i & 1)) { | |
731 if(!mc) { | |
732 mc = *m++; | |
733 xrpnt = ((real *) xr) + (*m++); | |
734 lwin = *m++; | |
735 cb = *m++; | |
736 if(lwin == 3) { | |
737 v = Gainpow2(gr_info->pow2gain + ((*scf++) << shift)); | |
738 step = 1; | |
739 } else { | |
740 v = Gainpow2(gr_info->full_gain[lwin] + ((*scf++) << shift)); | |
741 step = 3; | |
742 } | |
743 } | |
744 mc--; | |
745 } | |
746 if( (a & (0x8>>i)) ) { | |
747 max[lwin] = cb; | |
748 part2remain--; | |
749 if(part2remain < 0) { | |
750 part2remain++; | |
751 break; | |
752 } | |
753 if(get1bit()) | |
754 *xrpnt = -v; | |
755 else | |
756 *xrpnt = v; | |
757 } else | |
758 *xrpnt = 0.0; | |
759 xrpnt += step; | |
760 } | |
761 } // for(;l3 && (part2remain > 0);l3--) | |
762 | |
763 while( m < me ) { | |
764 if(!mc) { | |
765 mc = *m++; | |
766 xrpnt = ((real *) xr) + *m++; | |
767 if( (*m++) == 3) | |
768 step = 1; | |
769 else | |
770 step = 3; | |
771 m++; /* cb */ | |
772 } | |
773 mc--; | |
774 *xrpnt = 0.0; xrpnt += step; | |
775 *xrpnt = 0.0; xrpnt += step; | |
776 /* we could add a little opt. here: | |
777 * if we finished a band for window 3 or a long band | |
778 * further bands could copied in a simple loop without a | |
779 * special 'map' decoding | |
780 */ | |
781 } | |
782 | |
783 gr_info->maxband[0] = max[0]+1; | |
784 gr_info->maxband[1] = max[1]+1; | |
785 gr_info->maxband[2] = max[2]+1; | |
786 gr_info->maxbandl = max[3]+1; | |
787 | |
788 { int rmax = max[0] > max[1] ? max[0] : max[1]; | |
789 rmax = (rmax > max[2] ? rmax : max[2]) + 1; | |
790 gr_info->maxb = rmax ? shortLimit[sfreq][rmax] : longLimit[sfreq][max[3]+1]; | |
791 } | |
792 | |
793 } else { | |
794 /* | |
795 * decoding with 'long' BandIndex table (block_type != 2) | |
796 */ | |
797 int *pretab = gr_info->preflag ? pretab1 : pretab2; | |
798 int i,max = -1; | |
799 int cb = 0; | |
800 register int *m = map[sfreq][2]; | |
801 register real v = 0.0; | |
802 register int mc = 0; | |
803 #if 0 | |
804 me = mapend[sfreq][2]; | |
805 #endif | |
806 | |
807 /* | |
808 * long hash table values | |
809 */ | |
810 for(i=0;i<3;i++) { | |
811 int lp = l[i]; | |
812 struct newhuff *h = ht+gr_info->table_select[i]; | |
813 | |
814 for(;lp;lp--,mc--) { | |
815 int x,y; | |
816 | |
817 if(!mc) { | |
818 mc = *m++; | |
819 v = Gainpow2(gr_info->pow2gain + (((*scf++) + (*pretab++)) << shift)); | |
820 cb = *m++; | |
821 } | |
822 { register short *val = h->table; | |
823 while((y=*val++)<0) { | |
824 part2remain--; | |
716 | 825 if(part2remain < 0) return 1; |
1 | 826 if (get1bit()) val -= y; |
827 // if(part2remain<=0) return 0; // Arpi | |
828 } | |
829 x = y >> 4; | |
830 y &= 0xf; | |
831 } | |
832 if (x == 15) { | |
833 max = cb; | |
834 part2remain -= h->linbits+1; | |
835 x += getbits(h->linbits); | |
836 if(get1bit()) | |
837 *xrpnt++ = -ispow[x] * v; | |
838 else | |
839 *xrpnt++ = ispow[x] * v; | |
840 } else if(x) { | |
841 max = cb; | |
842 if(get1bit()) | |
843 *xrpnt++ = -ispow[x] * v; | |
844 else | |
845 *xrpnt++ = ispow[x] * v; | |
846 part2remain--; | |
847 } else | |
848 *xrpnt++ = 0.0; | |
849 | |
850 if (y == 15) { | |
851 max = cb; | |
852 part2remain -= h->linbits+1; | |
853 y += getbits(h->linbits); | |
854 if(get1bit()) | |
855 *xrpnt++ = -ispow[y] * v; | |
856 else | |
857 *xrpnt++ = ispow[y] * v; | |
858 } else if(y) { | |
859 max = cb; | |
860 if(get1bit()) | |
861 *xrpnt++ = -ispow[y] * v; | |
862 else | |
863 *xrpnt++ = ispow[y] * v; | |
864 part2remain--; | |
865 } else | |
866 *xrpnt++ = 0.0; | |
867 } | |
868 } | |
869 | |
870 /* | |
871 * short (count1table) values | |
872 */ | |
873 for(;l3 && (part2remain > 0);l3--) { | |
874 struct newhuff *h = htc+gr_info->count1table_select; | |
875 register short *val = h->table,a; | |
876 | |
877 while((a=*val++)<0) { | |
878 part2remain--; | |
879 if(part2remain < 0) { | |
880 part2remain++; | |
881 a = 0; | |
882 break; | |
883 } | |
884 if (get1bit()) val -= a; | |
885 } | |
886 | |
887 for(i=0;i<4;i++) { | |
888 if(!(i & 1)) { | |
889 if(!mc) { | |
890 mc = *m++; | |
891 cb = *m++; | |
892 v = Gainpow2(gr_info->pow2gain + (((*scf++) + (*pretab++)) << shift)); | |
893 } | |
894 mc--; | |
895 } | |
896 if ( (a & (0x8>>i)) ) { | |
897 max = cb; | |
898 part2remain--; | |
899 if(part2remain < 0) { | |
900 part2remain++; | |
901 break; | |
902 } | |
903 if(get1bit()) | |
904 *xrpnt++ = -v; | |
905 else | |
906 *xrpnt++ = v; | |
907 } else | |
908 *xrpnt++ = 0.0; | |
909 } | |
910 } | |
911 | |
912 /* | |
913 * zero part | |
914 */ | |
915 for(i=(&xr[SBLIMIT][0]-xrpnt)>>1;i;i--) { | |
916 *xrpnt++ = 0.0; | |
917 *xrpnt++ = 0.0; | |
918 } | |
919 | |
920 gr_info->maxbandl = max+1; | |
921 gr_info->maxb = longLimit[sfreq][gr_info->maxbandl]; | |
922 } | |
923 | |
924 while( part2remain > 16 ) { | |
925 getbits(16); /* Dismiss stuffing Bits */ | |
926 part2remain -= 16; | |
927 } | |
928 if(part2remain > 0) | |
929 getbits(part2remain); | |
930 else if(part2remain < 0) { | |
931 printf("\rCan't rewind stream by %d bits! \n",(-part2remain)); | |
932 return 1; /* -> error */ | |
933 } | |
934 return 0; | |
935 } | |
936 | |
937 static int III_dequantize_sample_ms(real xr[2][SBLIMIT][SSLIMIT],int *scf, | |
938 struct gr_info_s *gr_info,int sfreq,int part2bits) | |
939 { | |
940 int shift = 1 + gr_info->scalefac_scale; | |
941 real *xrpnt = (real *) xr[1]; | |
942 real *xr0pnt = (real *) xr[0]; | |
943 int l[3],l3; | |
944 int part2remain = gr_info->part2_3_length - part2bits; | |
945 int *me; | |
946 | |
947 { | |
948 int bv = gr_info->big_values; | |
949 int region1 = gr_info->region1start; | |
950 int region2 = gr_info->region2start; | |
951 | |
952 l3 = ((576>>1)-bv)>>1; | |
953 /* | |
954 * we may lose the 'odd' bit here !! | |
955 * check this later gain | |
956 */ | |
957 if(bv <= region1) { | |
958 l[0] = bv; l[1] = 0; l[2] = 0; | |
959 } | |
960 else { | |
961 l[0] = region1; | |
962 if(bv <= region2) { | |
963 l[1] = bv - l[0]; l[2] = 0; | |
964 } | |
965 else { | |
966 l[1] = region2 - l[0]; l[2] = bv - region2; | |
967 } | |
968 } | |
969 } | |
970 | |
971 if(gr_info->block_type == 2) { | |
972 int i,max[4]; | |
973 int step=0,lwin=0,cb=0; | |
974 register real v = 0.0; | |
975 register int *m,mc = 0; | |
976 | |
977 if(gr_info->mixed_block_flag) { | |
978 max[3] = -1; | |
979 max[0] = max[1] = max[2] = 2; | |
980 m = map[sfreq][0]; | |
981 me = mapend[sfreq][0]; | |
982 } | |
983 else { | |
984 max[0] = max[1] = max[2] = max[3] = -1; | |
985 /* max[3] not really needed in this case */ | |
986 m = map[sfreq][1]; | |
987 me = mapend[sfreq][1]; | |
988 } | |
989 | |
990 for(i=0;i<2;i++) { | |
991 int lp = l[i]; | |
992 struct newhuff *h = ht+gr_info->table_select[i]; | |
993 for(;lp;lp--,mc--) { | |
994 int x,y; | |
995 | |
996 if(!mc) { | |
997 mc = *m++; | |
998 xrpnt = ((real *) xr[1]) + *m; | |
999 xr0pnt = ((real *) xr[0]) + *m++; | |
1000 lwin = *m++; | |
1001 cb = *m++; | |
1002 if(lwin == 3) { | |
1003 v = Gainpow2(gr_info->pow2gain + ((*scf++) << shift)); | |
1004 step = 1; | |
1005 } | |
1006 else { | |
1007 v = Gainpow2(gr_info->full_gain[lwin] + ((*scf++) << shift)); | |
1008 step = 3; | |
1009 } | |
1010 } | |
1011 { | |
1012 register short *val = h->table; | |
1013 while((y=*val++)<0) { | |
1014 part2remain--; | |
716 | 1015 if(part2remain < 0) return 1; |
1 | 1016 if (get1bit()) val -= y; |
1017 // if(part2remain<=0) return 0; // Arpi | |
1018 } | |
1019 x = y >> 4; | |
1020 y &= 0xf; | |
1021 } | |
1022 if(x == 15) { | |
1023 max[lwin] = cb; | |
1024 part2remain -= h->linbits+1; | |
1025 x += getbits(h->linbits); | |
1026 if(get1bit()) { | |
1027 real a = ispow[x] * v; | |
1028 *xrpnt = *xr0pnt + a; | |
1029 *xr0pnt -= a; | |
1030 } | |
1031 else { | |
1032 real a = ispow[x] * v; | |
1033 *xrpnt = *xr0pnt - a; | |
1034 *xr0pnt += a; | |
1035 } | |
1036 } | |
1037 else if(x) { | |
1038 max[lwin] = cb; | |
1039 if(get1bit()) { | |
1040 real a = ispow[x] * v; | |
1041 *xrpnt = *xr0pnt + a; | |
1042 *xr0pnt -= a; | |
1043 } | |
1044 else { | |
1045 real a = ispow[x] * v; | |
1046 *xrpnt = *xr0pnt - a; | |
1047 *xr0pnt += a; | |
1048 } | |
1049 part2remain--; | |
1050 } | |
1051 else | |
1052 *xrpnt = *xr0pnt; | |
1053 xrpnt += step; | |
1054 xr0pnt += step; | |
1055 | |
1056 if(y == 15) { | |
1057 max[lwin] = cb; | |
1058 part2remain -= h->linbits+1; | |
1059 y += getbits(h->linbits); | |
1060 if(get1bit()) { | |
1061 real a = ispow[y] * v; | |
1062 *xrpnt = *xr0pnt + a; | |
1063 *xr0pnt -= a; | |
1064 } | |
1065 else { | |
1066 real a = ispow[y] * v; | |
1067 *xrpnt = *xr0pnt - a; | |
1068 *xr0pnt += a; | |
1069 } | |
1070 } | |
1071 else if(y) { | |
1072 max[lwin] = cb; | |
1073 if(get1bit()) { | |
1074 real a = ispow[y] * v; | |
1075 *xrpnt = *xr0pnt + a; | |
1076 *xr0pnt -= a; | |
1077 } | |
1078 else { | |
1079 real a = ispow[y] * v; | |
1080 *xrpnt = *xr0pnt - a; | |
1081 *xr0pnt += a; | |
1082 } | |
1083 part2remain--; | |
1084 } | |
1085 else | |
1086 *xrpnt = *xr0pnt; | |
1087 xrpnt += step; | |
1088 xr0pnt += step; | |
1089 } | |
1090 } | |
1091 | |
1092 for(;l3 && (part2remain > 0);l3--) { | |
1093 struct newhuff *h = htc+gr_info->count1table_select; | |
1094 register short *val = h->table,a; | |
1095 | |
1096 while((a=*val++)<0) { | |
1097 part2remain--; | |
1098 if(part2remain < 0) { | |
1099 part2remain++; | |
1100 a = 0; | |
1101 break; | |
1102 } | |
1103 if (get1bit()) | |
1104 val -= a; | |
1105 } | |
1106 | |
1107 for(i=0;i<4;i++) { | |
1108 if(!(i & 1)) { | |
1109 if(!mc) { | |
1110 mc = *m++; | |
1111 xrpnt = ((real *) xr[1]) + *m; | |
1112 xr0pnt = ((real *) xr[0]) + *m++; | |
1113 lwin = *m++; | |
1114 cb = *m++; | |
1115 if(lwin == 3) { | |
1116 v = Gainpow2(gr_info->pow2gain + ((*scf++) << shift)); | |
1117 step = 1; | |
1118 } | |
1119 else { | |
1120 v = Gainpow2(gr_info->full_gain[lwin] + ((*scf++) << shift)); | |
1121 step = 3; | |
1122 } | |
1123 } | |
1124 mc--; | |
1125 } | |
1126 if( (a & (0x8>>i)) ) { | |
1127 max[lwin] = cb; | |
1128 part2remain--; | |
1129 if(part2remain < 0) { | |
1130 part2remain++; | |
1131 break; | |
1132 } | |
1133 if(get1bit()) { | |
1134 *xrpnt = *xr0pnt + v; | |
1135 *xr0pnt -= v; | |
1136 } | |
1137 else { | |
1138 *xrpnt = *xr0pnt - v; | |
1139 *xr0pnt += v; | |
1140 } | |
1141 } | |
1142 else | |
1143 *xrpnt = *xr0pnt; | |
1144 xrpnt += step; | |
1145 xr0pnt += step; | |
1146 } | |
1147 } | |
1148 | |
1149 while( m < me ) { | |
1150 if(!mc) { | |
1151 mc = *m++; | |
1152 xrpnt = ((real *) xr[1]) + *m; | |
1153 xr0pnt = ((real *) xr[0]) + *m++; | |
1154 if(*m++ == 3) | |
1155 step = 1; | |
1156 else | |
1157 step = 3; | |
1158 m++; /* cb */ | |
1159 } | |
1160 mc--; | |
1161 *xrpnt = *xr0pnt; | |
1162 xrpnt += step; | |
1163 xr0pnt += step; | |
1164 *xrpnt = *xr0pnt; | |
1165 xrpnt += step; | |
1166 xr0pnt += step; | |
1167 /* we could add a little opt. here: | |
1168 * if we finished a band for window 3 or a long band | |
1169 * further bands could copied in a simple loop without a | |
1170 * special 'map' decoding | |
1171 */ | |
1172 } | |
1173 | |
1174 gr_info->maxband[0] = max[0]+1; | |
1175 gr_info->maxband[1] = max[1]+1; | |
1176 gr_info->maxband[2] = max[2]+1; | |
1177 gr_info->maxbandl = max[3]+1; | |
1178 | |
1179 { | |
1180 int rmax = max[0] > max[1] ? max[0] : max[1]; | |
1181 rmax = (rmax > max[2] ? rmax : max[2]) + 1; | |
1182 gr_info->maxb = rmax ? shortLimit[sfreq][rmax] : longLimit[sfreq][max[3]+1]; | |
1183 } | |
1184 } | |
1185 else { | |
1186 int *pretab = gr_info->preflag ? pretab1 : pretab2; | |
1187 int i,max = -1; | |
1188 int cb = 0; | |
1189 register int mc=0,*m = map[sfreq][2]; | |
1190 register real v = 0.0; | |
1191 #if 0 | |
1192 me = mapend[sfreq][2]; | |
1193 #endif | |
1194 | |
1195 for(i=0;i<3;i++) { | |
1196 int lp = l[i]; | |
1197 struct newhuff *h = ht+gr_info->table_select[i]; | |
1198 | |
1199 for(;lp;lp--,mc--) { | |
1200 int x,y; | |
1201 if(!mc) { | |
1202 mc = *m++; | |
1203 cb = *m++; | |
1204 v = Gainpow2(gr_info->pow2gain + (((*scf++) + (*pretab++)) << shift)); | |
1205 } | |
1206 { | |
1207 register short *val = h->table; | |
1208 while((y=*val++)<0) { | |
1209 part2remain--; | |
716 | 1210 if(part2remain < 0) return 1; |
1 | 1211 if (get1bit()) val -= y; |
1212 } | |
1213 x = y >> 4; | |
1214 y &= 0xf; | |
1215 } | |
1216 if (x == 15) { | |
1217 max = cb; | |
1218 part2remain -= h->linbits+1; | |
1219 x += getbits(h->linbits); | |
1220 if(get1bit()) { | |
1221 real a = ispow[x] * v; | |
1222 *xrpnt++ = *xr0pnt + a; | |
1223 *xr0pnt++ -= a; | |
1224 } | |
1225 else { | |
1226 real a = ispow[x] * v; | |
1227 *xrpnt++ = *xr0pnt - a; | |
1228 *xr0pnt++ += a; | |
1229 } | |
1230 } | |
1231 else if(x) { | |
1232 max = cb; | |
1233 if(get1bit()) { | |
1234 real a = ispow[x] * v; | |
1235 *xrpnt++ = *xr0pnt + a; | |
1236 *xr0pnt++ -= a; | |
1237 } | |
1238 else { | |
1239 real a = ispow[x] * v; | |
1240 *xrpnt++ = *xr0pnt - a; | |
1241 *xr0pnt++ += a; | |
1242 } | |
1243 part2remain--; | |
1244 } | |
1245 else | |
1246 *xrpnt++ = *xr0pnt++; | |
1247 | |
1248 if (y == 15) { | |
1249 max = cb; | |
1250 part2remain -= h->linbits+1; | |
1251 y += getbits(h->linbits); | |
1252 if(get1bit()) { | |
1253 real a = ispow[y] * v; | |
1254 *xrpnt++ = *xr0pnt + a; | |
1255 *xr0pnt++ -= a; | |
1256 } | |
1257 else { | |
1258 real a = ispow[y] * v; | |
1259 *xrpnt++ = *xr0pnt - a; | |
1260 *xr0pnt++ += a; | |
1261 } | |
1262 } | |
1263 else if(y) { | |
1264 max = cb; | |
1265 if(get1bit()) { | |
1266 real a = ispow[y] * v; | |
1267 *xrpnt++ = *xr0pnt + a; | |
1268 *xr0pnt++ -= a; | |
1269 } | |
1270 else { | |
1271 real a = ispow[y] * v; | |
1272 *xrpnt++ = *xr0pnt - a; | |
1273 *xr0pnt++ += a; | |
1274 } | |
1275 part2remain--; | |
1276 } | |
1277 else | |
1278 *xrpnt++ = *xr0pnt++; | |
1279 } | |
1280 } | |
1281 | |
1282 for(;l3 && (part2remain > 0);l3--) { | |
1283 struct newhuff *h = htc+gr_info->count1table_select; | |
1284 register short *val = h->table,a; | |
1285 | |
1286 while((a=*val++)<0) { | |
1287 part2remain--; | |
1288 if(part2remain < 0) { | |
1289 part2remain++; | |
1290 a = 0; | |
1291 break; | |
1292 } | |
1293 if (get1bit()) val -= a; | |
1294 } | |
1295 | |
1296 for(i=0;i<4;i++) { | |
1297 if(!(i & 1)) { | |
1298 if(!mc) { | |
1299 mc = *m++; | |
1300 cb = *m++; | |
1301 v = Gainpow2(gr_info->pow2gain + (((*scf++) + (*pretab++)) << shift)); | |
1302 } | |
1303 mc--; | |
1304 } | |
1305 if ( (a & (0x8>>i)) ) { | |
1306 max = cb; | |
1307 part2remain--; | |
1308 if(part2remain <= 0) { | |
1309 part2remain++; | |
1310 break; | |
1311 } | |
1312 if(get1bit()) { | |
1313 *xrpnt++ = *xr0pnt + v; | |
1314 *xr0pnt++ -= v; | |
1315 } | |
1316 else { | |
1317 *xrpnt++ = *xr0pnt - v; | |
1318 *xr0pnt++ += v; | |
1319 } | |
1320 } | |
1321 else | |
1322 *xrpnt++ = *xr0pnt++; | |
1323 } | |
1324 } | |
1325 for(i=(&xr[1][SBLIMIT][0]-xrpnt)>>1;i;i--) { | |
1326 *xrpnt++ = *xr0pnt++; | |
1327 *xrpnt++ = *xr0pnt++; | |
1328 } | |
1329 | |
1330 gr_info->maxbandl = max+1; | |
1331 gr_info->maxb = longLimit[sfreq][gr_info->maxbandl]; | |
1332 } | |
1333 | |
1334 while ( part2remain > 16 ) { | |
1335 getbits(16); /* Dismiss stuffing Bits */ | |
1336 part2remain -= 16; | |
1337 } | |
1338 if(part2remain > 0 ) | |
1339 getbits(part2remain); | |
1340 else if(part2remain < 0) { | |
1341 printf("\rCan't rewind stream by %d bits! \n",(-part2remain)); | |
1342 // fprintf(stderr,"mpg123: Can't rewind stream by %d bits (left=%d)!\n",(-part2remain),bitsleft); | |
1343 // fprintf(stderr,"mpg123_ms: Can't rewind stream by %d bits!\n",(-part2remain)); | |
1344 return 1; /* -> error */ | |
1345 } | |
1346 return 0; | |
1347 } | |
1348 | |
1349 /* | |
1350 * III_stereo: calculate real channel values for Joint-I-Stereo-mode | |
1351 */ | |
1352 static void III_i_stereo(real xr_buf[2][SBLIMIT][SSLIMIT],int *scalefac, | |
1353 struct gr_info_s *gr_info,int sfreq,int ms_stereo,int lsf) | |
1354 { | |
1355 real (*xr)[SBLIMIT*SSLIMIT] = (real (*)[SBLIMIT*SSLIMIT] ) xr_buf; | |
1356 struct bandInfoStruct *bi = &bandInfo[sfreq]; | |
1357 real *tab1,*tab2; | |
1358 | |
1359 if(lsf) { | |
1360 int p = gr_info->scalefac_compress & 0x1; | |
1361 if(ms_stereo) { | |
1362 tab1 = pow1_2[p]; tab2 = pow2_2[p]; | |
1363 } | |
1364 else { | |
1365 tab1 = pow1_1[p]; tab2 = pow2_1[p]; | |
1366 } | |
1367 } | |
1368 else { | |
1369 if(ms_stereo) { | |
1370 tab1 = tan1_2; tab2 = tan2_2; | |
1371 } | |
1372 else { | |
1373 tab1 = tan1_1; tab2 = tan2_1; | |
1374 } | |
1375 } | |
1376 | |
1377 if (gr_info->block_type == 2) | |
1378 { | |
1379 int lwin,do_l = 0; | |
1380 if( gr_info->mixed_block_flag ) | |
1381 do_l = 1; | |
1382 | |
1383 for (lwin=0;lwin<3;lwin++) /* process each window */ | |
1384 { | |
1385 /* get first band with zero values */ | |
1386 int is_p,sb,idx,sfb = gr_info->maxband[lwin]; /* sfb is minimal 3 for mixed mode */ | |
1387 if(sfb > 3) | |
1388 do_l = 0; | |
1389 | |
1390 for(;sfb<12;sfb++) | |
1391 { | |
1392 is_p = scalefac[sfb*3+lwin-gr_info->mixed_block_flag]; /* scale: 0-15 */ | |
1393 if(is_p != 7) { | |
1394 real t1,t2; | |
1395 sb = bi->shortDiff[sfb]; | |
1396 idx = bi->shortIdx[sfb] + lwin; | |
1397 t1 = tab1[is_p]; t2 = tab2[is_p]; | |
1398 for (; sb > 0; sb--,idx+=3) | |
1399 { | |
1400 real v = xr[0][idx]; | |
1401 xr[0][idx] = v * t1; | |
1402 xr[1][idx] = v * t2; | |
1403 } | |
1404 } | |
1405 } | |
1406 | |
1407 #if 1 | |
1408 /* in the original: copy 10 to 11 , here: copy 11 to 12 | |
1409 maybe still wrong??? (copy 12 to 13?) */ | |
1410 is_p = scalefac[11*3+lwin-gr_info->mixed_block_flag]; /* scale: 0-15 */ | |
1411 sb = bi->shortDiff[12]; | |
1412 idx = bi->shortIdx[12] + lwin; | |
1413 #else | |
1414 is_p = scalefac[10*3+lwin-gr_info->mixed_block_flag]; /* scale: 0-15 */ | |
1415 sb = bi->shortDiff[11]; | |
1416 idx = bi->shortIdx[11] + lwin; | |
1417 #endif | |
1418 if(is_p != 7) | |
1419 { | |
1420 real t1,t2; | |
1421 t1 = tab1[is_p]; t2 = tab2[is_p]; | |
1422 for ( ; sb > 0; sb--,idx+=3 ) | |
1423 { | |
1424 real v = xr[0][idx]; | |
1425 xr[0][idx] = v * t1; | |
1426 xr[1][idx] = v * t2; | |
1427 } | |
1428 } | |
1429 } /* end for(lwin; .. ; . ) */ | |
1430 | |
1431 if (do_l) | |
1432 { | |
1433 /* also check l-part, if ALL bands in the three windows are 'empty' | |
1434 * and mode = mixed_mode | |
1435 */ | |
1436 int sfb = gr_info->maxbandl; | |
1437 int idx = bi->longIdx[sfb]; | |
1438 | |
1439 for ( ; sfb<8; sfb++ ) | |
1440 { | |
1441 int sb = bi->longDiff[sfb]; | |
1442 int is_p = scalefac[sfb]; /* scale: 0-15 */ | |
1443 if(is_p != 7) { | |
1444 real t1,t2; | |
1445 t1 = tab1[is_p]; t2 = tab2[is_p]; | |
1446 for ( ; sb > 0; sb--,idx++) | |
1447 { | |
1448 real v = xr[0][idx]; | |
1449 xr[0][idx] = v * t1; | |
1450 xr[1][idx] = v * t2; | |
1451 } | |
1452 } | |
1453 else | |
1454 idx += sb; | |
1455 } | |
1456 } | |
1457 } | |
1458 else /* ((gr_info->block_type != 2)) */ | |
1459 { | |
1460 int sfb = gr_info->maxbandl; | |
1461 int is_p,idx = bi->longIdx[sfb]; | |
1462 for ( ; sfb<21; sfb++) | |
1463 { | |
1464 int sb = bi->longDiff[sfb]; | |
1465 is_p = scalefac[sfb]; /* scale: 0-15 */ | |
1466 if(is_p != 7) { | |
1467 real t1,t2; | |
1468 t1 = tab1[is_p]; t2 = tab2[is_p]; | |
1469 for ( ; sb > 0; sb--,idx++) | |
1470 { | |
1471 real v = xr[0][idx]; | |
1472 xr[0][idx] = v * t1; | |
1473 xr[1][idx] = v * t2; | |
1474 } | |
1475 } | |
1476 else | |
1477 idx += sb; | |
1478 } | |
1479 | |
1480 is_p = scalefac[20]; /* copy l-band 20 to l-band 21 */ | |
1481 if(is_p != 7) | |
1482 { | |
1483 int sb; | |
1484 real t1 = tab1[is_p],t2 = tab2[is_p]; | |
1485 | |
1486 for ( sb = bi->longDiff[21]; sb > 0; sb--,idx++ ) | |
1487 { | |
1488 real v = xr[0][idx]; | |
1489 xr[0][idx] = v * t1; | |
1490 xr[1][idx] = v * t2; | |
1491 } | |
1492 } | |
1493 } /* ... */ | |
1494 } | |
1495 | |
1496 static void III_antialias(real xr[SBLIMIT][SSLIMIT],struct gr_info_s *gr_info) | |
1497 { | |
1498 int sblim; | |
1499 | |
1500 if(gr_info->block_type == 2) { | |
1501 if(!gr_info->mixed_block_flag) return; | |
1502 sblim = 1; | |
1503 } else { | |
1504 sblim = gr_info->maxb-1; | |
1505 } | |
1506 | |
1507 //printf("sblim=%d\n",sblim); | |
1508 //if(sblim<=0 || sblim>SBLIMIT) return; | |
1509 | |
1510 /* 31 alias-reduction operations between each pair of sub-bands */ | |
1511 /* with 8 butterflies between each pair */ | |
1512 | |
1513 { int sb; | |
1514 real *xr1=(real *) xr[1]; | |
1515 | |
1516 for(sb=sblim;sb;sb--,xr1+=10) { | |
1517 int ss; | |
1518 real *cs=aa_cs,*ca=aa_ca; | |
1519 real *xr2 = xr1; | |
1520 | |
1521 for(ss=7;ss>=0;ss--) { /* upper and lower butterfly inputs */ | |
1522 register real bu = *--xr2,bd = *xr1; | |
1523 *xr2 = (bu * (*cs) ) - (bd * (*ca) ); | |
1524 *xr1++ = (bd * (*cs++) ) + (bu * (*ca++) ); | |
1525 } | |
1526 } | |
1527 | |
1528 } | |
1529 } | |
1530 | |
1531 #include "dct64.c" | |
1532 #include "dct36.c" | |
1533 #include "dct12.c" | |
1534 | |
1535 #include "decod386.c" | |
1536 | |
1537 /* | |
1538 * III_hybrid | |
1539 */ | |
1245
03b7e2955a20
Added newest MMX-optimized decore which speedups decoding at least on 13% for any cpu.
nick
parents:
716
diff
changeset
|
1540 |
03b7e2955a20
Added newest MMX-optimized decore which speedups decoding at least on 13% for any cpu.
nick
parents:
716
diff
changeset
|
1541 dct36_func_t dct36_func; |
03b7e2955a20
Added newest MMX-optimized decore which speedups decoding at least on 13% for any cpu.
nick
parents:
716
diff
changeset
|
1542 |
1 | 1543 static void III_hybrid(real fsIn[SBLIMIT][SSLIMIT],real tsOut[SSLIMIT][SBLIMIT], |
1544 int ch,struct gr_info_s *gr_info) | |
1545 { | |
1546 real *tspnt = (real *) tsOut; | |
1547 static real block[2][2][SBLIMIT*SSLIMIT] = { { { 0, } } }; | |
1548 static int blc[2]={0,0}; | |
1549 real *rawout1,*rawout2; | |
1550 int bt; | |
1551 int sb = 0; | |
1552 | |
1553 { | |
1554 int b = blc[ch]; | |
1555 rawout1=block[b][ch]; | |
1556 b=-b+1; | |
1557 rawout2=block[b][ch]; | |
1558 blc[ch] = b; | |
1559 } | |
1560 | |
1561 if(gr_info->mixed_block_flag) { | |
1562 sb = 2; | |
1245
03b7e2955a20
Added newest MMX-optimized decore which speedups decoding at least on 13% for any cpu.
nick
parents:
716
diff
changeset
|
1563 (*dct36_func)(fsIn[0],rawout1,rawout2,win[0],tspnt); |
03b7e2955a20
Added newest MMX-optimized decore which speedups decoding at least on 13% for any cpu.
nick
parents:
716
diff
changeset
|
1564 (*dct36_func)(fsIn[1],rawout1+18,rawout2+18,win1[0],tspnt+1); |
1 | 1565 rawout1 += 36; rawout2 += 36; tspnt += 2; |
1566 } | |
1567 | |
1568 bt = gr_info->block_type; | |
1569 if(bt == 2) { | |
1570 for (; sb<gr_info->maxb; sb+=2,tspnt+=2,rawout1+=36,rawout2+=36) { | |
1571 dct12(fsIn[sb],rawout1,rawout2,win[2],tspnt); | |
1572 dct12(fsIn[sb+1],rawout1+18,rawout2+18,win1[2],tspnt+1); | |
1573 } | |
1574 } | |
1575 else { | |
1576 for (; sb<gr_info->maxb; sb+=2,tspnt+=2,rawout1+=36,rawout2+=36) { | |
1245
03b7e2955a20
Added newest MMX-optimized decore which speedups decoding at least on 13% for any cpu.
nick
parents:
716
diff
changeset
|
1577 (*dct36_func)(fsIn[sb],rawout1,rawout2,win[bt],tspnt); |
03b7e2955a20
Added newest MMX-optimized decore which speedups decoding at least on 13% for any cpu.
nick
parents:
716
diff
changeset
|
1578 (*dct36_func)(fsIn[sb+1],rawout1+18,rawout2+18,win1[bt],tspnt+1); |
1 | 1579 } |
1580 } | |
1581 | |
1582 for(;sb<SBLIMIT;sb++,tspnt++) { | |
1583 int i; | |
1584 for(i=0;i<SSLIMIT;i++) { | |
1585 tspnt[i*SBLIMIT] = *rawout1++; | |
1586 *rawout2++ = 0.0; | |
1587 } | |
1588 } | |
1589 } | |
1590 | |
1591 /* | |
1592 * main layer3 handler | |
1593 */ | |
1594 /* int do_layer3(struct frame *fr,int outmode,struct audio_info_struct *ai) */ | |
1595 static int do_layer3(struct frame *fr,int single){ | |
1596 int gr, ch, ss,clip=0; | |
1597 int scalefacs[2][39]; /* max 39 for short[13][3] mode, mixed: 38, long: 22 */ | |
1598 struct III_sideinfo sideinfo; | |
1599 int stereo = fr->stereo; | |
1600 int ms_stereo,i_stereo; | |
1601 int sfreq = fr->sampling_frequency; | |
1602 int stereo1,granules; | |
1603 | |
1604 // if (fr->error_protection) getbits(16); /* skip crc */ | |
1605 | |
1606 if(stereo == 1) { /* stream is mono */ | |
1607 stereo1 = 1; | |
1608 single = 0; | |
1609 } else | |
1610 if(single >= 0) /* stream is stereo, but force to mono */ | |
1611 stereo1 = 1; | |
1612 else | |
1613 stereo1 = 2; | |
1614 | |
1615 if(fr->mode == MPG_MD_JOINT_STEREO) { | |
1616 ms_stereo = fr->mode_ext & 0x2; | |
1617 i_stereo = fr->mode_ext & 0x1; | |
1618 } else | |
1619 ms_stereo = i_stereo = 0; | |
1620 | |
1621 if(fr->lsf) { | |
1622 granules = 1; | |
1623 III_get_side_info_2(&sideinfo,stereo,ms_stereo,sfreq,single); | |
1624 } else { | |
1625 granules = 2; | |
1626 III_get_side_info_1(&sideinfo,stereo,ms_stereo,sfreq,single); | |
1627 } | |
1628 | |
1629 set_pointer(sideinfo.main_data_begin); | |
1630 | |
1631 for (gr=0;gr<granules;gr++){ | |
1632 static real hybridIn[2][SBLIMIT][SSLIMIT]; | |
1633 static real hybridOut[2][SSLIMIT][SBLIMIT]; | |
1634 | |
1635 { struct gr_info_s *gr_info = &(sideinfo.ch[0].gr[gr]); | |
1636 long part2bits; | |
1637 if(fr->lsf) | |
1638 part2bits = III_get_scale_factors_2(scalefacs[0],gr_info,0); | |
1639 else | |
1640 part2bits = III_get_scale_factors_1(scalefacs[0],gr_info); | |
1641 if(III_dequantize_sample(hybridIn[0], scalefacs[0],gr_info,sfreq,part2bits)) | |
1642 return clip; | |
1643 } | |
1644 | |
1645 if(stereo == 2) { | |
1646 struct gr_info_s *gr_info = &(sideinfo.ch[1].gr[gr]); | |
1647 | |
1648 long part2bits; | |
1649 if(fr->lsf) | |
1650 part2bits = III_get_scale_factors_2(scalefacs[1],gr_info,i_stereo); | |
1651 else | |
1652 part2bits = III_get_scale_factors_1(scalefacs[1],gr_info); | |
1653 | |
1654 if(ms_stereo) { | |
1655 if(III_dequantize_sample_ms(hybridIn,scalefacs[1],gr_info,sfreq,part2bits)) | |
1656 return clip; | |
1657 } else { | |
1658 if(III_dequantize_sample(hybridIn[1],scalefacs[1],gr_info,sfreq,part2bits)) | |
1659 return clip; | |
1660 } | |
1661 | |
1662 if(i_stereo) | |
1663 III_i_stereo(hybridIn,scalefacs[1],gr_info,sfreq,ms_stereo,fr->lsf); | |
1664 | |
1665 if(ms_stereo || i_stereo || (single == 3) ) { | |
1666 if(gr_info->maxb > sideinfo.ch[0].gr[gr].maxb) | |
1667 sideinfo.ch[0].gr[gr].maxb = gr_info->maxb; | |
1668 else | |
1669 gr_info->maxb = sideinfo.ch[0].gr[gr].maxb; | |
1670 } | |
1671 | |
1672 switch(single) { | |
1673 case 3: { | |
1674 register int i; | |
1675 register real *in0 = (real *) hybridIn[0],*in1 = (real *) hybridIn[1]; | |
1676 for(i=0;i<SSLIMIT*gr_info->maxb;i++,in0++) | |
1677 *in0 = (*in0 + *in1++); /* *0.5 done by pow-scale */ | |
1678 break; } | |
1679 case 1: { | |
1680 register int i; | |
1681 register real *in0 = (real *) hybridIn[0],*in1 = (real *) hybridIn[1]; | |
1682 for(i=0;i<SSLIMIT*gr_info->maxb;i++) | |
1683 *in0++ = *in1++; | |
1684 break; } | |
1685 } | |
1686 | |
1687 } // if(stereo == 2) | |
1688 | |
1689 for(ch=0;ch<stereo1;ch++) { | |
1690 struct gr_info_s *gr_info = &(sideinfo.ch[ch].gr[gr]); | |
1691 III_antialias(hybridIn[ch],gr_info); | |
1692 III_hybrid(hybridIn[ch], hybridOut[ch], ch,gr_info); | |
1693 } | |
1694 | |
1695 for(ss=0;ss<SSLIMIT;ss++) { | |
1696 if(single >= 0) { | |
1697 clip += (fr->synth_mono)(hybridOut[0][ss],pcm_sample,&pcm_point); | |
1698 } else { | |
1699 int p1 = pcm_point; | |
1700 clip += (fr->synth)(hybridOut[0][ss],0,pcm_sample,&p1); | |
1701 clip += (fr->synth)(hybridOut[1][ss],1,pcm_sample,&pcm_point); | |
1702 } | |
1703 } | |
1704 | |
1705 } | |
1706 | |
1707 return clip; | |
1708 } | |
1709 | |
1710 |