Fingerprint_Card

Loading...
Searching...
No Matches
ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine Class Reference

Low level compression engine for deflate algorithm which uses a 32K sliding window with secondary compression from Huffman/Shannon-Fano codes. More...

Inheritance diagram for ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine:
[legend]
Collaboration diagram for ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine:
[legend]

## Public Member Functions
| DeflaterEngine (DeflaterPending pending)
| Construct instance with pending buffer.
bool | Deflate (bool flush, bool finish)
| Deflate drives actual compression of data.
void | SetInput (byte[] buffer, int offset, int count)
| Sets input data to be deflated. Should only be called when.
bool | NeedsInput ()
| Determines if more input is needed.
void | SetDictionary (byte[] buffer, int offset, int length)
| Set compression dictionary.
void | Reset ()
| Reset internal state.
void | ResetAdler ()
| Reset Adler checksum.
void | SetLevel (int level)
| Set the deflate level (0-9)
void | FillWindow ()
| Fill the window.

## Properties
int | Adler`[get]`
| Get current value of Adler checksum.
long | TotalIn`[get]`
| Total data processed.
DeflateStrategy | Strategy`[get, set]`
| Get/set the deflate strategy

## Private Member Functions
void | UpdateHash ()
int | InsertString ()
| Inserts the current string in the head hash and returns the previous value for this hash.
void | SlideWindow ()
bool | FindLongestMatch (int curMatch)
| Find the best (longest) string in the window matching the string starting at strstart.
bool | DeflateStored (bool flush, bool finish)
bool | DeflateFast (bool flush, bool finish)
bool | DeflateSlow (bool flush, bool finish)

## Private Attributes
int | ins_h
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.
short[] | prev
int | matchStart
int | matchLen
bool | prevAvailable
int | blockStart
int | strstart
| Points to the current character in the window.
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.
byte[] | window
| This array contains the part of the uncompressed stream that is of relevance. The current character is indexed by strstart.
DeflateStrategy | strategy
int | max_chain
int | max_lazy
int | niceLength
int | goodLength
int | compressionFunction
| The current compression function.
byte[] | inputBuf
| The input data for compression.
long | totalIn
| The total bytes of input read.
int | inputOff
| The offset into inputBuf, where input data starts.
int | inputEnd
| The end offset of the input data.
DeflaterPending | pending
DeflaterHuffman | huffman
Adler32 | adler
| The adler checksum.

## Static Private Attributes
const int | TooFar = 4096

## Additional Inherited Members
Static Public Attributes inherited from ICSharpCode.SharpZipLib.Zip.Compression.DeflaterConstants
const bool | DEBUGGING = false
| Set to true to enable debugging.
const int | STORED_BLOCK = 0
| Written to Zip file to identify a stored block.
const int | STATIC_TREES = 1
| Identifies static tree in Zip file.
const int | DYN_TREES = 2
| Identifies dynamic tree in Zip file.
const int | PRESET_DICT = 0x20
| Header flag indicating a preset dictionary for deflation.
const int | DEFAULT_MEM_LEVEL = 8
| Sets internal buffer sizes for Huffman encoding.
const int | MAX_MATCH = 258
| Internal compression engine constant.
const int | MIN_MATCH = 3
| Internal compression engine constant.
const int | MAX_WBITS = 15
| Internal compression engine constant.
const int | WSIZE = 1 << MAX_WBITS
| Internal compression engine constant.
const int | WMASK = WSIZE - 1
| Internal compression engine constant.
const int | HASH_BITS = DEFAULT_MEM_LEVEL + 7
| Internal compression engine constant.
const int | HASH_SIZE = 1 << HASH_BITS
| Internal compression engine constant.
const int | HASH_MASK = HASH_SIZE - 1
| Internal compression engine constant.
const int | HASH_SHIFT = (HASH_BITS + MIN_MATCH - 1) / MIN_MATCH
| Internal compression engine constant.
const int | MIN_LOOKAHEAD = MAX_MATCH + MIN_MATCH + 1
| Internal compression engine constant.
const int | MAX_DIST = WSIZE - MIN_LOOKAHEAD
| Internal compression engine constant.
const int | PENDING_BUF_SIZE = 1 << (DEFAULT_MEM_LEVEL + 8)
| Internal compression engine constant.
static int | MAX_BLOCK_SIZE = Math.Min(65535, PENDING_BUF_SIZE - 5)
| Internal compression engine constant.
const int | DEFLATE_STORED = 0
| Internal compression engine constant.
const int | DEFLATE_FAST = 1
| Internal compression engine constant.
const int | DEFLATE_SLOW = 2
| Internal compression engine constant.
static int[] | GOOD_LENGTH = { 0, 4, 4, 4, 4, 8, 8, 8, 32, 32 }
| Internal compression engine constant.
static int[] | MAX_LAZY = { 0, 4, 5, 6, 4, 16, 16, 32, 128, 258 }
| Internal compression engine constant.
static int[] | NICE_LENGTH = { 0, 8, 16, 32, 16, 32, 128, 128, 258, 258 }
| Internal compression engine constant.
static int[] | MAX_CHAIN = { 0, 4, 8, 32, 16, 32, 128, 256, 1024, 4096 }
| Internal compression engine constant.
static int[] | COMPR_FUNC = { 0, 1, 1, 1, 1, 2, 2, 2, 2, 2 }
| Internal compression engine constant.

## Detailed Description

Low level compression engine for deflate algorithm which uses a 32K sliding window with secondary compression from Huffman/Shannon-Fano codes.

## Constructor & Destructor Documentation

## ◆ DeflaterEngine()

ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.DeflaterEngine | ( | DeflaterPending | pending | ) |

Construct instance with pending buffer.

Parameters

  pending | Pending buffer to use

>

## Member Function Documentation

## ◆ Deflate()

bool ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.Deflate | ( | bool | flush,
|  | bool | finish )

Deflate drives actual compression of data.

Parameters

  flush | True to flush input buffers
  finish | Finish deflation with the current input.

Returns
  Returns true if progress has been made.

Here is the call graph for this function:

## ◆ DeflateFast()

bool ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.DeflateFast | ( | bool | flush,
|  | bool | finish )
| private

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ DeflateSlow()

bool ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.DeflateSlow | ( | bool | flush,
|  | bool | finish )
| private

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ DeflateStored()

bool ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.DeflateStored | ( | bool | flush,
|  | bool | finish )
| private

Here is the caller graph for this function:

## ◆ FillWindow()

void ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.FillWindow | ( |  | ) |

Fill the window.

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ FindLongestMatch()

bool ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.FindLongestMatch | ( | int | curMatch | ) |
| private

Find the best (longest) string in the window matching the string starting at strstart.

Preconditions:

strstart + MAX_MATCH &lt;= window.length.
ICSharpCode.SharpZipLib.Zip.Compression.DeflaterConstants.MAX_MATCH
const int MAX_MATCH
Internal compression engine constant.
Definition DeflaterConstants.cs:83
ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.strstart
int strstart
Points to the current character in the window.
Definition DeflaterEngine.cs:816
ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.window
byte[] window
This array contains the part of the uncompressed stream that is of relevance. The current character i...
Definition DeflaterEngine.cs:830

Parameters

  curMatch |

Returns
  True if a match greater than the minimum length is found

Here is the caller graph for this function:

## ◆ InsertString()

int ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.InsertString | ( |  | ) |
| private

Inserts the current string in the head hash and returns the previous value for this hash.

Returns
  The previous hash value

Here is the caller graph for this function:

## ◆ NeedsInput()

bool ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.NeedsInput | ( |  | ) |

Determines if more input is needed.

Returns
  Return true if input is needed via SetInput

## ◆ Reset()

void ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.Reset | ( |  | ) |

Reset internal state.

## ◆ ResetAdler()

void ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.ResetAdler | ( |  | ) |

Reset Adler checksum.

## ◆ SetDictionary()

void ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.SetDictionary | ( | byte[] | buffer,
|  | int | offset,
|  | int | length )

Set compression dictionary.

Parameters

  buffer | The buffer containing the dictionary data
  offset | The offset in the buffer for the first byte of data
  length | The length of the dictionary data.

Here is the call graph for this function:

## ◆ SetInput()

void ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.SetInput | ( | byte[] | buffer,
|  | int | offset,
|  | int | count )

Sets input data to be deflated. Should only be called when.

NeedsInput()
ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.NeedsInput
bool NeedsInput()
Determines if more input is needed.
Definition DeflaterEngine.cs:206

returns true

Parameters

  buffer | The buffer containing input data.
  offset | The offset of the first byte of data.
  count | The number of bytes of data to use as input.

## ◆ SetLevel()

void ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.SetLevel | ( | int | level | ) |

Set the deflate level (0-9)

Parameters

  level | The value to set the level to.

Here is the call graph for this function:

## ◆ SlideWindow()

void ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.SlideWindow | ( |  | ) |
| private

Here is the caller graph for this function:

## ◆ UpdateHash()

void ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.UpdateHash | ( |  | ) |
| private

Here is the caller graph for this function:

## Member Data Documentation

## ◆ adler

Adler32 ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.adler
| private

The adler checksum.

## ◆ blockStart

int ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.blockStart
| private

## ◆ compressionFunction

int ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.compressionFunction
| private

The current compression function.

## ◆ goodLength

int ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.goodLength
| private

## ◆ head

short [] ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.head
| private

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.

## ◆ huffman

DeflaterHuffman ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.huffman
| private

## ◆ inputBuf

byte [] ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.inputBuf
| private

The input data for compression.

## ◆ inputEnd

int ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.inputEnd
| private

The end offset of the input data.

## ◆ inputOff

int ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.inputOff
| private

The offset into inputBuf, where input data starts.

## ◆ ins_h

int ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.ins_h
| private

## ◆ lookahead

int ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.lookahead
| private

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.

## ◆ matchLen

int ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.matchLen
| private

## ◆ matchStart

int ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.matchStart
| private

## ◆ max_chain

int ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.max_chain
| private

## ◆ max_lazy

int ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.max_lazy
| private

## ◆ niceLength

int ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.niceLength
| private

## ◆ pending

DeflaterPending ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.pending
| private

## ◆ prev

short [] ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.prev
| private

prev[index &amp; WMASK]
ICSharpCode.SharpZipLib.Zip.Compression.DeflaterConstants.WMASK
const int WMASK
Internal compression engine constant.
Definition DeflaterConstants.cs:103
ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.prev
short[] prev
Definition DeflaterEngine.cs:804

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.

## ◆ prevAvailable

bool ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.prevAvailable
| private

## ◆ strategy

DeflateStrategy ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.strategy
| private

## ◆ strstart

int ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.strstart
| private

Points to the current character in the window.

## ◆ TooFar

const int ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.TooFar = 4096
| static private

## ◆ totalIn

long ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.totalIn
| private

The total bytes of input read.

## ◆ window

byte [] ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.window
| private

This array contains the part of the uncompressed stream that is of relevance. The current character is indexed by strstart.

## Property Documentation

## ◆ Adler

int ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.Adler
| get

Get current value of Adler checksum.

## ◆ Strategy

DeflateStrategy ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.Strategy
| get set

Get/set the deflate strategy

## ◆ TotalIn

long ICSharpCode.SharpZipLib.Zip.Compression.DeflaterEngine.TotalIn
| get

Total data processed.

The documentation for this class was generated from the following file:

- ICSharpCode.SharpZLib/Zip/Compression/DeflaterEngine.cs