| Modifier and Type | Field and Description |
|---|---|
| private static final int | HUFFMAN_HIGH_SYMBOL_COST
Used in initial Huffman table generation. |
| private final int[][] | huffmanCodeLengths
The Canonical Huffman code lengths for each table. |
| private final int[][] | huffmanMergedCodeSymbols
Merged code symbols for each table. |
| private final int | mtfAlphabetSize
The number of unique values in the |
| private final char[] | mtfBlock
The output of the Move To Front Transform and Run Length Encoding[2] stages. |
| private final int | |
| private final int[] | mtfSymbolFrequencies
The global frequencies of values within the |
| private final byte[] | selectors
The selectors for each segment. |
| private final Bzip2BitWriter | writer
The |
| Access | Constructor and Description |
|---|---|
| pack-priv | Bzip2HuffmanStageEncoder(final Bzip2BitWriter
The writer, final char[] Bzip2BitWriter which provides bit-level writesThe MTF block data mtfBlock, final int The actual length of the MTF block mtfLength, final int The size of the MTF block's alphabet mtfAlphabetSize, final int[] The frequencies the MTF block's symbols mtfSymbolFrequencies)
|
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| pack-priv void | |
| private static void | generateHuffmanCodeLengths(final int
The total number of symbols alphabetSize, final int[] The frequencies of the symbols symbolFrequencies, final int[] The array to which the generated code lengths should be written codeLengths)Generate a Huffman code length table for a given list of symbol frequencies. |
| private void | generateHuffmanOptimisationSeeds()
Generate initial Huffman code length tables, giving each table a different low cost section of the alphabet that is roughly equal in overall cumulative frequency. |
| private void | optimiseSelectorsAndHuffmanTables(final boolean
If storeSelectors)true, write out the (final) chosen selectorsCo-optimise the selector list and the alternative Huffman table code lengths. |
| private static int | Returns: The selected table countThe length to select a table count for mtfLength)Selects an appropriate table count for a given MTF length. |
| private void | |
| private void |
| HUFFMAN_HIGH_SYMBOL_COST | back to summary |
|---|---|
| private static final int HUFFMAN_HIGH_SYMBOL_COST Used in initial Huffman table generation. | |
| huffmanCodeLengths | back to summary |
|---|---|
| private final int[][] huffmanCodeLengths The Canonical Huffman code lengths for each table. | |
| huffmanMergedCodeSymbols | back to summary |
|---|---|
| private final int[][] huffmanMergedCodeSymbols Merged code symbols for each table. The value at each position is ((code length << 24) | code). | |
| mtfAlphabetSize | back to summary |
|---|---|
| private final int mtfAlphabetSize The number of unique values in the | |
| mtfBlock | back to summary |
|---|---|
| private final char[] mtfBlock The output of the Move To Front Transform and Run Length Encoding[2] stages. | |
| mtfLength | back to summary |
|---|---|
| private final int mtfLength The actual number of values contained in the | |
| mtfSymbolFrequencies | back to summary |
|---|---|
| private final int[] mtfSymbolFrequencies The global frequencies of values within the | |
| selectors | back to summary |
|---|---|
| private final byte[] selectors The selectors for each segment. | |
| writer | back to summary |
|---|---|
| private final Bzip2BitWriter writer The | |
| Bzip2HuffmanStageEncoder | back to summary |
|---|---|
pack-priv Bzip2HuffmanStageEncoder(final Bzip2BitWriter writer, final char[] mtfBlock, final int mtfLength, final int mtfAlphabetSize, final int[] mtfSymbolFrequencies)
| |
| assignHuffmanCodeSymbols | back to summary |
|---|---|
| private void assignHuffmanCodeSymbols() Assigns Canonical Huffman codes based on the calculated lengths. | |
| encode | back to summary |
|---|---|
| pack-priv void encode(Buffer out) Encodes and writes the block data. | |
| generateHuffmanCodeLengths | back to summary |
|---|---|
| private static void generateHuffmanCodeLengths(final int alphabetSize, final int[] symbolFrequencies, final int[] codeLengths) Generate a Huffman code length table for a given list of symbol frequencies.
| |
| generateHuffmanOptimisationSeeds | back to summary |
|---|---|
| private void generateHuffmanOptimisationSeeds() Generate initial Huffman code length tables, giving each table a different low cost section
of the alphabet that is roughly equal in overall cumulative frequency. Note that the initial
tables are invalid for actual Huffman code generation, and only serve as the seed for later
iterative optimisation in | |
| optimiseSelectorsAndHuffmanTables | back to summary |
|---|---|
| private void optimiseSelectorsAndHuffmanTables(final boolean storeSelectors) Co-optimise the selector list and the alternative Huffman table code lengths. This method is
called repeatedly in the hope that the total encoded size of the selectors, the Huffman code
lengths and the block data encoded with them will converge towards a minimum.
| |
| selectTableCount | back to summary |
|---|---|
| private static int selectTableCount(final int mtfLength) Selects an appropriate table count for a given MTF length.
| |
| writeBlockData | back to summary |
|---|---|
| private void writeBlockData(Buffer out) Writes out the encoded block data. | |
| writeSelectorsAndHuffmanTables | back to summary |
|---|---|
| private void writeSelectorsAndHuffmanTables(Buffer out) Write out the selector list and Huffman tables. | |