Class Bzip2HuffmanStageDecoder


  • final class Bzip2HuffmanStageDecoder
    extends java.lang.Object
    A decoder for the Bzip2 Huffman coding stage.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) int alphabetSize
      The total number of codes (uniform for each table).
      private int[][] codeBases
      An array of values for each Huffman table that must be subtracted from the numerical value of a Huffman code of a given bit length to give its canonical code index.
      private int[][] codeLimits
      An array of values for each Huffman table that gives the highest numerical value of a Huffman code of a given bit length.
      private int[][] codeSymbols
      A mapping for each Huffman table from canonical code index to output symbol.
      (package private) int currentAlpha  
      (package private) int currentGroup  
      (package private) int currentLength  
      (package private) int currentSelector  
      private int currentTable
      The Huffman table for the current group.
      private int groupIndex
      The index of the current group within the selectors array.
      private int groupPosition
      The byte position within the current group.
      private int[] minimumLengths
      The minimum code length for each Huffman table.
      (package private) boolean modifyLength  
      private Bzip2BitReader reader
      A reader that provides bit-level reads.
      (package private) byte[] selectors
      The Huffman table number to use for each group of 50 symbols.
      (package private) byte[][] tableCodeLengths
      The Canonical Huffman code lengths for each table.
      (package private) Bzip2MoveToFrontTable tableMTF
      Table for Move To Front transformations.
      (package private) int totalTables
      Total number of used Huffman tables in range 2..6.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) void createHuffmanDecodingTables()
      Constructs Huffman decoding tables from lists of Canonical Huffman code lengths.
      (package private) int nextSymbol()
      Decodes and returns the next symbol.
      • Methods inherited from class java.lang.Object

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

      • reader

        private final Bzip2BitReader reader
        A reader that provides bit-level reads.
      • selectors

        byte[] selectors
        The Huffman table number to use for each group of 50 symbols.
      • minimumLengths

        private final int[] minimumLengths
        The minimum code length for each Huffman table.
      • codeBases

        private final int[][] codeBases
        An array of values for each Huffman table that must be subtracted from the numerical value of a Huffman code of a given bit length to give its canonical code index.
      • codeLimits

        private final int[][] codeLimits
        An array of values for each Huffman table that gives the highest numerical value of a Huffman code of a given bit length.
      • codeSymbols

        private final int[][] codeSymbols
        A mapping for each Huffman table from canonical code index to output symbol.
      • currentTable

        private int currentTable
        The Huffman table for the current group.
      • groupIndex

        private int groupIndex
        The index of the current group within the selectors array.
      • groupPosition

        private int groupPosition
        The byte position within the current group. A new group is selected every 50 decoded bytes.
      • totalTables

        final int totalTables
        Total number of used Huffman tables in range 2..6.
      • alphabetSize

        final int alphabetSize
        The total number of codes (uniform for each table).
      • currentSelector

        int currentSelector
      • tableCodeLengths

        final byte[][] tableCodeLengths
        The Canonical Huffman code lengths for each table.
      • currentGroup

        int currentGroup
      • currentLength

        int currentLength
      • currentAlpha

        int currentAlpha
      • modifyLength

        boolean modifyLength
    • Constructor Detail

      • Bzip2HuffmanStageDecoder

        Bzip2HuffmanStageDecoder​(Bzip2BitReader reader,
                                 int totalTables,
                                 int alphabetSize)
    • Method Detail

      • createHuffmanDecodingTables

        void createHuffmanDecodingTables()
        Constructs Huffman decoding tables from lists of Canonical Huffman code lengths.
      • nextSymbol

        int nextSymbol()
        Decodes and returns the next symbol.
        Returns:
        The decoded symbol