From: Angie Chiang Date: Thu, 4 Oct 2018 22:17:02 +0000 (-0700) Subject: Fix bug in prepare_nb_full_mvs X-Git-Tag: v1.8.0~261^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e49ef1476db5083e002863c7c2b8b5188c298d48;p=libvpx Fix bug in prepare_nb_full_mvs Previously, the prepare_nb_full_mvs might construct nb_full_mv with wrong mvs (from other ref frame). The following changes will fix the bug. 1) Let ready in TplDepStats becomes int array 2) Add parameter rf_idx 3) Use mv_arr instead of mv to build the nb_full_mv Change-Id: I199798aec4c6762d54799562e142457cc26ee043 --- diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c index 3dfc1b87b..ca10512c6 100644 --- a/vp9/encoder/vp9_encoder.c +++ b/vp9/encoder/vp9_encoder.c @@ -5445,7 +5445,7 @@ void init_tpl_stats(VP9_COMP *cpi) { #if CONFIG_NON_GREEDY_MV static void prepare_nb_full_mvs(const TplDepFrame *tpl_frame, int mi_row, - int mi_col, int_mv *nb_full_mvs) { + int mi_col, int rf_idx, int_mv *nb_full_mvs) { const int dirs[NB_MVS_NUM][2] = { { -1, 0 }, { 0, -1 }, { 1, 0 }, { 0, 1 } }; int i; for (i = 0; i < NB_MVS_NUM; ++i) { @@ -5456,9 +5456,9 @@ static void prepare_nb_full_mvs(const TplDepFrame *tpl_frame, int mi_row, const TplDepStats *tpl_ptr = &tpl_frame ->tpl_stats_ptr[(mi_row + r) * tpl_frame->stride + mi_col + c]; - if (tpl_ptr->ready) { - nb_full_mvs[i].as_mv.row = tpl_ptr->mv.as_mv.row >> 3; - nb_full_mvs[i].as_mv.col = tpl_ptr->mv.as_mv.col >> 3; + if (tpl_ptr->ready[rf_idx]) { + nb_full_mvs[i].as_mv.row = tpl_ptr->mv_arr[rf_idx].as_mv.row >> 3; + nb_full_mvs[i].as_mv.col = tpl_ptr->mv_arr[rf_idx].as_mv.col >> 3; } else { nb_full_mvs[i].as_int = INVALID_MV; } @@ -5521,7 +5521,8 @@ uint32_t motion_compensated_prediction(VP9_COMP *cpi, ThreadData *td, #if CONFIG_NON_GREEDY_MV (void)search_method; (void)sadpb; - prepare_nb_full_mvs(&cpi->tpl_stats[frame_idx], mi_row, mi_col, nb_full_mvs); + prepare_nb_full_mvs(&cpi->tpl_stats[frame_idx], mi_row, mi_col, rf_idx, + nb_full_mvs); vp9_full_pixel_diamond_new(cpi, x, &best_ref_mv1_full, step_param, lambda, MAX_MVSEARCH_STEPS - 1 - step_param, 1, &cpi->fn_ptr[bsize], nb_full_mvs, tpl_stats, @@ -5608,6 +5609,7 @@ void tpl_model_store(TplDepStats *tpl_stats, int mi_row, int mi_col, #if CONFIG_NON_GREEDY_MV int rf_idx; for (rf_idx = 0; rf_idx < 3; ++rf_idx) { + tpl_ptr->ready[rf_idx] = src_stats->ready[rf_idx]; tpl_ptr->mv_dist[rf_idx] = src_stats->mv_dist[rf_idx]; tpl_ptr->mv_cost[rf_idx] = src_stats->mv_cost[rf_idx]; tpl_ptr->inter_cost_arr[rf_idx] = src_stats->inter_cost; @@ -5616,7 +5618,6 @@ void tpl_model_store(TplDepStats *tpl_stats, int mi_row, int mi_col, tpl_ptr->mv_arr[rf_idx].as_int = src_stats->mv_arr[rf_idx].as_int; } tpl_ptr->feature_score = src_stats->feature_score; - tpl_ptr->ready = 1; #endif tpl_ptr->intra_cost = intra_cost; tpl_ptr->inter_cost = inter_cost; @@ -5837,9 +5838,13 @@ void mode_estimation(VP9_COMP *cpi, MACROBLOCK *x, MACROBLOCKD *xd, int_mv mv; if (ref_frame[rf_idx] == NULL) { #if CONFIG_NON_GREEDY_MV - tpl_stats->inter_cost_arr[rf_idx] = -1; + tpl_stats->ready[rf_idx] = 0; #endif continue; + } else { +#if CONFIG_NON_GREEDY_MV + tpl_stats->ready[rf_idx] = 1; +#endif } #if CONFIG_NON_GREEDY_MV diff --git a/vp9/encoder/vp9_encoder.h b/vp9/encoder/vp9_encoder.h index 87d590e5c..b8922dc56 100644 --- a/vp9/encoder/vp9_encoder.h +++ b/vp9/encoder/vp9_encoder.h @@ -291,7 +291,7 @@ typedef struct TplDepStats { int_mv mv; #if CONFIG_NON_GREEDY_MV - int ready; + int ready[3]; double mv_dist[3]; double mv_cost[3]; int64_t inter_cost_arr[3];