Path: blob/main/src/lwjgl/java/javazoom/jl/decoder/LayerIIIDecoder.java
8650 views
/*1* 11/19/04 1.0 moved to LGPL.2*3* 18/06/01 Michael Scheerer, Fixed bugs which causes4* negative indexes in method huffmann_decode and in method5* dequanisize_sample.6*7* 16/07/01 Michael Scheerer, Catched a bug in method8* huffmann_decode, which causes an outOfIndexException.9* Cause : Indexnumber of 24 at SfBandIndex,10* which has only a length of 22. I have simply and dirty11* fixed the index to <= 22, because I'm not really be able12* to fix the bug. The Indexnumber is taken from the MP313* file and the origin Ma-Player with the same code works14* well.15*16* 02/19/99 Java Conversion by E.B, [email protected]17*-----------------------------------------------------------------------18* This program is free software; you can redistribute it and/or modify19* it under the terms of the GNU Library General Public License as published20* by the Free Software Foundation; either version 2 of the License, or21* (at your option) any later version.22*23* This program is distributed in the hope that it will be useful,24* but WITHOUT ANY WARRANTY; without even the implied warranty of25* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the26* GNU Library General Public License for more details.27*28* You should have received a copy of the GNU Library General Public29* License along with this program; if not, write to the Free Software30* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.31*----------------------------------------------------------------------32*/3334package javazoom.jl.decoder;3536/**37* Class Implementing Layer 3 Decoding.38*39* @since 0.040*/41final class LayerIIIDecoder implements FrameDecoder42{43static final double d43 = (4.0/3.0);4445public int[] scalefac_buffer;4647// MDM: removed, as this wasn't being used.48//private float CheckSumOut1d = 0.0f;49private int CheckSumHuff = 0;50private int[] is_1d;51private float[][][] ro;52private float[][][] lr;53private float[] out_1d;54private float[][] prevblck;55private float[][] k;56private int[] nonzero;57private Bitstream stream;58private Header header;59private SynthesisFilter filter1, filter2;60private Obuffer buffer;61private int which_channels;62private BitReserve br;63private III_side_info_t si;6465private temporaire2[] III_scalefac_t;66private temporaire2[] scalefac;67// private III_scalefac_t scalefac;6869private int max_gr;70private int frame_start;71private int part2_start;72private int channels;73private int first_channel;74private int last_channel;75private int sfreq;767778/**79* Constructor.80*/81// REVIEW: these constructor arguments should be moved to the82// decodeFrame() method, where possible, so that one83public LayerIIIDecoder(Bitstream stream0, Header header0,84SynthesisFilter filtera, SynthesisFilter filterb,85Obuffer buffer0, int which_ch0)86{87huffcodetab.inithuff();88is_1d = new int[SBLIMIT*SSLIMIT+4];89ro = new float[2][SBLIMIT][SSLIMIT];90lr = new float[2][SBLIMIT][SSLIMIT];91out_1d = new float[SBLIMIT*SSLIMIT];92prevblck = new float[2][SBLIMIT*SSLIMIT];93k = new float[2][SBLIMIT*SSLIMIT];94nonzero = new int[2];9596//III_scalefact_t97III_scalefac_t = new temporaire2[2];98III_scalefac_t[0] = new temporaire2();99III_scalefac_t[1] = new temporaire2();100scalefac = III_scalefac_t;101// L3TABLE INIT102103sfBandIndex = new SBI[9]; // SZD: MPEG2.5 +3 indices104int[] l0 = {0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576};105int[] s0 = {0,4,8,12,18,24,32,42,56,74,100,132,174,192};106int[] l1 = {0,6,12,18,24,30,36,44,54,66,80,96,114,136,162,194,232,278,330,394,464,540,576};107int[] s1 = {0,4,8,12,18,26,36,48,62,80,104,136,180,192};108int[] l2 = {0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576};109int[] s2 = {0,4,8,12,18,26,36,48,62,80,104,134,174,192};110111int[] l3 = {0,4,8,12,16,20,24,30,36,44,52,62,74,90,110,134,162,196,238,288,342,418,576};112int[] s3 = {0,4,8,12,16,22,30,40,52,66,84,106,136,192};113int[] l4 = {0,4,8,12,16,20,24,30,36,42,50,60,72,88,106,128,156,190,230,276,330,384,576};114int[] s4 = {0,4,8,12,16,22,28,38,50,64,80,100,126,192};115int[] l5 = {0,4,8,12,16,20,24,30,36,44,54,66,82,102,126,156,194,240,296,364,448,550,576};116int[] s5 = {0,4,8,12,16,22,30,42,58,78,104,138,180,192};117// SZD: MPEG2.5118int[] l6 = {0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576};119int[] s6 = {0,4,8,12,18,26,36,48,62,80,104,134,174,192};120int[] l7 = {0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576};121int[] s7 = {0,4,8,12,18,26,36,48,62,80,104,134,174,192};122int[] l8 = {0,12,24,36,48,60,72,88,108,132,160,192,232,280,336,400,476,566,568,570,572,574,576};123int[] s8 = {0,8,16,24,36,52,72,96,124,160,162,164,166,192};124125sfBandIndex[0]= new SBI(l0,s0);126sfBandIndex[1]= new SBI(l1,s1);127sfBandIndex[2]= new SBI(l2,s2);128129sfBandIndex[3]= new SBI(l3,s3);130sfBandIndex[4]= new SBI(l4,s4);131sfBandIndex[5]= new SBI(l5,s5);132//SZD: MPEG2.5133sfBandIndex[6]= new SBI(l6,s6);134sfBandIndex[7]= new SBI(l7,s7);135sfBandIndex[8]= new SBI(l8,s8);136// END OF L3TABLE INIT137138if(reorder_table == null) { // SZD: generate LUT139reorder_table = new int[9][];140for(int i = 0; i < 9; i++)141reorder_table[i] = reorder(sfBandIndex[i].s);142}143144// Sftable145int[] ll0 = {0, 6, 11, 16, 21};146int[] ss0 = {0, 6, 12};147sftable = new Sftable(ll0,ss0);148// END OF Sftable149150// scalefac_buffer151scalefac_buffer = new int[54];152// END OF scalefac_buffer153154stream = stream0;155header = header0;156filter1 = filtera;157filter2 = filterb;158buffer = buffer0;159which_channels = which_ch0;160161frame_start = 0;162channels = (header.mode() == Header.SINGLE_CHANNEL) ? 1 : 2;163max_gr = (header.version() == Header.MPEG1) ? 2 : 1;164165sfreq = header.sample_frequency() +166((header.version() == Header.MPEG1) ? 3 :167(header.version() == Header.MPEG25_LSF) ? 6 : 0); // SZD168169if (channels == 2)170{171switch (which_channels)172{173case OutputChannels.LEFT_CHANNEL:174case OutputChannels.DOWNMIX_CHANNELS:175first_channel = last_channel = 0;176break;177178case OutputChannels.RIGHT_CHANNEL:179first_channel = last_channel = 1;180break;181182case OutputChannels.BOTH_CHANNELS:183default:184first_channel = 0;185last_channel = 1;186break;187}188}189else190{191first_channel = last_channel = 0;192}193194for(int ch=0;ch<2;ch++)195for (int j=0; j<576; j++)196prevblck[ch][j] = 0.0f;197198nonzero[0] = nonzero[1] = 576;199200br = new BitReserve();201si = new III_side_info_t();202}203204/**205* Notify decoder that a seek is being made.206*/207public void seek_notify()208{209frame_start = 0;210for(int ch=0;ch<2;ch++)211for (int j=0; j<576; j++)212prevblck[ch][j] = 0.0f;213br = new BitReserve();214}215216public void decodeFrame()217{218decode();219}220221/**222* Decode one frame, filling the buffer with the output samples.223*/224225// subband samples are buffered and passed to the226// SynthesisFilter in one go.227private float[] samples1 = new float[32];228private float[] samples2 = new float[32];229230public void decode()231{232int nSlots = header.slots();233int flush_main;234int gr, ch, ss, sb, sb18;235int main_data_end;236int bytes_to_discard;237int i;238239get_side_info();240241for (i=0; i<nSlots; i++)242br.hputbuf(stream.get_bits(8));243244main_data_end = br.hsstell() >>> 3; // of previous frame245246if ((flush_main = (br.hsstell() & 7)) != 0) {247br.hgetbits(8 - flush_main);248main_data_end++;249}250251bytes_to_discard = frame_start - main_data_end252- si.main_data_begin;253254frame_start += nSlots;255256if (bytes_to_discard < 0)257return;258259if (main_data_end > 4096) {260frame_start -= 4096;261br.rewindNbytes(4096);262}263264for (; bytes_to_discard > 0; bytes_to_discard--)265br.hgetbits(8);266267for (gr=0;gr<max_gr;gr++) {268269for (ch=0; ch<channels; ch++) {270part2_start = br.hsstell();271272if (header.version() == Header.MPEG1)273get_scale_factors(ch, gr);274else // MPEG-2 LSF, SZD: MPEG-2.5 LSF275get_LSF_scale_factors(ch, gr);276277huffman_decode(ch, gr);278// System.out.println("CheckSum HuffMan = " + CheckSumHuff);279dequantize_sample(ro[ch], ch, gr);280}281282stereo(gr);283284if ((which_channels == OutputChannels.DOWNMIX_CHANNELS) && (channels > 1))285do_downmix();286287for (ch=first_channel; ch<=last_channel; ch++) {288289reorder(lr[ch], ch, gr);290antialias(ch, gr);291//for (int hb = 0;hb<576;hb++) CheckSumOut1d = CheckSumOut1d + out_1d[hb];292//System.out.println("CheckSumOut1d = "+CheckSumOut1d);293294hybrid(ch, gr);295296//for (int hb = 0;hb<576;hb++) CheckSumOut1d = CheckSumOut1d + out_1d[hb];297//System.out.println("CheckSumOut1d = "+CheckSumOut1d);298299for (sb18=18;sb18<576;sb18+=36) // Frequency inversion300for (ss=1;ss<SSLIMIT;ss+=2)301out_1d[sb18 + ss] = -out_1d[sb18 + ss];302303if ((ch == 0) || (which_channels == OutputChannels.RIGHT_CHANNEL)) {304for (ss=0;ss<SSLIMIT;ss++) { // Polyphase synthesis305sb = 0;306for (sb18=0; sb18<576; sb18+=18) {307samples1[sb] = out_1d[sb18+ss];308//filter1.input_sample(out_1d[sb18+ss], sb);309sb++;310}311filter1.input_samples(samples1);312filter1.calculate_pcm_samples(buffer);313}314} else {315for (ss=0;ss<SSLIMIT;ss++) { // Polyphase synthesis316sb = 0;317for (sb18=0; sb18<576; sb18+=18) {318samples2[sb] = out_1d[sb18+ss];319//filter2.input_sample(out_1d[sb18+ss], sb);320sb++;321}322filter2.input_samples(samples2);323filter2.calculate_pcm_samples(buffer);324}325326}327} // channels328} // granule329330331// System.out.println("Counter = ................................."+counter);332//if (counter < 609)333//{334counter++;335buffer.write_buffer(1);336//}337//else if (counter == 609)338//{339// buffer.close();340// counter++;341//}342//else343//{344//}345346}347348/**349* Reads the side info from the stream, assuming the entire.350* frame has been read already.351* Mono : 136 bits (= 17 bytes)352* Stereo : 256 bits (= 32 bytes)353*/354private boolean get_side_info()355{356int ch, gr;357if (header.version() == Header.MPEG1)358{359360si.main_data_begin = stream.get_bits(9);361if (channels == 1)362si.private_bits = stream.get_bits(5);363else si.private_bits = stream.get_bits(3);364365for (ch=0; ch<channels; ch++) {366si.ch[ch].scfsi[0] = stream.get_bits(1);367si.ch[ch].scfsi[1] = stream.get_bits(1);368si.ch[ch].scfsi[2] = stream.get_bits(1);369si.ch[ch].scfsi[3] = stream.get_bits(1);370}371372for (gr=0; gr<2; gr++) {373for (ch=0; ch<channels; ch++) {374si.ch[ch].gr[gr].part2_3_length = stream.get_bits(12);375si.ch[ch].gr[gr].big_values = stream.get_bits(9);376si.ch[ch].gr[gr].global_gain = stream.get_bits(8);377si.ch[ch].gr[gr].scalefac_compress = stream.get_bits(4);378si.ch[ch].gr[gr].window_switching_flag = stream.get_bits(1);379if ((si.ch[ch].gr[gr].window_switching_flag) != 0) {380si.ch[ch].gr[gr].block_type = stream.get_bits(2);381si.ch[ch].gr[gr].mixed_block_flag = stream.get_bits(1);382383si.ch[ch].gr[gr].table_select[0] = stream.get_bits(5);384si.ch[ch].gr[gr].table_select[1] = stream.get_bits(5);385386si.ch[ch].gr[gr].subblock_gain[0] = stream.get_bits(3);387si.ch[ch].gr[gr].subblock_gain[1] = stream.get_bits(3);388si.ch[ch].gr[gr].subblock_gain[2] = stream.get_bits(3);389390// Set region_count parameters since they are implicit in this case.391392if (si.ch[ch].gr[gr].block_type == 0) {393// Side info bad: block_type == 0 in split block394return false;395} else if (si.ch[ch].gr[gr].block_type == 2396&& si.ch[ch].gr[gr].mixed_block_flag == 0) {397si.ch[ch].gr[gr].region0_count = 8;398} else {399si.ch[ch].gr[gr].region0_count = 7;400}401si.ch[ch].gr[gr].region1_count = 20 -402si.ch[ch].gr[gr].region0_count;403} else {404si.ch[ch].gr[gr].table_select[0] = stream.get_bits(5);405si.ch[ch].gr[gr].table_select[1] = stream.get_bits(5);406si.ch[ch].gr[gr].table_select[2] = stream.get_bits(5);407si.ch[ch].gr[gr].region0_count = stream.get_bits(4);408si.ch[ch].gr[gr].region1_count = stream.get_bits(3);409si.ch[ch].gr[gr].block_type = 0;410}411si.ch[ch].gr[gr].preflag = stream.get_bits(1);412si.ch[ch].gr[gr].scalefac_scale = stream.get_bits(1);413si.ch[ch].gr[gr].count1table_select = stream.get_bits(1);414}415}416417} else { // MPEG-2 LSF, SZD: MPEG-2.5 LSF418419si.main_data_begin = stream.get_bits(8);420if (channels == 1)421si.private_bits = stream.get_bits(1);422else si.private_bits = stream.get_bits(2);423424for (ch=0; ch<channels; ch++) {425426si.ch[ch].gr[0].part2_3_length = stream.get_bits(12);427si.ch[ch].gr[0].big_values = stream.get_bits(9);428si.ch[ch].gr[0].global_gain = stream.get_bits(8);429si.ch[ch].gr[0].scalefac_compress = stream.get_bits(9);430si.ch[ch].gr[0].window_switching_flag = stream.get_bits(1);431432if ((si.ch[ch].gr[0].window_switching_flag) != 0) {433434si.ch[ch].gr[0].block_type = stream.get_bits(2);435si.ch[ch].gr[0].mixed_block_flag = stream.get_bits(1);436si.ch[ch].gr[0].table_select[0] = stream.get_bits(5);437si.ch[ch].gr[0].table_select[1] = stream.get_bits(5);438439si.ch[ch].gr[0].subblock_gain[0] = stream.get_bits(3);440si.ch[ch].gr[0].subblock_gain[1] = stream.get_bits(3);441si.ch[ch].gr[0].subblock_gain[2] = stream.get_bits(3);442443// Set region_count parameters since they are implicit in this case.444445if (si.ch[ch].gr[0].block_type == 0) {446// Side info bad: block_type == 0 in split block447return false;448} else if (si.ch[ch].gr[0].block_type == 2449&& si.ch[ch].gr[0].mixed_block_flag == 0) {450si.ch[ch].gr[0].region0_count = 8;451} else {452si.ch[ch].gr[0].region0_count = 7;453si.ch[ch].gr[0].region1_count = 20 -454si.ch[ch].gr[0].region0_count;455}456457} else {458si.ch[ch].gr[0].table_select[0] = stream.get_bits(5);459si.ch[ch].gr[0].table_select[1] = stream.get_bits(5);460si.ch[ch].gr[0].table_select[2] = stream.get_bits(5);461si.ch[ch].gr[0].region0_count = stream.get_bits(4);462si.ch[ch].gr[0].region1_count = stream.get_bits(3);463si.ch[ch].gr[0].block_type = 0;464}465466si.ch[ch].gr[0].scalefac_scale = stream.get_bits(1);467si.ch[ch].gr[0].count1table_select = stream.get_bits(1);468} // for(ch=0; ch<channels; ch++)469} // if (header.version() == MPEG1)470return true;471}472473/**474*475*/476private void get_scale_factors(int ch, int gr)477{478int sfb, window;479gr_info_s gr_info = (si.ch[ch].gr[gr]);480int scale_comp = gr_info.scalefac_compress;481int length0 = slen[0][scale_comp];482int length1 = slen[1][scale_comp];483484if ((gr_info.window_switching_flag != 0) && (gr_info.block_type == 2)) {485if ((gr_info.mixed_block_flag) != 0) { // MIXED486for (sfb = 0; sfb < 8; sfb++)487scalefac[ch].l[sfb] = br.hgetbits(488slen[0][gr_info.scalefac_compress]);489for (sfb = 3; sfb < 6; sfb++)490for (window=0; window<3; window++)491scalefac[ch].s[window][sfb] = br.hgetbits(492slen[0][gr_info.scalefac_compress]);493for (sfb = 6; sfb < 12; sfb++)494for (window=0; window<3; window++)495scalefac[ch].s[window][sfb] = br.hgetbits(496slen[1][gr_info.scalefac_compress]);497for (sfb=12,window=0; window<3; window++)498scalefac[ch].s[window][sfb] = 0;499500} else { // SHORT501502scalefac[ch].s[0][0] = br.hgetbits(length0);503scalefac[ch].s[1][0] = br.hgetbits(length0);504scalefac[ch].s[2][0] = br.hgetbits(length0);505scalefac[ch].s[0][1] = br.hgetbits(length0);506scalefac[ch].s[1][1] = br.hgetbits(length0);507scalefac[ch].s[2][1] = br.hgetbits(length0);508scalefac[ch].s[0][2] = br.hgetbits(length0);509scalefac[ch].s[1][2] = br.hgetbits(length0);510scalefac[ch].s[2][2] = br.hgetbits(length0);511scalefac[ch].s[0][3] = br.hgetbits(length0);512scalefac[ch].s[1][3] = br.hgetbits(length0);513scalefac[ch].s[2][3] = br.hgetbits(length0);514scalefac[ch].s[0][4] = br.hgetbits(length0);515scalefac[ch].s[1][4] = br.hgetbits(length0);516scalefac[ch].s[2][4] = br.hgetbits(length0);517scalefac[ch].s[0][5] = br.hgetbits(length0);518scalefac[ch].s[1][5] = br.hgetbits(length0);519scalefac[ch].s[2][5] = br.hgetbits(length0);520scalefac[ch].s[0][6] = br.hgetbits(length1);521scalefac[ch].s[1][6] = br.hgetbits(length1);522scalefac[ch].s[2][6] = br.hgetbits(length1);523scalefac[ch].s[0][7] = br.hgetbits(length1);524scalefac[ch].s[1][7] = br.hgetbits(length1);525scalefac[ch].s[2][7] = br.hgetbits(length1);526scalefac[ch].s[0][8] = br.hgetbits(length1);527scalefac[ch].s[1][8] = br.hgetbits(length1);528scalefac[ch].s[2][8] = br.hgetbits(length1);529scalefac[ch].s[0][9] = br.hgetbits(length1);530scalefac[ch].s[1][9] = br.hgetbits(length1);531scalefac[ch].s[2][9] = br.hgetbits(length1);532scalefac[ch].s[0][10] = br.hgetbits(length1);533scalefac[ch].s[1][10] = br.hgetbits(length1);534scalefac[ch].s[2][10] = br.hgetbits(length1);535scalefac[ch].s[0][11] = br.hgetbits(length1);536scalefac[ch].s[1][11] = br.hgetbits(length1);537scalefac[ch].s[2][11] = br.hgetbits(length1);538scalefac[ch].s[0][12] = 0;539scalefac[ch].s[1][12] = 0;540scalefac[ch].s[2][12] = 0;541} // SHORT542543} else { // LONG types 0,1,3544545if ((si.ch[ch].scfsi[0] == 0) || (gr == 0)) {546scalefac[ch].l[0] = br.hgetbits(length0);547scalefac[ch].l[1] = br.hgetbits(length0);548scalefac[ch].l[2] = br.hgetbits(length0);549scalefac[ch].l[3] = br.hgetbits(length0);550scalefac[ch].l[4] = br.hgetbits(length0);551scalefac[ch].l[5] = br.hgetbits(length0);552}553if ((si.ch[ch].scfsi[1] == 0) || (gr == 0)) {554scalefac[ch].l[6] = br.hgetbits(length0);555scalefac[ch].l[7] = br.hgetbits(length0);556scalefac[ch].l[8] = br.hgetbits(length0);557scalefac[ch].l[9] = br.hgetbits(length0);558scalefac[ch].l[10] = br.hgetbits(length0);559}560if ((si.ch[ch].scfsi[2] == 0) || (gr == 0)) {561scalefac[ch].l[11] = br.hgetbits(length1);562scalefac[ch].l[12] = br.hgetbits(length1);563scalefac[ch].l[13] = br.hgetbits(length1);564scalefac[ch].l[14] = br.hgetbits(length1);565scalefac[ch].l[15] = br.hgetbits(length1);566}567if ((si.ch[ch].scfsi[3] == 0) || (gr == 0)) {568scalefac[ch].l[16] = br.hgetbits(length1);569scalefac[ch].l[17] = br.hgetbits(length1);570scalefac[ch].l[18] = br.hgetbits(length1);571scalefac[ch].l[19] = br.hgetbits(length1);572scalefac[ch].l[20] = br.hgetbits(length1);573}574575scalefac[ch].l[21] = 0;576scalefac[ch].l[22] = 0;577}578}579580/**581*582*/583// MDM: new_slen is fully initialized before use, no need584// to reallocate array.585private final int[] new_slen = new int[4];586587private void get_LSF_scale_data(int ch, int gr)588{589590int scalefac_comp, int_scalefac_comp;591int mode_ext = header.mode_extension();592int m;593int blocktypenumber;594int blocknumber = 0;595596gr_info_s gr_info = (si.ch[ch].gr[gr]);597598scalefac_comp = gr_info.scalefac_compress;599600if (gr_info.block_type == 2) {601if (gr_info.mixed_block_flag == 0)602blocktypenumber = 1;603else if (gr_info.mixed_block_flag == 1)604blocktypenumber = 2;605else606blocktypenumber = 0;607} else {608blocktypenumber = 0;609}610611if(!(((mode_ext == 1) || (mode_ext == 3)) && (ch == 1))) {612613if(scalefac_comp < 400) {614615new_slen[0] = (scalefac_comp >>> 4) / 5 ;616new_slen[1] = (scalefac_comp >>> 4) % 5 ;617new_slen[2] = (scalefac_comp & 0xF) >>> 2 ;618new_slen[3] = (scalefac_comp & 3);619si.ch[ch].gr[gr].preflag = 0;620blocknumber = 0;621622} else if (scalefac_comp < 500) {623624new_slen[0] = ((scalefac_comp - 400) >>> 2) / 5 ;625new_slen[1] = ((scalefac_comp - 400) >>> 2) % 5 ;626new_slen[2] = (scalefac_comp - 400 ) & 3 ;627new_slen[3] = 0;628si.ch[ch].gr[gr].preflag = 0;629blocknumber = 1;630631} else if (scalefac_comp < 512) {632633new_slen[0] = (scalefac_comp - 500 ) / 3 ;634new_slen[1] = (scalefac_comp - 500) % 3 ;635new_slen[2] = 0;636new_slen[3] = 0;637si.ch[ch].gr[gr].preflag = 1;638blocknumber = 2;639}640}641642if((((mode_ext == 1) || (mode_ext == 3)) && (ch == 1)))643{644int_scalefac_comp = scalefac_comp >>> 1;645646if (int_scalefac_comp < 180)647{648new_slen[0] = int_scalefac_comp / 36 ;649new_slen[1] = (int_scalefac_comp % 36 ) / 6 ;650new_slen[2] = (int_scalefac_comp % 36) % 6;651new_slen[3] = 0;652si.ch[ch].gr[gr].preflag = 0;653blocknumber = 3;654} else if (int_scalefac_comp < 244) {655new_slen[0] = ((int_scalefac_comp - 180 ) & 0x3F) >>> 4 ;656new_slen[1] = ((int_scalefac_comp - 180) & 0xF) >>> 2 ;657new_slen[2] = (int_scalefac_comp - 180 ) & 3 ;658new_slen[3] = 0;659si.ch[ch].gr[gr].preflag = 0;660blocknumber = 4;661} else if (int_scalefac_comp < 255) {662new_slen[0] = (int_scalefac_comp - 244 ) / 3 ;663new_slen[1] = (int_scalefac_comp - 244 ) % 3 ;664new_slen[2] = 0 ;665new_slen[3] = 0;666si.ch[ch].gr[gr].preflag = 0;667blocknumber = 5;668}669}670671for (int x=0; x<45; x++) // why 45, not 54?672scalefac_buffer[x] = 0;673674m = 0;675for (int i=0; i<4;i++) {676for (int j = 0; j < nr_of_sfb_block[blocknumber][blocktypenumber][i];677j++)678{679scalefac_buffer[m] = (new_slen[i] == 0) ? 0 :680br.hgetbits(new_slen[i]);681m++;682683} // for (unint32 j ...684} // for (uint32 i ...685}686687/**688*689*/690private void get_LSF_scale_factors(int ch, int gr)691{692int m = 0;693int sfb, window;694gr_info_s gr_info = (si.ch[ch].gr[gr]);695696get_LSF_scale_data(ch, gr);697698if ((gr_info.window_switching_flag != 0) && (gr_info.block_type == 2)) {699if (gr_info.mixed_block_flag != 0) { // MIXED700for (sfb = 0; sfb < 8; sfb++)701{702scalefac[ch].l[sfb] = scalefac_buffer[m];703m++;704}705for (sfb = 3; sfb < 12; sfb++) {706for (window=0; window<3; window++)707{708scalefac[ch].s[window][sfb] = scalefac_buffer[m];709m++;710}711}712for (window=0; window<3; window++)713scalefac[ch].s[window][12] = 0;714715} else { // SHORT716717for (sfb = 0; sfb < 12; sfb++) {718for (window=0; window<3; window++)719{720scalefac[ch].s[window][sfb] = scalefac_buffer[m];721m++;722}723}724725for (window=0; window<3; window++)726scalefac[ch].s[window][12] = 0;727}728} else { // LONG types 0,1,3729730for (sfb = 0; sfb < 21; sfb++) {731scalefac[ch].l[sfb] = scalefac_buffer[m];732m++;733}734scalefac[ch].l[21] = 0; // Jeff735scalefac[ch].l[22] = 0;736}737}738739/**740*741*/742int[] x = {0};743int[] y = {0};744int[] v = {0};745int[] w = {0};746private void huffman_decode(int ch, int gr)747{748x[0] = 0;749y[0] = 0;750v[0] = 0;751w[0] = 0;752753int part2_3_end = part2_start + si.ch[ch].gr[gr].part2_3_length;754int num_bits;755int region1Start;756int region2Start;757int index;758759int buf, buf1;760761huffcodetab h;762763// Find region boundary for short block case764765if ( ((si.ch[ch].gr[gr].window_switching_flag) != 0) &&766(si.ch[ch].gr[gr].block_type == 2) ) {767768// Region2.769//MS: Extrahandling for 8KHZ770region1Start = (sfreq == 8) ? 72 : 36; // sfb[9/3]*3=36 or in case 8KHZ = 72771region2Start = 576; // No Region2 for short block case772773} else { // Find region boundary for long block case774775buf = si.ch[ch].gr[gr].region0_count + 1;776buf1 = buf + si.ch[ch].gr[gr].region1_count + 1;777778if(buf1 > sfBandIndex[sfreq].l.length - 1) buf1 = sfBandIndex[sfreq].l.length - 1;779780region1Start = sfBandIndex[sfreq].l[buf];781region2Start = sfBandIndex[sfreq].l[buf1]; /* MI */782}783784index = 0;785// Read bigvalues area786for (int i=0; i<(si.ch[ch].gr[gr].big_values<<1); i+=2) {787if (i<region1Start) h = huffcodetab.ht[si.ch[ch].gr[gr].table_select[0]];788else if (i<region2Start) h = huffcodetab.ht[si.ch[ch].gr[gr].table_select[1]];789else h = huffcodetab.ht[si.ch[ch].gr[gr].table_select[2]];790791huffcodetab.huffman_decoder(h, x, y, v, w, br);792//if (index >= is_1d.length) System.out.println("i0="+i+"/"+(si.ch[ch].gr[gr].big_values<<1)+" Index="+index+" is_1d="+is_1d.length);793794is_1d[index++] = x[0];795is_1d[index++] = y[0];796797CheckSumHuff = CheckSumHuff + x[0] + y[0];798// System.out.println("x = "+x[0]+" y = "+y[0]);799}800801// Read count1 area802h = huffcodetab.ht[si.ch[ch].gr[gr].count1table_select+32];803num_bits = br.hsstell();804805while ((num_bits < part2_3_end) && (index < 576)) {806807huffcodetab.huffman_decoder(h, x, y, v, w, br);808809is_1d[index++] = v[0];810is_1d[index++] = w[0];811is_1d[index++] = x[0];812is_1d[index++] = y[0];813CheckSumHuff = CheckSumHuff + v[0] + w[0] + x[0] + y[0];814// System.out.println("v = "+v[0]+" w = "+w[0]);815// System.out.println("x = "+x[0]+" y = "+y[0]);816num_bits = br.hsstell();817}818819if (num_bits > part2_3_end) {820br.rewindNbits(num_bits - part2_3_end);821index-=4;822}823824num_bits = br.hsstell();825826// Dismiss stuffing bits827if (num_bits < part2_3_end)828br.hgetbits(part2_3_end - num_bits);829830// Zero out rest831832if (index < 576)833nonzero[ch] = index;834else835nonzero[ch] = 576;836837if (index < 0) index = 0;838839// may not be necessary840for (; index<576; index++)841is_1d[index] = 0;842}843844/**845*846*/847private void i_stereo_k_values(int is_pos, int io_type, int i)848{849if (is_pos == 0) {850k[0][i] = 1.0f;851k[1][i] = 1.0f;852} else if ((is_pos & 1) != 0) {853k[0][i] = io[io_type][(is_pos + 1) >>> 1];854k[1][i] = 1.0f;855} else {856k[0][i] = 1.0f;857k[1][i] = io[io_type][is_pos >>> 1];858}859}860861/**862*863*/864private void dequantize_sample(float xr[][], int ch, int gr)865{866gr_info_s gr_info = (si.ch[ch].gr[gr]);867int cb=0;868int next_cb_boundary;869int cb_begin = 0;870int cb_width = 0;871int index=0, t_index, j;872float g_gain;873float[][] xr_1d = xr;874875// choose correct scalefactor band per block type, initalize boundary876877if ((gr_info.window_switching_flag !=0 ) && (gr_info.block_type == 2) ) {878if (gr_info.mixed_block_flag != 0)879next_cb_boundary=sfBandIndex[sfreq].l[1]; // LONG blocks: 0,1,3880else {881cb_width = sfBandIndex[sfreq].s[1];882next_cb_boundary = (cb_width << 2) - cb_width;883cb_begin = 0;884}885} else {886next_cb_boundary=sfBandIndex[sfreq].l[1]; // LONG blocks: 0,1,3887}888889// Compute overall (global) scaling.890891g_gain = (float) Math.pow(2.0 , (0.25 * (gr_info.global_gain - 210.0)));892893for (j=0; j<nonzero[ch]; j++)894{895// Modif E.B 02/22/99896int reste = j % SSLIMIT;897int quotien = (int) ((j-reste)/SSLIMIT);898if (is_1d[j] == 0) xr_1d[quotien][reste] = 0.0f;899else900{901int abv = is_1d[j];902// Pow Array fix (11/17/04)903if (abv < t_43.length)904{905if (is_1d[j] > 0) xr_1d[quotien][reste] = g_gain * t_43[abv];906else907{908if (-abv < t_43.length) xr_1d[quotien][reste] = -g_gain * t_43[-abv];909else xr_1d[quotien][reste] = -g_gain * (float)Math.pow(-abv, d43);910}911}912else913{914if (is_1d[j] > 0) xr_1d[quotien][reste] = g_gain * (float)Math.pow(abv, d43);915else xr_1d[quotien][reste] = -g_gain * (float)Math.pow(-abv, d43);916}917}918}919920// apply formula per block type921for (j=0; j<nonzero[ch]; j++)922{923// Modif E.B 02/22/99924int reste = j % SSLIMIT;925int quotien = (int) ((j-reste)/SSLIMIT);926927if (index == next_cb_boundary) { /* Adjust critical band boundary */928if ((gr_info.window_switching_flag != 0) && (gr_info.block_type == 2)) {929if (gr_info.mixed_block_flag != 0) {930931if (index == sfBandIndex[sfreq].l[8]) {932next_cb_boundary = sfBandIndex[sfreq].s[4];933next_cb_boundary = (next_cb_boundary << 2) -934next_cb_boundary;935cb = 3;936cb_width = sfBandIndex[sfreq].s[4] -937sfBandIndex[sfreq].s[3];938939cb_begin = sfBandIndex[sfreq].s[3];940cb_begin = (cb_begin << 2) - cb_begin;941942} else if (index < sfBandIndex[sfreq].l[8]) {943944next_cb_boundary = sfBandIndex[sfreq].l[(++cb)+1];945946} else {947948next_cb_boundary = sfBandIndex[sfreq].s[(++cb)+1];949next_cb_boundary = (next_cb_boundary << 2) -950next_cb_boundary;951952cb_begin = sfBandIndex[sfreq].s[cb];953cb_width = sfBandIndex[sfreq].s[cb+1] -954cb_begin;955cb_begin = (cb_begin << 2) - cb_begin;956}957958} else {959960next_cb_boundary = sfBandIndex[sfreq].s[(++cb)+1];961next_cb_boundary = (next_cb_boundary << 2) -962next_cb_boundary;963964cb_begin = sfBandIndex[sfreq].s[cb];965cb_width = sfBandIndex[sfreq].s[cb+1] -966cb_begin;967cb_begin = (cb_begin << 2) - cb_begin;968}969970} else { // long blocks971972next_cb_boundary = sfBandIndex[sfreq].l[(++cb)+1];973974}975}976977// Do long/short dependent scaling operations978979if ((gr_info.window_switching_flag !=0)&&980(((gr_info.block_type == 2) && (gr_info.mixed_block_flag == 0)) ||981((gr_info.block_type == 2) && (gr_info.mixed_block_flag!=0) && (j >= 36)) ))982{983984t_index = (index - cb_begin) / cb_width;985/* xr[sb][ss] *= pow(2.0, ((-2.0 * gr_info.subblock_gain[t_index])986-(0.5 * (1.0 + gr_info.scalefac_scale)987* scalefac[ch].s[t_index][cb]))); */988int idx = scalefac[ch].s[t_index][cb]989<< gr_info.scalefac_scale;990idx += (gr_info.subblock_gain[t_index] << 2);991992xr_1d[quotien][reste] *= two_to_negative_half_pow[idx];993994} else { // LONG block types 0,1,3 & 1st 2 subbands of switched blocks995/* xr[sb][ss] *= pow(2.0, -0.5 * (1.0+gr_info.scalefac_scale)996* (scalefac[ch].l[cb]997+ gr_info.preflag * pretab[cb])); */998int idx = scalefac[ch].l[cb];9991000if (gr_info.preflag != 0)1001idx += pretab[cb];10021003idx = idx << gr_info.scalefac_scale;1004xr_1d[quotien][reste] *= two_to_negative_half_pow[idx];1005}1006index++;1007}10081009for (j=nonzero[ch]; j<576; j++)1010{1011// Modif E.B 02/22/991012int reste = j % SSLIMIT;1013int quotien = (int) ((j-reste)/SSLIMIT);1014if(reste < 0) reste = 0;1015if(quotien < 0) quotien = 0;1016xr_1d[quotien][reste] = 0.0f;1017}10181019return;1020}10211022/**1023*1024*/1025private void reorder(float xr[][], int ch, int gr)1026{1027gr_info_s gr_info = (si.ch[ch].gr[gr]);1028int freq, freq3;1029int index;1030int sfb, sfb_start, sfb_lines;1031int src_line, des_line;1032float[][] xr_1d = xr;10331034if ((gr_info.window_switching_flag !=0) && (gr_info.block_type == 2)) {10351036for(index=0; index<576; index++)1037out_1d[index] = 0.0f;10381039if (gr_info.mixed_block_flag !=0 ) {1040// NO REORDER FOR LOW 2 SUBBANDS1041for (index = 0; index < 36; index++)1042{1043// Modif E.B 02/22/991044int reste = index % SSLIMIT;1045int quotien = (int) ((index-reste)/SSLIMIT);1046out_1d[index] = xr_1d[quotien][reste];1047}1048// REORDERING FOR REST SWITCHED SHORT1049/*for( sfb=3,sfb_start=sfBandIndex[sfreq].s[3],1050sfb_lines=sfBandIndex[sfreq].s[4] - sfb_start;1051sfb < 13; sfb++,sfb_start = sfBandIndex[sfreq].s[sfb],1052sfb_lines = sfBandIndex[sfreq].s[sfb+1] - sfb_start )1053{*/1054for( sfb=3; sfb < 13; sfb++)1055{1056//System.out.println("sfreq="+sfreq+" sfb="+sfb+" sfBandIndex="+sfBandIndex.length+" sfBandIndex[sfreq].s="+sfBandIndex[sfreq].s.length);1057sfb_start = sfBandIndex[sfreq].s[sfb];1058sfb_lines = sfBandIndex[sfreq].s[sfb+1] - sfb_start;10591060int sfb_start3 = (sfb_start << 2) - sfb_start;10611062for(freq=0, freq3=0; freq<sfb_lines;1063freq++, freq3+=3) {10641065src_line = sfb_start3 + freq;1066des_line = sfb_start3 + freq3;1067// Modif E.B 02/22/991068int reste = src_line % SSLIMIT;1069int quotien = (int) ((src_line-reste)/SSLIMIT);10701071out_1d[des_line] = xr_1d[quotien][reste];1072src_line += sfb_lines;1073des_line++;10741075reste = src_line % SSLIMIT;1076quotien = (int) ((src_line-reste)/SSLIMIT);10771078out_1d[des_line] = xr_1d[quotien][reste];1079src_line += sfb_lines;1080des_line++;10811082reste = src_line % SSLIMIT;1083quotien = (int) ((src_line-reste)/SSLIMIT);10841085out_1d[des_line] = xr_1d[quotien][reste];1086}1087}10881089} else { // pure short1090for(index=0;index<576;index++)1091{1092int j = reorder_table[sfreq][index];1093int reste = j % SSLIMIT;1094int quotien = (int) ((j-reste)/SSLIMIT);1095out_1d[index] = xr_1d[quotien][reste];1096}1097}1098}1099else { // long blocks1100for(index=0; index<576; index++)1101{1102// Modif E.B 02/22/991103int reste = index % SSLIMIT;1104int quotien = (int) ((index-reste)/SSLIMIT);1105out_1d[index] = xr_1d[quotien][reste];1106}1107}1108}11091110/**1111*1112*/11131114int[] is_pos = new int[576];1115float[] is_ratio = new float[576];11161117private void stereo(int gr)1118{1119int sb, ss;11201121if (channels == 1) { // mono , bypass xr[0][][] to lr[0][][]11221123for(sb=0;sb<SBLIMIT;sb++)1124for(ss=0;ss<SSLIMIT;ss+=3) {1125lr[0][sb][ss] = ro[0][sb][ss];1126lr[0][sb][ss+1] = ro[0][sb][ss+1];1127lr[0][sb][ss+2] = ro[0][sb][ss+2];1128}11291130} else {11311132gr_info_s gr_info = (si.ch[0].gr[gr]);1133int mode_ext = header.mode_extension();1134int sfb;1135int i;1136int lines, temp, temp2;11371138boolean ms_stereo = ((header.mode() == Header.JOINT_STEREO) && ((mode_ext & 0x2)!=0));1139boolean i_stereo = ((header.mode() == Header.JOINT_STEREO) && ((mode_ext & 0x1)!=0));1140boolean lsf = ((header.version() == Header.MPEG2_LSF || header.version() == Header.MPEG25_LSF )); // SZD11411142int io_type = (gr_info.scalefac_compress & 1);11431144// initialization11451146for (i=0; i<576; i++)1147{1148is_pos[i] = 7;11491150is_ratio[i] = 0.0f;1151}11521153if (i_stereo) {1154if ((gr_info.window_switching_flag !=0 )&& (gr_info.block_type == 2)) {1155if (gr_info.mixed_block_flag != 0) {11561157int max_sfb = 0;11581159for (int j=0; j<3; j++) {1160int sfbcnt;1161sfbcnt = 2;1162for( sfb=12; sfb >=3; sfb-- ) {1163i = sfBandIndex[sfreq].s[sfb];1164lines = sfBandIndex[sfreq].s[sfb+1] - i;1165i = (i << 2) - i + (j+1) * lines - 1;11661167while (lines > 0) {1168if (ro[1][i/18][i%18] != 0.0f) {1169// MDM: in java, array access is very slow.1170// Is quicker to compute div and mod values.1171//if (ro[1][ss_div[i]][ss_mod[i]] != 0.0f) {1172sfbcnt = sfb;1173sfb = -10;1174lines = -10;1175}11761177lines--;1178i--;11791180} // while (lines > 0)11811182} // for (sfb=12 ...1183sfb = sfbcnt + 1;11841185if (sfb > max_sfb)1186max_sfb = sfb;11871188while(sfb < 12) {1189temp = sfBandIndex[sfreq].s[sfb];1190sb = sfBandIndex[sfreq].s[sfb+1] - temp;1191i = (temp << 2) - temp + j * sb;11921193for ( ; sb > 0; sb--) {1194is_pos[i] = scalefac[1].s[j][sfb];1195if (is_pos[i] != 7)1196if (lsf)1197i_stereo_k_values(is_pos[i], io_type, i);1198else1199is_ratio[i] = TAN12[is_pos[i]];12001201i++;1202} // for (; sb>0...1203sfb++;1204} // while (sfb < 12)1205sfb = sfBandIndex[sfreq].s[10];1206sb = sfBandIndex[sfreq].s[11] - sfb;1207sfb = (sfb << 2) - sfb + j * sb;1208temp = sfBandIndex[sfreq].s[11];1209sb = sfBandIndex[sfreq].s[12] - temp;1210i = (temp << 2) - temp + j * sb;12111212for (; sb > 0; sb--) {1213is_pos[i] = is_pos[sfb];12141215if (lsf) {1216k[0][i] = k[0][sfb];1217k[1][i] = k[1][sfb];1218} else {1219is_ratio[i] = is_ratio[sfb];1220}1221i++;1222} // for (; sb > 0 ...1223}1224if (max_sfb <= 3) {1225i = 2;1226ss = 17;1227sb = -1;1228while (i >= 0) {1229if (ro[1][i][ss] != 0.0f) {1230sb = (i<<4) + (i<<1) + ss;1231i = -1;1232} else {1233ss--;1234if (ss < 0) {1235i--;1236ss = 17;1237}1238} // if (ro ...1239} // while (i>=0)1240i = 0;1241while (sfBandIndex[sfreq].l[i] <= sb)1242i++;1243sfb = i;1244i = sfBandIndex[sfreq].l[i];1245for (; sfb<8; sfb++) {1246sb = sfBandIndex[sfreq].l[sfb+1]-sfBandIndex[sfreq].l[sfb];1247for (; sb>0; sb--) {1248is_pos[i] = scalefac[1].l[sfb];1249if (is_pos[i] != 7)1250if (lsf)1251i_stereo_k_values(is_pos[i], io_type, i);1252else1253is_ratio[i] = TAN12[is_pos[i]];1254i++;1255} // for (; sb>0 ...1256} // for (; sfb<8 ...1257} // for (j=0 ...1258} else { // if (gr_info.mixed_block_flag)1259for (int j=0; j<3; j++) {1260int sfbcnt;1261sfbcnt = -1;1262for( sfb=12; sfb >=0; sfb-- )1263{1264temp = sfBandIndex[sfreq].s[sfb];1265lines = sfBandIndex[sfreq].s[sfb+1] - temp;1266i = (temp << 2) - temp + (j+1) * lines - 1;12671268while (lines > 0) {1269if (ro[1][i/18][i%18] != 0.0f) {1270// MDM: in java, array access is very slow.1271// Is quicker to compute div and mod values.1272//if (ro[1][ss_div[i]][ss_mod[i]] != 0.0f) {1273sfbcnt = sfb;1274sfb = -10;1275lines = -10;1276}1277lines--;1278i--;1279} // while (lines > 0) */12801281} // for (sfb=12 ...1282sfb = sfbcnt + 1;1283while(sfb<12) {1284temp = sfBandIndex[sfreq].s[sfb];1285sb = sfBandIndex[sfreq].s[sfb+1] - temp;1286i = (temp << 2) - temp + j * sb;1287for ( ; sb > 0; sb--) {1288is_pos[i] = scalefac[1].s[j][sfb];1289if (is_pos[i] != 7)1290if (lsf)1291i_stereo_k_values(is_pos[i], io_type, i);1292else1293is_ratio[i] = TAN12[is_pos[i]];1294i++;1295} // for (; sb>0 ...1296sfb++;1297} // while (sfb<12)12981299temp = sfBandIndex[sfreq].s[10];1300temp2= sfBandIndex[sfreq].s[11];1301sb = temp2 - temp;1302sfb = (temp << 2) - temp + j * sb;1303sb = sfBandIndex[sfreq].s[12] - temp2;1304i = (temp2 << 2) - temp2 + j * sb;13051306for (; sb>0; sb--) {1307is_pos[i] = is_pos[sfb];13081309if (lsf) {1310k[0][i] = k[0][sfb];1311k[1][i] = k[1][sfb];1312} else {1313is_ratio[i] = is_ratio[sfb];1314}1315i++;1316} // for (; sb>0 ...1317} // for (sfb=121318} // for (j=0 ...1319} else { // if (gr_info.window_switching_flag ...1320i = 31;1321ss = 17;1322sb = 0;1323while (i >= 0) {1324if (ro[1][i][ss] != 0.0f) {1325sb = (i<<4) + (i<<1) + ss;1326i = -1;1327} else {1328ss--;1329if (ss < 0) {1330i--;1331ss = 17;1332}1333}1334}1335i = 0;1336while (sfBandIndex[sfreq].l[i] <= sb)1337i++;13381339sfb = i;1340i = sfBandIndex[sfreq].l[i];1341for (; sfb<21; sfb++) {1342sb = sfBandIndex[sfreq].l[sfb+1] - sfBandIndex[sfreq].l[sfb];1343for (; sb > 0; sb--) {1344is_pos[i] = scalefac[1].l[sfb];1345if (is_pos[i] != 7)1346if (lsf)1347i_stereo_k_values(is_pos[i], io_type, i);1348else1349is_ratio[i] = TAN12[is_pos[i]];1350i++;1351}1352}1353sfb = sfBandIndex[sfreq].l[20];1354for (sb = 576 - sfBandIndex[sfreq].l[21]; (sb > 0) && (i<576); sb--)1355{1356is_pos[i] = is_pos[sfb]; // error here : i >=57613571358if (lsf) {1359k[0][i] = k[0][sfb];1360k[1][i] = k[1][sfb];1361} else {1362is_ratio[i] = is_ratio[sfb];1363}1364i++;1365} // if (gr_info.mixed_block_flag)1366} // if (gr_info.window_switching_flag ...1367} // if (i_stereo)13681369i = 0;1370for(sb=0;sb<SBLIMIT;sb++)1371for(ss=0;ss<SSLIMIT;ss++) {1372if (is_pos[i] == 7) {1373if (ms_stereo) {1374lr[0][sb][ss] = (ro[0][sb][ss]+ro[1][sb][ss]) * 0.707106781f;1375lr[1][sb][ss] = (ro[0][sb][ss]-ro[1][sb][ss]) * 0.707106781f;1376} else {1377lr[0][sb][ss] = ro[0][sb][ss];1378lr[1][sb][ss] = ro[1][sb][ss];1379}1380}1381else if (i_stereo) {13821383if (lsf) {1384lr[0][sb][ss] = ro[0][sb][ss] * k[0][i];1385lr[1][sb][ss] = ro[0][sb][ss] * k[1][i];1386} else {1387lr[1][sb][ss] = ro[0][sb][ss] / (float) (1 + is_ratio[i]);1388lr[0][sb][ss] = lr[1][sb][ss] * is_ratio[i];1389}1390}1391/* else {1392System.out.println("Error in stereo processing\n");1393} */1394i++;1395}13961397} // channels == 213981399}14001401/**1402*1403*/1404private void antialias(int ch, int gr)1405{1406int sb18, ss, sb18lim;1407gr_info_s gr_info = (si.ch[ch].gr[gr]);1408// 31 alias-reduction operations between each pair of sub-bands1409// with 8 butterflies between each pair14101411if ((gr_info.window_switching_flag !=0) && (gr_info.block_type == 2) &&1412!(gr_info.mixed_block_flag != 0) )1413return;14141415if ((gr_info.window_switching_flag !=0) && (gr_info.mixed_block_flag != 0)&&1416(gr_info.block_type == 2)) {1417sb18lim = 18;1418} else {1419sb18lim = 558;1420}14211422for (sb18=0; sb18 < sb18lim; sb18+=18) {1423for (ss=0;ss<8;ss++) {1424int src_idx1 = sb18 + 17 - ss;1425int src_idx2 = sb18 + 18 + ss;1426float bu = out_1d[src_idx1];1427float bd = out_1d[src_idx2];1428out_1d[src_idx1] = (bu * cs[ss]) - (bd * ca[ss]);1429out_1d[src_idx2] = (bd * cs[ss]) + (bu * ca[ss]);1430}1431}1432}14331434/**1435*1436*/14371438// MDM: tsOutCopy and rawout do not need initializing, so the arrays1439// can be reused.1440float[] tsOutCopy = new float[18];1441float[] rawout = new float[36];14421443private void hybrid(int ch, int gr)1444{1445int bt;1446int sb18;1447gr_info_s gr_info = (si.ch[ch].gr[gr]);1448float[] tsOut;14491450float[][] prvblk;14511452for(sb18=0;sb18<576;sb18+=18)1453{1454bt = ((gr_info.window_switching_flag !=0 ) && (gr_info.mixed_block_flag !=0) &&1455(sb18 < 36)) ? 0 : gr_info.block_type;14561457tsOut = out_1d;1458// Modif E.B 02/22/991459System.arraycopy(tsOut, 0 + sb18, tsOutCopy, 0, 18);14601461inv_mdct(tsOutCopy, rawout, bt);14621463System.arraycopy(tsOutCopy, 0, tsOut, 0 + sb18, 18);1464// Fin Modif14651466// overlap addition1467prvblk = prevblck;14681469tsOut[0 + sb18] = rawout[0] + prvblk[ch][sb18 + 0];1470prvblk[ch][sb18 + 0] = rawout[18];1471tsOut[1 + sb18] = rawout[1] + prvblk[ch][sb18 + 1];1472prvblk[ch][sb18 + 1] = rawout[19];1473tsOut[2 + sb18] = rawout[2] + prvblk[ch][sb18 + 2];1474prvblk[ch][sb18 + 2] = rawout[20];1475tsOut[3 + sb18] = rawout[3] + prvblk[ch][sb18 + 3];1476prvblk[ch][sb18 + 3] = rawout[21];1477tsOut[4 + sb18] = rawout[4] + prvblk[ch][sb18 + 4];1478prvblk[ch][sb18 + 4] = rawout[22];1479tsOut[5 + sb18] = rawout[5] + prvblk[ch][sb18 + 5];1480prvblk[ch][sb18 + 5] = rawout[23];1481tsOut[6 + sb18] = rawout[6] + prvblk[ch][sb18 + 6];1482prvblk[ch][sb18 + 6] = rawout[24];1483tsOut[7 + sb18] = rawout[7] + prvblk[ch][sb18 + 7];1484prvblk[ch][sb18 + 7] = rawout[25];1485tsOut[8 + sb18] = rawout[8] + prvblk[ch][sb18 + 8];1486prvblk[ch][sb18 + 8] = rawout[26];1487tsOut[9 + sb18] = rawout[9] + prvblk[ch][sb18 + 9];1488prvblk[ch][sb18 + 9] = rawout[27];1489tsOut[10 + sb18] = rawout[10] + prvblk[ch][sb18 + 10];1490prvblk[ch][sb18 + 10] = rawout[28];1491tsOut[11 + sb18] = rawout[11] + prvblk[ch][sb18 + 11];1492prvblk[ch][sb18 + 11] = rawout[29];1493tsOut[12 + sb18] = rawout[12] + prvblk[ch][sb18 + 12];1494prvblk[ch][sb18 + 12] = rawout[30];1495tsOut[13 + sb18] = rawout[13] + prvblk[ch][sb18 + 13];1496prvblk[ch][sb18 + 13] = rawout[31];1497tsOut[14 + sb18] = rawout[14] + prvblk[ch][sb18 + 14];1498prvblk[ch][sb18 + 14] = rawout[32];1499tsOut[15 + sb18] = rawout[15] + prvblk[ch][sb18 + 15];1500prvblk[ch][sb18 + 15] = rawout[33];1501tsOut[16 + sb18] = rawout[16] + prvblk[ch][sb18 + 16];1502prvblk[ch][sb18 + 16] = rawout[34];1503tsOut[17 + sb18] = rawout[17] + prvblk[ch][sb18 + 17];1504prvblk[ch][sb18 + 17] = rawout[35];1505}1506}15071508/**1509*1510*/1511private void do_downmix()1512{1513for (int sb=0; sb<SSLIMIT; sb++) {1514for (int ss=0; ss<SSLIMIT; ss+=3) {1515lr[0][sb][ss] = (lr[0][sb][ss] + lr[1][sb][ss]) * 0.5f;1516lr[0][sb][ss+1] = (lr[0][sb][ss+1] + lr[1][sb][ss+1]) * 0.5f;1517lr[0][sb][ss+2] = (lr[0][sb][ss+2] + lr[1][sb][ss+2]) * 0.5f;1518}1519}1520}15211522/**1523* Fast INV_MDCT.1524*/15251526public void inv_mdct(float[] in, float[] out, int block_type)1527{1528float[] win_bt;1529int i;15301531float tmpf_0, tmpf_1, tmpf_2, tmpf_3, tmpf_4, tmpf_5, tmpf_6, tmpf_7, tmpf_8, tmpf_9;1532float tmpf_10, tmpf_11, tmpf_12, tmpf_13, tmpf_14, tmpf_15, tmpf_16, tmpf_17;15331534tmpf_0 = tmpf_1 = tmpf_2 = tmpf_3 = tmpf_4 = tmpf_5 = tmpf_6 = tmpf_7 = tmpf_8 = tmpf_9 =1535tmpf_10 = tmpf_11 = tmpf_12 = tmpf_13 = tmpf_14 = tmpf_15 = tmpf_16 = tmpf_17 = 0.0f;1536153715381539if(block_type == 2)1540{15411542/*1543*1544* Under MicrosoftVM 2922, This causes a GPF, or1545* At best, an ArrayIndexOutOfBoundsExceptin.1546for(int p=0;p<36;p+=9)1547{1548out[p] = out[p+1] = out[p+2] = out[p+3] =1549out[p+4] = out[p+5] = out[p+6] = out[p+7] =1550out[p+8] = 0.0f;1551}1552*/1553out[0] = 0.0f;1554out[1] = 0.0f;1555out[2] = 0.0f;1556out[3] = 0.0f;1557out[4] = 0.0f;1558out[5] = 0.0f;1559out[6] = 0.0f;1560out[7] = 0.0f;1561out[8] = 0.0f;1562out[9] = 0.0f;1563out[10] = 0.0f;1564out[11] = 0.0f;1565out[12] = 0.0f;1566out[13] = 0.0f;1567out[14] = 0.0f;1568out[15] = 0.0f;1569out[16] = 0.0f;1570out[17] = 0.0f;1571out[18] = 0.0f;1572out[19] = 0.0f;1573out[20] = 0.0f;1574out[21] = 0.0f;1575out[22] = 0.0f;1576out[23] = 0.0f;1577out[24] = 0.0f;1578out[25] = 0.0f;1579out[26] = 0.0f;1580out[27] = 0.0f;1581out[28] = 0.0f;1582out[29] = 0.0f;1583out[30] = 0.0f;1584out[31] = 0.0f;1585out[32] = 0.0f;1586out[33] = 0.0f;1587out[34] = 0.0f;1588out[35] = 0.0f;15891590int six_i = 0;15911592for(i=0;i<3;i++)1593{1594// 12 point IMDCT1595// Begin 12 point IDCT1596// Input aliasing for 12 pt IDCT1597in[15+i] += in[12+i]; in[12+i] += in[9+i]; in[9+i] += in[6+i];1598in[6+i] += in[3+i]; in[3+i] += in[0+i];15991600// Input aliasing on odd indices (for 6 point IDCT)1601in[15+i] += in[9+i]; in[9+i] += in[3+i];16021603// 3 point IDCT on even indices1604float pp1, pp2, sum;1605pp2 = in[12+i] * 0.500000000f;1606pp1 = in[ 6+i] * 0.866025403f;1607sum = in[0+i] + pp2;1608tmpf_1 = in[0+i] - in[12+i];1609tmpf_0 = sum + pp1;1610tmpf_2 = sum - pp1;16111612// End 3 point IDCT on even indices1613// 3 point IDCT on odd indices (for 6 point IDCT)1614pp2 = in[15+i] * 0.500000000f;1615pp1 = in[ 9+i] * 0.866025403f;1616sum = in[ 3+i] + pp2;1617tmpf_4 = in[3+i] - in[15+i];1618tmpf_5 = sum + pp1;1619tmpf_3 = sum - pp1;1620// End 3 point IDCT on odd indices1621// Twiddle factors on odd indices (for 6 point IDCT)16221623tmpf_3 *= 1.931851653f;1624tmpf_4 *= 0.707106781f;1625tmpf_5 *= 0.517638090f;16261627// Output butterflies on 2 3 point IDCT's (for 6 point IDCT)1628float save = tmpf_0;1629tmpf_0 += tmpf_5;1630tmpf_5 = save - tmpf_5;1631save = tmpf_1;1632tmpf_1 += tmpf_4;1633tmpf_4 = save - tmpf_4;1634save = tmpf_2;1635tmpf_2 += tmpf_3;1636tmpf_3 = save - tmpf_3;16371638// End 6 point IDCT1639// Twiddle factors on indices (for 12 point IDCT)16401641tmpf_0 *= 0.504314480f;1642tmpf_1 *= 0.541196100f;1643tmpf_2 *= 0.630236207f;1644tmpf_3 *= 0.821339815f;1645tmpf_4 *= 1.306562965f;1646tmpf_5 *= 3.830648788f;16471648// End 12 point IDCT16491650// Shift to 12 point modified IDCT, multiply by window type 21651tmpf_8 = -tmpf_0 * 0.793353340f;1652tmpf_9 = -tmpf_0 * 0.608761429f;1653tmpf_7 = -tmpf_1 * 0.923879532f;1654tmpf_10 = -tmpf_1 * 0.382683432f;1655tmpf_6 = -tmpf_2 * 0.991444861f;1656tmpf_11 = -tmpf_2 * 0.130526192f;16571658tmpf_0 = tmpf_3;1659tmpf_1 = tmpf_4 * 0.382683432f;1660tmpf_2 = tmpf_5 * 0.608761429f;16611662tmpf_3 = -tmpf_5 * 0.793353340f;1663tmpf_4 = -tmpf_4 * 0.923879532f;1664tmpf_5 = -tmpf_0 * 0.991444861f;16651666tmpf_0 *= 0.130526192f;16671668out[six_i + 6] += tmpf_0;1669out[six_i + 7] += tmpf_1;1670out[six_i + 8] += tmpf_2;1671out[six_i + 9] += tmpf_3;1672out[six_i + 10] += tmpf_4;1673out[six_i + 11] += tmpf_5;1674out[six_i + 12] += tmpf_6;1675out[six_i + 13] += tmpf_7;1676out[six_i + 14] += tmpf_8;1677out[six_i + 15] += tmpf_9;1678out[six_i + 16] += tmpf_10;1679out[six_i + 17] += tmpf_11;16801681six_i += 6;1682}1683}1684else1685{1686// 36 point IDCT1687// input aliasing for 36 point IDCT1688in[17]+=in[16]; in[16]+=in[15]; in[15]+=in[14]; in[14]+=in[13];1689in[13]+=in[12]; in[12]+=in[11]; in[11]+=in[10]; in[10]+=in[9];1690in[9] +=in[8]; in[8] +=in[7]; in[7] +=in[6]; in[6] +=in[5];1691in[5] +=in[4]; in[4] +=in[3]; in[3] +=in[2]; in[2] +=in[1];1692in[1] +=in[0];16931694// 18 point IDCT for odd indices1695// input aliasing for 18 point IDCT1696in[17]+=in[15]; in[15]+=in[13]; in[13]+=in[11]; in[11]+=in[9];1697in[9] +=in[7]; in[7] +=in[5]; in[5] +=in[3]; in[3] +=in[1];16981699float tmp0,tmp1,tmp2,tmp3,tmp4,tmp0_,tmp1_,tmp2_,tmp3_;1700float tmp0o,tmp1o,tmp2o,tmp3o,tmp4o,tmp0_o,tmp1_o,tmp2_o,tmp3_o;17011702// Fast 9 Point Inverse Discrete Cosine Transform1703//1704// By Francois-Raymond Boyer1705// mailto:[email protected]1706// http://www.iro.umontreal.ca/~boyerf1707//1708// The code has been optimized for Intel processors1709// (takes a lot of time to convert float to and from iternal FPU representation)1710//1711// It is a simple "factorization" of the IDCT matrix.17121713// 9 point IDCT on even indices17141715// 5 points on odd indices (not realy an IDCT)1716float i00 = in[0]+in[0];1717float iip12 = i00 + in[12];17181719tmp0 = iip12 + in[4]*1.8793852415718f + in[8]*1.532088886238f + in[16]*0.34729635533386f;1720tmp1 = i00 + in[4] - in[8] - in[12] - in[12] - in[16];1721tmp2 = iip12 - in[4]*0.34729635533386f - in[8]*1.8793852415718f + in[16]*1.532088886238f;1722tmp3 = iip12 - in[4]*1.532088886238f + in[8]*0.34729635533386f - in[16]*1.8793852415718f;1723tmp4 = in[0] - in[4] + in[8] - in[12] + in[16];17241725// 4 points on even indices1726float i66_ = in[6]*1.732050808f; // Sqrt[3]17271728tmp0_ = in[2]*1.9696155060244f + i66_ + in[10]*1.2855752193731f + in[14]*0.68404028665134f;1729tmp1_ = (in[2] - in[10] - in[14])*1.732050808f;1730tmp2_ = in[2]*1.2855752193731f - i66_ - in[10]*0.68404028665134f + in[14]*1.9696155060244f;1731tmp3_ = in[2]*0.68404028665134f - i66_ + in[10]*1.9696155060244f - in[14]*1.2855752193731f;17321733// 9 point IDCT on odd indices1734// 5 points on odd indices (not realy an IDCT)1735float i0 = in[0+1]+in[0+1];1736float i0p12 = i0 + in[12+1];17371738tmp0o = i0p12 + in[4+1]*1.8793852415718f + in[8+1]*1.532088886238f + in[16+1]*0.34729635533386f;1739tmp1o = i0 + in[4+1] - in[8+1] - in[12+1] - in[12+1] - in[16+1];1740tmp2o = i0p12 - in[4+1]*0.34729635533386f - in[8+1]*1.8793852415718f + in[16+1]*1.532088886238f;1741tmp3o = i0p12 - in[4+1]*1.532088886238f + in[8+1]*0.34729635533386f - in[16+1]*1.8793852415718f;1742tmp4o = (in[0+1] - in[4+1] + in[8+1] - in[12+1] + in[16+1])*0.707106781f; // Twiddled17431744// 4 points on even indices1745float i6_ = in[6+1]*1.732050808f; // Sqrt[3]17461747tmp0_o = in[2+1]*1.9696155060244f + i6_ + in[10+1]*1.2855752193731f + in[14+1]*0.68404028665134f;1748tmp1_o = (in[2+1] - in[10+1] - in[14+1])*1.732050808f;1749tmp2_o = in[2+1]*1.2855752193731f - i6_ - in[10+1]*0.68404028665134f + in[14+1]*1.9696155060244f;1750tmp3_o = in[2+1]*0.68404028665134f - i6_ + in[10+1]*1.9696155060244f - in[14+1]*1.2855752193731f;17511752// Twiddle factors on odd indices1753// and1754// Butterflies on 9 point IDCT's1755// and1756// twiddle factors for 36 point IDCT17571758float e, o;1759e = tmp0 + tmp0_; o = (tmp0o + tmp0_o)*0.501909918f; tmpf_0 = e + o; tmpf_17 = e - o;1760e = tmp1 + tmp1_; o = (tmp1o + tmp1_o)*0.517638090f; tmpf_1 = e + o; tmpf_16 = e - o;1761e = tmp2 + tmp2_; o = (tmp2o + tmp2_o)*0.551688959f; tmpf_2 = e + o; tmpf_15 = e - o;1762e = tmp3 + tmp3_; o = (tmp3o + tmp3_o)*0.610387294f; tmpf_3 = e + o; tmpf_14 = e - o;1763tmpf_4 = tmp4 + tmp4o; tmpf_13 = tmp4 - tmp4o;1764e = tmp3 - tmp3_; o = (tmp3o - tmp3_o)*0.871723397f; tmpf_5 = e + o; tmpf_12 = e - o;1765e = tmp2 - tmp2_; o = (tmp2o - tmp2_o)*1.183100792f; tmpf_6 = e + o; tmpf_11 = e - o;1766e = tmp1 - tmp1_; o = (tmp1o - tmp1_o)*1.931851653f; tmpf_7 = e + o; tmpf_10 = e - o;1767e = tmp0 - tmp0_; o = (tmp0o - tmp0_o)*5.736856623f; tmpf_8 = e + o; tmpf_9 = e - o;17681769// end 36 point IDCT */1770// shift to modified IDCT1771win_bt = win[block_type];17721773out[0] =-tmpf_9 * win_bt[0];1774out[1] =-tmpf_10 * win_bt[1];1775out[2] =-tmpf_11 * win_bt[2];1776out[3] =-tmpf_12 * win_bt[3];1777out[4] =-tmpf_13 * win_bt[4];1778out[5] =-tmpf_14 * win_bt[5];1779out[6] =-tmpf_15 * win_bt[6];1780out[7] =-tmpf_16 * win_bt[7];1781out[8] =-tmpf_17 * win_bt[8];1782out[9] = tmpf_17 * win_bt[9];1783out[10]= tmpf_16 * win_bt[10];1784out[11]= tmpf_15 * win_bt[11];1785out[12]= tmpf_14 * win_bt[12];1786out[13]= tmpf_13 * win_bt[13];1787out[14]= tmpf_12 * win_bt[14];1788out[15]= tmpf_11 * win_bt[15];1789out[16]= tmpf_10 * win_bt[16];1790out[17]= tmpf_9 * win_bt[17];1791out[18]= tmpf_8 * win_bt[18];1792out[19]= tmpf_7 * win_bt[19];1793out[20]= tmpf_6 * win_bt[20];1794out[21]= tmpf_5 * win_bt[21];1795out[22]= tmpf_4 * win_bt[22];1796out[23]= tmpf_3 * win_bt[23];1797out[24]= tmpf_2 * win_bt[24];1798out[25]= tmpf_1 * win_bt[25];1799out[26]= tmpf_0 * win_bt[26];1800out[27]= tmpf_0 * win_bt[27];1801out[28]= tmpf_1 * win_bt[28];1802out[29]= tmpf_2 * win_bt[29];1803out[30]= tmpf_3 * win_bt[30];1804out[31]= tmpf_4 * win_bt[31];1805out[32]= tmpf_5 * win_bt[32];1806out[33]= tmpf_6 * win_bt[33];1807out[34]= tmpf_7 * win_bt[34];1808out[35]= tmpf_8 * win_bt[35];1809}1810}18111812private int counter = 0;1813private static final int SSLIMIT=18;1814private static final int SBLIMIT=32;1815// Size of the table of whole numbers raised to 4/3 power.1816// This may be adjusted for performance without any problems.1817//public static final int POW_TABLE_LIMIT=512;18181819/************************************************************/1820/* L3TABLE */1821/************************************************************/18221823static class SBI1824{1825public int[] l;1826public int[] s;18271828public SBI()1829{1830l = new int[23];1831s = new int[14];1832}1833public SBI(int[] thel, int[] thes)1834{1835l = thel;1836s = thes;1837}1838}18391840static class gr_info_s1841{1842public int part2_3_length = 0;1843public int big_values = 0;1844public int global_gain = 0;1845public int scalefac_compress = 0;1846public int window_switching_flag = 0;1847public int block_type = 0;1848public int mixed_block_flag = 0;1849public int[] table_select;1850public int[] subblock_gain;1851public int region0_count = 0;1852public int region1_count = 0;1853public int preflag = 0;1854public int scalefac_scale = 0;1855public int count1table_select = 0;18561857/**1858* Dummy Constructor1859*/1860public gr_info_s()1861{1862table_select = new int[3];1863subblock_gain = new int[3];1864}1865}18661867static class temporaire1868{1869public int[] scfsi;1870public gr_info_s[] gr;18711872/**1873* Dummy Constructor1874*/1875public temporaire()1876{1877scfsi = new int[4];1878gr = new gr_info_s[2];1879gr[0] = new gr_info_s();1880gr[1] = new gr_info_s();1881}1882}18831884static class III_side_info_t1885{18861887public int main_data_begin = 0;1888public int private_bits = 0;1889public temporaire[] ch;1890/**1891* Dummy Constructor1892*/1893public III_side_info_t()1894{1895ch = new temporaire[2];1896ch[0] = new temporaire();1897ch[1] = new temporaire();1898}1899}19001901static class temporaire21902{1903public int[] l; /* [cb] */1904public int[][] s; /* [window][cb] */19051906/**1907* Dummy Constructor1908*/1909public temporaire2()1910{1911l = new int[23];1912s = new int[3][13];1913}1914}1915//class III_scalefac_t1916//{1917// public temporaire2[] tab;1918// /**1919// * Dummy Constructor1920// */1921// public III_scalefac_t()1922// {1923// tab = new temporaire2[2];1924// }1925//}19261927private static final int slen[][] =1928{1929{0, 0, 0, 0, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4},1930{0, 1, 2, 3, 0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 2, 3}1931};19321933public static final int pretab[] =1934{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 3, 2, 0};19351936private SBI[] sfBandIndex; // Init in the constructor.19371938public static final float two_to_negative_half_pow[] =1939{ 1.0000000000E+00f, 7.0710678119E-01f, 5.0000000000E-01f, 3.5355339059E-01f,19402.5000000000E-01f, 1.7677669530E-01f, 1.2500000000E-01f, 8.8388347648E-02f,19416.2500000000E-02f, 4.4194173824E-02f, 3.1250000000E-02f, 2.2097086912E-02f,19421.5625000000E-02f, 1.1048543456E-02f, 7.8125000000E-03f, 5.5242717280E-03f,19433.9062500000E-03f, 2.7621358640E-03f, 1.9531250000E-03f, 1.3810679320E-03f,19449.7656250000E-04f, 6.9053396600E-04f, 4.8828125000E-04f, 3.4526698300E-04f,19452.4414062500E-04f, 1.7263349150E-04f, 1.2207031250E-04f, 8.6316745750E-05f,19466.1035156250E-05f, 4.3158372875E-05f, 3.0517578125E-05f, 2.1579186438E-05f,19471.5258789062E-05f, 1.0789593219E-05f, 7.6293945312E-06f, 5.3947966094E-06f,19483.8146972656E-06f, 2.6973983047E-06f, 1.9073486328E-06f, 1.3486991523E-06f,19499.5367431641E-07f, 6.7434957617E-07f, 4.7683715820E-07f, 3.3717478809E-07f,19502.3841857910E-07f, 1.6858739404E-07f, 1.1920928955E-07f, 8.4293697022E-08f,19515.9604644775E-08f, 4.2146848511E-08f, 2.9802322388E-08f, 2.1073424255E-08f,19521.4901161194E-08f, 1.0536712128E-08f, 7.4505805969E-09f, 5.2683560639E-09f,19533.7252902985E-09f, 2.6341780319E-09f, 1.8626451492E-09f, 1.3170890160E-09f,19549.3132257462E-10f, 6.5854450798E-10f, 4.6566128731E-10f, 3.2927225399E-10f1955};195619571958public static final float t_43[] = create_t_43();19591960static private float[] create_t_43()1961{1962float[] t43 = new float[8192];1963final double d43 = (4.0/3.0);19641965for (int i=0; i<8192; i++)1966{1967t43[i] = (float)Math.pow(i, d43);1968}1969return t43;1970}19711972public static final float io[][] =1973{1974{ 1.0000000000E+00f, 8.4089641526E-01f, 7.0710678119E-01f, 5.9460355751E-01f,19755.0000000001E-01f, 4.2044820763E-01f, 3.5355339060E-01f, 2.9730177876E-01f,19762.5000000001E-01f, 2.1022410382E-01f, 1.7677669530E-01f, 1.4865088938E-01f,19771.2500000000E-01f, 1.0511205191E-01f, 8.8388347652E-02f, 7.4325444691E-02f,19786.2500000003E-02f, 5.2556025956E-02f, 4.4194173826E-02f, 3.7162722346E-02f,19793.1250000002E-02f, 2.6278012978E-02f, 2.2097086913E-02f, 1.8581361173E-02f,19801.5625000001E-02f, 1.3139006489E-02f, 1.1048543457E-02f, 9.2906805866E-03f,19817.8125000006E-03f, 6.5695032447E-03f, 5.5242717285E-03f, 4.6453402934E-03f },1982{ 1.0000000000E+00f, 7.0710678119E-01f, 5.0000000000E-01f, 3.5355339060E-01f,19832.5000000000E-01f, 1.7677669530E-01f, 1.2500000000E-01f, 8.8388347650E-02f,19846.2500000001E-02f, 4.4194173825E-02f, 3.1250000001E-02f, 2.2097086913E-02f,19851.5625000000E-02f, 1.1048543456E-02f, 7.8125000002E-03f, 5.5242717282E-03f,19863.9062500001E-03f, 2.7621358641E-03f, 1.9531250001E-03f, 1.3810679321E-03f,19879.7656250004E-04f, 6.9053396603E-04f, 4.8828125002E-04f, 3.4526698302E-04f,19882.4414062501E-04f, 1.7263349151E-04f, 1.2207031251E-04f, 8.6316745755E-05f,19896.1035156254E-05f, 4.3158372878E-05f, 3.0517578127E-05f, 2.1579186439E-05f }1990};1991199219931994public static final float TAN12[] =1995{19960.0f, 0.26794919f, 0.57735027f, 1.0f,19971.73205081f, 3.73205081f, 9.9999999e10f, -3.73205081f,1998-1.73205081f, -1.0f, -0.57735027f, -0.26794919f,19990.0f, 0.26794919f, 0.57735027f, 1.0f2000};20012002// REVIEW: in java, the array lookup may well be slower than2003// the actual calculation2004// 576 / 182005/*2006private static final int ss_div[] =2007{20080, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,20091, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,20102, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,20113, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,20124, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,20135, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,20146, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,20157, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,20168, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,20179, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,201810, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,201911, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,202012, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,202113, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,202214, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,202315, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,202416, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,202517, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,202618, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,202719, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,202820, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,202921, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,203022, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,203123, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,203224, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,203325, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,203426, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,203527, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,203628, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,203729, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,203830, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,203931, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 312040};20412042// 576 % 182043private static final int ss_mod[] =2044{20450, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,20460, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,20470, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,20480, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,20490, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,20500, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,20510, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,20520, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,20530, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,20540, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,20550, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,20560, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,20570, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,20580, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,20590, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,20600, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,20610, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,20620, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,20630, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,20640, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,20650, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,20660, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,20670, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,20680, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,20690, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,20700, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,20710, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,20720, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,20730, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,20740, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,20750, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,20760, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 172077};2078*/2079private static /*final*/ int reorder_table[][]/* = loadReorderTable()*/; // SZD: will be generated on demand20802081/**2082* Loads the data for the reorder2083*/2084/*private static int[][] loadReorderTable() // SZD: table will be generated2085{2086try2087{2088Class elemType = int[][].class.getComponentType();2089Object o = JavaLayerUtils.deserializeArrayResource("l3reorder.ser", elemType, 6);2090return (int[][])o;2091}2092catch (IOException ex)2093{2094throw new ExceptionInInitializerError(ex);2095}2096}*/20972098static int[] reorder(int scalefac_band[]) { // SZD: converted from LAME2099int j = 0;2100int ix[] = new int[576];2101for(int sfb = 0; sfb < 13; sfb++) {2102int start = scalefac_band[sfb];2103int end = scalefac_band[sfb + 1];2104for(int window = 0; window < 3; window++)2105for(int i = start; i < end; i++)2106ix[3 * i + window] = j++;2107}2108return ix;2109}21102111/*static final int reorder_table_data[][]; =2112{2113{ 0, 4, 8, 1, 5, 9, 2, 6, 10, 3, 7, 11, 12, 16, 20, 13,211417, 21, 14, 18, 22, 15, 19, 23, 24, 28, 32, 25, 29, 33, 26, 30,211534, 27, 31, 35, 36, 42, 48, 37, 43, 49, 38, 44, 50, 39, 45, 51,211640, 46, 52, 41, 47, 53, 54, 60, 66, 55, 61, 67, 56, 62, 68, 57,211763, 69, 58, 64, 70, 59, 65, 71, 72, 80, 88, 73, 81, 89, 74, 82,211890, 75, 83, 91, 76, 84, 92, 77, 85, 93, 78, 86, 94, 79, 87, 95,211996,106,116, 97,107,117, 98,108,118, 99,109,119,100,110,120,101,2120111,121,102,112,122,103,113,123,104,114,124,105,115,125,126,140,2121154,127,141,155,128,142,156,129,143,157,130,144,158,131,145,159,2122132,146,160,133,147,161,134,148,162,135,149,163,136,150,164,137,2123151,165,138,152,166,139,153,167,168,186,204,169,187,205,170,188,2124206,171,189,207,172,190,208,173,191,209,174,192,210,175,193,211,2125176,194,212,177,195,213,178,196,214,179,197,215,180,198,216,181,2126199,217,182,200,218,183,201,219,184,202,220,185,203,221,222,248,2127274,223,249,275,224,250,276,225,251,277,226,252,278,227,253,279,2128228,254,280,229,255,281,230,256,282,231,257,283,232,258,284,233,2129259,285,234,260,286,235,261,287,236,262,288,237,263,289,238,264,2130290,239,265,291,240,266,292,241,267,293,242,268,294,243,269,295,2131244,270,296,245,271,297,246,272,298,247,273,299,300,332,364,301,2132333,365,302,334,366,303,335,367,304,336,368,305,337,369,306,338,2133370,307,339,371,308,340,372,309,341,373,310,342,374,311,343,375,2134312,344,376,313,345,377,314,346,378,315,347,379,316,348,380,317,2135349,381,318,350,382,319,351,383,320,352,384,321,353,385,322,354,2136386,323,355,387,324,356,388,325,357,389,326,358,390,327,359,391,2137328,360,392,329,361,393,330,362,394,331,363,395,396,438,480,397,2138439,481,398,440,482,399,441,483,400,442,484,401,443,485,402,444,2139486,403,445,487,404,446,488,405,447,489,406,448,490,407,449,491,2140408,450,492,409,451,493,410,452,494,411,453,495,412,454,496,413,2141455,497,414,456,498,415,457,499,416,458,500,417,459,501,418,460,2142502,419,461,503,420,462,504,421,463,505,422,464,506,423,465,507,2143424,466,508,425,467,509,426,468,510,427,469,511,428,470,512,429,2144471,513,430,472,514,431,473,515,432,474,516,433,475,517,434,476,2145518,435,477,519,436,478,520,437,479,521,522,540,558,523,541,559,2146524,542,560,525,543,561,526,544,562,527,545,563,528,546,564,529,2147547,565,530,548,566,531,549,567,532,550,568,533,551,569,534,552,2148570,535,553,571,536,554,572,537,555,573,538,556,574,539,557,575},2149{ 0, 4, 8, 1, 5, 9, 2, 6, 10, 3, 7, 11, 12, 16, 20, 13,215017, 21, 14, 18, 22, 15, 19, 23, 24, 28, 32, 25, 29, 33, 26, 30,215134, 27, 31, 35, 36, 42, 48, 37, 43, 49, 38, 44, 50, 39, 45, 51,215240, 46, 52, 41, 47, 53, 54, 62, 70, 55, 63, 71, 56, 64, 72, 57,215365, 73, 58, 66, 74, 59, 67, 75, 60, 68, 76, 61, 69, 77, 78, 88,215498, 79, 89, 99, 80, 90,100, 81, 91,101, 82, 92,102, 83, 93,103,215584, 94,104, 85, 95,105, 86, 96,106, 87, 97,107,108,120,132,109,2156121,133,110,122,134,111,123,135,112,124,136,113,125,137,114,126,2157138,115,127,139,116,128,140,117,129,141,118,130,142,119,131,143,2158144,158,172,145,159,173,146,160,174,147,161,175,148,162,176,149,2159163,177,150,164,178,151,165,179,152,166,180,153,167,181,154,168,2160182,155,169,183,156,170,184,157,171,185,186,204,222,187,205,223,2161188,206,224,189,207,225,190,208,226,191,209,227,192,210,228,193,2162211,229,194,212,230,195,213,231,196,214,232,197,215,233,198,216,2163234,199,217,235,200,218,236,201,219,237,202,220,238,203,221,239,2164240,264,288,241,265,289,242,266,290,243,267,291,244,268,292,245,2165269,293,246,270,294,247,271,295,248,272,296,249,273,297,250,274,2166298,251,275,299,252,276,300,253,277,301,254,278,302,255,279,303,2167256,280,304,257,281,305,258,282,306,259,283,307,260,284,308,261,2168285,309,262,286,310,263,287,311,312,344,376,313,345,377,314,346,2169378,315,347,379,316,348,380,317,349,381,318,350,382,319,351,383,2170320,352,384,321,353,385,322,354,386,323,355,387,324,356,388,325,2171357,389,326,358,390,327,359,391,328,360,392,329,361,393,330,362,2172394,331,363,395,332,364,396,333,365,397,334,366,398,335,367,399,2173336,368,400,337,369,401,338,370,402,339,371,403,340,372,404,341,2174373,405,342,374,406,343,375,407,408,452,496,409,453,497,410,454,2175498,411,455,499,412,456,500,413,457,501,414,458,502,415,459,503,2176416,460,504,417,461,505,418,462,506,419,463,507,420,464,508,421,2177465,509,422,466,510,423,467,511,424,468,512,425,469,513,426,470,2178514,427,471,515,428,472,516,429,473,517,430,474,518,431,475,519,2179432,476,520,433,477,521,434,478,522,435,479,523,436,480,524,437,2180481,525,438,482,526,439,483,527,440,484,528,441,485,529,442,486,2181530,443,487,531,444,488,532,445,489,533,446,490,534,447,491,535,2182448,492,536,449,493,537,450,494,538,451,495,539,540,552,564,541,2183553,565,542,554,566,543,555,567,544,556,568,545,557,569,546,558,2184570,547,559,571,548,560,572,549,561,573,550,562,574,551,563,575},2185{ 0, 4, 8, 1, 5, 9, 2, 6, 10, 3, 7, 11, 12, 16, 20, 13,218617, 21, 14, 18, 22, 15, 19, 23, 24, 28, 32, 25, 29, 33, 26, 30,218734, 27, 31, 35, 36, 42, 48, 37, 43, 49, 38, 44, 50, 39, 45, 51,218840, 46, 52, 41, 47, 53, 54, 62, 70, 55, 63, 71, 56, 64, 72, 57,218965, 73, 58, 66, 74, 59, 67, 75, 60, 68, 76, 61, 69, 77, 78, 88,219098, 79, 89, 99, 80, 90,100, 81, 91,101, 82, 92,102, 83, 93,103,219184, 94,104, 85, 95,105, 86, 96,106, 87, 97,107,108,120,132,109,2192121,133,110,122,134,111,123,135,112,124,136,113,125,137,114,126,2193138,115,127,139,116,128,140,117,129,141,118,130,142,119,131,143,2194144,158,172,145,159,173,146,160,174,147,161,175,148,162,176,149,2195163,177,150,164,178,151,165,179,152,166,180,153,167,181,154,168,2196182,155,169,183,156,170,184,157,171,185,186,204,222,187,205,223,2197188,206,224,189,207,225,190,208,226,191,209,227,192,210,228,193,2198211,229,194,212,230,195,213,231,196,214,232,197,215,233,198,216,2199234,199,217,235,200,218,236,201,219,237,202,220,238,203,221,239,2200240,264,288,241,265,289,242,266,290,243,267,291,244,268,292,245,2201269,293,246,270,294,247,271,295,248,272,296,249,273,297,250,274,2202298,251,275,299,252,276,300,253,277,301,254,278,302,255,279,303,2203256,280,304,257,281,305,258,282,306,259,283,307,260,284,308,261,2204285,309,262,286,310,263,287,311,312,342,372,313,343,373,314,344,2205374,315,345,375,316,346,376,317,347,377,318,348,378,319,349,379,2206320,350,380,321,351,381,322,352,382,323,353,383,324,354,384,325,2207355,385,326,356,386,327,357,387,328,358,388,329,359,389,330,360,2208390,331,361,391,332,362,392,333,363,393,334,364,394,335,365,395,2209336,366,396,337,367,397,338,368,398,339,369,399,340,370,400,341,2210371,401,402,442,482,403,443,483,404,444,484,405,445,485,406,446,2211486,407,447,487,408,448,488,409,449,489,410,450,490,411,451,491,2212412,452,492,413,453,493,414,454,494,415,455,495,416,456,496,417,2213457,497,418,458,498,419,459,499,420,460,500,421,461,501,422,462,2214502,423,463,503,424,464,504,425,465,505,426,466,506,427,467,507,2215428,468,508,429,469,509,430,470,510,431,471,511,432,472,512,433,2216473,513,434,474,514,435,475,515,436,476,516,437,477,517,438,478,2217518,439,479,519,440,480,520,441,481,521,522,540,558,523,541,559,2218524,542,560,525,543,561,526,544,562,527,545,563,528,546,564,529,2219547,565,530,548,566,531,549,567,532,550,568,533,551,569,534,552,2220570,535,553,571,536,554,572,537,555,573,538,556,574,539,557,575},2221{ 0, 4, 8, 1, 5, 9, 2, 6, 10, 3, 7, 11, 12, 16, 20, 13,222217, 21, 14, 18, 22, 15, 19, 23, 24, 28, 32, 25, 29, 33, 26, 30,222334, 27, 31, 35, 36, 40, 44, 37, 41, 45, 38, 42, 46, 39, 43, 47,222448, 54, 60, 49, 55, 61, 50, 56, 62, 51, 57, 63, 52, 58, 64, 53,222559, 65, 66, 74, 82, 67, 75, 83, 68, 76, 84, 69, 77, 85, 70, 78,222686, 71, 79, 87, 72, 80, 88, 73, 81, 89, 90,100,110, 91,101,111,222792,102,112, 93,103,113, 94,104,114, 95,105,115, 96,106,116, 97,2228107,117, 98,108,118, 99,109,119,120,132,144,121,133,145,122,134,2229146,123,135,147,124,136,148,125,137,149,126,138,150,127,139,151,2230128,140,152,129,141,153,130,142,154,131,143,155,156,170,184,157,2231171,185,158,172,186,159,173,187,160,174,188,161,175,189,162,176,2232190,163,177,191,164,178,192,165,179,193,166,180,194,167,181,195,2233168,182,196,169,183,197,198,216,234,199,217,235,200,218,236,201,2234219,237,202,220,238,203,221,239,204,222,240,205,223,241,206,224,2235242,207,225,243,208,226,244,209,227,245,210,228,246,211,229,247,2236212,230,248,213,231,249,214,232,250,215,233,251,252,274,296,253,2237275,297,254,276,298,255,277,299,256,278,300,257,279,301,258,280,2238302,259,281,303,260,282,304,261,283,305,262,284,306,263,285,307,2239264,286,308,265,287,309,266,288,310,267,289,311,268,290,312,269,2240291,313,270,292,314,271,293,315,272,294,316,273,295,317,318,348,2241378,319,349,379,320,350,380,321,351,381,322,352,382,323,353,383,2242324,354,384,325,355,385,326,356,386,327,357,387,328,358,388,329,2243359,389,330,360,390,331,361,391,332,362,392,333,363,393,334,364,2244394,335,365,395,336,366,396,337,367,397,338,368,398,339,369,399,2245340,370,400,341,371,401,342,372,402,343,373,403,344,374,404,345,2246375,405,346,376,406,347,377,407,408,464,520,409,465,521,410,466,2247522,411,467,523,412,468,524,413,469,525,414,470,526,415,471,527,2248416,472,528,417,473,529,418,474,530,419,475,531,420,476,532,421,2249477,533,422,478,534,423,479,535,424,480,536,425,481,537,426,482,2250538,427,483,539,428,484,540,429,485,541,430,486,542,431,487,543,2251432,488,544,433,489,545,434,490,546,435,491,547,436,492,548,437,2252493,549,438,494,550,439,495,551,440,496,552,441,497,553,442,498,2253554,443,499,555,444,500,556,445,501,557,446,502,558,447,503,559,2254448,504,560,449,505,561,450,506,562,451,507,563,452,508,564,453,2255509,565,454,510,566,455,511,567,456,512,568,457,513,569,458,514,2256570,459,515,571,460,516,572,461,517,573,462,518,574,463,519,575},2257{ 0, 4, 8, 1, 5, 9, 2, 6, 10, 3, 7, 11, 12, 16, 20, 13,225817, 21, 14, 18, 22, 15, 19, 23, 24, 28, 32, 25, 29, 33, 26, 30,225934, 27, 31, 35, 36, 40, 44, 37, 41, 45, 38, 42, 46, 39, 43, 47,226048, 54, 60, 49, 55, 61, 50, 56, 62, 51, 57, 63, 52, 58, 64, 53,226159, 65, 66, 72, 78, 67, 73, 79, 68, 74, 80, 69, 75, 81, 70, 76,226282, 71, 77, 83, 84, 94,104, 85, 95,105, 86, 96,106, 87, 97,107,226388, 98,108, 89, 99,109, 90,100,110, 91,101,111, 92,102,112, 93,2264103,113,114,126,138,115,127,139,116,128,140,117,129,141,118,130,2265142,119,131,143,120,132,144,121,133,145,122,134,146,123,135,147,2266124,136,148,125,137,149,150,164,178,151,165,179,152,166,180,153,2267167,181,154,168,182,155,169,183,156,170,184,157,171,185,158,172,2268186,159,173,187,160,174,188,161,175,189,162,176,190,163,177,191,2269192,208,224,193,209,225,194,210,226,195,211,227,196,212,228,197,2270213,229,198,214,230,199,215,231,200,216,232,201,217,233,202,218,2271234,203,219,235,204,220,236,205,221,237,206,222,238,207,223,239,2272240,260,280,241,261,281,242,262,282,243,263,283,244,264,284,245,2273265,285,246,266,286,247,267,287,248,268,288,249,269,289,250,270,2274290,251,271,291,252,272,292,253,273,293,254,274,294,255,275,295,2275256,276,296,257,277,297,258,278,298,259,279,299,300,326,352,301,2276327,353,302,328,354,303,329,355,304,330,356,305,331,357,306,332,2277358,307,333,359,308,334,360,309,335,361,310,336,362,311,337,363,2278312,338,364,313,339,365,314,340,366,315,341,367,316,342,368,317,2279343,369,318,344,370,319,345,371,320,346,372,321,347,373,322,348,2280374,323,349,375,324,350,376,325,351,377,378,444,510,379,445,511,2281380,446,512,381,447,513,382,448,514,383,449,515,384,450,516,385,2282451,517,386,452,518,387,453,519,388,454,520,389,455,521,390,456,2283522,391,457,523,392,458,524,393,459,525,394,460,526,395,461,527,2284396,462,528,397,463,529,398,464,530,399,465,531,400,466,532,401,2285467,533,402,468,534,403,469,535,404,470,536,405,471,537,406,472,2286538,407,473,539,408,474,540,409,475,541,410,476,542,411,477,543,2287412,478,544,413,479,545,414,480,546,415,481,547,416,482,548,417,2288483,549,418,484,550,419,485,551,420,486,552,421,487,553,422,488,2289554,423,489,555,424,490,556,425,491,557,426,492,558,427,493,559,2290428,494,560,429,495,561,430,496,562,431,497,563,432,498,564,433,2291499,565,434,500,566,435,501,567,436,502,568,437,503,569,438,504,2292570,439,505,571,440,506,572,441,507,573,442,508,574,443,509,575},2293{ 0, 4, 8, 1, 5, 9, 2, 6, 10, 3, 7, 11, 12, 16, 20, 13,229417, 21, 14, 18, 22, 15, 19, 23, 24, 28, 32, 25, 29, 33, 26, 30,229534, 27, 31, 35, 36, 40, 44, 37, 41, 45, 38, 42, 46, 39, 43, 47,229648, 54, 60, 49, 55, 61, 50, 56, 62, 51, 57, 63, 52, 58, 64, 53,229759, 65, 66, 74, 82, 67, 75, 83, 68, 76, 84, 69, 77, 85, 70, 78,229886, 71, 79, 87, 72, 80, 88, 73, 81, 89, 90,102,114, 91,103,115,229992,104,116, 93,105,117, 94,106,118, 95,107,119, 96,108,120, 97,2300109,121, 98,110,122, 99,111,123,100,112,124,101,113,125,126,142,2301158,127,143,159,128,144,160,129,145,161,130,146,162,131,147,163,2302132,148,164,133,149,165,134,150,166,135,151,167,136,152,168,137,2303153,169,138,154,170,139,155,171,140,156,172,141,157,173,174,194,2304214,175,195,215,176,196,216,177,197,217,178,198,218,179,199,219,2305180,200,220,181,201,221,182,202,222,183,203,223,184,204,224,185,2306205,225,186,206,226,187,207,227,188,208,228,189,209,229,190,210,2307230,191,211,231,192,212,232,193,213,233,234,260,286,235,261,287,2308236,262,288,237,263,289,238,264,290,239,265,291,240,266,292,241,2309267,293,242,268,294,243,269,295,244,270,296,245,271,297,246,272,2310298,247,273,299,248,274,300,249,275,301,250,276,302,251,277,303,2311252,278,304,253,279,305,254,280,306,255,281,307,256,282,308,257,2312283,309,258,284,310,259,285,311,312,346,380,313,347,381,314,348,2313382,315,349,383,316,350,384,317,351,385,318,352,386,319,353,387,2314320,354,388,321,355,389,322,356,390,323,357,391,324,358,392,325,2315359,393,326,360,394,327,361,395,328,362,396,329,363,397,330,364,2316398,331,365,399,332,366,400,333,367,401,334,368,402,335,369,403,2317336,370,404,337,371,405,338,372,406,339,373,407,340,374,408,341,2318375,409,342,376,410,343,377,411,344,378,412,345,379,413,414,456,2319498,415,457,499,416,458,500,417,459,501,418,460,502,419,461,503,2320420,462,504,421,463,505,422,464,506,423,465,507,424,466,508,425,2321467,509,426,468,510,427,469,511,428,470,512,429,471,513,430,472,2322514,431,473,515,432,474,516,433,475,517,434,476,518,435,477,519,2323436,478,520,437,479,521,438,480,522,439,481,523,440,482,524,441,2324483,525,442,484,526,443,485,527,444,486,528,445,487,529,446,488,2325530,447,489,531,448,490,532,449,491,533,450,492,534,451,493,535,2326452,494,536,453,495,537,454,496,538,455,497,539,540,552,564,541,2327553,565,542,554,566,543,555,567,544,556,568,545,557,569,546,558,2328570,547,559,571,548,560,572,549,561,573,550,562,574,551,563,575}2329};2330*/23312332private static final float cs[] =2333{23340.857492925712f, 0.881741997318f, 0.949628649103f, 0.983314592492f,23350.995517816065f, 0.999160558175f, 0.999899195243f, 0.999993155067f2336};23372338private static final float ca[] =2339{2340-0.5144957554270f, -0.4717319685650f, -0.3133774542040f, -0.1819131996110f,2341-0.0945741925262f, -0.0409655828852f, -0.0141985685725f, -0.00369997467375f2342};23432344/************************************************************/2345/* END OF L3TABLE */2346/************************************************************/23472348/************************************************************/2349/* L3TYPE */2350/************************************************************/235123522353/***************************************************************/2354/* END OF L3TYPE */2355/***************************************************************/23562357/***************************************************************/2358/* INV_MDCT */2359/***************************************************************/2360public static final float win[][] =2361{2362{ -1.6141214951E-02f, -5.3603178919E-02f, -1.0070713296E-01f, -1.6280817573E-01f,2363-4.9999999679E-01f, -3.8388735032E-01f, -6.2061144372E-01f, -1.1659756083E+00f,2364-3.8720752656E+00f, -4.2256286556E+00f, -1.5195289984E+00f, -9.7416483388E-01f,2365-7.3744074053E-01f, -1.2071067773E+00f, -5.1636156596E-01f, -4.5426052317E-01f,2366-4.0715656898E-01f, -3.6969460527E-01f, -3.3876269197E-01f, -3.1242222492E-01f,2367-2.8939587111E-01f, -2.6880081906E-01f, -5.0000000266E-01f, -2.3251417468E-01f,2368-2.1596714708E-01f, -2.0004979098E-01f, -1.8449493497E-01f, -1.6905846094E-01f,2369-1.5350360518E-01f, -1.3758624925E-01f, -1.2103922149E-01f, -2.0710679058E-01f,2370-8.4752577594E-02f, -6.4157525656E-02f, -4.1131172614E-02f, -1.4790705759E-02f },23712372{ -1.6141214951E-02f, -5.3603178919E-02f, -1.0070713296E-01f, -1.6280817573E-01f,2373-4.9999999679E-01f, -3.8388735032E-01f, -6.2061144372E-01f, -1.1659756083E+00f,2374-3.8720752656E+00f, -4.2256286556E+00f, -1.5195289984E+00f, -9.7416483388E-01f,2375-7.3744074053E-01f, -1.2071067773E+00f, -5.1636156596E-01f, -4.5426052317E-01f,2376-4.0715656898E-01f, -3.6969460527E-01f, -3.3908542600E-01f, -3.1511810350E-01f,2377-2.9642226150E-01f, -2.8184548650E-01f, -5.4119610000E-01f, -2.6213228100E-01f,2378-2.5387916537E-01f, -2.3296291359E-01f, -1.9852728987E-01f, -1.5233534808E-01f,2379-9.6496400054E-02f, -3.3423828516E-02f, 0.0000000000E+00f, 0.0000000000E+00f,23800.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f },23812382{ -4.8300800645E-02f, -1.5715656932E-01f, -2.8325045177E-01f, -4.2953747763E-01f,2383-1.2071067795E+00f, -8.2426483178E-01f, -1.1451749106E+00f, -1.7695290101E+00f,2384-4.5470225061E+00f, -3.4890531002E+00f, -7.3296292804E-01f, -1.5076514758E-01f,23850.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f,23860.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f,23870.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f,23880.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f,23890.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f,23900.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f },23912392{ 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f, 0.0000000000E+00f,23930.0000000000E+00f, 0.0000000000E+00f, -1.5076513660E-01f, -7.3296291107E-01f,2394-3.4890530566E+00f, -4.5470224727E+00f, -1.7695290031E+00f, -1.1451749092E+00f,2395-8.3137738100E-01f, -1.3065629650E+00f, -5.4142014250E-01f, -4.6528974900E-01f,2396-4.1066990750E-01f, -3.7004680800E-01f, -3.3876269197E-01f, -3.1242222492E-01f,2397-2.8939587111E-01f, -2.6880081906E-01f, -5.0000000266E-01f, -2.3251417468E-01f,2398-2.1596714708E-01f, -2.0004979098E-01f, -1.8449493497E-01f, -1.6905846094E-01f,2399-1.5350360518E-01f, -1.3758624925E-01f, -1.2103922149E-01f, -2.0710679058E-01f,2400-8.4752577594E-02f, -6.4157525656E-02f, -4.1131172614E-02f, -1.4790705759E-02f }2401};2402/***************************************************************/2403/* END OF INV_MDCT */2404/***************************************************************/24052406static class Sftable2407{2408public int[] l;2409public int[] s;24102411public Sftable()2412{2413l = new int[5];2414s = new int[3];2415}24162417public Sftable(int[] thel, int[] thes)2418{2419l = thel;2420s = thes;2421}2422}24232424public Sftable sftable;24252426public static final int nr_of_sfb_block[][][] =2427{{{ 6, 5, 5, 5} , { 9, 9, 9, 9} , { 6, 9, 9, 9}},2428{{ 6, 5, 7, 3} , { 9, 9,12, 6} , { 6, 9,12, 6}},2429{{11,10, 0, 0} , {18,18, 0, 0} , {15,18, 0, 0}},2430{{ 7, 7, 7, 0} , {12,12,12, 0} , { 6,15,12, 0}},2431{{ 6, 6, 6, 3} , {12, 9, 9, 6} , { 6,12, 9, 6}},2432{{ 8, 8, 5, 0} , {15,12, 9, 0} , { 6,18, 9, 0}}};243324342435}243624372438