Class RANSEncode<T extends RANSParams>

java.lang.Object
htsjdk.samtools.cram.compression.rans.RANSEncode<T>
Direct Known Subclasses:
RANS4x8Encode, RANSNx16Encode

public abstract class RANSEncode<T extends RANSParams> extends Object
Abstract base class for rANS encoders (both 4x8 and Nx16). Holds the shared encoding symbol matrix and provides helper methods for frequency-to-symbol setup.

The encoding symbol matrix is allocated once at construction and reused across compress calls. Between calls, only the symbols that were actually used are reset.

  • Constructor Details

    • RANSEncode

      protected RANSEncode()
  • Method Details

    • getEncodingSymbols

      protected final RANSEncodingSymbol[][] getEncodingSymbols()
    • compress

      public abstract byte[] compress(byte[] input, T params)
      Compress a byte array using this rANS encoder.
      Parameters:
      input - the data to compress
      params - encoder-specific parameters (order, flags, etc.)
      Returns:
      the compressed byte stream
    • buildSymsOrder0

      protected final void buildSymsOrder0(int[] frequencies)
      Set up encoding symbols for Order-0 from the given normalized frequency table. Only symbols with non-zero frequency are initialized; others are reset to zero.
    • buildSymsOrder1

      protected final void buildSymsOrder1(int[][] frequencies)
      Set up encoding symbols for Order-1 from the given normalized frequency tables. Each row corresponds to one context symbol.