Top Description Constructors Methods
io.netty5.handler.codec.compression

pack-priv final Class Bzip2HuffmanAllocator

extends Object
Class Inheritance

An in-place, length restricted Canonical Huffman code length allocator.
Based on the algorithm proposed by R. L. Milidi'u, A. A. Pessoa and E. S. Laber in In-place Length-Restricted Prefix Coding and incorporating additional ideas from the implementation of shcodec by Simakov Alexander.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv static void
allocateHuffmanCodeLengths(final int[]
On input, a sorted array of symbol frequencies; On output, an array of Canonical Huffman code lengths
array
,
final int
The maximum code length. Must be at least ceil(log2(array.length))
maximumLength
)

Allocates Canonical Huffman code lengths in place based on a sorted frequency array.

private static void
allocateNodeLengths(final int[]
The code length array
array
)

A final allocation pass with no code length limit.

private static void
allocateNodeLengthsWithRelocation(final int[]
The code length array
array
,
final int
The number of internal nodes to be relocated
nodesToMove
,
final int
The depth at which to insert relocated nodes
insertDepth
)

A final allocation pass that relocates nodes in order to achieve a maximum code length limit.

private static int

Returns:

The number of nodes to relocate
findNodesToRelocate
(final int[]
The code length array
array
,
final int
The maximum bit length for the generated codes
maximumLength
)

Finds the number of nodes to relocate in order to achieve a given code length limit.

private static int

Returns:

The smallest k such that nodesToMove <= k <= i and i <= (array[k] % array.length)
first
(final int[]
The code length array
array
,
int
The input position
i
,
final int
The number of internal nodes to be relocated
nodesToMove
)

private static void
setExtendedParentPointers(final int[]
The code length array
array
)

Fills the code array with extended parent pointers.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Bzip2HuffmanAllocatorback to summary
private Bzip2HuffmanAllocator()

Method Detail

allocateHuffmanCodeLengthsback to summary
pack-priv static void allocateHuffmanCodeLengths(final int[] array, final int maximumLength)

Allocates Canonical Huffman code lengths in place based on a sorted frequency array.

Parameters
array:int[]

On input, a sorted array of symbol frequencies; On output, an array of Canonical Huffman code lengths

maximumLength:int

The maximum code length. Must be at least ceil(log2(array.length))

allocateNodeLengthsback to summary
private static void allocateNodeLengths(final int[] array)

A final allocation pass with no code length limit.

Parameters
array:int[]

The code length array

allocateNodeLengthsWithRelocationback to summary
private static void allocateNodeLengthsWithRelocation(final int[] array, final int nodesToMove, final int insertDepth)

A final allocation pass that relocates nodes in order to achieve a maximum code length limit.

Parameters
array:int[]

The code length array

nodesToMove:int

The number of internal nodes to be relocated

insertDepth:int

The depth at which to insert relocated nodes

findNodesToRelocateback to summary
private static int findNodesToRelocate(final int[] array, final int maximumLength)

Finds the number of nodes to relocate in order to achieve a given code length limit.

Parameters
array:int[]

The code length array

maximumLength:int

The maximum bit length for the generated codes

Returns:int

The number of nodes to relocate

firstback to summary
private static int first(final int[] array, int i, final int nodesToMove)
Parameters
array:int[]

The code length array

i:int

The input position

nodesToMove:int

The number of internal nodes to be relocated

Returns:int

The smallest k such that nodesToMove <= k <= i and i <= (array[k] % array.length)

setExtendedParentPointersback to summary
private static void setExtendedParentPointers(final int[] array)

Fills the code array with extended parent pointers.

Parameters
array:int[]

The code length array