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