Merge "Add "entropy" experiment" into nextgenv2
diff --git a/vp10/common/entropy.c b/vp10/common/entropy.c
index df03224..16b9dc4 100644
--- a/vp10/common/entropy.c
+++ b/vp10/common/entropy.c
@@ -686,6 +686,1779 @@
 }
 #endif  // CONFIG_ANS
 
+#if CONFIG_ENTROPY
+const vp10_coeff_probs_model
+default_qctx_coef_probs[QCTX_BINS][TX_SIZES][PLANE_TYPES] = {
+    {  // Q_Index 0
+        {  // TX_SIZE 0
+            {  // Y plane
+                {  // Intra
+                    {  // band 0
+                        {182,  34, 137}, { 79,  39, 103}, { 10,  28,  51},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        { 45,  88, 147}, { 46,  80, 140}, { 25,  69, 119},
+                        { 12,  57,  96}, {  4,  41,  65}, {  1,  20,  31},
+                    },
+                    {  // band 2
+                        { 58, 124, 190}, { 39, 106, 178}, { 16,  86, 147},
+                        {  7,  69, 114}, {  3,  50,  80}, {  1,  25,  42},
+                    },
+                    {  // band 3
+                        { 90, 138, 215}, { 54, 116, 198}, { 18,  86, 155},
+                        {  5,  62, 112}, {  1,  38,  68}, {  1,  17,  30},
+                    },
+                    {  // band 4
+                        {126, 149, 231}, { 82, 114, 211}, { 21,  80, 157},
+                        {  6,  56, 105}, {  1,  36,  64}, {  1,  17,  31},
+                    },
+                    {  // band 5
+                        {171,  56, 236}, {140,  54, 219}, { 57,  45, 167},
+                        { 26,  36, 113}, { 11,  29,  72}, {  3,  18,  39},
+                    },
+                },
+                {  // Intra
+                    {  // band 0
+                        {153, 122, 186}, {106, 109, 171}, { 36,  84, 128},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        { 27, 151, 201}, { 34, 131, 199}, { 23, 102, 161},
+                        { 10,  80, 120}, {  4,  52,  78}, {  1,  24,  37},
+                    },
+                    {  // band 2
+                        { 43, 158, 213}, { 35, 133, 203}, {  8,  92, 151},
+                        {  2,  64, 106}, {  1,  36,  60}, {  1,  13,  24},
+                    },
+                    {  // band 3
+                        { 68, 167, 223}, { 36, 135, 211}, {  9,  94, 157},
+                        {  2,  67, 112}, {  1,  40,  68}, {  1,  17,  31},
+                    },
+                    {  // band 4
+                        {131, 146, 237}, { 72, 119, 223}, { 17,  82, 164},
+                        {  4,  55, 107}, {  1,  34,  63}, {  1,  16,  29},
+                    },
+                    {  // band 5
+                        {184,  68, 244}, {153,  59, 232}, { 68,  51, 179},
+                        { 31,  40, 123}, { 13,  29,  77}, {  4,  17,  37},
+                    },
+                },
+            },
+            {  // UV plane
+                {  // Inter
+                    {  // band 0
+                        {203,  41, 203}, {127,  56, 174}, { 49,  56, 127},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        {110, 121, 217}, {119, 113, 213}, { 64,  95, 185},
+                        { 30,  72, 144}, {  8,  42,  76}, {  2,  17,  25},
+                    },
+                    {  // band 2
+                        {127, 159, 229}, {115, 134, 223}, { 36, 100, 189},
+                        { 11,  75, 142}, {  3,  48,  83}, {  1,  19,  33},
+                    },
+                    {  // band 3
+                        {150, 172, 241}, { 90, 133, 231}, { 28, 102, 192},
+                        {  7,  81, 147}, {  1,  53,  91}, {  1,  25,  42},
+                    },
+                    {  // band 4
+                        {184, 144, 248}, {114, 117, 237}, { 37,  89, 192},
+                        { 10,  63, 130}, {  4,  42,  76}, {  1,  19,  38},
+                    },
+                    {  // band 5
+                        {207,  79, 250}, {179,  74, 241}, { 83,  67, 199},
+                        { 38,  51, 142}, { 17,  37,  97}, { 10,  14,  55},
+                    },
+                },
+                {  // Inter
+                    {  // band 0
+                        {220,  82, 232}, {150,  93, 214}, { 66,  95, 177},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        {116, 160, 227}, {136, 141, 227}, { 67, 114, 190},
+                        { 40,  94, 148}, { 21,  70, 107}, { 10,  43,  63},
+                    },
+                    {  // band 2
+                        {124, 173, 235}, {105, 147, 226}, { 27, 107, 184},
+                        { 10,  80, 142}, {  3,  50,  86}, {  1,  16,  32},
+                    },
+                    {  // band 3
+                        {149, 179, 243}, { 89, 147, 234}, { 29, 112, 193},
+                        {  9,  94, 157}, {  1,  64, 111}, {  1,  25,  43},
+                    },
+                    {  // band 4
+                        {187, 153, 248}, {127, 130, 241}, { 52,  99, 202},
+                        { 20,  79, 152}, {  4,  50,  93}, {  1,  19,  32},
+                    },
+                    {  // band 5
+                        {215,  82, 251}, {195,  80, 246}, { 93,  70, 204},
+                        { 39,  54, 147}, { 14,  33,  88}, {  6,  14,  39},
+                    },
+                },
+            },
+        },
+        {  // TX_SIZE 1
+            {  // Y plane
+                {  // Intra
+                    {  // band 0
+                        {116,  43, 131}, { 39,  41,  94}, {  4,  28,  47},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        { 28, 101, 141}, { 27,  95, 140}, { 18,  80, 121},
+                        { 10,  61,  95}, {  4,  39,  60}, {  1,  19,  26},
+                    },
+                    {  // band 2
+                        { 29, 150, 183}, { 19, 127, 175}, {  8,  98, 147},
+                        {  3,  76, 115}, {  1,  55,  84}, {  1,  29,  43},
+                    },
+                    {  // band 3
+                        { 26, 168, 202}, { 12, 138, 188}, {  2,  98, 149},
+                        {  1,  69, 110}, {  1,  40,  65}, {  1,  17,  25},
+                    },
+                    {  // band 4
+                        { 33, 188, 225}, { 12, 155, 207}, {  2, 101, 155},
+                        {  1,  65, 106}, {  1,  36,  60}, {  1,  18,  26},
+                    },
+                    {  // band 5
+                        { 79, 205, 242}, { 30, 168, 224}, {  5, 106, 164},
+                        {  1,  68, 110}, {  1,  39,  65}, {  1,  18,  28},
+                    },
+                },
+                {  // Intra
+                    {  // band 0
+                        { 96,  80, 201}, { 51,  88, 168}, { 14,  78, 116},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        {  6, 167, 216}, { 32, 152, 211}, { 24, 121, 182},
+                        { 13,  98, 149}, { 12,  76, 108}, {  8,  48,  62},
+                    },
+                    {  // band 2
+                        { 17, 176, 225}, { 13, 147, 209}, {  3,  96, 155},
+                        {  1,  65, 108}, {  2,  43,  63}, {  2,  23,  25},
+                    },
+                    {  // band 3
+                        { 18, 183, 232}, { 10, 153, 214}, {  1,  96, 154},
+                        {  1,  63, 105}, {  1,  39,  59}, {  1,  21,  24},
+                    },
+                    {  // band 4
+                        { 23, 191, 239}, {  8, 159, 221}, {  1,  97, 158},
+                        {  1,  61, 105}, {  1,  37,  60}, {  1,  20,  26},
+                    },
+                    {  // band 5
+                        { 70, 201, 243}, { 29, 163, 228}, {  4, 102, 169},
+                        {  1,  67, 114}, {  1,  39,  66}, {  1,  17,  29},
+                    },
+                },
+            },
+            {  // UV plane
+                {  // Inter
+                    {  // band 0
+                        {181,  38, 192}, { 95,  47, 151}, { 29,  49, 102},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        { 72, 131, 202}, { 93, 120, 205}, { 50, 103, 179},
+                        { 24,  79, 143}, { 11,  47,  78}, {  7,  19,  25},
+                    },
+                    {  // band 2
+                        { 84, 176, 221}, { 56, 144, 214}, { 21, 108, 182},
+                        {  8,  83, 139}, {  3,  55,  90}, {  2,  27,  41},
+                    },
+                    {  // band 3
+                        { 84, 195, 234}, { 42, 156, 222}, { 10, 109, 180},
+                        {  4,  77, 133}, {  1,  48,  80}, {  1,  23,  35},
+                    },
+                    {  // band 4
+                        { 89, 210, 238}, { 35, 165, 221}, {  6, 106, 172},
+                        {  2,  70, 123}, {  1,  44,  74}, {  1,  21,  30},
+                    },
+                    {  // band 5
+                        {114, 221, 247}, { 49, 170, 234}, {  7, 113, 184},
+                        {  2,  77, 132}, {  1,  48,  79}, {  1,  25,  33},
+                    },
+                },
+                {  // Inter
+                    {  // band 0
+                        {192,  66, 237}, {113,  84, 211}, { 35,  84, 154},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        { 81, 180, 234}, {127, 165, 229}, { 58, 137, 204},
+                        { 41, 114, 174}, { 44,  94, 136}, { 29,  66,  86},
+                    },
+                    {  // band 2
+                        { 82, 193, 240}, { 39, 162, 223}, {  8, 113, 179},
+                        {  3,  83, 136}, {  6,  62,  84}, {  5,  45,  45},
+                    },
+                    {  // band 3
+                        { 78, 203, 242}, { 31, 170, 227}, {  4, 115, 181},
+                        {  1,  82, 135}, {  2,  59,  82}, {  1,  45,  47},
+                    },
+                    {  // band 4
+                        { 76, 210, 239}, { 25, 170, 213}, {  2,  99, 152},
+                        {  1,  69, 115}, {  1,  49,  80}, {  1,  47,  57},
+                    },
+                    {  // band 5
+                        {103, 217, 250}, { 42, 180, 237}, {  3, 124, 191},
+                        {  1,  90, 150}, {  1,  69, 116}, {  1,  52,  46},
+                    },
+                },
+            },
+        },
+        {  // TX_SIZE 2
+            {  // Y plane
+                {  // Intra
+                    {  // band 0
+                        { 58,  38,  99}, {  9,  26,  51}, {  1,  14,  22},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        { 14,  78, 109}, { 16,  73, 105}, { 11,  62,  92},
+                        {  6,  47,  72}, {  2,  29,  45}, {  1,  12,  18},
+                    },
+                    {  // band 2
+                        { 17, 131, 148}, { 11, 112, 140}, {  5,  87, 118},
+                        {  2,  63,  90}, {  1,  42,  63}, {  1,  19,  31},
+                    },
+                    {  // band 3
+                        { 12, 151, 168}, {  6, 116, 152}, {  1,  76, 115},
+                        {  1,  50,  81}, {  1,  32,  52}, {  1,  14,  23},
+                    },
+                    {  // band 4
+                        { 10, 174, 191}, {  3, 130, 172}, {  1,  80, 126},
+                        {  1,  53,  88}, {  1,  32,  55}, {  1,  14,  24},
+                    },
+                    {  // band 5
+                        { 19, 219, 237}, {  3, 168, 211}, {  1,  90, 142},
+                        {  1,  53,  91}, {  1,  29,  51}, {  1,  12,  21},
+                    },
+                },
+                {  // Intra
+                    {  // band 0
+                        { 21,  46, 184}, { 10,  53, 130}, {  2,  49,  78},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        {  3, 169, 198}, { 37, 165, 196}, { 26, 134, 176},
+                        { 11, 108, 149}, {  5,  81, 112}, {  3,  47,  64},
+                    },
+                    {  // band 2
+                        { 11, 183, 215}, {  8, 142, 192}, {  2,  91, 141},
+                        {  1,  62, 100}, {  1,  38,  62}, {  1,  17,  28},
+                    },
+                    {  // band 3
+                        { 12, 190, 223}, {  6, 149, 199}, {  1,  88, 139},
+                        {  1,  56,  93}, {  1,  31,  54}, {  1,  13,  21},
+                    },
+                    {  // band 4
+                        { 11, 197, 230}, {  3, 154, 204}, {  1,  83, 134},
+                        {  1,  50,  86}, {  1,  28,  49}, {  1,  12,  21},
+                    },
+                    {  // band 5
+                        { 17, 211, 240}, {  2, 167, 217}, {  1,  88, 143},
+                        {  1,  53,  91}, {  1,  30,  53}, {  1,  14,  24},
+                    },
+                },
+            },
+            {  // UV plane
+                {  // Inter
+                    {  // band 0
+                        {151,  30, 151}, { 50,  36, 105}, {  8,  34,  66},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        { 39, 111, 160}, { 62, 111, 165}, { 37,  99, 147},
+                        { 15,  77, 118}, {  3,  47,  73}, {  1,  17,  27},
+                    },
+                    {  // band 2
+                        { 48, 170, 190}, { 32, 135, 180}, { 11, 100, 149},
+                        {  4,  76, 116}, {  1,  51,  80}, {  1,  22,  36},
+                    },
+                    {  // band 3
+                        { 39, 191, 208}, { 18, 141, 191}, {  3,  96, 150},
+                        {  1,  66, 110}, {  1,  41,  69}, {  1,  17,  28},
+                    },
+                    {  // band 4
+                        { 32, 209, 219}, {  8, 152, 201}, {  1,  96, 153},
+                        {  1,  63, 106}, {  1,  38,  66}, {  1,  17,  29},
+                    },
+                    {  // band 5
+                        { 33, 230, 237}, {  5, 173, 214}, {  1, 100, 155},
+                        {  1,  62, 105}, {  1,  38,  66}, {  1,  18,  32},
+                    },
+                },
+                {  // Inter
+                    {  // band 0
+                        {149,  38, 231}, { 59,  51, 186}, { 12,  54, 117},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        { 53, 179, 226}, {126, 176, 223}, { 58, 147, 202},
+                        { 28, 118, 174}, { 15,  94, 138}, { 14,  63,  87},
+                    },
+                    {  // band 2
+                        { 58, 196, 232}, { 26, 158, 213}, {  5, 106, 166},
+                        {  1,  75, 124}, {  1,  46,  79}, {  1,  23,  39},
+                    },
+                    {  // band 3
+                        { 46, 203, 235}, { 17, 162, 213}, {  2, 104, 165},
+                        {  1,  72, 120}, {  1,  44,  74}, {  1,  22,  33},
+                    },
+                    {  // band 4
+                        { 37, 213, 238}, {  8, 167, 216}, {  1, 104, 168},
+                        {  1,  68, 119}, {  1,  40,  67}, {  1,  17,  29},
+                    },
+                    {  // band 5
+                        { 30, 228, 239}, {  4, 181, 213}, {  1, 103, 153},
+                        {  1,  65, 110}, {  1,  43,  79}, {  1,  27,  56},
+                    },
+                },
+            },
+        },
+        {  // TX_SIZE 3
+            {  // Y plane
+                {  // Intra
+                    {  // band 0
+                        { 76,  25,  53}, {  9,  18,  32}, {  1,  12,  18},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        { 29,  55,  91}, { 19,  58,  95}, { 15,  57,  89},
+                        { 12,  49,  77}, {  3,  29,  44}, {  1,   8,  12},
+                    },
+                    {  // band 2
+                        { 32, 160, 148}, { 33, 143, 146}, { 19, 122, 132},
+                        {  6,  90, 102}, {  1,  58,  70}, {  1,  17,  24},
+                    },
+                    {  // band 3
+                        { 16, 181, 181}, {  6, 142, 165}, {  1,  90, 120},
+                        {  1,  50,  71}, {  1,  25,  38}, {  1,   9,  14},
+                    },
+                    {  // band 4
+                        { 13, 203, 203}, {  3, 154, 176}, {  1,  80, 108},
+                        {  1,  41,  61}, {  1,  24,  37}, {  1,  11,  17},
+                    },
+                    {  // band 5
+                        {  6, 234, 240}, {  1, 178, 204}, {  1,  80, 119},
+                        {  1,  45,  71}, {  1,  26,  42}, {  1,  12,  19},
+                    },
+                },
+                {  // Intra
+                    {  // band 0
+                        { 78,  20, 135}, { 25,  18, 101}, {  5,  19,  57},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        {  7, 144, 183}, {117, 151, 195}, {109, 151, 187},
+                        { 39, 130, 168}, { 11, 100, 125}, {  4,  59,  64},
+                    },
+                    {  // band 2
+                        { 20, 184, 212}, { 12, 148, 191}, {  2,  98, 141},
+                        {  1,  65, 100}, {  1,  39,  61}, {  1,  14,  22},
+                    },
+                    {  // band 3
+                        { 15, 194, 222}, {  6, 153, 198}, {  1,  92, 138},
+                        {  1,  58,  91}, {  1,  32,  52}, {  1,  12,  18},
+                    },
+                    {  // band 4
+                        { 14, 206, 232}, {  3, 162, 206}, {  1,  89, 134},
+                        {  1,  52,  83}, {  1,  28,  46}, {  1,  11,  17},
+                    },
+                    {  // band 5
+                        {  6, 225, 241}, {  1, 175, 210}, {  1,  81, 125},
+                        {  1,  48,  78}, {  1,  28,  46}, {  1,  13,  21},
+                    },
+                },
+            },
+            {  // UV plane
+                {  // Inter
+                    {  // band 0
+                        {124,  23,  93}, { 31,  24,  63}, {  6,  24,  46},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        { 23,  86, 126}, { 45,  90, 145}, { 31,  91, 133},
+                        { 19,  80, 114}, {  7,  53,  72}, {  1,  20,  27},
+                    },
+                    {  // band 2
+                        { 51, 186, 189}, { 48, 159, 182}, { 33, 128, 156},
+                        { 15,  92, 124}, {  2,  62,  83}, {  1,  29,  43},
+                    },
+                    {  // band 3
+                        { 36, 198, 211}, { 15, 156, 187}, {  3,  97, 137},
+                        {  1,  61,  93}, {  1,  35,  57}, {  1,  15,  23},
+                    },
+                    {  // band 4
+                        { 34, 219, 223}, {  9, 162, 193}, {  1,  91, 136},
+                        {  1,  58,  92}, {  1,  35,  54}, {  1,  14,  23},
+                    },
+                    {  // band 5
+                        { 19, 243, 243}, {  3, 191, 208}, {  1,  91, 137},
+                        {  1,  56,  90}, {  1,  34,  55}, {  1,  16,  24},
+                    },
+                },
+                {  // Inter
+                    {  // band 0
+                        {119,  20, 197}, { 19,  29, 156}, {  3,  30, 107},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        { 24, 192, 226}, {161, 193, 227}, { 97, 185, 222},
+                        { 31, 158, 204}, { 16, 122, 165}, { 17,  84, 112},
+                    },
+                    {  // band 2
+                        { 26, 202, 229}, { 11, 165, 210}, {  2, 103, 152},
+                        {  1,  68, 104}, {  1,  42,  70}, {  1,  16,  36},
+                    },
+                    {  // band 3
+                        { 24, 209, 237}, {  6, 169, 214}, {  1, 102, 154},
+                        {  1,  65, 107}, {  1,  45,  68}, {  1,  17,  24},
+                    },
+                    {  // band 4
+                        { 19, 219, 243}, {  4, 183, 226}, {  1, 115, 172},
+                        {  1,  73, 119}, {  1,  43,  77}, {  1,  15,  37},
+                    },
+                    {  // band 5
+                        { 11, 237, 241}, {  2, 190, 216}, {  1, 108, 146},
+                        {  1,  59,  94}, {  1,  40,  67}, {  1,  30,  53},
+                    },
+                },
+            },
+        },
+    },
+    {  // Q_Index 1
+        {  // TX_SIZE 0
+            {  // Y plane
+                {  // Intra
+                    {  // band 0
+                        {174,  30, 159}, { 76,  38, 115}, { 15,  33,  65},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        { 60,  80, 153}, { 72,  75, 147}, { 36,  68, 129},
+                        { 15,  59, 104}, {  4,  45,  74}, {  1,  28,  45},
+                    },
+                    {  // band 2
+                        { 70, 122, 186}, { 55, 104, 175}, { 21,  83, 144},
+                        {  8,  67, 112}, {  2,  51,  82}, {  1,  34,  57},
+                    },
+                    {  // band 3
+                        { 97, 144, 207}, { 52, 109, 195}, { 16,  77, 153},
+                        {  4,  58, 113}, {  1,  43,  77}, {  1,  27,  48},
+                    },
+                    {  // band 4
+                        {128, 148, 229}, { 76, 104, 210}, { 18,  77, 159},
+                        {  4,  65, 110}, {  1,  52,  82}, {  1,  31,  55},
+                    },
+                    {  // band 5
+                        {165,  51, 238}, {128,  50, 230}, { 57,  49, 185},
+                        { 28,  47, 130}, { 12,  44,  96}, {  3,  36,  60},
+                    },
+                },
+                {  // Intra
+                    {  // band 0
+                        {169, 103, 203}, {117,  96, 176}, { 56,  81, 137},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        { 31, 150, 224}, { 49, 128, 212}, { 19,  92, 165},
+                        {  6,  67, 116}, {  2,  43,  71}, {  1,  21,  36},
+                    },
+                    {  // band 2
+                        { 58, 156, 230}, { 47, 130, 215}, {  7,  87, 158},
+                        {  2,  63, 114}, {  1,  39,  71}, {  1,  18,  36},
+                    },
+                    {  // band 3
+                        { 85, 176, 240}, { 43, 138, 226}, {  8,  93, 172},
+                        {  2,  70, 127}, {  1,  46,  81}, {  1,  26,  47},
+                    },
+                    {  // band 4
+                        {155, 144, 248}, { 93, 116, 235}, { 21,  83, 180},
+                        {  4,  59, 119}, {  1,  43,  80}, {  1,  25,  50},
+                    },
+                    {  // band 5
+                        {203,  61, 250}, {171,  57, 243}, { 71,  57, 199},
+                        { 31,  49, 144}, { 13,  42,  96}, {  7,  30,  52},
+                    },
+                },
+            },
+            {  // UV plane
+                {  // Inter
+                    {  // band 0
+                        {204,  44, 204}, {137,  57, 184}, { 72,  62, 152},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        {145, 117, 236}, {151, 112, 231}, { 87,  95, 208},
+                        { 31,  77, 165}, {  5,  49,  98}, {  1,  24,  39},
+                    },
+                    {  // band 2
+                        {146, 152, 241}, {140, 132, 236}, { 41, 103, 209},
+                        { 10,  86, 165}, {  2,  55, 106}, {  1,  25,  58},
+                    },
+                    {  // band 3
+                        {154, 181, 249}, { 84, 143, 240}, { 23, 114, 210},
+                        {  6, 102, 182}, {  2,  71, 137}, {  1,  35,  90},
+                    },
+                    {  // band 4
+                        {184, 150, 251}, {115, 130, 244}, { 34, 105, 215},
+                        { 15,  89, 173}, {  1,  51, 141}, {128, 128, 128},
+                    },
+                    {  // band 5
+                        {211,  71, 253}, {193,  78, 249}, {106,  91, 232},
+                        { 61,  87, 198}, { 85, 153, 254}, {128, 128, 128},
+                    },
+                },
+                {  // Inter
+                    {  // band 0
+                        {232, 104, 242}, {165, 114, 227}, { 96, 120, 206},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        {137, 178, 250}, {146, 153, 245}, { 74, 108, 205},
+                        { 41,  81, 149}, { 24,  55, 104}, { 13,  36,  68},
+                    },
+                    {  // band 2
+                        {147, 185, 252}, {127, 161, 246}, { 30, 104, 208},
+                        { 11,  74, 154}, {  6,  54, 100}, {  2,  29,  63},
+                    },
+                    {  // band 3
+                        {163, 191, 254}, {101, 161, 249}, { 22, 114, 215},
+                        {  6,  89, 173}, {  1,  65, 120}, {  1,   1, 170},
+                    },
+                    {  // band 4
+                        {197, 160, 254}, {142, 141, 251}, { 39, 102, 218},
+                        { 10,  76, 158}, {  1,  56, 122}, {128, 128, 128},
+                    },
+                    {  // band 5
+                        {224,  76, 254}, {215,  84, 253}, {107,  85, 232},
+                        { 43,  71, 177}, {  1,   1, 254}, {128, 128, 128},
+                    },
+                },
+            },
+        },
+        {  // TX_SIZE 1
+            {  // Y plane
+                {  // Intra
+                    {  // band 0
+                        { 68,  37, 120}, { 21,  34,  82}, {  5,  26,  49},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        { 41,  89, 138}, { 56,  83, 132}, { 31,  73, 115},
+                        { 16,  62,  92}, {  5,  45,  62}, {  1,  24,  32},
+                    },
+                    {  // band 2
+                        { 48, 139, 165}, { 30, 114, 160}, { 13,  92, 132},
+                        {  6,  72, 103}, {  3,  49,  72}, {  1,  26,  41},
+                    },
+                    {  // band 3
+                        { 44, 162, 191}, { 20, 127, 175}, {  5,  90, 137},
+                        {  1,  62, 100}, {  1,  38,  63}, {  1,  20,  32},
+                    },
+                    {  // band 4
+                        { 51, 184, 213}, { 16, 137, 193}, {  2,  89, 143},
+                        {  1,  60, 102}, {  1,  39,  66}, {  1,  23,  37},
+                    },
+                    {  // band 5
+                        { 76, 200, 235}, { 27, 150, 216}, {  3,  99, 164},
+                        {  1,  70, 119}, {  1,  45,  77}, {  1,  22,  38},
+                    },
+                },
+                {  // Intra
+                    {  // band 0
+                        { 81, 112, 199}, { 49, 101, 164}, { 19,  80, 119},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        { 12, 181, 217}, { 48, 151, 212}, { 38, 118, 180},
+                        { 22,  95, 140}, { 11,  67,  92}, { 13,  46,  44},
+                    },
+                    {  // band 2
+                        { 29, 188, 226}, { 19, 147, 210}, {  5,  95, 154},
+                        {  4,  68, 106}, {  3,  44,  60}, {  1,  24,  27},
+                    },
+                    {  // band 3
+                        { 30, 195, 234}, { 15, 153, 216}, {  3,  95, 156},
+                        {  2,  66, 108}, {  2,  44,  62}, {  1,  24,  29},
+                    },
+                    {  // band 4
+                        { 36, 203, 243}, { 12, 162, 225}, {  2,  98, 163},
+                        {  2,  67, 113}, {  2,  45,  68}, {  1,  24,  34},
+                    },
+                    {  // band 5
+                        { 86, 207, 248}, { 35, 165, 236}, {  3, 107, 180},
+                        {  1,  73, 128}, {  1,  45,  78}, {  1,  20,  34},
+                    },
+                },
+            },
+            {  // UV plane
+                {  // Inter
+                    {  // band 0
+                        {188,  37, 205}, {118,  51, 172}, { 56,  57, 135},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        {116, 135, 225}, {144, 123, 221}, { 72, 103, 197},
+                        { 35,  77, 153}, { 15,  47,  82}, {  6,  25,  34},
+                    },
+                    {  // band 2
+                        {128, 171, 233}, { 82, 142, 226}, { 31, 106, 191},
+                        { 16,  82, 146}, {  9,  59,  98}, {  4,  33,  54},
+                    },
+                    {  // band 3
+                        {126, 197, 241}, { 66, 155, 230}, { 18, 108, 190},
+                        {  7,  82, 148}, {  3,  58,  98}, {  1,  25,  50},
+                    },
+                    {  // band 4
+                        {117, 207, 244}, { 44, 163, 233}, {  9, 112, 191},
+                        {  5,  84, 148}, {  3,  61,  87}, {  1,  28,  38},
+                    },
+                    {  // band 5
+                        {112, 214, 249}, { 39, 174, 240}, {  6, 125, 205},
+                        {  4,  96, 163}, {  5,  66, 100}, {  1, 128, 254},
+                    },
+                },
+                {  // Inter
+                    {  // band 0
+                        {227,  70, 234}, {145,  91, 213}, { 61, 100, 173},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        {108, 198, 243}, {171, 172, 240}, {118, 130, 210},
+                        {104, 107, 165}, { 64,  85, 114}, { 55,  64,  60},
+                    },
+                    {  // band 2
+                        {110, 208, 247}, { 64, 175, 237}, { 24, 112, 187},
+                        { 24,  81, 133}, { 24,  63,  83}, { 21,  47,  53},
+                    },
+                    {  // band 3
+                        { 91, 218, 249}, { 46, 188, 238}, {  8, 113, 184},
+                        {  5,  83, 137}, {  6,  62,  95}, { 17,  44,  94},
+                    },
+                    {  // band 4
+                        { 84, 216, 248}, { 30, 187, 237}, {  2, 117, 188},
+                        {  1,  88, 141}, {  3,  63,  98}, {  1,   1,   1},
+                    },
+                    {  // band 5
+                        {116, 218, 252}, { 47, 186, 242}, {  2, 132, 204},
+                        {  1, 106, 175}, {  1,  88, 104}, {  1, 254, 128},
+                    },
+                },
+            },
+        },
+        {  // TX_SIZE 2
+            {  // Y plane
+                {  // Intra
+                    {  // band 0
+                        { 35,  41, 129}, { 12,  30,  70}, {  2,  19,  32},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        { 30,  77, 116}, { 39,  70, 110}, { 20,  58,  96},
+                        {  8,  47,  77}, {  2,  33,  52}, {  1,  17,  26},
+                    },
+                    {  // band 2
+                        { 31, 123, 146}, { 18, 103, 140}, {  7,  81, 119},
+                        {  2,  62,  95}, {  1,  44,  70}, {  1,  26,  42},
+                    },
+                    {  // band 3
+                        { 21, 149, 170}, {  9, 114, 158}, {  2,  80, 126},
+                        {  1,  57,  94}, {  1,  36,  61}, {  1,  18,  31},
+                    },
+                    {  // band 4
+                        { 20, 178, 199}, {  6, 134, 183}, {  1,  87, 139},
+                        {  1,  60, 100}, {  1,  37,  64}, {  1,  18,  31},
+                    },
+                    {  // band 5
+                        { 36, 218, 233}, {  6, 160, 207}, {  1,  92, 147},
+                        {  1,  59, 101}, {  1,  35,  62}, {  1,  18,  31},
+                    },
+                },
+                {  // Intra
+                    {  // band 0
+                        { 17,  62, 211}, { 14,  62, 153}, {  5,  50,  84},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        { 11, 180, 205}, { 87, 160, 205}, { 53, 128, 184},
+                        { 27, 106, 156}, { 13,  79, 115}, {  6,  46,  67},
+                    },
+                    {  // band 2
+                        { 32, 194, 220}, { 20, 145, 202}, {  4,  96, 152},
+                        {  1,  67, 111}, {  1,  42,  70}, {  1,  21,  37},
+                    },
+                    {  // band 3
+                        { 30, 204, 228}, { 14, 152, 207}, {  1,  92, 149},
+                        {  1,  61, 103}, {  1,  34,  59}, {  1,  16,  28},
+                    },
+                    {  // band 4
+                        { 27, 213, 235}, {  7, 159, 210}, {  1,  88, 143},
+                        {  1,  55,  94}, {  1,  31,  53}, {  1,  16,  27},
+                    },
+                    {  // band 5
+                        { 28, 223, 243}, {  4, 173, 217}, {  1,  91, 146},
+                        {  1,  58,  98}, {  1,  35,  60}, {  1,  19,  33},
+                    },
+                },
+            },
+            {  // UV plane
+                {  // Inter
+                    {  // band 0
+                        {172,  37, 202}, { 83,  51, 156}, { 24,  53, 110},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        { 76, 134, 206}, {110, 124, 200}, { 47, 106, 180},
+                        { 15,  82, 145}, {  3,  48,  83}, {  1,  19,  32},
+                    },
+                    {  // band 2
+                        { 80, 176, 220}, { 49, 145, 212}, { 17, 112, 180},
+                        {  7,  84, 140}, {  1,  53,  89}, {  1,  27,  43},
+                    },
+                    {  // band 3
+                        { 74, 201, 232}, { 38, 158, 221}, {  8, 112, 179},
+                        {  2,  79, 132}, {  1,  47,  82}, {  1,  26,  42},
+                    },
+                    {  // band 4
+                        { 73, 215, 239}, { 28, 169, 227}, {  3, 112, 176},
+                        {  1,  74, 126}, {  1,  48,  79}, {  1,  27,  44},
+                    },
+                    {  // band 5
+                        { 71, 233, 244}, { 18, 180, 230}, {  1, 114, 180},
+                        {  1,  80, 134}, {  1,  51,  85}, {  1,  26,  36},
+                    },
+                },
+                {  // Inter
+                    {  // band 0
+                        {213,  34, 244}, {126,  57, 212}, { 46,  67, 151},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        {120, 202, 245}, {198, 173, 241}, {119, 146, 224},
+                        { 76, 126, 195}, { 44, 102, 159}, { 40,  76, 115},
+                    },
+                    {  // band 2
+                        {120, 215, 248}, { 69, 171, 237}, { 23, 119, 194},
+                        { 10,  86, 147}, {  2,  56,  94}, {  1,  25,  44},
+                    },
+                    {  // band 3
+                        {102, 226, 250}, { 53, 183, 239}, {  9, 118, 188},
+                        {  2,  78, 131}, {  1,  48,  89}, {  1,  17,  36},
+                    },
+                    {  // band 4
+                        { 86, 235, 252}, { 34, 194, 240}, {  2, 109, 173},
+                        {  1,  68, 118}, {  1,  44,  79}, {  1,   1,  38},
+                    },
+                    {  // band 5
+                        { 59, 236, 243}, { 11, 189, 228}, {  1, 112, 187},
+                        {  1,  88, 145}, {  1,  55,  92}, {  1,   1, 128},
+                    },
+                },
+            },
+        },
+        {  // TX_SIZE 3
+            {  // Y plane
+                {  // Intra
+                    {  // band 0
+                        { 41,  40, 104}, { 12,  31,  64}, {  2,  16,  28},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        { 65,  58, 132}, { 50,  61, 130}, { 40,  57, 116},
+                        { 22,  46,  87}, {  2,  28,  44}, {  1,  11,  17},
+                    },
+                    {  // band 2
+                        { 55, 139, 135}, { 46, 122, 132}, { 21,  89, 110},
+                        {  6,  60,  78}, {  1,  38,  54}, {  1,  17,  27},
+                    },
+                    {  // band 3
+                        { 29, 167, 161}, { 10, 120, 141}, {  1,  69,  98},
+                        {  1,  42,  66}, {  1,  28,  44}, {  1,  15,  24},
+                    },
+                    {  // band 4
+                        { 19, 191, 180}, {  4, 125, 154}, {  1,  70, 107},
+                        {  1,  48,  77}, {  1,  33,  53}, {  1,  17,  28},
+                    },
+                    {  // band 5
+                        { 16, 238, 231}, {  2, 163, 198}, {  1,  85, 134},
+                        {  1,  54,  90}, {  1,  34,  57}, {  1,  17,  29},
+                    },
+                },
+                {  // Intra
+                    {  // band 0
+                        { 70,  15, 216}, { 40,  18, 164}, { 14,  17,  83},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        { 25, 150, 200}, {185, 154, 211}, {123, 137, 199},
+                        { 67, 119, 177}, { 31,  96, 137}, { 18,  63,  86},
+                    },
+                    {  // band 2
+                        { 57, 187, 223}, { 35, 148, 207}, {  7, 104, 159},
+                        {  2,  72, 113}, {  1,  44,  71}, {  1,  20,  34},
+                    },
+                    {  // band 3
+                        { 44, 203, 233}, { 18, 157, 212}, {  1,  98, 150},
+                        {  1,  61, 102}, {  1,  38,  62}, {  1,  19,  31},
+                    },
+                    {  // band 4
+                        { 41, 215, 238}, { 11, 166, 215}, {  1,  94, 146},
+                        {  1,  60, 101}, {  1,  37,  63}, {  1,  17,  28},
+                    },
+                    {  // band 5
+                        { 19, 236, 246}, {  3, 188, 223}, {  1,  95, 146},
+                        {  1,  58,  95}, {  1,  34,  56}, {  1,  17,  27},
+                    },
+                },
+            },
+            {  // UV plane
+                {  // Inter
+                    {  // band 0
+                        {146,  27, 156}, { 49,  32, 116}, { 10,  39,  77},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        { 47, 101, 172}, { 93, 100, 178}, { 58,  91, 165},
+                        { 26,  75, 134}, {  4,  49,  82}, {  2,  22,  33},
+                    },
+                    {  // band 2
+                        { 60, 158, 196}, { 44, 135, 186}, { 25, 106, 157},
+                        {  8,  81, 124}, {  2,  56,  86}, {  1,  28,  45},
+                    },
+                    {  // band 3
+                        { 44, 169, 212}, { 15, 138, 196}, {  2, 100, 157},
+                        {  1,  74, 119}, {  1,  49,  76}, {  1,  20,  34},
+                    },
+                    {  // band 4
+                        { 38, 199, 231}, { 11, 158, 214}, {  1, 111, 167},
+                        {  1,  76, 122}, {  1,  44,  76}, {  1,  17,  39},
+                    },
+                    {  // band 5
+                        { 40, 236, 246}, { 10, 187, 230}, {  1, 115, 175},
+                        {  1,  74, 122}, {  1,  42,  71}, {  1,  14,  59},
+                    },
+                },
+                {  // Inter
+                    {  // band 0
+                        {161,  26, 237}, { 65,  46, 209}, { 21,  46, 161},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        { 87, 229, 245}, {206, 214, 244}, {148, 186, 236},
+                        { 89, 165, 221}, { 41, 132, 186}, { 37,  93, 141},
+                    },
+                    {  // band 2
+                        { 93, 231, 246}, { 47, 181, 231}, {  8, 117, 188},
+                        {  2,  84, 138}, {  1,  43,  87}, {  1,  27,  41},
+                    },
+                    {  // band 3
+                        { 80, 239, 250}, { 28, 190, 236}, {  1, 119, 183},
+                        {  1,  84, 135}, {  1,  81,  69}, {  1, 102,   1},
+                    },
+                    {  // band 4
+                        { 67, 245, 252}, { 22, 206, 242}, {  1, 130, 195},
+                        {  1,  77, 136}, {  1,  35,  88}, {128, 128, 128},
+                    },
+                    {  // band 5
+                        { 43, 250, 228}, { 31, 185, 204}, {  6, 101, 183},
+                        {  1,  92, 151}, {  1,  84, 137}, {128, 128, 128},
+                    },
+                },
+            },
+        },
+    },
+    {  // Q_Index 2
+        {  // TX_SIZE 0
+            {  // Y plane
+                {  // Intra
+                    {  // band 0
+                        {181,  22, 175}, { 96,  37, 147}, { 35,  41, 105},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        { 80,  95, 197}, {111,  92, 193}, { 59,  87, 175},
+                        { 29,  79, 150}, { 10,  65, 118}, {  2,  47,  82},
+                    },
+                    {  // band 2
+                        { 90, 141, 216}, { 77, 120, 210}, { 23,  95, 184},
+                        { 11,  81, 151}, {  6,  75, 130}, {  2,  58, 113},
+                    },
+                    {  // band 3
+                        {122, 167, 231}, { 66, 119, 225}, { 26,  87, 189},
+                        {  7,  76, 151}, {  2,  63, 125}, {  1,  59,  77},
+                    },
+                    {  // band 4
+                        {162, 147, 244}, {110,  97, 236}, { 32,  88, 204},
+                        { 11,  89, 174}, {  5,  78, 151}, {128, 128, 128},
+                    },
+                    {  // band 5
+                        {205,  59, 251}, {176,  68, 248}, { 90,  71, 223},
+                        { 49,  72, 188}, { 17,  74, 203}, {128, 128, 128},
+                    },
+                },
+                {  // Intra
+                    {  // band 0
+                        {188,  70, 207}, {140,  73, 189}, { 85,  73, 163},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        { 59, 144, 239}, { 79, 126, 237}, { 31, 102, 202},
+                        { 10,  81, 153}, {  3,  56, 102}, {  2,  33,  59},
+                    },
+                    {  // band 2
+                        {100, 152, 243}, { 80, 129, 236}, { 14,  94, 194},
+                        {  4,  72, 150}, {  1,  50, 103}, {  1,  35,  60},
+                    },
+                    {  // band 3
+                        {130, 183, 247}, { 70, 139, 242}, { 19, 100, 203},
+                        {  4,  83, 159}, {  1,  59, 119}, {  1,  44,  72},
+                    },
+                    {  // band 4
+                        {197, 138, 252}, {135, 107, 247}, { 31,  86, 210},
+                        {  7,  74, 160}, {  1,  53, 107}, {128, 128, 128},
+                    },
+                    {  // band 5
+                        {229,  54, 254}, {200,  51, 251}, { 83,  61, 226},
+                        { 33,  55, 177}, { 12,  74, 145}, {128, 128, 128},
+                    },
+                },
+            },
+            {  // UV plane
+                {  // Inter
+                    {  // band 0
+                        {229,  20, 235}, {183,  37, 221}, {127,  47, 198},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        {188, 115, 251}, {208, 110, 250}, {101,  99, 235},
+                        { 38,  81, 197}, {  9,  56, 132}, {  9,  52,  63},
+                    },
+                    {  // band 2
+                        {189, 150, 252}, {186, 137, 251}, { 54, 107, 236},
+                        { 14,  90, 195}, {  1,  89, 104}, {128, 128, 128},
+                    },
+                    {  // band 3
+                        {209, 180, 254}, {142, 145, 253}, { 51, 130, 236},
+                        {  6, 128, 214}, {  1, 128, 254}, {128, 128, 128},
+                    },
+                    {  // band 4
+                        {231, 140, 254}, {194, 128, 254}, { 75, 119, 233},
+                        {128,  23, 230}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 5
+                        {244,  59, 254}, {239,  81, 254}, {128,  85, 254},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                },
+                {  // Inter
+                    {  // band 0
+                        {246,  55, 247}, {197,  64, 235}, {141,  74, 218},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        {178, 163, 254}, {192, 138, 252}, { 85, 103, 231},
+                        { 49,  81, 179}, { 32,  54, 133}, { 12,  26,  98},
+                    },
+                    {  // band 2
+                        {189, 173, 254}, {179, 150, 253}, { 60,  94, 237},
+                        { 34,  81, 198}, { 20,  53, 187}, {128, 128, 128},
+                    },
+                    {  // band 3
+                        {202, 191, 254}, {157, 160, 254}, { 57, 117, 240},
+                        { 28, 105, 211}, {  1, 128,   1}, {128, 128, 128},
+                    },
+                    {  // band 4
+                        {231, 146, 254}, {208, 133, 254}, { 66,  78, 233},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 5
+                        {246,  49, 254}, {246,  63, 254}, { 85, 142, 254},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                },
+            },
+        },
+        {  // TX_SIZE 1
+            {  // Y plane
+                {  // Intra
+                    {  // band 0
+                        { 45,  28, 124}, { 23,  35, 107}, { 10,  34,  78},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        { 53,  99, 177}, { 82,  96, 174}, { 46,  89, 158},
+                        { 21,  76, 133}, {  6,  56,  94}, {  1,  33,  54},
+                    },
+                    {  // band 2
+                        { 68, 147, 201}, { 42, 124, 195}, { 17,  98, 166},
+                        {  7,  75, 131}, {  2,  53,  93}, {  1,  33,  59},
+                    },
+                    {  // band 3
+                        { 65, 176, 217}, { 30, 137, 206}, {  6,  97, 167},
+                        {  2,  70, 128}, {  1,  47,  88}, {  1,  29,  46},
+                    },
+                    {  // band 4
+                        { 69, 195, 232}, { 24, 146, 218}, {  4, 100, 175},
+                        {  2,  72, 134}, {  1,  51,  93}, {  1,  29,  52},
+                    },
+                    {  // band 5
+                        { 96, 212, 246}, { 39, 158, 234}, {  6, 109, 192},
+                        {  2,  77, 144}, {  1,  50,  95}, {  1,  20,  45},
+                    },
+                },
+                {  // Intra
+                    {  // band 0
+                        { 71,  80, 213}, { 53,  73, 181}, { 25,  66, 141},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        { 35, 168, 231}, { 91, 150, 229}, { 49, 122, 202},
+                        { 22,  97, 162}, { 10,  68, 108}, {  9,  48,  57},
+                    },
+                    {  // band 2
+                        { 56, 178, 236}, { 32, 148, 225}, {  9,  99, 176},
+                        {  4,  69, 127}, {  2,  44,  78}, {  1,  25,  41},
+                    },
+                    {  // band 3
+                        { 57, 191, 242}, { 27, 155, 230}, {  5, 102, 180},
+                        {  2,  71, 133}, {  1,  44,  78}, {  1,  27,  41},
+                    },
+                    {  // band 4
+                        { 67, 201, 247}, { 24, 162, 237}, {  3, 106, 188},
+                        {  3,  74, 137}, {  1,  46,  85}, {  1,  34,  48},
+                    },
+                    {  // band 5
+                        {111, 210, 251}, { 47, 166, 244}, {  3, 113, 199},
+                        {  2,  77, 146}, {  1,  48,  93}, {  1,  38,  22},
+                    },
+                },
+            },
+            {  // UV plane
+                {  // Inter
+                    {  // band 0
+                        {206,  21, 221}, {150,  36, 195}, { 94,  44, 164},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        {147, 128, 239}, {194, 122, 238}, { 95, 104, 220},
+                        { 39,  81, 183}, { 13,  53, 111}, {  3,  24,  49},
+                    },
+                    {  // band 2
+                        {164, 163, 244}, {106, 142, 239}, { 50, 112, 215},
+                        { 26,  90, 177}, { 12,  67, 130}, {  1,   1,  64},
+                    },
+                    {  // band 3
+                        {155, 193, 249}, { 88, 158, 244}, { 26, 124, 220},
+                        { 10,  98, 173}, {  1,  77, 126}, {128, 128, 128},
+                    },
+                    {  // band 4
+                        {141, 205, 252}, { 64, 174, 248}, { 17, 124, 221},
+                        { 12,  92, 176}, {  1,  29, 148}, {128, 128, 128},
+                    },
+                    {  // band 5
+                        {150, 217, 254}, { 74, 191, 252}, { 30, 144, 215},
+                        {  1, 106, 137}, {128,   1, 128}, {128, 128, 128},
+                    },
+                },
+                {  // Inter
+                    {  // band 0
+                        {241,  37, 242}, {175,  48, 223}, { 99,  53, 189},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        {153, 183, 248}, {212, 156, 247}, {134, 124, 221},
+                        { 88, 103, 184}, { 59,  86, 132}, { 29,  61,  67},
+                    },
+                    {  // band 2
+                        {162, 199, 250}, {106, 167, 247}, { 56, 110, 207},
+                        { 32,  85, 165}, { 16,  71, 130}, {  1,  93, 254},
+                    },
+                    {  // band 3
+                        {143, 213, 252}, { 86, 187, 250}, { 23, 124, 220},
+                        {  7,  95, 176}, {  1, 109, 102}, {128, 128, 128},
+                    },
+                    {  // band 4
+                        {130, 219, 254}, { 70, 201, 253}, { 15, 128, 215},
+                        {  1, 101, 201}, {  1,  64, 170}, {128, 128, 128},
+                    },
+                    {  // band 5
+                        {155, 219, 254}, {105, 207, 254}, { 28, 155, 229},
+                        {  1, 153, 191}, {128, 128, 128}, {128, 128, 128},
+                    },
+                },
+            },
+        },
+        {  // TX_SIZE 2
+            {  // Y plane
+                {  // Intra
+                    {  // band 0
+                        { 18,  26, 117}, { 10,  29,  82}, {  3,  25,  52},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        { 35,  88, 152}, { 62,  85, 150}, { 36,  77, 137},
+                        { 16,  66, 116}, {  4,  47,  81}, {  1,  26,  44},
+                    },
+                    {  // band 2
+                        { 55, 141, 182}, { 32, 119, 177}, { 12,  93, 154},
+                        {  4,  71, 123}, {  1,  51,  89}, {  1,  32,  56},
+                    },
+                    {  // band 3
+                        { 46, 171, 202}, { 21, 130, 191}, {  5,  91, 154},
+                        {  1,  64, 115}, {  1,  42,  77}, {  1,  25,  41},
+                    },
+                    {  // band 4
+                        { 43, 195, 219}, { 12, 142, 203}, {  1,  91, 156},
+                        {  1,  63, 115}, {  1,  41,  77}, {  1,  22,  43},
+                    },
+                    {  // band 5
+                        { 42, 221, 238}, {  8, 162, 219}, {  1,  98, 167},
+                        {  1,  67, 123}, {  1,  43,  83}, {  1,  25,  38},
+                    },
+                },
+                {  // Intra
+                    {  // band 0
+                        { 16,  51, 216}, { 20,  48, 168}, {  9,  44, 109},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        { 34, 164, 226}, {124, 148, 226}, { 72, 127, 207},
+                        { 36, 107, 175}, { 15,  81, 129}, {  6,  51,  79},
+                    },
+                    {  // band 2
+                        { 61, 182, 234}, { 35, 148, 220}, {  9, 101, 178},
+                        {  4,  71, 134}, {  1,  46,  90}, {  1,  24,  51},
+                    },
+                    {  // band 3
+                        { 54, 198, 239}, { 25, 156, 224}, {  3,  98, 173},
+                        {  1,  66, 124}, {  1,  41,  78}, {  1,  15,  37},
+                    },
+                    {  // band 4
+                        { 48, 209, 242}, { 12, 162, 226}, {  1,  96, 169},
+                        {  1,  63, 119}, {  1,  40,  78}, {  1,  18,  45},
+                    },
+                    {  // band 5
+                        { 44, 223, 247}, {  6, 173, 232}, {  1, 105, 178},
+                        {  1,  71, 131}, {  1,  44,  84}, {  1,  13,  46},
+                    },
+                },
+            },
+            {  // UV plane
+                {  // Inter
+                    {  // band 0
+                        {188,  26, 214}, {121,  42, 181}, { 66,  49, 149},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        {136, 128, 233}, {172, 124, 230}, { 80, 106, 211},
+                        { 27,  81, 174}, {  6,  49,  98}, {  8,  28,  49},
+                    },
+                    {  // band 2
+                        {145, 166, 239}, { 92, 141, 229}, { 28, 108, 196},
+                        {  8,  87, 154}, {  1,  58, 105}, {  1,  27,  59},
+                    },
+                    {  // band 3
+                        {131, 193, 242}, { 66, 151, 231}, { 13, 112, 192},
+                        {  2,  81, 152}, {  1,  66, 121}, {  1,  23,  64},
+                    },
+                    {  // band 4
+                        {112, 211, 246}, { 41, 164, 235}, {  5, 117, 202},
+                        {  1,  83, 162}, {  1,  64, 111}, {128, 128, 128},
+                    },
+                    {  // band 5
+                        { 96, 230, 250}, { 28, 185, 243}, {  2, 132, 204},
+                        {  1,  91, 166}, {  1,  85,  46}, {128, 128, 128},
+                    },
+                },
+                {  // Inter
+                    {  // band 0
+                        {238,  23, 242}, {157,  29, 215}, { 73,  27, 162},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        {165, 173, 250}, {222, 151, 247}, {152, 134, 235},
+                        {114, 120, 210}, { 86, 109, 176}, { 53,  88, 145},
+                    },
+                    {  // band 2
+                        {164, 194, 249}, {100, 158, 241}, { 35, 111, 212},
+                        { 17,  85, 167}, {  1,  52, 112}, {  1,  73,   1},
+                    },
+                    {  // band 3
+                        {151, 215, 252}, { 83, 172, 245}, { 16, 122, 208},
+                        {  6, 101, 165}, {  1,  74, 113}, {  1,   1,   1},
+                    },
+                    {  // band 4
+                        {138, 230, 253}, { 65, 184, 248}, {  8, 128, 212},
+                        {  1, 111, 182}, {128,   1,   1}, {128, 128, 128},
+                    },
+                    {  // band 5
+                        {123, 240, 253}, { 36, 201, 250}, {  3, 127, 211},
+                        {  1,  68, 204}, {128,   1,   1}, {128, 128, 128},
+                    },
+                },
+            },
+        },
+        {  // TX_SIZE 3
+            {  // Y plane
+                {  // Intra
+                    {  // band 0
+                        { 51,  21, 156}, { 30,  23,  86}, {  4,  18,  37},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        { 38,  77, 129}, { 79,  76, 129}, { 40,  66, 117},
+                        { 12,  54,  95}, {  1,  36,  60}, {  1,  17,  29},
+                    },
+                    {  // band 2
+                        { 44, 133, 149}, { 24, 107, 143}, {  8,  78, 121},
+                        {  3,  59,  97}, {  1,  42,  71}, {  1,  22,  37},
+                    },
+                    {  // band 3
+                        { 29, 160, 171}, {  9, 114, 158}, {  1,  76, 125},
+                        {  1,  54,  93}, {  1,  36,  63}, {  1,  20,  35},
+                    },
+                    {  // band 4
+                        { 22, 188, 205}, {  6, 132, 186}, {  1,  87, 144},
+                        {  1,  62, 107}, {  1,  41,  72}, {  1,  23,  41},
+                    },
+                    {  // band 5
+                        { 25, 233, 236}, {  5, 165, 214}, {  1,  96, 158},
+                        {  1,  63, 112}, {  1,  40,  73}, {  1,  23,  40},
+                    },
+                },
+                {  // Intra
+                    {  // band 0
+                        { 48,  20, 231}, { 37,  21, 179}, { 15,  18, 109},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        { 41, 154, 216}, {196, 142, 221}, {131, 125, 207},
+                        { 84, 111, 181}, { 45,  91, 142}, { 27,  62,  89},
+                    },
+                    {  // band 2
+                        { 72, 181, 230}, { 41, 147, 215}, { 10, 102, 173},
+                        {  3,  73, 132}, {  1,  47,  89}, {  1,  23,  50},
+                    },
+                    {  // band 3
+                        { 60, 201, 236}, { 23, 157, 219}, {  2,  99, 167},
+                        {  1,  69, 124}, {  1,  43,  80}, {  1,  22,  39},
+                    },
+                    {  // band 4
+                        { 53, 214, 242}, { 15, 165, 224}, {  1, 101, 173},
+                        {  1,  70, 131}, {  1,  44,  83}, {  1,  23,  49},
+                    },
+                    {  // band 5
+                        { 39, 239, 248}, {  7, 186, 233}, {  1, 108, 174},
+                        {  1,  70, 123}, {  1,  43,  77}, {  1,  16,  42},
+                    },
+                },
+            },
+            {  // UV plane
+                {  // Inter
+                    {  // band 0
+                        {161,  26, 204}, { 77,  40, 160}, { 26,  50, 117},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        { 80, 140, 218}, {136, 133, 215}, { 63, 117, 197},
+                        { 20,  93, 170}, {  7,  55, 102}, { 13,  32,  52},
+                    },
+                    {  // band 2
+                        { 86, 173, 231}, { 46, 150, 220}, { 18, 118, 190},
+                        {  8,  90, 150}, {  2,  60,  95}, {  1,  39,  41},
+                    },
+                    {  // band 3
+                        { 80, 183, 242}, { 37, 160, 231}, {  6, 120, 182},
+                        {  1,  86, 137}, {  1,  46,  78}, {  1,  15,  24},
+                    },
+                    {  // band 4
+                        { 88, 215, 247}, { 42, 179, 235}, {  4, 116, 182},
+                        {  2,  80, 133}, {  1,  46,  85}, {  1,  64,  43},
+                    },
+                    {  // band 5
+                        {100, 236, 250}, { 31, 186, 234}, {  1, 114, 181},
+                        {  1,  85, 135}, {  1,  78,  64}, {128, 128, 128},
+                    },
+                },
+                {  // Inter
+                    {  // band 0
+                        {213,  13, 245}, {106,  16, 211}, { 32,  11, 156},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        {140, 214, 247}, {241, 186, 243}, {177, 172, 235},
+                        {128, 156, 219}, {106, 130, 191}, { 99, 105, 152},
+                    },
+                    {  // band 2
+                        {125, 218, 248}, { 75, 167, 239}, { 29, 111, 212},
+                        {  6,  66, 152}, {  1,  42,  96}, {  1,  85, 128},
+                    },
+                    {  // band 3
+                        {120, 232, 252}, { 60, 189, 247}, {  8, 141, 200},
+                        {  1,  89, 134}, {  1,  32, 128}, {128, 128, 128},
+                    },
+                    {  // band 4
+                        {111, 238, 253}, { 56, 198, 245}, {  1, 123, 208},
+                        {  1,  93, 176}, {  1,   1,  73}, {128, 128, 128},
+                    },
+                    {  // band 5
+                        { 98, 251, 249}, { 56, 189, 244}, { 17, 113, 220},
+                        {  1, 109, 179}, {128, 128, 128}, {128, 128, 128},
+                    },
+                },
+            },
+        },
+    },
+    {  // Q_Index 3
+        {  // TX_SIZE 0
+            {  // Y plane
+                {  // Intra
+                    {  // band 0
+                        {186,  16, 200}, {122,  31, 187}, { 78,  40, 161},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        {146, 119, 245}, {182, 115, 244}, {130, 113, 238},
+                        { 88, 110, 225}, { 47, 103, 208}, {  5, 102, 188},
+                    },
+                    {  // band 2
+                        {164, 157, 248}, {155, 141, 250}, { 71, 116, 243},
+                        { 88, 129, 233}, { 50,  99, 228}, { 26, 148, 191},
+                    },
+                    {  // band 3
+                        {200, 158, 253}, {177, 118, 252}, { 99, 113, 245},
+                        { 77, 120, 210}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 4
+                        {231, 104, 254}, {209,  82, 254}, {143, 112, 252},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 5
+                        {250,  36, 254}, {243,  55, 254}, {223, 170, 254},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                },
+                {  // Intra
+                    {  // band 0
+                        {207,  37, 226}, {164,  46, 218}, {122,  58, 201},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        {149, 154, 253}, {170, 137, 253}, { 94, 123, 247},
+                        { 42, 113, 222}, { 16,  97, 174}, { 49,  98, 159},
+                    },
+                    {  // band 2
+                        {177, 162, 253}, {165, 142, 252}, { 51, 108, 243},
+                        { 18, 108, 213}, {  1,  98, 254}, {128, 128, 128},
+                    },
+                    {  // band 3
+                        {211, 152, 254}, {184, 116, 254}, { 70, 110, 244},
+                        {  8, 108, 237}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 4
+                        {236,  89, 254}, {210,  67, 254}, {112, 111, 248},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 5
+                        {246,  26, 254}, {233,  35, 254}, {128,   1, 254},
+                        {254, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                },
+            },
+            {  // UV plane
+                {  // Inter
+                    {  // band 0
+                        {247,   2, 247}, {226,   8, 242}, {191,  14, 235},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        {231,  94, 254}, {248,  91, 254}, {186,  89, 252},
+                        {128,  92, 244}, { 79, 112, 254}, {128, 128, 128},
+                    },
+                    {  // band 2
+                        {228, 145, 253}, {240, 130, 254}, {223, 105, 254},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 3
+                        {245, 153, 253}, {240, 120, 254}, {128, 128, 128},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 4
+                        {254, 128, 254}, {204, 128, 254}, {128, 128, 128},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 5
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                },
+                {  // Inter
+                    {  // band 0
+                        {253,   7, 249}, {224,   9, 244}, {182,  13, 231},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        {234, 109, 254}, {242, 104, 254}, {160,  98, 254},
+                        {123,  85, 243}, { 82,  43, 217}, {128, 128, 128},
+                    },
+                    {  // band 2
+                        {243, 137, 254}, {240, 118, 254}, {136,  53, 254},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 3
+                        {251, 173, 254}, {229, 129, 250}, {128, 128, 128},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 4
+                        {254, 119, 254}, {254, 128, 128}, {128, 128, 128},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 5
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                },
+            },
+        },
+        {  // TX_SIZE 1
+            {  // Y plane
+                {  // Intra
+                    {  // band 0
+                        { 49,  26, 159}, { 36,  34, 150}, { 26,  38, 124},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        { 99, 122, 226}, {143, 119, 225}, { 90, 113, 213},
+                        { 46, 102, 193}, { 14,  84, 157}, {  3,  59, 107},
+                    },
+                    {  // band 2
+                        {109, 164, 237}, { 74, 142, 233}, { 29, 112, 216},
+                        { 14,  92, 184}, { 10,  80, 156}, {  1,  52, 137},
+                    },
+                    {  // band 3
+                        {110, 191, 245}, { 59, 156, 240}, { 18, 121, 220},
+                        {  8,  97, 184}, {  3,  84, 150}, {128, 128, 128},
+                    },
+                    {  // band 4
+                        {115, 203, 250}, { 59, 167, 246}, { 16, 130, 226},
+                        {  7,  97, 192}, {  1,  71,  99}, {128, 128, 128},
+                    },
+                    {  // band 5
+                        {149, 218, 253}, { 93, 171, 251}, { 28, 125, 233},
+                        { 28,  99, 192}, {128,  85,  85}, {128, 128, 128},
+                    },
+                },
+                {  // Intra
+                    {  // band 0
+                        { 97,  45, 229}, { 79,  52, 205}, { 46,  58, 171},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        { 99, 180, 249}, {156, 165, 249}, { 73, 141, 237},
+                        { 31, 116, 208}, { 13,  81, 153}, {  5,  42,  86},
+                    },
+                    {  // band 2
+                        {113, 188, 251}, { 68, 161, 244}, { 16, 108, 216},
+                        {  6,  81, 168}, {  2,  65, 118}, {128,   1,   1},
+                    },
+                    {  // band 3
+                        {117, 201, 252}, { 62, 171, 248}, { 12, 119, 221},
+                        {  5,  90, 182}, {  4,  66, 116}, {128, 128, 128},
+                    },
+                    {  // band 4
+                        {128, 207, 253}, { 70, 176, 251}, { 11, 126, 228},
+                        {  6,  89, 189}, {  1,  44, 148}, {128, 128, 128},
+                    },
+                    {  // band 5
+                        {162, 218, 254}, {107, 170, 253}, { 22, 131, 238},
+                        {  1,  77, 182}, {  1, 254, 128}, {128, 128, 128},
+                    },
+                },
+            },
+            {  // UV plane
+                {  // Inter
+                    {  // band 0
+                        {235,   5, 238}, {194,  14, 223}, {152,  22, 205},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        {200, 121, 251}, {241, 115, 252}, {167, 108, 248},
+                        { 93,  93, 233}, { 36,  66, 189}, {128, 128, 128},
+                    },
+                    {  // band 2
+                        {220, 151, 253}, {176, 135, 252}, { 95, 124, 254},
+                        { 64, 105, 217}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 3
+                        {225, 189, 254}, {175, 155, 254}, {102, 119, 254},
+                        {  1,   1,   1}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 4
+                        {218, 195, 254}, {125, 157, 253}, {128, 128, 254},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 5
+                        {221, 197, 254}, { 85, 210, 254}, {128, 128, 128},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                },
+                {  // Inter
+                    {  // band 0
+                        {250,   9, 246}, {204,  13, 234}, {144,  18, 211},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        {213, 157, 253}, {243, 138, 253}, {170, 117, 250},
+                        {109,  91, 233}, { 66,  77, 163}, { 64,  85, 254},
+                    },
+                    {  // band 2
+                        {221, 169, 254}, {182, 141, 253}, {112, 120, 239},
+                        { 85, 165, 254}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 3
+                        {226, 192, 254}, {189, 174, 251}, {153, 128, 254},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 4
+                        {232, 192, 254}, {195, 187, 247}, {  1, 191, 254},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 5
+                        {247, 185, 254}, {254,  93, 254}, {128, 128, 128},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                },
+            },
+        },
+        {  // TX_SIZE 2
+            {  // Y plane
+                {  // Intra
+                    {  // band 0
+                        { 14,  30, 136}, { 15,  33, 120}, { 10,  33,  90},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        { 92, 109, 209}, {113, 108, 207}, { 77, 102, 193},
+                        { 39,  91, 171}, { 11,  70, 129}, {  2,  44,  77},
+                    },
+                    {  // band 2
+                        { 99, 158, 223}, { 66, 135, 217}, { 23, 109, 194},
+                        {  9,  85, 160}, {  3,  66, 124}, {  1,  51, 100},
+                    },
+                    {  // band 3
+                        { 89, 189, 234}, { 46, 149, 225}, { 10, 110, 194},
+                        {  2,  83, 156}, {  1,  57, 113}, {  1,  47,  73},
+                    },
+                    {  // band 4
+                        { 78, 206, 242}, { 28, 161, 232}, {  3, 114, 200},
+                        {  1,  86, 161}, {  1,  62, 118}, {  1,   1,   1},
+                    },
+                    {  // band 5
+                        { 72, 227, 250}, { 20, 182, 242}, {  3, 126, 210},
+                        {  2,  91, 166}, {  1,  64, 126}, {128, 128, 128},
+                    },
+                },
+                {  // Intra
+                    {  // band 0
+                        { 23,  42, 227}, { 41,  43, 195}, { 25,  45, 146},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        {100, 172, 245}, {165, 158, 246}, { 88, 137, 234},
+                        { 44, 116, 203}, { 18,  85, 149}, {  7,  56,  92},
+                    },
+                    {  // band 2
+                        {117, 188, 247}, { 70, 155, 239}, { 18, 105, 204},
+                        {  7,  78, 158}, {  2,  50, 111}, {  1,  38,  77},
+                    },
+                    {  // band 3
+                        {104, 207, 250}, { 54, 166, 241}, {  6, 110, 199},
+                        {  1,  78, 155}, {  1,  45, 100}, {  1,   1,   1},
+                    },
+                    {  // band 4
+                        { 87, 216, 251}, { 30, 177, 243}, {  1, 114, 203},
+                        {  1,  85, 157}, {  1,  53, 108}, {128, 128, 128},
+                    },
+                    {  // band 5
+                        { 80, 230, 253}, { 23, 193, 248}, {  1, 127, 215},
+                        {  1,  94, 170}, {  1,  71,  59}, {128, 128, 128},
+                    },
+                },
+            },
+            {  // UV plane
+                {  // Inter
+                    {  // band 0
+                        {222,   9, 234}, {161,  20, 210}, {113,  30, 185},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        {195, 120, 248}, {231, 124, 247}, {148, 116, 238},
+                        { 64,  98, 207}, { 20,  70, 147}, { 87,  68, 100},
+                    },
+                    {  // band 2
+                        {186, 161, 250}, {124, 148, 245}, { 44, 123, 230},
+                        { 23, 107, 205}, {  1,  80, 131}, {128, 128, 128},
+                    },
+                    {  // band 3
+                        {172, 196, 252}, {110, 160, 248}, { 37, 134, 235},
+                        { 23, 125, 200}, {128, 254, 128}, {128, 128, 128},
+                    },
+                    {  // band 4
+                        {173, 209, 253}, {103, 175, 250}, {  1, 120, 240},
+                        {  1, 146, 254}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 5
+                        {184, 235, 254}, { 81, 186, 251}, {128, 109, 254},
+                        {128, 254, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                },
+                {  // Inter
+                    {  // band 0
+                        {248,   8, 243}, {185,  11, 225}, {108,  11, 189},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        {208, 158, 254}, {244, 147, 252}, {195, 132, 248},
+                        {161, 122, 224}, {129, 114, 188}, { 59, 119, 159},
+                    },
+                    {  // band 2
+                        {202, 182, 253}, {143, 161, 251}, { 73, 115, 247},
+                        {146, 175, 204}, {128,   1, 254}, {128, 128, 128},
+                    },
+                    {  // band 3
+                        {202, 204, 254}, {131, 174, 251}, { 18, 153, 207},
+                        {128, 254, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 4
+                        {192, 221, 254}, {114, 190, 254}, {128, 170, 254},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 5
+                        {166, 236, 254}, {119, 200, 254}, {128, 128, 128},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                },
+            },
+        },
+        {  // TX_SIZE 3
+            {  // Y plane
+                {  // Intra
+                    {  // band 0
+                        { 30,  32, 144}, { 21,  35,  96}, {  4,  27,  55},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        { 35, 107, 172}, { 61, 104, 170}, { 33,  94, 160},
+                        { 13,  80, 139}, {  2,  55,  97}, {  1,  28,  49},
+                    },
+                    {  // band 2
+                        { 51, 153, 195}, { 29, 129, 189}, {  9,  99, 163},
+                        {  3,  75, 129}, {  1,  49,  88}, {  1,  29,  50},
+                    },
+                    {  // band 3
+                        { 53, 164, 210}, { 21, 134, 201}, {  3,  97, 164},
+                        {  1,  69, 124}, {  1,  45,  82}, {  1,  31,  58},
+                    },
+                    {  // band 4
+                        { 47, 205, 234}, { 18, 158, 220}, {  2, 109, 177},
+                        {  1,  78, 137}, {  1,  53, 101}, {  1,  34,  70},
+                    },
+                    {  // band 5
+                        { 55, 233, 245}, { 16, 179, 233}, {  1, 116, 191},
+                        {  1,  79, 145}, {  1,  53, 101}, {  1,  37,  58},
+                    },
+                },
+                {  // Intra
+                    {  // band 0
+                        { 36,  33, 227}, { 39,  28, 190}, { 18,  27, 134},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        { 76, 156, 235}, {184, 147, 235}, {114, 130, 220},
+                        { 72, 112, 191}, { 42,  87, 144}, { 21,  65,  93},
+                    },
+                    {  // band 2
+                        { 96, 179, 240}, { 51, 149, 228}, { 12, 105, 191},
+                        {  6,  74, 148}, {  1,  47, 100}, {  1,  29,  53},
+                    },
+                    {  // band 3
+                        { 88, 191, 242}, { 35, 154, 231}, {  3, 106, 187},
+                        {  1,  74, 140}, {  1,  41,  84}, {  1,  25,  38},
+                    },
+                    {  // band 4
+                        { 77, 212, 249}, { 28, 171, 239}, {  2, 117, 199},
+                        {  1,  79, 151}, {  1,  45,  99}, {  1,   1,   1},
+                    },
+                    {  // band 5
+                        { 77, 236, 252}, { 27, 190, 246}, {  2, 120, 203},
+                        {  1,  78, 147}, {  1,  42,  72}, {128, 128, 128},
+                    },
+                },
+            },
+            {  // UV plane
+                {  // Inter
+                    {  // band 0
+                        {185,  11, 227}, {113,  30, 182}, { 57,  44, 144},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        {151, 139, 244}, {212, 139, 241}, {124, 126, 231},
+                        { 59, 104, 213}, { 26,  73, 158}, { 20,  45,  95},
+                    },
+                    {  // band 2
+                        {155, 163, 247}, {108, 152, 239}, { 39, 124, 214},
+                        {  7, 109, 162}, { 29,  57, 128}, {128, 128, 128},
+                    },
+                    {  // band 3
+                        {158, 176, 250}, { 89, 164, 243}, { 11, 114, 196},
+                        {  1,  96, 141}, {  1,  81, 118}, {128,   1,   1},
+                    },
+                    {  // band 4
+                        {148, 212, 251}, { 59, 174, 240}, {  2, 130, 203},
+                        {  1,  70, 168}, {  1,  51, 106}, {128, 128, 128},
+                    },
+                    {  // band 5
+                        {104, 237, 252}, { 39, 190, 246}, {  1, 154, 220},
+                        {128, 102,   1}, {128, 128, 128}, {128, 128, 128},
+                    },
+                },
+                {  // Inter
+                    {  // band 0
+                        {236,   6, 242}, {111,   6, 206}, { 36,   5, 161},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 1
+                        {193, 193, 252}, {248, 182, 251}, {218, 150, 246},
+                        {182, 134, 244}, {151, 137, 227}, { 45, 102, 195},
+                    },
+                    {  // band 2
+                        {188, 202, 251}, {125, 165, 249}, { 64,  75, 218},
+                        {  1, 128, 254}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 3
+                        {178, 225, 254}, {107, 188, 231}, { 21, 135, 233},
+                        {128,   1, 254}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 4
+                        {164, 227, 253}, { 55, 193, 251}, {  1, 111, 225},
+                        {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
+                    },
+                    {  // band 5
+                        {151, 243, 254}, { 50, 203, 254}, {128, 179, 254},
+                        {128,   1, 254}, {128, 128, 128}, {128, 128, 128},
+                    },
+                },
+            },
+        },
+    },
+};
+#else
 static const vp10_coeff_probs_model default_coef_probs_4x4[PLANE_TYPES] = {
   {  // Y plane
     {  // Intra
@@ -1021,6 +2794,7 @@
     }
   }
 };
+#endif  // CONFIG_ENTROPY
 
 static void extend_to_full_distribution(vpx_prob *probs, vpx_prob p) {
   assert(p != 0);
@@ -1034,10 +2808,17 @@
 }
 
 void vp10_default_coef_probs(VP10_COMMON *cm) {
+#if CONFIG_ENTROPY
+  const int index =
+      VPXMIN(ROUND_POWER_OF_TWO(cm->base_qindex, 8 - QCTX_BIN_BITS),
+             QCTX_BINS - 1);
+  vp10_copy(cm->fc->coef_probs, default_qctx_coef_probs[index]);
+#else
   vp10_copy(cm->fc->coef_probs[TX_4X4], default_coef_probs_4x4);
   vp10_copy(cm->fc->coef_probs[TX_8X8], default_coef_probs_8x8);
   vp10_copy(cm->fc->coef_probs[TX_16X16], default_coef_probs_16x16);
   vp10_copy(cm->fc->coef_probs[TX_32X32], default_coef_probs_32x32);
+#endif  // CONFIG_ENTROPY
 }
 
 #define COEF_COUNT_SAT 24
@@ -1052,9 +2833,17 @@
                              unsigned int update_factor) {
   const FRAME_CONTEXT *pre_fc = &cm->frame_contexts[cm->frame_context_idx];
   vp10_coeff_probs_model *const probs = cm->fc->coef_probs[tx_size];
+#if CONFIG_ENTROPY
+  const vp10_coeff_probs_model *const pre_probs = cm->partial_prob_update ?
+      (const vp10_coeff_probs_model *)cm->starting_coef_probs[tx_size] :
+      pre_fc->coef_probs[tx_size];
+#else
   const vp10_coeff_probs_model *const pre_probs = pre_fc->coef_probs[tx_size];
-  vp10_coeff_count_model *counts = cm->counts.coef[tx_size];
-  unsigned int (*eob_counts)[REF_TYPES][COEF_BANDS][COEFF_CONTEXTS] =
+#endif  // CONFIG_ENTROPY
+  const vp10_coeff_count_model *const counts =
+      (const vp10_coeff_count_model *)cm->counts.coef[tx_size];
+  const unsigned int (*eob_counts)[REF_TYPES][COEF_BANDS][COEFF_CONTEXTS] =
+      (const unsigned int (*)[REF_TYPES][COEF_BANDS][COEFF_CONTEXTS])
       cm->counts.eob_branch[tx_size];
   int i, j, k, l, m;
 
@@ -1092,6 +2881,23 @@
     update_factor = COEF_MAX_UPDATE_FACTOR;
     count_sat = COEF_COUNT_SAT;
   }
+#if CONFIG_ENTROPY
+  if (cm->partial_prob_update == 1) {
+    update_factor = COEF_MAX_UPDATE_FACTOR;
+  }
+#endif  // CONFIG_ENTROPY
   for (t = TX_4X4; t <= TX_32X32; t++)
     adapt_coef_probs(cm, t, count_sat, update_factor);
 }
+
+#if CONFIG_ENTROPY
+void vp10_partial_adapt_probs(VP10_COMMON *cm, int mi_row, int mi_col) {
+  (void)mi_row;
+  (void)mi_col;
+
+  if (cm->refresh_frame_context == REFRESH_FRAME_CONTEXT_BACKWARD) {
+    cm->partial_prob_update = 1;
+    vp10_adapt_coef_probs(cm);
+  }
+}
+#endif  // CONFIG_ENTROPY
diff --git a/vp10/common/entropy.h b/vp10/common/entropy.h
index 8ea01be..2385720 100644
--- a/vp10/common/entropy.h
+++ b/vp10/common/entropy.h
@@ -27,6 +27,12 @@
 #define DIFF_UPDATE_PROB       252
 #define GROUP_DIFF_UPDATE_PROB 252
 
+#if CONFIG_ENTROPY
+#define COEF_PROBS_BUFS 16
+#define QCTX_BIN_BITS 2
+#define QCTX_BINS (1 << QCTX_BIN_BITS)
+#endif  // CONFIG_ENTROPY
+
 // Coefficient token alphabet
 #define ZERO_TOKEN      0   // 0     Extra Bits 0+0
 #define ONE_TOKEN       1   // 1     Extra Bits 0+1
@@ -139,6 +145,9 @@
 struct VP10Common;
 void vp10_default_coef_probs(struct VP10Common *cm);
 void vp10_adapt_coef_probs(struct VP10Common *cm);
+#if CONFIG_ENTROPY
+void vp10_partial_adapt_probs(struct VP10Common *cm, int mi_row, int mi_col);
+#endif  // CONFIG_ENTROPY
 
 // This is the index in the scan order beyond which all coefficients for
 // 8x8 transform and above are in the top band.
diff --git a/vp10/common/onyxc_int.h b/vp10/common/onyxc_int.h
index 2dd09b5..6c257d7 100644
--- a/vp10/common/onyxc_int.h
+++ b/vp10/common/onyxc_int.h
@@ -283,6 +283,18 @@
   unsigned int  frame_context_idx; /* Context to use/update */
   FRAME_COUNTS counts;
 
+#if CONFIG_ENTROPY
+  // The initial probabilities for a frame, before any subframe backward update,
+  // and after forward update.
+  vp10_coeff_probs_model starting_coef_probs[TX_SIZES][PLANE_TYPES];
+  // Number of subframe backward updates already done
+  uint8_t coef_probs_update_idx;
+  // Signal if the backward update is subframe or end-of-frame
+  uint8_t partial_prob_update;
+  // Frame level flag to turn on/off subframe backward update
+  uint8_t do_subframe_update;
+#endif  // CONFIG_ENTROPY
+
   unsigned int current_video_frame;
   BITSTREAM_PROFILE profile;
 
diff --git a/vp10/decoder/decodeframe.c b/vp10/decoder/decodeframe.c
index 935e4f7..df75fea 100644
--- a/vp10/decoder/decodeframe.c
+++ b/vp10/decoder/decodeframe.c
@@ -3014,6 +3014,11 @@
   int mi_row, mi_col;
   TileData *tile_data = NULL;
 
+#if CONFIG_ENTROPY
+  cm->do_subframe_update =
+      cm->log2_tile_cols == 0 && cm->log2_tile_rows == 0;
+#endif  // CONFIG_ENTROPY
+
   if (cm->lf.filter_level && !cm->skip_loop_filter &&
       pbi->lf_worker.data1 == NULL) {
     CHECK_MEM_ERROR(cm, pbi->lf_worker.data1,
@@ -3112,6 +3117,18 @@
         if (pbi->mb.corrupted)
             vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME,
                                "Failed to decode tile data");
+#if CONFIG_ENTROPY
+        if (cm->do_subframe_update &&
+            cm->refresh_frame_context == REFRESH_FRAME_CONTEXT_BACKWARD) {
+          if ((mi_row + MI_SIZE) % (MI_SIZE *
+              VPXMAX(cm->mi_rows / MI_SIZE / COEF_PROBS_BUFS, 1)) == 0 &&
+              mi_row + MI_SIZE < cm->mi_rows &&
+              cm->coef_probs_update_idx < COEF_PROBS_BUFS - 1) {
+            vp10_partial_adapt_probs(cm, mi_row, mi_col);
+            ++cm->coef_probs_update_idx;
+          }
+        }
+#endif  // CONFIG_ENTROPY
       }
 #if !CONFIG_VAR_TX
       // Loopfilter one row.
@@ -3634,6 +3651,17 @@
   xd->bd = (int)cm->bit_depth;
 #endif
 
+#if CONFIG_ENTROPY
+  vp10_default_coef_probs(cm);
+  if (cm->frame_type == KEY_FRAME || cm->error_resilient_mode ||
+      cm->reset_frame_context == RESET_FRAME_CONTEXT_ALL) {
+    for (i = 0; i < FRAME_CONTEXTS; ++i)
+      cm->frame_contexts[i] = *cm->fc;
+  } else if (cm->reset_frame_context == RESET_FRAME_CONTEXT_CURRENT) {
+    cm->frame_contexts[cm->frame_context_idx] = *cm->fc;
+  }
+#endif  // CONFIG_ENTROPY
+
   setup_segmentation(cm, rb);
 
   {
@@ -4035,6 +4063,11 @@
     vp10_frameworker_unlock_stats(worker);
   }
 
+#if CONFIG_ENTROPY
+  vp10_copy(cm->starting_coef_probs, cm->fc->coef_probs);
+  cm->coef_probs_update_idx = 0;
+#endif  // CONFIG_ENTROPY
+
   if (pbi->max_threads > 1 && tile_rows == 1 && tile_cols > 1) {
     // Multi-threaded tile decoder
     *p_data_end = decode_tiles_mt(pbi, data + first_partition_size, data_end);
@@ -4065,6 +4098,9 @@
 
   if (!xd->corrupted) {
     if (cm->refresh_frame_context == REFRESH_FRAME_CONTEXT_BACKWARD) {
+#if CONFIG_ENTROPY
+      cm->partial_prob_update = 0;
+#endif  // CONFIG_ENTROPY
       vp10_adapt_coef_probs(cm);
       vp10_adapt_intra_frame_probs(cm);
 
diff --git a/vp10/encoder/bitstream.c b/vp10/encoder/bitstream.c
index 7f58b52..a4a7d9f 100644
--- a/vp10/encoder/bitstream.c
+++ b/vp10/encoder/bitstream.c
@@ -2052,10 +2052,250 @@
   }
 }
 
+#if CONFIG_ENTROPY
+// Calculate the token counts between subsequent subframe updates.
+static void get_coef_counts_diff(VP10_COMP *cpi, int index,
+                                 vp10_coeff_count
+                                 coef_counts[TX_SIZES][PLANE_TYPES],
+                                 unsigned int eob_counts[TX_SIZES]
+                                 [PLANE_TYPES][REF_TYPES][COEF_BANDS]
+                                 [COEFF_CONTEXTS]) {
+  int i, j, k, l, m, tx_size, val;
+  const int max_idx = cpi->common.coef_probs_update_idx;
+  const TX_MODE tx_mode = cpi->common.tx_mode;
+  const TX_SIZE max_tx_size = tx_mode_to_biggest_tx_size[tx_mode];
+  const SUBFRAME_STATS *subframe_stats = &cpi->subframe_stats;
+
+  assert(max_idx < COEF_PROBS_BUFS);
+
+  for (tx_size = TX_4X4; tx_size <= max_tx_size; ++tx_size)
+    for (i = 0; i < PLANE_TYPES; ++i)
+      for (j = 0; j < REF_TYPES; ++j)
+        for (k = 0; k < COEF_BANDS; ++k)
+          for (l = 0; l < BAND_COEFF_CONTEXTS(k); ++l) {
+            if (index == max_idx) {
+              val = cpi->common.counts.eob_branch[tx_size][i][j][k][l] -
+                  subframe_stats->eob_counts_buf[max_idx][tx_size][i][j][k][l];
+            } else {
+              val = subframe_stats->eob_counts_buf[index + 1][tx_size]
+                                                             [i][j][k][l] -
+                  subframe_stats->eob_counts_buf[index][tx_size][i][j][k][l];
+            }
+            assert(val >= 0);
+            eob_counts[tx_size][i][j][k][l] = val;
+
+            for (m = 0; m < ENTROPY_TOKENS; ++m) {
+              if (index == max_idx) {
+                val = cpi->td.rd_counts.coef_counts[tx_size][i][j][k][l][m] -
+                    subframe_stats->coef_counts_buf[max_idx][tx_size]
+                                                            [i][j][k][l][m];
+              } else {
+                val = subframe_stats->coef_counts_buf[index + 1]
+                                                     [tx_size][i][j][k][l][m] -
+                      subframe_stats->coef_counts_buf[index][tx_size]
+                                                            [i][j][k][l][m];
+              }
+              assert(val >= 0);
+              coef_counts[tx_size][i][j][k][l][m] = val;
+            }
+          }
+}
+
+static void update_coef_probs_subframe(vpx_writer* const bc, VP10_COMP *cpi,
+                                       TX_SIZE tx_size,
+                                       vp10_coeff_stats
+                                       branch_ct[COEF_PROBS_BUFS][TX_SIZES]
+                                                                 [PLANE_TYPES],
+                                     vp10_coeff_probs_model *new_coef_probs) {
+  vp10_coeff_probs_model *old_coef_probs = cpi->common.fc->coef_probs[tx_size];
+  const vpx_prob upd = DIFF_UPDATE_PROB;
+  const int entropy_nodes_update = UNCONSTRAINED_NODES;
+  int i, j, k, l, t;
+  int stepsize = cpi->sf.coeff_prob_appx_step;
+  const int max_idx = cpi->common.coef_probs_update_idx;
+  int idx;
+  unsigned int this_branch_ct[ENTROPY_NODES][COEF_PROBS_BUFS][2];
+
+  switch (cpi->sf.use_fast_coef_updates) {
+    case TWO_LOOP: {
+      /* dry run to see if there is any update at all needed */
+      int savings = 0;
+      int update[2] = {0, 0};
+      for (i = 0; i < PLANE_TYPES; ++i) {
+        for (j = 0; j < REF_TYPES; ++j) {
+          for (k = 0; k < COEF_BANDS; ++k) {
+            for (l = 0; l < BAND_COEFF_CONTEXTS(k); ++l) {
+              for (t = 0; t < ENTROPY_NODES; ++t) {
+                for (idx = 0; idx <= max_idx; ++idx) {
+                  memcpy(this_branch_ct[t][idx],
+                         branch_ct[idx][tx_size][i][j][k][l][t],
+                         2 * sizeof(this_branch_ct[t][idx][0]));
+                }
+              }
+              for (t = 0; t < entropy_nodes_update; ++t) {
+                vpx_prob newp = new_coef_probs[i][j][k][l][t];
+                const vpx_prob oldp = old_coef_probs[i][j][k][l][t];
+                int s, u = 0;
+
+                if (t == PIVOT_NODE)
+                  s = vp10_prob_update_search_model_subframe(this_branch_ct,
+                                      old_coef_probs[i][j][k][l], &newp, upd,
+                                      stepsize, max_idx);
+                else
+                  s = vp10_prob_update_search_subframe(this_branch_ct[t],
+                                                       oldp, &newp, upd,
+                                                       max_idx);
+                if (s > 0 && newp != oldp)
+                  u = 1;
+                if (u)
+                  savings += s - (int)(vp10_cost_zero(upd));
+                else
+                  savings -= (int)(vp10_cost_zero(upd));
+                update[u]++;
+              }
+            }
+          }
+        }
+      }
+
+      /* Is coef updated at all */
+      if (update[1] == 0 || savings < 0) {
+        vpx_write_bit(bc, 0);
+        return;
+      }
+      vpx_write_bit(bc, 1);
+      for (i = 0; i < PLANE_TYPES; ++i) {
+        for (j = 0; j < REF_TYPES; ++j) {
+          for (k = 0; k < COEF_BANDS; ++k) {
+            for (l = 0; l < BAND_COEFF_CONTEXTS(k); ++l) {
+              for (t = 0; t < ENTROPY_NODES; ++t) {
+                for (idx = 0; idx <= max_idx; ++idx) {
+                  memcpy(this_branch_ct[t][idx],
+                         branch_ct[idx][tx_size][i][j][k][l][t],
+                         2 * sizeof(this_branch_ct[t][idx][0]));
+                }
+              }
+              for (t = 0; t < entropy_nodes_update; ++t) {
+                vpx_prob newp = new_coef_probs[i][j][k][l][t];
+                vpx_prob *oldp = old_coef_probs[i][j][k][l] + t;
+                const vpx_prob upd = DIFF_UPDATE_PROB;
+                int s;
+                int u = 0;
+
+                if (t == PIVOT_NODE)
+                  s = vp10_prob_update_search_model_subframe(this_branch_ct,
+                                     old_coef_probs[i][j][k][l], &newp, upd,
+                                     stepsize, max_idx);
+                else
+                  s = vp10_prob_update_search_subframe(this_branch_ct[t],
+                                                       *oldp, &newp, upd,
+                                                       max_idx);
+                if (s > 0 && newp != *oldp)
+                  u = 1;
+                vpx_write(bc, u, upd);
+                if (u) {
+                  /* send/use new probability */
+                  vp10_write_prob_diff_update(bc, newp, *oldp);
+                  *oldp = newp;
+                }
+              }
+            }
+          }
+        }
+      }
+      return;
+    }
+
+    case ONE_LOOP_REDUCED: {
+      int updates = 0;
+      int noupdates_before_first = 0;
+      for (i = 0; i < PLANE_TYPES; ++i) {
+        for (j = 0; j < REF_TYPES; ++j) {
+          for (k = 0; k < COEF_BANDS; ++k) {
+            for (l = 0; l < BAND_COEFF_CONTEXTS(k); ++l) {
+              for (t = 0; t < ENTROPY_NODES; ++t) {
+                for (idx = 0; idx <= max_idx; ++idx) {
+                  memcpy(this_branch_ct[t][idx],
+                         branch_ct[idx][tx_size][i][j][k][l][t],
+                         2 * sizeof(this_branch_ct[t][idx][0]));
+                }
+              }
+              for (t = 0; t < entropy_nodes_update; ++t) {
+                vpx_prob newp = new_coef_probs[i][j][k][l][t];
+                vpx_prob *oldp = old_coef_probs[i][j][k][l] + t;
+                int s;
+                int u = 0;
+
+                if (t == PIVOT_NODE)
+                  s = vp10_prob_update_search_model_subframe(this_branch_ct,
+                                      old_coef_probs[i][j][k][l], &newp, upd,
+                                      stepsize, max_idx);
+                else
+                  s = vp10_prob_update_search_subframe(this_branch_ct[t],
+                                                       *oldp, &newp, upd,
+                                                       max_idx);
+                if (s > 0 && newp != *oldp)
+                  u = 1;
+                updates += u;
+                if (u == 0 && updates == 0) {
+                  noupdates_before_first++;
+                  continue;
+                }
+                if (u == 1 && updates == 1) {
+                  int v;
+                  // first update
+                  vpx_write_bit(bc, 1);
+                  for (v = 0; v < noupdates_before_first; ++v)
+                    vpx_write(bc, 0, upd);
+                }
+                vpx_write(bc, u, upd);
+                if (u) {
+                  /* send/use new probability */
+                  vp10_write_prob_diff_update(bc, newp, *oldp);
+                  *oldp = newp;
+                }
+              }
+            }
+          }
+        }
+      }
+      if (updates == 0) {
+        vpx_write_bit(bc, 0);  // no updates
+      }
+      return;
+    }
+    default:
+      assert(0);
+  }
+}
+#endif  // CONFIG_ENTROPY
+
 static void update_coef_probs(VP10_COMP *cpi, vpx_writer* w) {
   const TX_MODE tx_mode = cpi->common.tx_mode;
   const TX_SIZE max_tx_size = tx_mode_to_biggest_tx_size[tx_mode];
   TX_SIZE tx_size;
+#if CONFIG_ENTROPY
+  VP10_COMMON *cm = &cpi->common;
+  SUBFRAME_STATS *subframe_stats = &cpi->subframe_stats;
+  unsigned int eob_counts_copy[TX_SIZES][PLANE_TYPES][REF_TYPES]
+                              [COEF_BANDS][COEFF_CONTEXTS];
+  int i;
+  vp10_coeff_count coef_counts[COEF_PROBS_BUFS][TX_SIZES][PLANE_TYPES];
+  unsigned int eob_counts[COEF_PROBS_BUFS][TX_SIZES][PLANE_TYPES]
+                         [REF_TYPES][COEF_BANDS][COEFF_CONTEXTS];
+  vp10_coeff_stats branch_ct[COEF_PROBS_BUFS][TX_SIZES][PLANE_TYPES];
+  vp10_coeff_probs_model dummy_frame_coef_probs[PLANE_TYPES];
+
+  if (cm->do_subframe_update &&
+      cm->refresh_frame_context == REFRESH_FRAME_CONTEXT_BACKWARD) {
+    vp10_copy(cpi->common.fc->coef_probs,
+              subframe_stats->enc_starting_coef_probs);
+    for (i = 0; i <= cpi->common.coef_probs_update_idx; ++i) {
+      get_coef_counts_diff(cpi, i, coef_counts[i], eob_counts[i]);
+    }
+  }
+#endif  // CONFIG_ENTROPY
+
   for (tx_size = TX_4X4; tx_size <= max_tx_size; ++tx_size) {
     vp10_coeff_stats frame_branch_ct[PLANE_TYPES];
     vp10_coeff_probs_model frame_coef_probs[PLANE_TYPES];
@@ -2063,12 +2303,59 @@
         (tx_size >= TX_16X16 && cpi->sf.tx_size_search_method == USE_TX_8X8)) {
       vpx_write_bit(w, 0);
     } else {
-      build_tree_distribution(cpi, tx_size, frame_branch_ct,
-                              frame_coef_probs);
-      update_coef_probs_common(w, cpi, tx_size, frame_branch_ct,
-                               frame_coef_probs);
+#if CONFIG_ENTROPY
+      if (cm->do_subframe_update &&
+          cm->refresh_frame_context == REFRESH_FRAME_CONTEXT_BACKWARD) {
+        unsigned int eob_counts_copy[PLANE_TYPES][REF_TYPES]
+                                                 [COEF_BANDS][COEFF_CONTEXTS];
+        vp10_coeff_count coef_counts_copy[PLANE_TYPES];
+        vp10_copy(eob_counts_copy, cpi->common.counts.eob_branch[tx_size]);
+        vp10_copy(coef_counts_copy, cpi->td.rd_counts.coef_counts[tx_size]);
+        build_tree_distribution(cpi, tx_size, frame_branch_ct,
+                                frame_coef_probs);
+        for (i = 0; i <= cpi->common.coef_probs_update_idx; ++i) {
+          vp10_copy(cpi->common.counts.eob_branch[tx_size],
+                    eob_counts[i][tx_size]);
+          vp10_copy(cpi->td.rd_counts.coef_counts[tx_size],
+                    coef_counts[i][tx_size]);
+          build_tree_distribution(cpi, tx_size, branch_ct[i][tx_size],
+                                  dummy_frame_coef_probs);
+        }
+        vp10_copy(cpi->common.counts.eob_branch[tx_size], eob_counts_copy);
+        vp10_copy(cpi->td.rd_counts.coef_counts[tx_size], coef_counts_copy);
+
+        update_coef_probs_subframe(w, cpi, tx_size, branch_ct,
+                                   frame_coef_probs);
+      } else {
+#endif  // CONFIG_ENTROPY
+        build_tree_distribution(cpi, tx_size, frame_branch_ct,
+                                frame_coef_probs);
+        update_coef_probs_common(w, cpi, tx_size, frame_branch_ct,
+                                 frame_coef_probs);
+#if CONFIG_ENTROPY
+      }
+#endif  // CONFIG_ENTROPY
     }
   }
+
+#if CONFIG_ENTROPY
+  vp10_copy(cm->starting_coef_probs, cm->fc->coef_probs);
+  vp10_copy(subframe_stats->coef_probs_buf[0], cm->fc->coef_probs);
+  if (cm->do_subframe_update &&
+      cm->refresh_frame_context == REFRESH_FRAME_CONTEXT_BACKWARD) {
+    vp10_copy(eob_counts_copy, cm->counts.eob_branch);
+    for (i = 1; i <= cpi->common.coef_probs_update_idx; ++i) {
+      for (tx_size = TX_4X4; tx_size <= max_tx_size; ++tx_size)
+        full_to_model_counts(cm->counts.coef[tx_size],
+                             subframe_stats->coef_counts_buf[i][tx_size]);
+      vp10_copy(cm->counts.eob_branch, subframe_stats->eob_counts_buf[i]);
+      vp10_partial_adapt_probs(cm, 0, 0);
+      vp10_copy(subframe_stats->coef_probs_buf[i], cm->fc->coef_probs);
+    }
+    vp10_copy(cm->fc->coef_probs, subframe_stats->coef_probs_buf[0]);
+    vp10_copy(cm->counts.eob_branch, eob_counts_copy);
+  }
+#endif  // CONFIG_ENTROPY
 }
 
 #if CONFIG_LOOP_RESTORATION
diff --git a/vp10/encoder/encodeframe.c b/vp10/encoder/encodeframe.c
index 61f6e9c..16673f1 100644
--- a/vp10/encoder/encodeframe.c
+++ b/vp10/encoder/encodeframe.c
@@ -4238,6 +4238,31 @@
                         INT64_MAX, td->pc_root);
     }
   }
+#if CONFIG_ENTROPY
+  if (cm->do_subframe_update &&
+      cm->refresh_frame_context == REFRESH_FRAME_CONTEXT_BACKWARD) {
+    if ((mi_row + MI_SIZE) % (MI_SIZE *
+        VPXMAX(cm->mi_rows / MI_SIZE / COEF_PROBS_BUFS, 1)) == 0 &&
+        mi_row + MI_SIZE < cm->mi_rows &&
+        cm->coef_probs_update_idx < COEF_PROBS_BUFS - 1) {
+      TX_SIZE t;
+      SUBFRAME_STATS *subframe_stats = &cpi->subframe_stats;
+
+      for (t = TX_4X4; t <= TX_32X32; ++t)
+        full_to_model_counts(cpi->td.counts->coef[t],
+                             cpi->td.rd_counts.coef_counts[t]);
+      vp10_partial_adapt_probs(cm, mi_row, mi_col);
+      ++cm->coef_probs_update_idx;
+      vp10_copy(subframe_stats->coef_probs_buf[cm->coef_probs_update_idx],
+                cm->fc->coef_probs);
+      vp10_copy(subframe_stats->coef_counts_buf[cm->coef_probs_update_idx],
+                cpi->td.rd_counts.coef_counts);
+      vp10_copy(subframe_stats->eob_counts_buf[cm->coef_probs_update_idx],
+                cm->counts.eob_branch);
+      fill_token_costs(x->token_costs, cm->fc->coef_probs);
+    }
+  }
+#endif  // CONFIG_ENTROPY
 }
 
 static void init_encode_frame_mb_context(VP10_COMP *cpi) {
diff --git a/vp10/encoder/encoder.c b/vp10/encoder/encoder.c
index fc65e72..8aa1cac 100644
--- a/vp10/encoder/encoder.c
+++ b/vp10/encoder/encoder.c
@@ -3335,8 +3335,13 @@
   model_count[EOB_MODEL_TOKEN] = full_count[EOB_TOKEN];
 }
 
+#if CONFIG_ENTROPY
+void full_to_model_counts(vp10_coeff_count_model *model_count,
+                                 vp10_coeff_count *full_count) {
+#else
 static void full_to_model_counts(vp10_coeff_count_model *model_count,
                                  vp10_coeff_count *full_count) {
+#endif  // CONFIG_ENTROPY
   int i, j, k, l;
 
   for (i = 0; i < PLANE_TYPES; ++i)
@@ -3666,6 +3671,16 @@
 
   setup_frame(cpi);
 
+#if CONFIG_ENTROPY
+  cm->do_subframe_update =
+      cm->log2_tile_cols == 0 && cm->log2_tile_rows == 0;
+  vp10_copy(cm->starting_coef_probs, cm->fc->coef_probs);
+  vp10_copy(cpi->subframe_stats.enc_starting_coef_probs,
+            cm->fc->coef_probs);
+  cm->coef_probs_update_idx = 0;
+  vp10_copy(cpi->subframe_stats.coef_probs_buf[0], cm->fc->coef_probs);
+#endif  // CONFIG_ENTROPY
+
   suppress_active_map(cpi);
   // Variance adaptive and in frame q adjustment experiments are mutually
   // exclusive.
@@ -3768,6 +3783,44 @@
     if (loop_count == 0)
       setup_frame(cpi);
 
+#if CONFIG_ENTROPY
+    // Base q-index may have changed, so we need to assign proper default coef
+    // probs before every iteration.
+    if (frame_is_intra_only(cm) || cm->error_resilient_mode) {
+      int i;
+      vp10_default_coef_probs(cm);
+      if (cm->frame_type == KEY_FRAME || cm->error_resilient_mode ||
+          cm->reset_frame_context == RESET_FRAME_CONTEXT_ALL) {
+        for (i = 0; i < FRAME_CONTEXTS; ++i)
+          cm->frame_contexts[i] = *cm->fc;
+      } else if (cm->reset_frame_context == RESET_FRAME_CONTEXT_CURRENT) {
+        cm->frame_contexts[cm->frame_context_idx] = *cm->fc;
+      }
+    }
+#endif  // CONFIG_ENTROPY
+
+#if CONFIG_ENTROPY
+    cm->do_subframe_update =
+        cm->log2_tile_cols == 0 && cm->log2_tile_rows == 0;
+    if (loop_count == 0 || frame_is_intra_only(cm) ||
+        cm->error_resilient_mode) {
+      vp10_copy(cm->starting_coef_probs, cm->fc->coef_probs);
+      vp10_copy(cpi->subframe_stats.enc_starting_coef_probs,
+                cm->fc->coef_probs);
+    } else {
+      if (cm->do_subframe_update) {
+        vp10_copy(cm->fc->coef_probs,
+                  cpi->subframe_stats.enc_starting_coef_probs);
+        vp10_copy(cm->starting_coef_probs,
+                  cpi->subframe_stats.enc_starting_coef_probs);
+        vp10_zero(cpi->subframe_stats.coef_counts_buf);
+        vp10_zero(cpi->subframe_stats.eob_counts_buf);
+      }
+    }
+    cm->coef_probs_update_idx = 0;
+    vp10_copy(cpi->subframe_stats.coef_probs_buf[0], cm->fc->coef_probs);
+#endif  // CONFIG_ENTROPY
+
     // Variance adaptive and in frame q adjustment experiments are mutually
     // exclusive.
     if (cpi->oxcf.aq_mode == VARIANCE_AQ) {
@@ -4283,6 +4336,9 @@
                          cpi->td.rd_counts.coef_counts[t]);
 
   if (cm->refresh_frame_context == REFRESH_FRAME_CONTEXT_BACKWARD) {
+#if CONFIG_ENTROPY
+    cm->partial_prob_update = 0;
+#endif  // CONFIG_ENTROPY
     vp10_adapt_coef_probs(cm);
     vp10_adapt_intra_frame_probs(cm);
   }
diff --git a/vp10/encoder/encoder.h b/vp10/encoder/encoder.h
index b2fe978..7b7cb1c 100644
--- a/vp10/encoder/encoder.h
+++ b/vp10/encoder/encoder.h
@@ -290,6 +290,19 @@
   YV12_BUFFER_CONFIG buf;
 } EncRefCntBuffer;
 
+#if CONFIG_ENTROPY
+typedef struct SUBFRAME_STATS {
+  vp10_coeff_probs_model
+  coef_probs_buf[COEF_PROBS_BUFS][TX_SIZES][PLANE_TYPES];
+  vp10_coeff_count
+  coef_counts_buf[COEF_PROBS_BUFS][TX_SIZES][PLANE_TYPES];
+  unsigned int
+  eob_counts_buf[COEF_PROBS_BUFS]
+                [TX_SIZES][PLANE_TYPES][REF_TYPES][COEF_BANDS][COEFF_CONTEXTS];
+  vp10_coeff_probs_model enc_starting_coef_probs[TX_SIZES][PLANE_TYPES];
+} SUBFRAME_STATS;
+#endif  // CONFIG_ENTROPY
+
 typedef struct VP10_COMP {
   QUANTS quants;
   ThreadData td;
@@ -555,6 +568,9 @@
   VPxWorker *workers;
   struct EncWorkerData *tile_thr_data;
   VP9LfSync lf_row_sync;
+#if CONFIG_ENTROPY
+  SUBFRAME_STATS subframe_stats;
+#endif  // CONFIG_ENTROPY
 } VP10_COMP;
 
 void vp10_initialize_enc(void);
@@ -602,6 +618,11 @@
 
 int vp10_get_quantizer(struct VP10_COMP *cpi);
 
+#if CONFIG_ENTROPY
+void full_to_model_counts(vp10_coeff_count_model *model_count,
+                          vp10_coeff_count *full_count);
+#endif  // CONFIG_ENTROPY
+
 static INLINE int frame_is_kf_gf_arf(const VP10_COMP *cpi) {
   return frame_is_intra_only(&cpi->common) ||
          cpi->refresh_alt_ref_frame ||
diff --git a/vp10/encoder/rd.c b/vp10/encoder/rd.c
index 7097dc1..c2f148d 100644
--- a/vp10/encoder/rd.c
+++ b/vp10/encoder/rd.c
@@ -149,8 +149,13 @@
 #endif  // CONFIG_EXT_INTRA
 }
 
+#if CONFIG_ENTROPY
+void fill_token_costs(vp10_coeff_cost *c,
+                      vp10_coeff_probs_model (*p)[PLANE_TYPES]) {
+#else
 static void fill_token_costs(vp10_coeff_cost *c,
                              vp10_coeff_probs_model (*p)[PLANE_TYPES]) {
+#endif  // CONFIG_ENTROPY
   int i, j, k, l;
   TX_SIZE t;
   for (t = TX_4X4; t <= TX_32X32; ++t)
diff --git a/vp10/encoder/rd.h b/vp10/encoder/rd.h
index 61feabe..675b9db 100644
--- a/vp10/encoder/rd.h
+++ b/vp10/encoder/rd.h
@@ -340,6 +340,11 @@
 void vp10_update_rd_thresh_fact(int (*fact)[MAX_MODES], int rd_thresh,
                                int bsize, int best_mode_index);
 
+#if CONFIG_ENTROPY
+void fill_token_costs(vp10_coeff_cost *c,
+                      vp10_coeff_probs_model (*p)[PLANE_TYPES]);
+#endif  // CONFIG_ENTROPY
+
 static INLINE int rd_less_than_thresh(int64_t best_rd, int thresh,
                                       int thresh_fact) {
     return best_rd < ((int64_t)thresh * thresh_fact >> 5) || thresh == INT_MAX;
diff --git a/vp10/encoder/subexp.c b/vp10/encoder/subexp.c
index 9ddec2d..d944d01 100644
--- a/vp10/encoder/subexp.c
+++ b/vp10/encoder/subexp.c
@@ -180,6 +180,88 @@
   return bestsavings;
 }
 
+#if CONFIG_ENTROPY
+static int get_cost(unsigned int ct[][2], vpx_prob p, int n) {
+  int i, p0 = p;
+  unsigned int total_ct[2] = {0 , 0};
+  int cost = 0;
+
+  for (i = 0; i <= n; ++i) {
+    cost += cost_branch256(ct[i], p);
+    total_ct[0] += ct[i][0];
+    total_ct[1] += ct[i][1];
+    if (i < n)
+      p = merge_probs(p0, total_ct, 24, 112);
+  }
+
+  return cost;
+}
+
+int vp10_prob_update_search_subframe(unsigned int ct[][2],
+                                     vpx_prob oldp, vpx_prob *bestp,
+                                     vpx_prob upd, int n) {
+  const int old_b = get_cost(ct, oldp, n);
+  int bestsavings = 0;
+  vpx_prob newp, bestnewp = oldp;
+  const int step = *bestp > oldp ? -1 : 1;
+
+  for (newp = *bestp; newp != oldp; newp += step) {
+    const int new_b = get_cost(ct, newp, n);
+    const int update_b = prob_diff_update_cost(newp, oldp) + vp10_cost_upd256;
+    const int savings = old_b - new_b - update_b;
+    if (savings > bestsavings) {
+      bestsavings = savings;
+      bestnewp = newp;
+    }
+  }
+  *bestp = bestnewp;
+  return bestsavings;
+}
+
+int vp10_prob_update_search_model_subframe(unsigned int ct[ENTROPY_NODES]
+                                                          [COEF_PROBS_BUFS][2],
+                                           const vpx_prob *oldp,
+                                           vpx_prob *bestp, vpx_prob upd,
+                                           int stepsize, int n) {
+  int i, old_b, new_b, update_b, savings, bestsavings;
+  int newp;
+  const int step_sign = *bestp > oldp[PIVOT_NODE] ? -1 : 1;
+  const int step = stepsize * step_sign;
+  vpx_prob bestnewp, newplist[ENTROPY_NODES], oldplist[ENTROPY_NODES];
+  vp10_model_to_full_probs(oldp, oldplist);
+  memcpy(newplist, oldp, sizeof(vpx_prob) * UNCONSTRAINED_NODES);
+  for (i = UNCONSTRAINED_NODES, old_b = 0; i < ENTROPY_NODES; ++i)
+    old_b += get_cost(ct[i], oldplist[i], n);
+  old_b += get_cost(ct[PIVOT_NODE], oldplist[PIVOT_NODE], n);
+
+  bestsavings = 0;
+  bestnewp = oldp[PIVOT_NODE];
+
+  assert(stepsize > 0);
+
+  for (newp = *bestp; (newp - oldp[PIVOT_NODE]) * step_sign < 0;
+      newp += step) {
+    if (newp < 1 || newp > 255)
+      continue;
+    newplist[PIVOT_NODE] = newp;
+    vp10_model_to_full_probs(newplist, newplist);
+    for (i = UNCONSTRAINED_NODES, new_b = 0; i < ENTROPY_NODES; ++i)
+      new_b += get_cost(ct[i], newplist[i], n);
+    new_b += get_cost(ct[PIVOT_NODE], newplist[PIVOT_NODE], n);
+    update_b = prob_diff_update_cost(newp, oldp[PIVOT_NODE]) +
+        vp10_cost_upd256;
+    savings = old_b - new_b - update_b;
+    if (savings > bestsavings) {
+      bestsavings = savings;
+      bestnewp = newp;
+    }
+  }
+
+  *bestp = bestnewp;
+  return bestsavings;
+}
+#endif  // CONFIG_ENTROPY
+
 void vp10_cond_prob_diff_update(vpx_writer *w, vpx_prob *oldp,
                                const unsigned int ct[2]) {
   const vpx_prob upd = DIFF_UPDATE_PROB;
diff --git a/vp10/encoder/subexp.h b/vp10/encoder/subexp.h
index 64eb275..0f9227c 100644
--- a/vp10/encoder/subexp.h
+++ b/vp10/encoder/subexp.h
@@ -38,6 +38,18 @@
                                               int stepsize);
 int vp10_cond_prob_diff_update_savings(vpx_prob *oldp,
                                        const unsigned int ct[2]);
+
+#if CONFIG_ENTROPY
+int vp10_prob_update_search_subframe(unsigned int ct[][2],
+                                     vpx_prob oldp, vpx_prob *bestp,
+                                     vpx_prob upd, int n);
+int vp10_prob_update_search_model_subframe(unsigned int ct[ENTROPY_NODES]
+                                                          [COEF_PROBS_BUFS][2],
+                                           const vpx_prob *oldp,
+                                           vpx_prob *bestp, vpx_prob upd,
+                                           int stepsize, int n);
+#endif  // CONFIG_ENTROPY
+
 #ifdef __cplusplus
 }  // extern "C"
 #endif
diff --git a/vp10/encoder/tokenize.c b/vp10/encoder/tokenize.c
index 822ccc9..2398a53 100644
--- a/vp10/encoder/tokenize.c
+++ b/vp10/encoder/tokenize.c
@@ -455,8 +455,14 @@
   const int ref = is_inter_block(mbmi);
   unsigned int (*const counts)[COEFF_CONTEXTS][ENTROPY_TOKENS] =
       td->rd_counts.coef_counts[tx_size][type][ref];
+#if CONFIG_ENTROPY
+  vpx_prob (*coef_probs)[COEFF_CONTEXTS][UNCONSTRAINED_NODES] =
+      cpi->subframe_stats.coef_probs_buf[cpi->common.coef_probs_update_idx]
+                                        [tx_size][type][ref];
+#else
   vpx_prob (*const coef_probs)[COEFF_CONTEXTS][UNCONSTRAINED_NODES] =
       cpi->common.fc->coef_probs[tx_size][type][ref];
+#endif  // CONFIG_ENTROPY
   unsigned int (*const eob_branch)[COEFF_CONTEXTS] =
       td->counts->eob_branch[tx_size][type][ref];
   const uint8_t *const band = get_band_translate(tx_size);