shithub: libvpx

Download patch

ref: cbf0b1688a95508db4e468506065538af1a73801
parent: 087f131851d452d71b617e33135cc8379796735b
parent: 9f8ee48611a9f7bc708d6698b388996d5c6e4fe3
author: Angie Chiang <angiebird@google.com>
date: Thu Jun 20 13:14:15 EDT 2019

Merge "Change log2_fast to log2_approximation"

--- a/vp9/encoder/vp9_mcomp.c
+++ b/vp9/encoder/vp9_mcomp.c
@@ -1884,12 +1884,15 @@
   9.998590,
 };
 
-static double log2_fast(int v) {
+static double log2_approximation(int v) {
   assert(v > 0);
   if (v < LOG2_TABLE_SIZE) {
     return log2_table[v];
   } else {
-    return log2(v);
+    // use linear approximation when v >= 2^10
+    const double slope = 0.001409;  // slope = 1 / (log(2) * 1024)
+    assert(LOG2_TABLE_SIZE == 1 << 10);
+    return slope * (v - LOG2_TABLE_SIZE) + 10;
   }
 }
 double vp9_nb_mvs_inconsistency(const MV *mv, const int_mv *nb_mvs,
@@ -1903,7 +1906,8 @@
       MV nb_mv = nb_mvs[i].as_mv;
       const int row_diff = abs(mv->row - nb_mv.row);
       const int col_diff = abs(mv->col - nb_mv.col);
-      double cost = log2_fast(1 + row_diff * row_diff + col_diff * col_diff);
+      double cost =
+          log2_approximation(1 + row_diff * row_diff + col_diff * col_diff);
       if (update == 0) {
         best_cost = cost;
         update = 1;