Commit 59f92319 authored by Thomas Davies's avatar Thomas Davies
Browse files

NEW_MULTISYMBOL: adapt palette mode coding.

Use adaptive CDFs for coding the palette mode.

Change-Id: Iadbccfea4f4a38f3037814a609adf3f3ae2c835d
parent a48b1e68
......@@ -2284,6 +2284,10 @@ void av1_average_tile_intra_cdfs(FRAME_CONTEXT *fc, FRAME_CONTEXT *ec_ctxs[],
#if CONFIG_MRC_TX
AVERAGE_TILE_CDFS(mrc_mask_intra_cdf)
#endif // CONFIG_MRC_TX
#if CONFIG_NEW_MULTISYMBOL
AVERAGE_TILE_CDFS(palette_y_mode_cdf)
AVERAGE_TILE_CDFS(palette_uv_size_cdf)
#endif
}
void av1_average_tile_inter_cdfs(AV1_COMMON *cm, FRAME_CONTEXT *fc,
......
......@@ -1644,6 +1644,61 @@ const aom_prob av1_default_palette_uv_mode_prob[PALETTE_UV_MODE_CONTEXTS] = {
253, 229
};
#if CONFIG_NEW_MULTISYMBOL
const aom_cdf_prob
default_palette_y_mode_cdf[PALETTE_BLOCK_SIZES][PALETTE_Y_MODE_CONTEXTS]
[CDF_SIZE(2)] = {
{ { AOM_ICDF(128 * 240), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 180), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 100), AOM_ICDF(32768), 0 } },
{ { AOM_ICDF(128 * 240), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 180), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 100), AOM_ICDF(32768), 0 } },
{ { AOM_ICDF(128 * 240), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 180), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 100), AOM_ICDF(32768), 0 } },
{ { AOM_ICDF(128 * 240), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 180), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 100), AOM_ICDF(32768), 0 } },
{ { AOM_ICDF(128 * 240), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 180), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 100), AOM_ICDF(32768), 0 } },
{ { AOM_ICDF(128 * 240), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 180), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 100), AOM_ICDF(32768), 0 } },
{ { AOM_ICDF(128 * 240), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 180), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 100), AOM_ICDF(32768), 0 } },
{ { AOM_ICDF(128 * 240), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 180), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 100), AOM_ICDF(32768), 0 } },
{ { AOM_ICDF(128 * 240), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 180), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 100), AOM_ICDF(32768), 0 } },
{ { AOM_ICDF(128 * 240), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 180), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 100), AOM_ICDF(32768), 0 } },
#if CONFIG_EXT_PARTITION
{ { AOM_ICDF(128 * 240), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 180), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 100), AOM_ICDF(32768), 0 } },
{ { AOM_ICDF(128 * 240), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 180), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 100), AOM_ICDF(32768), 0 } },
{ { AOM_ICDF(128 * 240), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 180), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 100), AOM_ICDF(32768), 0 } },
#endif // CONFIG_EXT_PARTITION
};
const aom_cdf_prob
default_palette_uv_mode_cdf[PALETTE_UV_MODE_CONTEXTS][CDF_SIZE(2)] = {
{ AOM_ICDF(128 * 253), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 229), AOM_ICDF(32768), 0 }
};
#endif
const aom_cdf_prob default_palette_y_color_index_cdf
[PALETTE_SIZES][PALETTE_COLOR_INDEX_CONTEXTS][CDF_SIZE(PALETTE_COLORS)] = {
{
......@@ -4920,6 +4975,8 @@ static void init_mode_probs(FRAME_CONTEXT *fc) {
#endif // CONFIG_EXT_COMP_REFS
av1_copy(fc->comp_ref_prob, default_comp_ref_p);
#if CONFIG_NEW_MULTISYMBOL
av1_copy(fc->palette_y_mode_cdf, default_palette_y_mode_cdf);
av1_copy(fc->palette_uv_mode_cdf, default_palette_uv_mode_cdf);
av1_copy(fc->comp_ref_cdf, default_comp_ref_cdf);
#endif
#if CONFIG_LV_MAP
......
......@@ -261,6 +261,9 @@ typedef struct frame_contexts {
[CDF_SIZE(PALETTE_COLORS)];
#endif // CONFIG_MRC_TX
#if CONFIG_NEW_MULTISYMBOL
aom_cdf_prob palette_y_mode_cdf[PALETTE_BLOCK_SIZES][PALETTE_Y_MODE_CONTEXTS]
[CDF_SIZE(2)];
aom_cdf_prob palette_uv_mode_cdf[PALETTE_UV_MODE_CONTEXTS][CDF_SIZE(2)];
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
......
......@@ -789,6 +789,7 @@ static void read_palette_mode_info(AV1_COMMON *const cm, MACROBLOCKD *const xd,
assert(bsize >= BLOCK_8X8 && bsize <= BLOCK_LARGEST);
const int block_palette_idx = bsize - BLOCK_8X8;
int modev;
if (mbmi->mode == DC_PRED) {
int palette_y_mode_ctx = 0;
......@@ -800,9 +801,18 @@ static void read_palette_mode_info(AV1_COMMON *const cm, MACROBLOCKD *const xd,
palette_y_mode_ctx +=
(left_mi->mbmi.palette_mode_info.palette_size[0] > 0);
}
if (aom_read(r, av1_default_palette_y_mode_prob[block_palette_idx]
[palette_y_mode_ctx],
ACCT_STR)) {
#if CONFIG_NEW_MULTISYMBOL
modev = aom_read_symbol(
r,
xd->tile_ctx->palette_y_mode_cdf[block_palette_idx][palette_y_mode_ctx],
2, ACCT_STR);
#else
modev = aom_read(
r,
av1_default_palette_y_mode_prob[block_palette_idx][palette_y_mode_ctx],
ACCT_STR);
#endif
if (modev) {
pmi->palette_size[0] =
aom_read_symbol(r,
xd->tile_ctx->palette_y_size_cdf[block_palette_idx],
......@@ -816,11 +826,16 @@ static void read_palette_mode_info(AV1_COMMON *const cm, MACROBLOCKD *const xd,
#endif // CONFIG_PALETTE_DELTA_ENCODING
}
}
if (mbmi->uv_mode == UV_DC_PRED) {
const int palette_uv_mode_ctx = (pmi->palette_size[0] > 0);
if (aom_read(r, av1_default_palette_uv_mode_prob[palette_uv_mode_ctx],
ACCT_STR)) {
#if CONFIG_NEW_MULTISYMBOL
modev = aom_read_symbol(
r, xd->tile_ctx->palette_uv_mode_cdf[palette_uv_mode_ctx], 2, ACCT_STR);
#else
modev = aom_read(r, av1_default_palette_uv_mode_prob[palette_uv_mode_ctx],
ACCT_STR);
#endif
if (modev) {
pmi->palette_size[1] =
aom_read_symbol(r,
xd->tile_ctx->palette_uv_size_cdf[block_palette_idx],
......
......@@ -1502,9 +1502,16 @@ static void write_palette_mode_info(const AV1_COMMON *cm, const MACROBLOCKD *xd,
palette_y_mode_ctx +=
(left_mi->mbmi.palette_mode_info.palette_size[0] > 0);
}
#if CONFIG_NEW_MULTISYMBOL
aom_write_symbol(
w, n > 0,
xd->tile_ctx->palette_y_mode_cdf[block_palette_idx][palette_y_mode_ctx],
2);
#else
aom_write(
w, n > 0,
av1_default_palette_y_mode_prob[block_palette_idx][palette_y_mode_ctx]);
#endif
if (n > 0) {
aom_write_symbol(w, n - PALETTE_MIN_SIZE,
xd->tile_ctx->palette_y_size_cdf[block_palette_idx],
......@@ -1523,7 +1530,12 @@ static void write_palette_mode_info(const AV1_COMMON *cm, const MACROBLOCKD *xd,
if (mbmi->uv_mode == UV_DC_PRED) {
const int n = pmi->palette_size[1];
const int palette_uv_mode_ctx = (pmi->palette_size[0] > 0);
#if CONFIG_NEW_MULTISYMBOL
aom_write_symbol(w, n > 0,
xd->tile_ctx->palette_uv_mode_cdf[palette_uv_mode_ctx], 2);
#else
aom_write(w, n > 0, av1_default_palette_uv_mode_prob[palette_uv_mode_ctx]);
#endif
if (n > 0) {
aom_write_symbol(w, n - PALETTE_MIN_SIZE,
xd->tile_ctx->palette_uv_size_cdf[block_palette_idx],
......
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