132 [[nodiscard]]
int order(
void )
const {
return( f_order ); }
135 [[nodiscard]] std::uint32_t
sigma(
void )
const {
return( f_sigma ); }
139 [[nodiscard]] std::map< std::uint32_t , std::uint64_t >
140 counts(
const std::vector< std::uint32_t > & ctx )
const;
168 [[nodiscard]] std::vector< Step >
steps( std::uint32_t c )
const;
201 using Counts = std::map< std::uint32_t , std::uint64_t >;
207 template<
class Choose >
208 std::uint32_t walk( Choose choose )
const;
210 static constexpr std::uint64_t kLimit = std::uint64_t( 1 ) << 16;
213 std::uint32_t f_sigma;
214 std::map< std::vector< std::uint32_t > , Counts > f_ctx;
215 std::vector< std::uint32_t > f_hist;
236[[nodiscard]]
inline std::vector< std::uint8_t >
ppmEncode( std::string_view s ,
254[[nodiscard]]
inline std::string
255ppmDecode( std::span< const std::uint8_t > code , std::size_t n ,
int K );
265#include "ADS/compression/impl/PPM.tpp"
The arithmetic code (chapter 12, Statistical Coding, of Ferragina's book), exact and in integers.
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
std::map< std::uint32_t, std::uint64_t > counts(const std::vector< std::uint32_t > &ctx) const
the counts of the symbols seen after the context ctx (the oldest symbol first), empty if ctx was neve...
std::uint32_t sigma(void) const
the size of the alphabet
Definition PPM.h:135
int order(void) const
the order
Definition PPM.h:132
std::uint32_t decode(RangeDecoder &d) const
the symbol coded next in , after the symbols seen, by the walk of steps() that reads in whether each...
PPMModel(int order, std::uint32_t sigma=256)
the model of order = order on = sigma symbols, with no symbol seen
std::vector< Step > steps(std::uint32_t c) const
the steps that code after the symbols seen: the escapes, then
void encode(std::uint32_t c, RangeEncoder &e) const
codes after the symbols seen, by the steps of steps()
void update(std::uint32_t c)
adds to the symbols seen
the decoder of a RangeEncoder on bits
Definition ArithmeticCoding.h:270
the integer arithmetic encoder of Witten, Neal and Cleary on bits
Definition ArithmeticCoding.h:203
std::string ppmDecode(std::span< const std::uint8_t > code, std::size_t n, int K)
the bytes of the code by PPM of order
std::vector< std::uint8_t > ppmEncode(std::string_view s, int K)
the code of the bytes of by PPM of order
a step of the code: the cumulative counts of the symbol or of the escape, out of total
Definition PPM.h:118
std::uint64_t high
the cumulative count after the item
Definition PPM.h:120
std::uint64_t total
the total of the counts, with the escape
Definition PPM.h:121
std::uint64_t low
the cumulative count before the item
Definition PPM.h:119
friend bool operator==(const Step &a, const Step &b)=default
whether two steps are the same