2 * 11/19/04 1.0 moved to LGPL.
4 * 18/06/01 Michael Scheerer, Fixed bugs which causes
5 * negative indexes in method huffmann_decode and in method
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
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.
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.
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 *----------------------------------------------------------------------
36 * Class Implementing Layer 3 Decoder.
40 // @LATTICE("FS<BR,BR<SF,LR<IR,IR<IP,IP<SF,LR<K,K<F,LR<VAR,LR<RO,RO<F,VAR<F,VAR<RAW,CSH<F,SAM<O,O<F,NS<SI,SI<CH,SFREQ<H,MAX<H,H<CH,FLCH<CH,FLCH<WC,SF<SFT,SFT<NS,NS<C,TS<RAW,O<TS,LY<F,NZ<VAR,C*,FS*,IP*,IR*,LR*,K*,O*,TS*,TS<BT,BT<GR,GR<SI,LR<S,S<ME,ME<CH,K<SH,K<LSF,LSF<H,LSF<CH,IP<SH,SH<J,J<S,S<ME,SH<SFREQ,SH<RO,IP<TMP2,LSF<H,TMP2<F,J*,SH*,O<RO2,RO2<RO3,RO3<RO4,RO4<RO5,O<RO1,RO1<RO5,RO5<RO6,RO6<RO7,RO7<RO8,RO8<RO9,RO9<SFREQ,RO9<F,RO1*,RO4*,RO5*,RO6*,RO9*,VAR<HD3,HD3<HD2,HD2<HD1,HD1<SI,HD1<SFREQ,HD1<RAW,HD2*,HD3*,SFB<GLSFD5,GLSFD5<NS,GLSFD5<GLSFD4,NS<GLSFD3,GLSFD4<GLSFD3,GLSFD3<GLSFD2,GLSFD2<GLSFD1,GLSFD1<SI,GLSFD5*,SF<GLSFF4,GLSFF4<GLSFF3,GLSFF3<GLSFF2,GLSFF2<GLSFF1,GLSFF1<SI,GLSFF4*,GLSFF3*,GLSFF2*,SF<GSF5,GSF5<GSF4,GSF4<GSF3,GSF3<GSF2,GSF2<GSF1,GSF1<SI,GSF5*,GSF4*,O<D3,D3<D2,D2<D1,D1<FLCH,D1*,D2*")
41 // 4th line added for hybrid.
42 // 5th added for stereo
43 // 6th added for reorder method
44 // 7th added for huffman_decode method
45 // 8th added for get_LSF_scale_data
46 // 9th added for get_LSF_scale_factors
47 // 10th added for get_scale_factors
48 // llth added for decode
49 // @LATTICE("IS1D*,RO<IS1D,IS1D<SI2,SI2<SI1,SI<P2S,SF1<CH0,SF0*,SFB_SH<NS,NS<SI,SFB_SH*,SFB<SFB_SH,C,C*,SI1<SF2,SF2<SFB,SF1<BR,LR*,OUT<LR,LR<RO,NZ*,SI<SF1,SI1<NZ,NZ<SI,SI1<SBI,SBI<SI,BUF<FT,SF1<SF0,SF0<HD1,BR<ST,ST,FT<SP,SP<OUT,OUT<SI1,SI1<SI,P2S<CH0,CH0<MAX0,MAX0<BR1,FS<BR1,BR1<BR,BR<HD1,HD1<HD,OUT*,BR1*,SI1*,MAX0*,CH0*,RAW,TS,F,C,K,LY,VAR,IR,IP,CSH,GLSFD3,GLSFD4,GLSFD5,GLSFF4,GLSFF2,GLSFF3,GLSFF1,GSF4,GSF5,GSF1,GSF2,GSF3,HD2,HD3,BT,GR,RO6,RO5,RO9,RO8,RO7,RO4,RO1,RO3,RO2,SH,ME,TMP2,S,LSF,J")
50 @LATTICE("ISR*,ISP*,LR<ISR,ISR<ISP,SI1<SF2,NS*,HD<ST,IS1D*,RO1<RO,RO1*,RO<IS1D,IS1D<SI2,SI2<SI1,BR<NS,NS<SI,SFB_SH*,SFB<SFB_SH,C,C*,SF2<SFB,LR*,OUT<LR,ISP<RO1,NZ*,SI<SF1,BR1<NZ,NZ<BR,SI1<RT,RT<SBI,SBI<SI,BUF<FT,SF1<CH0,CH0<HD1,FT<SP,SP<OUT,OUT<SI1,SI1<SI,SFB_SH<BR1,BR1<BR,HD1<HD,OUT*,BR1*,SI1*,CH0*,RAW,TS,F,C,K,LY,VAR,IR,IP,CSH,GLSFD3,GLSFD4,GLSFD5,GLSFF4,GLSFF2,GLSFF3,GLSFF1,GSF4,GSF5,GSF1,GSF2,GSF3,HD2,HD3,BT,GR,RO6,RO5,RO9,RO8,RO7,RO4,RO1,RO3,RO2,SH,ME,TMP2,S,LSF,J")
51 @METHODDEFAULT("OUT<V,V<THIS,THIS<SH,SH<IN,SH*,THISLOC=THIS,GLOBALLOC=IN,RETURNLOC=OUT")
52 final class LayerIIIDecoder implements FrameDecoder {
53 static final double d43 = (4.0 / 3.0);
55 public int[] scalefac_buffer;
57 // MDM: removed, as this wasn't being used.
58 // private float CheckSumOut1d = 0.0f;
60 private int CheckSumHuff = 0;
64 private float[][][] ro;
66 private float[][][] lr;
68 private float[] out_1d; // 576 samples
70 private float[][] prevblck;
74 private int[] nonzero;
76 // private Header header;
78 private SynthesisFilter filter1;
80 private SynthesisFilter filter2;
82 // private Obuffer buffer; // output buffer
84 private int which_channels;
86 private BitReserve br;
88 private III_side_info_t si;
90 // @LOC("SBT") private temporaire2[] III_scalefac_t;
92 private temporaire2[] scalefac;
93 // private III_scalefac_t scalefac;
98 private int frame_start;
99 // @LOC("SI1") private int part2_start;
101 private int channels;
103 private int first_channel;
105 private int last_channel;
110 private int part2_start;
113 private boolean initialized = false;
115 // constructor for the linear type system
116 public LayerIIIDecoder(@DELEGATE @LOC("VAR") SynthesisFilter filtera,
117 @DELEGATE @LOC("VAR") SynthesisFilter filterb, @LOC("VAR") int which_ch0) {
122 huffcodetab.inithuff();
123 is_1d = new int[SBLIMIT * SSLIMIT + 4];
124 ro = new float[2][SBLIMIT][SSLIMIT];
125 lr = new float[2][SBLIMIT][SSLIMIT];
126 out_1d = new float[SBLIMIT * SSLIMIT];
127 prevblck = new float[2][SBLIMIT * SSLIMIT];
128 k = new float[2][SBLIMIT * SSLIMIT];
129 nonzero = new int[2];
131 // removes unnecessary aliases
133 // III_scalefac_t = new temporaire2[2];
134 // III_scalefac_t[0] = new temporaire2();
135 // III_scalefac_t[1] = new temporaire2();
136 // scalefac = III_scalefac_t;
138 scalefac = new temporaire2[2];
139 scalefac[0] = new temporaire2();
140 scalefac[1] = new temporaire2();
144 sfBandIndex = new SBI[9]; // SZD: MPEG2.5 +3 indices
145 @LOC("VAR") int[] l0 =
146 { 0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396,
148 @LOC("VAR") int[] s0 = { 0, 4, 8, 12, 18, 24, 32, 42, 56, 74, 100, 132, 174, 192 };
149 @LOC("VAR") int[] l1 =
150 { 0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 114, 136, 162, 194, 232, 278, 330, 394,
152 @LOC("VAR") int[] s1 = { 0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 136, 180, 192 };
153 @LOC("VAR") int[] l2 =
154 { 0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396,
156 @LOC("VAR") int[] s2 = { 0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 134, 174, 192 };
158 @LOC("VAR") int[] l3 =
159 { 0, 4, 8, 12, 16, 20, 24, 30, 36, 44, 52, 62, 74, 90, 110, 134, 162, 196, 238, 288, 342,
161 @LOC("VAR") int[] s3 = { 0, 4, 8, 12, 16, 22, 30, 40, 52, 66, 84, 106, 136, 192 };
162 @LOC("VAR") int[] l4 =
163 { 0, 4, 8, 12, 16, 20, 24, 30, 36, 42, 50, 60, 72, 88, 106, 128, 156, 190, 230, 276, 330,
165 @LOC("VAR") int[] s4 = { 0, 4, 8, 12, 16, 22, 28, 38, 50, 64, 80, 100, 126, 192 };
166 @LOC("VAR") int[] l5 =
167 { 0, 4, 8, 12, 16, 20, 24, 30, 36, 44, 54, 66, 82, 102, 126, 156, 194, 240, 296, 364, 448,
169 @LOC("VAR") int[] s5 = { 0, 4, 8, 12, 16, 22, 30, 42, 58, 78, 104, 138, 180, 192 };
171 @LOC("VAR") int[] l6 =
172 { 0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396,
174 @LOC("VAR") int[] s6 = { 0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 134, 174, 192 };
175 @LOC("VAR") int[] l7 =
176 { 0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396,
178 @LOC("VAR") int[] s7 = { 0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 134, 174, 192 };
179 @LOC("VAR") int[] l8 =
180 { 0, 12, 24, 36, 48, 60, 72, 88, 108, 132, 160, 192, 232, 280, 336, 400, 476, 566, 568,
181 570, 572, 574, 576 };
182 @LOC("VAR") int[] s8 = { 0, 8, 16, 24, 36, 52, 72, 96, 124, 160, 162, 164, 166, 192 };
184 sfBandIndex[0] = new SBI(l0, s0);
185 sfBandIndex[1] = new SBI(l1, s1);
186 sfBandIndex[2] = new SBI(l2, s2);
188 sfBandIndex[3] = new SBI(l3, s3);
189 sfBandIndex[4] = new SBI(l4, s4);
190 sfBandIndex[5] = new SBI(l5, s5);
192 sfBandIndex[6] = new SBI(l6, s6);
193 sfBandIndex[7] = new SBI(l7, s7);
194 sfBandIndex[8] = new SBI(l8, s8);
195 // END OF L3TABLE INIT
197 if (reorder_table == null) { // SZD: generate LUT
198 reorder_table = new int[9][];
199 for (@LOC("I") int i = 0; i < 9; i++)
200 reorder_table[i] = reorder(sfBandIndex[i].s);
204 @LOC("VAR") int[] ll0 = { 0, 6, 11, 16, 21 };
205 @LOC("VAR") int[] ss0 = { 0, 6, 12 };
206 sftable = new Sftable(ll0, ss0);
210 scalefac_buffer = new int[54];
211 // END OF scalefac_buffer
215 @LATTICE("THIS<C,THIS<IN,C*,THISLOC=THIS")
216 private void init(@LOC("IN") Header header) {
219 channels = (header.mode() == Header.SINGLE_CHANNEL) ? 1 : 2;
220 max_gr = (header.version() == Header.MPEG1) ? 2 : 1;
223 header.sample_frequency()
224 + ((header.version() == Header.MPEG1) ? 3 : (header.version() == Header.MPEG25_LSF) ? 6
228 switch (which_channels) {
229 case OutputChannels.LEFT_CHANNEL:
230 case OutputChannels.DOWNMIX_CHANNELS:
231 first_channel = last_channel = 0;
234 case OutputChannels.RIGHT_CHANNEL:
235 first_channel = last_channel = 1;
238 case OutputChannels.BOTH_CHANNELS:
245 first_channel = last_channel = 0;
248 for (@LOC("C") int ch = 0; ch < 2; ch++)
249 for (@LOC("C") int j = 0; j < 576; j++)
250 prevblck[ch][j] = 0.0f;
252 nonzero[0] = nonzero[1] = 576;
254 br = new BitReserve();
255 si = new III_side_info_t();
264 // REVIEW: these constructor arguments should be moved to the
265 // decodeFrame() method, where possible, so that one
266 // @LATTICE("THIS<VAR,THIS<I,THIS<J,J<CH,I*,J*,CH*,THISLOC=THIS,GLOBALLOC=THIS")
267 // public LayerIIIDecoder(@LOC("VAR") Header header0, @LOC("VAR")
268 // SynthesisFilter filtera,
269 // @LOC("VAR") SynthesisFilter filterb, @LOC("VAR") int which_ch0) {
271 // huffcodetab.inithuff();
272 // is_1d = new int[SBLIMIT * SSLIMIT + 4];
273 // ro = new float[2][SBLIMIT][SSLIMIT];
274 // lr = new float[2][SBLIMIT][SSLIMIT];
275 // out_1d = new float[SBLIMIT * SSLIMIT];
276 // prevblck = new float[2][SBLIMIT * SSLIMIT];
277 // k = new float[2][SBLIMIT * SSLIMIT];
278 // nonzero = new int[2];
280 // // removes unnecessary aliases
281 // // III_scalefact_t
282 // // III_scalefac_t = new temporaire2[2];
283 // // III_scalefac_t[0] = new temporaire2();
284 // // III_scalefac_t[1] = new temporaire2();
285 // // scalefac = III_scalefac_t;
287 // scalefac = new temporaire2[2];
288 // scalefac[0] = new temporaire2();
289 // scalefac[1] = new temporaire2();
293 // sfBandIndex = new SBI[9]; // SZD: MPEG2.5 +3 indices
294 // @LOC("VAR") int[] l0 =
295 // { 0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238,
298 // @LOC("VAR") int[] s0 = { 0, 4, 8, 12, 18, 24, 32, 42, 56, 74, 100, 132,
300 // @LOC("VAR") int[] l1 =
301 // { 0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 114, 136, 162, 194, 232,
304 // @LOC("VAR") int[] s1 = { 0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 136,
306 // @LOC("VAR") int[] l2 =
307 // { 0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238,
310 // @LOC("VAR") int[] s2 = { 0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 134,
313 // @LOC("VAR") int[] l3 =
314 // { 0, 4, 8, 12, 16, 20, 24, 30, 36, 44, 52, 62, 74, 90, 110, 134, 162, 196,
317 // @LOC("VAR") int[] s3 = { 0, 4, 8, 12, 16, 22, 30, 40, 52, 66, 84, 106, 136,
319 // @LOC("VAR") int[] l4 =
320 // { 0, 4, 8, 12, 16, 20, 24, 30, 36, 42, 50, 60, 72, 88, 106, 128, 156, 190,
323 // @LOC("VAR") int[] s4 = { 0, 4, 8, 12, 16, 22, 28, 38, 50, 64, 80, 100, 126,
325 // @LOC("VAR") int[] l5 =
326 // { 0, 4, 8, 12, 16, 20, 24, 30, 36, 44, 54, 66, 82, 102, 126, 156, 194, 240,
329 // @LOC("VAR") int[] s5 = { 0, 4, 8, 12, 16, 22, 30, 42, 58, 78, 104, 138,
332 // @LOC("VAR") int[] l6 =
333 // { 0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238,
336 // @LOC("VAR") int[] s6 = { 0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 134,
338 // @LOC("VAR") int[] l7 =
339 // { 0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238,
342 // @LOC("VAR") int[] s7 = { 0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 134,
344 // @LOC("VAR") int[] l8 =
345 // { 0, 12, 24, 36, 48, 60, 72, 88, 108, 132, 160, 192, 232, 280, 336, 400,
347 // 570, 572, 574, 576 };
348 // @LOC("VAR") int[] s8 = { 0, 8, 16, 24, 36, 52, 72, 96, 124, 160, 162, 164,
351 // sfBandIndex[0] = new SBI(l0, s0);
352 // sfBandIndex[1] = new SBI(l1, s1);
353 // sfBandIndex[2] = new SBI(l2, s2);
355 // sfBandIndex[3] = new SBI(l3, s3);
356 // sfBandIndex[4] = new SBI(l4, s4);
357 // sfBandIndex[5] = new SBI(l5, s5);
359 // sfBandIndex[6] = new SBI(l6, s6);
360 // sfBandIndex[7] = new SBI(l7, s7);
361 // sfBandIndex[8] = new SBI(l8, s8);
362 // // END OF L3TABLE INIT
364 // if (reorder_table == null) { // SZD: generate LUT
365 // reorder_table = new int[9][];
366 // for (@LOC("I") int i = 0; i < 9; i++)
367 // reorder_table[i] = reorder(sfBandIndex[i].s);
371 // @LOC("VAR") int[] ll0 = { 0, 6, 11, 16, 21 };
372 // @LOC("VAR") int[] ss0 = { 0, 6, 12 };
373 // sftable = new Sftable(ll0, ss0);
376 // // scalefac_buffer
377 // scalefac_buffer = new int[54];
378 // // END OF scalefac_buffer
380 // // header = header0;
381 // filter1 = filtera;
382 // filter2 = filterb;
383 // // buffer = buffer0;
384 // which_channels = which_ch0;
387 // channels = (header.mode() == Header.SINGLE_CHANNEL) ? 1 : 2;
388 // max_gr = (header.version() == Header.MPEG1) ? 2 : 1;
391 // header.sample_frequency()
392 // + ((header.version() == Header.MPEG1) ? 3 : (header.version() ==
393 // Header.MPEG25_LSF) ? 6
396 // if (channels == 2) {
397 // switch (which_channels) {
398 // case OutputChannels.LEFT_CHANNEL:
399 // case OutputChannels.DOWNMIX_CHANNELS:
400 // first_channel = last_channel = 0;
403 // case OutputChannels.RIGHT_CHANNEL:
404 // first_channel = last_channel = 1;
407 // case OutputChannels.BOTH_CHANNELS:
409 // first_channel = 0;
414 // first_channel = last_channel = 0;
417 // for (@LOC("CH") int ch = 0; ch < 2; ch++)
418 // for (@LOC("J") int j = 0; j < 576; j++)
419 // prevblck[ch][j] = 0.0f;
421 // nonzero[0] = nonzero[1] = 576;
423 // br = new BitReserve();
424 // si = new III_side_info_t();
428 * Notify decoder that a seek is being made.
430 @LATTICE("THIS<J,J<CH,J*,CH*,THISLOC=THIS,GLOBALLOC=THIS")
431 public void seek_notify() {
433 for (@LOC("CH") int ch = 0; ch < 2; ch++)
434 for (@LOC("J") int j = 0; j < 576; j++)
435 prevblck[ch][j] = 0.0f;
436 br = new BitReserve();
439 public void decodeFrame(@LOC("IN") Header header) {
444 * Decode one frame, filling the buffer with the output samples.
447 // subband samples are buffered and passed to the
448 // SynthesisFilter in one go.
450 private float[] samples1 = new float[32];
452 private float[] samples2 = new float[32];
455 * location hierarchy of decode() {header} {stream} {si} {br, flush_main,
456 * main_data_end,frame_start,nSlots,bytes_to_discard}* {gr,max_gr} // granule
457 * {ch,channels,first_channel, last_channel, which_channels} // channel
458 * {part2_start} {sb18, ss} {out_1d}* {sb}* {samples1,sample2}
461 // @LATTICE("BYTE<THIS,THIS<MAIN,MAIN<VAR,THIS<GR,GR<VAR,BYTE*,GR*,THISLOC=THIS,GLOBALLOC=VAR")
462 @LATTICE("VAR<THIS,C<THIS,THIS<IN,THISLOC=THIS,C*,VAR*")
463 public void decode(@LOC("IN") Header header) {
469 @LOC("THIS,LayerIIIDecoder.HD1") int nSlots = header.slots();
471 @LOC("THIS,LayerIIIDecoder.CH0") int gr;
472 @LOC("THIS,LayerIIIDecoder.CH0") int ch;
474 @LOC("THIS,LayerIIIDecoder.CH0") int ss;
475 @LOC("THIS,LayerIIIDecoder.CH0") int sb;
476 @LOC("THIS,LayerIIIDecoder.CH0") int sb18;
478 @LOC("THIS,LayerIIIDecoder.BR,BitReserve.BIT") int main_data_end;
479 @LOC("THIS,LayerIIIDecoder.BR,BitReserve.BIT") int flush_main;
481 @LOC("THIS,LayerIIIDecoder.BR,BitReserve.BIT") int bytes_to_discard;
484 // modifications for linear type
485 get_side_info(header);
486 br = header.getBitReserve();
488 // here 'gr' and 'max_gr' should be higher than 'ch','channels', and more
489 for (gr = 0; gr < max_gr; gr++) { // two granules per channel
490 // in the loop body, access set={part2_start}
492 // 'ch', 'channels' should be higher than all locs in the below body
493 for (ch = 0; ch < channels; ch++) {
494 part2_start = br.hsstell();
496 // grab scale factors from the main data.
497 // following the scale factors is the actual compressed data
498 if (header.version() == Header.MPEG1)
499 get_scale_factors(header, ch, gr); // no need to care from this side
500 // here move scale factor data from 'br' buffer to 'scalefac' field
502 // MPEG-2 LSF, SZD: MPEG-2.5 LSF
503 get_LSF_scale_factors(header, ch, gr); // no need to care from this
506 // here, decoding the compressed audio data
507 huffman_decode(ch, gr); // no need to care from this side
508 // System.out.println("CheckSum HuffMan = " + CheckSumHuff);
509 dequantize_sample(/* ro[ch], */ch, gr); // no need to care from this
513 stereo(header, gr); // no need to care from this side
515 if ((which_channels == OutputChannels.DOWNMIX_CHANNELS) && (channels > 1)) {
519 for (ch = first_channel; ch <= last_channel; ch++) { // 'ch' and
524 // read set= lr,ch,gr,out_1d, sb18, ss, SSLIMIT, out_1d
527 reorder(/* lr[ch], */ch, gr);
530 // float CheckSumOut1d=0;
531 // for (int hb = 0;hb<576;hb++) {
532 // CheckSumOut1d = CheckSumOut1d + out_1d[hb];
534 // System.out.println("CheckSumOut1d = "+CheckSumOut1d);
538 // float CheckSumOut1d=0;
539 // for (int hb = 0;hb<576;hb++) {
540 // CheckSumOut1d = CheckSumOut1d + out_1d[hb];
542 // System.out.println("CheckSumOut1d = "+CheckSumOut1d);
544 for (sb18 = 18; sb18 < 576; sb18 += 36) {
545 // sb18 > ss, SSLIMIT, out1d
546 // Frequency inversion
547 for (ss = 1; ss < SSLIMIT; ss += 2) {
548 // 'ss','SSLIMIT' > out_1d
549 out_1d[sb18 + ss] = -out_1d[sb18 + ss]; // out1d*
553 // 'ch', 'which_channels' should be higher than if/else body!
554 // location set written by if/else body
555 // = {samples1, samples2, filter1, filter2}
556 if ((ch == 0) || (which_channels == OutputChannels.RIGHT_CHANNEL)) {
557 for (ss = 0; ss < SSLIMIT; ss++) { // Polyphase synthesis
559 for (sb18 = 0; sb18 < 576; sb18 += 18) {
560 samples1[sb] = out_1d[sb18 + ss]; // out_1d > samples1
561 // filter1.input_sample(out_1d[sb18+ss], sb);
562 sb++; // sb should be loc*
564 filter1.input_samples(samples1);
565 filter1.calculate_pcm_samples();
568 for (ss = 0; ss < SSLIMIT; ss++) { // Polyphase synthesis
570 for (sb18 = 0; sb18 < 576; sb18 += 18) {
571 samples2[sb] = out_1d[sb18 + ss]; // out_1d > samples2
572 // filter2.input_sample(out_1d[sb18+ss], sb);
575 filter2.input_samples(samples2);
576 filter2.calculate_pcm_samples();
583 // System.out.println("Counter = ................................."+counter);
584 // if (counter < 609)
586 counter++; // count should be loc*
587 // buffer.write_buffer(1); // buffer!!!
589 // else if (counter == 609)
601 * Reads the side info from the stream, assuming the entire. frame has been
602 * read already. Mono : 136 bits (= 17 bytes) Stereo : 256 bits (= 32 bytes)
604 @LATTICE("THIS<C,C<IN,C*,THISLOC=THIS,RETURNLOC=THIS")
605 private boolean get_side_info(@LOC("IN") Header header) {
607 @LOC("IN") SideInfoBuffer sib = header.getSideInfoBuffer();
611 // System.out.println("#get_side_info");
612 if (header.version() == Header.MPEG1) {
614 si.main_data_begin = sib.get_bits(9);
616 si.private_bits = sib.get_bits(5);
618 si.private_bits = sib.get_bits(3);
620 for (ch = 0; ch < channels; ch++) {
621 si.ch[ch].scfsi[0] = sib.get_bits(1);
622 si.ch[ch].scfsi[1] = sib.get_bits(1);
623 si.ch[ch].scfsi[2] = sib.get_bits(1);
624 si.ch[ch].scfsi[3] = sib.get_bits(1);
627 // System.out.println("BEFORE GR,CH");
629 for (gr = 0; gr < 2; gr++) {
630 // System.out.println("GR=" + gr);
631 for (ch = 0; ch < channels; ch++) {
632 // System.out.println("CH");
633 si.ch[ch].gr[gr].part2_3_length = sib.get_bits(12);
634 si.ch[ch].gr[gr].big_values = sib.get_bits(9);
635 si.ch[ch].gr[gr].global_gain = sib.get_bits(8);
636 si.ch[ch].gr[gr].scalefac_compress = sib.get_bits(4);
637 si.ch[ch].gr[gr].window_switching_flag = sib.get_bits(1);
638 if ((si.ch[ch].gr[gr].window_switching_flag) != 0) {
639 si.ch[ch].gr[gr].block_type = sib.get_bits(2);
640 si.ch[ch].gr[gr].mixed_block_flag = sib.get_bits(1);
642 si.ch[ch].gr[gr].table_select[0] = sib.get_bits(5);
643 si.ch[ch].gr[gr].table_select[1] = sib.get_bits(5);
645 si.ch[ch].gr[gr].subblock_gain[0] = sib.get_bits(3);
646 si.ch[ch].gr[gr].subblock_gain[1] = sib.get_bits(3);
647 si.ch[ch].gr[gr].subblock_gain[2] = sib.get_bits(3);
649 // Set region_count parameters since they are implicit
652 if (si.ch[ch].gr[gr].block_type == 0) {
653 // Side info bad: block_type == 0 in split block
655 } else if (si.ch[ch].gr[gr].block_type == 2 && si.ch[ch].gr[gr].mixed_block_flag == 0) {
656 si.ch[ch].gr[gr].region0_count = 8;
658 si.ch[ch].gr[gr].region0_count = 7;
660 si.ch[ch].gr[gr].region1_count = 20 - si.ch[ch].gr[gr].region0_count;
662 si.ch[ch].gr[gr].table_select[0] = sib.get_bits(5);
663 si.ch[ch].gr[gr].table_select[1] = sib.get_bits(5);
664 si.ch[ch].gr[gr].table_select[2] = sib.get_bits(5);
665 si.ch[ch].gr[gr].region0_count = sib.get_bits(4);
666 si.ch[ch].gr[gr].region1_count = sib.get_bits(3);
667 si.ch[ch].gr[gr].block_type = 0;
669 si.ch[ch].gr[gr].preflag = sib.get_bits(1);
670 si.ch[ch].gr[gr].scalefac_scale = sib.get_bits(1);
671 si.ch[ch].gr[gr].count1table_select = sib.get_bits(1);
675 } else { // MPEG-2 LSF, SZD: MPEG-2.5 LSF
677 si.main_data_begin = sib.get_bits(8);
679 si.private_bits = sib.get_bits(1);
681 si.private_bits = sib.get_bits(2);
683 for (ch = 0; ch < channels; ch++) {
685 si.ch[ch].gr[0].part2_3_length = sib.get_bits(12);
686 si.ch[ch].gr[0].big_values = sib.get_bits(9);
687 si.ch[ch].gr[0].global_gain = sib.get_bits(8);
688 si.ch[ch].gr[0].scalefac_compress = sib.get_bits(9);
689 si.ch[ch].gr[0].window_switching_flag = sib.get_bits(1);
691 if ((si.ch[ch].gr[0].window_switching_flag) != 0) {
693 si.ch[ch].gr[0].block_type = sib.get_bits(2);
694 si.ch[ch].gr[0].mixed_block_flag = sib.get_bits(1);
695 si.ch[ch].gr[0].table_select[0] = sib.get_bits(5);
696 si.ch[ch].gr[0].table_select[1] = sib.get_bits(5);
698 si.ch[ch].gr[0].subblock_gain[0] = sib.get_bits(3);
699 si.ch[ch].gr[0].subblock_gain[1] = sib.get_bits(3);
700 si.ch[ch].gr[0].subblock_gain[2] = sib.get_bits(3);
702 // Set region_count parameters since they are implicit in
705 if (si.ch[ch].gr[0].block_type == 0) {
706 // Side info bad: block_type == 0 in split block
708 } else if (si.ch[ch].gr[0].block_type == 2 && si.ch[ch].gr[0].mixed_block_flag == 0) {
709 si.ch[ch].gr[0].region0_count = 8;
711 si.ch[ch].gr[0].region0_count = 7;
712 si.ch[ch].gr[0].region1_count = 20 - si.ch[ch].gr[0].region0_count;
716 si.ch[ch].gr[0].table_select[0] = sib.get_bits(5);
717 si.ch[ch].gr[0].table_select[1] = sib.get_bits(5);
718 si.ch[ch].gr[0].table_select[2] = sib.get_bits(5);
719 si.ch[ch].gr[0].region0_count = sib.get_bits(4);
720 si.ch[ch].gr[0].region1_count = sib.get_bits(3);
721 si.ch[ch].gr[0].block_type = 0;
724 si.ch[ch].gr[0].scalefac_scale = sib.get_bits(1);
725 si.ch[ch].gr[0].count1table_select = sib.get_bits(1);
726 } // for(ch=0; ch<channels; ch++)
727 } // if (header.version() == MPEG1)
734 @LATTICE("THIS<IN,THISLOC=THIS,GLOBALLOC=IN")
735 private void get_scale_factors(@LOC("IN") Header header, @LOC("THIS,LayerIIIDecoder.CH0") int ch,
736 @LOC("THIS,LayerIIIDecoder.CH0") int gr) {
738 // gr_info_s gr_info = (si.ch[ch].gr[gr]); remove alias
740 @LOC("THIS,LayerIIIDecoder.NS") int sfb;
741 @LOC("THIS,LayerIIIDecoder.NS") int window;
742 @LOC("THIS,LayerIIIDecoder.NS") int scale_comp = si.ch[ch].gr[gr].scalefac_compress;
743 @LOC("THIS,LayerIIIDecoder.NS") int length0 = slen[0][scale_comp];
744 @LOC("THIS,LayerIIIDecoder.NS") int length1 = slen[1][scale_comp];
746 if ((si.ch[ch].gr[gr].window_switching_flag != 0) && (si.ch[ch].gr[gr].block_type == 2)) {
747 if ((si.ch[ch].gr[gr].mixed_block_flag) != 0) { // MIXED
748 for (sfb = 0; sfb < 8; sfb++)
749 scalefac[ch].l[sfb] = br.hgetbits(slen[0][si.ch[ch].gr[gr].scalefac_compress]);
750 for (sfb = 3; sfb < 6; sfb++)
751 for (window = 0; window < 3; window++)
752 scalefac[ch].s[window][sfb] = br.hgetbits(slen[0][si.ch[ch].gr[gr].scalefac_compress]);
753 for (sfb = 6; sfb < 12; sfb++)
754 for (window = 0; window < 3; window++)
755 scalefac[ch].s[window][sfb] = br.hgetbits(slen[1][si.ch[ch].gr[gr].scalefac_compress]);
756 for (sfb = 12, window = 0; window < 3; window++)
757 scalefac[ch].s[window][sfb] = 0;
761 scalefac[ch].s[0][0] = br.hgetbits(length0);
762 scalefac[ch].s[1][0] = br.hgetbits(length0);
763 scalefac[ch].s[2][0] = br.hgetbits(length0);
764 scalefac[ch].s[0][1] = br.hgetbits(length0);
765 scalefac[ch].s[1][1] = br.hgetbits(length0);
766 scalefac[ch].s[2][1] = br.hgetbits(length0);
767 scalefac[ch].s[0][2] = br.hgetbits(length0);
768 scalefac[ch].s[1][2] = br.hgetbits(length0);
769 scalefac[ch].s[2][2] = br.hgetbits(length0);
770 scalefac[ch].s[0][3] = br.hgetbits(length0);
771 scalefac[ch].s[1][3] = br.hgetbits(length0);
772 scalefac[ch].s[2][3] = br.hgetbits(length0);
773 scalefac[ch].s[0][4] = br.hgetbits(length0);
774 scalefac[ch].s[1][4] = br.hgetbits(length0);
775 scalefac[ch].s[2][4] = br.hgetbits(length0);
776 scalefac[ch].s[0][5] = br.hgetbits(length0);
777 scalefac[ch].s[1][5] = br.hgetbits(length0);
778 scalefac[ch].s[2][5] = br.hgetbits(length0);
779 scalefac[ch].s[0][6] = br.hgetbits(length1);
780 scalefac[ch].s[1][6] = br.hgetbits(length1);
781 scalefac[ch].s[2][6] = br.hgetbits(length1);
782 scalefac[ch].s[0][7] = br.hgetbits(length1);
783 scalefac[ch].s[1][7] = br.hgetbits(length1);
784 scalefac[ch].s[2][7] = br.hgetbits(length1);
785 scalefac[ch].s[0][8] = br.hgetbits(length1);
786 scalefac[ch].s[1][8] = br.hgetbits(length1);
787 scalefac[ch].s[2][8] = br.hgetbits(length1);
788 scalefac[ch].s[0][9] = br.hgetbits(length1);
789 scalefac[ch].s[1][9] = br.hgetbits(length1);
790 scalefac[ch].s[2][9] = br.hgetbits(length1);
791 scalefac[ch].s[0][10] = br.hgetbits(length1);
792 scalefac[ch].s[1][10] = br.hgetbits(length1);
793 scalefac[ch].s[2][10] = br.hgetbits(length1);
794 scalefac[ch].s[0][11] = br.hgetbits(length1);
795 scalefac[ch].s[1][11] = br.hgetbits(length1);
796 scalefac[ch].s[2][11] = br.hgetbits(length1);
797 scalefac[ch].s[0][12] = 0;
798 scalefac[ch].s[1][12] = 0;
799 scalefac[ch].s[2][12] = 0;
802 } else { // LONG types 0,1,3
804 if ((si.ch[ch].scfsi[0] == 0) || (gr == 0)) {
805 scalefac[ch].l[0] = br.hgetbits(length0);
806 scalefac[ch].l[1] = br.hgetbits(length0);
807 scalefac[ch].l[2] = br.hgetbits(length0);
808 scalefac[ch].l[3] = br.hgetbits(length0);
809 scalefac[ch].l[4] = br.hgetbits(length0);
810 scalefac[ch].l[5] = br.hgetbits(length0);
812 if ((si.ch[ch].scfsi[1] == 0) || (gr == 0)) {
813 scalefac[ch].l[6] = br.hgetbits(length0);
814 scalefac[ch].l[7] = br.hgetbits(length0);
815 scalefac[ch].l[8] = br.hgetbits(length0);
816 scalefac[ch].l[9] = br.hgetbits(length0);
817 scalefac[ch].l[10] = br.hgetbits(length0);
819 if ((si.ch[ch].scfsi[2] == 0) || (gr == 0)) {
820 scalefac[ch].l[11] = br.hgetbits(length1);
821 scalefac[ch].l[12] = br.hgetbits(length1);
822 scalefac[ch].l[13] = br.hgetbits(length1);
823 scalefac[ch].l[14] = br.hgetbits(length1);
824 scalefac[ch].l[15] = br.hgetbits(length1);
826 if ((si.ch[ch].scfsi[3] == 0) || (gr == 0)) {
827 scalefac[ch].l[16] = br.hgetbits(length1);
828 scalefac[ch].l[17] = br.hgetbits(length1);
829 scalefac[ch].l[18] = br.hgetbits(length1);
830 scalefac[ch].l[19] = br.hgetbits(length1);
831 scalefac[ch].l[20] = br.hgetbits(length1);
834 scalefac[ch].l[21] = 0;
835 scalefac[ch].l[22] = 0;
842 // MDM: new_slen is fully initialized before use, no need
843 // to reallocate array.
845 private final int[] new_slen = new int[4];
848 @LATTICE("M<THIS,THIS<IN,THIS<C,C*,M*,THISLOC=THIS,GLOBALLOC=THIS")
849 private void get_LSF_scale_data(@LOC("IN") Header header,
850 @LOC("THIS,LayerIIIDecoder.CH0") int ch, @LOC("THIS,LayerIIIDecoder.CH0") int gr) {
852 @LOC("THIS,LayerIIIDecoder.HD1") int mode_ext = header.mode_extension();
853 // @LOC("THIS,LayerIIIDecoder.GLSFD1") gr_info_s gr_info =
854 // (si.ch[ch].gr[gr]); // remove alias
856 @LOC("THIS,LayerIIIDecoder.SI,LayerIIIDecoder$III_side_info_t.CH,LayerIIIDecoder$temporaire.GR,LayerIIIDecoder$gr_info_s.V") int scalefac_comp =
857 si.ch[ch].gr[gr].scalefac_compress;
858 @LOC("THIS,LayerIIIDecoder.SI") int blocktypenumber;
860 @LOC("THIS,LayerIIIDecoder.SI,LayerIIIDecoder$III_side_info_t.CH,LayerIIIDecoder$temporaire.GR,LayerIIIDecoder$gr_info_s.V") int int_scalefac_comp;
861 @LOC("THIS,LayerIIIDecoder.SFB_SH") int m;
862 @LOC("THIS,LayerIIIDecoder.SI,LayerIIIDecoder$III_side_info_t.CH,LayerIIIDecoder$temporaire.GR,LayerIIIDecoder$gr_info_s.V") int blocknumber =
865 if (si.ch[ch].gr[gr].block_type == 2) {
866 if (si.ch[ch].gr[gr].mixed_block_flag == 0) {
868 } else if (si.ch[ch].gr[gr].mixed_block_flag == 1) {
877 if (!(((mode_ext == 1) || (mode_ext == 3)) && (ch == 1))) {
879 if (scalefac_comp < 400) {
881 new_slen[0] = (scalefac_comp >>> 4) / 5;
882 new_slen[1] = (scalefac_comp >>> 4) % 5;
883 new_slen[2] = (scalefac_comp & 0xF) >>> 2;
884 new_slen[3] = (scalefac_comp & 3);
885 si.ch[ch].gr[gr].preflag = 0;
888 } else if (scalefac_comp < 500) {
890 new_slen[0] = ((scalefac_comp - 400) >>> 2) / 5;
891 new_slen[1] = ((scalefac_comp - 400) >>> 2) % 5;
892 new_slen[2] = (scalefac_comp - 400) & 3;
894 si.ch[ch].gr[gr].preflag = 0;
897 } else if (scalefac_comp < 512) {
899 new_slen[0] = (scalefac_comp - 500) / 3;
900 new_slen[1] = (scalefac_comp - 500) % 3;
903 si.ch[ch].gr[gr].preflag = 1;
908 if ((((mode_ext == 1) || (mode_ext == 3)) && (ch == 1))) {
909 int_scalefac_comp = scalefac_comp >>> 1;
911 if (int_scalefac_comp < 180) {
912 new_slen[0] = int_scalefac_comp / 36;
913 new_slen[1] = (int_scalefac_comp % 36) / 6;
914 new_slen[2] = (int_scalefac_comp % 36) % 6;
916 si.ch[ch].gr[gr].preflag = 0;
918 } else if (int_scalefac_comp < 244) {
919 new_slen[0] = ((int_scalefac_comp - 180) & 0x3F) >>> 4;
920 new_slen[1] = ((int_scalefac_comp - 180) & 0xF) >>> 2;
921 new_slen[2] = (int_scalefac_comp - 180) & 3;
923 si.ch[ch].gr[gr].preflag = 0;
925 } else if (int_scalefac_comp < 255) {
926 new_slen[0] = (int_scalefac_comp - 244) / 3;
927 new_slen[1] = (int_scalefac_comp - 244) % 3;
930 si.ch[ch].gr[gr].preflag = 0;
935 for (@LOC("C") int x = 0; x < 45; x++)
937 scalefac_buffer[x] = 0;
940 for (@LOC("C") int i = 0; i < 4; i++) {
941 for (@LOC("THIS,LayerIIIDecoder.NS") int j = 0; j < nr_of_sfb_block[blocknumber][blocktypenumber][i]; j++) {
942 scalefac_buffer[m] = (new_slen[i] == 0) ? 0 : br.hgetbits(new_slen[i]);
945 } // for (unint32 j ...
946 } // for (uint32 i ...
952 @LATTICE("THIS<IN,THISLOC=THIS,GLOBALLOC=IN")
953 private void get_LSF_scale_factors(@LOC("IN") Header header,
954 @LOC("THIS,LayerIIIDecoder.CH0") int ch, @LOC("THIS,LayerIIIDecoder.CH0") int gr) {
956 @LOC("THIS,LayerIIIDecoder.SFB_SH") int sfb;
957 @LOC("THIS,LayerIIIDecoder.SFB_SH") int m = 0;
958 @LOC("THIS,LayerIIIDecoder.SFB_SH") int window;
959 // gr_info_s gr_info = (si.ch[ch].gr[gr]); // remove alias
961 get_LSF_scale_data(header, ch, gr);
963 if ((si.ch[ch].gr[gr].window_switching_flag != 0) && (si.ch[ch].gr[gr].block_type == 2)) {
964 if (si.ch[ch].gr[gr].mixed_block_flag != 0) { // MIXED
965 for (sfb = 0; sfb < 8; sfb++) {
966 scalefac[ch].l[sfb] = scalefac_buffer[m];
969 for (sfb = 3; sfb < 12; sfb++) {
970 for (window = 0; window < 3; window++) {
971 scalefac[ch].s[window][sfb] = scalefac_buffer[m];
975 for (window = 0; window < 3; window++)
976 scalefac[ch].s[window][12] = 0;
980 for (sfb = 0; sfb < 12; sfb++) {
981 for (window = 0; window < 3; window++) {
982 scalefac[ch].s[window][sfb] = scalefac_buffer[m];
987 for (window = 0; window < 3; window++)
988 scalefac[ch].s[window][12] = 0;
990 } else { // LONG types 0,1,3
992 for (sfb = 0; sfb < 21; sfb++) {
993 scalefac[ch].l[sfb] = scalefac_buffer[m];
996 scalefac[ch].l[21] = 0; // Jeff
997 scalefac[ch].l[22] = 0;
1021 private void huffman_decode(@LOC("THIS,LayerIIIDecoder.CH0") int ch,
1022 @LOC("THIS,LayerIIIDecoder.CH0") int gr) {
1028 @LOC("THIS,LayerIIIDecoder.BR,BitReserve.BIT") int part2_3_end =
1029 part2_start + si.ch[ch].gr[gr].part2_3_length;
1030 @LOC("THIS,LayerIIIDecoder.BR,BitReserve.BIT") int num_bits;
1031 @LOC("THIS,LayerIIIDecoder.SI1") int region1Start;
1032 @LOC("THIS,LayerIIIDecoder.SI1") int region2Start;
1033 @LOC("THIS,LayerIIIDecoder.BR,BitReserve.BIT") int index;
1035 @LOC("THIS,LayerIIIDecoder.SI1") int buf;
1036 @LOC("THIS,LayerIIIDecoder.SI1") int buf1;
1038 // Find region boundary for short block case
1040 if (((si.ch[ch].gr[gr].window_switching_flag) != 0) && (si.ch[ch].gr[gr].block_type == 2)) {
1043 // MS: Extrahandling for 8KHZ
1044 region1Start = (sfreq == 8) ? 72 : 36; // sfb[9/3]*3=36 or in case
1046 region2Start = 576; // No Region2 for short block case
1048 } else { // Find region boundary for long block case
1050 buf = si.ch[ch].gr[gr].region0_count + 1;
1051 buf1 = buf + si.ch[ch].gr[gr].region1_count + 1;
1053 if (buf1 > sfBandIndex[sfreq].l.length - 1)
1054 buf1 = sfBandIndex[sfreq].l.length - 1;
1056 region1Start = sfBandIndex[sfreq].l[buf];
1057 region2Start = sfBandIndex[sfreq].l[buf1]; /* MI */
1061 // Read bigvalues area
1062 for (@LOC("THIS,LayerIIIDecoder.BR,BitReserve.BIT") int i = 0; i < (si.ch[ch].gr[gr].big_values << 1); i +=
1065 @LOC("THIS,LayerIIIDecoder.BR,BitReserve.BIT") int htIdx;
1066 if (i < region1Start) {
1067 htIdx = si.ch[ch].gr[gr].table_select[0];
1068 // h = huffcodetab.ht[si.ch[ch].gr[gr].table_select[0]];
1069 } else if (i < region2Start) {
1070 htIdx = si.ch[ch].gr[gr].table_select[1];
1071 // h = huffcodetab.ht[si.ch[ch].gr[gr].table_select[1]];
1073 htIdx = si.ch[ch].gr[gr].table_select[2];
1074 // h = huffcodetab.ht[si.ch[ch].gr[gr].table_select[2]];
1077 huffcodetab.huffman_decoder(htIdx, x, y, v, w, br);
1078 // if (index >= is_1d.length)
1079 // System.out.println("i0="+i+"/"+(si.ch[ch].gr[gr].big_values<<1)+" Index="+index+" is_1d="+is_1d.length);
1081 is_1d[index++] = x[0];
1082 is_1d[index++] = y[0];
1084 CheckSumHuff = CheckSumHuff + x[0] + y[0];
1085 // System.out.println("x = " + x[0] + " y = " + y[0]);
1090 @LOC("THIS,LayerIIIDecoder.BR,BitReserve.BIT") int htIdx = si.ch[ch].gr[gr].count1table_select + 32;
1091 // h = huffcodetab.ht[si.ch[ch].gr[gr].count1table_select + 32];
1092 num_bits = br.hsstell();
1094 while ((num_bits < part2_3_end) && (index < 576)) {
1096 huffcodetab.huffman_decoder(htIdx, x, y, v, w, br);
1098 is_1d[index++] = v[0];
1099 is_1d[index++] = w[0];
1100 is_1d[index++] = x[0];
1101 is_1d[index++] = y[0];
1102 CheckSumHuff = CheckSumHuff + v[0] + w[0] + x[0] + y[0];
1103 // System.out.println("v = "+v[0]+" w = "+w[0]);
1104 // System.out.println("x = "+x[0]+" y = "+y[0]);
1105 num_bits = br.hsstell();
1108 if (num_bits > part2_3_end) {
1109 br.rewindNbits(num_bits - part2_3_end);
1113 num_bits = br.hsstell();
1115 // Dismiss stuffing bits
1116 if (num_bits < part2_3_end)
1117 br.hgetbits(part2_3_end - num_bits);
1122 nonzero[ch] = index;
1129 // may not be necessary
1130 for (; index < 576; index++)
1134 @LATTICE("THIS,IN,THISLOC=THIS,RETURNLOC=THIS")
1135 private int huffcodetab_huffman_decoder(@LOC("IN") int h) {
1136 // TODO need to move huffmancodetab implementation here
1143 private void i_stereo_k_values(@LOC("THIS,LayerIIIDecoder.LR") int is_pos,
1144 @LOC("THIS,LayerIIIDecoder.LR") int io_type, @LOC("THIS,LayerIIIDecoder.LR") int i) {
1148 } else if ((is_pos & 1) != 0) {
1149 k[0][i] = io[io_type][(is_pos + 1) >>> 1];
1153 k[1][i] = io[io_type][is_pos >>> 1];
1160 // @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")
1161 @LATTICE("THIS,THISLOC=THIS,GLOBALLOC=THIS")
1163 private void dequantize_sample(
1164 /* @LOC("OUT") float xr[][], */@LOC("THIS,LayerIIIDecoder.SI") int ch,
1165 @LOC("THIS,LayerIIIDecoder.SI") int gr) {
1167 // @LOC("GR") gr_info_s gr_info = (si.ch[ch].gr[gr]); remove alias!
1168 @LOC("THIS,LayerIIIDecoder.SI1") int cb = 0;
1170 @LOC("THIS,LayerIIIDecoder.SI1") int next_cb_boundary;
1171 @LOC("THIS,LayerIIIDecoder.SI1") int cb_begin = 0;
1172 @LOC("THIS,LayerIIIDecoder.SI1") int cb_width = 0;
1173 @LOC("THIS,LayerIIIDecoder.SI1") float g_gain;
1175 @LOC("THIS,LayerIIIDecoder.SI1") int index = 0;
1176 @LOC("THIS,LayerIIIDecoder.SI1") int t_index;
1177 @LOC("THIS,LayerIIIDecoder.NZ") int j;
1179 // float[][] xr_1d = xr;//substituted xr for instances of xr_1d to decrease
1182 // choose correct scalefactor band per block type, initalize boundary
1184 if ((si.ch[ch].gr[gr].window_switching_flag != 0) && (si.ch[ch].gr[gr].block_type == 2)) {
1185 if (si.ch[ch].gr[gr].mixed_block_flag != 0)
1186 next_cb_boundary = sfBandIndex[sfreq].l[1]; // LONG blocks: 0,1,3
1188 cb_width = sfBandIndex[sfreq].s[1];
1189 next_cb_boundary = (cb_width << 2) - cb_width;
1193 next_cb_boundary = sfBandIndex[sfreq].l[1]; // LONG blocks: 0,1,3
1196 // Compute overall (global) scaling.
1198 g_gain = (float) Math.pow(2.0, (0.25 * (si.ch[ch].gr[gr].global_gain - 210.0)));
1200 for (j = 0; j < nonzero[ch]; j++) {
1201 // Modif E.B 02/22/99
1202 @LOC("THIS,LayerIIIDecoder.NZ") int reste = j % SSLIMIT;
1203 @LOC("THIS,LayerIIIDecoder.NZ") int quotien = (int) ((j - reste) / SSLIMIT);
1204 if (is_1d[j] == 0) {
1205 ro[ch][quotien][reste] = 0.0f;
1207 @LOC("THIS,LayerIIIDecoder.IS1D") int abv = is_1d[j];
1208 // Pow Array fix (11/17/04)
1209 if (abv < t_43.length) {
1211 ro[ch][quotien][reste] = g_gain * t_43[abv];
1213 if (-abv < t_43.length)
1214 ro[ch][quotien][reste] = -g_gain * t_43[-abv];
1216 ro[ch][quotien][reste] = -g_gain * (float) Math.pow(-abv, d43);
1220 ro[ch][quotien][reste] = g_gain * (float) Math.pow(abv, d43);
1222 ro[ch][quotien][reste] = -g_gain * (float) Math.pow(-abv, d43);
1227 // apply formula per block type
1228 for (j = 0; j < nonzero[ch]; j++) {
1229 // Modif E.B 02/22/99
1230 @LOC("THIS,LayerIIIDecoder.NZ") int reste = j % SSLIMIT;
1231 @LOC("THIS,LayerIIIDecoder.NZ") int quotien = (int) ((j - reste) / SSLIMIT);
1233 if (index == next_cb_boundary) { /* Adjust critical band boundary */
1234 if ((si.ch[ch].gr[gr].window_switching_flag != 0) && (si.ch[ch].gr[gr].block_type == 2)) {
1235 if (si.ch[ch].gr[gr].mixed_block_flag != 0) {
1237 if (index == sfBandIndex[sfreq].l[8]) {
1238 next_cb_boundary = sfBandIndex[sfreq].s[4];
1239 next_cb_boundary = (next_cb_boundary << 2) - next_cb_boundary;
1241 cb_width = sfBandIndex[sfreq].s[4] - sfBandIndex[sfreq].s[3];
1243 cb_begin = sfBandIndex[sfreq].s[3];
1244 cb_begin = (cb_begin << 2) - cb_begin;
1246 } else if (index < sfBandIndex[sfreq].l[8]) {
1248 next_cb_boundary = sfBandIndex[sfreq].l[(++cb) + 1];
1252 next_cb_boundary = sfBandIndex[sfreq].s[(++cb) + 1];
1253 next_cb_boundary = (next_cb_boundary << 2) - next_cb_boundary;
1255 cb_begin = sfBandIndex[sfreq].s[cb];
1256 cb_width = sfBandIndex[sfreq].s[cb + 1] - cb_begin;
1257 cb_begin = (cb_begin << 2) - cb_begin;
1262 next_cb_boundary = sfBandIndex[sfreq].s[(++cb) + 1];
1263 next_cb_boundary = (next_cb_boundary << 2) - next_cb_boundary;
1265 cb_begin = sfBandIndex[sfreq].s[cb];
1266 cb_width = sfBandIndex[sfreq].s[cb + 1] - cb_begin;
1267 cb_begin = (cb_begin << 2) - cb_begin;
1270 } else { // long blocks
1272 next_cb_boundary = sfBandIndex[sfreq].l[(++cb) + 1];
1277 // Do long/short dependent scaling operations
1279 if ((si.ch[ch].gr[gr].window_switching_flag != 0)
1280 && (((si.ch[ch].gr[gr].block_type == 2) && (si.ch[ch].gr[gr].mixed_block_flag == 0)) || ((si.ch[ch].gr[gr].block_type == 2)
1281 && (si.ch[ch].gr[gr].mixed_block_flag != 0) && (j >= 36)))) {
1283 t_index = (index - cb_begin) / cb_width;
1285 * xr[sb][ss] *= pow(2.0, ((-2.0 * gr_info.subblock_gain[t_index]) -(0.5
1286 * * (1.0 + gr_info.scalefac_scale) scalefac[ch].s[t_index][cb])));
1288 @LOC("THIS,LayerIIIDecoder.SI1") int idx =
1289 scalefac[ch].s[t_index][cb] << si.ch[ch].gr[gr].scalefac_scale;
1290 idx += (si.ch[ch].gr[gr].subblock_gain[t_index] << 2);
1292 ro[ch][quotien][reste] *= two_to_negative_half_pow[idx];
1294 } else { // LONG block types 0,1,3 & 1st 2 subbands of switched blocks
1296 * xr[sb][ss] *= pow(2.0, -0.5 * (1.0+gr_info.scalefac_scale)
1297 * (scalefac[ch].l[cb] + gr_info.preflag * pretab[cb]));
1299 @LOC("THIS,LayerIIIDecoder.SI1") int idx = scalefac[ch].l[cb];
1301 if (si.ch[ch].gr[gr].preflag != 0)
1304 idx = idx << si.ch[ch].gr[gr].scalefac_scale;
1305 ro[ch][quotien][reste] *= two_to_negative_half_pow[idx];
1310 for (j = nonzero[ch]; j < 576; j++) {
1311 // Modif E.B 02/22/99
1312 @LOC("THIS,LayerIIIDecoder.NZ") int reste = j % SSLIMIT;
1313 @LOC("THIS,LayerIIIDecoder.NZ") int quotien = (int) ((j - reste) / SSLIMIT);
1318 ro[ch][quotien][reste] = 0.0f;
1328 // @LATTICE("THIS<I,I<GR,GR<IN,I*,THISLOC=THIS,GLOBALLOC=IN")
1329 @LATTICE("THIS,THISLOC=THIS,GLOBALLOC=THIS")
1330 private void reorder(/* @LOC("IN") float xr[][], */@LOC("THIS,LayerIIIDecoder.CH0") int ch,
1331 @LOC("THIS,LayerIIIDecoder.CH0") int gr) {
1332 // the purpose of reordering: move 'short samples' back to their original
1334 // after reorder, the samples are no long ordered by frequency
1336 // the format of input data to reorder:
1337 // three small chunks of 192 samples each are combined to 576 samples
1338 // ordered by frequency
1340 // gr_info_s gr_info = (si.ch[ch].gr[gr]); //remove alias
1342 @LOC("THIS,LayerIIIDecoder.SI1") int index;
1344 @LOC("THIS,LayerIIIDecoder.SI1") int freq;
1345 @LOC("THIS,LayerIIIDecoder.SI1") int freq3;
1346 @LOC("THIS,LayerIIIDecoder.SI1") int sfb;
1347 @LOC("THIS,LayerIIIDecoder.SI1") int sfb_start;
1348 @LOC("THIS,LayerIIIDecoder.SI1") int sfb_lines;
1349 @LOC("THIS,LayerIIIDecoder.SI1") int src_line;
1350 @LOC("THIS,LayerIIIDecoder.SI1") int des_line;
1351 // float[][] xr_1d = xr; subbed in xr for xr_1d so as not to create extra
1354 if ((si.ch[ch].gr[gr].window_switching_flag != 0) && (si.ch[ch].gr[gr].block_type == 2)) {
1356 for (index = 0; index < 576; index++) {
1357 out_1d[index] = 0.0f;
1360 if (si.ch[ch].gr[gr].mixed_block_flag != 0) {
1361 // NO REORDER FOR LOW 2 SUBBANDS
1362 for (index = 0; index < 36; index++) {
1363 // Modif E.B 02/22/99
1364 @LOC("THIS,LayerIIIDecoder.SI1") int reste = index % SSLIMIT;
1365 @LOC("THIS,LayerIIIDecoder.SI1") int quotien = (int) ((index - reste) / SSLIMIT);
1366 out_1d[index] = lr[ch][quotien][reste];
1368 // REORDERING FOR REST SWITCHED SHORT
1370 * for( sfb=3,sfb_start=sfBandIndex[sfreq].s[3],
1371 * sfb_lines=sfBandIndex[sfreq].s[4] - sfb_start; sfb < 13;
1372 * sfb++,sfb_start = sfBandIndex[sfreq].s[sfb], sfb_lines =
1373 * sfBandIndex[sfreq].s[sfb+1] - sfb_start ) {
1375 for (sfb = 3; sfb < 13; sfb++) {
1376 // System.out.println("sfreq="+sfreq+" sfb="+sfb+" sfBandIndex="+sfBandIndex.length+" sfBandIndex[sfreq].s="+sfBandIndex[sfreq].s.length);
1377 sfb_start = sfBandIndex[sfreq].s[sfb];
1378 sfb_lines = sfBandIndex[sfreq].s[sfb + 1] - sfb_start;
1380 @LOC("THIS,LayerIIIDecoder.SI1") int sfb_start3 = (sfb_start << 2) - sfb_start;
1382 for (freq = 0, freq3 = 0; freq < sfb_lines; freq++, freq3 += 3) {
1384 src_line = sfb_start3 + freq;
1385 des_line = sfb_start3 + freq3;
1386 // Modif E.B 02/22/99
1387 @LOC("THIS,LayerIIIDecoder.SI1") int reste = src_line % SSLIMIT;
1388 @LOC("THIS,LayerIIIDecoder.SI1") int quotien = (int) ((src_line - reste) / SSLIMIT);
1390 out_1d[des_line] = lr[ch][quotien][reste];
1391 src_line += sfb_lines;
1394 reste = src_line % SSLIMIT;
1395 quotien = (int) ((src_line - reste) / SSLIMIT);
1397 out_1d[des_line] = lr[ch][quotien][reste];
1398 src_line += sfb_lines;
1401 reste = src_line % SSLIMIT;
1402 quotien = (int) ((src_line - reste) / SSLIMIT);
1404 out_1d[des_line] = lr[ch][quotien][reste];
1408 } else { // pure short
1409 for (index = 0; index < 576; index++) {
1410 @LOC("THIS,LayerIIIDecoder.SI1") int j = reorder_table[sfreq][index];
1411 @LOC("THIS,LayerIIIDecoder.SI1") int reste = j % SSLIMIT;
1412 @LOC("THIS,LayerIIIDecoder.SI1") int quotien = (int) ((j - reste) / SSLIMIT);
1413 out_1d[index] = lr[ch][quotien][reste];
1416 } else { // long blocks
1417 for (index = 0; index < 576; index++) {
1418 // Modif E.B 02/22/99
1419 @LOC("THIS,LayerIIIDecoder.SI1") int reste = index % SSLIMIT;
1420 @LOC("THIS,LayerIIIDecoder.SI1") int quotien = (int) ((index - reste) / SSLIMIT);
1421 out_1d[index] = lr[ch][quotien][reste];
1431 int[] is_pos = new int[576];
1433 float[] is_ratio = new float[576];
1436 @LATTICE("IO<THIS,THIS<IN,THISLOC=THIS,GLOBALLOC=IN")
1437 private void stereo(@LOC("IN") Header header, @LOC("THIS,LayerIIIDecoder.CH0") int gr) {
1438 @LOC("THIS,LayerIIIDecoder.RO1") int sb;
1439 @LOC("THIS,LayerIIIDecoder.RO1") int ss;
1441 if (channels == 1) { // mono , bypass xr[0][][] to lr[0][][]
1443 for (sb = 0; sb < SBLIMIT; sb++)
1444 for (ss = 0; ss < SSLIMIT; ss += 3) {
1445 lr[0][sb][ss] = ro[0][sb][ss];
1446 lr[0][sb][ss + 1] = ro[0][sb][ss + 1];
1447 lr[0][sb][ss + 2] = ro[0][sb][ss + 2];
1452 // gr_info_s gr_info = (si.ch[0].gr[gr]); remove alias
1453 @LOC("THIS,LayerIIIDecoder.HD1") int mode_ext = header.mode_extension();
1455 @LOC("THIS,LayerIIIDecoder.RO1") int sfb;
1456 @LOC("THIS,LayerIIIDecoder.RO1") int i;
1457 @LOC("THIS,LayerIIIDecoder.RO1") int lines;
1458 @LOC("THIS,LayerIIIDecoder.RO1") int temp;
1459 @LOC("THIS,LayerIIIDecoder.RO1") int temp2;
1461 @LOC("THIS,LayerIIIDecoder.CH0") boolean ms_stereo =
1462 ((header.mode() == Header.JOINT_STEREO) && ((mode_ext & 0x2) != 0));
1463 @LOC("THIS,LayerIIIDecoder.CH0") boolean i_stereo =
1464 ((header.mode() == Header.JOINT_STEREO) && ((mode_ext & 0x1) != 0));
1465 @LOC("THIS,LayerIIIDecoder.CH0") boolean lsf =
1466 ((header.version() == Header.MPEG2_LSF || header.version() == Header.MPEG25_LSF)); // SZD
1468 @LOC("THIS,LayerIIIDecoder.LR") int io_type = (si.ch[0].gr[gr].scalefac_compress & 1);
1472 for (i = 0; i < 576; i++) {
1479 if ((si.ch[0].gr[gr].window_switching_flag != 0) && (si.ch[0].gr[gr].block_type == 2)) {
1480 if (si.ch[0].gr[gr].mixed_block_flag != 0) {
1482 @LOC("THIS,LayerIIIDecoder.RO1") int max_sfb = 0;
1484 for (@LOC("THIS,LayerIIIDecoder.RO1") int j = 0; j < 3; j++) {
1485 @LOC("THIS,LayerIIIDecoder.RO1") int sfbcnt;
1487 for (sfb = 12; sfb >= 3; sfb--) {
1488 i = sfBandIndex[sfreq].s[sfb];
1489 lines = sfBandIndex[sfreq].s[sfb + 1] - i;
1490 i = (i << 2) - i + (j + 1) * lines - 1;
1493 if (ro[1][i / 18][i % 18] != 0.0f) {
1494 // MDM: in java, array access is very slow.
1495 // Is quicker to compute div and mod values.
1496 // if (ro[1][ss_div[i]][ss_mod[i]] != 0.0f) {
1505 } // while (lines > 0)
1507 } // for (sfb=12 ...
1514 temp = sfBandIndex[sfreq].s[sfb];
1515 sb = sfBandIndex[sfreq].s[sfb + 1] - temp;
1516 i = (temp << 2) - temp + j * sb;
1518 for (; sb > 0; sb--) {
1519 is_pos[i] = scalefac[1].s[j][sfb];
1522 i_stereo_k_values(is_pos[i], io_type, i);
1524 is_ratio[i] = TAN12[is_pos[i]];
1529 } // while (sfb < 12)
1530 sfb = sfBandIndex[sfreq].s[10];
1531 sb = sfBandIndex[sfreq].s[11] - sfb;
1532 sfb = (sfb << 2) - sfb + j * sb;
1533 temp = sfBandIndex[sfreq].s[11];
1534 sb = sfBandIndex[sfreq].s[12] - temp;
1535 i = (temp << 2) - temp + j * sb;
1537 for (; sb > 0; sb--) {
1538 is_pos[i] = is_pos[sfb];
1541 k[0][i] = k[0][sfb];
1542 k[1][i] = k[1][sfb];
1544 is_ratio[i] = is_ratio[sfb];
1547 } // for (; sb > 0 ...
1554 if (ro[1][i][ss] != 0.0f) {
1555 sb = (i << 4) + (i << 1) + ss;
1566 while (sfBandIndex[sfreq].l[i] <= sb)
1569 i = sfBandIndex[sfreq].l[i];
1570 for (; sfb < 8; sfb++) {
1571 sb = sfBandIndex[sfreq].l[sfb + 1] - sfBandIndex[sfreq].l[sfb];
1572 for (; sb > 0; sb--) {
1573 is_pos[i] = scalefac[1].l[sfb];
1576 i_stereo_k_values(is_pos[i], io_type, i);
1578 is_ratio[i] = TAN12[is_pos[i]];
1580 } // for (; sb>0 ...
1581 } // for (; sfb<8 ...
1583 } else { // if (gr_info.mixed_block_flag)
1584 for (@LOC("THIS,LayerIIIDecoder.RO1") int j = 0; j < 3; j++) {
1585 @LOC("THIS,LayerIIIDecoder.RO1") int sfbcnt;
1587 for (sfb = 12; sfb >= 0; sfb--) {
1588 temp = sfBandIndex[sfreq].s[sfb];
1589 lines = sfBandIndex[sfreq].s[sfb + 1] - temp;
1590 i = (temp << 2) - temp + (j + 1) * lines - 1;
1593 if (ro[1][i / 18][i % 18] != 0.0f) {
1594 // MDM: in java, array access is very slow.
1595 // Is quicker to compute div and mod values.
1596 // if (ro[1][ss_div[i]][ss_mod[i]] != 0.0f) {
1603 } // while (lines > 0) */
1605 } // for (sfb=12 ...
1608 temp = sfBandIndex[sfreq].s[sfb];
1609 sb = sfBandIndex[sfreq].s[sfb + 1] - temp;
1610 i = (temp << 2) - temp + j * sb;
1611 for (; sb > 0; sb--) {
1612 is_pos[i] = scalefac[1].s[j][sfb];
1615 i_stereo_k_values(is_pos[i], io_type, i);
1617 is_ratio[i] = TAN12[is_pos[i]];
1619 } // for (; sb>0 ...
1623 temp = sfBandIndex[sfreq].s[10];
1624 temp2 = sfBandIndex[sfreq].s[11];
1626 sfb = (temp << 2) - temp + j * sb;
1627 sb = sfBandIndex[sfreq].s[12] - temp2;
1628 i = (temp2 << 2) - temp2 + j * sb;
1630 for (; sb > 0; sb--) {
1631 is_pos[i] = is_pos[sfb];
1634 k[0][i] = k[0][sfb];
1635 k[1][i] = k[1][sfb];
1637 is_ratio[i] = is_ratio[sfb];
1640 } // for (; sb>0 ...
1643 } else { // if (gr_info.window_switching_flag ...
1648 if (ro[1][i][ss] != 0.0f) {
1649 sb = (i << 4) + (i << 1) + ss;
1660 while (sfBandIndex[sfreq].l[i] <= sb)
1664 i = sfBandIndex[sfreq].l[i];
1665 for (; sfb < 21; sfb++) {
1666 sb = sfBandIndex[sfreq].l[sfb + 1] - sfBandIndex[sfreq].l[sfb];
1667 for (; sb > 0; sb--) {
1668 is_pos[i] = scalefac[1].l[sfb];
1671 i_stereo_k_values(is_pos[i], io_type, i);
1673 is_ratio[i] = TAN12[is_pos[i]];
1677 sfb = sfBandIndex[sfreq].l[20];
1678 for (sb = 576 - sfBandIndex[sfreq].l[21]; (sb > 0) && (i < 576); sb--) {
1679 is_pos[i] = is_pos[sfb]; // error here : i >=576
1682 k[0][i] = k[0][sfb];
1683 k[1][i] = k[1][sfb];
1685 is_ratio[i] = is_ratio[sfb];
1688 } // if (gr_info.mixed_block_flag)
1689 } // if (gr_info.window_switching_flag ...
1693 for (sb = 0; sb < SBLIMIT; sb++)
1694 for (ss = 0; ss < SSLIMIT; ss++) {
1695 if (is_pos[i] == 7) {
1697 lr[0][sb][ss] = (ro[0][sb][ss] + ro[1][sb][ss]) * 0.707106781f;
1698 lr[1][sb][ss] = (ro[0][sb][ss] - ro[1][sb][ss]) * 0.707106781f;
1700 lr[0][sb][ss] = ro[0][sb][ss];
1701 lr[1][sb][ss] = ro[1][sb][ss];
1703 } else if (i_stereo) {
1706 lr[0][sb][ss] = ro[0][sb][ss] * k[0][i];
1707 lr[1][sb][ss] = ro[0][sb][ss] * k[1][i];
1709 lr[1][sb][ss] = ro[0][sb][ss] / (float) (1 + is_ratio[i]);
1710 lr[0][sb][ss] = lr[1][sb][ss] * is_ratio[i];
1714 * else { System.out.println("Error in stereo processing\n"); }
1726 // @LATTICE("THIS<SRC,SRC<SS,SS<SB18,SB18<SB18LIM,SB18LIM<GR,GR<IN,SB18*,SS*,THISLOC=THIS")
1727 @LATTICE("VAR<THIS,THIS<C,C<IN,THISLOC=THIS,C*")
1728 private void antialias(@LOC("THIS,LayerIIIDecoder.SI") int ch,
1729 @LOC("THIS,LayerIIIDecoder.SI") int gr) {
1731 @LOC("THIS,LayerIIIDecoder.SI,LayerIIIDecoder$III_side_info_t.CH,LayerIIIDecoder$temporaire.GR2") int sb18;
1732 @LOC("THIS,LayerIIIDecoder.SI1") int ss;
1733 @LOC("THIS,LayerIIIDecoder.SI,LayerIIIDecoder$III_side_info_t.CH,LayerIIIDecoder$temporaire.GR2") int sb18lim;
1735 // @LOC("THIS,LayerIIIDecoder.SI,LayerIIIDecoder$III_side_info_t.CH,LayerIIIDecoder$temporaire.GR1")
1736 // gr_info_s gr_info =
1737 // (si.ch[ch].gr[gr]);
1738 // 31 alias-reduction operations between each pair of sub-bands
1739 // with 8 butterflies between each pair
1741 if ((si.ch[ch].gr[gr].window_switching_flag != 0) && (si.ch[ch].gr[gr].block_type == 2)
1742 && !(si.ch[ch].gr[gr].mixed_block_flag != 0))
1745 if ((si.ch[ch].gr[gr].window_switching_flag != 0) && (si.ch[ch].gr[gr].mixed_block_flag != 0)
1746 && (si.ch[ch].gr[gr].block_type == 2)) {
1752 for (sb18 = 0; sb18 < sb18lim; sb18 += 18) {
1753 for (ss = 0; ss < 8; ss++) {
1754 @LOC("THIS,LayerIIIDecoder.SI1") int src_idx1 = sb18 + 17 - ss;
1755 @LOC("THIS,LayerIIIDecoder.SI1") int src_idx2 = sb18 + 18 + ss;
1756 @LOC("THIS,LayerIIIDecoder.OUT") float bu = out_1d[src_idx1];
1757 @LOC("THIS,LayerIIIDecoder.OUT") float bd = out_1d[src_idx2];
1758 out_1d[src_idx1] = (bu * cs[ss]) - (bd * ca[ss]);
1759 out_1d[src_idx2] = (bd * cs[ss]) + (bu * ca[ss]);
1768 // MDM: tsOutCopy and rawout do not need initializing, so the arrays
1771 float[] tsOutCopy = new float[18];
1773 float[] rawout = new float[36];
1775 @LATTICE("THIS<SB,SB*,THISLOC=THIS")
1776 private void hybrid(@LOC("THIS,LayerIIIDecoder.SI") int ch, @LOC("THIS,LayerIIIDecoder.SI") int gr) {
1778 @LOC("THIS,LayerIIIDecoder.SI1") int bt;
1779 @LOC("SB") int sb18;
1780 // gr_info_s gr_info = (si.ch[ch].gr[gr]); //remove alias
1781 // @LOC("THIS,LayerIIIDecoder.TS") float[] tsOut; //remove alias
1783 // float[][] prvblk;
1785 for (sb18 = 0; sb18 < 576; sb18 += 18) {
1787 ((si.ch[ch].gr[gr].window_switching_flag != 0)
1788 && (si.ch[ch].gr[gr].mixed_block_flag != 0) && (sb18 < 36)) ? 0
1789 : si.ch[ch].gr[gr].block_type;
1792 // Modif E.B 02/22/99
1793 for (@LOC("SB") int cc = 0; cc < 18; cc++)
1794 tsOutCopy[cc] = out_1d[cc + sb18];
1798 for (@LOC("SB") int cc = 0; cc < 18; cc++)
1799 out_1d[cc + sb18] = tsOutCopy[cc];
1803 // prvblk = prevblck; //eliminated unnecessary areas
1805 out_1d[0 + sb18] = rawout[0] + prevblck[ch][sb18 + 0];
1806 prevblck[ch][sb18 + 0] = rawout[18];
1807 out_1d[1 + sb18] = rawout[1] + prevblck[ch][sb18 + 1];
1808 prevblck[ch][sb18 + 1] = rawout[19];
1809 out_1d[2 + sb18] = rawout[2] + prevblck[ch][sb18 + 2];
1810 prevblck[ch][sb18 + 2] = rawout[20];
1811 out_1d[3 + sb18] = rawout[3] + prevblck[ch][sb18 + 3];
1812 prevblck[ch][sb18 + 3] = rawout[21];
1813 out_1d[4 + sb18] = rawout[4] + prevblck[ch][sb18 + 4];
1814 prevblck[ch][sb18 + 4] = rawout[22];
1815 out_1d[5 + sb18] = rawout[5] + prevblck[ch][sb18 + 5];
1816 prevblck[ch][sb18 + 5] = rawout[23];
1817 out_1d[6 + sb18] = rawout[6] + prevblck[ch][sb18 + 6];
1818 prevblck[ch][sb18 + 6] = rawout[24];
1819 out_1d[7 + sb18] = rawout[7] + prevblck[ch][sb18 + 7];
1820 prevblck[ch][sb18 + 7] = rawout[25];
1821 out_1d[8 + sb18] = rawout[8] + prevblck[ch][sb18 + 8];
1822 prevblck[ch][sb18 + 8] = rawout[26];
1823 out_1d[9 + sb18] = rawout[9] + prevblck[ch][sb18 + 9];
1824 prevblck[ch][sb18 + 9] = rawout[27];
1825 out_1d[10 + sb18] = rawout[10] + prevblck[ch][sb18 + 10];
1826 prevblck[ch][sb18 + 10] = rawout[28];
1827 out_1d[11 + sb18] = rawout[11] + prevblck[ch][sb18 + 11];
1828 prevblck[ch][sb18 + 11] = rawout[29];
1829 out_1d[12 + sb18] = rawout[12] + prevblck[ch][sb18 + 12];
1830 prevblck[ch][sb18 + 12] = rawout[30];
1831 out_1d[13 + sb18] = rawout[13] + prevblck[ch][sb18 + 13];
1832 prevblck[ch][sb18 + 13] = rawout[31];
1833 out_1d[14 + sb18] = rawout[14] + prevblck[ch][sb18 + 14];
1834 prevblck[ch][sb18 + 14] = rawout[32];
1835 out_1d[15 + sb18] = rawout[15] + prevblck[ch][sb18 + 15];
1836 prevblck[ch][sb18 + 15] = rawout[33];
1837 out_1d[16 + sb18] = rawout[16] + prevblck[ch][sb18 + 16];
1838 prevblck[ch][sb18 + 16] = rawout[34];
1839 out_1d[17 + sb18] = rawout[17] + prevblck[ch][sb18 + 17];
1840 prevblck[ch][sb18 + 17] = rawout[35];
1847 @LATTICE("THIS<SB,THIS<SS,SB<GLOBAL,SS<GLOBAL,SS*,SB*,THISLOC=THIS,GLOBALLOC=GLOBAL")
1848 private void do_downmix() {
1849 for (@LOC("SB") int sb = 0; sb < SSLIMIT; sb++) {
1850 for (@LOC("SS") int ss = 0; ss < SSLIMIT; ss += 3) {
1851 lr[0][sb][ss] = (lr[0][sb][ss] + lr[1][sb][ss]) * 0.5f;
1852 lr[0][sb][ss + 1] = (lr[0][sb][ss + 1] + lr[1][sb][ss + 1]) * 0.5f;
1853 lr[0][sb][ss + 2] = (lr[0][sb][ss + 2] + lr[1][sb][ss + 2]) * 0.5f;
1861 // @LATTICE("OUT<6I,OUT<TMPF,TMPF<EO,EO<TMP,TMP<SUM,TMP<IIP,IIP<I00,I00<SH,SUM<PP,PP<SH,SH<I,I<IN,TMPF*,SH*,I*,6I*,GLOBALLOC=IN,THISLOC=IN")
1862 // public void inv_mdct(@LOC("SH") float[] in, @LOC("OUT") float[] out,
1863 // @LOC("IN") int block_type) {//remove alias
1865 @LATTICE("THIS,THISLOC=THIS")
1866 public void inv_mdct(@LOC("THIS,LayerIIIDecoder.OUT") int block_type) {
1868 @LOC("THIS,LayerIIIDecoder.OUT") int i;
1870 @LOC("THIS,LayerIIIDecoder.OUT") float tmpf_0;
1871 @LOC("THIS,LayerIIIDecoder.OUT") float tmpf_1;
1872 @LOC("THIS,LayerIIIDecoder.OUT") float tmpf_2;
1873 @LOC("THIS,LayerIIIDecoder.OUT") float tmpf_3;
1874 @LOC("THIS,LayerIIIDecoder.OUT") float tmpf_4;
1875 @LOC("THIS,LayerIIIDecoder.OUT") float tmpf_5;
1876 @LOC("THIS,LayerIIIDecoder.OUT") float tmpf_6;
1877 @LOC("THIS,LayerIIIDecoder.OUT") float tmpf_7;
1878 @LOC("THIS,LayerIIIDecoder.OUT") float tmpf_8;
1879 @LOC("THIS,LayerIIIDecoder.OUT") float tmpf_9;
1880 @LOC("THIS,LayerIIIDecoder.OUT") float tmpf_10;
1881 @LOC("THIS,LayerIIIDecoder.OUT") float tmpf_11;
1882 @LOC("THIS,LayerIIIDecoder.OUT") float tmpf_12;
1883 @LOC("THIS,LayerIIIDecoder.OUT") float tmpf_13;
1884 @LOC("THIS,LayerIIIDecoder.OUT") float tmpf_14;
1885 @LOC("THIS,LayerIIIDecoder.OUT") float tmpf_15;
1886 @LOC("THIS,LayerIIIDecoder.OUT") float tmpf_16;
1887 @LOC("THIS,LayerIIIDecoder.OUT") float tmpf_17;
1904 tmpf_15 = tmpf_16 = tmpf_17 = 0.0f;
1906 if (block_type == 2) {
1910 * Under MicrosoftVM 2922, This causes a GPF, or At best, an
1911 * ArrayIndexOutOfBoundsExceptin. for(int p=0;p<36;p+=9) { out[p] =
1912 * out[p+1] = out[p+2] = out[p+3] = out[p+4] = out[p+5] = out[p+6] =
1913 * out[p+7] = out[p+8] = 0.0f; }
1952 @LOC("THIS,LayerIIIDecoder.OUT") int six_i = 0;
1954 for (i = 0; i < 3; i++) {
1956 // Begin 12 point IDCT
1957 // Input aliasing for 12 pt IDCT
1958 tsOutCopy[15 + i] += tsOutCopy[12 + i];
1959 tsOutCopy[12 + i] += tsOutCopy[9 + i];
1960 tsOutCopy[9 + i] += tsOutCopy[6 + i];
1961 tsOutCopy[6 + i] += tsOutCopy[3 + i];
1962 tsOutCopy[3 + i] += tsOutCopy[0 + i];
1964 // Input aliasing on odd indices (for 6 point IDCT)
1965 tsOutCopy[15 + i] += tsOutCopy[9 + i];
1966 tsOutCopy[9 + i] += tsOutCopy[3 + i];
1968 // 3 point IDCT on even indices
1969 @LOC("THIS,LayerIIIDecoder.OUT") float pp1;
1970 @LOC("THIS,LayerIIIDecoder.OUT") float pp2;
1971 @LOC("THIS,LayerIIIDecoder.OUT") float sum;
1972 pp2 = tsOutCopy[12 + i] * 0.500000000f;
1973 pp1 = tsOutCopy[6 + i] * 0.866025403f;
1974 sum = tsOutCopy[0 + i] + pp2;
1975 tmpf_1 = tsOutCopy[0 + i] - tsOutCopy[12 + i];
1979 // End 3 point IDCT on even indices
1980 // 3 point IDCT on odd indices (for 6 point IDCT)
1981 pp2 = tsOutCopy[15 + i] * 0.500000000f;
1982 pp1 = tsOutCopy[9 + i] * 0.866025403f;
1983 sum = tsOutCopy[3 + i] + pp2;
1984 tmpf_4 = tsOutCopy[3 + i] - tsOutCopy[15 + i];
1987 // End 3 point IDCT on odd indices
1988 // Twiddle factors on odd indices (for 6 point IDCT)
1990 tmpf_3 *= 1.931851653f;
1991 tmpf_4 *= 0.707106781f;
1992 tmpf_5 *= 0.517638090f;
1994 // Output butterflies on 2 3 point IDCT's (for 6 point IDCT)
1995 @LOC("THIS,LayerIIIDecoder.OUT") float save = tmpf_0;
1997 tmpf_5 = save - tmpf_5;
2000 tmpf_4 = save - tmpf_4;
2003 tmpf_3 = save - tmpf_3;
2006 // Twiddle factors on indices (for 12 point IDCT)
2008 tmpf_0 *= 0.504314480f;
2009 tmpf_1 *= 0.541196100f;
2010 tmpf_2 *= 0.630236207f;
2011 tmpf_3 *= 0.821339815f;
2012 tmpf_4 *= 1.306562965f;
2013 tmpf_5 *= 3.830648788f;
2015 // End 12 point IDCT
2017 // Shift to 12 point modified IDCT, multiply by window type 2
2018 tmpf_8 = -tmpf_0 * 0.793353340f;
2019 tmpf_9 = -tmpf_0 * 0.608761429f;
2020 tmpf_7 = -tmpf_1 * 0.923879532f;
2021 tmpf_10 = -tmpf_1 * 0.382683432f;
2022 tmpf_6 = -tmpf_2 * 0.991444861f;
2023 tmpf_11 = -tmpf_2 * 0.130526192f;
2026 tmpf_1 = tmpf_4 * 0.382683432f;
2027 tmpf_2 = tmpf_5 * 0.608761429f;
2029 tmpf_3 = -tmpf_5 * 0.793353340f;
2030 tmpf_4 = -tmpf_4 * 0.923879532f;
2031 tmpf_5 = -tmpf_0 * 0.991444861f;
2033 tmpf_0 *= 0.130526192f;
2035 rawout[six_i + 6] += tmpf_0;
2036 rawout[six_i + 7] += tmpf_1;
2037 rawout[six_i + 8] += tmpf_2;
2038 rawout[six_i + 9] += tmpf_3;
2039 rawout[six_i + 10] += tmpf_4;
2040 rawout[six_i + 11] += tmpf_5;
2041 rawout[six_i + 12] += tmpf_6;
2042 rawout[six_i + 13] += tmpf_7;
2043 rawout[six_i + 14] += tmpf_8;
2044 rawout[six_i + 15] += tmpf_9;
2045 rawout[six_i + 16] += tmpf_10;
2046 rawout[six_i + 17] += tmpf_11;
2052 // input aliasing for 36 point IDCT
2053 tsOutCopy[17] += tsOutCopy[16];
2054 tsOutCopy[16] += tsOutCopy[15];
2055 tsOutCopy[15] += tsOutCopy[14];
2056 tsOutCopy[14] += tsOutCopy[13];
2057 tsOutCopy[13] += tsOutCopy[12];
2058 tsOutCopy[12] += tsOutCopy[11];
2059 tsOutCopy[11] += tsOutCopy[10];
2060 tsOutCopy[10] += tsOutCopy[9];
2061 tsOutCopy[9] += tsOutCopy[8];
2062 tsOutCopy[8] += tsOutCopy[7];
2063 tsOutCopy[7] += tsOutCopy[6];
2064 tsOutCopy[6] += tsOutCopy[5];
2065 tsOutCopy[5] += tsOutCopy[4];
2066 tsOutCopy[4] += tsOutCopy[3];
2067 tsOutCopy[3] += tsOutCopy[2];
2068 tsOutCopy[2] += tsOutCopy[1];
2069 tsOutCopy[1] += tsOutCopy[0];
2071 // 18 point IDCT for odd indices
2072 // input aliasing for 18 point IDCT
2073 tsOutCopy[17] += tsOutCopy[15];
2074 tsOutCopy[15] += tsOutCopy[13];
2075 tsOutCopy[13] += tsOutCopy[11];
2076 tsOutCopy[11] += tsOutCopy[9];
2077 tsOutCopy[9] += tsOutCopy[7];
2078 tsOutCopy[7] += tsOutCopy[5];
2079 tsOutCopy[5] += tsOutCopy[3];
2080 tsOutCopy[3] += tsOutCopy[1];
2082 @LOC("THIS,LayerIIIDecoder.OUT") float tmp0;
2083 @LOC("THIS,LayerIIIDecoder.OUT") float tmp1;
2084 @LOC("THIS,LayerIIIDecoder.OUT") float tmp2;
2085 @LOC("THIS,LayerIIIDecoder.OUT") float tmp3;
2086 @LOC("THIS,LayerIIIDecoder.OUT") float tmp4;
2087 @LOC("THIS,LayerIIIDecoder.OUT") float tmp0_;
2088 @LOC("THIS,LayerIIIDecoder.OUT") float tmp1_;
2089 @LOC("THIS,LayerIIIDecoder.OUT") float tmp2_;
2090 @LOC("THIS,LayerIIIDecoder.OUT") float tmp3_;
2091 @LOC("THIS,LayerIIIDecoder.OUT") float tmp0o;
2092 @LOC("THIS,LayerIIIDecoder.OUT") float tmp1o;
2093 @LOC("THIS,LayerIIIDecoder.OUT") float tmp2o;
2094 @LOC("THIS,LayerIIIDecoder.OUT") float tmp3o;
2095 @LOC("THIS,LayerIIIDecoder.OUT") float tmp4o;
2096 @LOC("THIS,LayerIIIDecoder.OUT") float tmp0_o;
2097 @LOC("THIS,LayerIIIDecoder.OUT") float tmp1_o;
2098 @LOC("THIS,LayerIIIDecoder.OUT") float tmp2_o;
2099 @LOC("THIS,LayerIIIDecoder.OUT") float tmp3_o;
2101 // Fast 9 Point Inverse Discrete Cosine Transform
2103 // By Francois-Raymond Boyer
2104 // mailto:boyerf@iro.umontreal.ca
2105 // http://www.iro.umontreal.ca/~boyerf
2107 // The code has been optimized for Intel processors
2108 // (takes a lot of time to convert float to and from iternal FPU
2111 // It is a simple "factorization" of the IDCT matrix.
2113 // 9 point IDCT on even indices
2115 // 5 points on odd indices (not realy an IDCT)
2116 @LOC("THIS,LayerIIIDecoder.OUT") float i00 = tsOutCopy[0] + tsOutCopy[0];
2117 @LOC("THIS,LayerIIIDecoder.OUT") float iip12 = i00 + tsOutCopy[12];
2120 iip12 + tsOutCopy[4] * 1.8793852415718f + tsOutCopy[8] * 1.532088886238f + tsOutCopy[16]
2121 * 0.34729635533386f;
2122 tmp1 = i00 + tsOutCopy[4] - tsOutCopy[8] - tsOutCopy[12] - tsOutCopy[12] - tsOutCopy[16];
2124 iip12 - tsOutCopy[4] * 0.34729635533386f - tsOutCopy[8] * 1.8793852415718f
2125 + tsOutCopy[16] * 1.532088886238f;
2127 iip12 - tsOutCopy[4] * 1.532088886238f + tsOutCopy[8] * 0.34729635533386f - tsOutCopy[16]
2129 tmp4 = tsOutCopy[0] - tsOutCopy[4] + tsOutCopy[8] - tsOutCopy[12] + tsOutCopy[16];
2131 // 4 points on even indices
2132 @LOC("THIS,LayerIIIDecoder.OUT") float i66_ = tsOutCopy[6] * 1.732050808f; // Sqrt[3]
2135 tsOutCopy[2] * 1.9696155060244f + i66_ + tsOutCopy[10] * 1.2855752193731f + tsOutCopy[14]
2136 * 0.68404028665134f;
2137 tmp1_ = (tsOutCopy[2] - tsOutCopy[10] - tsOutCopy[14]) * 1.732050808f;
2139 tsOutCopy[2] * 1.2855752193731f - i66_ - tsOutCopy[10] * 0.68404028665134f
2140 + tsOutCopy[14] * 1.9696155060244f;
2142 tsOutCopy[2] * 0.68404028665134f - i66_ + tsOutCopy[10] * 1.9696155060244f
2143 - tsOutCopy[14] * 1.2855752193731f;
2145 // 9 point IDCT on odd indices
2146 // 5 points on odd indices (not realy an IDCT)
2147 @LOC("THIS,LayerIIIDecoder.OUT") float i0 = tsOutCopy[0 + 1] + tsOutCopy[0 + 1];
2148 @LOC("THIS,LayerIIIDecoder.OUT") float i0p12 = i0 + tsOutCopy[12 + 1];
2151 i0p12 + tsOutCopy[4 + 1] * 1.8793852415718f + tsOutCopy[8 + 1] * 1.532088886238f
2152 + tsOutCopy[16 + 1] * 0.34729635533386f;
2154 i0 + tsOutCopy[4 + 1] - tsOutCopy[8 + 1] - tsOutCopy[12 + 1] - tsOutCopy[12 + 1]
2155 - tsOutCopy[16 + 1];
2157 i0p12 - tsOutCopy[4 + 1] * 0.34729635533386f - tsOutCopy[8 + 1] * 1.8793852415718f
2158 + tsOutCopy[16 + 1] * 1.532088886238f;
2160 i0p12 - tsOutCopy[4 + 1] * 1.532088886238f + tsOutCopy[8 + 1] * 0.34729635533386f
2161 - tsOutCopy[16 + 1] * 1.8793852415718f;
2163 (tsOutCopy[0 + 1] - tsOutCopy[4 + 1] + tsOutCopy[8 + 1] - tsOutCopy[12 + 1] + tsOutCopy[16 + 1]) * 0.707106781f; // Twiddled
2165 // 4 points on even indices
2166 @LOC("THIS,LayerIIIDecoder.OUT") float i6_ = tsOutCopy[6 + 1] * 1.732050808f; // Sqrt[3]
2169 tsOutCopy[2 + 1] * 1.9696155060244f + i6_ + tsOutCopy[10 + 1] * 1.2855752193731f
2170 + tsOutCopy[14 + 1] * 0.68404028665134f;
2171 tmp1_o = (tsOutCopy[2 + 1] - tsOutCopy[10 + 1] - tsOutCopy[14 + 1]) * 1.732050808f;
2173 tsOutCopy[2 + 1] * 1.2855752193731f - i6_ - tsOutCopy[10 + 1] * 0.68404028665134f
2174 + tsOutCopy[14 + 1] * 1.9696155060244f;
2176 tsOutCopy[2 + 1] * 0.68404028665134f - i6_ + tsOutCopy[10 + 1] * 1.9696155060244f
2177 - tsOutCopy[14 + 1] * 1.2855752193731f;
2179 // Twiddle factors on odd indices
2181 // Butterflies on 9 point IDCT's
2183 // twiddle factors for 36 point IDCT
2185 @LOC("THIS,LayerIIIDecoder.OUT") float e;
2186 @LOC("THIS,LayerIIIDecoder.OUT") float o;
2188 o = (tmp0o + tmp0_o) * 0.501909918f;
2192 o = (tmp1o + tmp1_o) * 0.517638090f;
2196 o = (tmp2o + tmp2_o) * 0.551688959f;
2200 o = (tmp3o + tmp3_o) * 0.610387294f;
2203 tmpf_4 = tmp4 + tmp4o;
2204 tmpf_13 = tmp4 - tmp4o;
2206 o = (tmp3o - tmp3_o) * 0.871723397f;
2210 o = (tmp2o - tmp2_o) * 1.183100792f;
2214 o = (tmp1o - tmp1_o) * 1.931851653f;
2218 o = (tmp0o - tmp0_o) * 5.736856623f;
2222 // end 36 point IDCT */
2223 // shift to modified IDCT
2224 // win_bt = win[block_type]; //substituted this so that a new area does
2225 // not become created
2227 rawout[0] = -tmpf_9 * win[block_type][0];
2228 rawout[1] = -tmpf_10 * win[block_type][1];
2229 rawout[2] = -tmpf_11 * win[block_type][2];
2230 rawout[3] = -tmpf_12 * win[block_type][3];
2231 rawout[4] = -tmpf_13 * win[block_type][4];
2232 rawout[5] = -tmpf_14 * win[block_type][5];
2233 rawout[6] = -tmpf_15 * win[block_type][6];
2234 rawout[7] = -tmpf_16 * win[block_type][7];
2235 rawout[8] = -tmpf_17 * win[block_type][8];
2236 rawout[9] = tmpf_17 * win[block_type][9];
2237 rawout[10] = tmpf_16 * win[block_type][10];
2238 rawout[11] = tmpf_15 * win[block_type][11];
2239 rawout[12] = tmpf_14 * win[block_type][12];
2240 rawout[13] = tmpf_13 * win[block_type][13];
2241 rawout[14] = tmpf_12 * win[block_type][14];
2242 rawout[15] = tmpf_11 * win[block_type][15];
2243 rawout[16] = tmpf_10 * win[block_type][16];
2244 rawout[17] = tmpf_9 * win[block_type][17];
2245 rawout[18] = tmpf_8 * win[block_type][18];
2246 rawout[19] = tmpf_7 * win[block_type][19];
2247 rawout[20] = tmpf_6 * win[block_type][20];
2248 rawout[21] = tmpf_5 * win[block_type][21];
2249 rawout[22] = tmpf_4 * win[block_type][22];
2250 rawout[23] = tmpf_3 * win[block_type][23];
2251 rawout[24] = tmpf_2 * win[block_type][24];
2252 rawout[25] = tmpf_1 * win[block_type][25];
2253 rawout[26] = tmpf_0 * win[block_type][26];
2254 rawout[27] = tmpf_0 * win[block_type][27];
2255 rawout[28] = tmpf_1 * win[block_type][28];
2256 rawout[29] = tmpf_2 * win[block_type][29];
2257 rawout[30] = tmpf_3 * win[block_type][30];
2258 rawout[31] = tmpf_4 * win[block_type][31];
2259 rawout[32] = tmpf_5 * win[block_type][32];
2260 rawout[33] = tmpf_6 * win[block_type][33];
2261 rawout[34] = tmpf_7 * win[block_type][34];
2262 rawout[35] = tmpf_8 * win[block_type][35];
2268 private int counter = 0;
2269 private static final int SSLIMIT = 18;
2270 private static final int SBLIMIT = 32;
2272 // Size of the table of whole numbers raised to 4/3 power.
2273 // This may be adjusted for performance without any problems.
2274 // public static final int POW_TABLE_LIMIT=512;
2276 /************************************************************/
2278 /************************************************************/
2292 @LATTICE("THIS<IN,THISLOC=THIS")
2293 public SBI(@DELEGATE @LOC("IN") int[] thel, @DELEGATE @LOC("IN") int[] thes) {
2300 static class gr_info_s {
2302 public int part2_3_length = 0;
2304 public int big_values = 0;
2306 public int global_gain = 0;
2308 public int scalefac_compress = 0;
2310 public int window_switching_flag = 0;
2312 public int block_type = 0;
2314 public int mixed_block_flag = 0;
2316 public int[] table_select;
2318 public int[] subblock_gain;
2320 public int region0_count = 0;
2322 public int region1_count = 0;
2324 public int preflag = 0;
2326 public int scalefac_scale = 0;
2328 public int count1table_select = 0;
2333 public gr_info_s() {
2334 table_select = new int[3];
2335 subblock_gain = new int[3];
2339 @LATTICE("GR2<GR1,GR1<GR,GR2*")
2340 static class temporaire {
2344 public gr_info_s[] gr;
2349 public temporaire() {
2351 gr = new gr_info_s[2];
2352 gr[0] = new gr_info_s();
2353 gr[1] = new gr_info_s();
2358 static class III_side_info_t {
2361 public int main_data_begin = 0;
2363 public int private_bits = 0;
2365 public temporaire[] ch;
2370 public III_side_info_t() {
2371 ch = new temporaire[2];
2372 ch[0] = new temporaire();
2373 ch[1] = new temporaire();
2378 static class temporaire2 {
2380 public int[] l; /* [cb] */
2382 public int[][] s; /* [window][cb] */
2387 public temporaire2() {
2393 // class III_scalefac_t
2395 // public temporaire2[] tab;
2397 // * Dummy Constructor
2399 // public III_scalefac_t()
2401 // tab = new temporaire2[2];
2405 private static final int slen[][] = { { 0, 0, 0, 0, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4 },
2406 { 0, 1, 2, 3, 0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 2, 3 } };
2408 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,
2412 private SBI[] sfBandIndex; // Init in the constructor.
2414 public static final float two_to_negative_half_pow[] = { 1.0000000000E+00f, 7.0710678119E-01f,
2415 5.0000000000E-01f, 3.5355339059E-01f, 2.5000000000E-01f, 1.7677669530E-01f,
2416 1.2500000000E-01f, 8.8388347648E-02f, 6.2500000000E-02f, 4.4194173824E-02f,
2417 3.1250000000E-02f, 2.2097086912E-02f, 1.5625000000E-02f, 1.1048543456E-02f,
2418 7.8125000000E-03f, 5.5242717280E-03f, 3.9062500000E-03f, 2.7621358640E-03f,
2419 1.9531250000E-03f, 1.3810679320E-03f, 9.7656250000E-04f, 6.9053396600E-04f,
2420 4.8828125000E-04f, 3.4526698300E-04f, 2.4414062500E-04f, 1.7263349150E-04f,
2421 1.2207031250E-04f, 8.6316745750E-05f, 6.1035156250E-05f, 4.3158372875E-05f,
2422 3.0517578125E-05f, 2.1579186438E-05f, 1.5258789062E-05f, 1.0789593219E-05f,
2423 7.6293945312E-06f, 5.3947966094E-06f, 3.8146972656E-06f, 2.6973983047E-06f,
2424 1.9073486328E-06f, 1.3486991523E-06f, 9.5367431641E-07f, 6.7434957617E-07f,
2425 4.7683715820E-07f, 3.3717478809E-07f, 2.3841857910E-07f, 1.6858739404E-07f,
2426 1.1920928955E-07f, 8.4293697022E-08f, 5.9604644775E-08f, 4.2146848511E-08f,
2427 2.9802322388E-08f, 2.1073424255E-08f, 1.4901161194E-08f, 1.0536712128E-08f,
2428 7.4505805969E-09f, 5.2683560639E-09f, 3.7252902985E-09f, 2.6341780319E-09f,
2429 1.8626451492E-09f, 1.3170890160E-09f, 9.3132257462E-10f, 6.5854450798E-10f,
2430 4.6566128731E-10f, 3.2927225399E-10f };
2432 public static final float t_43[] = create_t_43();
2435 static private float[] create_t_43() {
2436 @LOC("OUT") float[] t43 = new float[8192];
2437 final double d43 = (4.0 / 3.0);
2439 for (@LOC("SH") int i = 0; i < 8192; i++) {
2440 t43[i] = (float) Math.pow(i, d43);
2445 public static final float io[][] = {
2446 { 1.0000000000E+00f, 8.4089641526E-01f, 7.0710678119E-01f, 5.9460355751E-01f,
2447 5.0000000001E-01f, 4.2044820763E-01f, 3.5355339060E-01f, 2.9730177876E-01f,
2448 2.5000000001E-01f, 2.1022410382E-01f, 1.7677669530E-01f, 1.4865088938E-01f,
2449 1.2500000000E-01f, 1.0511205191E-01f, 8.8388347652E-02f, 7.4325444691E-02f,
2450 6.2500000003E-02f, 5.2556025956E-02f, 4.4194173826E-02f, 3.7162722346E-02f,
2451 3.1250000002E-02f, 2.6278012978E-02f, 2.2097086913E-02f, 1.8581361173E-02f,
2452 1.5625000001E-02f, 1.3139006489E-02f, 1.1048543457E-02f, 9.2906805866E-03f,
2453 7.8125000006E-03f, 6.5695032447E-03f, 5.5242717285E-03f, 4.6453402934E-03f },
2454 { 1.0000000000E+00f, 7.0710678119E-01f, 5.0000000000E-01f, 3.5355339060E-01f,
2455 2.5000000000E-01f, 1.7677669530E-01f, 1.2500000000E-01f, 8.8388347650E-02f,
2456 6.2500000001E-02f, 4.4194173825E-02f, 3.1250000001E-02f, 2.2097086913E-02f,
2457 1.5625000000E-02f, 1.1048543456E-02f, 7.8125000002E-03f, 5.5242717282E-03f,
2458 3.9062500001E-03f, 2.7621358641E-03f, 1.9531250001E-03f, 1.3810679321E-03f,
2459 9.7656250004E-04f, 6.9053396603E-04f, 4.8828125002E-04f, 3.4526698302E-04f,
2460 2.4414062501E-04f, 1.7263349151E-04f, 1.2207031251E-04f, 8.6316745755E-05f,
2461 6.1035156254E-05f, 4.3158372878E-05f, 3.0517578127E-05f, 2.1579186439E-05f } };
2463 public static final float TAN12[] = { 0.0f, 0.26794919f, 0.57735027f, 1.0f, 1.73205081f,
2464 3.73205081f, 9.9999999e10f, -3.73205081f, -1.73205081f, -1.0f, -0.57735027f, -0.26794919f,
2465 0.0f, 0.26794919f, 0.57735027f, 1.0f };
2467 // REVIEW: in java, the array lookup may well be slower than
2468 // the actual calculation
2471 * private static final int ss_div[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2472 * 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,
2473 * 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,
2474 * 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,
2475 * 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,
2476 * 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,
2477 * 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,
2478 * 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10,
2479 * 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11,
2480 * 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12,
2481 * 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13,
2482 * 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14,
2483 * 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
2484 * 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
2485 * 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
2486 * 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
2487 * 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
2488 * 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
2489 * 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
2490 * 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
2491 * 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
2492 * 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 25,
2493 * 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26,
2494 * 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27,
2495 * 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28,
2496 * 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29,
2497 * 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 30, 30, 30, 30, 30, 30,
2498 * 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 31, 31, 31, 31, 31, 31, 31,
2499 * 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31 };
2501 * // 576 % 18 private static final int ss_mod[] = { 0, 1, 2, 3, 4, 5, 6, 7,
2502 * 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
2503 * 12, 13, 14, 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
2504 * 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
2505 * 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 1, 2, 3,
2506 * 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7,
2507 * 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
2508 * 12, 13, 14, 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
2509 * 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
2510 * 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 1, 2, 3,
2511 * 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7,
2512 * 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
2513 * 12, 13, 14, 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
2514 * 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
2515 * 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 1, 2, 3,
2516 * 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7,
2517 * 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
2518 * 12, 13, 14, 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
2519 * 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
2520 * 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 1, 2, 3,
2521 * 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7,
2522 * 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
2523 * 12, 13, 14, 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
2524 * 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
2525 * 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 1, 2, 3,
2526 * 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7,
2527 * 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
2528 * 12, 13, 14, 15, 16, 17 };
2531 private static/* final */int reorder_table[][]/* = loadReorderTable() */; // SZD:
2540 * Loads the data for the reorder
2543 * private static int[][] loadReorderTable() // SZD: table will be generated {
2544 * try { Class elemType = int[][].class.getComponentType(); Object o =
2545 * JavaLayerUtils.deserializeArrayResource("l3reorder.ser", elemType, 6);
2546 * return (int[][])o; } catch (IOException ex) { throw new
2547 * ExceptionInInitializerError(ex); } }
2549 @LATTICE("OUT<J,J<I,I<SE,I<WIN,SE<SF,SE<SFB,WIN<SFB,J*,I*,WIN*,SFB*")
2550 static int[] reorder(@LOC("SF") int scalefac_band[]) { // SZD: converted from
2552 @LOC("J") int j = 0;
2553 @LOC("OUT") int ix[] = new int[576];
2554 for (int sfb = 0; sfb < 13; sfb++) {
2555 int start = scalefac_band[sfb];
2556 int end = scalefac_band[sfb + 1];
2557 for (int window = 0; window < 3; window++)
2558 for (int i = start; i < end; i++)
2559 ix[3 * i + window] = j++;
2565 * static final int reorder_table_data[][]; = { { 0, 4, 8, 1, 5, 9, 2, 6, 10,
2566 * 3, 7, 11, 12, 16, 20, 13, 17, 21, 14, 18, 22, 15, 19, 23, 24, 28, 32, 25,
2567 * 29, 33, 26, 30, 34, 27, 31, 35, 36, 42, 48, 37, 43, 49, 38, 44, 50, 39, 45,
2568 * 51, 40, 46, 52, 41, 47, 53, 54, 60, 66, 55, 61, 67, 56, 62, 68, 57, 63, 69,
2569 * 58, 64, 70, 59, 65, 71, 72, 80, 88, 73, 81, 89, 74, 82, 90, 75, 83, 91, 76,
2570 * 84, 92, 77, 85, 93, 78, 86, 94, 79, 87, 95, 96,106,116, 97,107,117,
2571 * 98,108,118, 99,109,119,100,110,120,101,
2572 * 111,121,102,112,122,103,113,123,104,114,124,105,115,125,126,140,
2573 * 154,127,141,155,128,142,156,129,143,157,130,144,158,131,145,159,
2574 * 132,146,160,133,147,161,134,148,162,135,149,163,136,150,164,137,
2575 * 151,165,138,152,166,139,153,167,168,186,204,169,187,205,170,188,
2576 * 206,171,189,207,172,190,208,173,191,209,174,192,210,175,193,211,
2577 * 176,194,212,177,195,213,178,196,214,179,197,215,180,198,216,181,
2578 * 199,217,182,200,218,183,201,219,184,202,220,185,203,221,222,248,
2579 * 274,223,249,275,224,250,276,225,251,277,226,252,278,227,253,279,
2580 * 228,254,280,229,255,281,230,256,282,231,257,283,232,258,284,233,
2581 * 259,285,234,260,286,235,261,287,236,262,288,237,263,289,238,264,
2582 * 290,239,265,291,240,266,292,241,267,293,242,268,294,243,269,295,
2583 * 244,270,296,245,271,297,246,272,298,247,273,299,300,332,364,301,
2584 * 333,365,302,334,366,303,335,367,304,336,368,305,337,369,306,338,
2585 * 370,307,339,371,308,340,372,309,341,373,310,342,374,311,343,375,
2586 * 312,344,376,313,345,377,314,346,378,315,347,379,316,348,380,317,
2587 * 349,381,318,350,382,319,351,383,320,352,384,321,353,385,322,354,
2588 * 386,323,355,387,324,356,388,325,357,389,326,358,390,327,359,391,
2589 * 328,360,392,329,361,393,330,362,394,331,363,395,396,438,480,397,
2590 * 439,481,398,440,482,399,441,483,400,442,484,401,443,485,402,444,
2591 * 486,403,445,487,404,446,488,405,447,489,406,448,490,407,449,491,
2592 * 408,450,492,409,451,493,410,452,494,411,453,495,412,454,496,413,
2593 * 455,497,414,456,498,415,457,499,416,458,500,417,459,501,418,460,
2594 * 502,419,461,503,420,462,504,421,463,505,422,464,506,423,465,507,
2595 * 424,466,508,425,467,509,426,468,510,427,469,511,428,470,512,429,
2596 * 471,513,430,472,514,431,473,515,432,474,516,433,475,517,434,476,
2597 * 518,435,477,519,436,478,520,437,479,521,522,540,558,523,541,559,
2598 * 524,542,560,525,543,561,526,544,562,527,545,563,528,546,564,529,
2599 * 547,565,530,548,566,531,549,567,532,550,568,533,551,569,534,552,
2600 * 570,535,553,571,536,554,572,537,555,573,538,556,574,539,557,575}, { 0, 4,
2601 * 8, 1, 5, 9, 2, 6, 10, 3, 7, 11, 12, 16, 20, 13, 17, 21, 14, 18, 22, 15, 19,
2602 * 23, 24, 28, 32, 25, 29, 33, 26, 30, 34, 27, 31, 35, 36, 42, 48, 37, 43, 49,
2603 * 38, 44, 50, 39, 45, 51, 40, 46, 52, 41, 47, 53, 54, 62, 70, 55, 63, 71, 56,
2604 * 64, 72, 57, 65, 73, 58, 66, 74, 59, 67, 75, 60, 68, 76, 61, 69, 77, 78, 88,
2605 * 98, 79, 89, 99, 80, 90,100, 81, 91,101, 82, 92,102, 83, 93,103, 84, 94,104,
2606 * 85, 95,105, 86, 96,106, 87, 97,107,108,120,132,109,
2607 * 121,133,110,122,134,111,123,135,112,124,136,113,125,137,114,126,
2608 * 138,115,127,139,116,128,140,117,129,141,118,130,142,119,131,143,
2609 * 144,158,172,145,159,173,146,160,174,147,161,175,148,162,176,149,
2610 * 163,177,150,164,178,151,165,179,152,166,180,153,167,181,154,168,
2611 * 182,155,169,183,156,170,184,157,171,185,186,204,222,187,205,223,
2612 * 188,206,224,189,207,225,190,208,226,191,209,227,192,210,228,193,
2613 * 211,229,194,212,230,195,213,231,196,214,232,197,215,233,198,216,
2614 * 234,199,217,235,200,218,236,201,219,237,202,220,238,203,221,239,
2615 * 240,264,288,241,265,289,242,266,290,243,267,291,244,268,292,245,
2616 * 269,293,246,270,294,247,271,295,248,272,296,249,273,297,250,274,
2617 * 298,251,275,299,252,276,300,253,277,301,254,278,302,255,279,303,
2618 * 256,280,304,257,281,305,258,282,306,259,283,307,260,284,308,261,
2619 * 285,309,262,286,310,263,287,311,312,344,376,313,345,377,314,346,
2620 * 378,315,347,379,316,348,380,317,349,381,318,350,382,319,351,383,
2621 * 320,352,384,321,353,385,322,354,386,323,355,387,324,356,388,325,
2622 * 357,389,326,358,390,327,359,391,328,360,392,329,361,393,330,362,
2623 * 394,331,363,395,332,364,396,333,365,397,334,366,398,335,367,399,
2624 * 336,368,400,337,369,401,338,370,402,339,371,403,340,372,404,341,
2625 * 373,405,342,374,406,343,375,407,408,452,496,409,453,497,410,454,
2626 * 498,411,455,499,412,456,500,413,457,501,414,458,502,415,459,503,
2627 * 416,460,504,417,461,505,418,462,506,419,463,507,420,464,508,421,
2628 * 465,509,422,466,510,423,467,511,424,468,512,425,469,513,426,470,
2629 * 514,427,471,515,428,472,516,429,473,517,430,474,518,431,475,519,
2630 * 432,476,520,433,477,521,434,478,522,435,479,523,436,480,524,437,
2631 * 481,525,438,482,526,439,483,527,440,484,528,441,485,529,442,486,
2632 * 530,443,487,531,444,488,532,445,489,533,446,490,534,447,491,535,
2633 * 448,492,536,449,493,537,450,494,538,451,495,539,540,552,564,541,
2634 * 553,565,542,554,566,543,555,567,544,556,568,545,557,569,546,558,
2635 * 570,547,559,571,548,560,572,549,561,573,550,562,574,551,563,575}, { 0, 4,
2636 * 8, 1, 5, 9, 2, 6, 10, 3, 7, 11, 12, 16, 20, 13, 17, 21, 14, 18, 22, 15, 19,
2637 * 23, 24, 28, 32, 25, 29, 33, 26, 30, 34, 27, 31, 35, 36, 42, 48, 37, 43, 49,
2638 * 38, 44, 50, 39, 45, 51, 40, 46, 52, 41, 47, 53, 54, 62, 70, 55, 63, 71, 56,
2639 * 64, 72, 57, 65, 73, 58, 66, 74, 59, 67, 75, 60, 68, 76, 61, 69, 77, 78, 88,
2640 * 98, 79, 89, 99, 80, 90,100, 81, 91,101, 82, 92,102, 83, 93,103, 84, 94,104,
2641 * 85, 95,105, 86, 96,106, 87, 97,107,108,120,132,109,
2642 * 121,133,110,122,134,111,123,135,112,124,136,113,125,137,114,126,
2643 * 138,115,127,139,116,128,140,117,129,141,118,130,142,119,131,143,
2644 * 144,158,172,145,159,173,146,160,174,147,161,175,148,162,176,149,
2645 * 163,177,150,164,178,151,165,179,152,166,180,153,167,181,154,168,
2646 * 182,155,169,183,156,170,184,157,171,185,186,204,222,187,205,223,
2647 * 188,206,224,189,207,225,190,208,226,191,209,227,192,210,228,193,
2648 * 211,229,194,212,230,195,213,231,196,214,232,197,215,233,198,216,
2649 * 234,199,217,235,200,218,236,201,219,237,202,220,238,203,221,239,
2650 * 240,264,288,241,265,289,242,266,290,243,267,291,244,268,292,245,
2651 * 269,293,246,270,294,247,271,295,248,272,296,249,273,297,250,274,
2652 * 298,251,275,299,252,276,300,253,277,301,254,278,302,255,279,303,
2653 * 256,280,304,257,281,305,258,282,306,259,283,307,260,284,308,261,
2654 * 285,309,262,286,310,263,287,311,312,342,372,313,343,373,314,344,
2655 * 374,315,345,375,316,346,376,317,347,377,318,348,378,319,349,379,
2656 * 320,350,380,321,351,381,322,352,382,323,353,383,324,354,384,325,
2657 * 355,385,326,356,386,327,357,387,328,358,388,329,359,389,330,360,
2658 * 390,331,361,391,332,362,392,333,363,393,334,364,394,335,365,395,
2659 * 336,366,396,337,367,397,338,368,398,339,369,399,340,370,400,341,
2660 * 371,401,402,442,482,403,443,483,404,444,484,405,445,485,406,446,
2661 * 486,407,447,487,408,448,488,409,449,489,410,450,490,411,451,491,
2662 * 412,452,492,413,453,493,414,454,494,415,455,495,416,456,496,417,
2663 * 457,497,418,458,498,419,459,499,420,460,500,421,461,501,422,462,
2664 * 502,423,463,503,424,464,504,425,465,505,426,466,506,427,467,507,
2665 * 428,468,508,429,469,509,430,470,510,431,471,511,432,472,512,433,
2666 * 473,513,434,474,514,435,475,515,436,476,516,437,477,517,438,478,
2667 * 518,439,479,519,440,480,520,441,481,521,522,540,558,523,541,559,
2668 * 524,542,560,525,543,561,526,544,562,527,545,563,528,546,564,529,
2669 * 547,565,530,548,566,531,549,567,532,550,568,533,551,569,534,552,
2670 * 570,535,553,571,536,554,572,537,555,573,538,556,574,539,557,575}, { 0, 4,
2671 * 8, 1, 5, 9, 2, 6, 10, 3, 7, 11, 12, 16, 20, 13, 17, 21, 14, 18, 22, 15, 19,
2672 * 23, 24, 28, 32, 25, 29, 33, 26, 30, 34, 27, 31, 35, 36, 40, 44, 37, 41, 45,
2673 * 38, 42, 46, 39, 43, 47, 48, 54, 60, 49, 55, 61, 50, 56, 62, 51, 57, 63, 52,
2674 * 58, 64, 53, 59, 65, 66, 74, 82, 67, 75, 83, 68, 76, 84, 69, 77, 85, 70, 78,
2675 * 86, 71, 79, 87, 72, 80, 88, 73, 81, 89, 90,100,110, 91,101,111, 92,102,112,
2676 * 93,103,113, 94,104,114, 95,105,115, 96,106,116, 97, 107,117, 98,108,118,
2677 * 99,109,119,120,132,144,121,133,145,122,134,
2678 * 146,123,135,147,124,136,148,125,137,149,126,138,150,127,139,151,
2679 * 128,140,152,129,141,153,130,142,154,131,143,155,156,170,184,157,
2680 * 171,185,158,172,186,159,173,187,160,174,188,161,175,189,162,176,
2681 * 190,163,177,191,164,178,192,165,179,193,166,180,194,167,181,195,
2682 * 168,182,196,169,183,197,198,216,234,199,217,235,200,218,236,201,
2683 * 219,237,202,220,238,203,221,239,204,222,240,205,223,241,206,224,
2684 * 242,207,225,243,208,226,244,209,227,245,210,228,246,211,229,247,
2685 * 212,230,248,213,231,249,214,232,250,215,233,251,252,274,296,253,
2686 * 275,297,254,276,298,255,277,299,256,278,300,257,279,301,258,280,
2687 * 302,259,281,303,260,282,304,261,283,305,262,284,306,263,285,307,
2688 * 264,286,308,265,287,309,266,288,310,267,289,311,268,290,312,269,
2689 * 291,313,270,292,314,271,293,315,272,294,316,273,295,317,318,348,
2690 * 378,319,349,379,320,350,380,321,351,381,322,352,382,323,353,383,
2691 * 324,354,384,325,355,385,326,356,386,327,357,387,328,358,388,329,
2692 * 359,389,330,360,390,331,361,391,332,362,392,333,363,393,334,364,
2693 * 394,335,365,395,336,366,396,337,367,397,338,368,398,339,369,399,
2694 * 340,370,400,341,371,401,342,372,402,343,373,403,344,374,404,345,
2695 * 375,405,346,376,406,347,377,407,408,464,520,409,465,521,410,466,
2696 * 522,411,467,523,412,468,524,413,469,525,414,470,526,415,471,527,
2697 * 416,472,528,417,473,529,418,474,530,419,475,531,420,476,532,421,
2698 * 477,533,422,478,534,423,479,535,424,480,536,425,481,537,426,482,
2699 * 538,427,483,539,428,484,540,429,485,541,430,486,542,431,487,543,
2700 * 432,488,544,433,489,545,434,490,546,435,491,547,436,492,548,437,
2701 * 493,549,438,494,550,439,495,551,440,496,552,441,497,553,442,498,
2702 * 554,443,499,555,444,500,556,445,501,557,446,502,558,447,503,559,
2703 * 448,504,560,449,505,561,450,506,562,451,507,563,452,508,564,453,
2704 * 509,565,454,510,566,455,511,567,456,512,568,457,513,569,458,514,
2705 * 570,459,515,571,460,516,572,461,517,573,462,518,574,463,519,575}, { 0, 4,
2706 * 8, 1, 5, 9, 2, 6, 10, 3, 7, 11, 12, 16, 20, 13, 17, 21, 14, 18, 22, 15, 19,
2707 * 23, 24, 28, 32, 25, 29, 33, 26, 30, 34, 27, 31, 35, 36, 40, 44, 37, 41, 45,
2708 * 38, 42, 46, 39, 43, 47, 48, 54, 60, 49, 55, 61, 50, 56, 62, 51, 57, 63, 52,
2709 * 58, 64, 53, 59, 65, 66, 72, 78, 67, 73, 79, 68, 74, 80, 69, 75, 81, 70, 76,
2710 * 82, 71, 77, 83, 84, 94,104, 85, 95,105, 86, 96,106, 87, 97,107, 88, 98,108,
2711 * 89, 99,109, 90,100,110, 91,101,111, 92,102,112, 93,
2712 * 103,113,114,126,138,115,127,139,116,128,140,117,129,141,118,130,
2713 * 142,119,131,143,120,132,144,121,133,145,122,134,146,123,135,147,
2714 * 124,136,148,125,137,149,150,164,178,151,165,179,152,166,180,153,
2715 * 167,181,154,168,182,155,169,183,156,170,184,157,171,185,158,172,
2716 * 186,159,173,187,160,174,188,161,175,189,162,176,190,163,177,191,
2717 * 192,208,224,193,209,225,194,210,226,195,211,227,196,212,228,197,
2718 * 213,229,198,214,230,199,215,231,200,216,232,201,217,233,202,218,
2719 * 234,203,219,235,204,220,236,205,221,237,206,222,238,207,223,239,
2720 * 240,260,280,241,261,281,242,262,282,243,263,283,244,264,284,245,
2721 * 265,285,246,266,286,247,267,287,248,268,288,249,269,289,250,270,
2722 * 290,251,271,291,252,272,292,253,273,293,254,274,294,255,275,295,
2723 * 256,276,296,257,277,297,258,278,298,259,279,299,300,326,352,301,
2724 * 327,353,302,328,354,303,329,355,304,330,356,305,331,357,306,332,
2725 * 358,307,333,359,308,334,360,309,335,361,310,336,362,311,337,363,
2726 * 312,338,364,313,339,365,314,340,366,315,341,367,316,342,368,317,
2727 * 343,369,318,344,370,319,345,371,320,346,372,321,347,373,322,348,
2728 * 374,323,349,375,324,350,376,325,351,377,378,444,510,379,445,511,
2729 * 380,446,512,381,447,513,382,448,514,383,449,515,384,450,516,385,
2730 * 451,517,386,452,518,387,453,519,388,454,520,389,455,521,390,456,
2731 * 522,391,457,523,392,458,524,393,459,525,394,460,526,395,461,527,
2732 * 396,462,528,397,463,529,398,464,530,399,465,531,400,466,532,401,
2733 * 467,533,402,468,534,403,469,535,404,470,536,405,471,537,406,472,
2734 * 538,407,473,539,408,474,540,409,475,541,410,476,542,411,477,543,
2735 * 412,478,544,413,479,545,414,480,546,415,481,547,416,482,548,417,
2736 * 483,549,418,484,550,419,485,551,420,486,552,421,487,553,422,488,
2737 * 554,423,489,555,424,490,556,425,491,557,426,492,558,427,493,559,
2738 * 428,494,560,429,495,561,430,496,562,431,497,563,432,498,564,433,
2739 * 499,565,434,500,566,435,501,567,436,502,568,437,503,569,438,504,
2740 * 570,439,505,571,440,506,572,441,507,573,442,508,574,443,509,575}, { 0, 4,
2741 * 8, 1, 5, 9, 2, 6, 10, 3, 7, 11, 12, 16, 20, 13, 17, 21, 14, 18, 22, 15, 19,
2742 * 23, 24, 28, 32, 25, 29, 33, 26, 30, 34, 27, 31, 35, 36, 40, 44, 37, 41, 45,
2743 * 38, 42, 46, 39, 43, 47, 48, 54, 60, 49, 55, 61, 50, 56, 62, 51, 57, 63, 52,
2744 * 58, 64, 53, 59, 65, 66, 74, 82, 67, 75, 83, 68, 76, 84, 69, 77, 85, 70, 78,
2745 * 86, 71, 79, 87, 72, 80, 88, 73, 81, 89, 90,102,114, 91,103,115, 92,104,116,
2746 * 93,105,117, 94,106,118, 95,107,119, 96,108,120, 97, 109,121, 98,110,122,
2747 * 99,111,123,100,112,124,101,113,125,126,142,
2748 * 158,127,143,159,128,144,160,129,145,161,130,146,162,131,147,163,
2749 * 132,148,164,133,149,165,134,150,166,135,151,167,136,152,168,137,
2750 * 153,169,138,154,170,139,155,171,140,156,172,141,157,173,174,194,
2751 * 214,175,195,215,176,196,216,177,197,217,178,198,218,179,199,219,
2752 * 180,200,220,181,201,221,182,202,222,183,203,223,184,204,224,185,
2753 * 205,225,186,206,226,187,207,227,188,208,228,189,209,229,190,210,
2754 * 230,191,211,231,192,212,232,193,213,233,234,260,286,235,261,287,
2755 * 236,262,288,237,263,289,238,264,290,239,265,291,240,266,292,241,
2756 * 267,293,242,268,294,243,269,295,244,270,296,245,271,297,246,272,
2757 * 298,247,273,299,248,274,300,249,275,301,250,276,302,251,277,303,
2758 * 252,278,304,253,279,305,254,280,306,255,281,307,256,282,308,257,
2759 * 283,309,258,284,310,259,285,311,312,346,380,313,347,381,314,348,
2760 * 382,315,349,383,316,350,384,317,351,385,318,352,386,319,353,387,
2761 * 320,354,388,321,355,389,322,356,390,323,357,391,324,358,392,325,
2762 * 359,393,326,360,394,327,361,395,328,362,396,329,363,397,330,364,
2763 * 398,331,365,399,332,366,400,333,367,401,334,368,402,335,369,403,
2764 * 336,370,404,337,371,405,338,372,406,339,373,407,340,374,408,341,
2765 * 375,409,342,376,410,343,377,411,344,378,412,345,379,413,414,456,
2766 * 498,415,457,499,416,458,500,417,459,501,418,460,502,419,461,503,
2767 * 420,462,504,421,463,505,422,464,506,423,465,507,424,466,508,425,
2768 * 467,509,426,468,510,427,469,511,428,470,512,429,471,513,430,472,
2769 * 514,431,473,515,432,474,516,433,475,517,434,476,518,435,477,519,
2770 * 436,478,520,437,479,521,438,480,522,439,481,523,440,482,524,441,
2771 * 483,525,442,484,526,443,485,527,444,486,528,445,487,529,446,488,
2772 * 530,447,489,531,448,490,532,449,491,533,450,492,534,451,493,535,
2773 * 452,494,536,453,495,537,454,496,538,455,497,539,540,552,564,541,
2774 * 553,565,542,554,566,543,555,567,544,556,568,545,557,569,546,558,
2775 * 570,547,559,571,548,560,572,549,561,573,550,562,574,551,563,575} };
2778 private static final float cs[] = { 0.857492925712f, 0.881741997318f, 0.949628649103f,
2779 0.983314592492f, 0.995517816065f, 0.999160558175f, 0.999899195243f, 0.999993155067f };
2781 private static final float ca[] = { -0.5144957554270f, -0.4717319685650f, -0.3133774542040f,
2782 -0.1819131996110f, -0.0945741925262f, -0.0409655828852f, -0.0141985685725f,
2783 -0.00369997467375f };
2785 /************************************************************/
2786 /* END OF L3TABLE */
2787 /************************************************************/
2789 /************************************************************/
2791 /************************************************************/
2793 /***************************************************************/
2795 /***************************************************************/
2797 /***************************************************************/
2799 /***************************************************************/
2800 public static final float win[][] = {
2801 { -1.6141214951E-02f, -5.3603178919E-02f, -1.0070713296E-01f, -1.6280817573E-01f,
2802 -4.9999999679E-01f, -3.8388735032E-01f, -6.2061144372E-01f, -1.1659756083E+00f,
2803 -3.8720752656E+00f, -4.2256286556E+00f, -1.5195289984E+00f, -9.7416483388E-01f,
2804 -7.3744074053E-01f, -1.2071067773E+00f, -5.1636156596E-01f, -4.5426052317E-01f,
2805 -4.0715656898E-01f, -3.6969460527E-01f, -3.3876269197E-01f, -3.1242222492E-01f,
2806 -2.8939587111E-01f, -2.6880081906E-01f, -5.0000000266E-01f, -2.3251417468E-01f,
2807 -2.1596714708E-01f, -2.0004979098E-01f, -1.8449493497E-01f, -1.6905846094E-01f,
2808 -1.5350360518E-01f, -1.3758624925E-01f, -1.2103922149E-01f, -2.0710679058E-01f,
2809 -8.4752577594E-02f, -6.4157525656E-02f, -4.1131172614E-02f, -1.4790705759E-02f },
2811 { -1.6141214951E-02f, -5.3603178919E-02f, -1.0070713296E-01f, -1.6280817573E-01f,
2812 -4.9999999679E-01f, -3.8388735032E-01f, -6.2061144372E-01f, -1.1659756083E+00f,
2813 -3.8720752656E+00f, -4.2256286556E+00f, -1.5195289984E+00f, -9.7416483388E-01f,
2814 -7.3744074053E-01f, -1.2071067773E+00f, -5.1636156596E-01f, -4.5426052317E-01f,
2815 -4.0715656898E-01f, -3.6969460527E-01f, -3.3908542600E-01f, -3.1511810350E-01f,
2816 -2.9642226150E-01f, -2.8184548650E-01f, -5.4119610000E-01f, -2.6213228100E-01f,
2817 -2.5387916537E-01f, -2.3296291359E-01f, -1.9852728987E-01f, -1.5233534808E-01f,
2818 -9.6496400054E-02f, -3.3423828516E-02f, 0.0000000000E+00f, 0.0000000000E+00f,
2819 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f },
2821 { -4.8300800645E-02f, -1.5715656932E-01f, -2.8325045177E-01f, -4.2953747763E-01f,
2822 -1.2071067795E+00f, -8.2426483178E-01f, -1.1451749106E+00f, -1.7695290101E+00f,
2823 -4.5470225061E+00f, -3.4890531002E+00f, -7.3296292804E-01f, -1.5076514758E-01f,
2824 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f,
2825 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f,
2826 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f,
2827 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f,
2828 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f,
2829 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f },
2831 { 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f,
2832 0.0000000000E+00f, 0.0000000000E+00f, -1.5076513660E-01f, -7.3296291107E-01f,
2833 -3.4890530566E+00f, -4.5470224727E+00f, -1.7695290031E+00f, -1.1451749092E+00f,
2834 -8.3137738100E-01f, -1.3065629650E+00f, -5.4142014250E-01f, -4.6528974900E-01f,
2835 -4.1066990750E-01f, -3.7004680800E-01f, -3.3876269197E-01f, -3.1242222492E-01f,
2836 -2.8939587111E-01f, -2.6880081906E-01f, -5.0000000266E-01f, -2.3251417468E-01f,
2837 -2.1596714708E-01f, -2.0004979098E-01f, -1.8449493497E-01f, -1.6905846094E-01f,
2838 -1.5350360518E-01f, -1.3758624925E-01f, -1.2103922149E-01f, -2.0710679058E-01f,
2839 -8.4752577594E-02f, -6.4157525656E-02f, -4.1131172614E-02f, -1.4790705759E-02f } };
2841 /***************************************************************/
2842 /* END OF INV_MDCT */
2843 /***************************************************************/
2856 @LATTICE("THIS<IN,THISLOC=THIS")
2857 public Sftable(@DELEGATE @LOC("IN") int[] thel, @DELEGATE @LOC("IN") int[] thes) {
2864 public Sftable sftable;
2866 public static final int nr_of_sfb_block[][][] = {
2867 { { 6, 5, 5, 5 }, { 9, 9, 9, 9 }, { 6, 9, 9, 9 } },
2868 { { 6, 5, 7, 3 }, { 9, 9, 12, 6 }, { 6, 9, 12, 6 } },
2869 { { 11, 10, 0, 0 }, { 18, 18, 0, 0 }, { 15, 18, 0, 0 } },
2870 { { 7, 7, 7, 0 }, { 12, 12, 12, 0 }, { 6, 15, 12, 0 } },
2871 { { 6, 6, 6, 3 }, { 12, 9, 9, 6 }, { 6, 12, 9, 6 } },
2872 { { 8, 8, 5, 0 }, { 15, 12, 9, 0 }, { 6, 18, 9, 0 } } };