Move filtertype cdf-update to the final encodepass
A slight improvement in BDRATE.
STATS_CHANGED
Change-Id: Ieec2bed12f40e3ca7c898bde4a7f63020244052e
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index 82c64f8..61648a8 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -423,8 +423,7 @@
}
}
-static AOM_INLINE void update_filter_type_count(uint8_t allow_update_cdf,
- FRAME_COUNTS *counts,
+static AOM_INLINE void update_filter_type_count(FRAME_COUNTS *counts,
const MACROBLOCKD *xd,
const MB_MODE_INFO *mbmi) {
int dir;
@@ -432,10 +431,17 @@
const int ctx = av1_get_pred_context_switchable_interp(xd, dir);
InterpFilter filter = av1_extract_interp_filter(mbmi->interp_filters, dir);
++counts->switchable_interp[ctx][filter];
- if (allow_update_cdf) {
- update_cdf(xd->tile_ctx->switchable_interp_cdf[ctx], filter,
- SWITCHABLE_FILTERS);
- }
+ }
+}
+
+static AOM_INLINE void update_filter_type_cdf(const MACROBLOCKD *xd,
+ const MB_MODE_INFO *mbmi) {
+ int dir;
+ for (dir = 0; dir < 2; ++dir) {
+ const int ctx = av1_get_pred_context_switchable_interp(xd, dir);
+ InterpFilter filter = av1_extract_interp_filter(mbmi->interp_filters, dir);
+ update_cdf(xd->tile_ctx->switchable_interp_cdf[ctx], filter,
+ SWITCHABLE_FILTERS);
}
}
@@ -472,9 +478,7 @@
x->skip = 0;
}
-static AOM_INLINE void update_state(const AV1_COMP *const cpi,
- const TileDataEnc *const tile_data,
- ThreadData *td,
+static AOM_INLINE void update_state(const AV1_COMP *const cpi, ThreadData *td,
const PICK_MODE_CONTEXT *const ctx,
int mi_row, int mi_col, BLOCK_SIZE bsize,
RUN_TYPE dry_run) {
@@ -583,8 +587,7 @@
if (cm->interp_filter == SWITCHABLE &&
mi_addr->motion_mode != WARPED_CAUSAL &&
!is_nontrans_global_motion(xd, xd->mi[0])) {
- update_filter_type_count(tile_data->allow_update_cdf, td->counts, xd,
- mi_addr);
+ update_filter_type_count(td->counts, xd, mi_addr);
}
rdc->comp_pred_diff[SINGLE_REFERENCE] += ctx->single_pred_diff;
@@ -1369,6 +1372,11 @@
}
}
+ if (inter_block && cm->interp_filter == SWITCHABLE &&
+ mbmi->motion_mode != WARPED_CAUSAL &&
+ !is_nontrans_global_motion(xd, mbmi)) {
+ update_filter_type_cdf(xd, mbmi);
+ }
if (inter_block &&
!segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) {
const PREDICTION_MODE mode = mbmi->mode;
@@ -1527,7 +1535,7 @@
setup_block_rdmult(cpi, x, mi_row, mi_col, bsize, NO_AQ, NULL);
MB_MODE_INFO *mbmi = xd->mi[0];
mbmi->partition = partition;
- update_state(cpi, tile_data, td, ctx, mi_row, mi_col, bsize, dry_run);
+ update_state(cpi, td, ctx, mi_row, mi_col, bsize, dry_run);
if (!dry_run) {
x->mbmi_ext->cb_offset = x->cb_offset;
@@ -1908,7 +1916,7 @@
RD_STATS tmp_rdc;
const PICK_MODE_CONTEXT *const ctx_h = &pc_tree->horizontal[0];
av1_init_rd_stats(&tmp_rdc);
- update_state(cpi, tile_data, td, ctx_h, mi_row, mi_col, subsize, 1);
+ update_state(cpi, td, ctx_h, mi_row, mi_col, subsize, 1);
encode_superblock(cpi, tile_data, td, tp, DRY_RUN_NORMAL, mi_row,
mi_col, subsize, NULL);
pick_sb_modes(cpi, tile_data, x, mi_row + hbs, mi_col, &tmp_rdc,
@@ -1932,7 +1940,7 @@
RD_STATS tmp_rdc;
const PICK_MODE_CONTEXT *const ctx_v = &pc_tree->vertical[0];
av1_init_rd_stats(&tmp_rdc);
- update_state(cpi, tile_data, td, ctx_v, mi_row, mi_col, subsize, 1);
+ update_state(cpi, td, ctx_v, mi_row, mi_col, subsize, 1);
encode_superblock(cpi, tile_data, td, tp, DRY_RUN_NORMAL, mi_row,
mi_col, subsize, NULL);
pick_sb_modes(cpi, tile_data, x, mi_row, mi_col + hbs, &tmp_rdc,
@@ -2296,7 +2304,7 @@
}
if (!is_last) {
- update_state(cpi, tile_data, td, this_ctx, mi_row, mi_col, subsize, 1);
+ update_state(cpi, td, this_ctx, mi_row, mi_col, subsize, 1);
encode_superblock(cpi, tile_data, td, tp, DRY_RUN_NORMAL, mi_row, mi_col,
subsize, NULL);
}
@@ -2886,7 +2894,7 @@
if (pmi->palette_size[0] == 0 && pmi->palette_size[1] == 0) {
if (mbmi->uv_mode != UV_CFL_PRED) horz_ctx_is_ready = 1;
}
- update_state(cpi, tile_data, td, ctx_h, mi_row, mi_col, subsize, 1);
+ update_state(cpi, td, ctx_h, mi_row, mi_col, subsize, 1);
encode_superblock(cpi, tile_data, td, tp, DRY_RUN_NORMAL, mi_row, mi_col,
subsize, NULL);
@@ -2972,8 +2980,7 @@
if (pmi->palette_size[0] == 0 && pmi->palette_size[1] == 0) {
if (mbmi->uv_mode != UV_CFL_PRED) vert_ctx_is_ready = 1;
}
- update_state(cpi, tile_data, td, &pc_tree->vertical[0], mi_row, mi_col,
- subsize, 1);
+ update_state(cpi, td, &pc_tree->vertical[0], mi_row, mi_col, subsize, 1);
encode_superblock(cpi, tile_data, td, tp, DRY_RUN_NORMAL, mi_row, mi_col,
subsize, NULL);