C# Class Blast.Blast.HuffmanTable

Huffman code decoding tables. count[1..MAXBITS] is the number of symbols of each length, which for a canonical code are stepped through in order. symbol[] are the symbol values in canonical order, where the number of entries is the sum of the counts in count[]. The decoding process can be seen in the function decode() below.
Show file Open project: Nihlus/libwarcraft

Public Properties

Property Type Description
DISTANCE_CODE HuffmanTable
LENGTH_CODE HuffmanTable
LITERAL_CODE HuffmanTable
count short[]
symbol short[]

Public Methods

Method Description
HuffmanTable ( int symbolSize, byte compacted ) : System

Private Methods

Method Description
Construct ( byte rep ) : int

Given a list of repeated code lengths rep[0..n-1], where each byte is a count (high four bits + 1) and a code length (low four bits), generate the list of code lengths. This compaction reduces the size of the object code. Then given the list of code lengths length[0..n-1] representing a canonical Huffman code for n symbols, construct the tables required to decode those codes. Those tables are the number of codes of each length, and the symbols sorted by length, retaining their original order within each length. The return value is zero for a complete code set, negative for an over- subscribed code set, and positive for an incomplete code set. The tables can be used if the return value is zero or positive, but they cannot be used if the return value is negative. If the return value is zero, it is not possible for decode() using that table to return an error -- any stream of enough bits will resolve to a symbol. If the return value is positive, then it is possible for decode() using that table to return an error for received codes past the end of the incomplete lengths.

Method Details

HuffmanTable() public method

public HuffmanTable ( int symbolSize, byte compacted ) : System
symbolSize int
compacted byte
return System

Property Details

DISTANCE_CODE public static property

public static HuffmanTable DISTANCE_CODE
return HuffmanTable

LENGTH_CODE public static property

public static HuffmanTable LENGTH_CODE
return HuffmanTable

LITERAL_CODE public static property

public static HuffmanTable LITERAL_CODE
return HuffmanTable

count public property

public short[] count
return short[]

symbol public property

public short[] symbol
return short[]