C# Class ComponentAce.Compression.Libs.ZLib.Deflate

Implementation of the Deflate compression algorithm.
Mostrar archivo Open project: jschementi/iron Class Usage Examples

Private Methods

Method Description
Deflate ( ) : System

Default constructor

_tr_align ( ) : void

Send one empty static block to give enough lookahead for inflate. This takes 10 bits, of which 7 may remain in the bit buffer. The current inflate code requires 9 bits of lookahead. If the last two codes for the previous block (real code plus EOB) were coded on 5 bits or less, inflate may have only 5+3 bits of lookahead to decode the last real code. In this case we send two empty static blocks instead of one. (There are no problems if the previous block is stored or fixed.) To simplify the code, we assume the worst case of last real code encoded on one bit only.

_tr_flush_block ( int buf, int stored_len, bool eof ) : void

Determine the best encoding for the current block: dynamic trees, static trees or store, and output the encoded block to the zip file.

_tr_stored_block ( int buf, int stored_len, bool eof ) : void

Send a stored block

_tr_tally ( int dist, int lc ) : bool

Save the match info and tally the frequency counts. Return true if the current block must be flushed.

bi_flush ( ) : void

Flush the bit buffer, keeping at most 7 bits in it.

bi_windup ( ) : void

Flush the bit buffer and align the output on a byte boundary

build_bl_tree ( ) : int

Construct the Huffman tree for the bit lengths and return the index in bl_order of the last bit length code to send.

compress_block ( short ltree, short dtree ) : void

Send the block data compressed using the given Huffman trees

copy_block ( int buf, int len, bool header ) : void

Copy a stored block, storing first the length and its one's complement if requested.

deflate ( ZStream strm, FlushStrategy f ) : int

Performs data compression with the deflate algorithm

deflateEnd ( ) : int

Finish compression with deflate algorithm

deflateInit ( ZStream strm, int level ) : int

Initializes deflate algorithm

deflateInit ( ZStream strm, int level, int bits ) : int

Deflate algorithm initialization

deflateInit2 ( ZStream strm, int level, int method, int windowBits, int memLevel, CompressionStrategy strategy ) : int

Deflate algorithm initialization

deflateParams ( ZStream strm, int level, CompressionStrategy strategy ) : int

Sets deflate algorithm parameters

deflateReset ( ZStream strm ) : int

Resets the current state of deflate object

deflateSetDictionary ( ZStream strm, byte dictionary, int dictLength ) : int

Sets deflate dictionary

deflate_fast ( int flush ) : int

Compress as much as possible from the input stream, return the current block state. This function does not perform lazy evaluation of matches and inserts new strings in the dictionary only for unmatched strings or for short matches. It is used only for the fast compression options.

deflate_slow ( int flush ) : int

Same as above, but achieves better compression. We use a lazy evaluation for matches: a match is finally adopted only if there is no better match at the next Window position.

deflate_stored ( int flush ) : int

Copy without compression as much as possible from the input stream, return the current block state. This function does not insert new strings in the dictionary since uncompressible data is probably not useful. This function is used only for the level=0 compression option. NOTE: this function should be optimized to avoid extra copying from Window to Pending_buf.

fill_window ( ) : void

Fill the Window when the lookahead becomes insufficient. Updates strstart and lookahead. IN assertion: lookahead less than MIN_LOOKAHEAD OUT assertions: strstart less than or equal to window_size-MIN_LOOKAHEAD At least one byte has been ReadPos, or _avail_in == 0; reads are performed for at least two bytes (required for the zip translate_eol option -- not supported here).

flush_block_only ( bool eof ) : void

Flushes block

init_block ( ) : void

Initializes block

lm_init ( ) : void

Initialization

longest_match ( int cur_match ) : int

Finds the longest matching data part

pqdownheap ( short tree, int k ) : void

Restore the heap property by moving down the tree starting at node k, exchanging a node with the smallest of its two sons if necessary, stopping when the heap property is re-established (each father smaller than its two sons).

putShortMSB ( int b ) : void
put_byte ( byte c ) : void

Adds a byte to the buffer

put_byte ( byte p, int start, int len ) : void

Output a byte on the stream. IN assertion: there is enough room in Pending_buf.

put_short ( int w ) : void
scan_tree ( short tree, int max_code ) : void

Scan a literal or distance tree to determine the frequencies of the codes in the bit length tree.

send_all_trees ( int lcodes, int dcodes, int blcodes ) : void

Send the header for a block using dynamic Huffman trees: the counts, the lengths of the bit length codes, the literal tree and the distance tree. IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.

send_bits ( int value_Renamed, int length ) : void
send_code ( int c, short tree ) : void
send_tree ( short tree, int max_code ) : void

Send a literal or distance tree in compressed form, using the codes in bl_tree.

set_data_type ( ) : void

Set the data type to ASCII or BINARY, using a crude approximation: binary if more than 20% of the bytes are <= 6 or >= 128, ascii otherwise. IN assertion: the fields freq of dyn_ltree are set and the total of all frequencies does not exceed 64K (to fit in an int on 16 bit machines).

smaller ( short tree, int n, int m, byte depth ) : bool
tr_init ( ) : void

Initialize the tree data structures for a new zlib stream.