]> git.sesse.net Git - narabu/blobdiff - qdc.cpp
Go down to 4 rANS streams instead of 8.
[narabu] / qdc.cpp
diff --git a/qdc.cpp b/qdc.cpp
index b5594b76856918d9b14bee3f55dd5bcec24fdd7a..951915225f8784ff1ede25c8978db48ea6395a2a 100644 (file)
--- a/qdc.cpp
+++ b/qdc.cpp
@@ -25,7 +25,7 @@
 // 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;
@@ -154,12 +154,37 @@ SymbolStats stats[128];
 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
 }