shithub: libvpx

Download patch

ref: ba4fbc4b8d46be713b171fd8e28ad23a164ecdfa
parent: 069943a5f1e059aaaac7800466dad92b8b5a7cae
author: Angie Chiang <angiebird@google.com>
date: Thu Oct 18 06:40:06 EDT 2018

Refactor av1_nb_mvs_inconsistency()

Change-Id: Ib9d16a4bc3ce1d28493e34f24dc18a6b511738f0

--- a/vp9/encoder/vp9_mcomp.c
+++ b/vp9/encoder/vp9_mcomp.c
@@ -1735,7 +1735,8 @@
 #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 @@
       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,