Commit 879d341b authored by Nathan E. Egge's avatar Nathan E. Egge Committed by Nathan Egge

Update uv_mode_cdf tables once per frame.

Move computing the uv_mode_cdf tables per coded intra mode symbol to
 computing them only when the probabilities are updated.

Change-Id: I627b59d30726c913f5d7ba7753cb0446a12655bb
parent 7b8ac4f5
......@@ -868,6 +868,8 @@ static void init_mode_probs(FRAME_CONTEXT *fc) {
#if CONFIG_DAALA_EC
av1_tree_to_cdf_1D(av1_intra_mode_tree, fc->y_mode_prob, fc->y_mode_cdf,
BLOCK_SIZE_GROUPS);
av1_tree_to_cdf_1D(av1_intra_mode_tree, fc->uv_mode_prob, fc->uv_mode_cdf,
INTRA_MODES);
av1_tree_to_cdf_1D(av1_switchable_interp_tree, fc->switchable_interp_prob,
fc->switchable_interp_cdf, SWITCHABLE_FILTER_CONTEXTS);
av1_tree_to_cdf_2D(av1_ext_tx_tree, fc->intra_ext_tx_prob,
......
......@@ -104,6 +104,7 @@ typedef struct frame_contexts {
int initialized;
#if CONFIG_DAALA_EC
aom_cdf_prob y_mode_cdf[BLOCK_SIZE_GROUPS][INTRA_MODES];
aom_cdf_prob uv_mode_cdf[INTRA_MODES][INTRA_MODES];
aom_cdf_prob partition_cdf[PARTITION_CONTEXTS][PARTITION_TYPES];
aom_cdf_prob
switchable_interp_cdf[SWITCHABLE_FILTER_CONTEXTS][SWITCHABLE_FILTERS];
......
......@@ -2036,9 +2036,14 @@ static int read_compressed_header(AV1Decoder *pbi, const uint8_t *data,
#endif
}
for (j = 0; j < INTRA_MODES; j++)
for (j = 0; j < INTRA_MODES; j++) {
for (i = 0; i < INTRA_MODES - 1; ++i)
av1_diff_update_prob(&r, &fc->uv_mode_prob[j][i], ACCT_STR);
#if CONFIG_DAALA_EC
av1_tree_to_cdf(av1_intra_mode_tree, fc->uv_mode_prob[j],
fc->uv_mode_cdf[j]);
#endif
}
for (j = 0; j < PARTITION_CONTEXTS; ++j) {
for (i = 0; i < PARTITION_TYPES - 1; ++i)
......
......@@ -28,21 +28,21 @@
#define ACCT_STR __func__
#if CONFIG_DAALA_EC
static PREDICTION_MODE read_intra_mode_cdf(aom_reader *r,
const aom_cdf_prob *cdf) {
static PREDICTION_MODE read_intra_mode(aom_reader *r, const aom_cdf_prob *cdf) {
return (PREDICTION_MODE)
av1_intra_mode_inv[aom_read_symbol(r, cdf, INTRA_MODES, ACCT_STR)];
}
#endif
#else
static PREDICTION_MODE read_intra_mode(aom_reader *r, const aom_prob *p) {
return (PREDICTION_MODE)aom_read_tree(r, av1_intra_mode_tree, p, ACCT_STR);
}
#endif
static PREDICTION_MODE read_intra_mode_y(AV1_COMMON *cm, MACROBLOCKD *xd,
aom_reader *r, int size_group) {
const PREDICTION_MODE y_mode =
#if CONFIG_DAALA_EC
read_intra_mode_cdf(r, cm->fc->y_mode_cdf[size_group]);
read_intra_mode(r, cm->fc->y_mode_cdf[size_group]);
#else
read_intra_mode(r, cm->fc->y_mode_prob[size_group]);
#endif
......@@ -55,7 +55,11 @@ static PREDICTION_MODE read_intra_mode_uv(AV1_COMMON *cm, MACROBLOCKD *xd,
aom_reader *r,
PREDICTION_MODE y_mode) {
const PREDICTION_MODE uv_mode =
#if CONFIG_DAALA_EC
read_intra_mode(r, cm->fc->uv_mode_cdf[y_mode]);
#else
read_intra_mode(r, cm->fc->uv_mode_prob[y_mode]);
#endif
FRAME_COUNTS *counts = xd->counts;
if (counts) ++counts->uv_mode[y_mode][uv_mode];
return uv_mode;
......@@ -459,8 +463,7 @@ static void read_intra_frame_mode_info(AV1_COMMON *const cm,
for (i = 0; i < 4; ++i)
mi->bmi[i].as_mode =
#if CONFIG_DAALA_EC
read_intra_mode_cdf(r,
get_y_mode_cdf(cm, mi, above_mi, left_mi, i));
read_intra_mode(r, get_y_mode_cdf(cm, mi, above_mi, left_mi, i));
#else
read_intra_mode(r, get_y_mode_probs(cm, mi, above_mi, left_mi, i));
#endif
......@@ -469,13 +472,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_DAALA_EC
read_intra_mode_cdf(r, get_y_mode_cdf(cm, mi, above_mi, left_mi, 0));
read_intra_mode(r, get_y_mode_cdf(cm, 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_DAALA_EC
read_intra_mode_cdf(r, get_y_mode_cdf(cm, mi, above_mi, left_mi, 1));
read_intra_mode(r, get_y_mode_cdf(cm, mi, above_mi, left_mi, 1));
#else
read_intra_mode(r, get_y_mode_probs(cm, mi, above_mi, left_mi, 1));
#endif
......@@ -483,13 +486,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_DAALA_EC
read_intra_mode_cdf(r, get_y_mode_cdf(cm, mi, above_mi, left_mi, 0));
read_intra_mode(r, get_y_mode_cdf(cm, 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_DAALA_EC
read_intra_mode_cdf(r, get_y_mode_cdf(cm, mi, above_mi, left_mi, 2));
read_intra_mode(r, get_y_mode_cdf(cm, mi, above_mi, left_mi, 2));
#else
read_intra_mode(r, get_y_mode_probs(cm, mi, above_mi, left_mi, 2));
#endif
......@@ -497,7 +500,7 @@ static void read_intra_frame_mode_info(AV1_COMMON *const cm,
default:
mbmi->mode =
#if CONFIG_DAALA_EC
read_intra_mode_cdf(r, get_y_mode_cdf(cm, mi, above_mi, left_mi, 0));
read_intra_mode(r, get_y_mode_cdf(cm, mi, above_mi, left_mi, 0));
#else
read_intra_mode(r, get_y_mode_probs(cm, mi, above_mi, left_mi, 0));
#endif
......
......@@ -116,10 +116,12 @@ void av1_encode_token_init() {
#endif
}
#if !CONFIG_DAALA_EC
static void write_intra_mode(aom_writer *w, PREDICTION_MODE mode,
const aom_prob *probs) {
av1_write_token(w, av1_intra_mode_tree, probs, &intra_mode_encodings[mode]);
}
#endif
static void write_inter_mode(AV1_COMMON *cm, aom_writer *w,
PREDICTION_MODE mode, const int16_t mode_ctx) {
......@@ -745,7 +747,12 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const MODE_INFO *mi,
}
}
}
#if CONFIG_DAALA_EC
aom_write_symbol(w, av1_intra_mode_ind[mbmi->uv_mode],
cm->fc->uv_mode_cdf[mode], INTRA_MODES);
#else
write_intra_mode(w, mbmi->uv_mode, cm->fc->uv_mode_prob[mode]);
#endif
#if CONFIG_EXT_INTRA
write_intra_angle_info(mbmi, w);
#endif // CONFIG_EXT_INTRA
......@@ -912,8 +919,12 @@ static void write_mb_modes_kf(const AV1_COMMON *cm, const MACROBLOCKD *xd,
}
}
}
#if CONFIG_DAALA_EC
aom_write_symbol(w, av1_intra_mode_ind[mbmi->uv_mode],
cm->fc->uv_mode_cdf[mbmi->mode], INTRA_MODES);
#else
write_intra_mode(w, mbmi->uv_mode, cm->fc->uv_mode_prob[mbmi->mode]);
#endif
#if CONFIG_EXT_INTRA
write_intra_angle_info(mbmi, w);
#endif // CONFIG_EXT_INTRA
......@@ -1976,9 +1987,14 @@ static size_t write_compressed_header(AV1_COMP *cpi, uint8_t *data) {
#if CONFIG_MISC_FIXES
update_seg_probs(cpi, header_bc);
for (i = 0; i < INTRA_MODES; ++i)
for (i = 0; i < INTRA_MODES; ++i) {
prob_diff_update(av1_intra_mode_tree, fc->uv_mode_prob[i],
counts->uv_mode[i], INTRA_MODES, header_bc);
#if CONFIG_DAALA_EC
av1_tree_to_cdf(av1_intra_mode_tree, fc->uv_mode_prob[i],
fc->uv_mode_cdf[i]);
#endif
}
for (i = 0; i < PARTITION_CONTEXTS; ++i) {
prob_diff_update(av1_partition_tree, fc->partition_prob[i],
......
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