public abstract class LZEncoder
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
void |
copyUncompressed(java.io.OutputStream out,
int backward,
int len) |
int |
fillWindow(byte[] in,
int off,
int len)
Copies new data into the LZEncoder's buffer.
|
int |
getAvail()
Get the number of bytes available, including the current byte.
|
int |
getByte(int backward)
Gets the byte from the given backward offset.
|
int |
getByte(int forward,
int backward)
Gets the byte from the given forward minus backward offset.
|
static LZEncoder |
getInstance(int dictSize,
int extraSizeBefore,
int extraSizeAfter,
int niceLen,
int matchLenMax,
int mf,
int depthLimit)
Creates a new LZEncoder.
|
abstract Matches |
getMatches()
Runs match finder for the next byte and returns the matches found.
|
int |
getMatchLen(int dist,
int lenLimit)
Get the length of a match at the given distance.
|
int |
getMatchLen(int forward,
int dist,
int lenLimit)
Get the length of a match at the given distance and forward offset.
|
static int |
getMemoryUsage(int dictSize,
int extraSizeBefore,
int extraSizeAfter,
int matchLenMax,
int mf)
Gets approximate memory usage of the LZEncoder base structure and
the match finder as kibibytes.
|
int |
getPos()
Gets the lowest four bits of the absolute offset of the current byte.
|
boolean |
hasEnoughData(int alreadyReadLen)
Tests if there is enough input available to let the caller encode
at least one more byte.
|
boolean |
isStarted()
Returns true if at least one byte has already been run through
the match finder.
|
void |
setFinishing()
Marks that there is no more input remaining.
|
void |
setFlushing()
Marks that all the input needs to be made available in
the encoded output.
|
void |
setPresetDict(int dictSize,
byte[] presetDict)
Sets a preset dictionary.
|
abstract void |
skip(int len)
Skips the given number of bytes in the match finder.
|
boolean |
verifyMatches(Matches matches)
Verifies that the matches returned by the match finder are valid.
|
public static final int MF_HC4
public static final int MF_BT4
public static int getMemoryUsage(int dictSize, int extraSizeBefore, int extraSizeAfter, int matchLenMax, int mf)
public static LZEncoder getInstance(int dictSize, int extraSizeBefore, int extraSizeAfter, int niceLen, int matchLenMax, int mf, int depthLimit)
dictSize
- dictionary sizeextraSizeBefore
- number of bytes to keep available in the
history in addition to dictSizeextraSizeAfter
- number of bytes that must be available
after current position + matchLenMaxniceLen
- if a match of at least niceLen
bytes is found, be happy with it and don't
stop looking for longer matchesmatchLenMax
- don't test for matches longer than
matchLenMax
bytesmf
- match finder IDdepthLimit
- match finder search depth limitpublic void setPresetDict(int dictSize, byte[] presetDict)
public int fillWindow(byte[] in, int off, int len)
public boolean isStarted()
public void setFlushing()
public void setFinishing()
public boolean hasEnoughData(int alreadyReadLen)
public void copyUncompressed(java.io.OutputStream out, int backward, int len) throws java.io.IOException
java.io.IOException
public int getAvail()
Note that the result is undefined if getMatches
or
skip
hasn't been called yet and no preset dictionary
is being used.
public int getPos()
public int getByte(int backward)
The current byte is at
This function is equivalent to 0
, the previous byte
at 1
etc. To get a byte at zero-based distance,
use getByte(dist + 1)
.
getByte(0, backward)
.
public int getByte(int forward, int backward)
public int getMatchLen(int dist, int lenLimit)
dist
- zero-based distance of the match to testlenLimit
- don't test for a match longer than thispublic int getMatchLen(int forward, int dist, int lenLimit)
forward
- forward offsetdist
- zero-based distance of the match to testlenLimit
- don't test for a match longer than thispublic boolean verifyMatches(Matches matches)
matches
- return value from getMatches
public abstract Matches getMatches()
public abstract void skip(int len)