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