Move an mv_cost table init from temporal filter to tpl_model Since temporal filter uses sad instead of entropy for mv_cost, the initialization should not be done in temporal filtering. This commit moves it to the correct location. Furthermore, this fixes an incorrect behavior where temporal dependency model would use 0 as the mvcost in motion estimation. This happens in the rare scenario where there is not enough frames in the kf group for temporal filtering, so the mv_cost is not initialized. There are some small changes on a couple clips, but the overall performance is neutral. STATS_CHANGED Change-Id: I90450f1095348bc9033c57144c3dd74783ae197e
diff --git a/av1/encoder/temporal_filter.c b/av1/encoder/temporal_filter.c index fc9d420..1226e61 100644 --- a/av1/encoder/temporal_filter.c +++ b/av1/encoder/temporal_filter.c
@@ -1190,17 +1190,6 @@ return 0; } - // TODO(yunqing): For INTNL_ARF_UPDATE type, the following me initialization - // is used somewhere unexpectedly. Should be resolved later. - // Initialize errorperbit and sadperbit - const int rdmult = av1_compute_rd_mult_based_on_qindex(cpi, TF_QINDEX); - MvCosts *mv_costs = cpi->td.mb.mv_costs; - av1_set_error_per_bit(&cpi->td.mb.errorperbit, rdmult); - av1_set_sad_per_bit(cpi, &cpi->td.mb.sadperbit, TF_QINDEX); - av1_fill_mv_costs(cpi->common.fc, - cpi->common.features.cur_frame_force_integer_mv, - cpi->common.features.allow_high_precision_mv, mv_costs); - // Initialize temporal filter context structure. init_tf_ctx(cpi, filter_frame_lookahead_idx, is_second_arf, update_type, is_forward_keyframe);
diff --git a/av1/encoder/temporal_filter.h b/av1/encoder/temporal_filter.h index 8ecc774..2ae7dd4 100644 --- a/av1/encoder/temporal_filter.h +++ b/av1/encoder/temporal_filter.h
@@ -169,9 +169,6 @@ double av1_estimate_noise_from_single_plane(const YV12_BUFFER_CONFIG *frame, const int plane, const int bit_depth); - -#define TF_QINDEX 128 // Q-index used in temporal filtering. - /*!\endcond */ /*!\brief Does temporal filter for a given macroblock row.
diff --git a/av1/encoder/tpl_model.c b/av1/encoder/tpl_model.c index c983571..38b70c7 100644 --- a/av1/encoder/tpl_model.c +++ b/av1/encoder/tpl_model.c
@@ -1436,6 +1436,12 @@ av1_setup_scale_factors_for_frame(&cm->sf_identity, cm->width, cm->height, cm->width, cm->height); + if (frame_params->frame_type == KEY_FRAME) { + av1_init_mv_probs(cm); + } + av1_fill_mv_costs(cm->fc, cm->features.cur_frame_force_integer_mv, + cm->features.allow_high_precision_mv, cpi->td.mb.mv_costs); + // Backward propagation from tpl_group_frames to 1. for (int frame_idx = gf_group->index; frame_idx < tpl_gf_group_frames; ++frame_idx) {