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 int
private int
private int
private final short[]
(package private) static final int
Clear: Re-initialize tables.(package private) static final int
End of Information.private static final int
private int
private static final int
private int
private int
private long
private final short[]
private final short[]
private static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static int
bitmaskFor
(int bits) void
encode
(OutputStream stream, ByteBuffer buffer) Encodes up tobuffer.remaining()
bytes into the given input stream, from the given buffer.(package private) void
encodeBytes
(OutputStream stream, ByteBuffer buffer) private void
private static int
maxValue
(int codeLen) private void
private void
writeCode
(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:Encoder
Encodes up tobuffer.remaining()
bytes into the given input stream, from the given buffer.- Specified by:
encode
in 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)
-