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

Update partition_cdf per frame.

Move computing the partition_cdf tables per symbol to
 computing them only when the probabilities are updated.

Change-Id: I442f9230ba00be7f5d0558d7c38d7324ad009ee8
parent 73845731
...@@ -406,6 +406,8 @@ static void init_mode_probs(FRAME_CONTEXT *fc) { ...@@ -406,6 +406,8 @@ static void init_mode_probs(FRAME_CONTEXT *fc) {
fc->intra_ext_tx_cdf, EXT_TX_SIZES, TX_TYPES); fc->intra_ext_tx_cdf, EXT_TX_SIZES, TX_TYPES);
av1_tree_to_cdf_1D(av1_ext_tx_tree, fc->inter_ext_tx_prob, av1_tree_to_cdf_1D(av1_ext_tx_tree, fc->inter_ext_tx_prob,
fc->inter_ext_tx_cdf, EXT_TX_SIZES); fc->inter_ext_tx_cdf, EXT_TX_SIZES);
av1_tree_to_cdf_1D(av1_partition_tree, fc->partition_prob, fc->partition_cdf,
PARTITION_CONTEXTS);
#endif #endif
} }
...@@ -497,9 +499,14 @@ void av1_adapt_inter_frame_probs(AV1_COMMON *cm) { ...@@ -497,9 +499,14 @@ void av1_adapt_inter_frame_probs(AV1_COMMON *cm) {
aom_tree_merge_probs(av1_intra_mode_tree, pre_fc->uv_mode_prob[i], aom_tree_merge_probs(av1_intra_mode_tree, pre_fc->uv_mode_prob[i],
counts->uv_mode[i], fc->uv_mode_prob[i]); counts->uv_mode[i], fc->uv_mode_prob[i]);
for (i = 0; i < PARTITION_CONTEXTS; i++) for (i = 0; i < PARTITION_CONTEXTS; i++) {
aom_tree_merge_probs(av1_partition_tree, pre_fc->partition_prob[i], aom_tree_merge_probs(av1_partition_tree, pre_fc->partition_prob[i],
counts->partition[i], fc->partition_prob[i]); counts->partition[i], fc->partition_prob[i]);
#if CONFIG_DAALA_EC
av1_tree_to_cdf(av1_partition_tree, fc->partition_prob[i],
fc->partition_cdf[i]);
#endif
}
#endif #endif
if (cm->interp_filter == SWITCHABLE) { if (cm->interp_filter == SWITCHABLE) {
...@@ -584,9 +591,14 @@ void av1_adapt_intra_frame_probs(AV1_COMMON *cm) { ...@@ -584,9 +591,14 @@ void av1_adapt_intra_frame_probs(AV1_COMMON *cm) {
aom_tree_merge_probs(av1_intra_mode_tree, pre_fc->uv_mode_prob[i], aom_tree_merge_probs(av1_intra_mode_tree, pre_fc->uv_mode_prob[i],
counts->uv_mode[i], fc->uv_mode_prob[i]); counts->uv_mode[i], fc->uv_mode_prob[i]);
for (i = 0; i < PARTITION_CONTEXTS; i++) for (i = 0; i < PARTITION_CONTEXTS; i++) {
aom_tree_merge_probs(av1_partition_tree, pre_fc->partition_prob[i], aom_tree_merge_probs(av1_partition_tree, pre_fc->partition_prob[i],
counts->partition[i], fc->partition_prob[i]); counts->partition[i], fc->partition_prob[i]);
#if CONFIG_DAALA_EC
av1_tree_to_cdf(av1_partition_tree, fc->partition_prob[i],
fc->partition_cdf[i]);
#endif
}
#endif #endif
} }
......
...@@ -53,6 +53,9 @@ typedef struct frame_contexts { ...@@ -53,6 +53,9 @@ typedef struct frame_contexts {
aom_prob y_mode_prob[BLOCK_SIZE_GROUPS][INTRA_MODES - 1]; aom_prob y_mode_prob[BLOCK_SIZE_GROUPS][INTRA_MODES - 1];
aom_prob uv_mode_prob[INTRA_MODES][INTRA_MODES - 1]; aom_prob uv_mode_prob[INTRA_MODES][INTRA_MODES - 1];
aom_prob partition_prob[PARTITION_CONTEXTS][PARTITION_TYPES - 1]; aom_prob partition_prob[PARTITION_CONTEXTS][PARTITION_TYPES - 1];
#if CONFIG_DAALA_EC
uint16_t partition_cdf[PARTITION_CONTEXTS][PARTITION_TYPES];
#endif
av1_coeff_probs_model coef_probs[TX_SIZES][PLANE_TYPES]; av1_coeff_probs_model coef_probs[TX_SIZES][PLANE_TYPES];
#if CONFIG_RANS #if CONFIG_RANS
coeff_cdf_model coef_cdfs[TX_SIZES][PLANE_TYPES]; coeff_cdf_model coef_cdfs[TX_SIZES][PLANE_TYPES];
......
...@@ -596,7 +596,12 @@ static PARTITION_TYPE read_partition(AV1_COMMON *cm, MACROBLOCKD *xd, ...@@ -596,7 +596,12 @@ static PARTITION_TYPE read_partition(AV1_COMMON *cm, MACROBLOCKD *xd,
PARTITION_TYPE p; PARTITION_TYPE p;
if (has_rows && has_cols) if (has_rows && has_cols)
#if CONFIG_DAALA_EC
p = (PARTITION_TYPE)aom_read_tree_cdf(r, cm->fc->partition_cdf[ctx],
PARTITION_TYPES);
#else
p = (PARTITION_TYPE)aom_read_tree(r, av1_partition_tree, probs); p = (PARTITION_TYPE)aom_read_tree(r, av1_partition_tree, probs);
#endif
else if (!has_rows && has_cols) else if (!has_rows && has_cols)
p = aom_read(r, probs[1]) ? PARTITION_SPLIT : PARTITION_HORZ; p = aom_read(r, probs[1]) ? PARTITION_SPLIT : PARTITION_HORZ;
else if (has_rows && !has_cols) else if (has_rows && !has_cols)
...@@ -1990,9 +1995,14 @@ static int read_compressed_header(AV1Decoder *pbi, const uint8_t *data, ...@@ -1990,9 +1995,14 @@ static int read_compressed_header(AV1Decoder *pbi, const uint8_t *data,
for (i = 0; i < INTRA_MODES - 1; ++i) for (i = 0; i < INTRA_MODES - 1; ++i)
av1_diff_update_prob(&r, &fc->uv_mode_prob[j][i]); av1_diff_update_prob(&r, &fc->uv_mode_prob[j][i]);
for (j = 0; j < PARTITION_CONTEXTS; ++j) for (j = 0; j < PARTITION_CONTEXTS; ++j) {
for (i = 0; i < PARTITION_TYPES - 1; ++i) for (i = 0; i < PARTITION_TYPES - 1; ++i)
av1_diff_update_prob(&r, &fc->partition_prob[j][i]); av1_diff_update_prob(&r, &fc->partition_prob[j][i]);
#if CONFIG_DAALA_EC
av1_tree_to_cdf(av1_partition_tree, fc->partition_prob[j],
fc->partition_cdf[j]);
#endif
}
#endif #endif
if (frame_is_intra_only(cm)) { if (frame_is_intra_only(cm)) {
...@@ -2034,9 +2044,14 @@ static int read_compressed_header(AV1Decoder *pbi, const uint8_t *data, ...@@ -2034,9 +2044,14 @@ static int read_compressed_header(AV1Decoder *pbi, const uint8_t *data,
av1_diff_update_prob(&r, &fc->y_mode_prob[j][i]); av1_diff_update_prob(&r, &fc->y_mode_prob[j][i]);
#if !CONFIG_MISC_FIXES #if !CONFIG_MISC_FIXES
for (j = 0; j < PARTITION_CONTEXTS; ++j) for (j = 0; j < PARTITION_CONTEXTS; ++j) {
for (i = 0; i < PARTITION_TYPES - 1; ++i) for (i = 0; i < PARTITION_TYPES - 1; ++i)
av1_diff_update_prob(&r, &fc->partition_prob[j][i]); av1_diff_update_prob(&r, &fc->partition_prob[j][i]);
#if CONFIG_DAALA_EC
av1_tree_to_cdf(av1_partition_tree, fc->partition_prob[j],
fc->partition_cdf[j]);
#endif
}
#endif #endif
#if CONFIG_REF_MV #if CONFIG_REF_MV
......
...@@ -838,7 +838,11 @@ static void write_partition(const AV1_COMMON *const cm, ...@@ -838,7 +838,11 @@ static void write_partition(const AV1_COMMON *const cm,
const int has_cols = (mi_col + hbs) < cm->mi_cols; const int has_cols = (mi_col + hbs) < cm->mi_cols;
if (has_rows && has_cols) { if (has_rows && has_cols) {
#if CONFIG_DAALA_EC
aom_write_tree_cdf(w, p, cm->fc->partition_cdf[ctx], PARTITION_TYPES);
#else
av1_write_token(w, av1_partition_tree, probs, &partition_encodings[p]); av1_write_token(w, av1_partition_tree, probs, &partition_encodings[p]);
#endif
} else if (!has_rows && has_cols) { } else if (!has_rows && has_cols) {
assert(p == PARTITION_SPLIT || p == PARTITION_HORZ); assert(p == PARTITION_SPLIT || p == PARTITION_HORZ);
aom_write(w, p == PARTITION_SPLIT, probs[1]); aom_write(w, p == PARTITION_SPLIT, probs[1]);
...@@ -1797,9 +1801,14 @@ static size_t write_compressed_header(AV1_COMP *cpi, uint8_t *data) { ...@@ -1797,9 +1801,14 @@ static size_t write_compressed_header(AV1_COMP *cpi, uint8_t *data) {
prob_diff_update(av1_intra_mode_tree, fc->uv_mode_prob[i], prob_diff_update(av1_intra_mode_tree, fc->uv_mode_prob[i],
counts->uv_mode[i], INTRA_MODES, header_bc); counts->uv_mode[i], INTRA_MODES, header_bc);
for (i = 0; i < PARTITION_CONTEXTS; ++i) for (i = 0; i < PARTITION_CONTEXTS; ++i) {
prob_diff_update(av1_partition_tree, fc->partition_prob[i], prob_diff_update(av1_partition_tree, fc->partition_prob[i],
counts->partition[i], PARTITION_TYPES, header_bc); counts->partition[i], PARTITION_TYPES, header_bc);
#if CONFIG_DAALA_EC
av1_tree_to_cdf(av1_partition_tree, cm->fc->partition_prob[i],
cm->fc->partition_cdf[i]);
#endif
}
#endif #endif
if (frame_is_intra_only(cm)) { if (frame_is_intra_only(cm)) {
...@@ -1879,9 +1888,14 @@ static size_t write_compressed_header(AV1_COMP *cpi, uint8_t *data) { ...@@ -1879,9 +1888,14 @@ static size_t write_compressed_header(AV1_COMP *cpi, uint8_t *data) {
counts->y_mode[i], INTRA_MODES, header_bc); counts->y_mode[i], INTRA_MODES, header_bc);
#if !CONFIG_MISC_FIXES #if !CONFIG_MISC_FIXES
for (i = 0; i < PARTITION_CONTEXTS; ++i) for (i = 0; i < PARTITION_CONTEXTS; ++i) {
prob_diff_update(av1_partition_tree, fc->partition_prob[i], prob_diff_update(av1_partition_tree, fc->partition_prob[i],
counts->partition[i], PARTITION_TYPES, header_bc); counts->partition[i], PARTITION_TYPES, header_bc);
#if CONFIG_DAALA_EC
av1_tree_to_cdf(av1_partition_tree, cm->fc->partition_prob[i],
cm->fc->partition_cdf[i]);
#endif
}
#endif #endif
av1_write_nmv_probs(cm, cm->allow_high_precision_mv, header_bc, av1_write_nmv_probs(cm, cm->allow_high_precision_mv, header_bc,
......
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