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

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 5710c722
......@@ -1413,6 +1413,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,
......
......@@ -166,6 +166,7 @@ typedef struct frame_contexts {
#endif // CONFIG_LOOP_RESTORATION
#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];
......
......@@ -3725,9 +3725,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
}
#if CONFIG_EXT_PARTITION_TYPES
for (i = 0; i < PARTITION_TYPES - 1; ++i)
......
......@@ -42,15 +42,15 @@ static INLINE int read_uniform(aom_reader *r, int n) {
#endif // CONFIG_EXT_INTRA || CONFIG_FILTER_INTRA || CONFIG_PALETTE
#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
#if CONFIG_DELTA_Q
static int read_delta_qindex(AV1_COMMON *cm, MACROBLOCKD *xd, aom_reader *r,
......@@ -92,7 +92,7 @@ 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
......@@ -105,7 +105,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;
......@@ -668,8 +672,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
......@@ -678,13 +681,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
......@@ -692,13 +695,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
......@@ -706,7 +709,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
......
......@@ -197,10 +197,12 @@ void av1_encode_token_init(void) {
#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
#if CONFIG_EXT_INTER
static void write_interintra_mode(aom_writer *w, INTERINTRA_MODE mode,
......@@ -1258,7 +1260,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(cm, xd, w);
#endif // CONFIG_EXT_INTRA
......@@ -1661,8 +1668,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(cm, xd, w);
#endif // CONFIG_EXT_INTRA
......@@ -3616,9 +3627,14 @@ static uint32_t write_compressed_header(AV1_COMP *cpi, uint8_t *data) {
#endif
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
}
#if CONFIG_EXT_PARTITION_TYPES
prob_diff_update(av1_partition_tree, fc->partition_prob[0],
......
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