Commit ce7272d2 authored by Thomas Davies's avatar Thomas Davies

NEW_MULTISYMBOL: use CDFs for palette tree coding.

AWCY results, 1 frame, tune-content=1

objective-1-fast:
PSNR (Y, Cb, Cr) : -0.26%, -0.24%, -0.26%
PSNR-HVS         : -0.26%
MS-SSIM          : -0.25%

screenshots:
PSNR (Y, Cb, Cr) :  -2.28%, -2.29%, -2.29%
PSNR-HVS         :  -2.30%
MS-SSIM          :  -2.26%

twitch-1 :
PSNR (Y, Cb, Cr) : -0.73%, -0.73%, -0.73%
PSNR-HVS         : -0.75%
MS-SSIM          : -0.74%

Change-Id: I7aac475710ab3895778d7ff05d9113f5713133b1
parent 04e5aa7f
......@@ -5677,7 +5677,13 @@ void av1_average_tile_intra_cdfs(FRAME_CONTEXT *fc, FRAME_CONTEXT *ec_ctxs[],
#if CONFIG_VAR_TX
AVERAGE_TILE_CDFS(txfm_partition_cdf)
#endif
#if CONFIG_PALETTE
AVERAGE_TILE_CDFS(palette_y_size_cdf);
AVERAGE_TILE_CDFS(palette_uv_size_cdf);
AVERAGE_TILE_CDFS(palette_y_color_index_cdf);
AVERAGE_TILE_CDFS(palette_uv_color_index_cdf);
#endif
#endif // CONFIG_NEW_MULTISYMBOL
}
void av1_average_tile_inter_cdfs(AV1_COMMON *cm, FRAME_CONTEXT *fc,
......
This diff is collapsed.
......@@ -239,6 +239,17 @@ typedef struct frame_contexts {
aom_prob intra_inter_prob[INTRA_INTER_CONTEXTS];
aom_prob comp_inter_prob[COMP_INTER_CONTEXTS];
#if CONFIG_NEW_MULTISYMBOL
#if CONFIG_PALETTE
aom_cdf_prob palette_y_size_cdf[PALETTE_BLOCK_SIZES][CDF_SIZE(PALETTE_SIZES)];
aom_cdf_prob palette_uv_size_cdf[PALETTE_BLOCK_SIZES]
[CDF_SIZE(PALETTE_SIZES)];
aom_cdf_prob palette_y_color_index_cdf[PALETTE_SIZES]
[PALETTE_COLOR_INDEX_CONTEXTS]
[CDF_SIZE(PALETTE_COLORS)];
aom_cdf_prob palette_uv_color_index_cdf[PALETTE_SIZES]
[PALETTE_COLOR_INDEX_CONTEXTS]
[CDF_SIZE(PALETTE_COLORS)];
#endif
aom_cdf_prob comp_inter_cdf[COMP_INTER_CONTEXTS][CDF_SIZE(2)];
aom_cdf_prob single_ref_cdf[REF_CONTEXTS][SINGLE_REFS - 1][CDF_SIZE(2)];
#endif
......
......@@ -825,10 +825,17 @@ static void read_palette_mode_info(AV1_COMMON *const cm, MACROBLOCKD *const xd,
[palette_y_mode_ctx],
ACCT_STR)) {
pmi->palette_size[0] =
#if CONFIG_NEW_MULTISYMBOL
aom_read_symbol(r,
xd->tile_ctx->palette_y_size_cdf[bsize - BLOCK_8X8],
PALETTE_SIZES, ACCT_STR) +
2;
#else
aom_read_tree(r, av1_palette_size_tree,
av1_default_palette_y_size_prob[bsize - BLOCK_8X8],
ACCT_STR) +
2;
#endif
n = pmi->palette_size[0];
#if CONFIG_PALETTE_DELTA_ENCODING
read_palette_colors_y(xd, cm->bit_depth, pmi, r);
......@@ -847,10 +854,17 @@ static void read_palette_mode_info(AV1_COMMON *const cm, MACROBLOCKD *const xd,
if (aom_read(r, av1_default_palette_uv_mode_prob[palette_uv_mode_ctx],
ACCT_STR)) {
pmi->palette_size[1] =
#if CONFIG_NEW_MULTISYMBOL
aom_read_symbol(r,
xd->tile_ctx->palette_uv_size_cdf[bsize - BLOCK_8X8],
PALETTE_SIZES, ACCT_STR) +
2;
#else
aom_read_tree(r, av1_palette_size_tree,
av1_default_palette_uv_size_prob[bsize - BLOCK_8X8],
ACCT_STR) +
2;
#endif
n = pmi->palette_size[1];
#if CONFIG_PALETTE_DELTA_ENCODING
read_palette_colors_uv(xd, cm->bit_depth, pmi, r);
......
......@@ -260,10 +260,18 @@ void av1_decode_palette_tokens(MACROBLOCKD *const xd, int plane,
const int n = mbmi->palette_mode_info.palette_size[plane];
int i, j;
uint8_t *const color_map = xd->plane[plane].color_index_map;
#if CONFIG_NEW_MULTISYMBOL
aom_cdf_prob(
*palette_cdf)[PALETTE_COLOR_INDEX_CONTEXTS][CDF_SIZE(PALETTE_COLORS)] =
plane ? xd->tile_ctx->palette_uv_color_index_cdf
: xd->tile_ctx->palette_y_color_index_cdf;
#else
const aom_prob(
*const prob)[PALETTE_COLOR_INDEX_CONTEXTS][PALETTE_COLORS - 1] =
plane ? av1_default_palette_uv_color_index_prob
: av1_default_palette_y_color_index_prob;
#endif
int plane_block_width, plane_block_height, rows, cols;
av1_get_block_dimensions(mbmi->sb_type, plane, xd, &plane_block_width,
&plane_block_height, &rows, &cols);
......@@ -275,9 +283,14 @@ void av1_decode_palette_tokens(MACROBLOCKD *const xd, int plane,
for (j = AOMMIN(i, cols - 1); j >= AOMMAX(0, i - rows + 1); --j) {
const int color_ctx = av1_get_palette_color_index_context(
color_map, plane_block_width, (i - j), j, n, color_order, NULL);
#if CONFIG_NEW_MULTISYMBOL
const int color_idx = aom_read_symbol(
r, palette_cdf[n - PALETTE_MIN_SIZE][color_ctx], n, ACCT_STR);
#else
const int color_idx =
aom_read_tree(r, av1_palette_color_index_tree[n - 2],
prob[n - 2][color_ctx], ACCT_STR);
#endif
assert(color_idx >= 0 && color_idx < n);
color_map[(i - j) * plane_block_width + j] = color_order[color_idx];
}
......@@ -295,9 +308,14 @@ void av1_decode_palette_tokens(MACROBLOCKD *const xd, int plane,
for (j = (i == 0 ? 1 : 0); j < cols; ++j) {
const int color_ctx = av1_get_palette_color_index_context(
color_map, plane_block_width, i, j, n, color_order, NULL);
#if CONFIG_NEW_MULTISYMBOL
const int color_idx = aom_read_symbol(
r, palette_cdf[n - PALETTE_MIN_SIZE][color_ctx], n, ACCT_STR);
#else
const int color_idx =
aom_read_tree(r, av1_palette_color_index_tree[n - PALETTE_MIN_SIZE],
prob[n - PALETTE_MIN_SIZE][color_ctx], ACCT_STR);
#endif
assert(color_idx >= 0 && color_idx < n);
color_map[i * plane_block_width + j] = color_order[color_idx];
}
......
......@@ -927,9 +927,13 @@ static void pack_palette_tokens(aom_writer *w, const TOKENEXTRA **tp, int n,
const TOKENEXTRA *p = *tp;
for (i = 0; i < num; ++i) {
#if CONFIG_NEW_MULTISYMBOL
aom_write_symbol(w, p->token, p->palette_cdf, n);
#else
av1_write_token(
w, av1_palette_color_index_tree[n - PALETTE_MIN_SIZE], p->context_tree,
&palette_color_index_encodings[n - PALETTE_MIN_SIZE][p->token]);
#endif
++p;
}
......@@ -1739,9 +1743,15 @@ static void write_palette_mode_info(const AV1_COMMON *cm, const MACROBLOCKD *xd,
w, n > 0,
av1_default_palette_y_mode_prob[bsize - BLOCK_8X8][palette_y_mode_ctx]);
if (n > 0) {
#if CONFIG_NEW_MULTISYMBOL
aom_write_symbol(w, n - PALETTE_MIN_SIZE,
xd->tile_ctx->palette_y_size_cdf[bsize - BLOCK_8X8],
PALETTE_SIZES);
#else
av1_write_token(w, av1_palette_size_tree,
av1_default_palette_y_size_prob[bsize - BLOCK_8X8],
&palette_size_encodings[n - PALETTE_MIN_SIZE]);
#endif
#if CONFIG_PALETTE_DELTA_ENCODING
write_palette_colors_y(xd, pmi, cm->bit_depth, w);
#else
......@@ -1759,9 +1769,15 @@ static void write_palette_mode_info(const AV1_COMMON *cm, const MACROBLOCKD *xd,
const int palette_uv_mode_ctx = (pmi->palette_size[0] > 0);
aom_write(w, n > 0, av1_default_palette_uv_mode_prob[palette_uv_mode_ctx]);
if (n > 0) {
#if CONFIG_NEW_MULTISYMBOL
aom_write_symbol(w, n - PALETTE_MIN_SIZE,
xd->tile_ctx->palette_uv_size_cdf[bsize - BLOCK_8X8],
PALETTE_SIZES);
#else
av1_write_token(w, av1_palette_size_tree,
av1_default_palette_uv_size_prob[bsize - BLOCK_8X8],
&palette_size_encodings[n - PALETTE_MIN_SIZE]);
#endif
#if CONFIG_PALETTE_DELTA_ENCODING
write_palette_colors_uv(xd, pmi, cm->bit_depth, w);
#else
......
......@@ -331,10 +331,18 @@ void av1_tokenize_palette_sb(const AV1_COMP *cpi,
int i, j;
int this_rate = 0;
uint8_t color_order[PALETTE_MAX_SIZE];
#if CONFIG_NEW_MULTISYMBOL
aom_cdf_prob(
*palette_cdf)[PALETTE_COLOR_INDEX_CONTEXTS][CDF_SIZE(PALETTE_COLORS)] =
plane ? xd->tile_ctx->palette_uv_color_index_cdf
: xd->tile_ctx->palette_y_color_index_cdf;
#else
const aom_prob(
*const probs)[PALETTE_COLOR_INDEX_CONTEXTS][PALETTE_COLORS - 1] =
plane == 0 ? av1_default_palette_y_color_index_prob
: av1_default_palette_uv_color_index_prob;
#endif
int plane_block_width, rows, cols;
av1_get_block_dimensions(bsize, plane, xd, &plane_block_width, NULL, &rows,
&cols);
......@@ -357,7 +365,11 @@ void av1_tokenize_palette_sb(const AV1_COMP *cpi,
this_rate += cpi->palette_y_color_cost[n - PALETTE_MIN_SIZE][color_ctx]
[color_new_idx];
(*t)->token = color_new_idx;
#if CONFIG_NEW_MULTISYMBOL
(*t)->palette_cdf = palette_cdf[n - PALETTE_MIN_SIZE][color_ctx];
#else
(*t)->context_tree = probs[n - PALETTE_MIN_SIZE][color_ctx];
#endif
(*t)->skip_eob_node = 0;
++(*t);
}
......
......@@ -37,6 +37,9 @@ typedef struct {
typedef struct {
aom_cdf_prob (*tail_cdf)[CDF_SIZE(ENTROPY_TOKENS)];
aom_cdf_prob (*head_cdf)[CDF_SIZE(ENTROPY_TOKENS)];
#if CONFIG_NEW_MULTISYMBOL && CONFIG_PALETTE
aom_cdf_prob *palette_cdf;
#endif
int eob_val;
int first_val;
const aom_prob *context_tree;
......
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