Commit 1bfb5eda authored by Thomas Davies's avatar Thomas Davies

EC_ADAPT: use tile context for intra mode syntax.

Change-Id: Id01c785ad48134075c4f6643233413564f0b8fbc
parent 2452329a
......@@ -1844,7 +1844,7 @@ void av1_set_mode_cdfs(struct AV1Common *cm) {
for (i = 0; i < INTRA_MODES; ++i)
for (j = 0; j < INTRA_MODES; ++j)
av1_tree_to_cdf(av1_intra_mode_tree, cm->kf_y_prob[i][j],
cm->kf_y_cdf[i][j]);
cm->fc->kf_y_cdf[i][j]);
for (j = 0; j < SWITCHABLE_FILTER_CONTEXTS; ++j)
av1_tree_to_cdf(av1_switchable_interp_tree, fc->switchable_interp_prob[j],
......
......@@ -183,6 +183,10 @@ typedef struct frame_contexts {
aom_cdf_prob switchable_interp_cdf[SWITCHABLE_FILTER_CONTEXTS]
[SWITCHABLE_FILTERS];
aom_cdf_prob inter_mode_cdf[INTER_MODE_CONTEXTS][INTER_MODES];
/* Keep track of kf_y_cdf here, as this makes handling
multiple copies for adaptation in tiles easier */
aom_cdf_prob kf_y_cdf[INTRA_MODES][INTRA_MODES][INTRA_MODES];
#if !CONFIG_EXT_TX
aom_cdf_prob intra_ext_tx_cdf[EXT_TX_SIZES][TX_TYPES][TX_TYPES];
aom_cdf_prob inter_ext_tx_cdf[EXT_TX_SIZES][TX_TYPES];
......
......@@ -396,9 +396,6 @@ typedef struct AV1Common {
// - this is intentionally not placed in FRAME_CONTEXT since it's reset upon
// each keyframe and not used afterwards
aom_prob kf_y_prob[INTRA_MODES][INTRA_MODES][INTRA_MODES - 1];
#if CONFIG_EC_MULTISYMBOL
aom_cdf_prob kf_y_cdf[INTRA_MODES][INTRA_MODES][INTRA_MODES];
#endif
#if CONFIG_GLOBAL_MOTION
WarpedMotionParams global_motion[TOTAL_REFS_PER_FRAME];
#endif
......@@ -633,13 +630,14 @@ static INLINE const aom_prob *get_y_mode_probs(const AV1_COMMON *cm,
}
#if CONFIG_EC_MULTISYMBOL
static INLINE aom_cdf_prob *get_y_mode_cdf(AV1_COMMON *cm, const MODE_INFO *mi,
static INLINE aom_cdf_prob *get_y_mode_cdf(FRAME_CONTEXT *tile_ctx,
const MODE_INFO *mi,
const MODE_INFO *above_mi,
const MODE_INFO *left_mi,
int block) {
const PREDICTION_MODE above = av1_above_block_mode(mi, above_mi, block);
const PREDICTION_MODE left = av1_left_block_mode(mi, left_mi, block);
return cm->kf_y_cdf[above][left];
return tile_ctx->kf_y_cdf[above][left];
}
#endif
......
......@@ -4469,7 +4469,7 @@ static int read_compressed_header(AV1Decoder *pbi, const uint8_t *data,
if (frame_is_intra_only(cm)) {
av1_copy(cm->kf_y_prob, av1_kf_y_mode_prob);
#if CONFIG_EC_MULTISYMBOL
av1_copy(cm->kf_y_cdf, av1_kf_y_mode_cdf);
av1_copy(cm->fc->kf_y_cdf, av1_kf_y_mode_cdf);
#endif
#if !CONFIG_EC_ADAPT
for (k = 0; k < INTRA_MODES; k++)
......
......@@ -96,13 +96,22 @@ static int read_delta_qindex(AV1_COMMON *cm, MACROBLOCKD *xd, aom_reader *r,
static PREDICTION_MODE read_intra_mode_y(AV1_COMMON *cm, MACROBLOCKD *xd,
aom_reader *r, int size_group) {
#if CONFIG_EC_ADAPT
FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
#elif CONFIG_EC_MULTISYMBOL
FRAME_CONTEXT *ec_ctx = cm->fc;
#endif
const PREDICTION_MODE y_mode =
#if CONFIG_EC_MULTISYMBOL
read_intra_mode(r, cm->fc->y_mode_cdf[size_group]);
read_intra_mode(r, ec_ctx->y_mode_cdf[size_group]);
#else
read_intra_mode(r, cm->fc->y_mode_prob[size_group]);
#endif
FRAME_COUNTS *counts = xd->counts;
#if CONFIG_EC_ADAPT
(void)cm;
#endif
if (counts) ++counts->y_mode[size_group][y_mode];
return y_mode;
}
......@@ -110,13 +119,22 @@ static PREDICTION_MODE read_intra_mode_y(AV1_COMMON *cm, MACROBLOCKD *xd,
static PREDICTION_MODE read_intra_mode_uv(AV1_COMMON *cm, MACROBLOCKD *xd,
aom_reader *r,
PREDICTION_MODE y_mode) {
#if CONFIG_EC_ADAPT
FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
#elif CONFIG_EC_MULTISYMBOL
FRAME_CONTEXT *ec_ctx = cm->fc;
#endif
const PREDICTION_MODE uv_mode =
#if CONFIG_EC_MULTISYMBOL
read_intra_mode(r, cm->fc->uv_mode_cdf[y_mode]);
read_intra_mode(r, ec_ctx->uv_mode_cdf[y_mode]);
#else
read_intra_mode(r, cm->fc->uv_mode_prob[y_mode]);
#endif
FRAME_COUNTS *counts = xd->counts;
#if CONFIG_EC_ADAPT
(void)cm;
#endif
if (counts) ++counts->uv_mode[y_mode][uv_mode];
return uv_mode;
}
......@@ -789,6 +807,11 @@ static void read_intra_frame_mode_info(AV1_COMMON *const cm,
// TODO(slavarnway): move x_mis, y_mis into xd ?????
const int x_mis = AOMMIN(cm->mi_cols - mi_col, bw);
const int y_mis = AOMMIN(cm->mi_rows - mi_row, bh);
#if CONFIG_EC_ADAPT
FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
#elif CONFIG_EC_MULTISYMBOL
FRAME_CONTEXT *ec_ctx = cm->fc;
#endif
mbmi->segment_id = read_intra_segment_id(cm, xd, mi_offset, x_mis, y_mis, r);
mbmi->skip = read_skip(cm, xd, mbmi->segment_id, r);
......@@ -810,7 +833,7 @@ static void read_intra_frame_mode_info(AV1_COMMON *const cm,
(void)i;
mbmi->mode =
#if CONFIG_EC_MULTISYMBOL
read_intra_mode(r, get_y_mode_cdf(cm, mi, above_mi, left_mi, 0));
read_intra_mode(r, get_y_mode_cdf(ec_ctx, mi, above_mi, left_mi, 0));
#else
read_intra_mode(r, get_y_mode_probs(cm, mi, above_mi, left_mi, 0));
#endif
......@@ -820,7 +843,8 @@ static void read_intra_frame_mode_info(AV1_COMMON *const cm,
for (i = 0; i < 4; ++i)
mi->bmi[i].as_mode =
#if CONFIG_EC_MULTISYMBOL
read_intra_mode(r, get_y_mode_cdf(cm, mi, above_mi, left_mi, i));
read_intra_mode(r,
get_y_mode_cdf(ec_ctx, mi, above_mi, left_mi, i));
#else
read_intra_mode(r, get_y_mode_probs(cm, mi, above_mi, left_mi, i));
#endif
......@@ -829,13 +853,13 @@ static void read_intra_frame_mode_info(AV1_COMMON *const cm,
case BLOCK_4X8:
mi->bmi[0].as_mode = mi->bmi[2].as_mode =
#if CONFIG_EC_MULTISYMBOL
read_intra_mode(r, get_y_mode_cdf(cm, mi, above_mi, left_mi, 0));
read_intra_mode(r, get_y_mode_cdf(ec_ctx, mi, above_mi, left_mi, 0));
#else
read_intra_mode(r, get_y_mode_probs(cm, mi, above_mi, left_mi, 0));
#endif
mi->bmi[1].as_mode = mi->bmi[3].as_mode = mbmi->mode =
#if CONFIG_EC_MULTISYMBOL
read_intra_mode(r, get_y_mode_cdf(cm, mi, above_mi, left_mi, 1));
read_intra_mode(r, get_y_mode_cdf(ec_ctx, mi, above_mi, left_mi, 1));
#else
read_intra_mode(r, get_y_mode_probs(cm, mi, above_mi, left_mi, 1));
#endif
......@@ -843,13 +867,13 @@ static void read_intra_frame_mode_info(AV1_COMMON *const cm,
case BLOCK_8X4:
mi->bmi[0].as_mode = mi->bmi[1].as_mode =
#if CONFIG_EC_MULTISYMBOL
read_intra_mode(r, get_y_mode_cdf(cm, mi, above_mi, left_mi, 0));
read_intra_mode(r, get_y_mode_cdf(ec_ctx, mi, above_mi, left_mi, 0));
#else
read_intra_mode(r, get_y_mode_probs(cm, mi, above_mi, left_mi, 0));
#endif
mi->bmi[2].as_mode = mi->bmi[3].as_mode = mbmi->mode =
#if CONFIG_EC_MULTISYMBOL
read_intra_mode(r, get_y_mode_cdf(cm, mi, above_mi, left_mi, 2));
read_intra_mode(r, get_y_mode_cdf(ec_ctx, mi, above_mi, left_mi, 2));
#else
read_intra_mode(r, get_y_mode_probs(cm, mi, above_mi, left_mi, 2));
#endif
......@@ -857,7 +881,7 @@ static void read_intra_frame_mode_info(AV1_COMMON *const cm,
default:
mbmi->mode =
#if CONFIG_EC_MULTISYMBOL
read_intra_mode(r, get_y_mode_cdf(cm, mi, above_mi, left_mi, 0));
read_intra_mode(r, get_y_mode_cdf(ec_ctx, mi, above_mi, left_mi, 0));
#else
read_intra_mode(r, get_y_mode_probs(cm, mi, above_mi, left_mi, 0));
#endif
......
......@@ -66,6 +66,9 @@ typedef struct TileWorkerData {
/* forward transformed predicted image, a reference for PVQ */
DECLARE_ALIGNED(16, tran_low_t, pvq_ref_coeff[OD_TXSIZE_MAX * OD_TXSIZE_MAX]);
#endif
#if CONFIG_EC_ADAPT
FRAME_CONTEXT tctx;
#endif
#if CONFIG_PALETTE
DECLARE_ALIGNED(16, uint8_t, color_index_map[2][MAX_SB_SQUARE]);
#endif // CONFIG_PALETTE
......
......@@ -1354,7 +1354,7 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const MODE_INFO *mi,
if (bsize >= BLOCK_8X8 || unify_bsize) {
#if CONFIG_EC_MULTISYMBOL
aom_write_symbol(w, av1_intra_mode_ind[mode],
cm->fc->y_mode_cdf[size_group_lookup[bsize]],
ec_ctx->y_mode_cdf[size_group_lookup[bsize]],
INTRA_MODES);
#else
write_intra_mode(w, mode, cm->fc->y_mode_prob[size_group_lookup[bsize]]);
......@@ -1367,7 +1367,7 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const MODE_INFO *mi,
for (idx = 0; idx < 2; idx += num_4x4_w) {
const PREDICTION_MODE b_mode = mi->bmi[idy * 2 + idx].as_mode;
#if CONFIG_EC_MULTISYMBOL
aom_write_symbol(w, av1_intra_mode_ind[b_mode], cm->fc->y_mode_cdf[0],
aom_write_symbol(w, av1_intra_mode_ind[b_mode], ec_ctx->y_mode_cdf[0],
INTRA_MODES);
#else
write_intra_mode(w, b_mode, cm->fc->y_mode_prob[0]);
......@@ -1377,7 +1377,7 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const MODE_INFO *mi,
}
#if CONFIG_EC_MULTISYMBOL
aom_write_symbol(w, av1_intra_mode_ind[mbmi->uv_mode],
cm->fc->uv_mode_cdf[mode], INTRA_MODES);
ec_ctx->uv_mode_cdf[mode], INTRA_MODES);
#else
write_intra_mode(w, mbmi->uv_mode, cm->fc->uv_mode_prob[mode]);
#endif
......@@ -1681,6 +1681,12 @@ static void write_mb_modes_kf(AV1_COMMON *cm, const MACROBLOCKD *xd,
const int unify_bsize = 0;
#endif
#if CONFIG_EC_ADAPT
FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
#elif CONFIG_EC_MULTISYMBOL
FRAME_CONTEXT *ec_ctx = cm->fc;
#endif
if (seg->update_map) write_segment_id(w, seg, segp, mbmi->segment_id);
#if CONFIG_DELTA_Q
......@@ -1707,7 +1713,8 @@ static void write_mb_modes_kf(AV1_COMMON *cm, const MACROBLOCKD *xd,
if (bsize >= BLOCK_8X8 || unify_bsize) {
#if CONFIG_EC_MULTISYMBOL
aom_write_symbol(w, av1_intra_mode_ind[mbmi->mode],
get_y_mode_cdf(cm, mi, above_mi, left_mi, 0), INTRA_MODES);
get_y_mode_cdf(ec_ctx, mi, above_mi, left_mi, 0),
INTRA_MODES);
#else
write_intra_mode(w, mbmi->mode,
get_y_mode_probs(cm, mi, above_mi, left_mi, 0));
......@@ -1722,7 +1729,7 @@ static void write_mb_modes_kf(AV1_COMMON *cm, const MACROBLOCKD *xd,
const int block = idy * 2 + idx;
#if CONFIG_EC_MULTISYMBOL
aom_write_symbol(w, av1_intra_mode_ind[mi->bmi[block].as_mode],
get_y_mode_cdf(cm, mi, above_mi, left_mi, block),
get_y_mode_cdf(ec_ctx, mi, above_mi, left_mi, block),
INTRA_MODES);
#else
write_intra_mode(w, mi->bmi[block].as_mode,
......@@ -1733,7 +1740,7 @@ static void write_mb_modes_kf(AV1_COMMON *cm, const MACROBLOCKD *xd,
}
#if CONFIG_EC_MULTISYMBOL
aom_write_symbol(w, av1_intra_mode_ind[mbmi->uv_mode],
cm->fc->uv_mode_cdf[mbmi->mode], INTRA_MODES);
ec_ctx->uv_mode_cdf[mbmi->mode], INTRA_MODES);
#else
write_intra_mode(w, mbmi->uv_mode, cm->fc->uv_mode_prob[mbmi->mode]);
#endif
......@@ -4461,7 +4468,7 @@ static uint32_t write_compressed_header(AV1_COMP *cpi, uint8_t *data) {
if (frame_is_intra_only(cm)) {
av1_copy(cm->kf_y_prob, av1_kf_y_mode_prob);
#if CONFIG_EC_MULTISYMBOL
av1_copy(cm->kf_y_cdf, av1_kf_y_mode_cdf);
av1_copy(cm->fc->kf_y_cdf, av1_kf_y_mode_cdf);
#endif
#if !CONFIG_EC_ADAPT
......
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