Class Huffman

java.lang.Object
com.itextpdf.io.codec.brotli.dec.Huffman

final class Huffman extends Object
Utilities for building Huffman decoding tables.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) static final int
    Maximum possible Huffman table size for an alphabet size of 704, max code length 15 and root table bits 8.
    private static final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) static void
    buildHuffmanTable(int[] rootTable, int tableOffset, int rootBits, int[] codeLengths, int codeLengthsSize)
    Builds Huffman lookup table assuming code lengths are in symbol order.
    private static int
    getNextKey(int key, int len)
    Returns reverse(reverse(key, len) + 1, len).
    private static int
    nextTableBitSize(int[] count, int len, int rootBits)
     
    private static void
    replicateValue(int[] table, int offset, int step, int end, int item)
    Stores item in table[0], table[step], table[2 * step] .., table[end].

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • HUFFMAN_MAX_TABLE_SIZE

      static final int HUFFMAN_MAX_TABLE_SIZE
      Maximum possible Huffman table size for an alphabet size of 704, max code length 15 and root table bits 8.
      See Also:
    • MAX_LENGTH

      private static final int MAX_LENGTH
      See Also:
  • Constructor Details

    • Huffman

      Huffman()
  • Method Details

    • getNextKey

      private static int getNextKey(int key, int len)
      Returns reverse(reverse(key, len) + 1, len).

      reverse(key, len) is the bit-wise reversal of the len least significant bits of key.

    • replicateValue

      private static void replicateValue(int[] table, int offset, int step, int end, int item)
      Stores item in table[0], table[step], table[2 * step] .., table[end].

      Assumes that end is an integer multiple of step.

    • nextTableBitSize

      private static int nextTableBitSize(int[] count, int len, int rootBits)
      Parameters:
      count - histogram of bit lengths for the remaining symbols,
      len - code length of the next processed symbol.
      Returns:
      table width of the next 2nd level table.
    • buildHuffmanTable

      static void buildHuffmanTable(int[] rootTable, int tableOffset, int rootBits, int[] codeLengths, int codeLengthsSize)
      Builds Huffman lookup table assuming code lengths are in symbol order.