5 #include <libutl/Encoder.h> 6 #include <libutl/Vector.h> 45 set(numSymbols, inc, incLimit);
56 interval(&low, &high, symbol);
99 void update(
uint_t symbol);
176 start(mode, stream, owner, ctx, eob);
179 virtual size_t decode(
byte_t* block,
size_t num);
188 virtual size_t encode(
const byte_t* block,
size_t num);
220 virtual void clear();
221 virtual void finishEncoding();
236 inline void putBit(
bool b);
249 ArithmeticEncoder::putBit(
bool b)
252 while (_followBits > 0)
285 if (_L + _R <= _half)
289 else if (_L >= _half)
311 uint_t l, h, t, r, rl, target, symbol;
318 target =
min(t - 1, _L / r);
319 symbol = ctx->
symbol(target);
338 bit = _stream->getBit();
339 _L = (_L << 1) | (bit ? 1 : 0);
void update(uint_t symbol)
Add inc to the frequency count for the given symbol.
void deInit()
De-initialize UTL++.
uint_t totFreq() const
Return the total frequency of all symbols.
Encoder/decoder abstraction.
uint_t symbol(uint_t target)
Return the symbol whose cumulative frequency count is the least that exceeds the given target...
void interval(uint_t *low, uint_t *high, uint_t symbol) const
Return the total frequency of all symbols before the given symbol.
#define UTL_CLASS_DECL(DC, BC)
Declaration of standard UTL++ functionality for a non-template class.
unsigned char byte_t
Unsigned character.
Statistical context for ArithmeticEncoder.
void copy(T *dest, const T *src, size_t len)
Copy one array of objects to another.
uint_t freq(uint_t symbol) const
Get the frequency count for the given symbol.
unsigned int uint_t
Unsigned integer.
uint_t numSymbols() const
Return the number of symbols.
ArithmeticEncoder(uint_t mode, Stream *stream=nullptr, bool owner=true, ArithContext *ctx=nullptr, bool eob=false)
Constructor.
const T & min(const T &a, const T &b, const R &... args)
Return the smallest value among two or more provided values of the same type.
Root of UTL++ class hierarchy.
void init()
Initialize UTL++.
void setContext(ArithContext *ctx)
Set the default context.
ArithContext(uint_t numSymbols, uint_t inc, uint_t incLimit)
Constructor.