add source code that does not have location annotations.
[IRC.git] / Robust / src / Benchmarks / SSJava / MP3DecoderInfer / LayerIIIDecoder.java
1 /*
2  * 11/19/04      1.0 moved to LGPL.
3  * 
4  * 18/06/01  Michael Scheerer,  Fixed bugs which causes
5  *           negative indexes in method huffmann_decode and in method 
6  *           dequanisize_sample.
7  *
8  * 16/07/01  Michael Scheerer, Catched a bug in method
9  *           huffmann_decode, which causes an outOfIndexException.
10  *           Cause : Indexnumber of 24 at SfBandIndex,
11  *           which has only a length of 22. I have simply and dirty 
12  *           fixed the index to <= 22, because I'm not really be able
13  *           to fix the bug. The Indexnumber is taken from the MP3 
14  *           file and the origin Ma-Player with the same code works 
15  *           well.      
16  * 
17  * 02/19/99  Java Conversion by E.B, javalayer@javazoom.net
18  *-----------------------------------------------------------------------
19  *   This program is free software; you can redistribute it and/or modify
20  *   it under the terms of the GNU Library General Public License as published
21  *   by the Free Software Foundation; either version 2 of the License, or
22  *   (at your option) any later version.
23  *
24  *   This program is distributed in the hope that it will be useful,
25  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
26  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27  *   GNU Library General Public License for more details.
28  *
29  *   You should have received a copy of the GNU Library General Public
30  *   License along with this program; if not, write to the Free Software
31  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
32  *----------------------------------------------------------------------
33  */
34
35 /**
36  * Class Implementing Layer 3 Decoder.
37  * 
38  * @since 0.0
39  */
40 // 
41 // 4th line added for hybrid.
42 // 5th added for stereo
43 // 6th added for reorder method
44 // 7th added for huffman_decode method
45 // 8th added for get_LSF_scale_data
46 // 9th added for get_LSF_scale_factors
47 // 10th added for get_scale_factors
48 // llth added for decode
49 // 
50
51
52 final class LayerIIIDecoder implements FrameDecoder {
53   static final double d43 = (4.0 / 3.0);
54   
55   public int[] scalefac_buffer;
56
57   // MDM: removed, as this wasn't being used.
58   // private float CheckSumOut1d = 0.0f;
59   
60   private int CheckSumHuff = 0;
61   
62   private int[] is_1d;
63   
64   private float[][][] ro;
65   
66   private float[][][] lr;
67   
68   private float[] inter; // 576 samples
69   
70   private float[] out_1d; // 576 samples
71   
72   private float[][] prevblck;
73
74   
75   private float[][] k;
76   
77   private int[] nonzero;
78   
79   private SynthesisFilter filter1;
80   
81   private SynthesisFilter filter2;
82   // 
83   // private Obuffer buffer; // output buffer
84   
85   private int which_channels;
86   
87   private BitReserve br;
88   
89   private III_side_info_t si;
90
91   //  private temporaire2[] III_scalefac_t;
92   
93   private final temporaire2[] scalefac;
94   // private III_scalefac_t scalefac;
95
96   
97   private int max_gr;
98   
99   private int frame_start;
100   //  private int part2_start;
101   
102   private final int channels;
103   
104   private int first_channel;
105   
106   private int last_channel;
107   
108   private int sfreq;
109
110   
111   private int part2_start;
112
113   
114   private boolean initialized = false;
115
116   
117   float[][] raw_full; // 18 left shfited since it will be copied into prevblck!
118
119   // constructor for the linear type system
120   public LayerIIIDecoder(Header h, @DELEGATE  SynthesisFilter filtera,
121       @DELEGATE  SynthesisFilter filterb,  int which_ch0) {
122
123     filter_pos = 11;
124     raw_full = new float[2][SBLIMIT * SSLIMIT];
125
126     filter1 = filtera;
127     filter2 = filterb;
128
129     huffcodetab.inithuff();
130     is_1d = new int[SBLIMIT * SSLIMIT + 4];
131     ro = new float[2][SBLIMIT][SSLIMIT];
132     lr = new float[2][SBLIMIT][SSLIMIT];
133     out_1d = new float[SBLIMIT * SSLIMIT];
134     inter = new float[SBLIMIT * SSLIMIT];
135     prevblck = new float[2][SBLIMIT * SSLIMIT];
136     k = new float[2][SBLIMIT * SSLIMIT];
137     nonzero = new int[2];
138
139     // removes unnecessary aliases
140     // III_scalefact_t
141     // III_scalefac_t = new temporaire2[2];
142     // III_scalefac_t[0] = new temporaire2();
143     // III_scalefac_t[1] = new temporaire2();
144     // scalefac = III_scalefac_t;
145
146     scalefac = new temporaire2[2];
147     scalefac[0] = new temporaire2();
148     scalefac[1] = new temporaire2();
149
150     // L3TABLE INIT
151
152     sfBandIndex = new SBI[9]; // SZD: MPEG2.5 +3 indices
153      int[] l0 =
154         { 0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396,
155             464, 522, 576 };
156      int[] s0 = { 0, 4, 8, 12, 18, 24, 32, 42, 56, 74, 100, 132, 174, 192 };
157      int[] l1 =
158         { 0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 114, 136, 162, 194, 232, 278, 330, 394,
159             464, 540, 576 };
160      int[] s1 = { 0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 136, 180, 192 };
161      int[] l2 =
162         { 0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396,
163             464, 522, 576 };
164      int[] s2 = { 0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 134, 174, 192 };
165
166      int[] l3 =
167         { 0, 4, 8, 12, 16, 20, 24, 30, 36, 44, 52, 62, 74, 90, 110, 134, 162, 196, 238, 288, 342,
168             418, 576 };
169      int[] s3 = { 0, 4, 8, 12, 16, 22, 30, 40, 52, 66, 84, 106, 136, 192 };
170      int[] l4 =
171         { 0, 4, 8, 12, 16, 20, 24, 30, 36, 42, 50, 60, 72, 88, 106, 128, 156, 190, 230, 276, 330,
172             384, 576 };
173      int[] s4 = { 0, 4, 8, 12, 16, 22, 28, 38, 50, 64, 80, 100, 126, 192 };
174      int[] l5 =
175         { 0, 4, 8, 12, 16, 20, 24, 30, 36, 44, 54, 66, 82, 102, 126, 156, 194, 240, 296, 364, 448,
176             550, 576 };
177      int[] s5 = { 0, 4, 8, 12, 16, 22, 30, 42, 58, 78, 104, 138, 180, 192 };
178     // SZD: MPEG2.5
179      int[] l6 =
180         { 0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396,
181             464, 522, 576 };
182      int[] s6 = { 0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 134, 174, 192 };
183      int[] l7 =
184         { 0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396,
185             464, 522, 576 };
186      int[] s7 = { 0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 134, 174, 192 };
187      int[] l8 =
188         { 0, 12, 24, 36, 48, 60, 72, 88, 108, 132, 160, 192, 232, 280, 336, 400, 476, 566, 568,
189             570, 572, 574, 576 };
190      int[] s8 = { 0, 8, 16, 24, 36, 52, 72, 96, 124, 160, 162, 164, 166, 192 };
191
192     sfBandIndex[0] = new SBI(l0, s0);
193     sfBandIndex[1] = new SBI(l1, s1);
194     sfBandIndex[2] = new SBI(l2, s2);
195
196     sfBandIndex[3] = new SBI(l3, s3);
197     sfBandIndex[4] = new SBI(l4, s4);
198     sfBandIndex[5] = new SBI(l5, s5);
199     // SZD: MPEG2.5
200     sfBandIndex[6] = new SBI(l6, s6);
201     sfBandIndex[7] = new SBI(l7, s7);
202     sfBandIndex[8] = new SBI(l8, s8);
203     // END OF L3TABLE INIT
204
205     if (reorder_table == null) { // SZD: generate LUT
206       reorder_table = new int[9][];
207       for ( int i = 0; i < 9; i++)
208         reorder_table[i] = reorder(sfBandIndex[i].s);
209     }
210
211     // scalefac_buffer
212     scalefac_buffer = new int[54];
213     // END OF scalefac_buffer
214
215     init(h);
216   }
217
218   
219   private void init( Header header) {
220
221     frame_start = 0;
222     channels = (header.mode() == Header.SINGLE_CHANNEL) ? 1 : 2;
223     max_gr = (header.version() == Header.MPEG1) ? 2 : 1;
224
225     sfreq =
226         header.sample_frequency()
227             + ((header.version() == Header.MPEG1) ? 3 : (header.version() == Header.MPEG25_LSF) ? 6
228                 : 0); // SZD
229
230     if (channels == 2) {
231       switch (which_channels) {
232       case OutputChannels.LEFT_CHANNEL:
233       case OutputChannels.DOWNMIX_CHANNELS:
234         first_channel = last_channel = 0;
235         break;
236
237       case OutputChannels.RIGHT_CHANNEL:
238         first_channel = last_channel = 1;
239         break;
240
241       case OutputChannels.BOTH_CHANNELS:
242       default:
243         first_channel = 0;
244         last_channel = 1;
245         break;
246       }
247     } else {
248       first_channel = last_channel = 0;
249     }
250
251     for ( int ch = 0; ch < 2; ch++)
252       for ( int j = 0; j < 576; j++)
253         prevblck[ch][j] = 0.0f;
254
255     nonzero[0] = nonzero[1] = 576;
256
257     si = new III_side_info_t();
258
259     initialized = true;
260
261   }
262
263   /**
264    * Constructor.
265    */
266   // REVIEW: these constructor arguments should be moved to the
267   // decodeFrame() method, where possible, so that one
268   // 
269   // public LayerIIIDecoder( Header header0, 
270   // SynthesisFilter filtera,
271   //  SynthesisFilter filterb,  int which_ch0) {
272   //
273   // huffcodetab.inithuff();
274   // is_1d = new int[SBLIMIT * SSLIMIT + 4];
275   // ro = new float[2][SBLIMIT][SSLIMIT];
276   // lr = new float[2][SBLIMIT][SSLIMIT];
277   // out_1d = new float[SBLIMIT * SSLIMIT];
278   // prevblck = new float[2][SBLIMIT * SSLIMIT];
279   // k = new float[2][SBLIMIT * SSLIMIT];
280   // nonzero = new int[2];
281   //
282   // // removes unnecessary aliases
283   // // III_scalefact_t
284   // // III_scalefac_t = new temporaire2[2];
285   // // III_scalefac_t[0] = new temporaire2();
286   // // III_scalefac_t[1] = new temporaire2();
287   // // scalefac = III_scalefac_t;
288   //
289   // scalefac = new temporaire2[2];
290   // scalefac[0] = new temporaire2();
291   // scalefac[1] = new temporaire2();
292   //
293   // // L3TABLE INIT
294   //
295   // sfBandIndex = new SBI[9]; // SZD: MPEG2.5 +3 indices
296   //  int[] l0 =
297   // { 0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238,
298   // 284, 336, 396,
299   // 464, 522, 576 };
300   //  int[] s0 = { 0, 4, 8, 12, 18, 24, 32, 42, 56, 74, 100, 132,
301   // 174, 192 };
302   //  int[] l1 =
303   // { 0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 114, 136, 162, 194, 232,
304   // 278, 330, 394,
305   // 464, 540, 576 };
306   //  int[] s1 = { 0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 136,
307   // 180, 192 };
308   //  int[] l2 =
309   // { 0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238,
310   // 284, 336, 396,
311   // 464, 522, 576 };
312   //  int[] s2 = { 0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 134,
313   // 174, 192 };
314   //
315   //  int[] l3 =
316   // { 0, 4, 8, 12, 16, 20, 24, 30, 36, 44, 52, 62, 74, 90, 110, 134, 162, 196,
317   // 238, 288, 342,
318   // 418, 576 };
319   //  int[] s3 = { 0, 4, 8, 12, 16, 22, 30, 40, 52, 66, 84, 106, 136,
320   // 192 };
321   //  int[] l4 =
322   // { 0, 4, 8, 12, 16, 20, 24, 30, 36, 42, 50, 60, 72, 88, 106, 128, 156, 190,
323   // 230, 276, 330,
324   // 384, 576 };
325   //  int[] s4 = { 0, 4, 8, 12, 16, 22, 28, 38, 50, 64, 80, 100, 126,
326   // 192 };
327   //  int[] l5 =
328   // { 0, 4, 8, 12, 16, 20, 24, 30, 36, 44, 54, 66, 82, 102, 126, 156, 194, 240,
329   // 296, 364, 448,
330   // 550, 576 };
331   //  int[] s5 = { 0, 4, 8, 12, 16, 22, 30, 42, 58, 78, 104, 138,
332   // 180, 192 };
333   // // SZD: MPEG2.5
334   //  int[] l6 =
335   // { 0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238,
336   // 284, 336, 396,
337   // 464, 522, 576 };
338   //  int[] s6 = { 0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 134,
339   // 174, 192 };
340   //  int[] l7 =
341   // { 0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238,
342   // 284, 336, 396,
343   // 464, 522, 576 };
344   //  int[] s7 = { 0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 134,
345   // 174, 192 };
346   //  int[] l8 =
347   // { 0, 12, 24, 36, 48, 60, 72, 88, 108, 132, 160, 192, 232, 280, 336, 400,
348   // 476, 566, 568,
349   // 570, 572, 574, 576 };
350   //  int[] s8 = { 0, 8, 16, 24, 36, 52, 72, 96, 124, 160, 162, 164,
351   // 166, 192 };
352   //
353   // sfBandIndex[0] = new SBI(l0, s0);
354   // sfBandIndex[1] = new SBI(l1, s1);
355   // sfBandIndex[2] = new SBI(l2, s2);
356   //
357   // sfBandIndex[3] = new SBI(l3, s3);
358   // sfBandIndex[4] = new SBI(l4, s4);
359   // sfBandIndex[5] = new SBI(l5, s5);
360   // // SZD: MPEG2.5
361   // sfBandIndex[6] = new SBI(l6, s6);
362   // sfBandIndex[7] = new SBI(l7, s7);
363   // sfBandIndex[8] = new SBI(l8, s8);
364   // // END OF L3TABLE INIT
365   //
366   // if (reorder_table == null) { // SZD: generate LUT
367   // reorder_table = new int[9][];
368   // for ( int i = 0; i < 9; i++)
369   // reorder_table[i] = reorder(sfBandIndex[i].s);
370   // }
371   //
372   // // Sftable
373   //  int[] ll0 = { 0, 6, 11, 16, 21 };
374   //  int[] ss0 = { 0, 6, 12 };
375   // sftable = new Sftable(ll0, ss0);
376   // // END OF Sftable
377   //
378   // // scalefac_buffer
379   // scalefac_buffer = new int[54];
380   // // END OF scalefac_buffer
381   //
382   // // header = header0;
383   // filter1 = filtera;
384   // filter2 = filterb;
385   // // buffer = buffer0;
386   // which_channels = which_ch0;
387   //
388   // frame_start = 0;
389   // channels = (header.mode() == Header.SINGLE_CHANNEL) ? 1 : 2;
390   // max_gr = (header.version() == Header.MPEG1) ? 2 : 1;
391   //
392   // sfreq =
393   // header.sample_frequency()
394   // + ((header.version() == Header.MPEG1) ? 3 : (header.version() ==
395   // Header.MPEG25_LSF) ? 6
396   // : 0); // SZD
397   //
398   // if (channels == 2) {
399   // switch (which_channels) {
400   // case OutputChannels.LEFT_CHANNEL:
401   // case OutputChannels.DOWNMIX_CHANNELS:
402   // first_channel = last_channel = 0;
403   // break;
404   //
405   // case OutputChannels.RIGHT_CHANNEL:
406   // first_channel = last_channel = 1;
407   // break;
408   //
409   // case OutputChannels.BOTH_CHANNELS:
410   // default:
411   // first_channel = 0;
412   // last_channel = 1;
413   // break;
414   // }
415   // } else {
416   // first_channel = last_channel = 0;
417   // }
418   //
419   // for ( int ch = 0; ch < 2; ch++)
420   // for ( int j = 0; j < 576; j++)
421   // prevblck[ch][j] = 0.0f;
422   //
423   // nonzero[0] = nonzero[1] = 576;
424   //
425   // br = new BitReserve();
426   // si = new III_side_info_t();
427   // }
428
429   /**
430    * Notify decoder that a seek is being made.
431    */
432   
433   public void seek_notify() {
434     frame_start = 0;
435     for ( int ch = 0; ch < 2; ch++)
436       for ( int j = 0; j < 576; j++)
437         prevblck[ch][j] = 0.0f;
438     br = new BitReserve();
439   }
440
441   public void decodeFrame( Header header) {
442     decode(header);
443   }
444
445   /**
446    * Decode one frame, filling the buffer with the output samples.
447    */
448
449   // subband samples are buffered and passed to the
450   // SynthesisFilter in one go.
451   
452   private float[] samples1 = new float[32];
453   
454   private float[] samples2 = new float[32];
455   
456   private int filter_pos;
457
458   /*
459    * location hierarchy of decode() {header} {stream} {si} {br, flush_main,
460    * main_data_end,frame_start,nSlots,bytes_to_discard}* {gr,max_gr} // granule
461    * {ch,channels,first_channel, last_channel, which_channels} // channel
462    * {part2_start} {sb18, ss} {out_1d}* {sb}* {samples1,sample2}
463    * {filter1,filter2}
464    */
465   // 
466   
467   public void decode( Header header) {
468
469     // if (!initialized) {
470     // init(header);
471     // }
472
473     // overwrites once per a loop
474     SSJAVA.arrayinit(samples1, 0);
475     SSJAVA.arrayinit(samples2, 0);
476     SSJAVA.arrayinit(ro, 2, SBLIMIT, SSLIMIT, 0);
477     SSJAVA.arrayinit(lr, 2, SBLIMIT, SSLIMIT, 0);
478     SSJAVA.arrayinit(is_pos, 7);
479     SSJAVA.arrayinit(is_ratio, 0);
480     SSJAVA.arrayinit(out_1d, 0);
481     SSJAVA.arrayinit(inter, 0);
482     SSJAVA.arrayinit(k, 2, SBLIMIT * SSLIMIT, 0);
483     SSJAVA.arrayinit(is_1d, 0);
484     SSJAVA.arrayinit(tsOutCopy, 0);
485     SSJAVA.arrayinit(scalefac_buffer, 0);
486     SSJAVA.arrayinit(nonzero, 576);
487     SSJAVA.arrayinit(new_slen, 0);
488
489     SSJAVA.arrayinit(raw_full, 2, SBLIMIT * SSLIMIT, 0);
490     SSJAVA.arrayinit(rawout, 0);
491     CheckSumHuff = 0;
492     // prevblck = new float[2][SBLIMIT * SSLIMIT];
493     si = new III_side_info_t();
494     //
495
496      int nSlots = header.slots();
497
498      int gr;
499      int ch;
500
501      int ss;
502      int sb;
503      int sb18;
504
505      int main_data_end;
506      int flush_main;
507
508      int bytes_to_discard;
509      int i;
510
511     // modifications for linear type
512     get_side_info(header);
513     br = header.getBitReserve();
514
515      int version = header.version();
516
517     // additional codes for the definitely written property
518     filter_pos = (header.getIdx() * 4) & 0xf;
519     filter1.vidx = 1;
520     filter2.vidx = 1;
521     filter1.actual_write_pos = filter_pos;
522     filter2.actual_write_pos = filter_pos;
523
524     // here 'gr' and 'max_gr' should be higher than 'ch','channels', and more
525     for (gr = 0; gr < max_gr; gr++) { // two granules per channel
526       // in the loop body, access set={part2_start}
527
528       // 'ch', 'channels' should be higher than all locs in the below body
529       for (ch = 0; ch < channels; ch++) {
530         // part2_start = br.hsstell();
531          int part2_start_local = br.hsstell();
532
533         // grab scale factors from the main data.
534         // following the scale factors is the actual compressed data
535         if (version == Header.MPEG1)
536           get_scale_factors(header, ch, gr); // no need to care from this side
537         // here move scale factor data from 'br' buffer to 'scalefac' field
538         else
539           // MPEG-2 LSF, SZD: MPEG-2.5 LSF
540           get_LSF_scale_factors(header, ch, gr); // no need to care from this
541                                                  // side
542
543         // here, decoding the compressed audio data
544         huffman_decode(part2_start_local, ch, gr); // no need to care from this
545                                                    // side
546         // System.out.println("CheckSum HuffMan = " + CheckSumHuff);
547         dequantize_sample(/* ro[ch], */ch, gr); // no need to care from this
548                                                 // side
549       }
550
551       stereo(header, gr); // no need to care from this side
552
553       if ((which_channels == OutputChannels.DOWNMIX_CHANNELS) && (channels > 1)) {
554         do_downmix();
555       }
556
557       for (ch = first_channel; ch <= last_channel; ch++) { // 'ch' and
558                                                            // 'first_channel' >
559                                                            // the body
560
561         reorder(/* lr[ch], */ch, gr);
562         antialias(ch, gr);
563
564         // float CheckSumOut1d=0;
565         // for (int hb = 0;hb<576;hb++) {
566         // CheckSumOut1d = CheckSumOut1d + out_1d[hb];
567         // }
568         // System.out.println("CheckSumOut1d = "+CheckSumOut1d);
569
570         for ( int index = 0; index < 576; index++) {
571           out_1d[index] = inter[index];
572         }
573
574         hybrid(ch, gr);
575
576         // float CheckSumOut1d=0;
577         // for (int hb = 0;hb<576;hb++) {
578         // CheckSumOut1d = CheckSumOut1d + out_1d[hb];
579         // }
580         // System.out.println("CheckSumOut1d = "+CheckSumOut1d);
581
582         for (sb18 = 18; sb18 < 576; sb18 += 36) {
583           // sb18 > ss, SSLIMIT, out1d
584           // Frequency inversion
585           for (ss = 1; ss < SSLIMIT; ss += 2) {
586             // 'ss','SSLIMIT' > out_1d
587             out_1d[sb18 + ss] = -out_1d[sb18 + ss]; // out1d*
588           }
589         }
590
591         // 'ch', 'which_channels' should be higher than if/else body!
592         // location set written by if/else body
593         // = {samples1, samples2, filter1, filter2}
594         if ((ch == 0) || (which_channels == OutputChannels.RIGHT_CHANNEL)) {
595           for (ss = 0; ss < SSLIMIT; ss++) { // Polyphase synthesis
596             sb = 0;
597             for (sb18 = 0; sb18 < 576; sb18 += 18) {
598               samples1[sb] = out_1d[sb18 + ss]; // out_1d > samples1
599               // filter1.input_sample(out_1d[sb18+ss], sb);
600               sb++; // sb should be loc*
601             }
602             filter1.input_samples(samples1);
603             // System.out.println("filter1 writepos=" + filter1.actual_write_pos
604             // + " vidx=" + filter1.vidx);
605             filter1.calculate_pcm_samples();
606           }
607         } else {
608           for (ss = 0; ss < SSLIMIT; ss++) { // Polyphase synthesis
609             sb = 0;
610             for (sb18 = 0; sb18 < 576; sb18 += 18) {
611               samples2[sb] = out_1d[sb18 + ss]; // out_1d > samples2
612               // filter2.input_sample(out_1d[sb18+ss], sb);
613               sb++;
614             }
615             filter2.input_samples(samples2);
616             filter2.calculate_pcm_samples();
617           }
618         }
619         // System.out.println("#END CH=" + ch + " actual_write_pos=" +
620         // filter1.actual_write_pos);
621       } // channels
622
623       // TODO
624       if (gr < max_gr - 1) {
625         // init prev
626         SSJAVA.arrayinit(prevblck, 2, SBLIMIT * SSLIMIT, 0);
627         // copy from raw_full to prev
628         SSJAVA.arraycopy(prevblck, raw_full, 2, SBLIMIT * SSLIMIT);
629       }
630       // for (int chidx = 0; chidx < 2; chidx++) {
631       // for (int sidx = 0; sidx < SBLIMIT * SSLIMIT; sidx++) {
632       // prevblck[chidx][sidx] = raw_full[chidx][sidx];
633       // }
634       // }
635       // System.out.println("#END GR=" + gr + " actual_write_pos=" +
636       // filter1.actual_write_pos);
637     } // granule
638
639     // TODO
640     // init prev
641     SSJAVA.arrayinit(prevblck, 2, SBLIMIT * SSLIMIT, 0);
642     // copy from raw_full to prev
643     SSJAVA.arraycopy(prevblck, raw_full, 2, SBLIMIT * SSLIMIT);
644
645     // System.out.println("#END FRAME actual_write_pos=" +
646     // filter1.actual_write_pos);
647
648     filter1.clear();
649     filter2.clear();
650
651     // System.out.println("Counter = ................................."+counter);
652     // if (counter < 609)
653     // {
654     // counter++; // count should be loc*
655     // buffer.write_buffer(1); // buffer!!!
656     // }
657     // else if (counter == 609)
658     // {
659     // buffer.close();
660     // counter++;
661     // }
662     // else
663     // {
664     // }
665
666   }
667
668   /**
669    * Reads the side info from the stream, assuming the entire. frame has been
670    * read already. Mono : 136 bits (= 17 bytes) Stereo : 256 bits (= 32 bytes)
671    */
672   
673   private boolean get_side_info( Header header) {
674
675      SideInfoBuffer sib =
676         header.getSideInfoBuffer();
677      int version = header.version();
678
679      int ch;
680      int gr;
681     // System.out.println("#get_side_info");
682     if (version == Header.MPEG1) {
683
684       si.main_data_begin = sib.get_bits(9);
685       if (channels == 1)
686         si.private_bits = sib.get_bits(5);
687       else
688         si.private_bits = sib.get_bits(3);
689
690       for (ch = 0; ch < channels; ch++) {
691         si.ch[ch].scfsi[0] = sib.get_bits(1);
692         si.ch[ch].scfsi[1] = sib.get_bits(1);
693         si.ch[ch].scfsi[2] = sib.get_bits(1);
694         si.ch[ch].scfsi[3] = sib.get_bits(1);
695       }
696
697       // System.out.println("BEFORE GR,CH");
698
699       for (gr = 0; gr < 2; gr++) {
700         // System.out.println("GR=" + gr);
701         for (ch = 0; ch < channels; ch++) {
702           // System.out.println("CH");
703           si.ch[ch].gr[gr].part2_3_length = sib.get_bits(12);
704           si.ch[ch].gr[gr].big_values = sib.get_bits(9);
705           si.ch[ch].gr[gr].global_gain = sib.get_bits(8);
706           si.ch[ch].gr[gr].scalefac_compress = sib.get_bits(4);
707            int cond = sib.get_bits(1);
708           // si.ch[ch].gr[gr].window_switching_flag = sib.get_bits(1);
709           // if ((si.ch[ch].gr[gr].window_switching_flag) != 0) {
710           if (cond != 0) {
711             si.ch[ch].gr[gr].block_type = sib.get_bits(2);
712             si.ch[ch].gr[gr].mixed_block_flag = sib.get_bits(1);
713
714             si.ch[ch].gr[gr].table_select[0] = sib.get_bits(5);
715             si.ch[ch].gr[gr].table_select[1] = sib.get_bits(5);
716
717             si.ch[ch].gr[gr].subblock_gain[0] = sib.get_bits(3);
718             si.ch[ch].gr[gr].subblock_gain[1] = sib.get_bits(3);
719             si.ch[ch].gr[gr].subblock_gain[2] = sib.get_bits(3);
720
721             // Set region_count parameters since they are implicit
722             // in this case.
723
724             if (si.ch[ch].gr[gr].block_type == 0) {
725               // Side info bad: block_type == 0 in split block
726               return false;
727             } else if (si.ch[ch].gr[gr].block_type == 2 && si.ch[ch].gr[gr].mixed_block_flag == 0) {
728               si.ch[ch].gr[gr].region0_count = 8;
729             } else {
730               si.ch[ch].gr[gr].region0_count = 7;
731             }
732             si.ch[ch].gr[gr].region1_count = 20 - si.ch[ch].gr[gr].region0_count;
733           } else {
734             si.ch[ch].gr[gr].table_select[0] = sib.get_bits(5);
735             si.ch[ch].gr[gr].table_select[1] = sib.get_bits(5);
736             si.ch[ch].gr[gr].table_select[2] = sib.get_bits(5);
737             si.ch[ch].gr[gr].region0_count = sib.get_bits(4);
738             si.ch[ch].gr[gr].region1_count = sib.get_bits(3);
739             si.ch[ch].gr[gr].block_type = 0;
740           }
741           //
742           si.ch[ch].gr[gr].window_switching_flag = cond;
743           //
744           si.ch[ch].gr[gr].preflag = sib.get_bits(1);
745           si.ch[ch].gr[gr].scalefac_scale = sib.get_bits(1);
746           si.ch[ch].gr[gr].count1table_select = sib.get_bits(1);
747         }
748       }
749
750     } else { // MPEG-2 LSF, SZD: MPEG-2.5 LSF
751
752       si.main_data_begin = sib.get_bits(8);
753       if (channels == 1)
754         si.private_bits = sib.get_bits(1);
755       else
756         si.private_bits = sib.get_bits(2);
757
758       for (ch = 0; ch < channels; ch++) {
759
760         si.ch[ch].gr[0].part2_3_length = sib.get_bits(12);
761         si.ch[ch].gr[0].big_values = sib.get_bits(9);
762         si.ch[ch].gr[0].global_gain = sib.get_bits(8);
763         si.ch[ch].gr[0].scalefac_compress = sib.get_bits(9);
764
765          int cond = sib.get_bits(1);
766         // si.ch[ch].gr[0].window_switching_flag = sib.get_bits(1);
767         // if ((si.ch[ch].gr[0].window_switching_flag) != 0) {
768         if (cond != 0) {
769
770           si.ch[ch].gr[0].block_type = sib.get_bits(2);
771           si.ch[ch].gr[0].mixed_block_flag = sib.get_bits(1);
772           si.ch[ch].gr[0].table_select[0] = sib.get_bits(5);
773           si.ch[ch].gr[0].table_select[1] = sib.get_bits(5);
774
775           si.ch[ch].gr[0].subblock_gain[0] = sib.get_bits(3);
776           si.ch[ch].gr[0].subblock_gain[1] = sib.get_bits(3);
777           si.ch[ch].gr[0].subblock_gain[2] = sib.get_bits(3);
778
779           // Set region_count parameters since they are implicit in
780           // this case.
781
782           if (si.ch[ch].gr[0].block_type == 0) {
783             // Side info bad: block_type == 0 in split block
784             return false;
785           } else if (si.ch[ch].gr[0].block_type == 2 && si.ch[ch].gr[0].mixed_block_flag == 0) {
786             si.ch[ch].gr[0].region0_count = 8;
787           } else {
788             si.ch[ch].gr[0].region0_count = 7;
789             si.ch[ch].gr[0].region1_count = 20 - si.ch[ch].gr[0].region0_count;
790           }
791
792         } else {
793           si.ch[ch].gr[0].table_select[0] = sib.get_bits(5);
794           si.ch[ch].gr[0].table_select[1] = sib.get_bits(5);
795           si.ch[ch].gr[0].table_select[2] = sib.get_bits(5);
796           si.ch[ch].gr[0].region0_count = sib.get_bits(4);
797           si.ch[ch].gr[0].region1_count = sib.get_bits(3);
798           si.ch[ch].gr[0].block_type = 0;
799         }
800         //
801         si.ch[ch].gr[gr].window_switching_flag = cond;
802         //
803
804         si.ch[ch].gr[0].scalefac_scale = sib.get_bits(1);
805         si.ch[ch].gr[0].count1table_select = sib.get_bits(1);
806       } // for(ch=0; ch<channels; ch++)
807     } // if (header.version() == MPEG1)
808     return true;
809   }
810
811   /**
812          *
813          */
814   
815   private void get_scale_factors( Header header,
816        int ch,  int gr) {
817
818     // gr_info_s gr_info = (si.ch[ch].gr[gr]); remove alias
819
820      int sfb;
821      int window;
822      int scale_comp = si.ch[ch].gr[gr].scalefac_compress;
823      int length0 = slen[0][scale_comp];
824      int length1 = slen[1][scale_comp];
825
826     if ((si.ch[ch].gr[gr].window_switching_flag != 0) && (si.ch[ch].gr[gr].block_type == 2)) {
827       if ((si.ch[ch].gr[gr].mixed_block_flag) != 0) { // MIXED
828         for (sfb = 0; sfb < 8; sfb++)
829           scalefac[ch].l[sfb] = br.hgetbits(slen[0][si.ch[ch].gr[gr].scalefac_compress]);
830         for (sfb = 3; sfb < 6; sfb++)
831           for (window = 0; window < 3; window++)
832             scalefac[ch].s[window][sfb] = br.hgetbits(slen[0][si.ch[ch].gr[gr].scalefac_compress]);
833         for (sfb = 6; sfb < 12; sfb++)
834           for (window = 0; window < 3; window++)
835             scalefac[ch].s[window][sfb] = br.hgetbits(slen[1][si.ch[ch].gr[gr].scalefac_compress]);
836         for (sfb = 12, window = 0; window < 3; window++)
837           scalefac[ch].s[window][sfb] = 0;
838
839       } else { // SHORT
840
841         scalefac[ch].s[0][0] = br.hgetbits(length0);
842         scalefac[ch].s[1][0] = br.hgetbits(length0);
843         scalefac[ch].s[2][0] = br.hgetbits(length0);
844         scalefac[ch].s[0][1] = br.hgetbits(length0);
845         scalefac[ch].s[1][1] = br.hgetbits(length0);
846         scalefac[ch].s[2][1] = br.hgetbits(length0);
847         scalefac[ch].s[0][2] = br.hgetbits(length0);
848         scalefac[ch].s[1][2] = br.hgetbits(length0);
849         scalefac[ch].s[2][2] = br.hgetbits(length0);
850         scalefac[ch].s[0][3] = br.hgetbits(length0);
851         scalefac[ch].s[1][3] = br.hgetbits(length0);
852         scalefac[ch].s[2][3] = br.hgetbits(length0);
853         scalefac[ch].s[0][4] = br.hgetbits(length0);
854         scalefac[ch].s[1][4] = br.hgetbits(length0);
855         scalefac[ch].s[2][4] = br.hgetbits(length0);
856         scalefac[ch].s[0][5] = br.hgetbits(length0);
857         scalefac[ch].s[1][5] = br.hgetbits(length0);
858         scalefac[ch].s[2][5] = br.hgetbits(length0);
859         scalefac[ch].s[0][6] = br.hgetbits(length1);
860         scalefac[ch].s[1][6] = br.hgetbits(length1);
861         scalefac[ch].s[2][6] = br.hgetbits(length1);
862         scalefac[ch].s[0][7] = br.hgetbits(length1);
863         scalefac[ch].s[1][7] = br.hgetbits(length1);
864         scalefac[ch].s[2][7] = br.hgetbits(length1);
865         scalefac[ch].s[0][8] = br.hgetbits(length1);
866         scalefac[ch].s[1][8] = br.hgetbits(length1);
867         scalefac[ch].s[2][8] = br.hgetbits(length1);
868         scalefac[ch].s[0][9] = br.hgetbits(length1);
869         scalefac[ch].s[1][9] = br.hgetbits(length1);
870         scalefac[ch].s[2][9] = br.hgetbits(length1);
871         scalefac[ch].s[0][10] = br.hgetbits(length1);
872         scalefac[ch].s[1][10] = br.hgetbits(length1);
873         scalefac[ch].s[2][10] = br.hgetbits(length1);
874         scalefac[ch].s[0][11] = br.hgetbits(length1);
875         scalefac[ch].s[1][11] = br.hgetbits(length1);
876         scalefac[ch].s[2][11] = br.hgetbits(length1);
877         scalefac[ch].s[0][12] = 0;
878         scalefac[ch].s[1][12] = 0;
879         scalefac[ch].s[2][12] = 0;
880       } // SHORT
881
882     } else { // LONG types 0,1,3
883
884       if ((si.ch[ch].scfsi[0] == 0) || (gr == 0)) {
885         scalefac[ch].l[0] = br.hgetbits(length0);
886         scalefac[ch].l[1] = br.hgetbits(length0);
887         scalefac[ch].l[2] = br.hgetbits(length0);
888         scalefac[ch].l[3] = br.hgetbits(length0);
889         scalefac[ch].l[4] = br.hgetbits(length0);
890         scalefac[ch].l[5] = br.hgetbits(length0);
891       }
892       if ((si.ch[ch].scfsi[1] == 0) || (gr == 0)) {
893         scalefac[ch].l[6] = br.hgetbits(length0);
894         scalefac[ch].l[7] = br.hgetbits(length0);
895         scalefac[ch].l[8] = br.hgetbits(length0);
896         scalefac[ch].l[9] = br.hgetbits(length0);
897         scalefac[ch].l[10] = br.hgetbits(length0);
898       }
899       if ((si.ch[ch].scfsi[2] == 0) || (gr == 0)) {
900         scalefac[ch].l[11] = br.hgetbits(length1);
901         scalefac[ch].l[12] = br.hgetbits(length1);
902         scalefac[ch].l[13] = br.hgetbits(length1);
903         scalefac[ch].l[14] = br.hgetbits(length1);
904         scalefac[ch].l[15] = br.hgetbits(length1);
905       }
906       if ((si.ch[ch].scfsi[3] == 0) || (gr == 0)) {
907         scalefac[ch].l[16] = br.hgetbits(length1);
908         scalefac[ch].l[17] = br.hgetbits(length1);
909         scalefac[ch].l[18] = br.hgetbits(length1);
910         scalefac[ch].l[19] = br.hgetbits(length1);
911         scalefac[ch].l[20] = br.hgetbits(length1);
912       }
913
914       scalefac[ch].l[21] = 0;
915       scalefac[ch].l[22] = 0;
916     }
917   }
918
919   /**
920          *
921          */
922   // MDM: new_slen is fully initialized before use, no need
923   // to reallocate array.
924   
925   private int[] new_slen = new int[4];
926
927   // ssjava
928   
929   private void get_LSF_scale_data( Header header,
930        int ch,  int gr) {
931
932      int mode_ext = header.mode_extension();
933     //  gr_info_s gr_info =
934     // (si.ch[ch].gr[gr]); // remove alias
935
936      int scalefac_comp =
937         si.ch[ch].gr[gr].scalefac_compress;
938      int blocktypenumber;
939
940      int int_scalefac_comp;
941      int m;
942      int blocknumber =
943         0;
944
945     if (si.ch[ch].gr[gr].block_type == 2) {
946       if (si.ch[ch].gr[gr].mixed_block_flag == 0) {
947         blocktypenumber = 1;
948       } else if (si.ch[ch].gr[gr].mixed_block_flag == 1) {
949         blocktypenumber = 2;
950       } else {
951         blocktypenumber = 0;
952       }
953     } else {
954       blocktypenumber = 0;
955     }
956
957     if (!(((mode_ext == 1) || (mode_ext == 3)) && (ch == 1))) {
958
959       if (scalefac_comp < 400) {
960
961         new_slen[0] = (scalefac_comp >>> 4) / 5;
962         new_slen[1] = (scalefac_comp >>> 4) % 5;
963         new_slen[2] = (scalefac_comp & 0xF) >>> 2;
964         new_slen[3] = (scalefac_comp & 3);
965         si.ch[ch].gr[gr].preflag = 0;
966         blocknumber = 0;
967
968       } else if (scalefac_comp < 500) {
969
970         new_slen[0] = ((scalefac_comp - 400) >>> 2) / 5;
971         new_slen[1] = ((scalefac_comp - 400) >>> 2) % 5;
972         new_slen[2] = (scalefac_comp - 400) & 3;
973         new_slen[3] = 0;
974         si.ch[ch].gr[gr].preflag = 0;
975         blocknumber = 1;
976
977       } else if (scalefac_comp < 512) {
978
979         new_slen[0] = (scalefac_comp - 500) / 3;
980         new_slen[1] = (scalefac_comp - 500) % 3;
981         new_slen[2] = 0;
982         new_slen[3] = 0;
983         si.ch[ch].gr[gr].preflag = 1;
984         blocknumber = 2;
985       }
986     }
987
988     if ((((mode_ext == 1) || (mode_ext == 3)) && (ch == 1))) {
989       int_scalefac_comp = scalefac_comp >>> 1;
990
991       if (int_scalefac_comp < 180) {
992         new_slen[0] = int_scalefac_comp / 36;
993         new_slen[1] = (int_scalefac_comp % 36) / 6;
994         new_slen[2] = (int_scalefac_comp % 36) % 6;
995         new_slen[3] = 0;
996         si.ch[ch].gr[gr].preflag = 0;
997         blocknumber = 3;
998       } else if (int_scalefac_comp < 244) {
999         new_slen[0] = ((int_scalefac_comp - 180) & 0x3F) >>> 4;
1000         new_slen[1] = ((int_scalefac_comp - 180) & 0xF) >>> 2;
1001         new_slen[2] = (int_scalefac_comp - 180) & 3;
1002         new_slen[3] = 0;
1003         si.ch[ch].gr[gr].preflag = 0;
1004         blocknumber = 4;
1005       } else if (int_scalefac_comp < 255) {
1006         new_slen[0] = (int_scalefac_comp - 244) / 3;
1007         new_slen[1] = (int_scalefac_comp - 244) % 3;
1008         new_slen[2] = 0;
1009         new_slen[3] = 0;
1010         si.ch[ch].gr[gr].preflag = 0;
1011         blocknumber = 5;
1012       }
1013     }
1014
1015     // for ( int x = 0; x < 45; x++)
1016     // // why 45, not 54?
1017     // scalefac_buffer[x] = 0;
1018
1019     m = 0;
1020     for ( int i = 0; i < 4; i++) {
1021        int jmax = nr_of_sfb_block[blocknumber][blocktypenumber][i];
1022       for ( int j = 0; j < jmax; j++) {
1023         scalefac_buffer[m] = (new_slen[i] == 0) ? 0 : br.hgetbits(new_slen[i]);
1024         m++;
1025
1026       } // for (unint32 j ...
1027     } // for (uint32 i ...
1028   }
1029
1030   /**
1031          *
1032          */
1033   
1034   private void get_LSF_scale_factors( Header header,
1035        int ch,  int gr) {
1036
1037      int sfb;
1038      int m = 0;
1039      int window;
1040     // gr_info_s gr_info = (si.ch[ch].gr[gr]); // remove alias
1041
1042     get_LSF_scale_data(header, ch, gr);
1043
1044     if ((si.ch[ch].gr[gr].window_switching_flag != 0) && (si.ch[ch].gr[gr].block_type == 2)) {
1045       if (si.ch[ch].gr[gr].mixed_block_flag != 0) { // MIXED
1046         for (sfb = 0; sfb < 8; sfb++) {
1047           scalefac[ch].l[sfb] = scalefac_buffer[m];
1048           m++;
1049         }
1050         for (sfb = 3; sfb < 12; sfb++) {
1051           for (window = 0; window < 3; window++) {
1052             scalefac[ch].s[window][sfb] = scalefac_buffer[m];
1053             m++;
1054           }
1055         }
1056         for (window = 0; window < 3; window++)
1057           scalefac[ch].s[window][12] = 0;
1058
1059       } else { // SHORT
1060
1061         for (sfb = 0; sfb < 12; sfb++) {
1062           for (window = 0; window < 3; window++) {
1063             scalefac[ch].s[window][sfb] = scalefac_buffer[m];
1064             m++;
1065           }
1066         }
1067
1068         for (window = 0; window < 3; window++)
1069           scalefac[ch].s[window][12] = 0;
1070       }
1071     } else { // LONG types 0,1,3
1072
1073       for (sfb = 0; sfb < 21; sfb++) {
1074         scalefac[ch].l[sfb] = scalefac_buffer[m];
1075         m++;
1076       }
1077       scalefac[ch].l[21] = 0; // Jeff
1078       scalefac[ch].l[22] = 0;
1079     }
1080   }
1081
1082   /**
1083          *
1084          */
1085   // 
1086   // int[] x = { 0 };
1087   // 
1088   // int[] y = { 0 };
1089   // 
1090   // int[] v = { 0 };
1091   // 
1092   // int[] w = { 0 };
1093   // 
1094   // int x[] = { 0 };
1095   // 
1096   // int y[] = { 0 };
1097   // 
1098   // int v[] = { 0 };
1099   // 
1100   // int w[] = { 0 };
1101
1102   
1103   private void huffman_decode( int part2_start_local,
1104        int ch,  int gr) {
1105
1106      int x[] = new int[1];
1107      int y[] = new int[1];
1108      int v[] = new int[1];
1109      int w[] = new int[1];
1110
1111      int part2_3_end =
1112         part2_start_local + si.ch[ch].gr[gr].part2_3_length;
1113      int num_bits;
1114      int region1Start;
1115      int region2Start;
1116      int index;
1117
1118      int buf;
1119      int buf1;
1120
1121     // Find region boundary for short block case
1122
1123     if (((si.ch[ch].gr[gr].window_switching_flag) != 0) && (si.ch[ch].gr[gr].block_type == 2)) {
1124
1125       // Region2.
1126       // MS: Extrahandling for 8KHZ
1127       region1Start = (sfreq == 8) ? 72 : 36; // sfb[9/3]*3=36 or in case
1128                                              // 8KHZ = 72
1129       region2Start = 576; // No Region2 for short block case
1130
1131     } else { // Find region boundary for long block case
1132
1133       buf = si.ch[ch].gr[gr].region0_count + 1;
1134       buf1 = buf + si.ch[ch].gr[gr].region1_count + 1;
1135
1136       if (buf1 > sfBandIndex[sfreq].l.length - 1)
1137         buf1 = sfBandIndex[sfreq].l.length - 1;
1138
1139       region1Start = sfBandIndex[sfreq].l[buf];
1140       region2Start = sfBandIndex[sfreq].l[buf1]; /* MI */
1141     }
1142
1143     index = 0;
1144     // Read bigvalues area
1145     TERMINATE: for ( int i = 0; i < (si.ch[ch].gr[gr].big_values << 1); i +=
1146         2) {
1147
1148        int htIdx;
1149       if (i < region1Start) {
1150         htIdx = si.ch[ch].gr[gr].table_select[0];
1151         // h = huffcodetab.ht[si.ch[ch].gr[gr].table_select[0]];
1152       } else if (i < region2Start) {
1153         htIdx = si.ch[ch].gr[gr].table_select[1];
1154         // h = huffcodetab.ht[si.ch[ch].gr[gr].table_select[1]];
1155       } else {
1156         htIdx = si.ch[ch].gr[gr].table_select[2];
1157         // h = huffcodetab.ht[si.ch[ch].gr[gr].table_select[2]];
1158       }
1159
1160       huffcodetab.huffman_decoder(htIdx, x, y, v, w, br);
1161       // if (index >= is_1d.length)
1162       // System.out.println("i0="+i+"/"+(si.ch[ch].gr[gr].big_values<<1)+" Index="+index+" is_1d="+is_1d.length);
1163
1164       is_1d[index++] = x[0];
1165       is_1d[index++] = y[0];
1166
1167       CheckSumHuff = CheckSumHuff + x[0] + y[0];
1168       // System.out.println("x = " + x[0] + " y = " + y[0]);
1169     }
1170
1171     // Read count1 area
1172
1173      int htIdx = si.ch[ch].gr[gr].count1table_select + 32;
1174     // h = huffcodetab.ht[si.ch[ch].gr[gr].count1table_select + 32];
1175     num_bits = br.hsstell();
1176
1177     TERMINATE: while ((num_bits < part2_3_end) && (index < 576)) {
1178
1179       huffcodetab.huffman_decoder(htIdx, x, y, v, w, br);
1180
1181       is_1d[index++] = v[0];
1182       is_1d[index++] = w[0];
1183       is_1d[index++] = x[0];
1184       is_1d[index++] = y[0];
1185       CheckSumHuff = CheckSumHuff + v[0] + w[0] + x[0] + y[0];
1186       // System.out.println("v = "+v[0]+" w = "+w[0]);
1187       // System.out.println("x = "+x[0]+" y = "+y[0]);
1188       num_bits = br.hsstell();
1189     }
1190
1191     if (num_bits > part2_3_end) {
1192       br.rewindNbits(num_bits - part2_3_end);
1193       index -= 4;
1194     }
1195
1196     num_bits = br.hsstell();
1197
1198     // Dismiss stuffing bits
1199     if (num_bits < part2_3_end)
1200       br.hgetbits(part2_3_end - num_bits);
1201
1202     // Zero out rest
1203
1204     if (index < 576)
1205       nonzero[ch] = index;
1206     else
1207       nonzero[ch] = 576;
1208
1209     if (index < 0)
1210       index = 0;
1211
1212     // may not be necessary
1213     for (; index < 576; index++)
1214       is_1d[index] = 0;
1215   }
1216
1217   
1218   private int huffcodetab_huffman_decoder( int h) {
1219     // TODO need to move huffmancodetab implementation here
1220     return 0;
1221   }
1222
1223   /**
1224          *
1225          */
1226   private void i_stereo_k_values( int is_pos,
1227        int io_type,  int i) {
1228     if (is_pos == 0) {
1229       k[0][i] = 1.0f;
1230       k[1][i] = 1.0f;
1231     } else if ((is_pos & 1) != 0) {
1232       k[0][i] = io[io_type][(is_pos + 1) >>> 1];
1233       k[1][i] = 1.0f;
1234     } else {
1235       k[0][i] = 1.0f;
1236       k[1][i] = io[io_type][is_pos >>> 1];
1237     }
1238   }
1239
1240   /**
1241          *
1242          */
1243   // 
1244   
1245   // ssjava
1246   private void dequantize_sample(
1247   /*  float xr[][], */ int ch,
1248        int gr) {
1249
1250     //  gr_info_s gr_info = (si.ch[ch].gr[gr]); remove alias!
1251      int cb = 0;
1252
1253      int next_cb_boundary;
1254      int cb_begin = 0;
1255      int cb_width = 0;
1256      float g_gain;
1257
1258      int index = 0;
1259      int t_index;
1260      int j;
1261
1262     // float[][] xr_1d = xr;//substituted xr for instances of xr_1d to decrease
1263     // number of areas
1264
1265     // choose correct scalefactor band per block type, initalize boundary
1266
1267     if ((si.ch[ch].gr[gr].window_switching_flag != 0) && (si.ch[ch].gr[gr].block_type == 2)) {
1268       if (si.ch[ch].gr[gr].mixed_block_flag != 0)
1269         next_cb_boundary = sfBandIndex[sfreq].l[1]; // LONG blocks: 0,1,3
1270       else {
1271         cb_width = sfBandIndex[sfreq].s[1];
1272         next_cb_boundary = (cb_width << 2) - cb_width;
1273         cb_begin = 0;
1274       }
1275     } else {
1276       next_cb_boundary = sfBandIndex[sfreq].l[1]; // LONG blocks: 0,1,3
1277     }
1278
1279     // Compute overall (global) scaling.
1280
1281     g_gain = (float) Math.pow(2.0, (0.25 * (si.ch[ch].gr[gr].global_gain - 210.0)));
1282
1283     for (j = 0; j < nonzero[ch]; j++) {
1284       // Modif E.B 02/22/99
1285        int reste = j % SSLIMIT;
1286        int quotien = (int) ((j - reste) / SSLIMIT);
1287       if (is_1d[j] == 0) {
1288         ro[ch][quotien][reste] = 0.0f;
1289       } else {
1290          int abv = is_1d[j];
1291         // Pow Array fix (11/17/04)
1292         if (abv < t_43.length) {
1293           if (is_1d[j] > 0)
1294             ro[ch][quotien][reste] = g_gain * t_43[abv];
1295           else {
1296             if (-abv < t_43.length)
1297               ro[ch][quotien][reste] = -g_gain * t_43[-abv];
1298             else
1299               ro[ch][quotien][reste] = -g_gain * (float) Math.pow(-abv, d43);
1300           }
1301         } else {
1302           if (is_1d[j] > 0)
1303             ro[ch][quotien][reste] = g_gain * (float) Math.pow(abv, d43);
1304           else
1305             ro[ch][quotien][reste] = -g_gain * (float) Math.pow(-abv, d43);
1306         }
1307       }
1308     }
1309
1310     // apply formula per block type
1311     for (j = 0; j < nonzero[ch]; j++) {
1312       // Modif E.B 02/22/99
1313        int reste = j % SSLIMIT;
1314        int quotien = (int) ((j - reste) / SSLIMIT);
1315
1316       if (index == next_cb_boundary) { /* Adjust critical band boundary */
1317         if ((si.ch[ch].gr[gr].window_switching_flag != 0) && (si.ch[ch].gr[gr].block_type == 2)) {
1318           if (si.ch[ch].gr[gr].mixed_block_flag != 0) {
1319
1320             if (index == sfBandIndex[sfreq].l[8]) {
1321               next_cb_boundary = sfBandIndex[sfreq].s[4];
1322               next_cb_boundary = (next_cb_boundary << 2) - next_cb_boundary;
1323               cb = 3;
1324               cb_width = sfBandIndex[sfreq].s[4] - sfBandIndex[sfreq].s[3];
1325
1326               cb_begin = sfBandIndex[sfreq].s[3];
1327               cb_begin = (cb_begin << 2) - cb_begin;
1328
1329             } else if (index < sfBandIndex[sfreq].l[8]) {
1330
1331               next_cb_boundary = sfBandIndex[sfreq].l[(++cb) + 1];
1332
1333             } else {
1334
1335               next_cb_boundary = sfBandIndex[sfreq].s[(++cb) + 1];
1336               next_cb_boundary = (next_cb_boundary << 2) - next_cb_boundary;
1337
1338               cb_begin = sfBandIndex[sfreq].s[cb];
1339               cb_width = sfBandIndex[sfreq].s[cb + 1] - cb_begin;
1340               cb_begin = (cb_begin << 2) - cb_begin;
1341             }
1342
1343           } else {
1344
1345             next_cb_boundary = sfBandIndex[sfreq].s[(++cb) + 1];
1346             next_cb_boundary = (next_cb_boundary << 2) - next_cb_boundary;
1347
1348             cb_begin = sfBandIndex[sfreq].s[cb];
1349             cb_width = sfBandIndex[sfreq].s[cb + 1] - cb_begin;
1350             cb_begin = (cb_begin << 2) - cb_begin;
1351           }
1352
1353         } else { // long blocks
1354
1355           next_cb_boundary = sfBandIndex[sfreq].l[(++cb) + 1];
1356
1357         }
1358       }
1359
1360       // Do long/short dependent scaling operations
1361
1362       if ((si.ch[ch].gr[gr].window_switching_flag != 0)
1363           && (((si.ch[ch].gr[gr].block_type == 2) && (si.ch[ch].gr[gr].mixed_block_flag == 0)) || ((si.ch[ch].gr[gr].block_type == 2)
1364               && (si.ch[ch].gr[gr].mixed_block_flag != 0) && (j >= 36)))) {
1365
1366         t_index = (index - cb_begin) / cb_width;
1367         /*
1368          * xr[sb][ss] *= pow(2.0, ((-2.0 * gr_info.subblock_gain[t_index]) -(0.5
1369          * * (1.0 + gr_info.scalefac_scale) scalefac[ch].s[t_index][cb])));
1370          */
1371          int idx =
1372             scalefac[ch].s[t_index][cb] << si.ch[ch].gr[gr].scalefac_scale;
1373         idx += (si.ch[ch].gr[gr].subblock_gain[t_index] << 2);
1374
1375         ro[ch][quotien][reste] *= two_to_negative_half_pow[idx];
1376
1377       } else { // LONG block types 0,1,3 & 1st 2 subbands of switched blocks
1378         /*
1379          * xr[sb][ss] *= pow(2.0, -0.5 * (1.0+gr_info.scalefac_scale)
1380          * (scalefac[ch].l[cb] + gr_info.preflag * pretab[cb]));
1381          */
1382          int idx = scalefac[ch].l[cb];
1383
1384         if (si.ch[ch].gr[gr].preflag != 0)
1385           idx += pretab[cb];
1386
1387         idx = idx << si.ch[ch].gr[gr].scalefac_scale;
1388         ro[ch][quotien][reste] *= two_to_negative_half_pow[idx];
1389       }
1390       index++;
1391     }
1392
1393     for (j = nonzero[ch]; j < 576; j++) {
1394       // Modif E.B 02/22/99
1395        int reste = j % SSLIMIT;
1396        int quotien = (int) ((j - reste) / SSLIMIT);
1397       if (reste < 0)
1398         reste = 0;
1399       if (quotien < 0)
1400         quotien = 0;
1401       ro[ch][quotien][reste] = 0.0f;
1402     }
1403
1404     return;
1405   }
1406
1407   /**
1408          *
1409          */
1410   // ssjava
1411   // 
1412   
1413   private void reorder(/*  float xr[][], */ int ch,
1414        int gr) {
1415     // the purpose of reordering: move 'short samples' back to their original
1416     // position
1417     // after reorder, the samples are no long ordered by frequency
1418
1419     // the format of input data to reorder:
1420     // three small chunks of 192 samples each are combined to 576 samples
1421     // ordered by frequency
1422
1423     // gr_info_s gr_info = (si.ch[ch].gr[gr]); //remove alias
1424
1425      int index;
1426
1427      int freq;
1428      int freq3;
1429      int sfb;
1430      int sfb_start;
1431      int sfb_lines;
1432      int src_line;
1433      int des_line;
1434     // float[][] xr_1d = xr; subbed in xr for xr_1d so as not to create extra
1435     // areas
1436
1437     if ((si.ch[ch].gr[gr].window_switching_flag != 0) && (si.ch[ch].gr[gr].block_type == 2)) {
1438
1439       // for (index = 0; index < 576; index++) {
1440       // inter[index] = 0.0f;
1441       // }
1442
1443       if (si.ch[ch].gr[gr].mixed_block_flag != 0) {
1444         // NO REORDER FOR LOW 2 SUBBANDS
1445         for (index = 0; index < 36; index++) {
1446           // Modif E.B 02/22/99
1447            int reste = index % SSLIMIT;
1448            int quotien = (int) ((index - reste) / SSLIMIT);
1449           inter[index] = lr[ch][quotien][reste];
1450         }
1451         // REORDERING FOR REST SWITCHED SHORT
1452         /*
1453          * for( sfb=3,sfb_start=sfBandIndex[sfreq].s[3],
1454          * sfb_lines=sfBandIndex[sfreq].s[4] - sfb_start; sfb < 13;
1455          * sfb++,sfb_start = sfBandIndex[sfreq].s[sfb], sfb_lines =
1456          * sfBandIndex[sfreq].s[sfb+1] - sfb_start ) {
1457          */
1458         for (sfb = 3; sfb < 13; sfb++) {
1459           // System.out.println("sfreq="+sfreq+" sfb="+sfb+" sfBandIndex="+sfBandIndex.length+" sfBandIndex[sfreq].s="+sfBandIndex[sfreq].s.length);
1460           sfb_start = sfBandIndex[sfreq].s[sfb];
1461           sfb_lines = sfBandIndex[sfreq].s[sfb + 1] - sfb_start;
1462
1463            int sfb_start3 = (sfb_start << 2) - sfb_start;
1464
1465           for (freq = 0, freq3 = 0; freq < sfb_lines; freq++, freq3 += 3) {
1466
1467             src_line = sfb_start3 + freq;
1468             des_line = sfb_start3 + freq3;
1469             // Modif E.B 02/22/99
1470              int reste = src_line % SSLIMIT;
1471              int quotien = (int) ((src_line - reste) / SSLIMIT);
1472
1473             inter[des_line] = lr[ch][quotien][reste];
1474             src_line += sfb_lines;
1475             des_line++;
1476
1477             reste = src_line % SSLIMIT;
1478             quotien = (int) ((src_line - reste) / SSLIMIT);
1479
1480             inter[des_line] = lr[ch][quotien][reste];
1481             src_line += sfb_lines;
1482             des_line++;
1483
1484             reste = src_line % SSLIMIT;
1485             quotien = (int) ((src_line - reste) / SSLIMIT);
1486
1487             inter[des_line] = lr[ch][quotien][reste];
1488           }
1489         }
1490
1491       } else { // pure short
1492         for (index = 0; index < 576; index++) {
1493            int j = reorder_table[sfreq][index];
1494            int reste = j % SSLIMIT;
1495            int quotien = (int) ((j - reste) / SSLIMIT);
1496           inter[index] = lr[ch][quotien][reste];
1497         }
1498       }
1499     } else { // long blocks
1500       for (index = 0; index < 576; index++) {
1501         // Modif E.B 02/22/99
1502          int reste = index % SSLIMIT;
1503          int quotien = (int) ((index - reste) / SSLIMIT);
1504         inter[index] = lr[ch][quotien][reste];
1505       }
1506     }
1507   }
1508
1509   /**
1510          *
1511          */
1512
1513   
1514   int[] is_pos = new int[576];
1515   
1516   float[] is_ratio = new float[576];
1517
1518   // ssjava
1519   
1520   private void stereo( Header header,
1521        int gr) {
1522      int sb;
1523      int ss;
1524
1525     if (channels == 1) { // mono , bypass xr[0][][] to lr[0][][]
1526
1527       for (sb = 0; sb < SBLIMIT; sb++)
1528         for (ss = 0; ss < SSLIMIT; ss += 3) {
1529           lr[0][sb][ss] = ro[0][sb][ss];
1530           lr[0][sb][ss + 1] = ro[0][sb][ss + 1];
1531           lr[0][sb][ss + 2] = ro[0][sb][ss + 2];
1532         }
1533
1534     } else {
1535
1536       // gr_info_s gr_info = (si.ch[0].gr[gr]); remove alias
1537        int mode_ext = header.mode_extension();
1538
1539        int sfb;
1540        int i;
1541        int lines;
1542        int temp;
1543        int temp2;
1544
1545        boolean ms_stereo =
1546           ((header.mode() == Header.JOINT_STEREO) && ((mode_ext & 0x2) != 0));
1547        boolean i_stereo =
1548           ((header.mode() == Header.JOINT_STEREO) && ((mode_ext & 0x1) != 0));
1549        boolean lsf =
1550           ((header.version() == Header.MPEG2_LSF || header.version() == Header.MPEG25_LSF)); // SZD
1551
1552        int io_type = (si.ch[0].gr[gr].scalefac_compress & 1);
1553
1554       // initialization
1555       // for (i = 0; i < 576; i++) {
1556       // is_pos[i] = 7;
1557       // is_ratio[i] = 0.0f;
1558       // }
1559
1560       if (i_stereo) {
1561         if ((si.ch[0].gr[gr].window_switching_flag != 0) && (si.ch[0].gr[gr].block_type == 2)) {
1562           if (si.ch[0].gr[gr].mixed_block_flag != 0) {
1563
1564              int max_sfb = 0;
1565
1566             for ( int j = 0; j < 3; j++) {
1567                int sfbcnt;
1568               sfbcnt = 2;
1569               TERMINATE: for (sfb = 12; sfb >= 3; sfb--) {
1570                 i = sfBandIndex[sfreq].s[sfb];
1571                 lines = sfBandIndex[sfreq].s[sfb + 1] - i;
1572                 i = (i << 2) - i + (j + 1) * lines - 1;
1573                 TERMINATE: while (lines > 0) {
1574                   if (ro[1][i / 18][i % 18] != 0.0f) {
1575                     // MDM: in java, array access is very slow.
1576                     // Is quicker to compute div and mod values.
1577                     // if (ro[1][ss_div[i]][ss_mod[i]] != 0.0f) {
1578                     sfbcnt = sfb;
1579                     sfb = -10;
1580                     lines = -10;
1581                   }
1582
1583                   lines--;
1584                   i--;
1585
1586                 } // while (lines > 0)
1587
1588               } // for (sfb=12 ...
1589               sfb = sfbcnt + 1;
1590
1591               if (sfb > max_sfb)
1592                 max_sfb = sfb;
1593
1594               while (sfb < 12) {
1595                 temp = sfBandIndex[sfreq].s[sfb];
1596                 sb = sfBandIndex[sfreq].s[sfb + 1] - temp;
1597                 i = (temp << 2) - temp + j * sb;
1598
1599                 TERMINATE: for (; sb > 0; sb--) {
1600                   is_pos[i] = scalefac[1].s[j][sfb];
1601                   if (is_pos[i] != 7)
1602                     if (lsf)
1603                       i_stereo_k_values(is_pos[i], io_type, i);
1604                     else
1605                       is_ratio[i] = TAN12[is_pos[i]];
1606
1607                   i++;
1608                 } // for (; sb>0...
1609                 sfb++;
1610               } // while (sfb < 12)
1611               sfb = sfBandIndex[sfreq].s[10];
1612               sb = sfBandIndex[sfreq].s[11] - sfb;
1613               sfb = (sfb << 2) - sfb + j * sb;
1614               temp = sfBandIndex[sfreq].s[11];
1615               sb = sfBandIndex[sfreq].s[12] - temp;
1616               i = (temp << 2) - temp + j * sb;
1617               TERMINATE: for (; sb > 0; sb--) {
1618                 is_pos[i] = is_pos[sfb];
1619
1620                 if (lsf) {
1621                   k[0][i] = k[0][sfb];
1622                   k[1][i] = k[1][sfb];
1623                 } else {
1624                   is_ratio[i] = is_ratio[sfb];
1625                 }
1626                 i++;
1627               } // for (; sb > 0 ...
1628             }
1629             if (max_sfb <= 3) {
1630               i = 2;
1631               ss = 17;
1632               sb = -1;
1633               TERMINATE: while (i >= 0) {
1634                 if (ro[1][i][ss] != 0.0f) {
1635                   sb = (i << 4) + (i << 1) + ss;
1636                   i = -1;
1637                 } else {
1638                   ss--;
1639                   if (ss < 0) {
1640                     i--;
1641                     ss = 17;
1642                   }
1643                 } // if (ro ...
1644               } // while (i>=0)
1645               i = 0;
1646               while (sfBandIndex[sfreq].l[i] <= sb)
1647                 i++;
1648               sfb = i;
1649               i = sfBandIndex[sfreq].l[i];
1650               for (; sfb < 8; sfb++) {
1651                 sb = sfBandIndex[sfreq].l[sfb + 1] - sfBandIndex[sfreq].l[sfb];
1652                 TERMINATE: for (; sb > 0; sb--) {
1653                   is_pos[i] = scalefac[1].l[sfb];
1654                   if (is_pos[i] != 7)
1655                     if (lsf)
1656                       i_stereo_k_values(is_pos[i], io_type, i);
1657                     else
1658                       is_ratio[i] = TAN12[is_pos[i]];
1659                   i++;
1660                 } // for (; sb>0 ...
1661               } // for (; sfb<8 ...
1662             } // for (j=0 ...
1663           } else { // if (gr_info.mixed_block_flag)
1664             for ( int j = 0; j < 3; j++) {
1665                int sfbcnt;
1666               sfbcnt = -1;
1667               TERMINATE: for (sfb = 12; sfb >= 0; sfb--) {
1668                 temp = sfBandIndex[sfreq].s[sfb];
1669                 lines = sfBandIndex[sfreq].s[sfb + 1] - temp;
1670                 i = (temp << 2) - temp + (j + 1) * lines - 1;
1671                 TERMINATE: while (lines > 0) {
1672                   if (ro[1][i / 18][i % 18] != 0.0f) {
1673                     // MDM: in java, array access is very slow.
1674                     // Is quicker to compute div and mod values.
1675                     // if (ro[1][ss_div[i]][ss_mod[i]] != 0.0f) {
1676                     sfbcnt = sfb;
1677                     sfb = -10;
1678                     lines = -10;
1679                   }
1680                   lines--;
1681                   i--;
1682                 } // while (lines > 0) */
1683
1684               } // for (sfb=12 ...
1685               sfb = sfbcnt + 1;
1686               while (sfb < 12) {
1687                 temp = sfBandIndex[sfreq].s[sfb];
1688                 sb = sfBandIndex[sfreq].s[sfb + 1] - temp;
1689                 i = (temp << 2) - temp + j * sb;
1690                 TERMINATE: for (; sb > 0; sb--) {
1691                   is_pos[i] = scalefac[1].s[j][sfb];
1692                   if (is_pos[i] != 7)
1693                     if (lsf)
1694                       i_stereo_k_values(is_pos[i], io_type, i);
1695                     else
1696                       is_ratio[i] = TAN12[is_pos[i]];
1697                   i++;
1698                 } // for (; sb>0 ...
1699                 sfb++;
1700               } // while (sfb<12)
1701
1702               temp = sfBandIndex[sfreq].s[10];
1703               temp2 = sfBandIndex[sfreq].s[11];
1704               sb = temp2 - temp;
1705               sfb = (temp << 2) - temp + j * sb;
1706               sb = sfBandIndex[sfreq].s[12] - temp2;
1707               i = (temp2 << 2) - temp2 + j * sb;
1708               TERMINATE: for (; sb > 0; sb--) {
1709                 is_pos[i] = is_pos[sfb];
1710
1711                 if (lsf) {
1712                   k[0][i] = k[0][sfb];
1713                   k[1][i] = k[1][sfb];
1714                 } else {
1715                   is_ratio[i] = is_ratio[sfb];
1716                 }
1717                 i++;
1718               } // for (; sb>0 ...
1719             } // for (sfb=12
1720           } // for (j=0 ...
1721         } else { // if (gr_info.window_switching_flag ...
1722           i = 31;
1723           ss = 17;
1724           sb = 0;
1725           TERMINATE: while (i >= 0) {
1726             if (ro[1][i][ss] != 0.0f) {
1727               sb = (i << 4) + (i << 1) + ss;
1728               i = -1;
1729             } else {
1730               ss--;
1731               if (ss < 0) {
1732                 i--;
1733                 ss = 17;
1734               }
1735             }
1736           }
1737           i = 0;
1738           while (sfBandIndex[sfreq].l[i] <= sb)
1739             i++;
1740
1741           sfb = i;
1742           i = sfBandIndex[sfreq].l[i];
1743           for (; sfb < 21; sfb++) {
1744             sb = sfBandIndex[sfreq].l[sfb + 1] - sfBandIndex[sfreq].l[sfb];
1745             TERMINATE: for (; sb > 0; sb--) {
1746               is_pos[i] = scalefac[1].l[sfb];
1747               if (is_pos[i] != 7)
1748                 if (lsf)
1749                   i_stereo_k_values(is_pos[i], io_type, i);
1750                 else
1751                   is_ratio[i] = TAN12[is_pos[i]];
1752               i++;
1753             }
1754           }
1755           sfb = sfBandIndex[sfreq].l[20];
1756           TERMINATE: for (sb = 576 - sfBandIndex[sfreq].l[21]; (sb > 0) && (i < 576); sb--) {
1757             is_pos[i] = is_pos[sfb]; // error here : i >=576
1758
1759             if (lsf) {
1760               k[0][i] = k[0][sfb];
1761               k[1][i] = k[1][sfb];
1762             } else {
1763               is_ratio[i] = is_ratio[sfb];
1764             }
1765             i++;
1766           } // if (gr_info.mixed_block_flag)
1767         } // if (gr_info.window_switching_flag ...
1768       } // if (i_stereo)
1769
1770       i = 0;
1771       for (sb = 0; sb < SBLIMIT; sb++)
1772         for (ss = 0; ss < SSLIMIT; ss++) {
1773           if (is_pos[i] == 7) {
1774             if (ms_stereo) {
1775               lr[0][sb][ss] = (ro[0][sb][ss] + ro[1][sb][ss]) * 0.707106781f;
1776               lr[1][sb][ss] = (ro[0][sb][ss] - ro[1][sb][ss]) * 0.707106781f;
1777             } else {
1778               lr[0][sb][ss] = ro[0][sb][ss];
1779               lr[1][sb][ss] = ro[1][sb][ss];
1780             }
1781           } else if (i_stereo) {
1782
1783             if (lsf) {
1784               lr[0][sb][ss] = ro[0][sb][ss] * k[0][i];
1785               lr[1][sb][ss] = ro[0][sb][ss] * k[1][i];
1786             } else {
1787               lr[1][sb][ss] = ro[0][sb][ss] / (float) (1 + is_ratio[i]);
1788               lr[0][sb][ss] = lr[1][sb][ss] * is_ratio[i];
1789             }
1790           }
1791           /*
1792            * else { System.out.println("Error in stereo processing\n"); }
1793            */
1794           i++;
1795         }
1796
1797     } // channels == 2
1798
1799   }
1800
1801   /**
1802          *
1803          */
1804   // 
1805   
1806   private void antialias( int ch,
1807        int gr) {
1808
1809      int sb18;
1810      int ss;
1811      int sb18lim;
1812
1813     // 
1814     // gr_info_s gr_info =
1815     // (si.ch[ch].gr[gr]);
1816     // 31 alias-reduction operations between each pair of sub-bands
1817     // with 8 butterflies between each pair
1818
1819     if ((si.ch[ch].gr[gr].window_switching_flag != 0) && (si.ch[ch].gr[gr].block_type == 2)
1820         && !(si.ch[ch].gr[gr].mixed_block_flag != 0))
1821       return;
1822
1823     if ((si.ch[ch].gr[gr].window_switching_flag != 0) && (si.ch[ch].gr[gr].mixed_block_flag != 0)
1824         && (si.ch[ch].gr[gr].block_type == 2)) {
1825       sb18lim = 18;
1826     } else {
1827       sb18lim = 558;
1828     }
1829
1830     for (sb18 = 0; sb18 < sb18lim; sb18 += 18) {
1831       for (ss = 0; ss < 8; ss++) {
1832          int src_idx1 = sb18 + 17 - ss;
1833          int src_idx2 = sb18 + 18 + ss;
1834          float bu = inter[src_idx1];
1835          float bd = inter[src_idx2];
1836         inter[src_idx1] = (bu * cs[ss]) - (bd * ca[ss]);
1837         inter[src_idx2] = (bd * cs[ss]) + (bu * ca[ss]);
1838       }
1839     }
1840   }
1841
1842   /**
1843          *
1844          */
1845
1846   // MDM: tsOutCopy and rawout do not need initializing, so the arrays
1847   // can be reused.
1848   
1849   float[] tsOutCopy = new float[18];
1850   
1851   float[] rawout = new float[36];
1852
1853   
1854   private void hybrid( int ch,  int gr) {
1855
1856      int bt;
1857      int sb18;
1858     // gr_info_s gr_info = (si.ch[ch].gr[gr]); //remove alias
1859     //  float[] tsOut; //remove alias
1860
1861     // float[][] prvblk;
1862
1863     for (sb18 = 0; sb18 < 576; sb18 += 18) {
1864       if ((si.ch[ch].gr[gr].window_switching_flag != 0) && (si.ch[ch].gr[gr].mixed_block_flag != 0)
1865           && (sb18 < 36)) {
1866         bt = 0;
1867       } else {
1868         bt = si.ch[ch].gr[gr].block_type;
1869       }
1870
1871       // tsOut = out_1d;
1872       // Modif E.B 02/22/99
1873       for ( int cc = 0; cc < 18; cc++) {
1874         // tsOutCopy[cc] = out_1d[cc + sb18];
1875         tsOutCopy[cc] = inter[cc + sb18];
1876       }
1877
1878       inv_mdct(bt);
1879
1880       for ( int cc = 0; cc < 18; cc++) {
1881         out_1d[cc + sb18] = tsOutCopy[cc];
1882       }
1883
1884       // Fin Modif
1885
1886       // overlap addition
1887       out_1d[0 + sb18] = rawout[0] + prevblck[ch][sb18 + 0];
1888       out_1d[1 + sb18] = rawout[1] + prevblck[ch][sb18 + 1];
1889       out_1d[2 + sb18] = rawout[2] + prevblck[ch][sb18 + 2];
1890       out_1d[3 + sb18] = rawout[3] + prevblck[ch][sb18 + 3];
1891       out_1d[4 + sb18] = rawout[4] + prevblck[ch][sb18 + 4];
1892       out_1d[5 + sb18] = rawout[5] + prevblck[ch][sb18 + 5];
1893       out_1d[6 + sb18] = rawout[6] + prevblck[ch][sb18 + 6];
1894       out_1d[7 + sb18] = rawout[7] + prevblck[ch][sb18 + 7];
1895       out_1d[8 + sb18] = rawout[8] + prevblck[ch][sb18 + 8];
1896       out_1d[9 + sb18] = rawout[9] + prevblck[ch][sb18 + 9];
1897       out_1d[10 + sb18] = rawout[10] + prevblck[ch][sb18 + 10];
1898       out_1d[11 + sb18] = rawout[11] + prevblck[ch][sb18 + 11];
1899       out_1d[12 + sb18] = rawout[12] + prevblck[ch][sb18 + 12];
1900       out_1d[13 + sb18] = rawout[13] + prevblck[ch][sb18 + 13];
1901       out_1d[14 + sb18] = rawout[14] + prevblck[ch][sb18 + 14];
1902       out_1d[15 + sb18] = rawout[15] + prevblck[ch][sb18 + 15];
1903       out_1d[16 + sb18] = rawout[16] + prevblck[ch][sb18 + 16];
1904       out_1d[17 + sb18] = rawout[17] + prevblck[ch][sb18 + 17];
1905       raw_full[ch][sb18 + 0] = rawout[18];
1906       raw_full[ch][sb18 + 1] = rawout[19];
1907       raw_full[ch][sb18 + 2] = rawout[20];
1908       raw_full[ch][sb18 + 3] = rawout[21];
1909       raw_full[ch][sb18 + 4] = rawout[22];
1910       raw_full[ch][sb18 + 5] = rawout[23];
1911       raw_full[ch][sb18 + 6] = rawout[24];
1912       raw_full[ch][sb18 + 7] = rawout[25];
1913       raw_full[ch][sb18 + 8] = rawout[26];
1914       raw_full[ch][sb18 + 9] = rawout[27];
1915       raw_full[ch][sb18 + 10] = rawout[28];
1916       raw_full[ch][sb18 + 11] = rawout[29];
1917       raw_full[ch][sb18 + 12] = rawout[30];
1918       raw_full[ch][sb18 + 13] = rawout[31];
1919       raw_full[ch][sb18 + 14] = rawout[32];
1920       raw_full[ch][sb18 + 15] = rawout[33];
1921       raw_full[ch][sb18 + 16] = rawout[34];
1922       raw_full[ch][sb18 + 17] = rawout[35];
1923
1924       // original implementation:
1925       // out_1d[0 + sb18] = rawout[0] + prevblck[ch][sb18 + 0];
1926       // prevblck[ch][sb18 + 0] = rawout[18];
1927       // out_1d[1 + sb18] = rawout[1] + prevblck[ch][sb18 + 1];
1928       // prevblck[ch][sb18 + 1] = rawout[19];
1929       // out_1d[2 + sb18] = rawout[2] + prevblck[ch][sb18 + 2];
1930       // prevblck[ch][sb18 + 2] = rawout[20];
1931       // out_1d[3 + sb18] = rawout[3] + prevblck[ch][sb18 + 3];
1932       // prevblck[ch][sb18 + 3] = rawout[21];
1933       // out_1d[4 + sb18] = rawout[4] + prevblck[ch][sb18 + 4];
1934       // prevblck[ch][sb18 + 4] = rawout[22];
1935       // out_1d[5 + sb18] = rawout[5] + prevblck[ch][sb18 + 5];
1936       // prevblck[ch][sb18 + 5] = rawout[23];
1937       // out_1d[6 + sb18] = rawout[6] + prevblck[ch][sb18 + 6];
1938       // prevblck[ch][sb18 + 6] = rawout[24];
1939       // out_1d[7 + sb18] = rawout[7] + prevblck[ch][sb18 + 7];
1940       // prevblck[ch][sb18 + 7] = rawout[25];
1941       // out_1d[8 + sb18] = rawout[8] + prevblck[ch][sb18 + 8];
1942       // prevblck[ch][sb18 + 8] = rawout[26];
1943       // out_1d[9 + sb18] = rawout[9] + prevblck[ch][sb18 + 9];
1944       // prevblck[ch][sb18 + 9] = rawout[27];
1945       // out_1d[10 + sb18] = rawout[10] + prevblck[ch][sb18 + 10];
1946       // prevblck[ch][sb18 + 10] = rawout[28];
1947       // out_1d[11 + sb18] = rawout[11] + prevblck[ch][sb18 + 11];
1948       // prevblck[ch][sb18 + 11] = rawout[29];
1949       // out_1d[12 + sb18] = rawout[12] + prevblck[ch][sb18 + 12];
1950       // prevblck[ch][sb18 + 12] = rawout[30];
1951       // out_1d[13 + sb18] = rawout[13] + prevblck[ch][sb18 + 13];
1952       // prevblck[ch][sb18 + 13] = rawout[31];
1953       // out_1d[14 + sb18] = rawout[14] + prevblck[ch][sb18 + 14];
1954       // prevblck[ch][sb18 + 14] = rawout[32];
1955       // out_1d[15 + sb18] = rawout[15] + prevblck[ch][sb18 + 15];
1956       // prevblck[ch][sb18 + 15] = rawout[33];
1957       // out_1d[16 + sb18] = rawout[16] + prevblck[ch][sb18 + 16];
1958       // prevblck[ch][sb18 + 16] = rawout[34];
1959       // out_1d[17 + sb18] = rawout[17] + prevblck[ch][sb18 + 17];
1960       // prevblck[ch][sb18 + 17] = rawout[35];
1961
1962     }
1963   }
1964
1965   /**
1966          *
1967          */
1968   private void do_downmix() {
1969     for ( int sb = 0; sb < SSLIMIT; sb++) {
1970       for ( int ss = 0; ss < SSLIMIT; ss += 3) {
1971         lr[0][sb][ss] = (lr[0][sb][ss] + lr[1][sb][ss]) * 0.5f;
1972         lr[0][sb][ss + 1] = (lr[0][sb][ss + 1] + lr[1][sb][ss + 1]) * 0.5f;
1973         lr[0][sb][ss + 2] = (lr[0][sb][ss + 2] + lr[1][sb][ss + 2]) * 0.5f;
1974       }
1975     }
1976   }
1977
1978   /**
1979    * Fast INV_MDCT.
1980    */
1981   // 
1982   // public void inv_mdct( float[] in,  float[] out,
1983   //  int block_type) {//remove alias
1984   // ssjava
1985   
1986   public void inv_mdct( int block_type) {
1987     // float[] win_bt;
1988      int i;
1989
1990      float tmpf_0;
1991      float tmpf_1;
1992      float tmpf_2;
1993      float tmpf_3;
1994      float tmpf_4;
1995      float tmpf_5;
1996      float tmpf_6;
1997      float tmpf_7;
1998      float tmpf_8;
1999      float tmpf_9;
2000      float tmpf_10;
2001      float tmpf_11;
2002      float tmpf_12;
2003      float tmpf_13;
2004      float tmpf_14;
2005      float tmpf_15;
2006      float tmpf_16;
2007      float tmpf_17;
2008
2009     tmpf_0 =
2010         tmpf_1 =
2011             tmpf_2 =
2012                 tmpf_3 =
2013                     tmpf_4 =
2014                         tmpf_5 =
2015                             tmpf_6 =
2016                                 tmpf_7 =
2017                                     tmpf_8 =
2018                                         tmpf_9 =
2019                                             tmpf_10 =
2020                                                 tmpf_11 =
2021                                                     tmpf_12 =
2022                                                         tmpf_13 =
2023                                                             tmpf_14 =
2024                                                                 tmpf_15 = tmpf_16 = tmpf_17 = 0.0f;
2025
2026     if (block_type == 2) {
2027
2028       /*
2029        * 
2030        * Under MicrosoftVM 2922, This causes a GPF, or At best, an
2031        * ArrayIndexOutOfBoundsExceptin. for(int p=0;p<36;p+=9) { out[p] =
2032        * out[p+1] = out[p+2] = out[p+3] = out[p+4] = out[p+5] = out[p+6] =
2033        * out[p+7] = out[p+8] = 0.0f; }
2034        */
2035       rawout[0] = 0.0f;
2036       rawout[1] = 0.0f;
2037       rawout[2] = 0.0f;
2038       rawout[3] = 0.0f;
2039       rawout[4] = 0.0f;
2040       rawout[5] = 0.0f;
2041       rawout[6] = 0.0f;
2042       rawout[7] = 0.0f;
2043       rawout[8] = 0.0f;
2044       rawout[9] = 0.0f;
2045       rawout[10] = 0.0f;
2046       rawout[11] = 0.0f;
2047       rawout[12] = 0.0f;
2048       rawout[13] = 0.0f;
2049       rawout[14] = 0.0f;
2050       rawout[15] = 0.0f;
2051       rawout[16] = 0.0f;
2052       rawout[17] = 0.0f;
2053       rawout[18] = 0.0f;
2054       rawout[19] = 0.0f;
2055       rawout[20] = 0.0f;
2056       rawout[21] = 0.0f;
2057       rawout[22] = 0.0f;
2058       rawout[23] = 0.0f;
2059       rawout[24] = 0.0f;
2060       rawout[25] = 0.0f;
2061       rawout[26] = 0.0f;
2062       rawout[27] = 0.0f;
2063       rawout[28] = 0.0f;
2064       rawout[29] = 0.0f;
2065       rawout[30] = 0.0f;
2066       rawout[31] = 0.0f;
2067       rawout[32] = 0.0f;
2068       rawout[33] = 0.0f;
2069       rawout[34] = 0.0f;
2070       rawout[35] = 0.0f;
2071
2072        int six_i = 0;
2073
2074       for (i = 0; i < 3; i++) {
2075         // 12 point IMDCT
2076         // Begin 12 point IDCT
2077         // Input aliasing for 12 pt IDCT
2078         tsOutCopy[15 + i] += tsOutCopy[12 + i];
2079         tsOutCopy[12 + i] += tsOutCopy[9 + i];
2080         tsOutCopy[9 + i] += tsOutCopy[6 + i];
2081         tsOutCopy[6 + i] += tsOutCopy[3 + i];
2082         tsOutCopy[3 + i] += tsOutCopy[0 + i];
2083
2084         // Input aliasing on odd indices (for 6 point IDCT)
2085         tsOutCopy[15 + i] += tsOutCopy[9 + i];
2086         tsOutCopy[9 + i] += tsOutCopy[3 + i];
2087
2088         // 3 point IDCT on even indices
2089          float pp1;
2090          float pp2;
2091          float sum;
2092         pp2 = tsOutCopy[12 + i] * 0.500000000f;
2093         pp1 = tsOutCopy[6 + i] * 0.866025403f;
2094         sum = tsOutCopy[0 + i] + pp2;
2095         tmpf_1 = tsOutCopy[0 + i] - tsOutCopy[12 + i];
2096         tmpf_0 = sum + pp1;
2097         tmpf_2 = sum - pp1;
2098
2099         // End 3 point IDCT on even indices
2100         // 3 point IDCT on odd indices (for 6 point IDCT)
2101         pp2 = tsOutCopy[15 + i] * 0.500000000f;
2102         pp1 = tsOutCopy[9 + i] * 0.866025403f;
2103         sum = tsOutCopy[3 + i] + pp2;
2104         tmpf_4 = tsOutCopy[3 + i] - tsOutCopy[15 + i];
2105         tmpf_5 = sum + pp1;
2106         tmpf_3 = sum - pp1;
2107         // End 3 point IDCT on odd indices
2108         // Twiddle factors on odd indices (for 6 point IDCT)
2109
2110         tmpf_3 *= 1.931851653f;
2111         tmpf_4 *= 0.707106781f;
2112         tmpf_5 *= 0.517638090f;
2113
2114         // Output butterflies on 2 3 point IDCT's (for 6 point IDCT)
2115          float save = tmpf_0;
2116         tmpf_0 += tmpf_5;
2117         tmpf_5 = save - tmpf_5;
2118         save = tmpf_1;
2119         tmpf_1 += tmpf_4;
2120         tmpf_4 = save - tmpf_4;
2121         save = tmpf_2;
2122         tmpf_2 += tmpf_3;
2123         tmpf_3 = save - tmpf_3;
2124
2125         // End 6 point IDCT
2126         // Twiddle factors on indices (for 12 point IDCT)
2127
2128         tmpf_0 *= 0.504314480f;
2129         tmpf_1 *= 0.541196100f;
2130         tmpf_2 *= 0.630236207f;
2131         tmpf_3 *= 0.821339815f;
2132         tmpf_4 *= 1.306562965f;
2133         tmpf_5 *= 3.830648788f;
2134
2135         // End 12 point IDCT
2136
2137         // Shift to 12 point modified IDCT, multiply by window type 2
2138         tmpf_8 = -tmpf_0 * 0.793353340f;
2139         tmpf_9 = -tmpf_0 * 0.608761429f;
2140         tmpf_7 = -tmpf_1 * 0.923879532f;
2141         tmpf_10 = -tmpf_1 * 0.382683432f;
2142         tmpf_6 = -tmpf_2 * 0.991444861f;
2143         tmpf_11 = -tmpf_2 * 0.130526192f;
2144
2145         tmpf_0 = tmpf_3;
2146         tmpf_1 = tmpf_4 * 0.382683432f;
2147         tmpf_2 = tmpf_5 * 0.608761429f;
2148
2149         tmpf_3 = -tmpf_5 * 0.793353340f;
2150         tmpf_4 = -tmpf_4 * 0.923879532f;
2151         tmpf_5 = -tmpf_0 * 0.991444861f;
2152
2153         tmpf_0 *= 0.130526192f;
2154
2155         rawout[six_i + 6] += tmpf_0;
2156         rawout[six_i + 7] += tmpf_1;
2157         rawout[six_i + 8] += tmpf_2;
2158         rawout[six_i + 9] += tmpf_3;
2159         rawout[six_i + 10] += tmpf_4;
2160         rawout[six_i + 11] += tmpf_5;
2161         rawout[six_i + 12] += tmpf_6;
2162         rawout[six_i + 13] += tmpf_7;
2163         rawout[six_i + 14] += tmpf_8;
2164         rawout[six_i + 15] += tmpf_9;
2165         rawout[six_i + 16] += tmpf_10;
2166         rawout[six_i + 17] += tmpf_11;
2167
2168         six_i += 6;
2169       }
2170     } else {
2171       // 36 point IDCT
2172       // input aliasing for 36 point IDCT
2173       tsOutCopy[17] += tsOutCopy[16];
2174       tsOutCopy[16] += tsOutCopy[15];
2175       tsOutCopy[15] += tsOutCopy[14];
2176       tsOutCopy[14] += tsOutCopy[13];
2177       tsOutCopy[13] += tsOutCopy[12];
2178       tsOutCopy[12] += tsOutCopy[11];
2179       tsOutCopy[11] += tsOutCopy[10];
2180       tsOutCopy[10] += tsOutCopy[9];
2181       tsOutCopy[9] += tsOutCopy[8];
2182       tsOutCopy[8] += tsOutCopy[7];
2183       tsOutCopy[7] += tsOutCopy[6];
2184       tsOutCopy[6] += tsOutCopy[5];
2185       tsOutCopy[5] += tsOutCopy[4];
2186       tsOutCopy[4] += tsOutCopy[3];
2187       tsOutCopy[3] += tsOutCopy[2];
2188       tsOutCopy[2] += tsOutCopy[1];
2189       tsOutCopy[1] += tsOutCopy[0];
2190
2191       // 18 point IDCT for odd indices
2192       // input aliasing for 18 point IDCT
2193       tsOutCopy[17] += tsOutCopy[15];
2194       tsOutCopy[15] += tsOutCopy[13];
2195       tsOutCopy[13] += tsOutCopy[11];
2196       tsOutCopy[11] += tsOutCopy[9];
2197       tsOutCopy[9] += tsOutCopy[7];
2198       tsOutCopy[7] += tsOutCopy[5];
2199       tsOutCopy[5] += tsOutCopy[3];
2200       tsOutCopy[3] += tsOutCopy[1];
2201
2202        float tmp0;
2203        float tmp1;
2204        float tmp2;
2205        float tmp3;
2206        float tmp4;
2207        float tmp0_;
2208        float tmp1_;
2209        float tmp2_;
2210        float tmp3_;
2211        float tmp0o;
2212        float tmp1o;
2213        float tmp2o;
2214        float tmp3o;
2215        float tmp4o;
2216        float tmp0_o;
2217        float tmp1_o;
2218        float tmp2_o;
2219        float tmp3_o;
2220
2221       // Fast 9 Point Inverse Discrete Cosine Transform
2222       //
2223       // By Francois-Raymond Boyer
2224       // mailto:boyerf@iro.umontreal.ca
2225       // http://www.iro.umontreal.ca/~boyerf
2226       //
2227       // The code has been optimized for Intel processors
2228       // (takes a lot of time to convert float to and from iternal FPU
2229       // representation)
2230       //
2231       // It is a simple "factorization" of the IDCT matrix.
2232
2233       // 9 point IDCT on even indices
2234
2235       // 5 points on odd indices (not realy an IDCT)
2236        float i00 = tsOutCopy[0] + tsOutCopy[0];
2237        float iip12 = i00 + tsOutCopy[12];
2238
2239       tmp0 =
2240           iip12 + tsOutCopy[4] * 1.8793852415718f + tsOutCopy[8] * 1.532088886238f + tsOutCopy[16]
2241               * 0.34729635533386f;
2242       tmp1 = i00 + tsOutCopy[4] - tsOutCopy[8] - tsOutCopy[12] - tsOutCopy[12] - tsOutCopy[16];
2243       tmp2 =
2244           iip12 - tsOutCopy[4] * 0.34729635533386f - tsOutCopy[8] * 1.8793852415718f
2245               + tsOutCopy[16] * 1.532088886238f;
2246       tmp3 =
2247           iip12 - tsOutCopy[4] * 1.532088886238f + tsOutCopy[8] * 0.34729635533386f - tsOutCopy[16]
2248               * 1.8793852415718f;
2249       tmp4 = tsOutCopy[0] - tsOutCopy[4] + tsOutCopy[8] - tsOutCopy[12] + tsOutCopy[16];
2250
2251       // 4 points on even indices
2252        float i66_ = tsOutCopy[6] * 1.732050808f; // Sqrt[3]
2253
2254       tmp0_ =
2255           tsOutCopy[2] * 1.9696155060244f + i66_ + tsOutCopy[10] * 1.2855752193731f + tsOutCopy[14]
2256               * 0.68404028665134f;
2257       tmp1_ = (tsOutCopy[2] - tsOutCopy[10] - tsOutCopy[14]) * 1.732050808f;
2258       tmp2_ =
2259           tsOutCopy[2] * 1.2855752193731f - i66_ - tsOutCopy[10] * 0.68404028665134f
2260               + tsOutCopy[14] * 1.9696155060244f;
2261       tmp3_ =
2262           tsOutCopy[2] * 0.68404028665134f - i66_ + tsOutCopy[10] * 1.9696155060244f
2263               - tsOutCopy[14] * 1.2855752193731f;
2264
2265       // 9 point IDCT on odd indices
2266       // 5 points on odd indices (not realy an IDCT)
2267        float i0 = tsOutCopy[0 + 1] + tsOutCopy[0 + 1];
2268        float i0p12 = i0 + tsOutCopy[12 + 1];
2269
2270       tmp0o =
2271           i0p12 + tsOutCopy[4 + 1] * 1.8793852415718f + tsOutCopy[8 + 1] * 1.532088886238f
2272               + tsOutCopy[16 + 1] * 0.34729635533386f;
2273       tmp1o =
2274           i0 + tsOutCopy[4 + 1] - tsOutCopy[8 + 1] - tsOutCopy[12 + 1] - tsOutCopy[12 + 1]
2275               - tsOutCopy[16 + 1];
2276       tmp2o =
2277           i0p12 - tsOutCopy[4 + 1] * 0.34729635533386f - tsOutCopy[8 + 1] * 1.8793852415718f
2278               + tsOutCopy[16 + 1] * 1.532088886238f;
2279       tmp3o =
2280           i0p12 - tsOutCopy[4 + 1] * 1.532088886238f + tsOutCopy[8 + 1] * 0.34729635533386f
2281               - tsOutCopy[16 + 1] * 1.8793852415718f;
2282       tmp4o =
2283           (tsOutCopy[0 + 1] - tsOutCopy[4 + 1] + tsOutCopy[8 + 1] - tsOutCopy[12 + 1] + tsOutCopy[16 + 1]) * 0.707106781f; // Twiddled
2284
2285       // 4 points on even indices
2286        float i6_ = tsOutCopy[6 + 1] * 1.732050808f; // Sqrt[3]
2287
2288       tmp0_o =
2289           tsOutCopy[2 + 1] * 1.9696155060244f + i6_ + tsOutCopy[10 + 1] * 1.2855752193731f
2290               + tsOutCopy[14 + 1] * 0.68404028665134f;
2291       tmp1_o = (tsOutCopy[2 + 1] - tsOutCopy[10 + 1] - tsOutCopy[14 + 1]) * 1.732050808f;
2292       tmp2_o =
2293           tsOutCopy[2 + 1] * 1.2855752193731f - i6_ - tsOutCopy[10 + 1] * 0.68404028665134f
2294               + tsOutCopy[14 + 1] * 1.9696155060244f;
2295       tmp3_o =
2296           tsOutCopy[2 + 1] * 0.68404028665134f - i6_ + tsOutCopy[10 + 1] * 1.9696155060244f
2297               - tsOutCopy[14 + 1] * 1.2855752193731f;
2298
2299       // Twiddle factors on odd indices
2300       // and
2301       // Butterflies on 9 point IDCT's
2302       // and
2303       // twiddle factors for 36 point IDCT
2304
2305        float e;
2306        float o;
2307       e = tmp0 + tmp0_;
2308       o = (tmp0o + tmp0_o) * 0.501909918f;
2309       tmpf_0 = e + o;
2310       tmpf_17 = e - o;
2311       e = tmp1 + tmp1_;
2312       o = (tmp1o + tmp1_o) * 0.517638090f;
2313       tmpf_1 = e + o;
2314       tmpf_16 = e - o;
2315       e = tmp2 + tmp2_;
2316       o = (tmp2o + tmp2_o) * 0.551688959f;
2317       tmpf_2 = e + o;
2318       tmpf_15 = e - o;
2319       e = tmp3 + tmp3_;
2320       o = (tmp3o + tmp3_o) * 0.610387294f;
2321       tmpf_3 = e + o;
2322       tmpf_14 = e - o;
2323       tmpf_4 = tmp4 + tmp4o;
2324       tmpf_13 = tmp4 - tmp4o;
2325       e = tmp3 - tmp3_;
2326       o = (tmp3o - tmp3_o) * 0.871723397f;
2327       tmpf_5 = e + o;
2328       tmpf_12 = e - o;
2329       e = tmp2 - tmp2_;
2330       o = (tmp2o - tmp2_o) * 1.183100792f;
2331       tmpf_6 = e + o;
2332       tmpf_11 = e - o;
2333       e = tmp1 - tmp1_;
2334       o = (tmp1o - tmp1_o) * 1.931851653f;
2335       tmpf_7 = e + o;
2336       tmpf_10 = e - o;
2337       e = tmp0 - tmp0_;
2338       o = (tmp0o - tmp0_o) * 5.736856623f;
2339       tmpf_8 = e + o;
2340       tmpf_9 = e - o;
2341
2342       // end 36 point IDCT */
2343       // shift to modified IDCT
2344       // win_bt = win[block_type]; //substituted this so that a new area does
2345       // not become created
2346
2347       rawout[0] = -tmpf_9 * win[block_type][0];
2348       rawout[1] = -tmpf_10 * win[block_type][1];
2349       rawout[2] = -tmpf_11 * win[block_type][2];
2350       rawout[3] = -tmpf_12 * win[block_type][3];
2351       rawout[4] = -tmpf_13 * win[block_type][4];
2352       rawout[5] = -tmpf_14 * win[block_type][5];
2353       rawout[6] = -tmpf_15 * win[block_type][6];
2354       rawout[7] = -tmpf_16 * win[block_type][7];
2355       rawout[8] = -tmpf_17 * win[block_type][8];
2356       rawout[9] = tmpf_17 * win[block_type][9];
2357       rawout[10] = tmpf_16 * win[block_type][10];
2358       rawout[11] = tmpf_15 * win[block_type][11];
2359       rawout[12] = tmpf_14 * win[block_type][12];
2360       rawout[13] = tmpf_13 * win[block_type][13];
2361       rawout[14] = tmpf_12 * win[block_type][14];
2362       rawout[15] = tmpf_11 * win[block_type][15];
2363       rawout[16] = tmpf_10 * win[block_type][16];
2364       rawout[17] = tmpf_9 * win[block_type][17];
2365       rawout[18] = tmpf_8 * win[block_type][18];
2366       rawout[19] = tmpf_7 * win[block_type][19];
2367       rawout[20] = tmpf_6 * win[block_type][20];
2368       rawout[21] = tmpf_5 * win[block_type][21];
2369       rawout[22] = tmpf_4 * win[block_type][22];
2370       rawout[23] = tmpf_3 * win[block_type][23];
2371       rawout[24] = tmpf_2 * win[block_type][24];
2372       rawout[25] = tmpf_1 * win[block_type][25];
2373       rawout[26] = tmpf_0 * win[block_type][26];
2374       rawout[27] = tmpf_0 * win[block_type][27];
2375       rawout[28] = tmpf_1 * win[block_type][28];
2376       rawout[29] = tmpf_2 * win[block_type][29];
2377       rawout[30] = tmpf_3 * win[block_type][30];
2378       rawout[31] = tmpf_4 * win[block_type][31];
2379       rawout[32] = tmpf_5 * win[block_type][32];
2380       rawout[33] = tmpf_6 * win[block_type][33];
2381       rawout[34] = tmpf_7 * win[block_type][34];
2382       rawout[35] = tmpf_8 * win[block_type][35];
2383     }
2384
2385   }
2386
2387   
2388   private int counter = 0;
2389   private static final int SSLIMIT = 18;
2390   private static final int SBLIMIT = 32;
2391
2392   // Size of the table of whole numbers raised to 4/3 power.
2393   // This may be adjusted for performance without any problems.
2394   // public static final int POW_TABLE_LIMIT=512;
2395
2396   private static final int slen[][] = { { 0, 0, 0, 0, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4 },
2397       { 0, 1, 2, 3, 0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 2, 3 } };
2398
2399   public static final int pretab[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 3,
2400       2, 0 };
2401
2402   
2403   private SBI[] sfBandIndex; // Init in the constructor.
2404
2405   public static final float two_to_negative_half_pow[] = { 1.0000000000E+00f, 7.0710678119E-01f,
2406       5.0000000000E-01f, 3.5355339059E-01f, 2.5000000000E-01f, 1.7677669530E-01f,
2407       1.2500000000E-01f, 8.8388347648E-02f, 6.2500000000E-02f, 4.4194173824E-02f,
2408       3.1250000000E-02f, 2.2097086912E-02f, 1.5625000000E-02f, 1.1048543456E-02f,
2409       7.8125000000E-03f, 5.5242717280E-03f, 3.9062500000E-03f, 2.7621358640E-03f,
2410       1.9531250000E-03f, 1.3810679320E-03f, 9.7656250000E-04f, 6.9053396600E-04f,
2411       4.8828125000E-04f, 3.4526698300E-04f, 2.4414062500E-04f, 1.7263349150E-04f,
2412       1.2207031250E-04f, 8.6316745750E-05f, 6.1035156250E-05f, 4.3158372875E-05f,
2413       3.0517578125E-05f, 2.1579186438E-05f, 1.5258789062E-05f, 1.0789593219E-05f,
2414       7.6293945312E-06f, 5.3947966094E-06f, 3.8146972656E-06f, 2.6973983047E-06f,
2415       1.9073486328E-06f, 1.3486991523E-06f, 9.5367431641E-07f, 6.7434957617E-07f,
2416       4.7683715820E-07f, 3.3717478809E-07f, 2.3841857910E-07f, 1.6858739404E-07f,
2417       1.1920928955E-07f, 8.4293697022E-08f, 5.9604644775E-08f, 4.2146848511E-08f,
2418       2.9802322388E-08f, 2.1073424255E-08f, 1.4901161194E-08f, 1.0536712128E-08f,
2419       7.4505805969E-09f, 5.2683560639E-09f, 3.7252902985E-09f, 2.6341780319E-09f,
2420       1.8626451492E-09f, 1.3170890160E-09f, 9.3132257462E-10f, 6.5854450798E-10f,
2421       4.6566128731E-10f, 3.2927225399E-10f };
2422
2423   public static final float t_43[] = create_t_43();
2424
2425   
2426   static private float[] create_t_43() {
2427      float[] t43 = new float[8192];
2428     final double d43 = (4.0 / 3.0);
2429
2430     for ( int i = 0; i < 8192; i++) {
2431       t43[i] = (float) Math.pow(i, d43);
2432     }
2433     return t43;
2434   }
2435
2436   public static final float io[][] = {
2437       { 1.0000000000E+00f, 8.4089641526E-01f, 7.0710678119E-01f, 5.9460355751E-01f,
2438           5.0000000001E-01f, 4.2044820763E-01f, 3.5355339060E-01f, 2.9730177876E-01f,
2439           2.5000000001E-01f, 2.1022410382E-01f, 1.7677669530E-01f, 1.4865088938E-01f,
2440           1.2500000000E-01f, 1.0511205191E-01f, 8.8388347652E-02f, 7.4325444691E-02f,
2441           6.2500000003E-02f, 5.2556025956E-02f, 4.4194173826E-02f, 3.7162722346E-02f,
2442           3.1250000002E-02f, 2.6278012978E-02f, 2.2097086913E-02f, 1.8581361173E-02f,
2443           1.5625000001E-02f, 1.3139006489E-02f, 1.1048543457E-02f, 9.2906805866E-03f,
2444           7.8125000006E-03f, 6.5695032447E-03f, 5.5242717285E-03f, 4.6453402934E-03f },
2445       { 1.0000000000E+00f, 7.0710678119E-01f, 5.0000000000E-01f, 3.5355339060E-01f,
2446           2.5000000000E-01f, 1.7677669530E-01f, 1.2500000000E-01f, 8.8388347650E-02f,
2447           6.2500000001E-02f, 4.4194173825E-02f, 3.1250000001E-02f, 2.2097086913E-02f,
2448           1.5625000000E-02f, 1.1048543456E-02f, 7.8125000002E-03f, 5.5242717282E-03f,
2449           3.9062500001E-03f, 2.7621358641E-03f, 1.9531250001E-03f, 1.3810679321E-03f,
2450           9.7656250004E-04f, 6.9053396603E-04f, 4.8828125002E-04f, 3.4526698302E-04f,
2451           2.4414062501E-04f, 1.7263349151E-04f, 1.2207031251E-04f, 8.6316745755E-05f,
2452           6.1035156254E-05f, 4.3158372878E-05f, 3.0517578127E-05f, 2.1579186439E-05f } };
2453
2454   public static final float TAN12[] = { 0.0f, 0.26794919f, 0.57735027f, 1.0f, 1.73205081f,
2455       3.73205081f, 9.9999999e10f, -3.73205081f, -1.73205081f, -1.0f, -0.57735027f, -0.26794919f,
2456       0.0f, 0.26794919f, 0.57735027f, 1.0f };
2457
2458   // REVIEW: in java, the array lookup may well be slower than
2459   // the actual calculation
2460   // 576 / 18
2461   /*
2462    * private static final int ss_div[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2463    * 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
2464    * 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
2465    * 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
2466    * 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6,
2467    * 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
2468    * 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
2469    * 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10,
2470    * 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11,
2471    * 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12,
2472    * 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13,
2473    * 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14,
2474    * 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
2475    * 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
2476    * 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
2477    * 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
2478    * 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
2479    * 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
2480    * 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
2481    * 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
2482    * 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
2483    * 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 25,
2484    * 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26,
2485    * 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27,
2486    * 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28,
2487    * 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29,
2488    * 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 30, 30, 30, 30, 30, 30,
2489    * 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 31, 31, 31, 31, 31, 31, 31,
2490    * 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31 };
2491    * 
2492    * // 576 % 18 private static final int ss_mod[] = { 0, 1, 2, 3, 4, 5, 6, 7,
2493    * 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
2494    * 12, 13, 14, 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
2495    * 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
2496    * 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 1, 2, 3,
2497    * 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7,
2498    * 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
2499    * 12, 13, 14, 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
2500    * 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
2501    * 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 1, 2, 3,
2502    * 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7,
2503    * 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
2504    * 12, 13, 14, 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
2505    * 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
2506    * 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 1, 2, 3,
2507    * 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7,
2508    * 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
2509    * 12, 13, 14, 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
2510    * 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
2511    * 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 1, 2, 3,
2512    * 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7,
2513    * 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
2514    * 12, 13, 14, 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
2515    * 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
2516    * 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 1, 2, 3,
2517    * 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7,
2518    * 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
2519    * 12, 13, 14, 15, 16, 17 };
2520    */
2521   
2522   private static/* final */int reorder_table[][]/* = loadReorderTable() */; // SZD:
2523
2524   // will
2525   // be
2526   // generated
2527   // on
2528   // demand
2529
2530   /**
2531    * Loads the data for the reorder
2532    */
2533   /*
2534    * private static int[][] loadReorderTable() // SZD: table will be generated {
2535    * try { Class elemType = int[][].class.getComponentType(); Object o =
2536    * JavaLayerUtils.deserializeArrayResource("l3reorder.ser", elemType, 6);
2537    * return (int[][])o; } catch (IOException ex) { throw new
2538    * ExceptionInInitializerError(ex); } }
2539    */
2540   
2541   static int[] reorder( int scalefac_band[]) { // SZD: converted from
2542                                                          // LAME
2543      int j = 0;
2544      int ix[] = new int[576];
2545     for (int sfb = 0; sfb < 13; sfb++) {
2546       int start = scalefac_band[sfb];
2547       int end = scalefac_band[sfb + 1];
2548       for (int window = 0; window < 3; window++)
2549         for (int i = start; i < end; i++)
2550           ix[3 * i + window] = j++;
2551     }
2552     return ix;
2553   }
2554
2555   /*
2556    * static final int reorder_table_data[][]; = { { 0, 4, 8, 1, 5, 9, 2, 6, 10,
2557    * 3, 7, 11, 12, 16, 20, 13, 17, 21, 14, 18, 22, 15, 19, 23, 24, 28, 32, 25,
2558    * 29, 33, 26, 30, 34, 27, 31, 35, 36, 42, 48, 37, 43, 49, 38, 44, 50, 39, 45,
2559    * 51, 40, 46, 52, 41, 47, 53, 54, 60, 66, 55, 61, 67, 56, 62, 68, 57, 63, 69,
2560    * 58, 64, 70, 59, 65, 71, 72, 80, 88, 73, 81, 89, 74, 82, 90, 75, 83, 91, 76,
2561    * 84, 92, 77, 85, 93, 78, 86, 94, 79, 87, 95, 96,106,116, 97,107,117,
2562    * 98,108,118, 99,109,119,100,110,120,101,
2563    * 111,121,102,112,122,103,113,123,104,114,124,105,115,125,126,140,
2564    * 154,127,141,155,128,142,156,129,143,157,130,144,158,131,145,159,
2565    * 132,146,160,133,147,161,134,148,162,135,149,163,136,150,164,137,
2566    * 151,165,138,152,166,139,153,167,168,186,204,169,187,205,170,188,
2567    * 206,171,189,207,172,190,208,173,191,209,174,192,210,175,193,211,
2568    * 176,194,212,177,195,213,178,196,214,179,197,215,180,198,216,181,
2569    * 199,217,182,200,218,183,201,219,184,202,220,185,203,221,222,248,
2570    * 274,223,249,275,224,250,276,225,251,277,226,252,278,227,253,279,
2571    * 228,254,280,229,255,281,230,256,282,231,257,283,232,258,284,233,
2572    * 259,285,234,260,286,235,261,287,236,262,288,237,263,289,238,264,
2573    * 290,239,265,291,240,266,292,241,267,293,242,268,294,243,269,295,
2574    * 244,270,296,245,271,297,246,272,298,247,273,299,300,332,364,301,
2575    * 333,365,302,334,366,303,335,367,304,336,368,305,337,369,306,338,
2576    * 370,307,339,371,308,340,372,309,341,373,310,342,374,311,343,375,
2577    * 312,344,376,313,345,377,314,346,378,315,347,379,316,348,380,317,
2578    * 349,381,318,350,382,319,351,383,320,352,384,321,353,385,322,354,
2579    * 386,323,355,387,324,356,388,325,357,389,326,358,390,327,359,391,
2580    * 328,360,392,329,361,393,330,362,394,331,363,395,396,438,480,397,
2581    * 439,481,398,440,482,399,441,483,400,442,484,401,443,485,402,444,
2582    * 486,403,445,487,404,446,488,405,447,489,406,448,490,407,449,491,
2583    * 408,450,492,409,451,493,410,452,494,411,453,495,412,454,496,413,
2584    * 455,497,414,456,498,415,457,499,416,458,500,417,459,501,418,460,
2585    * 502,419,461,503,420,462,504,421,463,505,422,464,506,423,465,507,
2586    * 424,466,508,425,467,509,426,468,510,427,469,511,428,470,512,429,
2587    * 471,513,430,472,514,431,473,515,432,474,516,433,475,517,434,476,
2588    * 518,435,477,519,436,478,520,437,479,521,522,540,558,523,541,559,
2589    * 524,542,560,525,543,561,526,544,562,527,545,563,528,546,564,529,
2590    * 547,565,530,548,566,531,549,567,532,550,568,533,551,569,534,552,
2591    * 570,535,553,571,536,554,572,537,555,573,538,556,574,539,557,575}, { 0, 4,
2592    * 8, 1, 5, 9, 2, 6, 10, 3, 7, 11, 12, 16, 20, 13, 17, 21, 14, 18, 22, 15, 19,
2593    * 23, 24, 28, 32, 25, 29, 33, 26, 30, 34, 27, 31, 35, 36, 42, 48, 37, 43, 49,
2594    * 38, 44, 50, 39, 45, 51, 40, 46, 52, 41, 47, 53, 54, 62, 70, 55, 63, 71, 56,
2595    * 64, 72, 57, 65, 73, 58, 66, 74, 59, 67, 75, 60, 68, 76, 61, 69, 77, 78, 88,
2596    * 98, 79, 89, 99, 80, 90,100, 81, 91,101, 82, 92,102, 83, 93,103, 84, 94,104,
2597    * 85, 95,105, 86, 96,106, 87, 97,107,108,120,132,109,
2598    * 121,133,110,122,134,111,123,135,112,124,136,113,125,137,114,126,
2599    * 138,115,127,139,116,128,140,117,129,141,118,130,142,119,131,143,
2600    * 144,158,172,145,159,173,146,160,174,147,161,175,148,162,176,149,
2601    * 163,177,150,164,178,151,165,179,152,166,180,153,167,181,154,168,
2602    * 182,155,169,183,156,170,184,157,171,185,186,204,222,187,205,223,
2603    * 188,206,224,189,207,225,190,208,226,191,209,227,192,210,228,193,
2604    * 211,229,194,212,230,195,213,231,196,214,232,197,215,233,198,216,
2605    * 234,199,217,235,200,218,236,201,219,237,202,220,238,203,221,239,
2606    * 240,264,288,241,265,289,242,266,290,243,267,291,244,268,292,245,
2607    * 269,293,246,270,294,247,271,295,248,272,296,249,273,297,250,274,
2608    * 298,251,275,299,252,276,300,253,277,301,254,278,302,255,279,303,
2609    * 256,280,304,257,281,305,258,282,306,259,283,307,260,284,308,261,
2610    * 285,309,262,286,310,263,287,311,312,344,376,313,345,377,314,346,
2611    * 378,315,347,379,316,348,380,317,349,381,318,350,382,319,351,383,
2612    * 320,352,384,321,353,385,322,354,386,323,355,387,324,356,388,325,
2613    * 357,389,326,358,390,327,359,391,328,360,392,329,361,393,330,362,
2614    * 394,331,363,395,332,364,396,333,365,397,334,366,398,335,367,399,
2615    * 336,368,400,337,369,401,338,370,402,339,371,403,340,372,404,341,
2616    * 373,405,342,374,406,343,375,407,408,452,496,409,453,497,410,454,
2617    * 498,411,455,499,412,456,500,413,457,501,414,458,502,415,459,503,
2618    * 416,460,504,417,461,505,418,462,506,419,463,507,420,464,508,421,
2619    * 465,509,422,466,510,423,467,511,424,468,512,425,469,513,426,470,
2620    * 514,427,471,515,428,472,516,429,473,517,430,474,518,431,475,519,
2621    * 432,476,520,433,477,521,434,478,522,435,479,523,436,480,524,437,
2622    * 481,525,438,482,526,439,483,527,440,484,528,441,485,529,442,486,
2623    * 530,443,487,531,444,488,532,445,489,533,446,490,534,447,491,535,
2624    * 448,492,536,449,493,537,450,494,538,451,495,539,540,552,564,541,
2625    * 553,565,542,554,566,543,555,567,544,556,568,545,557,569,546,558,
2626    * 570,547,559,571,548,560,572,549,561,573,550,562,574,551,563,575}, { 0, 4,
2627    * 8, 1, 5, 9, 2, 6, 10, 3, 7, 11, 12, 16, 20, 13, 17, 21, 14, 18, 22, 15, 19,
2628    * 23, 24, 28, 32, 25, 29, 33, 26, 30, 34, 27, 31, 35, 36, 42, 48, 37, 43, 49,
2629    * 38, 44, 50, 39, 45, 51, 40, 46, 52, 41, 47, 53, 54, 62, 70, 55, 63, 71, 56,
2630    * 64, 72, 57, 65, 73, 58, 66, 74, 59, 67, 75, 60, 68, 76, 61, 69, 77, 78, 88,
2631    * 98, 79, 89, 99, 80, 90,100, 81, 91,101, 82, 92,102, 83, 93,103, 84, 94,104,
2632    * 85, 95,105, 86, 96,106, 87, 97,107,108,120,132,109,
2633    * 121,133,110,122,134,111,123,135,112,124,136,113,125,137,114,126,
2634    * 138,115,127,139,116,128,140,117,129,141,118,130,142,119,131,143,
2635    * 144,158,172,145,159,173,146,160,174,147,161,175,148,162,176,149,
2636    * 163,177,150,164,178,151,165,179,152,166,180,153,167,181,154,168,
2637    * 182,155,169,183,156,170,184,157,171,185,186,204,222,187,205,223,
2638    * 188,206,224,189,207,225,190,208,226,191,209,227,192,210,228,193,
2639    * 211,229,194,212,230,195,213,231,196,214,232,197,215,233,198,216,
2640    * 234,199,217,235,200,218,236,201,219,237,202,220,238,203,221,239,
2641    * 240,264,288,241,265,289,242,266,290,243,267,291,244,268,292,245,
2642    * 269,293,246,270,294,247,271,295,248,272,296,249,273,297,250,274,
2643    * 298,251,275,299,252,276,300,253,277,301,254,278,302,255,279,303,
2644    * 256,280,304,257,281,305,258,282,306,259,283,307,260,284,308,261,
2645    * 285,309,262,286,310,263,287,311,312,342,372,313,343,373,314,344,
2646    * 374,315,345,375,316,346,376,317,347,377,318,348,378,319,349,379,
2647    * 320,350,380,321,351,381,322,352,382,323,353,383,324,354,384,325,
2648    * 355,385,326,356,386,327,357,387,328,358,388,329,359,389,330,360,
2649    * 390,331,361,391,332,362,392,333,363,393,334,364,394,335,365,395,
2650    * 336,366,396,337,367,397,338,368,398,339,369,399,340,370,400,341,
2651    * 371,401,402,442,482,403,443,483,404,444,484,405,445,485,406,446,
2652    * 486,407,447,487,408,448,488,409,449,489,410,450,490,411,451,491,
2653    * 412,452,492,413,453,493,414,454,494,415,455,495,416,456,496,417,
2654    * 457,497,418,458,498,419,459,499,420,460,500,421,461,501,422,462,
2655    * 502,423,463,503,424,464,504,425,465,505,426,466,506,427,467,507,
2656    * 428,468,508,429,469,509,430,470,510,431,471,511,432,472,512,433,
2657    * 473,513,434,474,514,435,475,515,436,476,516,437,477,517,438,478,
2658    * 518,439,479,519,440,480,520,441,481,521,522,540,558,523,541,559,
2659    * 524,542,560,525,543,561,526,544,562,527,545,563,528,546,564,529,
2660    * 547,565,530,548,566,531,549,567,532,550,568,533,551,569,534,552,
2661    * 570,535,553,571,536,554,572,537,555,573,538,556,574,539,557,575}, { 0, 4,
2662    * 8, 1, 5, 9, 2, 6, 10, 3, 7, 11, 12, 16, 20, 13, 17, 21, 14, 18, 22, 15, 19,
2663    * 23, 24, 28, 32, 25, 29, 33, 26, 30, 34, 27, 31, 35, 36, 40, 44, 37, 41, 45,
2664    * 38, 42, 46, 39, 43, 47, 48, 54, 60, 49, 55, 61, 50, 56, 62, 51, 57, 63, 52,
2665    * 58, 64, 53, 59, 65, 66, 74, 82, 67, 75, 83, 68, 76, 84, 69, 77, 85, 70, 78,
2666    * 86, 71, 79, 87, 72, 80, 88, 73, 81, 89, 90,100,110, 91,101,111, 92,102,112,
2667    * 93,103,113, 94,104,114, 95,105,115, 96,106,116, 97, 107,117, 98,108,118,
2668    * 99,109,119,120,132,144,121,133,145,122,134,
2669    * 146,123,135,147,124,136,148,125,137,149,126,138,150,127,139,151,
2670    * 128,140,152,129,141,153,130,142,154,131,143,155,156,170,184,157,
2671    * 171,185,158,172,186,159,173,187,160,174,188,161,175,189,162,176,
2672    * 190,163,177,191,164,178,192,165,179,193,166,180,194,167,181,195,
2673    * 168,182,196,169,183,197,198,216,234,199,217,235,200,218,236,201,
2674    * 219,237,202,220,238,203,221,239,204,222,240,205,223,241,206,224,
2675    * 242,207,225,243,208,226,244,209,227,245,210,228,246,211,229,247,
2676    * 212,230,248,213,231,249,214,232,250,215,233,251,252,274,296,253,
2677    * 275,297,254,276,298,255,277,299,256,278,300,257,279,301,258,280,
2678    * 302,259,281,303,260,282,304,261,283,305,262,284,306,263,285,307,
2679    * 264,286,308,265,287,309,266,288,310,267,289,311,268,290,312,269,
2680    * 291,313,270,292,314,271,293,315,272,294,316,273,295,317,318,348,
2681    * 378,319,349,379,320,350,380,321,351,381,322,352,382,323,353,383,
2682    * 324,354,384,325,355,385,326,356,386,327,357,387,328,358,388,329,
2683    * 359,389,330,360,390,331,361,391,332,362,392,333,363,393,334,364,
2684    * 394,335,365,395,336,366,396,337,367,397,338,368,398,339,369,399,
2685    * 340,370,400,341,371,401,342,372,402,343,373,403,344,374,404,345,
2686    * 375,405,346,376,406,347,377,407,408,464,520,409,465,521,410,466,
2687    * 522,411,467,523,412,468,524,413,469,525,414,470,526,415,471,527,
2688    * 416,472,528,417,473,529,418,474,530,419,475,531,420,476,532,421,
2689    * 477,533,422,478,534,423,479,535,424,480,536,425,481,537,426,482,
2690    * 538,427,483,539,428,484,540,429,485,541,430,486,542,431,487,543,
2691    * 432,488,544,433,489,545,434,490,546,435,491,547,436,492,548,437,
2692    * 493,549,438,494,550,439,495,551,440,496,552,441,497,553,442,498,
2693    * 554,443,499,555,444,500,556,445,501,557,446,502,558,447,503,559,
2694    * 448,504,560,449,505,561,450,506,562,451,507,563,452,508,564,453,
2695    * 509,565,454,510,566,455,511,567,456,512,568,457,513,569,458,514,
2696    * 570,459,515,571,460,516,572,461,517,573,462,518,574,463,519,575}, { 0, 4,
2697    * 8, 1, 5, 9, 2, 6, 10, 3, 7, 11, 12, 16, 20, 13, 17, 21, 14, 18, 22, 15, 19,
2698    * 23, 24, 28, 32, 25, 29, 33, 26, 30, 34, 27, 31, 35, 36, 40, 44, 37, 41, 45,
2699    * 38, 42, 46, 39, 43, 47, 48, 54, 60, 49, 55, 61, 50, 56, 62, 51, 57, 63, 52,
2700    * 58, 64, 53, 59, 65, 66, 72, 78, 67, 73, 79, 68, 74, 80, 69, 75, 81, 70, 76,
2701    * 82, 71, 77, 83, 84, 94,104, 85, 95,105, 86, 96,106, 87, 97,107, 88, 98,108,
2702    * 89, 99,109, 90,100,110, 91,101,111, 92,102,112, 93,
2703    * 103,113,114,126,138,115,127,139,116,128,140,117,129,141,118,130,
2704    * 142,119,131,143,120,132,144,121,133,145,122,134,146,123,135,147,
2705    * 124,136,148,125,137,149,150,164,178,151,165,179,152,166,180,153,
2706    * 167,181,154,168,182,155,169,183,156,170,184,157,171,185,158,172,
2707    * 186,159,173,187,160,174,188,161,175,189,162,176,190,163,177,191,
2708    * 192,208,224,193,209,225,194,210,226,195,211,227,196,212,228,197,
2709    * 213,229,198,214,230,199,215,231,200,216,232,201,217,233,202,218,
2710    * 234,203,219,235,204,220,236,205,221,237,206,222,238,207,223,239,
2711    * 240,260,280,241,261,281,242,262,282,243,263,283,244,264,284,245,
2712    * 265,285,246,266,286,247,267,287,248,268,288,249,269,289,250,270,
2713    * 290,251,271,291,252,272,292,253,273,293,254,274,294,255,275,295,
2714    * 256,276,296,257,277,297,258,278,298,259,279,299,300,326,352,301,
2715    * 327,353,302,328,354,303,329,355,304,330,356,305,331,357,306,332,
2716    * 358,307,333,359,308,334,360,309,335,361,310,336,362,311,337,363,
2717    * 312,338,364,313,339,365,314,340,366,315,341,367,316,342,368,317,
2718    * 343,369,318,344,370,319,345,371,320,346,372,321,347,373,322,348,
2719    * 374,323,349,375,324,350,376,325,351,377,378,444,510,379,445,511,
2720    * 380,446,512,381,447,513,382,448,514,383,449,515,384,450,516,385,
2721    * 451,517,386,452,518,387,453,519,388,454,520,389,455,521,390,456,
2722    * 522,391,457,523,392,458,524,393,459,525,394,460,526,395,461,527,
2723    * 396,462,528,397,463,529,398,464,530,399,465,531,400,466,532,401,
2724    * 467,533,402,468,534,403,469,535,404,470,536,405,471,537,406,472,
2725    * 538,407,473,539,408,474,540,409,475,541,410,476,542,411,477,543,
2726    * 412,478,544,413,479,545,414,480,546,415,481,547,416,482,548,417,
2727    * 483,549,418,484,550,419,485,551,420,486,552,421,487,553,422,488,
2728    * 554,423,489,555,424,490,556,425,491,557,426,492,558,427,493,559,
2729    * 428,494,560,429,495,561,430,496,562,431,497,563,432,498,564,433,
2730    * 499,565,434,500,566,435,501,567,436,502,568,437,503,569,438,504,
2731    * 570,439,505,571,440,506,572,441,507,573,442,508,574,443,509,575}, { 0, 4,
2732    * 8, 1, 5, 9, 2, 6, 10, 3, 7, 11, 12, 16, 20, 13, 17, 21, 14, 18, 22, 15, 19,
2733    * 23, 24, 28, 32, 25, 29, 33, 26, 30, 34, 27, 31, 35, 36, 40, 44, 37, 41, 45,
2734    * 38, 42, 46, 39, 43, 47, 48, 54, 60, 49, 55, 61, 50, 56, 62, 51, 57, 63, 52,
2735    * 58, 64, 53, 59, 65, 66, 74, 82, 67, 75, 83, 68, 76, 84, 69, 77, 85, 70, 78,
2736    * 86, 71, 79, 87, 72, 80, 88, 73, 81, 89, 90,102,114, 91,103,115, 92,104,116,
2737    * 93,105,117, 94,106,118, 95,107,119, 96,108,120, 97, 109,121, 98,110,122,
2738    * 99,111,123,100,112,124,101,113,125,126,142,
2739    * 158,127,143,159,128,144,160,129,145,161,130,146,162,131,147,163,
2740    * 132,148,164,133,149,165,134,150,166,135,151,167,136,152,168,137,
2741    * 153,169,138,154,170,139,155,171,140,156,172,141,157,173,174,194,
2742    * 214,175,195,215,176,196,216,177,197,217,178,198,218,179,199,219,
2743    * 180,200,220,181,201,221,182,202,222,183,203,223,184,204,224,185,
2744    * 205,225,186,206,226,187,207,227,188,208,228,189,209,229,190,210,
2745    * 230,191,211,231,192,212,232,193,213,233,234,260,286,235,261,287,
2746    * 236,262,288,237,263,289,238,264,290,239,265,291,240,266,292,241,
2747    * 267,293,242,268,294,243,269,295,244,270,296,245,271,297,246,272,
2748    * 298,247,273,299,248,274,300,249,275,301,250,276,302,251,277,303,
2749    * 252,278,304,253,279,305,254,280,306,255,281,307,256,282,308,257,
2750    * 283,309,258,284,310,259,285,311,312,346,380,313,347,381,314,348,
2751    * 382,315,349,383,316,350,384,317,351,385,318,352,386,319,353,387,
2752    * 320,354,388,321,355,389,322,356,390,323,357,391,324,358,392,325,
2753    * 359,393,326,360,394,327,361,395,328,362,396,329,363,397,330,364,
2754    * 398,331,365,399,332,366,400,333,367,401,334,368,402,335,369,403,
2755    * 336,370,404,337,371,405,338,372,406,339,373,407,340,374,408,341,
2756    * 375,409,342,376,410,343,377,411,344,378,412,345,379,413,414,456,
2757    * 498,415,457,499,416,458,500,417,459,501,418,460,502,419,461,503,
2758    * 420,462,504,421,463,505,422,464,506,423,465,507,424,466,508,425,
2759    * 467,509,426,468,510,427,469,511,428,470,512,429,471,513,430,472,
2760    * 514,431,473,515,432,474,516,433,475,517,434,476,518,435,477,519,
2761    * 436,478,520,437,479,521,438,480,522,439,481,523,440,482,524,441,
2762    * 483,525,442,484,526,443,485,527,444,486,528,445,487,529,446,488,
2763    * 530,447,489,531,448,490,532,449,491,533,450,492,534,451,493,535,
2764    * 452,494,536,453,495,537,454,496,538,455,497,539,540,552,564,541,
2765    * 553,565,542,554,566,543,555,567,544,556,568,545,557,569,546,558,
2766    * 570,547,559,571,548,560,572,549,561,573,550,562,574,551,563,575} };
2767    */
2768
2769   private static final float cs[] = { 0.857492925712f, 0.881741997318f, 0.949628649103f,
2770       0.983314592492f, 0.995517816065f, 0.999160558175f, 0.999899195243f, 0.999993155067f };
2771
2772   private static final float ca[] = { -0.5144957554270f, -0.4717319685650f, -0.3133774542040f,
2773       -0.1819131996110f, -0.0945741925262f, -0.0409655828852f, -0.0141985685725f,
2774       -0.00369997467375f };
2775
2776   /************************************************************/
2777   /* END OF L3TABLE */
2778   /************************************************************/
2779
2780   /************************************************************/
2781   /* L3TYPE */
2782   /************************************************************/
2783
2784   /***************************************************************/
2785   /* END OF L3TYPE */
2786   /***************************************************************/
2787
2788   /***************************************************************/
2789   /* INV_MDCT */
2790   /***************************************************************/
2791   public static final float win[][] = {
2792       { -1.6141214951E-02f, -5.3603178919E-02f, -1.0070713296E-01f, -1.6280817573E-01f,
2793           -4.9999999679E-01f, -3.8388735032E-01f, -6.2061144372E-01f, -1.1659756083E+00f,
2794           -3.8720752656E+00f, -4.2256286556E+00f, -1.5195289984E+00f, -9.7416483388E-01f,
2795           -7.3744074053E-01f, -1.2071067773E+00f, -5.1636156596E-01f, -4.5426052317E-01f,
2796           -4.0715656898E-01f, -3.6969460527E-01f, -3.3876269197E-01f, -3.1242222492E-01f,
2797           -2.8939587111E-01f, -2.6880081906E-01f, -5.0000000266E-01f, -2.3251417468E-01f,
2798           -2.1596714708E-01f, -2.0004979098E-01f, -1.8449493497E-01f, -1.6905846094E-01f,
2799           -1.5350360518E-01f, -1.3758624925E-01f, -1.2103922149E-01f, -2.0710679058E-01f,
2800           -8.4752577594E-02f, -6.4157525656E-02f, -4.1131172614E-02f, -1.4790705759E-02f },
2801
2802       { -1.6141214951E-02f, -5.3603178919E-02f, -1.0070713296E-01f, -1.6280817573E-01f,
2803           -4.9999999679E-01f, -3.8388735032E-01f, -6.2061144372E-01f, -1.1659756083E+00f,
2804           -3.8720752656E+00f, -4.2256286556E+00f, -1.5195289984E+00f, -9.7416483388E-01f,
2805           -7.3744074053E-01f, -1.2071067773E+00f, -5.1636156596E-01f, -4.5426052317E-01f,
2806           -4.0715656898E-01f, -3.6969460527E-01f, -3.3908542600E-01f, -3.1511810350E-01f,
2807           -2.9642226150E-01f, -2.8184548650E-01f, -5.4119610000E-01f, -2.6213228100E-01f,
2808           -2.5387916537E-01f, -2.3296291359E-01f, -1.9852728987E-01f, -1.5233534808E-01f,
2809           -9.6496400054E-02f, -3.3423828516E-02f, 0.0000000000E+00f, 0.0000000000E+00f,
2810           0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f },
2811
2812       { -4.8300800645E-02f, -1.5715656932E-01f, -2.8325045177E-01f, -4.2953747763E-01f,
2813           -1.2071067795E+00f, -8.2426483178E-01f, -1.1451749106E+00f, -1.7695290101E+00f,
2814           -4.5470225061E+00f, -3.4890531002E+00f, -7.3296292804E-01f, -1.5076514758E-01f,
2815           0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f,
2816           0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f,
2817           0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f,
2818           0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f,
2819           0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f,
2820           0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f },
2821
2822       { 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f,
2823           0.0000000000E+00f, 0.0000000000E+00f, -1.5076513660E-01f, -7.3296291107E-01f,
2824           -3.4890530566E+00f, -4.5470224727E+00f, -1.7695290031E+00f, -1.1451749092E+00f,
2825           -8.3137738100E-01f, -1.3065629650E+00f, -5.4142014250E-01f, -4.6528974900E-01f,
2826           -4.1066990750E-01f, -3.7004680800E-01f, -3.3876269197E-01f, -3.1242222492E-01f,
2827           -2.8939587111E-01f, -2.6880081906E-01f, -5.0000000266E-01f, -2.3251417468E-01f,
2828           -2.1596714708E-01f, -2.0004979098E-01f, -1.8449493497E-01f, -1.6905846094E-01f,
2829           -1.5350360518E-01f, -1.3758624925E-01f, -1.2103922149E-01f, -2.0710679058E-01f,
2830           -8.4752577594E-02f, -6.4157525656E-02f, -4.1131172614E-02f, -1.4790705759E-02f } };
2831
2832   /***************************************************************/
2833   /* END OF INV_MDCT */
2834   /***************************************************************/
2835
2836   public static final int nr_of_sfb_block[][][] = {
2837       { { 6, 5, 5, 5 }, { 9, 9, 9, 9 }, { 6, 9, 9, 9 } },
2838       { { 6, 5, 7, 3 }, { 9, 9, 12, 6 }, { 6, 9, 12, 6 } },
2839       { { 11, 10, 0, 0 }, { 18, 18, 0, 0 }, { 15, 18, 0, 0 } },
2840       { { 7, 7, 7, 0 }, { 12, 12, 12, 0 }, { 6, 15, 12, 0 } },
2841       { { 6, 6, 6, 3 }, { 12, 9, 9, 6 }, { 6, 12, 9, 6 } },
2842       { { 8, 8, 5, 0 }, { 15, 12, 9, 0 }, { 6, 18, 9, 0 } } };
2843
2844 }
2845
2846 /************************************************************/
2847 /* L3TABLE */
2848 /************************************************************/
2849
2850
2851 class SBI {
2852   
2853   public int[] l;
2854   
2855   public int[] s;
2856
2857   public SBI() {
2858     l = new int[23];
2859     s = new int[14];
2860   }
2861
2862   
2863   public SBI(@DELEGATE  int[] thel, @DELEGATE  int[] thes) {
2864     l = thel;
2865     s = thes;
2866   }
2867 }
2868
2869
2870 class gr_info_s {
2871   
2872   public int part2_3_length = 0;
2873   
2874   public int big_values = 0;
2875   
2876   public int global_gain = 0;
2877   
2878   public int scalefac_compress = 0;
2879   
2880   public int window_switching_flag = 0;
2881   
2882   public int block_type = 0;
2883   
2884   public int mixed_block_flag = 0;
2885   
2886   public int[] table_select;
2887   
2888   public int[] subblock_gain;
2889   
2890   public int region0_count = 0;
2891   
2892   public int region1_count = 0;
2893   
2894   public int preflag = 0;
2895   
2896   public int scalefac_scale = 0;
2897   
2898   public int count1table_select = 0;
2899
2900   /**
2901    * Dummy Constructor
2902    */
2903   public gr_info_s() {
2904     table_select = new int[3];
2905     subblock_gain = new int[3];
2906   }
2907 }
2908
2909
2910 class temporaire {
2911   
2912   public int[] scfsi;
2913   
2914   public gr_info_s[] gr;
2915
2916   /**
2917    * Dummy Constructor
2918    */
2919   public temporaire() {
2920     scfsi = new int[4];
2921     gr = new gr_info_s[2];
2922     gr[0] = new gr_info_s();
2923     gr[1] = new gr_info_s();
2924   }
2925 }
2926
2927
2928 class III_side_info_t {
2929
2930   
2931   public int main_data_begin = 0;
2932   
2933   public int private_bits = 0;
2934   
2935   public temporaire[] ch;
2936
2937   /**
2938    * Dummy Constructor
2939    */
2940   public III_side_info_t() {
2941     ch = new temporaire[2];
2942     ch[0] = new temporaire();
2943     ch[1] = new temporaire();
2944   }
2945 }
2946
2947
2948 class temporaire2 {
2949   
2950   public int[] l; /* [cb] */
2951   
2952   public int[][] s; /* [window][cb] */
2953
2954   /**
2955    * Dummy Constructor
2956    */
2957   public temporaire2() {
2958     l = new int[23];
2959     s = new int[3][13];
2960   }
2961 }
2962
2963 // class III_scalefac_t
2964 // {
2965 // public temporaire2[] tab;
2966 // /**
2967 // * Dummy Constructor
2968 // */
2969 // public III_scalefac_t()
2970 // {
2971 // tab = new temporaire2[2];
2972 // }
2973 // }