Initialize coeff, mode and mv costs
When cost update frequency was set to tile level,
coeff_costs, mode_costs and mv costs were not initialized.
This resulted in run to run mismatch in the multi-thread
scenario with row-mt=1. Also, when cost update frequency
was set to off, coeff_costs and mode_costs were initialized
to zero. This patch correctly initializes these costs.
Change-Id: I4193185058be045b9711d2bb2df77dbf5ba8634b
diff --git a/av1/common/entropy.h b/av1/common/entropy.h
index ee78f56..53ef3b1 100644
--- a/av1/common/entropy.h
+++ b/av1/common/entropy.h
@@ -73,6 +73,7 @@
struct frame_contexts;
void av1_reset_cdf_symbol_counters(struct frame_contexts *fc);
void av1_default_coef_probs(struct AV1Common *cm);
+void av1_init_mode_probs(struct frame_contexts *fc);
struct frame_contexts;
diff --git a/av1/common/entropymode.c b/av1/common/entropymode.c
index daee332..2ec2241 100644
--- a/av1/common/entropymode.c
+++ b/av1/common/entropymode.c
@@ -1083,7 +1083,7 @@
#undef NUM_PALETTE_NEIGHBORS
#undef MAX_COLOR_CONTEXT_HASH
-static void init_mode_probs(FRAME_CONTEXT *fc) {
+void av1_init_mode_probs(FRAME_CONTEXT *fc) {
av1_copy(fc->palette_y_size_cdf, default_palette_y_size_cdf);
av1_copy(fc->palette_uv_size_cdf, default_palette_uv_size_cdf);
av1_copy(fc->palette_y_color_index_cdf, default_palette_y_color_index_cdf);
@@ -1204,7 +1204,7 @@
set_default_lf_deltas(&cm->lf);
av1_default_coef_probs(cm);
- init_mode_probs(cm->fc);
+ av1_init_mode_probs(cm->fc);
av1_init_mv_probs(cm);
cm->fc->initialized = 1;
av1_setup_frame_contexts(cm);
diff --git a/av1/encoder/firstpass.c b/av1/encoder/firstpass.c
index db098e1..e483b57 100644
--- a/av1/encoder/firstpass.c
+++ b/av1/encoder/firstpass.c
@@ -1212,6 +1212,8 @@
xd->cfl.store_y = 0;
av1_frame_init_quantizer(cpi);
+ av1_default_coef_probs(cm);
+ av1_init_mode_probs(cm->fc);
av1_init_mv_probs(cm);
av1_initialize_rd_consts(cpi);
diff --git a/av1/encoder/rd.c b/av1/encoder/rd.c
index 59fd5f3..6bceddb 100644
--- a/av1/encoder/rd.c
+++ b/av1/encoder/rd.c
@@ -582,6 +582,11 @@
MACROBLOCK *const x = &cpi->td.mb;
RD_OPT *const rd = &cpi->rd;
MvCosts *mv_costs = &x->mv_costs;
+ int use_nonrd_pick_mode = cpi->sf.rt_sf.use_nonrd_pick_mode;
+ CostUpdateFreq cost_upd_freq = cpi->oxcf.cost_upd_freq;
+ int fill_costs =
+ frame_is_intra_only(cm) || (cm->current_frame.frame_number & 0x07) == 1;
+ int num_planes = av1_num_planes(cm);
aom_clear_system_state();
@@ -592,13 +597,20 @@
set_block_thresholds(cm, rd);
- if ((!cpi->sf.rt_sf.use_nonrd_pick_mode &&
- cpi->oxcf.cost_upd_freq.mv != COST_UPD_OFF) ||
- frame_is_intra_only(cm) || (cm->current_frame.frame_number & 0x07) == 1)
+ if ((!use_nonrd_pick_mode && cost_upd_freq.mv != COST_UPD_OFF) ||
+ cost_upd_freq.mv == COST_UPD_TILE || fill_costs)
av1_fill_mv_costs(cm->fc, cm->features.cur_frame_force_integer_mv,
cm->features.allow_high_precision_mv, mv_costs);
- if (!cpi->sf.rt_sf.use_nonrd_pick_mode && frame_is_intra_only(cm) &&
+ if ((!use_nonrd_pick_mode && cost_upd_freq.coeff != COST_UPD_OFF) ||
+ cost_upd_freq.coeff == COST_UPD_TILE || fill_costs)
+ av1_fill_coeff_costs(&x->coeff_costs, cm->fc, num_planes);
+
+ if ((!use_nonrd_pick_mode && cost_upd_freq.mode != COST_UPD_OFF) ||
+ cost_upd_freq.mode == COST_UPD_TILE || fill_costs)
+ av1_fill_mode_rates(cm, &x->mode_costs, cm->fc);
+
+ if (!use_nonrd_pick_mode && frame_is_intra_only(cm) &&
cm->features.allow_screen_content_tools &&
!is_stat_generation_stage(cpi)) {
IntraBCMVCosts *const dv_costs = &cpi->dv_costs;