Class LZWEncoder
java.lang.Object
com.twelvemonkeys.imageio.plugins.tiff.LZWEncoder
- All Implemented Interfaces:
Encoder
LZWEncoder
Inspired 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
FieldsModifier and TypeFieldDescriptionprivate intprivate intprivate intprivate final short[](package private) static final intClear: Re-initialize tables.(package private) static final intEnd of Information.private static final intprivate intprivate static final intprivate intprivate intprivate longprivate final short[]private final short[]private static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static intbitmaskFor(int bits) voidencode(OutputStream stream, ByteBuffer buffer) Encodes up tobuffer.remaining()bytes into the given input stream, from the given buffer.(package private) voidencodeBytes(OutputStream stream, ByteBuffer buffer) private voidprivate static intmaxValue(int codeLen) private voidprivate voidwriteCode(OutputStream stream, int code)
-
Field Details
-
CLEAR_CODE
static final int CLEAR_CODEClear: Re-initialize tables.- See Also:
-
EOI_CODE
static final int EOI_CODEEnd of Information.- See Also:
-
MIN_BITS
private static final int MIN_BITS- See Also:
-
MAX_BITS
private static final int MAX_BITS- See Also:
-
TABLE_SIZE
private static final int TABLE_SIZE- See Also:
-
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
-
-
Constructor Details
-
LZWEncoder
LZWEncoder(long length)
-
-
Method Details
-
encode
Description copied from interface:EncoderEncodes up tobuffer.remaining()bytes into the given input stream, from the given buffer.- Specified by:
encodein interfaceEncoder- Parameters:
stream- the output stream to encode data tobuffer- buffer to read data from- Throws:
IOException- if an I/O error occurs
-
encodeBytes
- Throws:
IOException
-
increaseCodeSizeOrResetIfNeeded
- Throws:
IOException
-
resetTables
private void resetTables() -
writeCode
- Throws:
IOException
-
maxValue
private static int maxValue(int codeLen) -
bitmaskFor
private static int bitmaskFor(int bits)
-