Arithmetic coding tutorial code
1
AC
|
#include <arith_code.hh>
Public Member Functions | |
unsigned int | number_input_bits () |
number of bits inserted in the state More... | |
unsigned int | number_input_symbols () |
number of symbols inserted in the state More... | |
unsigned int | number_output_bits () |
number of bits extracted from the state More... | |
unsigned int | number_output_symbols () |
number of symbols extracted from the state More... | |
void | print_state () |
print the internal state More... | |
interval_t | S_interval () |
return the S_interval More... | |
interval_t | B_interval () |
return the B_interval More... | |
int | output_bit () |
outputs one bit from the state, if available, else -1 More... | |
void | output_bits (output_callback_t out) |
outputs multiple bits, returns them using a callback (if not null; else they are lost) More... | |
void | frequencies2cumulative_frequencies () |
if the output callback is used in decoding, then the "cumulative_frequencies" and "max_symbol" must be used; "cumulative_frequencies" may be updated from "frequencies" using this call, that wraps freq2cum_freq() More... | |
Data Fields | |
const char * | prefix |
name of the class, for printing More... | |
FILE * | verbose_stream = stdout |
F_t * | cumulative_frequencies = NULL |
if the output callback is used in decoding, then the "cumulative_frequencies" and "max_symbol" must be updated after each symbol is decoded, with the correct frequencies for the next symbol More... | |
I_t | max_symbol = -1 |
if the output callback is used in decoding, then the "cumulative_frequencies" and "max_symbol" must be updated after each symbol is decoded, with the correct frequencies for the next symbol More... | |
F_t * | frequencies = NULL |
if the output callback is used in decoding, then the "cumulative_frequencies" and "max_symbol" must be used; these may be derived from a table of frequencies, that may be stored here More... | |
void * | callback_data = NULL |
Protected Member Functions | |
void | doubleit () |
void | doublehi () |
void | doublelow () |
void | doublecen () |
I_t | separ_low_high (int symb, const F_t *cum_freq) |
divides Slow - Shigh in subintervals : returns the beginning of each interval; note that intervals are in reverse order wrt symbols, that is, symb=0 gives the rightmost subinterval, symb=max_symbols-1 is the leftmost More... | |
int | resize_pull_one_bit () |
returns 0 , 1 or -1 if no bit can be pulled at this moment ; resize S-interval and B-interval accordingly More... | |
I_t | interval_right (int symb, const F_t *cum_freq) |
right extreme of a S-sub-interval ; note that symbols start from 0 here More... | |
I_t | interval_left (int symb, const F_t *cum_freq) |
left extreme of a S-sub-interval More... | |
void | push_symbol (int symb, const F_t *cum_freq) |
put symbol in S-interval by splitting it and choosing a subinterval, proportional to the frequencies More... | |
void | push_bit (int bit) |
put bit in B-interval More... | |
Base () | |
Protected Attributes | |
unsigned int | bitsToFollow |
int | virtual_bit |
const I_t | One = 1 |
const I_t | Top = (One << AC_representation_bitsize) |
representation of 1 More... | |
const I_t | Qtr = (One << (AC_representation_bitsize-2)) |
representation of 1/4 More... | |
const I_t | QtrMinus = (One << (AC_representation_bitsize-2)) - One |
representation of point preceding 1/4 More... | |
const I_t | Half = (Qtr*2) |
Representation of 3/4. More... | |
const I_t | ThreeQtr = (Qtr*3) |
representation of 3/4 More... | |
F_t const | cum_freq_uniform8 [9] = { 8 , 7 , 6 , 5, 4 , 3 , 2 , 1 , 0 } |
cumulative tables of 8 equidistributed symbols More... | |
F_t const * | cum_freq_flush = cum_freq_uniform8 |
special cumulative table used for flushing More... | |
I_t | Slow |
S-interval left extreme. More... | |
I_t | Shigh |
S-interval right extreme (included in the interval) More... | |
long_I_t | Srange |
S-interval width. More... | |
I_t | Blow |
B-interval left extreme. More... | |
I_t | Bhigh |
B-interval right extreme. More... | |
unsigned int | significant_bits |
significant bits (used in the decoder) More... | |
unsigned int | n_in_bits |
number of bits inserted in the state More... | |
unsigned int | n_in_symbs |
number of symbols inserted in the state More... | |
unsigned int | n_zooms |
number of zooms More... | |
unsigned int | n_out_bits |
number of bits extracted from the state More... | |
unsigned int | n_out_symbs |
number of symbols extracted from the state More... | |
Static Protected Attributes | |
static const int | n_symbols_flush = 8 |
how many symbols in the special cumulative table used for flushing More... | |
! base class ; should not be used; contains the logic common to encoder and decoder
|
protected |
interval_t AC::Base::B_interval | ( | ) |
return the B_interval
|
protected |
|
protected |
|
protected |
|
protected |
void AC::Base::frequencies2cumulative_frequencies | ( | ) |
if the output callback is used in decoding, then the "cumulative_frequencies" and "max_symbol" must be used; "cumulative_frequencies" may be updated from "frequencies" using this call, that wraps freq2cum_freq()
left extreme of a S-sub-interval
right extreme of a S-sub-interval ; note that symbols start from 0 here
unsigned int AC::Base::number_input_bits | ( | ) |
number of bits inserted in the state
unsigned int AC::Base::number_input_symbols | ( | ) |
number of symbols inserted in the state
unsigned int AC::Base::number_output_bits | ( | ) |
number of bits extracted from the state
unsigned int AC::Base::number_output_symbols | ( | ) |
number of symbols extracted from the state
int AC::Base::output_bit | ( | ) |
outputs one bit from the state, if available, else -1
void AC::Base::output_bits | ( | output_callback_t | out | ) |
outputs multiple bits, returns them using a callback (if not null; else they are lost)
void AC::Base::print_state | ( | ) |
print the internal state
|
protected |
put bit in B-interval
|
protected |
put symbol in S-interval by splitting it and choosing a subinterval, proportional to the frequencies
|
protected |
returns 0 , 1 or -1 if no bit can be pulled at this moment ; resize S-interval and B-interval accordingly
interval_t AC::Base::S_interval | ( | ) |
return the S_interval
divides Slow - Shigh in subintervals : returns the beginning of each interval; note that intervals are in reverse order wrt symbols, that is, symb=0 gives the rightmost subinterval, symb=max_symbols-1 is the leftmost
|
protected |
B-interval right extreme.
|
protected |
|
protected |
B-interval left extreme.
void* AC::Base::callback_data = NULL |
a pointer to data that the callbacks receive as second argument (it is initialized with a pointer to the class)
|
protected |
special cumulative table used for flushing
|
protected |
cumulative tables of 8 equidistributed symbols
F_t* AC::Base::cumulative_frequencies = NULL |
if the output callback is used in decoding, then the "cumulative_frequencies" and "max_symbol" must be updated after each symbol is decoded, with the correct frequencies for the next symbol
F_t* AC::Base::frequencies = NULL |
if the output callback is used in decoding, then the "cumulative_frequencies" and "max_symbol" must be used; these may be derived from a table of frequencies, that may be stored here
I_t AC::Base::max_symbol = -1 |
if the output callback is used in decoding, then the "cumulative_frequencies" and "max_symbol" must be updated after each symbol is decoded, with the correct frequencies for the next symbol
|
protected |
number of bits inserted in the state
|
protected |
number of symbols inserted in the state
|
protected |
number of bits extracted from the state
|
protected |
number of symbols extracted from the state
|
staticprotected |
how many symbols in the special cumulative table used for flushing
|
protected |
number of zooms
|
protected |
const char* AC::Base::prefix |
name of the class, for printing
|
protected |
representation of 1/4
|
protected |
representation of point preceding 1/4
|
protected |
S-interval right extreme (included in the interval)
|
protected |
significant bits (used in the decoder)
|
protected |
S-interval left extreme.
|
protected |
S-interval width.
|
protected |
representation of 1
FILE* AC::Base::verbose_stream = stdout |
stream where verbose output will be printed (verbose output may be enabled by defining the AC_verbose macro)
|
protected |