Class RANSEncodingSymbol
java.lang.Object
htsjdk.samtools.cram.compression.rans.RANSEncodingSymbol
Encoding state for a single symbol in the rANS codec. Fields are package-private to allow
the encode loops in
RANSNx16Encode and RANS4x8Encode to inline the
renormalization and state-update arithmetic directly, avoiding method call overhead
in the hot inner loop.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongputSymbol4x8(long r, byte[] out, int[] posHolder) byte[] variant for 4x8 encoding — writes backwards, decrementing posHolder[0].longputSymbolNx16(long r, byte[] out, int[] posHolder) byte[] variant for Nx16 encoding — writes backwards (decrementing posHolder[0]).voidreset()Reset all encoding parameters to zero.voidset(int start, int freq, int scaleBits) Initialize encoding parameters for a symbol given its position in the frequency table.
-
Constructor Details
-
RANSEncodingSymbol
public RANSEncodingSymbol()
-
-
Method Details
-
reset
public void reset()Reset all encoding parameters to zero. -
set
public void set(int start, int freq, int scaleBits) Initialize encoding parameters for a symbol given its position in the frequency table. Computes the reciprocal frequency and bias needed for fast integer division during encoding.- Parameters:
start- cumulative frequency of all preceding symbolsfreq- frequency of this symbol (must be > 0)scaleBits- log2 of the total frequency sum
-
putSymbolNx16
public long putSymbolNx16(long r, byte[] out, int[] posHolder) byte[] variant for Nx16 encoding — writes backwards (decrementing posHolder[0]). Renormalization bytes are written so the final memory layout is little-endian (LSB at lower address), matching htslib's RansEncPutSymbol output format. -
putSymbol4x8
public long putSymbol4x8(long r, byte[] out, int[] posHolder) byte[] variant for 4x8 encoding — writes backwards, decrementing posHolder[0].
-