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