Class HuffmanDecoder


  • public class HuffmanDecoder
    extends java.lang.Object

    A class to implement Huffman decoding as used by the SCP-ECG standard.

    See Also:
    DefaultHuffmanTable, HuffmanTable
    • Constructor Summary

      Constructors 
      Constructor Description
      HuffmanDecoder​(byte[] bytesToDecompress, int differenceDataUsed, int multiplier, int numberOfHuffmanTables, java.util.ArrayList huffmanTablesList)
      Construct a Huffman decoder for the supplied encoded data, as read from an SCP-ECG file.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      short decode()
      Decode a single value.
      short[] decode​(int nValuesWanted)
      Decode a specified number of values.
      static void main​(java.lang.String[] arg)
      For testing.
      java.lang.String toString()
      Dump the current decoder state as a String.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • HuffmanDecoder

        public HuffmanDecoder​(byte[] bytesToDecompress,
                              int differenceDataUsed,
                              int multiplier,
                              int numberOfHuffmanTables,
                              java.util.ArrayList huffmanTablesList)

        Construct a Huffman decoder for the supplied encoded data, as read from an SCP-ECG file.

        Parameters:
        bytesToDecompress - the compressed data
        differenceDataUsed - 0 = no, 1 = 1 difference value, 2 = 2 difference values
        multiplier - a value by which to scale the decoded values
        numberOfHuffmanTables - how many tables are available for use
        huffmanTablesList - the Huffman tables themselves
    • Method Detail

      • decode

        public final short decode()
                           throws java.lang.Exception

        Decode a single value.

        Returns:
        the decoded value
        Throws:
        java.lang.Exception
      • decode

        public final short[] decode​(int nValuesWanted)
                             throws java.lang.Exception

        Decode a specified number of values.

        Parameters:
        nValuesWanted - the number of decoded values wanted
        Returns:
        the decoded values
        Throws:
        java.lang.Exception
      • toString

        public java.lang.String toString()

        Dump the current decoder state as a String.

        Overrides:
        toString in class java.lang.Object
        Returns:
        the current decoder state as a String
      • main

        public static void main​(java.lang.String[] arg)

        For testing.

        Decodes the byte stream in the example specified in the SCP-ECG standard.

        Parameters:
        arg - none