Commit f627e58e authored by Nathan E. Egge's avatar Nathan E. Egge Committed by Yaowu Xu

Update segment tree_cdf per frame.

Move computing the segmentation_probs.tree_cdf table per symbol to
 computing it only when the probabilities are updated.

Change-Id: I3826418094bbaca4ded87de5ff04d4b27c85e35a
parent d7baf45f
......@@ -1325,9 +1325,14 @@ static const aom_prob default_supertx_prob[PARTITION_SUPERTX_CONTEXTS]
#endif // CONFIG_SUPERTX
// FIXME(someone) need real defaults here
static const struct segmentation_probs default_seg_probs = {
{ 128, 128, 128, 128, 128, 128, 128 }, { 128, 128, 128 },
static const aom_prob default_segment_tree_probs[SEG_TREE_PROBS] = {
128, 128, 128, 128, 128, 128, 128
};
// clang-format off
static const aom_prob default_segment_pred_probs[PREDICTION_PROBS] = {
128, 128, 128
};
// clang-format on
static void init_mode_probs(FRAME_CONTEXT *fc) {
av1_copy(fc->uv_mode_prob, default_uv_probs);
......@@ -1372,8 +1377,8 @@ static void init_mode_probs(FRAME_CONTEXT *fc) {
#if CONFIG_SUPERTX
av1_copy(fc->supertx_prob, default_supertx_prob);
#endif // CONFIG_SUPERTX
av1_copy(fc->seg.tree_probs, default_seg_probs.tree_probs);
av1_copy(fc->seg.pred_probs, default_seg_probs.pred_probs);
av1_copy(fc->seg.tree_probs, default_segment_tree_probs);
av1_copy(fc->seg.pred_probs, default_segment_pred_probs);
#if CONFIG_EXT_INTRA
av1_copy(fc->ext_intra_probs, default_ext_intra_probs);
av1_copy(fc->intra_filter_probs, default_intra_filter_probs);
......@@ -1392,6 +1397,7 @@ static void init_mode_probs(FRAME_CONTEXT *fc) {
fc->inter_ext_tx_cdf, EXT_TX_SIZES);
av1_tree_to_cdf_1D(av1_partition_tree, fc->partition_prob, fc->partition_cdf,
PARTITION_CONTEXTS);
av1_tree_to_cdf(av1_segment_tree, fc->seg.tree_probs, fc->seg.tree_cdf);
#endif
}
......
......@@ -48,6 +48,9 @@ struct segmentation {
struct segmentation_probs {
aom_prob tree_probs[SEG_TREE_PROBS];
#if CONFIG_DAALA_EC
aom_cdf_prob tree_cdf[MAX_SEGMENTS];
#endif
aom_prob pred_probs[PREDICTION_PROBS];
};
......
......@@ -3672,6 +3672,10 @@ static int read_compressed_header(AV1Decoder *pbi, const uint8_t *data,
}
for (k = 0; k < MAX_SEGMENTS - 1; k++)
av1_diff_update_prob(&r, &cm->fc->seg.tree_probs[k]);
#if CONFIG_DAALA_EC
av1_tree_to_cdf(av1_segment_tree, cm->fc->seg.tree_probs,
cm->fc->seg.tree_cdf);
#endif
}
for (j = 0; j < INTRA_MODES; j++)
......
......@@ -207,7 +207,11 @@ static PREDICTION_MODE read_inter_compound_mode(AV1_COMMON *cm, MACROBLOCKD *xd,
static int read_segment_id(aom_reader *r,
const struct segmentation_probs *segp) {
#if CONFIG_DAALA_EC
return aom_read_symbol(r, segp->tree_cdf, MAX_SEGMENTS);
#else
return aom_read_tree(r, av1_segment_tree, segp->tree_probs);
#endif
}
#if CONFIG_VAR_TX
......
......@@ -807,8 +807,13 @@ static void pack_txb_tokens(aom_writer *w, const TOKENEXTRA **tp,
static void write_segment_id(aom_writer *w, const struct segmentation *seg,
const struct segmentation_probs *segp,
int segment_id) {
if (seg->enabled && seg->update_map)
if (seg->enabled && seg->update_map) {
#if CONFIG_DAALA_EC
aom_write_symbol(w, segment_id, segp->tree_cdf, MAX_SEGMENTS);
#else
aom_write_tree(w, av1_segment_tree, segp->tree_probs, segment_id, 3, 0);
#endif
}
}
// This function encodes the reference frame
......@@ -2739,6 +2744,10 @@ static void update_seg_probs(AV1_COMP *cpi, aom_writer *w) {
prob_diff_update(av1_segment_tree, cm->fc->seg.tree_probs,
cm->counts.seg.tree_total, MAX_SEGMENTS, w);
}
#if CONFIG_DAALA_EC
av1_tree_to_cdf(av1_segment_tree, cm->fc->seg.tree_probs,
cm->fc->seg.tree_cdf);
#endif
}
static void write_txfm_mode(TX_MODE mode, struct aom_write_bit_buffer *wb) {
......
......@@ -366,6 +366,9 @@ void av1_choose_segmap_coding_method(AV1_COMMON *cm, MACROBLOCKD *xd) {
} else {
seg->temporal_update = 0;
}
#if CONFIG_DAALA_EC
av1_tree_to_cdf(av1_segment_tree, segp->tree_probs, segp->tree_cdf);
#endif
}
void av1_reset_segment_features(AV1_COMMON *cm) {
......
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