X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=Robust%2Fsrc%2FBenchmarks%2FSSJava%2FMP3Decoder%2Fhuffcodetab.java;fp=Robust%2Fsrc%2FBenchmarks%2FSSJava%2FMP3Decoder%2Fhuffcodetab.java;h=a0266ace0a8534622cb7512c7d356be363257021;hb=15e12c52c54314d14b860b578c46251adb3e8625;hp=0b8ba3347c4ed3ec6d46d450b205d5f4eece8cf2;hpb=47cc527f574f19b71e92fceac668fb8c0655b13b;p=IRC.git diff --git a/Robust/src/Benchmarks/SSJava/MP3Decoder/huffcodetab.java b/Robust/src/Benchmarks/SSJava/MP3Decoder/huffcodetab.java index 0b8ba334..a0266ace 100644 --- a/Robust/src/Benchmarks/SSJava/MP3Decoder/huffcodetab.java +++ b/Robust/src/Benchmarks/SSJava/MP3Decoder/huffcodetab.java @@ -1,664 +1,664 @@ -/* - * 11/19/04 1.0 moved to LGPL. - * 16/11/99 Renamed class, added javadoc, and changed table - * name from String to 3 chars. mdm@techie.com - * 02/15/99 Java Conversion by E.B, javalayer@javazoom.net - * - * 04/19/97 : Adapted from the ISO MPEG Audio Subgroup Software Simulation - * Group's public c source for its MPEG audio decoder. Miscellaneous - * changes by Jeff Tsay (ctsay@pasteur.eecs.berkeley.edu). - *----------------------------------------------------------------------- - * Copyright (c) 1991 MPEG/audio software simulation group, All Rights Reserved - * MPEG/audio coding/decoding software, work in progress - * NOT for public distribution until verified and approved by the - * MPEG/audio committee. For further information, please contact - * Davis Pan, 508-493-2241, e-mail: pan@3d.enet.dec.com - * - * VERSION 4.1 - * changes made since last update: - * date programmers comment - * 27.2.92 F.O.Witte (ITT Intermetall) - * 8/24/93 M. Iwadare Changed for 1 pass decoding. - * 7/14/94 J. Koller useless 'typedef' before huffcodetab removed - *----------------------------------------------------------------------- - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as published - * by the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - *---------------------------------------------------------------------- - */ - -/** - * Class to implements Huffman decoder. - */ -@LATTICE("FIELD>> 4; - y[0] = ht[htIdx].val[point][1] & 0xf; - error = 0; - break; - } - - // hget1bit() is called thousands of times, and so needs to be - // ultra fast. - /* - * if (bitIndex==bitsAvailable) { bitsAvailable = br.readBits(bits, 32); - * bitIndex = 0; } - */ - // if (bits[bitIndex++]!=0) - if (br.hget1bit() != 0) { - TERMINATE: while (ht[htIdx].val[point][1] >= MXOFF) - point += ht[htIdx].val[point][1]; - point += ht[htIdx].val[point][1]; - } else { - TERMINATE: while (ht[htIdx].val[point][0] >= MXOFF) - point += ht[htIdx].val[point][0]; - point += ht[htIdx].val[point][0]; - } - level >>>= 1; - // MDM: ht[0] is always 0; - } while ((level != 0) || (point < 0 /* ht[0].treelen */)); - - // put back any bits not consumed - /* - * int unread = (bitsAvailable-bitIndex); if (unread>0) - * br.rewindNbits(unread); - */ - /* Process sign encodings for quadruples tables. */ - // System.out.println(ht[htIdx].tablename); - if (ht[htIdx].tablename0 == '3' && (ht[htIdx].tablename1 == '2' || ht[htIdx].tablename1 == '3')) { - v[0] = (y[0] >> 3) & 1; - w[0] = (y[0] >> 2) & 1; - x[0] = (y[0] >> 1) & 1; - y[0] = y[0] & 1; - - /* - * v, w, x and y are reversed in the bitstream. switch them around to make - * test bistream work. - */ - - if (v[0] != 0) - if (br.hget1bit() != 0) - v[0] = -v[0]; - if (w[0] != 0) - if (br.hget1bit() != 0) - w[0] = -w[0]; - if (x[0] != 0) - if (br.hget1bit() != 0) - x[0] = -x[0]; - if (y[0] != 0) - if (br.hget1bit() != 0) - y[0] = -y[0]; - } else { - // Process sign and escape encodings for dual tables. - // x and y are reversed in the test bitstream. - // Reverse x and y here to make test bitstream work. - - if (ht[htIdx].linbits != 0) - if ((ht[htIdx].xlen - 1) == x[0]) - x[0] += br.hgetbits(ht[htIdx].linbits); - if (x[0] != 0) - if (br.hget1bit() != 0) - x[0] = -x[0]; - if (ht[htIdx].linbits != 0) - if ((ht[htIdx].ylen - 1) == y[0]) - y[0] += br.hgetbits(ht[htIdx].linbits); - if (y[0] != 0) - if (br.hget1bit() != 0) - y[0] = -y[0]; - } - return error; - } - - public static void inithuff() { - - if (ht != null) - return; - - ht = new huffcodetab[HTN]; - ht[0] = new huffcodetab("0 ", 0, 0, 0, 0, -1, null, null, ValTab0, 0); - ht[1] = new huffcodetab("1 ", 2, 2, 0, 0, -1, null, null, ValTab1, 7); - ht[2] = new huffcodetab("2 ", 3, 3, 0, 0, -1, null, null, ValTab2, 17); - ht[3] = new huffcodetab("3 ", 3, 3, 0, 0, -1, null, null, ValTab3, 17); - ht[4] = new huffcodetab("4 ", 0, 0, 0, 0, -1, null, null, ValTab4, 0); - ht[5] = new huffcodetab("5 ", 4, 4, 0, 0, -1, null, null, ValTab5, 31); - ht[6] = new huffcodetab("6 ", 4, 4, 0, 0, -1, null, null, ValTab6, 31); - ht[7] = new huffcodetab("7 ", 6, 6, 0, 0, -1, null, null, ValTab7, 71); - ht[8] = new huffcodetab("8 ", 6, 6, 0, 0, -1, null, null, ValTab8, 71); - ht[9] = new huffcodetab("9 ", 6, 6, 0, 0, -1, null, null, ValTab9, 71); - ht[10] = new huffcodetab("10 ", 8, 8, 0, 0, -1, null, null, ValTab10, 127); - ht[11] = new huffcodetab("11 ", 8, 8, 0, 0, -1, null, null, ValTab11, 127); - ht[12] = new huffcodetab("12 ", 8, 8, 0, 0, -1, null, null, ValTab12, 127); - ht[13] = new huffcodetab("13 ", 16, 16, 0, 0, -1, null, null, ValTab13, 511); - ht[14] = new huffcodetab("14 ", 0, 0, 0, 0, -1, null, null, ValTab14, 0); - ht[15] = new huffcodetab("15 ", 16, 16, 0, 0, -1, null, null, ValTab15, 511); - ht[16] = new huffcodetab("16 ", 16, 16, 1, 1, -1, null, null, ValTab16, 511); - ht[17] = new huffcodetab("17 ", 16, 16, 2, 3, 16, null, null, ValTab16, 511); - ht[18] = new huffcodetab("18 ", 16, 16, 3, 7, 16, null, null, ValTab16, 511); - ht[19] = new huffcodetab("19 ", 16, 16, 4, 15, 16, null, null, ValTab16, 511); - ht[20] = new huffcodetab("20 ", 16, 16, 6, 63, 16, null, null, ValTab16, 511); - ht[21] = new huffcodetab("21 ", 16, 16, 8, 255, 16, null, null, ValTab16, 511); - ht[22] = new huffcodetab("22 ", 16, 16, 10, 1023, 16, null, null, ValTab16, 511); - ht[23] = new huffcodetab("23 ", 16, 16, 13, 8191, 16, null, null, ValTab16, 511); - ht[24] = new huffcodetab("24 ", 16, 16, 4, 15, -1, null, null, ValTab24, 512); - ht[25] = new huffcodetab("25 ", 16, 16, 5, 31, 24, null, null, ValTab24, 512); - ht[26] = new huffcodetab("26 ", 16, 16, 6, 63, 24, null, null, ValTab24, 512); - ht[27] = new huffcodetab("27 ", 16, 16, 7, 127, 24, null, null, ValTab24, 512); - ht[28] = new huffcodetab("28 ", 16, 16, 8, 255, 24, null, null, ValTab24, 512); - ht[29] = new huffcodetab("29 ", 16, 16, 9, 511, 24, null, null, ValTab24, 512); - ht[30] = new huffcodetab("30 ", 16, 16, 11, 2047, 24, null, null, ValTab24, 512); - ht[31] = new huffcodetab("31 ", 16, 16, 13, 8191, 24, null, null, ValTab24, 512); - ht[32] = new huffcodetab("32 ", 1, 16, 0, 0, -1, null, null, ValTab32, 31); - ht[33] = new huffcodetab("33 ", 1, 16, 0, 0, -1, null, null, ValTab33, 31); - } -} +/* + * 11/19/04 1.0 moved to LGPL. + * 16/11/99 Renamed class, added javadoc, and changed table + * name from String to 3 chars. mdm@techie.com + * 02/15/99 Java Conversion by E.B, javalayer@javazoom.net + * + * 04/19/97 : Adapted from the ISO MPEG Audio Subgroup Software Simulation + * Group's public c source for its MPEG audio decoder. Miscellaneous + * changes by Jeff Tsay (ctsay@pasteur.eecs.berkeley.edu). + *----------------------------------------------------------------------- + * Copyright (c) 1991 MPEG/audio software simulation group, All Rights Reserved + * MPEG/audio coding/decoding software, work in progress + * NOT for public distribution until verified and approved by the + * MPEG/audio committee. For further information, please contact + * Davis Pan, 508-493-2241, e-mail: pan@3d.enet.dec.com + * + * VERSION 4.1 + * changes made since last update: + * date programmers comment + * 27.2.92 F.O.Witte (ITT Intermetall) + * 8/24/93 M. Iwadare Changed for 1 pass decoding. + * 7/14/94 J. Koller useless 'typedef' before huffcodetab removed + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ + +/** + * Class to implements Huffman decoder. + */ +@LATTICE("FIELD>> 4; + y[0] = ht[htIdx].val[point][1] & 0xf; + error = 0; + break; + } + + // hget1bit() is called thousands of times, and so needs to be + // ultra fast. + /* + * if (bitIndex==bitsAvailable) { bitsAvailable = br.readBits(bits, 32); + * bitIndex = 0; } + */ + // if (bits[bitIndex++]!=0) + if (br.hget1bit() != 0) { + TERMINATE: while (ht[htIdx].val[point][1] >= MXOFF) + point += ht[htIdx].val[point][1]; + point += ht[htIdx].val[point][1]; + } else { + TERMINATE: while (ht[htIdx].val[point][0] >= MXOFF) + point += ht[htIdx].val[point][0]; + point += ht[htIdx].val[point][0]; + } + level >>>= 1; + // MDM: ht[0] is always 0; + } while ((level != 0) || (point < 0 /* ht[0].treelen */)); + + // put back any bits not consumed + /* + * int unread = (bitsAvailable-bitIndex); if (unread>0) + * br.rewindNbits(unread); + */ + /* Process sign encodings for quadruples tables. */ + // System.out.println(ht[htIdx].tablename); + if (ht[htIdx].tablename0 == '3' && (ht[htIdx].tablename1 == '2' || ht[htIdx].tablename1 == '3')) { + v[0] = (y[0] >> 3) & 1; + w[0] = (y[0] >> 2) & 1; + x[0] = (y[0] >> 1) & 1; + y[0] = y[0] & 1; + + /* + * v, w, x and y are reversed in the bitstream. switch them around to make + * test bistream work. + */ + + if (v[0] != 0) + if (br.hget1bit() != 0) + v[0] = -v[0]; + if (w[0] != 0) + if (br.hget1bit() != 0) + w[0] = -w[0]; + if (x[0] != 0) + if (br.hget1bit() != 0) + x[0] = -x[0]; + if (y[0] != 0) + if (br.hget1bit() != 0) + y[0] = -y[0]; + } else { + // Process sign and escape encodings for dual tables. + // x and y are reversed in the test bitstream. + // Reverse x and y here to make test bitstream work. + + if (ht[htIdx].linbits != 0) + if ((ht[htIdx].xlen - 1) == x[0]) + x[0] += br.hgetbits(ht[htIdx].linbits); + if (x[0] != 0) + if (br.hget1bit() != 0) + x[0] = -x[0]; + if (ht[htIdx].linbits != 0) + if ((ht[htIdx].ylen - 1) == y[0]) + y[0] += br.hgetbits(ht[htIdx].linbits); + if (y[0] != 0) + if (br.hget1bit() != 0) + y[0] = -y[0]; + } + return error; + } + + public static void inithuff() { + + if (ht != null) + return; + + ht = new huffcodetab[HTN]; + ht[0] = new huffcodetab("0 ", 0, 0, 0, 0, -1, null, null, ValTab0, 0); + ht[1] = new huffcodetab("1 ", 2, 2, 0, 0, -1, null, null, ValTab1, 7); + ht[2] = new huffcodetab("2 ", 3, 3, 0, 0, -1, null, null, ValTab2, 17); + ht[3] = new huffcodetab("3 ", 3, 3, 0, 0, -1, null, null, ValTab3, 17); + ht[4] = new huffcodetab("4 ", 0, 0, 0, 0, -1, null, null, ValTab4, 0); + ht[5] = new huffcodetab("5 ", 4, 4, 0, 0, -1, null, null, ValTab5, 31); + ht[6] = new huffcodetab("6 ", 4, 4, 0, 0, -1, null, null, ValTab6, 31); + ht[7] = new huffcodetab("7 ", 6, 6, 0, 0, -1, null, null, ValTab7, 71); + ht[8] = new huffcodetab("8 ", 6, 6, 0, 0, -1, null, null, ValTab8, 71); + ht[9] = new huffcodetab("9 ", 6, 6, 0, 0, -1, null, null, ValTab9, 71); + ht[10] = new huffcodetab("10 ", 8, 8, 0, 0, -1, null, null, ValTab10, 127); + ht[11] = new huffcodetab("11 ", 8, 8, 0, 0, -1, null, null, ValTab11, 127); + ht[12] = new huffcodetab("12 ", 8, 8, 0, 0, -1, null, null, ValTab12, 127); + ht[13] = new huffcodetab("13 ", 16, 16, 0, 0, -1, null, null, ValTab13, 511); + ht[14] = new huffcodetab("14 ", 0, 0, 0, 0, -1, null, null, ValTab14, 0); + ht[15] = new huffcodetab("15 ", 16, 16, 0, 0, -1, null, null, ValTab15, 511); + ht[16] = new huffcodetab("16 ", 16, 16, 1, 1, -1, null, null, ValTab16, 511); + ht[17] = new huffcodetab("17 ", 16, 16, 2, 3, 16, null, null, ValTab16, 511); + ht[18] = new huffcodetab("18 ", 16, 16, 3, 7, 16, null, null, ValTab16, 511); + ht[19] = new huffcodetab("19 ", 16, 16, 4, 15, 16, null, null, ValTab16, 511); + ht[20] = new huffcodetab("20 ", 16, 16, 6, 63, 16, null, null, ValTab16, 511); + ht[21] = new huffcodetab("21 ", 16, 16, 8, 255, 16, null, null, ValTab16, 511); + ht[22] = new huffcodetab("22 ", 16, 16, 10, 1023, 16, null, null, ValTab16, 511); + ht[23] = new huffcodetab("23 ", 16, 16, 13, 8191, 16, null, null, ValTab16, 511); + ht[24] = new huffcodetab("24 ", 16, 16, 4, 15, -1, null, null, ValTab24, 512); + ht[25] = new huffcodetab("25 ", 16, 16, 5, 31, 24, null, null, ValTab24, 512); + ht[26] = new huffcodetab("26 ", 16, 16, 6, 63, 24, null, null, ValTab24, 512); + ht[27] = new huffcodetab("27 ", 16, 16, 7, 127, 24, null, null, ValTab24, 512); + ht[28] = new huffcodetab("28 ", 16, 16, 8, 255, 24, null, null, ValTab24, 512); + ht[29] = new huffcodetab("29 ", 16, 16, 9, 511, 24, null, null, ValTab24, 512); + ht[30] = new huffcodetab("30 ", 16, 16, 11, 2047, 24, null, null, ValTab24, 512); + ht[31] = new huffcodetab("31 ", 16, 16, 13, 8191, 24, null, null, ValTab24, 512); + ht[32] = new huffcodetab("32 ", 1, 16, 0, 0, -1, null, null, ValTab32, 31); + ht[33] = new huffcodetab("33 ", 1, 16, 0, 0, -1, null, null, ValTab33, 31); + } +}