Commit f0e0a7e7 authored by Hui Su's avatar Hui Su Committed by Gerrit Code Review

Merge "Complete (mostly) migration of palette mode" into nextgenv2

parents 571072b8 78b0bd0a
...@@ -383,7 +383,7 @@ vp10_default_palette_y_mode_prob[PALETTE_BLOCK_SIZES][PALETTE_Y_MODE_CONTEXTS] ...@@ -383,7 +383,7 @@ vp10_default_palette_y_mode_prob[PALETTE_BLOCK_SIZES][PALETTE_Y_MODE_CONTEXTS]
}; };
const vpx_prob default_uv_palette_mode_prob[2] = { const vpx_prob vp10_default_palette_uv_mode_prob[2] = {
253, 229 253, 229
}; };
......
...@@ -176,6 +176,7 @@ extern const vpx_prob vp10_kf_y_mode_prob[INTRA_MODES][INTRA_MODES] ...@@ -176,6 +176,7 @@ extern const vpx_prob vp10_kf_y_mode_prob[INTRA_MODES][INTRA_MODES]
[INTRA_MODES - 1]; [INTRA_MODES - 1];
extern const vpx_prob extern const vpx_prob
vp10_default_palette_y_mode_prob[PALETTE_BLOCK_SIZES][PALETTE_Y_MODE_CONTEXTS]; vp10_default_palette_y_mode_prob[PALETTE_BLOCK_SIZES][PALETTE_Y_MODE_CONTEXTS];
extern const vpx_prob vp10_default_palette_uv_mode_prob[2];
extern const vpx_prob extern const vpx_prob
vp10_default_palette_y_size_prob[PALETTE_BLOCK_SIZES][PALETTE_SIZES - 1]; vp10_default_palette_y_size_prob[PALETTE_BLOCK_SIZES][PALETTE_SIZES - 1];
extern const vpx_prob extern const vpx_prob
......
...@@ -1978,6 +1978,10 @@ static void decode_block(VP10Decoder *const pbi, MACROBLOCKD *const xd, ...@@ -1978,6 +1978,10 @@ static void decode_block(VP10Decoder *const pbi, MACROBLOCKD *const xd,
} }
if (!is_inter_block(mbmi)) { if (!is_inter_block(mbmi)) {
int plane; int plane;
for (plane = 0; plane <= 1; ++plane) {
if (mbmi->palette_mode_info.palette_size[plane])
vp10_decode_palette_tokens(xd, plane, r);
}
for (plane = 0; plane < MAX_MB_PLANE; ++plane) { for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
const struct macroblockd_plane *const pd = &xd->plane[plane]; const struct macroblockd_plane *const pd = &xd->plane[plane];
const TX_SIZE tx_size = const TX_SIZE tx_size =
...@@ -1994,9 +1998,6 @@ static void decode_block(VP10Decoder *const pbi, MACROBLOCKD *const xd, ...@@ -1994,9 +1998,6 @@ static void decode_block(VP10Decoder *const pbi, MACROBLOCKD *const xd,
(xd->mb_to_bottom_edge >= 0 ? (xd->mb_to_bottom_edge >= 0 ?
0 : xd->mb_to_bottom_edge >> (5 + pd->subsampling_y)); 0 : xd->mb_to_bottom_edge >> (5 + pd->subsampling_y));
if (plane <= 1 && mbmi->palette_mode_info.palette_size[plane])
vp10_decode_palette_tokens(xd, plane, r);
for (row = 0; row < max_blocks_high; row += step) for (row = 0; row < max_blocks_high; row += step)
for (col = 0; col < max_blocks_wide; col += step) for (col = 0; col < max_blocks_wide; col += step)
predict_and_reconstruct_intra_block(xd, predict_and_reconstruct_intra_block(xd,
......
...@@ -419,30 +419,48 @@ static void read_palette_mode_info(VP10_COMMON *const cm, ...@@ -419,30 +419,48 @@ static void read_palette_mode_info(VP10_COMMON *const cm,
vpx_reader *r) { vpx_reader *r) {
MODE_INFO *const mi = xd->mi[0]; MODE_INFO *const mi = xd->mi[0];
MB_MODE_INFO *const mbmi = &mi->mbmi; MB_MODE_INFO *const mbmi = &mi->mbmi;
const MODE_INFO *above_mi = xd->above_mi; const MODE_INFO *const above_mi = xd->above_mi;
const MODE_INFO *left_mi = xd->left_mi; const MODE_INFO *const left_mi = xd->left_mi;
const BLOCK_SIZE bsize = mbmi->sb_type; const BLOCK_SIZE bsize = mbmi->sb_type;
int i, palette_ctx = 0; int i, n, palette_ctx = 0;
PALETTE_MODE_INFO *const pmi = &mbmi->palette_mode_info;
if (above_mi)
palette_ctx += (above_mi->mbmi.palette_mode_info.palette_size[0] > 0); if (mbmi->mode == DC_PRED) {
if (left_mi) if (above_mi)
palette_ctx += (left_mi->mbmi.palette_mode_info.palette_size[0] > 0); palette_ctx += (above_mi->mbmi.palette_mode_info.palette_size[0] > 0);
if (vpx_read(r, vp10_default_palette_y_mode_prob[bsize - BLOCK_8X8] if (left_mi)
[palette_ctx])) { palette_ctx += (left_mi->mbmi.palette_mode_info.palette_size[0] > 0);
int n; if (vpx_read(r, vp10_default_palette_y_mode_prob[bsize - BLOCK_8X8]
PALETTE_MODE_INFO *pmi = &mbmi->palette_mode_info; [palette_ctx])) {
pmi->palette_size[0] =
pmi->palette_size[0] =
vpx_read_tree(r, vp10_palette_size_tree, vpx_read_tree(r, vp10_palette_size_tree,
vp10_default_palette_y_size_prob[bsize - BLOCK_8X8]) + 2; vp10_default_palette_y_size_prob[bsize - BLOCK_8X8]) + 2;
n = pmi->palette_size[0]; n = pmi->palette_size[0];
for (i = 0; i < n; ++i)
pmi->palette_colors[i] = vpx_read_literal(r, cm->bit_depth);
for (i = 0; i < n; ++i) xd->plane[0].color_index_map[0] = read_uniform(r, n);
pmi->palette_colors[i] = vpx_read_literal(r, cm->bit_depth); assert(xd->plane[0].color_index_map[0] < n);
}
}
xd->plane[0].color_index_map[0] = read_uniform(r, n); if (mbmi->uv_mode == DC_PRED) {
assert(xd->plane[0].color_index_map[0] < n); if (vpx_read(r,
vp10_default_palette_uv_mode_prob[pmi->palette_size[0] > 0])) {
pmi->palette_size[1] =
vpx_read_tree(r, vp10_palette_size_tree,
vp10_default_palette_uv_size_prob[bsize - BLOCK_8X8])
+ 2;
n = pmi->palette_size[1];
for (i = 0; i < n; ++i) {
pmi->palette_colors[PALETTE_MAX_SIZE + i] =
vpx_read_literal(r, cm->bit_depth);
pmi->palette_colors[2 * PALETTE_MAX_SIZE + i] =
vpx_read_literal(r, cm->bit_depth);
}
xd->plane[1].color_index_map[0] = read_uniform(r, n);
assert(xd->plane[1].color_index_map[0] < n);
}
} }
} }
...@@ -456,7 +474,8 @@ static void read_ext_intra_mode_info(VP10_COMMON *const cm, ...@@ -456,7 +474,8 @@ static void read_ext_intra_mode_info(VP10_COMMON *const cm,
#if !ALLOW_FILTER_INTRA_MODES #if !ALLOW_FILTER_INTRA_MODES
return; return;
#endif #endif
if (mbmi->mode == DC_PRED) { if (mbmi->mode == DC_PRED &&
mbmi->palette_mode_info.palette_size[0] == 0) {
mbmi->ext_intra_mode_info.use_ext_intra_mode[0] = mbmi->ext_intra_mode_info.use_ext_intra_mode[0] =
vpx_read(r, cm->fc->ext_intra_probs[0]); vpx_read(r, cm->fc->ext_intra_probs[0]);
if (mbmi->ext_intra_mode_info.use_ext_intra_mode[0]) { if (mbmi->ext_intra_mode_info.use_ext_intra_mode[0]) {
...@@ -466,7 +485,8 @@ static void read_ext_intra_mode_info(VP10_COMMON *const cm, ...@@ -466,7 +485,8 @@ static void read_ext_intra_mode_info(VP10_COMMON *const cm,
if (counts) if (counts)
++counts->ext_intra[0][mbmi->ext_intra_mode_info.use_ext_intra_mode[0]]; ++counts->ext_intra[0][mbmi->ext_intra_mode_info.use_ext_intra_mode[0]];
} }
if (mbmi->uv_mode == DC_PRED) { if (mbmi->uv_mode == DC_PRED &&
mbmi->palette_mode_info.palette_size[1] == 0) {
mbmi->ext_intra_mode_info.use_ext_intra_mode[1] = mbmi->ext_intra_mode_info.use_ext_intra_mode[1] =
vpx_read(r, cm->fc->ext_intra_probs[1]); vpx_read(r, cm->fc->ext_intra_probs[1]);
if (mbmi->ext_intra_mode_info.use_ext_intra_mode[1]) { if (mbmi->ext_intra_mode_info.use_ext_intra_mode[1]) {
...@@ -555,8 +575,7 @@ static void read_intra_frame_mode_info(VP10_COMMON *const cm, ...@@ -555,8 +575,7 @@ static void read_intra_frame_mode_info(VP10_COMMON *const cm,
mbmi->palette_mode_info.palette_size[0] = 0; mbmi->palette_mode_info.palette_size[0] = 0;
mbmi->palette_mode_info.palette_size[1] = 0; mbmi->palette_mode_info.palette_size[1] = 0;
if (bsize >= BLOCK_8X8 && cm->allow_screen_content_tools && if (bsize >= BLOCK_8X8 && cm->allow_screen_content_tools)
mbmi->mode == DC_PRED)
read_palette_mode_info(cm, xd, r); read_palette_mode_info(cm, xd, r);
if (!FIXED_TX_TYPE) { if (!FIXED_TX_TYPE) {
...@@ -868,9 +887,10 @@ static void read_intra_block_mode_info(VP10_COMMON *const cm, ...@@ -868,9 +887,10 @@ static void read_intra_block_mode_info(VP10_COMMON *const cm,
mbmi->angle_delta[1] = mbmi->angle_delta[1] =
read_uniform(r, 2 * MAX_ANGLE_DELTAS + 1) - MAX_ANGLE_DELTAS; read_uniform(r, 2 * MAX_ANGLE_DELTAS + 1) - MAX_ANGLE_DELTAS;
#endif // CONFIG_EXT_INTRA #endif // CONFIG_EXT_INTRA
mbmi->palette_mode_info.palette_size[0] = 0; mbmi->palette_mode_info.palette_size[0] = 0;
mbmi->palette_mode_info.palette_size[1] = 0; mbmi->palette_mode_info.palette_size[1] = 0;
if (bsize >= BLOCK_8X8 && cm->allow_screen_content_tools)
read_palette_mode_info(cm, xd, r);
#if CONFIG_EXT_INTRA #if CONFIG_EXT_INTRA
mbmi->ext_intra_mode_info.use_ext_intra_mode[0] = 0; mbmi->ext_intra_mode_info.use_ext_intra_mode[0] = 0;
mbmi->ext_intra_mode_info.use_ext_intra_mode[1] = 0; mbmi->ext_intra_mode_info.use_ext_intra_mode[1] = 0;
...@@ -1151,6 +1171,9 @@ static void read_inter_block_mode_info(VP10Decoder *const pbi, ...@@ -1151,6 +1171,9 @@ static void read_inter_block_mode_info(VP10Decoder *const pbi,
int16_t mode_ctx = 0; int16_t mode_ctx = 0;
MV_REFERENCE_FRAME ref_frame; MV_REFERENCE_FRAME ref_frame;
mbmi->palette_mode_info.palette_size[0] = 0;
mbmi->palette_mode_info.palette_size[1] = 0;
read_ref_frames(cm, xd, r, mbmi->segment_id, mbmi->ref_frame); read_ref_frames(cm, xd, r, mbmi->segment_id, mbmi->ref_frame);
is_compound = has_second_ref(mbmi); is_compound = has_second_ref(mbmi);
......
...@@ -429,13 +429,15 @@ void vp10_decode_palette_tokens(MACROBLOCKD *const xd, int plane, ...@@ -429,13 +429,15 @@ void vp10_decode_palette_tokens(MACROBLOCKD *const xd, int plane,
MODE_INFO *const mi = xd->mi[0]; MODE_INFO *const mi = xd->mi[0];
MB_MODE_INFO *const mbmi = &mi->mbmi; MB_MODE_INFO *const mbmi = &mi->mbmi;
const BLOCK_SIZE bsize = mbmi->sb_type; const BLOCK_SIZE bsize = mbmi->sb_type;
int rows = 4 * num_4x4_blocks_high_lookup[bsize]; const int rows = (4 * num_4x4_blocks_high_lookup[bsize]) >>
int cols = 4 * num_4x4_blocks_wide_lookup[bsize]; (xd->plane[plane != 0].subsampling_y);
const int cols = (4 * num_4x4_blocks_wide_lookup[bsize]) >>
(xd->plane[plane != 0].subsampling_x);
int color_idx, color_ctx, color_order[PALETTE_MAX_SIZE]; int color_idx, color_ctx, color_order[PALETTE_MAX_SIZE];
int n = mbmi->palette_mode_info.palette_size[plane != 0]; int n = mbmi->palette_mode_info.palette_size[plane != 0];
int i, j; int i, j;
uint8_t *color_map = xd->plane[plane].color_index_map; uint8_t *color_map = xd->plane[plane != 0].color_index_map;
const vpx_prob (* prob)[PALETTE_COLOR_CONTEXTS][PALETTE_COLORS - 1] = const vpx_prob (* const prob)[PALETTE_COLOR_CONTEXTS][PALETTE_COLORS - 1] =
plane ? vp10_default_palette_uv_color_prob : plane ? vp10_default_palette_uv_color_prob :
vp10_default_palette_y_color_prob; vp10_default_palette_y_color_prob;
......
...@@ -509,13 +509,11 @@ static void update_ext_tx_probs(VP10_COMMON *cm, vpx_writer *w) { ...@@ -509,13 +509,11 @@ static void update_ext_tx_probs(VP10_COMMON *cm, vpx_writer *w) {
#endif // CONFIG_EXT_TX #endif // CONFIG_EXT_TX
static void pack_palette_tokens(vpx_writer *w, TOKENEXTRA **tp, static void pack_palette_tokens(vpx_writer *w, TOKENEXTRA **tp,
BLOCK_SIZE bsize, int n) { int n, int num) {
int rows = 4 * num_4x4_blocks_high_lookup[bsize];
int cols = 4 * num_4x4_blocks_wide_lookup[bsize];
int i; int i;
TOKENEXTRA *p = *tp; TOKENEXTRA *p = *tp;
for (i = 0; i < rows * cols -1; ++i) { for (i = 0; i < num; ++i) {
vp10_write_token(w, vp10_palette_color_tree[n - 2], p->context_tree, vp10_write_token(w, vp10_palette_color_tree[n - 2], p->context_tree,
&palette_color_encodings[n - 2][p->token]); &palette_color_encodings[n - 2][p->token]);
++p; ++p;
...@@ -842,7 +840,8 @@ static void write_ext_intra_mode_info(const VP10_COMMON *const cm, ...@@ -842,7 +840,8 @@ static void write_ext_intra_mode_info(const VP10_COMMON *const cm,
#if !ALLOW_FILTER_INTRA_MODES #if !ALLOW_FILTER_INTRA_MODES
return; return;
#endif #endif
if (mbmi->mode == DC_PRED) { if (mbmi->mode == DC_PRED &&
mbmi->palette_mode_info.palette_size[0] == 0) {
vpx_write(w, mbmi->ext_intra_mode_info.use_ext_intra_mode[0], vpx_write(w, mbmi->ext_intra_mode_info.use_ext_intra_mode[0],
cm->fc->ext_intra_probs[0]); cm->fc->ext_intra_probs[0]);
if (mbmi->ext_intra_mode_info.use_ext_intra_mode[0]) { if (mbmi->ext_intra_mode_info.use_ext_intra_mode[0]) {
...@@ -850,7 +849,8 @@ static void write_ext_intra_mode_info(const VP10_COMMON *const cm, ...@@ -850,7 +849,8 @@ static void write_ext_intra_mode_info(const VP10_COMMON *const cm,
write_uniform(w, FILTER_INTRA_MODES, mode); write_uniform(w, FILTER_INTRA_MODES, mode);
} }
} }
if (mbmi->uv_mode == DC_PRED) { if (mbmi->uv_mode == DC_PRED &&
mbmi->palette_mode_info.palette_size[1] == 0) {
vpx_write(w, mbmi->ext_intra_mode_info.use_ext_intra_mode[1], vpx_write(w, mbmi->ext_intra_mode_info.use_ext_intra_mode[1],
cm->fc->ext_intra_probs[1]); cm->fc->ext_intra_probs[1]);
if (mbmi->ext_intra_mode_info.use_ext_intra_mode[1]) { if (mbmi->ext_intra_mode_info.use_ext_intra_mode[1]) {
...@@ -881,6 +881,55 @@ static void write_switchable_interp_filter(VP10_COMP *cpi, ...@@ -881,6 +881,55 @@ static void write_switchable_interp_filter(VP10_COMP *cpi,
} }
} }
static void write_palette_mode_info(const VP10_COMMON *cm,
const MACROBLOCKD *xd,
const MODE_INFO *const mi,
vpx_writer *w) {
const MB_MODE_INFO *const mbmi = &mi->mbmi;
const MODE_INFO *const above_mi = xd->above_mi;
const MODE_INFO *const left_mi = xd->left_mi;
const BLOCK_SIZE bsize = mbmi->sb_type;
const PALETTE_MODE_INFO *const pmi = &mbmi->palette_mode_info;
int palette_ctx = 0;
int n, i;
if (mbmi->mode == DC_PRED) {
n = pmi->palette_size[0];
if (above_mi)
palette_ctx += (above_mi->mbmi.palette_mode_info.palette_size[0] > 0);
if (left_mi)
palette_ctx += (left_mi->mbmi.palette_mode_info.palette_size[0] > 0);
vpx_write(w, n > 0,
vp10_default_palette_y_mode_prob[bsize - BLOCK_8X8][palette_ctx]);
if (n > 0) {
vp10_write_token(w, vp10_palette_size_tree,
vp10_default_palette_y_size_prob[bsize - BLOCK_8X8],
&palette_size_encodings[n - 2]);
for (i = 0; i < n; ++i)
vpx_write_literal(w, pmi->palette_colors[i], cm->bit_depth);
write_uniform(w, n, pmi->palette_first_color_idx[0]);
}
}
if (mbmi->uv_mode == DC_PRED) {
n = pmi->palette_size[1];
vpx_write(w, n > 0,
vp10_default_palette_uv_mode_prob[pmi->palette_size[0] > 0]);
if (n > 0) {
vp10_write_token(w, vp10_palette_size_tree,
vp10_default_palette_uv_size_prob[bsize - BLOCK_8X8],
&palette_size_encodings[n - 2]);
for (i = 0; i < n; ++i) {
vpx_write_literal(w, pmi->palette_colors[PALETTE_MAX_SIZE + i],
cm->bit_depth);
vpx_write_literal(w, pmi->palette_colors[2 * PALETTE_MAX_SIZE + i],
cm->bit_depth);
}
write_uniform(w, n, pmi->palette_first_color_idx[1]);
}
}
}
static void pack_inter_mode_mvs(VP10_COMP *cpi, const MODE_INFO *mi, static void pack_inter_mode_mvs(VP10_COMP *cpi, const MODE_INFO *mi,
#if CONFIG_SUPERTX #if CONFIG_SUPERTX
int supertx_enabled, int supertx_enabled,
...@@ -995,7 +1044,10 @@ static void pack_inter_mode_mvs(VP10_COMP *cpi, const MODE_INFO *mi, ...@@ -995,7 +1044,10 @@ static void pack_inter_mode_mvs(VP10_COMP *cpi, const MODE_INFO *mi,
bsize >= BLOCK_8X8) bsize >= BLOCK_8X8)
write_uniform(w, 2 * MAX_ANGLE_DELTAS + 1, write_uniform(w, 2 * MAX_ANGLE_DELTAS + 1,
MAX_ANGLE_DELTAS + mbmi->angle_delta[1]); MAX_ANGLE_DELTAS + mbmi->angle_delta[1]);
#endif // CONFIG_EXT_INTRA
if (bsize >= BLOCK_8X8 && cm->allow_screen_content_tools)
write_palette_mode_info(cm, xd, mi, w);
#if CONFIG_EXT_INTRA
if (bsize >= BLOCK_8X8) if (bsize >= BLOCK_8X8)
write_ext_intra_mode_info(cm, mbmi, w); write_ext_intra_mode_info(cm, mbmi, w);
#endif // CONFIG_EXT_INTRA #endif // CONFIG_EXT_INTRA
...@@ -1263,36 +1315,6 @@ static void pack_inter_mode_mvs(VP10_COMP *cpi, const MODE_INFO *mi, ...@@ -1263,36 +1315,6 @@ static void pack_inter_mode_mvs(VP10_COMP *cpi, const MODE_INFO *mi,
} }
} }
static void write_palette_mode_info(const VP10_COMMON *cm,
const MACROBLOCKD *xd,
const MODE_INFO *const mi,
vpx_writer *w) {
const MB_MODE_INFO *const mbmi = &mi->mbmi;
const MODE_INFO *const above_mi = xd->above_mi;
const MODE_INFO *const left_mi = xd->left_mi;
const BLOCK_SIZE bsize = mbmi->sb_type;
const PALETTE_MODE_INFO *pmi = &mbmi->palette_mode_info;
int palette_ctx = 0;
int n, i;
n = pmi->palette_size[0];
if (above_mi)
palette_ctx += (above_mi->mbmi.palette_mode_info.palette_size[0] > 0);
if (left_mi)
palette_ctx += (left_mi->mbmi.palette_mode_info.palette_size[0] > 0);
vpx_write(w, n > 0,
vp10_default_palette_y_mode_prob[bsize - BLOCK_8X8][palette_ctx]);
if (n > 0) {
vp10_write_token(w, vp10_palette_size_tree,
vp10_default_palette_y_size_prob[bsize - BLOCK_8X8],
&palette_size_encodings[n - 2]);
for (i = 0; i < n; ++i)
vpx_write_literal(w, pmi->palette_colors[i],
cm->bit_depth);
write_uniform(w, n, pmi->palette_first_color_idx[0]);
}
}
static void write_mb_modes_kf(const VP10_COMMON *cm, const MACROBLOCKD *xd, static void write_mb_modes_kf(const VP10_COMMON *cm, const MACROBLOCKD *xd,
MODE_INFO **mi_8x8, vpx_writer *w) { MODE_INFO **mi_8x8, vpx_writer *w) {
const struct segmentation *const seg = &cm->seg; const struct segmentation *const seg = &cm->seg;
...@@ -1351,9 +1373,7 @@ static void write_mb_modes_kf(const VP10_COMMON *cm, const MACROBLOCKD *xd, ...@@ -1351,9 +1373,7 @@ static void write_mb_modes_kf(const VP10_COMMON *cm, const MACROBLOCKD *xd,
write_uniform(w, 2 * MAX_ANGLE_DELTAS + 1, write_uniform(w, 2 * MAX_ANGLE_DELTAS + 1,
MAX_ANGLE_DELTAS + mbmi->angle_delta[1]); MAX_ANGLE_DELTAS + mbmi->angle_delta[1]);
#endif // CONFIG_EXT_INTRA #endif // CONFIG_EXT_INTRA
if (bsize >= BLOCK_8X8 && cm->allow_screen_content_tools)
if (bsize >= BLOCK_8X8 && cm->allow_screen_content_tools &&
mbmi->mode == DC_PRED)
write_palette_mode_info(cm, xd, mi, w); write_palette_mode_info(cm, xd, mi, w);
if (!FIXED_TX_TYPE) { if (!FIXED_TX_TYPE) {
...@@ -1428,11 +1448,17 @@ static void write_modes_b(VP10_COMP *cpi, const TileInfo *const tile, ...@@ -1428,11 +1448,17 @@ static void write_modes_b(VP10_COMP *cpi, const TileInfo *const tile,
w); w);
} }
if (m->mbmi.palette_mode_info.palette_size[0] > 0) { for (plane = 0; plane <= 1; ++plane) {
assert(*tok < tok_end); if (m->mbmi.palette_mode_info.palette_size[plane] > 0) {
pack_palette_tokens(w, tok, m->mbmi.sb_type, const int rows = (4 * num_4x4_blocks_high_lookup[m->mbmi.sb_type]) >>
m->mbmi.palette_mode_info.palette_size[0]); (xd->plane[plane].subsampling_y);
assert(*tok < tok_end); const int cols = (4 * num_4x4_blocks_wide_lookup[m->mbmi.sb_type]) >>
(xd->plane[plane].subsampling_x);
assert(*tok < tok_end);
pack_palette_tokens(w, tok, m->mbmi.palette_mode_info.palette_size[plane],
rows * cols - 1);
assert(*tok < tok_end);
}
} }
#if CONFIG_SUPERTX #if CONFIG_SUPERTX
......
...@@ -4432,9 +4432,11 @@ static void encode_superblock(VP10_COMP *cpi, ThreadData *td, ...@@ -4432,9 +4432,11 @@ static void encode_superblock(VP10_COMP *cpi, ThreadData *td,
#if CONFIG_EXT_INTRA #if CONFIG_EXT_INTRA
if (output_enabled && bsize >= BLOCK_8X8) { if (output_enabled && bsize >= BLOCK_8X8) {
FRAME_COUNTS *counts = td->counts; FRAME_COUNTS *counts = td->counts;
if (mbmi->mode == DC_PRED) if (mbmi->mode == DC_PRED &&
mbmi->palette_mode_info.palette_size[0] == 0)
++counts->ext_intra[0][mbmi->ext_intra_mode_info.use_ext_intra_mode[0]]; ++counts->ext_intra[0][mbmi->ext_intra_mode_info.use_ext_intra_mode[0]];
if (mbmi->uv_mode == DC_PRED) if (mbmi->uv_mode == DC_PRED &&
mbmi->palette_mode_info.palette_size[1] == 0)
++counts->ext_intra[1][mbmi->ext_intra_mode_info.use_ext_intra_mode[1]]; ++counts->ext_intra[1][mbmi->ext_intra_mode_info.use_ext_intra_mode[1]];
if (mbmi->mode != DC_PRED && mbmi->mode != TM_PRED) { if (mbmi->mode != DC_PRED && mbmi->mode != TM_PRED) {
int p_angle; int p_angle;
...@@ -4448,12 +4450,14 @@ static void encode_superblock(VP10_COMP *cpi, ThreadData *td, ...@@ -4448,12 +4450,14 @@ static void encode_superblock(VP10_COMP *cpi, ThreadData *td,
#endif // CONFIG_EXT_INTRA #endif // CONFIG_EXT_INTRA
if (bsize >= BLOCK_8X8 && output_enabled) { if (bsize >= BLOCK_8X8 && output_enabled) {
if (mbmi->palette_mode_info.palette_size[0] > 0) { for (plane = 0; plane <= 1; ++plane) {
mbmi->palette_mode_info.palette_first_color_idx[0] = if (mbmi->palette_mode_info.palette_size[plane] > 0) {
xd->plane[0].color_index_map[0]; mbmi->palette_mode_info.palette_first_color_idx[plane] =
// TODO(huisu): this increases the use of token buffer. Needs stretch xd->plane[plane].color_index_map[0];
// test to verify. // TODO(huisu): this increases the use of token buffer. Needs stretch
vp10_tokenize_palette_sb(td, bsize, 0, t); // test to verify.
vp10_tokenize_palette_sb(td, bsize, plane, t);
}
} }
} }
vp10_tokenize_sb(cpi, td, t, !output_enabled, VPXMAX(bsize, BLOCK_8X8)); vp10_tokenize_sb(cpi, td, t, !output_enabled, VPXMAX(bsize, BLOCK_8X8));
......
...@@ -93,7 +93,7 @@ int vp10_k_means(const double *data, double *centroids, uint8_t *indices, ...@@ -93,7 +93,7 @@ int vp10_k_means(const double *data, double *centroids, uint8_t *indices,
uint8_t *pre_indices, int n, int k, int dim, int max_itr) { uint8_t *pre_indices, int n, int k, int dim, int max_itr) {
int i = 0; int i = 0;
double pre_dist, this_dist; double pre_dist, this_dist;
double pre_centroids[PALETTE_MAX_SIZE]; double pre_centroids[2 * PALETTE_MAX_SIZE];
vp10_calc_indices(data, centroids, indices, n, k, dim); vp10_calc_indices(data, centroids, indices, n, k, dim);
pre_dist = calc_total_dist(data, centroids, indices, n, k, dim); pre_dist = calc_total_dist(data, centroids, indices, n, k, dim);
......
This diff is collapsed.
...@@ -398,13 +398,18 @@ void vp10_tokenize_palette_sb(struct ThreadData *const td, ...@@ -398,13 +398,18 @@ void vp10_tokenize_palette_sb(struct ThreadData *const td,
MACROBLOCK *const x = &td->mb; MACROBLOCK *const x = &td->mb;
MACROBLOCKD *const xd = &x->e_mbd; MACROBLOCKD *const xd = &x->e_mbd;
MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
uint8_t *color_map = xd->plane[0].color_index_map; uint8_t *color_map = xd->plane[plane != 0].color_index_map;
PALETTE_MODE_INFO *pmi = &mbmi->palette_mode_info; PALETTE_MODE_INFO *pmi = &mbmi->palette_mode_info;
int n = pmi->palette_size[plane != 0]; int n = pmi->palette_size[plane != 0];
int i, j, k; int i, j, k;
int color_new_idx = -1, color_ctx, color_order[PALETTE_MAX_SIZE]; int color_new_idx = -1, color_ctx, color_order[PALETTE_MAX_SIZE];
int rows = 4 * num_4x4_blocks_high_lookup[bsize]; const int rows = (4 * num_4x4_blocks_high_lookup[bsize]) >>
int cols = 4 * num_4x4_blocks_wide_lookup[bsize]; (xd->plane[plane != 0].subsampling_y);
const int cols = (4 * num_4x4_blocks_wide_lookup[bsize]) >>
(xd->plane[plane != 0].subsampling_x);
const vpx_prob (* const probs)[PALETTE_COLOR_CONTEXTS][PALETTE_COLORS - 1] =
plane == 0 ? vp10_default_palette_y_color_prob :
vp10_default_palette_uv_color_prob;
for (i = 0; i < rows; ++i) { for (i = 0; i < rows; ++i) {
for (j = (i == 0 ? 1 : 0); j < cols; ++j) { for (j = (i == 0 ? 1 : 0); j < cols; ++j) {
...@@ -416,9 +421,8 @@ void vp10_tokenize_palette_sb(struct ThreadData *const td, ...@@ -416,9 +421,8 @@ void vp10_tokenize_palette_sb(struct ThreadData *const td,
break; break;
} }
assert(color_new_idx >= 0 && color_new_idx < n); assert(color_new_idx >= 0 && color_new_idx < n);
(*t)->token = color_new_idx; (*t)->token = color_new_idx;
(*t)->context_tree = vp10_default_palette_y_color_prob[n - 2][color_ctx]; (*t)->context_tree = probs[n - 2][color_ctx];
(*t)->skip_eob_node = 0; (*t)->skip_eob_node = 0;
++(*t); ++(*t);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment