/** * @param codesize the size of code to be preallocated for the * string store. **/ public void ClearTable(int codesize) { numStrings_ = 0; for (int q = 0; q < HASHSIZE; q++) strHsh_[q] = HASH_FREE; int w = (1 << codesize) + RES_CODES; for (int q = 0; q < w; q++) AddCharString((short)0xFFFF, (byte)q); // init with no prefix }
/** * @param index index to prefix string * @param b the character that follws the index prefix * @return b if param index is HASH_FREE. Else return the code * for this prefix and byte successor **/ public short FindCharString(short index, byte b) { int hshidx, nxtidx; if (index == HASH_FREE) return (short)(b & 0xFF); // Rob fixed used to sign extend hshidx = Hash(index, b); while ((nxtidx = strHsh_[hshidx]) != HASH_FREE) // search { if (strNxt_[nxtidx] == index && strChr_[nxtidx] == b) return (short)nxtidx; hshidx = (hshidx + HASHSTEP) % HASHSIZE; } return (short)0xFFFF; }
public void dump(PrintStream out) { lzss_.dump(out); }
if ((index = lzss_.FindCharString(prefix_, c)) != -1) prefix_ = index; else if (lzss_.AddCharString(prefix_, c) > limit_) lzss_.ClearTable(codeSize_); numBits_ = codeSize_ + 1;
/** * @param out destination for compressed data * @param codeSize the initial code size for the LZW compressor * @param TIFF flag indicating that TIFF lzw fudge needs to be applied * @exception IOException if underlying output stream error **/ public LZWCompressor(ImageOutputStream out, int codeSize, boolean TIFF) throws IOException { bf_ = new BitFile(out, !TIFF); // set flag for GIF as NOT tiff codeSize_ = codeSize; tiffFudge_ = TIFF; clearCode_ = 1 << codeSize_; endOfInfo_ = clearCode_ + 1; numBits_ = codeSize_ + 1; limit_ = (1 << numBits_) - 1; if (tiffFudge_) --limit_; prefix_ = (short)0xFFFF; lzss_ = new LZWStringTable(); lzss_.ClearTable(codeSize_); bf_.writeBits(clearCode_, numBits_); }
if ((index = lzss_.FindCharString(prefix_, c)) != -1) prefix_ = index; else if (lzss_.AddCharString(prefix_, c) > limit_) lzss_.ClearTable(codeSize_); numBits_ = codeSize_ + 1;
/** * @param out destination for compressed data * @param codeSize the initial code size for the LZW compressor * @param TIFF flag indicating that TIFF lzw fudge needs to be applied * @exception IOException if underlying output stream error **/ public LZWCompressor(ImageOutputStream out, int codeSize, boolean TIFF) throws IOException { bf_ = new BitFile(out, !TIFF); // set flag for GIF as NOT tiff codeSize_ = codeSize; tiffFudge_ = TIFF; clearCode_ = 1 << codeSize_; endOfInfo_ = clearCode_ + 1; numBits_ = codeSize_ + 1; limit_ = (1 << numBits_) - 1; if (tiffFudge_) --limit_; prefix_ = (short)0xFFFF; lzss_ = new LZWStringTable(); lzss_.ClearTable(codeSize_); bf_.writeBits(clearCode_, numBits_); }
if ((index = lzss_.FindCharString(prefix_, c)) != -1) prefix_ = index; else if (lzss_.AddCharString(prefix_, c) > limit_) lzss_.ClearTable(codeSize_); numBits_ = codeSize_ + 1;
/** * @param out destination for compressed data * @param codeSize the initial code size for the LZW compressor * @param TIFF flag indicating that TIFF lzw fudge needs to be applied * @exception IOException if underlying output stream error **/ public LZWCompressor(ImageOutputStream out, int codeSize, boolean TIFF) throws IOException { bf_ = new BitFile(out, !TIFF); // set flag for GIF as NOT tiff codeSize_ = codeSize; tiffFudge_ = TIFF; clearCode_ = 1 << codeSize_; endOfInfo_ = clearCode_ + 1; numBits_ = codeSize_ + 1; limit_ = (1 << numBits_) - 1; if (tiffFudge_) --limit_; prefix_ = (short)0xFFFF; lzss_ = new LZWStringTable(); lzss_.ClearTable(codeSize_); bf_.writeBits(clearCode_, numBits_); }
/** * @param index index to prefix string * @param b the character that follws the index prefix * @return b if param index is HASH_FREE. Else return the code * for this prefix and byte successor **/ public short FindCharString(short index, byte b) { int hshidx, nxtidx; if (index == HASH_FREE) return (short)(b & 0xFF); // Rob fixed used to sign extend hshidx = Hash(index, b); while ((nxtidx = strHsh_[hshidx]) != HASH_FREE) // search { if (strNxt_[nxtidx] == index && strChr_[nxtidx] == b) return (short)nxtidx; hshidx = (hshidx + HASHSTEP) % HASHSIZE; } return (short)0xFFFF; }
public void dump(PrintStream out) { lzss_.dump(out); }
/** * @param codesize the size of code to be preallocated for the * string store. **/ public void ClearTable(int codesize) { numStrings_ = 0; for (int q = 0; q < HASHSIZE; q++) strHsh_[q] = HASH_FREE; int w = (1 << codesize) + RES_CODES; for (int q = 0; q < w; q++) AddCharString((short)0xFFFF, (byte)q); // init with no prefix }
/** * @param index index to prefix string * @param b the character that follws the index prefix * @return b if param index is HASH_FREE. Else return the code * for this prefix and byte successor **/ public short FindCharString(short index, byte b) { int hshidx, nxtidx; if (index == HASH_FREE) return (short)(b & 0xFF); // Rob fixed used to sign extend hshidx = Hash(index, b); while ((nxtidx = strHsh_[hshidx]) != HASH_FREE) // search { if (strNxt_[nxtidx] == index && strChr_[nxtidx] == b) return (short)nxtidx; hshidx = (hshidx + HASHSTEP) % HASHSIZE; } return (short)0xFFFF; }
public void dump(PrintStream out) { lzss_.dump(out); }
/** * @param codesize the size of code to be preallocated for the * string store. **/ public void ClearTable(int codesize) { numStrings_ = 0; for (int q = 0; q < HASHSIZE; q++) strHsh_[q] = HASH_FREE; int w = (1 << codesize) + RES_CODES; for (int q = 0; q < w; q++) AddCharString((short)0xFFFF, (byte)q); // init with no prefix }
hshidx = Hash(index, b); while (strHsh_[hshidx] != HASH_FREE) hshidx = (hshidx + HASHSTEP) % HASHSIZE;
hshidx = Hash(index, b); while (strHsh_[hshidx] != HASH_FREE) hshidx = (hshidx + HASHSTEP) % HASHSIZE;
hshidx = Hash(index, b); while (strHsh_[hshidx] != HASH_FREE) hshidx = (hshidx + HASHSTEP) % HASHSIZE;