Commit 5d011cb2 authored by hui su's avatar hui su

VP10: Add palette mode part 1

Add palette mode for keyframe luma channel. Palette mode is enabled
when using "--tune-content=screen" in encoding config parameters.

on screen_content testset:  +6.89%
on derlr                 :  +0.00%

Design doc (WIP):
https://goo.gl/lD4yJw

Change-Id: Ib368b216bfd3ea21c6c27436934ad87afdaa6f88
parent ba7ea445
......@@ -63,6 +63,20 @@ typedef struct {
#define MAX_REF_FRAMES 4
typedef int8_t MV_REFERENCE_FRAME;
typedef struct {
// Number of base colors for Y (0) and UV (1)
uint8_t palette_size[2];
// Value of base colors for Y, U, and V
#if CONFIG_VP9_HIGHBITDEPTH
uint16_t palette_colors[3 * PALETTE_MAX_SIZE];
#else
uint8_t palette_colors[3 * PALETTE_MAX_SIZE];
#endif // CONFIG_VP9_HIGHBITDEPTH
// Only used by encoder to store the color index of the top left pixel.
// TODO(huisu): move this to encoder
uint8_t palette_first_color_idx[2];
} PALETTE_MODE_INFO;
// This structure now relates to 8x8 block regions.
typedef struct {
// Common for both INTER and INTRA blocks
......@@ -78,6 +92,7 @@ typedef struct {
// Only for INTRA blocks
PREDICTION_MODE uv_mode;
PALETTE_MODE_INFO palette_mode_info;
// Only for INTER blocks
INTERP_FILTER interp_filter;
......@@ -131,6 +146,7 @@ struct macroblockd_plane {
ENTROPY_CONTEXT *above_context;
ENTROPY_CONTEXT *left_context;
int16_t seg_dequant[MAX_SEGMENTS][2];
uint8_t *color_index_map;
// number of 4x4s in current block
uint16_t n4_w, n4_h;
......
......@@ -275,6 +275,438 @@ static const struct tx_probs default_tx_probs = {
{ 66 } }
};
const vpx_tree_index vp10_palette_size_tree[TREE_SIZE(PALETTE_SIZES)] = {
-TWO_COLORS, 2,
-THREE_COLORS, 4,
-FOUR_COLORS, 6,
-FIVE_COLORS, 8,
-SIX_COLORS, 10,
-SEVEN_COLORS, -EIGHT_COLORS,
};
// TODO(huisu): tune these probs
const vpx_prob vp10_default_palette_y_size_prob[10][PALETTE_SIZES - 1] = {
{ 96, 89, 100, 64, 77, 130},
{ 22, 15, 44, 16, 34, 82},
{ 30, 19, 57, 18, 38, 86},
{ 94, 36, 104, 23, 43, 92},
{ 116, 76, 107, 46, 65, 105},
{ 112, 82, 94, 40, 70, 112},
{ 147, 124, 123, 58, 69, 103},
{ 180, 113, 136, 49, 45, 114},
{ 107, 70, 87, 49, 154, 156},
{ 98, 105, 142, 63, 64, 152},
};
const vpx_prob vp10_default_palette_uv_size_prob[10][PALETTE_SIZES - 1] = {
{ 160, 196, 228, 213, 175, 230},
{ 87, 148, 208, 141, 166, 163},
{ 72, 151, 204, 139, 155, 161},
{ 78, 135, 171, 104, 120, 173},
{ 59, 92, 131, 78, 92, 142},
{ 75, 118, 149, 84, 90, 128},
{ 89, 87, 92, 66, 66, 128},
{ 67, 53, 54, 55, 66, 93},
{ 120, 130, 83, 171, 75, 214},
{ 72, 55, 66, 68, 79, 107},
};
const vpx_prob vp10_default_palette_y_mode_prob[10][3] = {
{ 240, 180, 100, },
{ 240, 180, 100, },
{ 240, 180, 100, },
{ 240, 180, 100, },
{ 240, 180, 100, },
{ 240, 180, 100, },
{ 240, 180, 100, },
{ 240, 180, 100, },
{ 240, 180, 100, },
{ 240, 180, 100, },
};
const vpx_prob default_uv_palette_mode_prob[2] = {
253, 229
};
const vpx_tree_index
vp10_palette_color_tree[PALETTE_MAX_SIZE - 1][TREE_SIZE(PALETTE_COLORS)] = {
{ // 2 colors
-PALETTE_COLOR_ONE, -PALETTE_COLOR_TWO,
},
{ // 3 colors
-PALETTE_COLOR_ONE, 2,
-PALETTE_COLOR_TWO, -PALETTE_COLOR_THREE,
},
{ // 4 colors
-PALETTE_COLOR_ONE, 2,
-PALETTE_COLOR_TWO, 4,
-PALETTE_COLOR_THREE, -PALETTE_COLOR_FOUR,
},
{ // 5 colors
-PALETTE_COLOR_ONE, 2,
-PALETTE_COLOR_TWO, 4,
-PALETTE_COLOR_THREE, 6,
-PALETTE_COLOR_FOUR, -PALETTE_COLOR_FIVE,
},
{ // 6 colors
-PALETTE_COLOR_ONE, 2,
-PALETTE_COLOR_TWO, 4,
-PALETTE_COLOR_THREE, 6,
-PALETTE_COLOR_FOUR, 8,
-PALETTE_COLOR_FIVE, -PALETTE_COLOR_SIX,
},
{ // 7 colors
-PALETTE_COLOR_ONE, 2,
-PALETTE_COLOR_TWO, 4,
-PALETTE_COLOR_THREE, 6,
-PALETTE_COLOR_FOUR, 8,
-PALETTE_COLOR_FIVE, 10,
-PALETTE_COLOR_SIX, -PALETTE_COLOR_SEVEN,
},
{ // 8 colors
-PALETTE_COLOR_ONE, 2,
-PALETTE_COLOR_TWO, 4,
-PALETTE_COLOR_THREE, 6,
-PALETTE_COLOR_FOUR, 8,
-PALETTE_COLOR_FIVE, 10,
-PALETTE_COLOR_SIX, 12,
-PALETTE_COLOR_SEVEN, -PALETTE_COLOR_EIGHT,
},
};
const vpx_prob vp10_default_palette_y_color_prob
[PALETTE_MAX_SIZE - 1][PALETTE_COLOR_CONTEXTS][PALETTE_COLORS - 1] = {
{ // 2 colors
{ 230, 255, 128, 128, 128, 128, 128 },
{ 214, 255, 128, 128, 128, 128, 128 },
{ 128, 128, 128, 128, 128, 128, 128 },
{ 128, 128, 128, 128, 128, 128, 128 },
{ 128, 128, 128, 128, 128, 128, 128 },
{ 240, 255, 128, 128, 128, 128, 128 },
{ 73, 255, 128, 128, 128, 128, 128 },
{ 128, 128, 128, 128, 128, 128, 128 },
{ 130, 255, 128, 128, 128, 128, 128 },
{ 227, 255, 128, 128, 128, 128, 128 },
{ 128, 128, 128, 128, 128, 128, 128 },
{ 188, 255, 128, 128, 128, 128, 128 },
{ 75, 255, 128, 128, 128, 128, 128 },
{ 250, 255, 128, 128, 128, 128, 128 },
{ 223, 255, 128, 128, 128, 128, 128 },
{ 252, 255, 128, 128, 128, 128, 128 },
}, { // 3 colors
{ 229, 137, 255, 128, 128, 128, 128 },
{ 197, 120, 255, 128, 128, 128, 128 },
{ 107, 195, 255, 128, 128, 128, 128 },
{ 128, 128, 128, 128, 128, 128, 128 },
{ 27, 151, 255, 128, 128, 128, 128 },
{ 230, 130, 255, 128, 128, 128, 128 },
{ 37, 230, 255, 128, 128, 128, 128 },
{ 67, 221, 255, 128, 128, 128, 128 },
{ 124, 230, 255, 128, 128, 128, 128 },
{ 195, 109, 255, 128, 128, 128, 128 },
{ 99, 122, 255, 128, 128, 128, 128 },
{ 205, 208, 255, 128, 128, 128, 128 },
{ 40, 235, 255, 128, 128, 128, 128 },
{ 251, 132, 255, 128, 128, 128, 128 },
{ 237, 186, 255, 128, 128, 128, 128 },
{ 253, 112, 255, 128, 128, 128, 128 },
}, { // 4 colors
{ 195, 87, 128, 255, 128, 128, 128 },
{ 143, 100, 123, 255, 128, 128, 128 },
{ 94, 124, 119, 255, 128, 128, 128 },
{ 77, 91, 130, 255, 128, 128, 128 },
{ 39, 114, 178, 255, 128, 128, 128 },
{ 222, 94, 125, 255, 128, 128, 128 },
{ 44, 203, 132, 255, 128, 128, 128 },
{ 68, 175, 122, 255, 128, 128, 128 },
{ 110, 187, 124, 255, 128, 128, 128 },
{ 152, 91, 128, 255, 128, 128, 128 },
{ 70, 109, 181, 255, 128, 128, 128 },
{ 133, 113, 164, 255, 128, 128, 128 },
{ 47, 205, 133, 255, 128, 128, 128 },
{ 247, 94, 136, 255, 128, 128, 128 },
{ 205, 122, 146, 255, 128, 128, 128 },
{ 251, 100, 141, 255, 128, 128, 128 },
}, { // 5 colors
{ 195, 65, 84, 125, 255, 128, 128 },
{ 150, 76, 84, 121, 255, 128, 128 },
{ 94, 110, 81, 117, 255, 128, 128 },
{ 79, 85, 91, 139, 255, 128, 128 },
{ 26, 102, 139, 127, 255, 128, 128 },
{ 220, 73, 91, 119, 255, 128, 128 },
{ 38, 203, 86, 127, 255, 128, 128 },
{ 61, 186, 72, 124, 255, 128, 128 },
{ 132, 199, 84, 128, 255, 128, 128 },
{ 172, 52, 62, 120, 255, 128, 128 },
{ 102, 89, 121, 122, 255, 128, 128 },
{ 182, 48, 69, 186, 255, 128, 128 },
{ 36, 206, 87, 126, 255, 128, 128 },
{ 249, 55, 67, 122, 255, 128, 128 },
{ 218, 88, 75, 122, 255, 128, 128 },
{ 253, 64, 80, 119, 255, 128, 128 },
}, { // 6 colors
{ 182, 54, 64, 75, 118, 255, 128 },
{ 126, 67, 70, 76, 116, 255, 128 },
{ 79, 92, 67, 85, 120, 255, 128 },
{ 63, 61, 81, 118, 132, 255, 128 },
{ 21, 80, 105, 83, 119, 255, 128 },
{ 215, 72, 74, 74, 111, 255, 128 },
{ 50, 176, 63, 79, 120, 255, 128 },
{ 72, 148, 66, 77, 120, 255, 128 },
{ 105, 177, 57, 78, 130, 255, 128 },
{ 150, 66, 66, 80, 127, 255, 128 },
{ 81, 76, 109, 85, 116, 255, 128 },
{ 113, 81, 62, 96, 148, 255, 128 },
{ 54, 179, 69, 82, 121, 255, 128 },
{ 244, 47, 48, 67, 118, 255, 128 },
{ 198, 83, 53, 65, 121, 255, 128 },
{ 250, 42, 51, 69, 110, 255, 128 },
}, { // 7 colors
{ 182, 45, 54, 62, 74, 113, 255 },
{ 124, 63, 57, 62, 77, 114, 255 },
{ 77, 80, 56, 66, 76, 117, 255 },
{ 63, 57, 69, 98, 85, 131, 255 },
{ 19, 81, 98, 63, 80, 116, 255 },
{ 215, 56, 60, 63, 68, 105, 255 },
{ 50, 174, 50, 60, 79, 118, 255 },
{ 68, 151, 50, 58, 73, 117, 255 },
{ 104, 182, 53, 57, 79, 127, 255 },
{ 156, 50, 51, 63, 77, 111, 255 },
{ 88, 67, 97, 59, 82, 120, 255 },
{ 114, 81, 46, 65, 103, 132, 255 },
{ 55, 166, 57, 66, 82, 120, 255 },
{ 245, 34, 38, 43, 63, 114, 255 },
{ 203, 68, 45, 47, 60, 118, 255 },
{ 250, 35, 37, 47, 66, 110, 255 },
}, { // 8 colors
{ 180, 43, 46, 50, 56, 69, 109 },
{ 116, 53, 51, 49, 57, 73, 115 },
{ 79, 70, 49, 50, 59, 74, 117 },
{ 60, 54, 57, 70, 62, 83, 129 },
{ 20, 73, 85, 52, 66, 81, 119 },
{ 213, 56, 52, 49, 53, 62, 104 },
{ 48, 161, 41, 45, 56, 77, 116 },
{ 68, 139, 40, 47, 54, 71, 116 },
{ 123, 166, 42, 43, 52, 76, 130 },
{ 153, 44, 44, 47, 54, 79, 129 },
{ 87, 64, 83, 49, 60, 75, 127 },
{ 131, 68, 43, 48, 73, 96, 130 },
{ 55, 152, 45, 51, 64, 77, 113 },
{ 243, 30, 28, 33, 41, 65, 114 },
{ 202, 56, 35, 36, 42, 63, 123 },
{ 249, 31, 29, 32, 45, 68, 111 },
}
};
const vpx_prob vp10_default_palette_uv_color_prob
[PALETTE_MAX_SIZE - 1][PALETTE_COLOR_CONTEXTS][PALETTE_COLORS - 1] = {
{ // 2 colors
{ 228, 255, 128, 128, 128, 128, 128 },
{ 195, 255, 128, 128, 128, 128, 128 },
{ 128, 128, 128, 128, 128, 128, 128 },
{ 128, 128, 128, 128, 128, 128, 128 },
{ 128, 128, 128, 128, 128, 128, 128 },
{ 228, 255, 128, 128, 128, 128, 128 },
{ 71, 255, 128, 128, 128, 128, 128 },
{ 128, 128, 128, 128, 128, 128, 128 },
{ 129, 255, 128, 128, 128, 128, 128 },
{ 206, 255, 128, 128, 128, 128, 128 },
{ 128, 128, 128, 128, 128, 128, 128 },
{ 136, 255, 128, 128, 128, 128, 128 },
{ 98, 255, 128, 128, 128, 128, 128 },
{ 236, 255, 128, 128, 128, 128, 128 },
{ 222, 255, 128, 128, 128, 128, 128 },
{ 249, 255, 128, 128, 128, 128, 128 },
}, { // 3 colors
{ 198, 136, 255, 128, 128, 128, 128 },
{ 178, 105, 255, 128, 128, 128, 128 },
{ 100, 206, 255, 128, 128, 128, 128 },
{ 128, 128, 128, 128, 128, 128, 128 },
{ 12, 136, 255, 128, 128, 128, 128 },
{ 219, 134, 255, 128, 128, 128, 128 },
{ 50, 198, 255, 128, 128, 128, 128 },
{ 61, 231, 255, 128, 128, 128, 128 },
{ 110, 209, 255, 128, 128, 128, 128 },
{ 173, 106, 255, 128, 128, 128, 128 },
{ 145, 166, 255, 128, 128, 128, 128 },
{ 156, 175, 255, 128, 128, 128, 128 },
{ 69, 183, 255, 128, 128, 128, 128 },
{ 241, 163, 255, 128, 128, 128, 128 },
{ 224, 160, 255, 128, 128, 128, 128 },
{ 246, 154, 255, 128, 128, 128, 128 },
}, { // 4 colors
{ 173, 88, 143, 255, 128, 128, 128 },
{ 146, 81, 127, 255, 128, 128, 128 },
{ 84, 134, 102, 255, 128, 128, 128 },
{ 69, 138, 140, 255, 128, 128, 128 },
{ 31, 103, 200, 255, 128, 128, 128 },
{ 217, 101, 139, 255, 128, 128, 128 },
{ 51, 174, 121, 255, 128, 128, 128 },
{ 64, 177, 109, 255, 128, 128, 128 },
{ 96, 179, 145, 255, 128, 128, 128 },
{ 164, 77, 114, 255, 128, 128, 128 },
{ 87, 94, 156, 255, 128, 128, 128 },
{ 105, 57, 173, 255, 128, 128, 128 },
{ 63, 158, 137, 255, 128, 128, 128 },
{ 236, 102, 156, 255, 128, 128, 128 },
{ 197, 115, 153, 255, 128, 128, 128 },
{ 245, 106, 154, 255, 128, 128, 128 },
}, { // 5 colors
{ 179, 64, 97, 129, 255, 128, 128 },
{ 137, 56, 88, 125, 255, 128, 128 },
{ 82, 107, 61, 118, 255, 128, 128 },
{ 59, 113, 86, 115, 255, 128, 128 },
{ 23, 88, 118, 130, 255, 128, 128 },
{ 213, 66, 90, 125, 255, 128, 128 },
{ 37, 181, 103, 121, 255, 128, 128 },
{ 47, 188, 61, 131, 255, 128, 128 },
{ 104, 185, 103, 144, 255, 128, 128 },
{ 163, 39, 76, 112, 255, 128, 128 },
{ 94, 74, 131, 126, 255, 128, 128 },
{ 142, 42, 103, 163, 255, 128, 128 },
{ 53, 162, 99, 149, 255, 128, 128 },
{ 239, 54, 84, 108, 255, 128, 128 },
{ 203, 84, 110, 147, 255, 128, 128 },
{ 248, 70, 105, 151, 255, 128, 128 },
}, { // 6 colors
{ 189, 50, 67, 90, 130, 255, 128 },
{ 114, 50, 55, 90, 123, 255, 128 },
{ 66, 76, 54, 82, 128, 255, 128 },
{ 43, 69, 69, 80, 129, 255, 128 },
{ 22, 59, 87, 88, 141, 255, 128 },
{ 203, 49, 68, 87, 122, 255, 128 },
{ 43, 157, 74, 104, 146, 255, 128 },
{ 54, 138, 51, 95, 138, 255, 128 },
{ 82, 171, 58, 102, 146, 255, 128 },
{ 129, 38, 59, 64, 168, 255, 128 },
{ 56, 67, 119, 92, 112, 255, 128 },
{ 96, 62, 53, 132, 82, 255, 128 },
{ 60, 147, 77, 108, 145, 255, 128 },
{ 238, 76, 73, 93, 148, 255, 128 },
{ 189, 86, 73, 103, 157, 255, 128 },
{ 246, 62, 75, 83, 167, 255, 128 },
}, { // 7 colors
{ 179, 42, 51, 73, 99, 134, 255 },
{ 119, 52, 52, 61, 64, 114, 255 },
{ 53, 77, 35, 65, 71, 131, 255 },
{ 38, 70, 51, 68, 89, 144, 255 },
{ 23, 65, 128, 73, 97, 131, 255 },
{ 210, 47, 52, 63, 81, 143, 255 },
{ 42, 159, 57, 68, 98, 143, 255 },
{ 49, 153, 45, 82, 93, 143, 255 },
{ 81, 169, 52, 72, 113, 151, 255 },
{ 136, 46, 35, 56, 75, 96, 255 },
{ 57, 84, 109, 47, 107, 131, 255 },
{ 128, 78, 57, 36, 128, 85, 255 },
{ 54, 149, 68, 77, 94, 153, 255 },
{ 243, 58, 50, 71, 81, 167, 255 },
{ 189, 92, 64, 70, 121, 173, 255 },
{ 248, 35, 38, 51, 82, 201, 255 },
}, { // 8 colors
{ 201, 40, 36, 42, 64, 92, 123 },
{ 116, 43, 33, 43, 73, 102, 128 },
{ 46, 77, 37, 69, 62, 78, 150 },
{ 40, 65, 52, 50, 76, 89, 133 },
{ 28, 48, 91, 17, 64, 77, 133 },
{ 218, 43, 43, 37, 56, 72, 163 },
{ 41, 155, 44, 83, 82, 129, 180 },
{ 44, 141, 29, 55, 64, 89, 147 },
{ 92, 166, 48, 45, 59, 126, 179 },
{ 169, 35, 49, 41, 36, 99, 139 },
{ 55, 77, 77, 56, 60, 75, 156 },
{ 155, 81, 51, 64, 57, 182, 255 },
{ 60, 134, 49, 49, 93, 128, 174 },
{ 244, 98, 51, 46, 22, 73, 238 },
{ 189, 70, 40, 87, 93, 79, 201 },
{ 248, 54, 49, 40, 29, 42, 227 },
}
};
static const int palette_color_context_lookup[PALETTE_COLOR_CONTEXTS] = {
// (3, 0, 0, 0), (3, 2, 0, 0), (3, 3, 2, 0), (3, 3, 2, 2),
3993, 4235, 4378, 4380,
// (4, 3, 3, 0), (5, 0, 0, 0), (5, 3, 0, 0), (5, 3, 2, 0),
5720, 6655, 7018, 7040,
// (5, 5, 0, 0), (6, 2, 0, 0), (6, 2, 2, 0), (6, 4, 0, 0),
7260, 8228, 8250, 8470,
// (7, 3, 0, 0), (8, 0, 0, 0), (8, 2, 0, 0), (10, 0, 0, 0)
9680, 10648, 10890, 13310
};
int vp10_get_palette_color_context(const uint8_t *color_map, int cols,
int r, int c, int n, int *color_order) {
int i, j, max, max_idx, temp;
int scores[PALETTE_MAX_SIZE + 10];
int weights[4] = {3, 2, 3, 2};
int color_ctx = 0;
int color_neighbors[4];
assert(n <= PALETTE_MAX_SIZE);
if (c - 1 >= 0)
color_neighbors[0] = color_map[r * cols + c - 1];
else
color_neighbors[0] = -1;
if (c - 1 >= 0 && r - 1 >= 0)
color_neighbors[1] = color_map[(r - 1) * cols + c - 1];
else
color_neighbors[1] = -1;
if (r - 1 >= 0)
color_neighbors[2] = color_map[(r - 1) * cols + c];
else
color_neighbors[2] = -1;
if (r - 1 >= 0 && c + 1 <= cols - 1)
color_neighbors[3] = color_map[(r - 1) * cols + c + 1];
else
color_neighbors[3] = -1;
for (i = 0; i < PALETTE_MAX_SIZE; ++i)
color_order[i] = i;
memset(scores, 0, PALETTE_MAX_SIZE * sizeof(scores[0]));
for (i = 0; i < 4; ++i) {
if (color_neighbors[i] >= 0)
scores[color_neighbors[i]] += weights[i];
}
for (i = 0; i < 4; ++i) {
max = scores[i];
max_idx = i;
j = i + 1;
while (j < n) {
if (scores[j] > max) {
max = scores[j];
max_idx = j;
}
++j;
}
if (max_idx != i) {
temp = scores[i];
scores[i] = scores[max_idx];
scores[max_idx] = temp;
temp = color_order[i];
color_order[i] = color_order[max_idx];
color_order[max_idx] = temp;
}
}
for (i = 0; i < 4; ++i)
color_ctx = color_ctx * 11 + scores[i];
for (i = 0; i < PALETTE_COLOR_CONTEXTS; ++i)
if (color_ctx == palette_color_context_lookup[i]) {
color_ctx = i;
break;
}
if (color_ctx >= PALETTE_COLOR_CONTEXTS)
color_ctx = 0;
return color_ctx;
}
void vp10_tx_counts_to_branch_counts_32x32(const unsigned int *tx_count_32x32p,
unsigned int (*ct_32x32p)[2]) {
ct_32x32p[0][0] = tx_count_32x32p[TX_4X4];
......
......@@ -26,6 +26,12 @@ extern "C" {
#define INTER_OFFSET(mode) ((mode) - NEARESTMV)
#define PALETTE_COLOR_CONTEXTS 16
#define PALETTE_MAX_SIZE 8
#define PALETTE_BLOCK_SIZES (BLOCK_64X64 - BLOCK_8X8 + 1)
#define PALETTE_Y_MODE_CONTEXTS 3
struct VP10Common;
struct tx_probs {
......@@ -83,11 +89,26 @@ extern const vpx_prob vp10_kf_y_mode_prob[INTRA_MODES][INTRA_MODES]
[INTRA_MODES - 1];
extern const vpx_prob vp10_kf_partition_probs[PARTITION_CONTEXTS]
[PARTITION_TYPES - 1];
extern const vpx_prob
vp10_default_palette_y_mode_prob[PALETTE_BLOCK_SIZES][PALETTE_Y_MODE_CONTEXTS];
extern const vpx_prob
vp10_default_palette_y_size_prob[PALETTE_BLOCK_SIZES][PALETTE_SIZES - 1];
extern const vpx_prob
vp10_default_palette_uv_size_prob[PALETTE_BLOCK_SIZES][PALETTE_SIZES - 1];
extern const vpx_prob vp10_default_palette_y_color_prob
[PALETTE_MAX_SIZE - 1][PALETTE_COLOR_CONTEXTS][PALETTE_COLORS - 1];
extern const vpx_prob vp10_default_palette_uv_color_prob
[PALETTE_MAX_SIZE - 1][PALETTE_COLOR_CONTEXTS][PALETTE_COLORS - 1];
extern const vpx_tree_index vp10_intra_mode_tree[TREE_SIZE(INTRA_MODES)];
extern const vpx_tree_index vp10_inter_mode_tree[TREE_SIZE(INTER_MODES)];
extern const vpx_tree_index vp10_partition_tree[TREE_SIZE(PARTITION_TYPES)];
extern const vpx_tree_index vp10_switchable_interp_tree
[TREE_SIZE(SWITCHABLE_FILTERS)];
extern const vpx_tree_index vp10_palette_size_tree[TREE_SIZE(PALETTE_SIZES)];
extern const vpx_tree_index
vp10_palette_color_tree[PALETTE_MAX_SIZE - 1][TREE_SIZE(PALETTE_COLORS)];
void vp10_setup_past_independence(struct VP10Common *cm);
......@@ -100,6 +121,18 @@ void vp10_tx_counts_to_branch_counts_16x16(const unsigned int *tx_count_16x16p,
void vp10_tx_counts_to_branch_counts_8x8(const unsigned int *tx_count_8x8p,
unsigned int (*ct_8x8p)[2]);
static INLINE int vp10_ceil_log2(int n) {
int i = 1, p = 2;
while (p < n) {
i++;
p = p << 1;
}
return i;
}
int vp10_get_palette_color_context(const uint8_t *color_map, int cols,
int r, int c, int n, int *color_order);
#ifdef __cplusplus
} // extern "C"
#endif
......
......@@ -109,6 +109,29 @@ typedef enum {
PLANE_TYPES
} PLANE_TYPE;
typedef enum {
TWO_COLORS,
THREE_COLORS,
FOUR_COLORS,
FIVE_COLORS,
SIX_COLORS,
SEVEN_COLORS,
EIGHT_COLORS,
PALETTE_SIZES
} PALETTE_SIZE;
typedef enum {
PALETTE_COLOR_ONE,
PALETTE_COLOR_TWO,
PALETTE_COLOR_THREE,
PALETTE_COLOR_FOUR,
PALETTE_COLOR_FIVE,
PALETTE_COLOR_SIX,
PALETTE_COLOR_SEVEN,
PALETTE_COLOR_EIGHT,
PALETTE_COLORS
} PALETTE_COLOR;
#define DC_PRED 0 // Average of above and left pixels
#define V_PRED 1 // Vertical
#define H_PRED 2 // Horizontal
......
......@@ -185,6 +185,8 @@ typedef struct VP10Common {
int allow_high_precision_mv;
int allow_screen_content_tools;
// Flag signaling which frame contexts should be reset to default values.
RESET_FRAME_CONTEXT_MODE reset_frame_context;
......
......@@ -397,6 +397,40 @@ void vp10_predict_intra_block(const MACROBLOCKD *xd, int bwl_in,
const int x = aoff * 4;
const int y = loff * 4;
if (xd->mi[0]->mbmi.palette_mode_info.palette_size[plane != 0] > 0) {
const int bs = 4 * (1 << tx_size);
const int stride = 4 * (1 << bwl_in);
int r, c;
uint8_t *map = NULL;
#if CONFIG_VP9_HIGHBITDEPTH
uint16_t *palette = xd->mi[0]->mbmi.palette_mode_info.palette_colors +
plane * PALETTE_MAX_SIZE;
#else
uint8_t *palette = xd->mi[0]->mbmi.palette_mode_info.palette_colors +
plane * PALETTE_MAX_SIZE;