1 #ifndef RENORMALIZE_H_INCLUDED
2 #define RENORMALIZE_H_INCLUDED
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.
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).
17 void OptimalRenormalize(uint32_t *cum_freqs, uint32_t num_syms, uint32_t target_total);
19 #endif // RENORMALIZE_H_INCLUDED