shithub: libvpx

Download patch

ref: af52e4657c064b8ba5a282335d1c3a326326d95b
parent: 0113fc35160342e3ad636e2ca7b77a6e8956b2a2
author: Angie Chiang <angiebird@google.com>
date: Thu Jun 20 12:06:56 EDT 2019

Make vp9_nb_mvs_inconsistency return int64_t

Change-Id: I925156ed45e13a06c449c2fbff8a3c26baf8d835

--- a/vp9/encoder/vp9_mcomp.c
+++ b/vp9/encoder/vp9_mcomp.c
@@ -1899,8 +1899,8 @@
   }
 }
 
-double vp9_nb_mvs_inconsistency(const MV *mv, const int_mv *nb_mvs,
-                                int mv_num) {
+int64_t vp9_nb_mvs_inconsistency(const MV *mv, const int_mv *nb_mvs,
+                                 int mv_num) {
   int i;
   int update = 0;
   int64_t best_cost = 0;
@@ -1920,7 +1920,7 @@
       }
     }
   }
-  return best_cost * 1. / (1 << LOG2_PRECISION);
+  return best_cost;
 }
 
 static double exhaustive_mesh_search_new(const MACROBLOCK *x, MV *best_mv,
@@ -1946,7 +1946,8 @@
   best_sad =
       fn_ptr->sdf(what->buf, what->stride,
                   get_buf_from_mv(in_what, &fcenter_mv), in_what->stride) +
-      lambda * vp9_nb_mvs_inconsistency(&fcenter_mv, nb_full_mvs, full_mv_num);
+      lambda * vp9_nb_mvs_inconsistency(&fcenter_mv, nb_full_mvs, full_mv_num) /
+          (double)(1 << LOG2_PRECISION);
   start_row = VPXMAX(-range, x->mv_limits.row_min - fcenter_mv.row);
   start_col = VPXMAX(-range, x->mv_limits.col_min - fcenter_mv.col);
   end_row = VPXMIN(range, x->mv_limits.row_max - fcenter_mv.row);
@@ -1961,8 +1962,9 @@
             fn_ptr->sdf(what->buf, what->stride, get_buf_from_mv(in_what, &mv),
                         in_what->stride);
         if (sad < best_sad) {
-          sad +=
-              lambda * vp9_nb_mvs_inconsistency(&mv, nb_full_mvs, full_mv_num);
+          sad += lambda *
+                 vp9_nb_mvs_inconsistency(&mv, nb_full_mvs, full_mv_num) /
+                 (double)(1 << LOG2_PRECISION);
           if (sad < best_sad) {
             best_sad = sad;
             *best_mv = mv;
@@ -1983,8 +1985,10 @@
             if (sads[i] < best_sad) {
               const MV mv = { fcenter_mv.row + r, fcenter_mv.col + c + i };
               const double sad =
-                  sads[i] + lambda * vp9_nb_mvs_inconsistency(&mv, nb_full_mvs,
-                                                              full_mv_num);
+                  sads[i] +
+                  lambda *
+                      vp9_nb_mvs_inconsistency(&mv, nb_full_mvs, full_mv_num) /
+                      (double)(1 << LOG2_PRECISION);
               if (sad < best_sad) {
                 best_sad = sad;
                 *best_mv = mv;
@@ -1999,7 +2003,8 @@
                             get_buf_from_mv(in_what, &mv), in_what->stride);
             if (sad < best_sad) {
               sad += lambda *
-                     vp9_nb_mvs_inconsistency(&mv, nb_full_mvs, full_mv_num);
+                     vp9_nb_mvs_inconsistency(&mv, nb_full_mvs, full_mv_num) /
+                     (double)(1 << LOG2_PRECISION);
               if (sad < best_sad) {
                 best_sad = sad;
                 *best_mv = mv;
@@ -2114,7 +2119,8 @@
   // Check the starting position
   *best_mv_dist = fn_ptr->sdf(what, what_stride, in_what, in_what_stride);
   *best_mv_cost =
-      vp9_nb_mvs_inconsistency(best_full_mv, nb_full_mvs, full_mv_num);
+      vp9_nb_mvs_inconsistency(best_full_mv, nb_full_mvs, full_mv_num) /
+      (double)(1 << LOG2_PRECISION);
   bestsad = (*best_mv_dist) + lambda * (*best_mv_cost);
 
   i = 0;
@@ -2148,7 +2154,8 @@
                                best_full_mv->col + ss_mv[i].col };
           const double mv_dist = sad_array[t];
           const double mv_cost =
-              vp9_nb_mvs_inconsistency(&this_mv, nb_full_mvs, full_mv_num);
+              vp9_nb_mvs_inconsistency(&this_mv, nb_full_mvs, full_mv_num) /
+              (double)(1 << LOG2_PRECISION);
           double thissad = mv_dist + lambda * mv_cost;
           if (thissad < bestsad) {
             bestsad = thissad;
@@ -2169,7 +2176,8 @@
           const double mv_dist =
               fn_ptr->sdf(what, what_stride, check_here, in_what_stride);
           const double mv_cost =
-              vp9_nb_mvs_inconsistency(&this_mv, nb_full_mvs, full_mv_num);
+              vp9_nb_mvs_inconsistency(&this_mv, nb_full_mvs, full_mv_num) /
+              (double)(1 << LOG2_PRECISION);
           double thissad = mv_dist + lambda * mv_cost;
           if (thissad < bestsad) {
             bestsad = thissad;
@@ -2791,7 +2799,8 @@
   *best_mv_dist =
       fn_ptr->sdf(what->buf, what->stride, best_address, in_what->stride);
   *best_mv_cost =
-      vp9_nb_mvs_inconsistency(best_full_mv, nb_full_mvs, full_mv_num);
+      vp9_nb_mvs_inconsistency(best_full_mv, nb_full_mvs, full_mv_num) /
+      (double)(1 << LOG2_PRECISION);
   best_sad = (*best_mv_dist) + lambda * (*best_mv_cost);
 
   for (i = 0; i < search_range; i++) {
@@ -2814,7 +2823,8 @@
                         best_full_mv->col + neighbors[j].col };
         const double mv_dist = sads[j];
         const double mv_cost =
-            vp9_nb_mvs_inconsistency(&mv, nb_full_mvs, full_mv_num);
+            vp9_nb_mvs_inconsistency(&mv, nb_full_mvs, full_mv_num) /
+            (double)(1 << LOG2_PRECISION);
         const double thissad = mv_dist + lambda * mv_cost;
         if (thissad < best_sad) {
           best_sad = thissad;
@@ -2833,7 +2843,8 @@
               fn_ptr->sdf(what->buf, what->stride,
                           get_buf_from_mv(in_what, &mv), in_what->stride);
           const double mv_cost =
-              vp9_nb_mvs_inconsistency(&mv, nb_full_mvs, full_mv_num);
+              vp9_nb_mvs_inconsistency(&mv, nb_full_mvs, full_mv_num) /
+              (double)(1 << LOG2_PRECISION);
           const double thissad = mv_dist + lambda * mv_cost;
           if (thissad < best_sad) {
             best_sad = thissad;
--- a/vp9/encoder/vp9_mcomp.h
+++ b/vp9/encoder/vp9_mcomp.h
@@ -142,7 +142,8 @@
                                   MV *best_mv, double *best_mv_dist,
                                   double *best_mv_cost);
 
-double vp9_nb_mvs_inconsistency(const MV *mv, const int_mv *nb_mvs, int mv_num);
+int64_t vp9_nb_mvs_inconsistency(const MV *mv, const int_mv *nb_mvs,
+                                 int mv_num);
 static INLINE MV get_full_mv(const MV *mv) {
   MV out_mv;
   out_mv.row = mv->row >> 3;