// of coefficients to rANS probability distributions. This is randomized,
// so you might want to run it a few times.
#define FIND_OPTIMAL_STREAM_ASSIGNMENT 0
-#define NUM_CLUSTERS 8
+#define NUM_CLUSTERS 4
static constexpr uint32_t prob_bits = 12;
static constexpr uint32_t prob_scale = 1 << prob_bits;
float kl_dist[64][64];
#endif
+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 FIND_OPTIMAL_STREAM_ASSIGNMENT
return y * 8 + x + is_chroma * 64;
#else
- return std::min<int>(x + y, 7) + is_chroma * 8;
+ if (is_chroma) {
+ return chroma_mapping[y * 8 + x] + 4;
+ } else {
+ return luma_mapping[y * 8 + x];
+ }
#endif
}