]> git.sesse.net Git - narabu/blob - ryg_rans/renormalize.h
More fixes of hard-coded values.
[narabu] / ryg_rans / renormalize.h
1 #ifndef RENORMALIZE_H_INCLUDED
2 #define RENORMALIZE_H_INCLUDED
3
4 // Optimal renormalization of a frequency table down to a more coarse-grained
5 // table; through a combination of heuristics and memoization, finds the
6 // rounding that produces the fewest amount of bits needed to encode, while
7 // making sure no symbol gets a frequency of zero. Primarily useful for when
8 // your precision is low enough that loss is a real problem; compared to direct
9 // rounding, it tends to cut the overhead about in half.
10 //
11 // This operation is cheap but not free; it seems to use 1–2 ms on a Haswell 2.1 GHz
12 // for 256 symbols (the speed is mostly dependent on number of symbols, although
13 // number of bits also matters some).
14
15 #include <stdint.h>
16
17 void OptimalRenormalize(uint32_t *cum_freqs, uint32_t num_syms, uint32_t target_total);
18
19 #endif // RENORMALIZE_H_INCLUDED