Class HuffmanDecoder

java.lang.Object
com.pixelmed.scpecg.HuffmanDecoder

public class HuffmanDecoder extends Object

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

See Also:
  • Constructor Summary

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

    Modifier and Type
    Method
    Description
    final short
    Decode a single value.
    final short[]
    decode(int nValuesWanted)
    Decode a specified number of values.
    static void
    main(String[] arg)
    For testing.
    Dump the current decoder state as a String.

    Methods inherited from class java.lang.Object

    clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • HuffmanDecoder

      public HuffmanDecoder(byte[] bytesToDecompress, int differenceDataUsed, int multiplier, int numberOfHuffmanTables, 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 Details

    • decode

      public final short decode() throws Exception

      Decode a single value.

      Returns:
      the decoded value
      Throws:
      Exception
    • decode

      public final short[] decode(int nValuesWanted) throws Exception

      Decode a specified number of values.

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

      public String toString()

      Dump the current decoder state as a String.

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

      public static void main(String[] arg)

      For testing.

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

      Parameters:
      arg - none