X-Git-Url: https://git.sesse.net/?p=narabu;a=blobdiff_plain;f=narabu.cpp;h=2eb29dcd46877d788de0ee43a03e443352b1308b;hp=ba1e967e8c95884d36b93e16f6370ad921c1c2f6;hb=34138d5b1a1302a7a1050fd46d2fb95c0186140a;hpb=8989d0f3ce3d2c5074aeb5be4297fda30d3efc67 diff --git a/narabu.cpp b/narabu.cpp index ba1e967..2eb29dc 100644 --- a/narabu.cpp +++ b/narabu.cpp @@ -23,7 +23,7 @@ using namespace std::chrono; const unsigned prob_bits = 12; const unsigned prob_scale = 1 << prob_bits; const unsigned NUM_SYMS = 256; -const unsigned NUM_TABLES = 16; +const unsigned NUM_TABLES = 8; struct RansDecSymbol { unsigned sym_start; @@ -122,11 +122,11 @@ int main(int argc, char **argv) exit(1); } - decode_tables[table].dsyms[(sym + 1) & 255].sym_start = cum_freq; - decode_tables[table].dsyms[(sym + 1) & 255].sym_freq = *freq; + decode_tables[table].dsyms[(sym + 1) & (NUM_SYMS - 1)].sym_start = cum_freq; + decode_tables[table].dsyms[(sym + 1) & (NUM_SYMS - 1)].sym_freq = *freq; for (uint32_t i = 0; i < freq; ++i) { if (cum_freq < prob_scale) - decode_tables[table].cum2sym[cum_freq] = (sym + 1) & 255; + decode_tables[table].cum2sym[cum_freq] = (sym + 1) & (NUM_SYMS - 1); ++cum_freq; } }