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