14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package com.sun.imageio.plugins.common; 27 28 import java.io.PrintStream; 29 30 /** 31 * General purpose LZW String Table. 32 * Extracted from GIFEncoder by Adam Doppelt 33 * Comments added by Robin Luiten 34 * <code>expandCode</code> added by Robin Luiten 35 * The strLen table to give quick access to the lenght of an expanded 36 * code for use by the <code>expandCode</code> method added by Robin. 37 **/ 38 public class LZWStringTable { 39 /** codesize + Reserved Codes */ 40 private static final int RES_CODES = 2; 41 42 private static final short HASH_FREE = (short)0xFFFF; 43 private static final short NEXT_FIRST = (short)0xFFFF; 44 45 private static final int MAXBITS = 12; 46 private static final int MAXSTR = (1 << MAXBITS); 47 48 private static final short HASHSIZE = 9973; 49 private static final short HASHSTEP = 2039; 50 51 byte[] strChr; // after predecessor character 52 short[] strNxt; // predecessor string 53 short[] strHsh; // hash table to find predecessor + char pairs 54 short numStrings; // next code if adding new prestring + char 55 56 /* | 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package com.sun.imageio.plugins.common; 27 28 import java.io.PrintStream; 29 30 /** 31 * General purpose LZW String Table. 32 * Extracted from GIFEncoder by Adam Doppelt 33 * Comments added by Robin Luiten 34 * {@code expandCode} added by Robin Luiten 35 * The strLen table to give quick access to the lenght of an expanded 36 * code for use by the {@code expandCode} method added by Robin. 37 **/ 38 public class LZWStringTable { 39 /** codesize + Reserved Codes */ 40 private static final int RES_CODES = 2; 41 42 private static final short HASH_FREE = (short)0xFFFF; 43 private static final short NEXT_FIRST = (short)0xFFFF; 44 45 private static final int MAXBITS = 12; 46 private static final int MAXSTR = (1 << MAXBITS); 47 48 private static final short HASHSIZE = 9973; 49 private static final short HASHSTEP = 2039; 50 51 byte[] strChr; // after predecessor character 52 short[] strNxt; // predecessor string 53 short[] strHsh; // hash table to find predecessor + char pairs 54 short numStrings; // next code if adding new prestring + char 55 56 /* |