Class RANSDecode

java.lang.Object
htsjdk.samtools.cram.compression.rans.RANSDecode
Direct Known Subclasses:
RANS4x8Decode, RANSNx16Decode

public abstract class RANSDecode extends Object
Abstract base class for rANS decoders (both 4x8 and Nx16). Holds the shared decoding state: per-context frequency tables, reverse-lookup tables, and decoding symbols.

State is allocated once at construction and reused across calls. Between calls, only the rows that were actually used in the previous decode are reset, avoiding the O(65536) full reset that would otherwise be required.

  • Constructor Details

    • RANSDecode

      protected RANSDecode()
  • Method Details

    • getFrequencies

      protected final int[][] getFrequencies()
    • getReverseLookup

      protected final byte[][] getReverseLookup()
    • getDecodingSymbols

      protected final RANSDecodingSymbol[][] getDecodingSymbols()
    • uncompress

      public abstract byte[] uncompress(byte[] input)
      Uncompress a rANS-encoded byte stream.
      Parameters:
      input - the compressed byte stream (format-specific header + encoded data)
      Returns:
      the uncompressed data
    • markRowUsed

      protected final void markRowUsed(int row)
      Mark a context row as used. Called by subclass readFrequencyTable methods when populating a row. Enables selective reset on the next resetDecoderState() call.
    • resetDecoderState

      protected final void resetDecoderState()
      Reset only the decoder rows that were used in the previous decode operation. Called at the start of each uncompress to prepare for new data.