|
Arithmetic coding tutorial code
1
AC
|
Data Structures | |
| class | Base |
| class | Decoder |
| class | Encoder |
Typedefs | |
| typedef std::function< void(int, int, F_t, F_t, double)> | printit_t |
| typedef uint32_t | I_t |
| types for variables defining intervals More... | |
| typedef uint64_t | long_I_t |
| typedef I_t | F_t |
| types for variables defining frequencies More... | |
| typedef std::pair< I_t, I_t > | interval_t |
| struct to represent an interval More... | |
| typedef std::function< void(int, void *)> | output_callback_t |
| type for callbacks More... | |
| typedef std::function< int(void *)> | input_callback_t |
| type for bit reader call More... | |
Functions | |
| std::string | string_hex (I_t b) |
| prints an integer in a string More... | |
| std::string | string_binary_comma (I_t b, std::string sep="'") |
| void | freq2cum_freq (F_t cum_freq[], F_t freq[], int max_symb, int assert_non_zero=1) |
| computes the cumulative cum_freq given the frequencies of symbols More... | |
| void | prob2cum_freq (F_t cum_freq[], double prob[], int max_symb) |
| computes the cum_freq given the probabilities More... | |
| int | renormalize_frequencies (AC::F_t *fr, int n_symbols, unsigned int max_freq=AC::MAX_FREQ) |
| double | compute_entropy (F_t *freq, int MAX_SYMB) |
| compute the entropy given the frequencies More... | |
| void | print_table_generic (std::function< void(int)> head, printit_t printit, F_t *fr, F_t *cufr, int n_symbols, const int columns=6) |
| void | print_table_freq (F_t *fr, F_t *cufr, int n_symbols, const int columns=6, FILE *out=stderr) |
| prints the table of frequencies More... | |
| void | print_table_freq_ascii (F_t *fr, F_t *cufr, int n_symbols, const int columns=6, FILE *out=stderr) |
| prints the table of frequencies, with ascii characters More... | |
| void | print_table_cum_freq_ascii (F_t *fr, F_t *cufr, int n_symbols, FILE *out=stdout, int columns=4) |
| prints the table of frequencies and cumulative frequencies, with ascii symbols More... | |
| void | print_table_cum_freq (F_t *fr, F_t *cufr, int n_symbols, FILE *out=stdout, const int columns=4) |
| prints the table of frequencies and cumulative frequencies More... | |
Variables | |
| const char * | bit_rep [16] |
| const char * | hex_rep [16] |
| const int | NO_SYMBOL = -1 |
| value that represents a non symbol More... | |
| const int | FLUSH_SYMBOL = -2 |
| const int | MIN_SYMBOL = 0 |
| const I_t | MAX_FREQ = ((I_t)1) << (AC_representation_bitsize-2) |
| the sum of all frequencies of symbols cannot exceed this value More... | |
| typedef uint32_t AC::I_t |
types for variables defining intervals
| typedef std::function<int(void *)> AC::input_callback_t |
type for bit reader call
| typedef std::pair<I_t, I_t> AC::interval_t |
struct to represent an interval
| typedef uint64_t AC::long_I_t |
| typedef std::function<void(int,void *)> AC::output_callback_t |
type for callbacks
| typedef std::function<void(int,int,F_t,F_t,double)> AC::printit_t |
| double AC::compute_entropy | ( | F_t * | freq, |
| int | MAX_SYMB | ||
| ) |
compute the entropy given the frequencies
computes the cumulative cum_freq given the frequencies of symbols
| void AC::print_table_cum_freq | ( | F_t * | fr, |
| F_t * | cufr, | ||
| int | n_symbols, | ||
| FILE * | out = stdout, |
||
| const int | columns = 4 |
||
| ) |
prints the table of frequencies and cumulative frequencies
| void AC::print_table_cum_freq_ascii | ( | F_t * | fr, |
| F_t * | cufr, | ||
| int | n_symbols, | ||
| FILE * | out = stdout, |
||
| int | columns = 4 |
||
| ) |
prints the table of frequencies and cumulative frequencies, with ascii symbols
| void AC::print_table_freq | ( | F_t * | fr, |
| F_t * | cufr, | ||
| int | n_symbols, | ||
| const int | columns = 6, |
||
| FILE * | out = stderr |
||
| ) |
prints the table of frequencies
| void AC::print_table_freq_ascii | ( | F_t * | fr, |
| F_t * | cufr, | ||
| int | n_symbols, | ||
| const int | columns = 6, |
||
| FILE * | out = stderr |
||
| ) |
prints the table of frequencies, with ascii characters
| void AC::print_table_generic | ( | std::function< void(int)> | head, |
| printit_t | printit, | ||
| F_t * | fr, | ||
| F_t * | cufr, | ||
| int | n_symbols, | ||
| const int | columns = 6 |
||
| ) |
| head | prints the heading of a columns |
| printit | prints the content of columns |
| void AC::prob2cum_freq | ( | F_t | cum_freq[], |
| double | prob[], | ||
| int | max_symb | ||
| ) |
computes the cum_freq given the probabilities
| int AC::renormalize_frequencies | ( | AC::F_t * | fr, |
| int | n_symbols, | ||
| unsigned int | max_freq = AC::MAX_FREQ |
||
| ) |
reduces the frequencies if they are too high returns positive number if the frequencies were renormalized
| fr | table of frequencies |
| n_symbols | number of symbols |
| max_freq | maximum frequency |
| std::string AC::string_binary_comma | ( | I_t | b, |
| std::string | sep = "'" |
||
| ) |
prints a string in binary, as if it was a decimal number; used to print the extreme of an interval
| std::string AC::string_hex | ( | I_t | b | ) |
prints an integer in a string
| const char* AC::bit_rep[16] |
| const int AC::FLUSH_SYMBOL = -2 |
value that represents a succeful deflushing (note that this symbol is not counted in the internal count of symbols)
| const char* AC::hex_rep[16] |
| const I_t AC::MAX_FREQ = ((I_t)1) << (AC_representation_bitsize-2) |
the sum of all frequencies of symbols cannot exceed this value
| const int AC::MIN_SYMBOL = 0 |
minimum value for a symbol, 0 is the common choice for computer programs, 1 is the common choice for people
| const int AC::NO_SYMBOL = -1 |
value that represents a non symbol
1.8.13