Commit e1f9e33d authored by Nathan E. Egge's avatar Nathan E. Egge Committed by Nathan Egge

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 ef446026
......@@ -789,9 +789,14 @@ static const aom_prob default_switchable_interp_prob
#if CONFIG_MISC_FIXES
// 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
#endif
const aom_tree_index av1_ext_tx_tree[TREE_SIZE(TX_TYPES)] = {
......@@ -839,8 +844,8 @@ static void init_mode_probs(FRAME_CONTEXT *fc) {
av1_copy(fc->motion_mode_prob, default_motion_mode_prob);
#endif // CONFIG_MOTION_VAR
#if CONFIG_MISC_FIXES
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);
#endif
av1_copy(fc->intra_ext_tx_prob, default_intra_ext_tx_prob);
av1_copy(fc->inter_ext_tx_prob, default_inter_ext_tx_prob);
......@@ -853,6 +858,9 @@ 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);
#if CONFIG_MISC_FIXES
av1_tree_to_cdf(av1_segment_tree, fc->seg.tree_probs, fc->seg.tree_cdf);
#endif
#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];
};
......
......@@ -755,9 +755,13 @@ static void setup_segmentation(AV1_COMMON *const cm,
}
if (seg->update_map) {
#if !CONFIG_MISC_FIXES
for (i = 0; i < SEG_TREE_PROBS; i++)
for (i = 0; i < SEG_TREE_PROBS; i++) {
segp->tree_probs[i] =
aom_rb_read_bit(rb) ? aom_rb_read_literal(rb, 8) : MAX_PROB;
}
#if CONFIG_DAALA_EC
av1_tree_to_cdf(av1_segment_tree, segp->tree_probs, segp->tree_cdf);
#endif
#endif
if (frame_is_intra_only(cm) || cm->error_resilient_mode) {
seg->temporal_update = 0;
......@@ -2007,6 +2011,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++)
......
......@@ -163,7 +163,11 @@ static MOTION_MODE read_motion_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
}
static TX_SIZE read_selected_tx_size(AV1_COMMON *cm, MACROBLOCKD *xd,
......
......@@ -482,8 +482,13 @@ static void pack_mb_tokens(aom_writer *w, 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
......@@ -1430,6 +1435,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) {
......
......@@ -304,6 +304,9 @@ void av1_choose_segmap_coding_method(AV1_COMMON *cm, MACROBLOCKD *xd) {
memcpy(segp->tree_probs, no_pred_tree, sizeof(no_pred_tree));
#endif
}
#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