Package net.sf.jazzlib
Class DeflaterEngine
- java.lang.Object
-
- net.sf.jazzlib.DeflaterEngine
-
- All Implemented Interfaces:
DeflaterConstants
class DeflaterEngine extends java.lang.Object implements DeflaterConstants
-
-
Field Summary
Fields Modifier and Type Field Description private Adler32adlerThe adler checksumprivate intblockStartprivate intcomprFuncThe current compression function.private intgoodLengthprivate short[]headHashtable, hashing three characters to an index for window, so that window[index]..window[index+2] have this hash code.private DeflaterHuffmanhuffmanprivate byte[]inputBufThe input data for compression.private intinputEndThe end offset of the input data.private intinputOffThe offset into inputBuf, where input data starts.private intins_hprivate intlookaheadlookahead is the number of characters starting at strstart in window that are valid.private intmatchLenprivate intmatchStartprivate intmax_chainprivate intmax_lazyprivate intniceLengthprivate DeflaterPendingpendingprivate short[]prevprev[index & WMASK] points to the previous index that has the same hash code as the string starting at index.private booleanprevAvailableprivate intstrategyprivate intstrstartstrstart points to the current character in window.private static intTOO_FARprivate inttotalInThe total bytes of input read.private byte[]windowThis array contains the part of the uncompressed stream that is of relevance.-
Fields inherited from interface net.sf.jazzlib.DeflaterConstants
COMPR_FUNC, DEBUGGING, DEFAULT_MEM_LEVEL, DEFLATE_FAST, DEFLATE_SLOW, DEFLATE_STORED, DYN_TREES, GOOD_LENGTH, HASH_BITS, HASH_MASK, HASH_SHIFT, HASH_SIZE, MAX_BLOCK_SIZE, MAX_CHAIN, MAX_DIST, MAX_LAZY, MAX_MATCH, MAX_WBITS, MIN_LOOKAHEAD, MIN_MATCH, NICE_LENGTH, PENDING_BUF_SIZE, PRESET_DICT, STATIC_TREES, STORED_BLOCK, WMASK, WSIZE
-
-
Constructor Summary
Constructors Constructor Description DeflaterEngine(DeflaterPending pending)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleandeflate(boolean flush, boolean finish)private booleandeflateFast(boolean flush, boolean finish)private booleandeflateSlow(boolean flush, boolean finish)private booleandeflateStored(boolean flush, boolean finish)private voidfillWindow()Fill the window when the lookahead becomes insufficient.private booleanfindLongestMatch(int curMatch)Find the best (longest) string in the window matching the string starting at strstart.intgetAdler()intgetTotalIn()private intinsertString()Inserts the current string in the head hash and returns the previous value for this hash.booleanneedsInput()voidreset()voidresetAdler()(package private) voidsetDictionary(byte[] buffer, int offset, int length)voidsetInput(byte[] buf, int off, int len)voidsetLevel(int lvl)voidsetStrategy(int strat)private voidslideWindow()private voidupdateHash()
-
-
-
Field Detail
-
TOO_FAR
private static final int TOO_FAR
- See Also:
- Constant Field Values
-
ins_h
private int ins_h
-
head
private final short[] head
Hashtable, hashing three characters to an index for window, so that window[index]..window[index+2] have this hash code. Note that the array should really be unsigned short, so you need to and the values with 0xffff.
-
prev
private final short[] prev
prev[index & WMASK] points to the previous index that has the same hash code as the string starting at index. This way entries with the same hash code are in a linked list. Note that the array should really be unsigned short, so you need to and the values with 0xffff.
-
matchStart
private int matchStart
-
matchLen
private int matchLen
-
prevAvailable
private boolean prevAvailable
-
blockStart
private int blockStart
-
strstart
private int strstart
strstart points to the current character in window.
-
lookahead
private int lookahead
lookahead is the number of characters starting at strstart in window that are valid. So window[strstart] until window[strstart+lookahead-1] are valid characters.
-
window
private final byte[] window
This array contains the part of the uncompressed stream that is of relevance. The current character is indexed by strstart.
-
strategy
private int strategy
-
max_chain
private int max_chain
-
max_lazy
private int max_lazy
-
niceLength
private int niceLength
-
goodLength
private int goodLength
-
comprFunc
private int comprFunc
The current compression function.
-
inputBuf
private byte[] inputBuf
The input data for compression.
-
totalIn
private int totalIn
The total bytes of input read.
-
inputOff
private int inputOff
The offset into inputBuf, where input data starts.
-
inputEnd
private int inputEnd
The end offset of the input data.
-
pending
private final DeflaterPending pending
-
huffman
private final DeflaterHuffman huffman
-
adler
private final Adler32 adler
The adler checksum
-
-
Constructor Detail
-
DeflaterEngine
DeflaterEngine(DeflaterPending pending)
-
-
Method Detail
-
reset
public void reset()
-
resetAdler
public final void resetAdler()
-
getAdler
public final int getAdler()
-
getTotalIn
public final int getTotalIn()
-
setStrategy
public final void setStrategy(int strat)
-
setLevel
public void setLevel(int lvl)
-
updateHash
private final void updateHash()
-
insertString
private final int insertString()
Inserts the current string in the head hash and returns the previous value for this hash.
-
slideWindow
private void slideWindow()
-
fillWindow
private void fillWindow()
Fill the window when the lookahead becomes insufficient. Updates strstart and lookahead. OUT assertions: strstart + lookahead <= 2*WSIZE lookahead >= MIN_LOOKAHEAD or inputOff == inputEnd
-
findLongestMatch
private boolean findLongestMatch(int curMatch)
Find the best (longest) string in the window matching the string starting at strstart. Preconditions: strstart + MAX_MATCH <= window.length.- Parameters:
curMatch-
-
setDictionary
void setDictionary(byte[] buffer, int offset, int length)
-
deflateStored
private boolean deflateStored(boolean flush, boolean finish)
-
deflateFast
private boolean deflateFast(boolean flush, boolean finish)
-
deflateSlow
private boolean deflateSlow(boolean flush, boolean finish)
-
deflate
public boolean deflate(boolean flush, boolean finish)
-
setInput
public void setInput(byte[] buf, int off, int len)
-
needsInput
public final boolean needsInput()
-
-