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