int cum2sym[prob_scale];
RansDecSymbol dsyms[NUM_SYMS];
};
-RansDecodeTable decode_tables[16];
+#define NUM_TABLES 8
+RansDecodeTable decode_tables[NUM_TABLES];
static const unsigned char std_luminance_quant_tbl[64] = {
#if 0
};
-int pick_stats_for(int y, int x)
+const int luma_mapping[64] = {
+ 0, 0, 1, 1, 2, 2, 3, 3,
+ 0, 0, 1, 2, 2, 2, 3, 3,
+ 1, 1, 2, 2, 2, 3, 3, 3,
+ 1, 1, 2, 2, 2, 3, 3, 3,
+ 1, 2, 2, 2, 2, 3, 3, 3,
+ 2, 2, 2, 2, 3, 3, 3, 3,
+ 2, 2, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3,
+};
+const int chroma_mapping[64] = {
+ 0, 1, 1, 2, 2, 2, 3, 3,
+ 1, 1, 2, 2, 2, 3, 3, 3,
+ 2, 2, 2, 2, 3, 3, 3, 3,
+ 2, 2, 2, 3, 3, 3, 3, 3,
+ 2, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3,
+};
+
+int pick_stats_for(int x, int y, bool is_chroma)
{
- if (x + y >= 7) return 7;
- return x + y;
+ if (is_chroma) {
+ return chroma_mapping[y * 8 + x] + 4;
+ } else {
+ return luma_mapping[y * 8 + x];
+ }
}
uint32_t read_varint(FILE *fp)
exit(1);
}
- uint32_t sign_bias[16];
- for (unsigned table = 0; table < 16; ++table) {
+ uint32_t sign_bias[NUM_TABLES];
+ for (unsigned table = 0; table < NUM_TABLES; ++table) {
uint32_t cum_freq = 0;
for (unsigned sym = 0; sym < NUM_SYMS; ++sym) {
uint32_t freq = read_varint(fp);
// loop over all coefficients
for (unsigned y = 0; y < 8; ++y) {
for (unsigned x = 0; x < 8; ++x) {
- unsigned tbl = pick_stats_for(x, y);
+ unsigned tbl = pick_stats_for(x, y, false);
RansState rans = 0;