Class LZWEncoder
- java.lang.Object
-
- com.twelvemonkeys.imageio.plugins.tiff.LZWEncoder
-
- All Implemented Interfaces:
Encoder
final class LZWEncoder extends java.lang.Object implements Encoder
LZWEncoderInspired by LZWTreeEncoder by Wen Yu and the algorithm described by Bob Montgomery which "[...] uses a tree method to search if a new string is already in the table, which is much simpler, faster, and easier to understand than hashing."
- Version:
- $Id: LZWEncoder.java,v 1.0 02.12.13 14:13 haraldk Exp$
-
-
Field Summary
Fields Modifier and Type Field Description private intbitPosprivate intbitsprivate intbitsPerCodeprivate short[]CHILDREN(package private) static intCLEAR_CODEClear: Re-initialize tables.(package private) static intEOI_CODEEnd of Information.private static intMAX_BITSprivate intmaxCodeprivate static intMIN_BITSprivate intnextValidCodeprivate intparentprivate longremainingprivate short[]SIBLINGSprivate short[]SUFFIXESprivate static intTABLE_SIZE
-
Constructor Summary
Constructors Constructor Description LZWEncoder(long length)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static intbitmaskFor(int bits)voidencode(java.io.OutputStream stream, java.nio.ByteBuffer buffer)Encodes up tobuffer.remaining()bytes into the given input stream, from the given buffer.(package private) voidencodeBytes(java.io.OutputStream stream, java.nio.ByteBuffer buffer)private voidincreaseCodeSizeOrResetIfNeeded(java.io.OutputStream stream)private static intmaxValue(int codeLen)private voidresetTables()private voidwriteCode(java.io.OutputStream stream, int code)
-
-
-
Field Detail
-
CLEAR_CODE
static final int CLEAR_CODE
Clear: Re-initialize tables.- See Also:
- Constant Field Values
-
EOI_CODE
static final int EOI_CODE
End of Information.- See Also:
- Constant Field Values
-
MIN_BITS
private static final int MIN_BITS
- See Also:
- Constant Field Values
-
MAX_BITS
private static final int MAX_BITS
- See Also:
- Constant Field Values
-
TABLE_SIZE
private static final int TABLE_SIZE
- See Also:
- Constant Field Values
-
CHILDREN
private final short[] CHILDREN
-
SIBLINGS
private final short[] SIBLINGS
-
SUFFIXES
private final short[] SUFFIXES
-
parent
private int parent
-
bitsPerCode
private int bitsPerCode
-
nextValidCode
private int nextValidCode
-
maxCode
private int maxCode
-
bits
private int bits
-
bitPos
private int bitPos
-
remaining
private long remaining
-
-
Method Detail
-
encode
public void encode(java.io.OutputStream stream, java.nio.ByteBuffer buffer) throws java.io.IOExceptionDescription copied from interface:EncoderEncodes up tobuffer.remaining()bytes into the given input stream, from the given buffer.
-
encodeBytes
void encodeBytes(java.io.OutputStream stream, java.nio.ByteBuffer buffer) throws java.io.IOException- Throws:
java.io.IOException
-
increaseCodeSizeOrResetIfNeeded
private void increaseCodeSizeOrResetIfNeeded(java.io.OutputStream stream) throws java.io.IOException- Throws:
java.io.IOException
-
resetTables
private void resetTables()
-
writeCode
private void writeCode(java.io.OutputStream stream, int code) throws java.io.IOException- Throws:
java.io.IOException
-
maxValue
private static int maxValue(int codeLen)
-
bitmaskFor
private static int bitmaskFor(int bits)
-
-