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