Class Utils
java.lang.Object
htsjdk.samtools.cram.compression.rans.Utils
Utility methods for rANS encoding and decoding: cumulative frequency lookup,
state renormalization, and frequency table normalization.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidnormaliseFrequenciesOrder0(int[] F, int bits) Normalize symbol frequencies so they sum to1 << bits.static voidnormaliseFrequenciesOrder0Shift(int[] frequencies, int bits) Shift-based frequency normalization: scale frequencies by a power of 2 so they sum to1 << bits.static voidnormaliseFrequenciesOrder1(int[][] F, int shift) Normalize Order-1 frequency tables: for each context symbol with non-zero frequency, compute the minimum bit size and normalize that context's frequency table.static voidnormaliseFrequenciesOrder1Shift(int[][] F, int shift) Shift-based normalization for all Order-1 context rows.static longRANSDecodeRenormalize4x8(long r, byte[] buf, int[] posHolder) 4x8 renormalization: reads 1 byte at a time from buf at posHolder[0] until state reaches lower bound.static longRANSDecodeRenormalizeNx16(long r, byte[] buf, int[] posHolder) Nx16 renormalization: reads 2 LE bytes from buf at posHolder[0] if state is below lower bound.static intRANSGetCumulativeFrequency(long r, int scaleBits) Extract the cumulative frequency from a rANS state by masking off the lowerscaleBitsbits.
-
Constructor Details
-
Utils
public Utils()
-
-
Method Details
-
RANSGetCumulativeFrequency
public static int RANSGetCumulativeFrequency(long r, int scaleBits) Extract the cumulative frequency from a rANS state by masking off the lowerscaleBitsbits.- Parameters:
r- the current rANS statescaleBits- log2 of the total frequency sum- Returns:
- the cumulative frequency used to look up the decoded symbol
-
RANSDecodeRenormalizeNx16
public static long RANSDecodeRenormalizeNx16(long r, byte[] buf, int[] posHolder) Nx16 renormalization: reads 2 LE bytes from buf at posHolder[0] if state is below lower bound. -
RANSDecodeRenormalize4x8
public static long RANSDecodeRenormalize4x8(long r, byte[] buf, int[] posHolder) 4x8 renormalization: reads 1 byte at a time from buf at posHolder[0] until state reaches lower bound. -
normaliseFrequenciesOrder0
public static void normaliseFrequenciesOrder0(int[] F, int bits) Normalize symbol frequencies so they sum to1 << bits. Uses fixed-point arithmetic to scale frequencies proportionally. -
normaliseFrequenciesOrder1
public static void normaliseFrequenciesOrder1(int[][] F, int shift) Normalize Order-1 frequency tables: for each context symbol with non-zero frequency, compute the minimum bit size and normalize that context's frequency table. -
normaliseFrequenciesOrder0Shift
public static void normaliseFrequenciesOrder0Shift(int[] frequencies, int bits) Shift-based frequency normalization: scale frequencies by a power of 2 so they sum to1 << bits. -
normaliseFrequenciesOrder1Shift
public static void normaliseFrequenciesOrder1Shift(int[][] F, int shift) Shift-based normalization for all Order-1 context rows.
-