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
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index 6e30597..112e6d6 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -927,9 +927,13 @@
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 @@
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 @@
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
diff --git a/av1/encoder/tokenize.c b/av1/encoder/tokenize.c
index ef72cb4..3df9b6a 100644
--- a/av1/encoder/tokenize.c
+++ b/av1/encoder/tokenize.c
@@ -331,10 +331,18 @@
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 @@
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);
}
diff --git a/av1/encoder/tokenize.h b/av1/encoder/tokenize.h
index cbfa3cd..b0115e7 100644
--- a/av1/encoder/tokenize.h
+++ b/av1/encoder/tokenize.h
@@ -37,6 +37,9 @@
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;