# Class FQZCompDecode

java.lang.Object
htsjdk.samtools.cram.compression.fqzcomp.FQZCompDecode

public class FQZCompDecode extends Object
Decoder for the CRAM 3.1 FQZComp codec, used for compressing quality scores. Allows the use of previous quality values, position within the read sequence, a sum of the quality differences from the previous quality, and a generic model selector to generate a context model. Uses the range (adaptive arithmetic) codec internally for compression.

## Constructor Summary

Constructors
Constructor
Description
`FQZCompDecode()`

## Method Summary

Modifier and Type
Method
Description
`static void`
`decodeFQZNewRecord(ByteBuffer inBuffer, RangeCoder rangeCoder, FQZModels model, FQZParams fqzParams, FQZState state)`
Decode the header for a new record: selector, length, reverse flag, and duplicate flag.
`static int`
`fqzUpdateContext(FQZParam params, FQZState state, int quality)`
Update the 16-bit context value after encoding/decoding a quality score.
`static void`
`reverseQualities(ByteBuffer outBuffer, int outBufferLength, FQZState fqzState)`
Reverse quality score arrays for records that were flagged for reversal during encoding.
`static ByteBuffer`
`uncompress(ByteBuffer inBuffer)`
Decompress a FQZComp-compressed quality score block.

### Methods inherited from class Object

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

## Constructor Details

### FQZCompDecode

public FQZCompDecode()

## Method Details

### uncompress

public static ByteBuffer uncompress(ByteBuffer inBuffer)
Decompress a FQZComp-compressed quality score block. Reads the uncompressed size, version, parameters, and then decodes quality symbols using adaptive arithmetic coding with the context model defined by the parameters.

Parameters:
  `inBuffer` - the compressed FQZComp data (consumed by this call)
Returns:
  a rewound ByteBuffer containing the decompressed quality scores

### decodeFQZNewRecord

public static void decodeFQZNewRecord(ByteBuffer inBuffer, RangeCoder rangeCoder, FQZModels model, FQZParams fqzParams, FQZState state)
Decode the header for a new record: selector, length, reverse flag, and duplicate flag. Updates the FQZ state with the decoded record metadata.

### fqzUpdateContext

public static int fqzUpdateContext(FQZParam params, FQZState state, int quality)
Update the 16-bit context value after encoding/decoding a quality score. Incorporates quality history, position, delta, and selector into the context based on the parameter configuration. Also decrements the remaining bases counter.

Parameters:
  `params` - the parameter block controlling context bit allocation
  `state` - the mutable encoder/decoder state
  `quality` - the quality value just encoded/decoded
Returns:
  the new 16-bit context value

### reverseQualities

public static void reverseQualities(ByteBuffer outBuffer, int outBufferLength, FQZState fqzState)
Reverse quality score arrays for records that were flagged for reversal during encoding. Called after all quality scores have been decoded when the global DO_REVERSE flag is set.