X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=ryg_rans%2Frenormalize.h;fp=ryg_rans%2Frenormalize.h;h=b41a4d2e5498476f580e36679aa588eaed3a9bed;hb=062abd7f7c940204d34c496f765aeb143d2d8e6c;hp=0000000000000000000000000000000000000000;hpb=8cca8db811c7888058c6093d2f1ae5ae4f00cccc;p=narabu diff --git a/ryg_rans/renormalize.h b/ryg_rans/renormalize.h new file mode 100644 index 0000000..b41a4d2 --- /dev/null +++ b/ryg_rans/renormalize.h @@ -0,0 +1,19 @@ +#ifndef RENORMALIZE_H_INCLUDED +#define RENORMALIZE_H_INCLUDED + +// Optimal renormalization of a frequency table down to a more coarse-grained +// table; through a combination of heuristics and memoization, finds the +// rounding that produces the fewest amount of bits needed to encode, while +// making sure no symbol gets a frequency of zero. Primarily useful for when +// your precision is low enough that loss is a real problem; compared to direct +// rounding, it tends to cut the overhead about in half. +// +// This operation is cheap but not free; it seems to use 1–2 ms on a Haswell 2.1 GHz +// for 256 symbols (the speed is mostly dependent on number of symbols, although +// number of bits also matters some). + +#include + +void OptimalRenormalize(uint32_t *cum_freqs, uint32_t num_syms, uint32_t target_total); + +#endif // RENORMALIZE_H_INCLUDED