RPNX::Compress
Self-contained C++20 compression and ZIP library
 
Loading...
Searching...
No Matches
rpnx::compression::xz_codec::range_decoder Class Reference

One-shot LZMA range decoder. More...

#include <xz.hpp>

Public Member Functions

 range_decoder (std::span< std::byte const > input)
 Initializes a decoder from one complete LZMA chunk.
 
std::uint8_t decode_bit (std::uint16_t &probability)
 Decodes one adaptive binary symbol.
 
std::uint32_t decode_tree (std::span< std::uint16_t > probabilities, std::uint32_t leaf_base)
 Decodes a most-significant-bit-first probability tree.
 
std::uint32_t decode_reverse_tree (std::span< std::uint16_t > probabilities, std::ptrdiff_t base, std::uint8_t bit_count)
 Decodes a least-significant-bit-first probability tree.
 
std::uint32_t decode_direct (std::uint8_t bit_count)
 Decodes equiprobable direct bits.
 
void finish ()
 Validate exact consumption and the LZMA terminal range state.
 

Detailed Description

One-shot LZMA range decoder.

Definition at line 167 of file xz.hpp.

Constructor & Destructor Documentation

◆ range_decoder()

rpnx::compression::xz_codec::range_decoder::range_decoder ( std::span< std::byte const > input)
inlineexplicit

Initializes a decoder from one complete LZMA chunk.

Parameters
inputComplete range-coded chunk retained for this object's lifetime.

Definition at line 174 of file xz.hpp.

Member Function Documentation

◆ decode_bit()

std::uint8_t rpnx::compression::xz_codec::range_decoder::decode_bit ( std::uint16_t & probability)
inlinenodiscard

Decodes one adaptive binary symbol.

Parameters
probabilityProbability updated in place after the decision.
Returns
Zero or one.

Definition at line 191 of file xz.hpp.

References rpnx::compression::xz_codec::probability_move_bits, and rpnx::compression::xz_codec::probability_total.

Referenced by rpnx::compression::xz_codec::decode_length(), rpnx::compression::xz_codec::decode_lzma_chunk(), decode_reverse_tree(), and decode_tree().

◆ decode_direct()

std::uint32_t rpnx::compression::xz_codec::range_decoder::decode_direct ( std::uint8_t bit_count)
inlinenodiscard

Decodes equiprobable direct bits.

Parameters
bit_countNumber of bits to decode.
Returns
Decoded most-significant-bit-first value.

Definition at line 257 of file xz.hpp.

Referenced by rpnx::compression::xz_codec::decode_lzma_chunk().

◆ decode_reverse_tree()

std::uint32_t rpnx::compression::xz_codec::range_decoder::decode_reverse_tree ( std::span< std::uint16_t > probabilities,
std::ptrdiff_t base,
std::uint8_t bit_count )
inlinenodiscard

Decodes a least-significant-bit-first probability tree.

Parameters
probabilitiesBacking probability table updated in place.
baseOffset immediately before the tree's root.
bit_countTree depth.
Returns
Reversed decoded value.

Definition at line 234 of file xz.hpp.

References decode_bit(), rpnx::compression::invalid_data, and rpnx::compression::xz.

Referenced by rpnx::compression::xz_codec::decode_lzma_chunk().

◆ decode_tree()

std::uint32_t rpnx::compression::xz_codec::range_decoder::decode_tree ( std::span< std::uint16_t > probabilities,
std::uint32_t leaf_base )
inlinenodiscard

Decodes a most-significant-bit-first probability tree.

Parameters
probabilitiesTree probabilities updated in place.
leaf_baseFirst leaf index, which must be a power of two.
Returns
Tree leaf index including leaf_base.

Definition at line 213 of file xz.hpp.

References decode_bit(), rpnx::compression::invalid_data, and rpnx::compression::xz.

Referenced by rpnx::compression::xz_codec::decode_length(), and rpnx::compression::xz_codec::decode_lzma_chunk().

◆ finish()

void rpnx::compression::xz_codec::range_decoder::finish ( )
inline

Validate exact consumption and the LZMA terminal range state.

Definition at line 276 of file xz.hpp.

References rpnx::compression::invalid_data, and rpnx::compression::xz.

Referenced by rpnx::compression::xz_codec::decode_lzma_chunk().


The documentation for this class was generated from the following file: