public class LZWStringTable extends Object
expandCode
added by Robin Luiten
The strLen_ table to give quick access to the lenght of an expanded
code for use by the expandCode
method added by Robin.Modifier and Type | Field and Description |
---|---|
private static short |
HASH_FREE |
private static short |
HASHSIZE |
private static short |
HASHSTEP |
private static int |
MAXBITS |
private static int |
MAXSTR |
private static short |
NEXT_FIRST |
(package private) short |
numStrings_ |
private static int |
RES_CODES
codesize + Reserved Codes
|
(package private) byte[] |
strChr_ |
(package private) short[] |
strHsh_ |
(package private) int[] |
strLen_
each entry corresponds to a code and contains the length of data
that the code expands to when decoded.
|
(package private) short[] |
strNxt_ |
Constructor and Description |
---|
LZWStringTable()
Constructor allocate memory for string store data
|
Modifier and Type | Method and Description |
---|---|
int |
AddCharString(short index,
byte b) |
void |
ClearTable(int codesize) |
void |
dump(PrintStream out) |
int |
expandCode(byte[] buf,
int offset,
short code,
int skipHead)
If expanded data doesnt fit into array only what will fit is written
to buf and the return value indicates how much of the expanded code has
been written to the buf.
|
short |
FindCharString(short index,
byte b) |
static int |
Hash(short index,
byte lastbyte) |
private static final int RES_CODES
private static final short HASH_FREE
private static final short NEXT_FIRST
private static final int MAXBITS
private static final int MAXSTR
private static final short HASHSIZE
private static final short HASHSTEP
byte[] strChr_
short[] strNxt_
short[] strHsh_
short numStrings_
int[] strLen_
public LZWStringTable()
public int AddCharString(short index, byte b)
index
- value of -1 indicates no predecessor [used in initialisation]b
- the byte [character] to add to the string store which follows
the predecessor string specified the index.public short FindCharString(short index, byte b)
index
- index to prefix stringb
- the character that follws the index prefixpublic void ClearTable(int codesize)
codesize
- the size of code to be preallocated for the
string store.public static int Hash(short index, byte lastbyte)
public int expandCode(byte[] buf, int offset, short code, int skipHead)
buf
- buffer to place expanded data intooffset
- offset to place expanded datacode
- the code to expand to the byte array it represents.
PRECONDITION This code must allready be in the LZSSskipHead
- is the number of bytes at the start of the expanded code to
be skipped before data is written to buf. It is possible that skipHead is
equal to codeLen.public void dump(PrintStream out)
Copyright © 2016 Open Microscopy Environment