Commit 00021354 authored by Thomas Davies's avatar Thomas Davies

NEW_MULTISYMBOL: add CDF for segment_id prediction.

With aq-mode=1 (which forces segmentation), AWCY
gives -0.12% (objective-1-fast, cpu-used=4,
NEW_MULTISYMBOL on for reference and tested).

No change to baseline metrics, with or without
NEW_MULTISYMBOL.

Change-Id: I841a9e8978598402dacfbca9265269163f7440c0
parent 7eab9ff1
......@@ -5657,6 +5657,9 @@ void av1_average_tile_intra_cdfs(FRAME_CONTEXT *fc, FRAME_CONTEXT *ec_ctxs[],
AVERAGE_TILE_CDFS(inter_ext_tx_cdf)
AVERAGE_TILE_CDFS(seg.tree_cdf)
#if CONFIG_NEW_MULTISYMBOL
AVERAGE_TILE_CDFS(seg.pred_cdf)
#endif
AVERAGE_TILE_CDFS(uv_mode_cdf)
AVERAGE_TILE_CDFS(partition_cdf)
......
......@@ -2509,6 +2509,14 @@ static const aom_prob default_segment_tree_probs[SEG_TREE_PROBS] = {
static const aom_prob default_segment_pred_probs[PREDICTION_PROBS] = {
128, 128, 128
};
#if CONFIG_NEW_MULTISYMBOL
static const aom_cdf_prob
default_segment_pred_cdf[PREDICTION_PROBS][CDF_SIZE(2)] = {
{ AOM_ICDF(128 * 128), AOM_ICDF(32768), 0},
{ AOM_ICDF(128 * 128), AOM_ICDF(32768), 0},
{ AOM_ICDF(128 * 128), AOM_ICDF(32768), 0}
};
#endif
// clang-format on
#if CONFIG_DUAL_FILTER
......@@ -4860,6 +4868,9 @@ static void init_mode_probs(FRAME_CONTEXT *fc) {
#endif // CONFIG_SUPERTX
av1_copy(fc->seg.tree_probs, default_segment_tree_probs);
av1_copy(fc->seg.pred_probs, default_segment_pred_probs);
#if CONFIG_NEW_MULTISYMBOL
av1_copy(fc->seg.pred_cdf, default_segment_pred_cdf);
#endif
#if CONFIG_EXT_INTRA
#if CONFIG_INTRA_INTERP
av1_copy(fc->intra_filter_probs, default_intra_filter_probs);
......
......@@ -54,6 +54,13 @@ static INLINE aom_prob av1_get_pred_prob_seg_id(
return segp->pred_probs[av1_get_pred_context_seg_id(xd)];
}
#if CONFIG_NEW_MULTISYMBOL
static INLINE aom_cdf_prob *av1_get_pred_cdf_seg_id(
struct segmentation_probs *segp, const MACROBLOCKD *xd) {
return segp->pred_cdf[av1_get_pred_context_seg_id(xd)];
}
#endif
static INLINE int av1_get_skip_context(const MACROBLOCKD *xd) {
const MODE_INFO *const above_mi = xd->above_mi;
const MODE_INFO *const left_mi = xd->left_mi;
......
......@@ -50,6 +50,9 @@ struct segmentation_probs {
aom_prob tree_probs[SEG_TREE_PROBS];
aom_cdf_prob tree_cdf[CDF_SIZE(MAX_SEGMENTS)];
aom_prob pred_probs[PREDICTION_PROBS];
#if CONFIG_NEW_MULTISYMBOL
aom_cdf_prob pred_cdf[PREDICTION_PROBS][CDF_SIZE(2)];
#endif
};
static INLINE int segfeature_active(const struct segmentation *seg,
......
......@@ -661,8 +661,13 @@ static int read_inter_segment_id(AV1_COMMON *const cm, MACROBLOCKD *const xd,
if (seg->temporal_update) {
const int ctx = av1_get_pred_context_seg_id(xd);
#if CONFIG_NEW_MULTISYMBOL
aom_cdf_prob *pred_cdf = segp->pred_cdf[ctx];
mbmi->seg_id_predicted = aom_read_symbol(r, pred_cdf, 2, ACCT_STR);
#else
const aom_prob pred_prob = segp->pred_probs[ctx];
mbmi->seg_id_predicted = aom_read(r, pred_prob, ACCT_STR);
#endif
if (counts) ++counts->seg.pred[ctx][mbmi->seg_id_predicted];
if (mbmi->seg_id_predicted) {
segment_id = predicted_segment_id;
......
......@@ -1708,8 +1708,13 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const int mi_row,
if (seg->update_map) {
if (seg->temporal_update) {
const int pred_flag = mbmi->seg_id_predicted;
#if CONFIG_NEW_MULTISYMBOL
aom_cdf_prob *pred_cdf = av1_get_pred_cdf_seg_id(segp, xd);
aom_write_symbol(w, pred_flag, pred_cdf, 2);
#else
aom_prob pred_prob = av1_get_pred_prob_seg_id(segp, xd);
aom_write(w, pred_flag, pred_prob);
#endif
if (!pred_flag) write_segment_id(w, seg, segp, segment_id);
} else {
write_segment_id(w, seg, segp, segment_id);
......
......@@ -299,7 +299,7 @@ void av1_choose_segmap_coding_method(AV1_COMMON *cm, MACROBLOCKD *xd) {
int no_pred_cost;
int t_pred_cost = INT_MAX;
int i, tile_col, tile_row, mi_row, mi_col;
int tile_col, tile_row, mi_row, mi_col;
#if CONFIG_TILE_GROUPS
const int probwt = cm->num_tg;
#else
......@@ -312,7 +312,9 @@ void av1_choose_segmap_coding_method(AV1_COMMON *cm, MACROBLOCKD *xd) {
aom_prob no_pred_tree[SEG_TREE_PROBS];
aom_prob t_pred_tree[SEG_TREE_PROBS];
#if !CONFIG_NEW_MULTISYMBOL
aom_prob t_nopred_prob[PREDICTION_PROBS];
#endif
(void)xd;
......@@ -357,8 +359,9 @@ void av1_choose_segmap_coding_method(AV1_COMMON *cm, MACROBLOCKD *xd) {
calc_segtree_probs(t_unpred_seg_counts, t_pred_tree, segp->tree_probs,
probwt);
t_pred_cost = cost_segmap(t_unpred_seg_counts, t_pred_tree);
#if !CONFIG_NEW_MULTISYMBOL
// Add in the cost of the signaling for each prediction context.
int i;
for (i = 0; i < PREDICTION_PROBS; i++) {
const int count0 = temporal_predictor_count[i][0];
const int count1 = temporal_predictor_count[i][1];
......@@ -372,6 +375,7 @@ void av1_choose_segmap_coding_method(AV1_COMMON *cm, MACROBLOCKD *xd) {
t_pred_cost += count0 * av1_cost_zero(t_nopred_prob[i]) +
count1 * av1_cost_one(t_nopred_prob[i]);
}
#endif
}
// Now choose which coding method to use.
......
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