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