From ba4fbc4b8d46be713b171fd8e28ad23a164ecdfa Mon Sep 17 00:00:00 2001 From: Angie Chiang Date: Thu, 18 Oct 2018 10:40:06 -0700 Subject: [PATCH] Refactor av1_nb_mvs_inconsistency() Change-Id: Ib9d16a4bc3ce1d28493e34f24dc18a6b511738f0 --- vp9/encoder/vp9_mcomp.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/vp9/encoder/vp9_mcomp.c b/vp9/encoder/vp9_mcomp.c index 1192ed64d..a2543035c 100644 --- a/vp9/encoder/vp9_mcomp.c +++ b/vp9/encoder/vp9_mcomp.c @@ -1735,7 +1735,8 @@ static int exhuastive_mesh_search(const MACROBLOCK *x, MV *ref_mv, MV *best_mv, #if CONFIG_NON_GREEDY_MV double av1_nb_mvs_inconsistency(const MV *mv, const int_mv *nb_mvs) { int i; - double best_cost = -1; + int update = 0; + double best_cost = 0; vpx_clear_system_state(); for (i = 0; i < NB_MVS_NUM; ++i) { if (nb_mvs[i].as_int != INVALID_MV) { @@ -1744,18 +1745,15 @@ double av1_nb_mvs_inconsistency(const MV *mv, const int_mv *nb_mvs) { const double col_diff = mv->col - nb_mv.col; double cost = row_diff * row_diff + col_diff * col_diff; cost = log2(1 + cost); - if (best_cost < 0) { + if (update == 0) { best_cost = cost; + update = 1; } else { best_cost = cost < best_cost ? cost : best_cost; } } } - if (best_cost < 0) { - return 0; - } else { - return best_cost; - } + return best_cost; } double vp9_diamond_search_sad_new(const MACROBLOCK *x, -- 2.40.0