# 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 Summary

Constructors
Modifier
Constructor
Description
`protected`
`RANSDecode()`

## Method Summary

Modifier and Type
Method
Description
`protected final RANSDecodingSymbol[][]`
`getDecodingSymbols()`
`protected final int[][]`
`getFrequencies()`
`protected final byte[][]`
`getReverseLookup()`
`protected final void`
`markRowUsed(int row)`
Mark a context row as used.
`protected final void`
`resetDecoderState()`
Reset only the decoder rows that were used in the previous decode operation.
`abstract byte[]`
`uncompress(byte[] input)`
Uncompress a rANS-encoded byte stream.

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## 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.