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 int
bitPos
private int
bits
private int
bitsPerCode
private short[]
CHILDREN
(package private) static int
CLEAR_CODE
Clear: Re-initialize tables.(package private) static int
EOI_CODE
End of Information.private static int
MAX_BITS
private int
maxCode
private static int
MIN_BITS
private int
nextValidCode
private int
parent
private long
remaining
private short[]
SIBLINGS
private short[]
SUFFIXES
private static int
TABLE_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 int
bitmaskFor(int bits)
void
encode(java.io.OutputStream stream, java.nio.ByteBuffer buffer)
Encodes up tobuffer.remaining()
bytes into the given input stream, from the given buffer.(package private) void
encodeBytes(java.io.OutputStream stream, java.nio.ByteBuffer buffer)
private void
increaseCodeSizeOrResetIfNeeded(java.io.OutputStream stream)
private static int
maxValue(int codeLen)
private void
resetTables()
private void
writeCode(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.IOException
Description copied from interface:Encoder
Encodes 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)
-
-