ref: 9f8ee48611a9f7bc708d6698b388996d5c6e4fe3
parent: aecad5a3131dc0a0ab427c50fdcb70eba22740e3
author: Angie Chiang <angiebird@google.com>
date: Tue Jun 18 11:33:23 EDT 2019
Change log2_fast to log2_approximation This reduce non_greedy_mv encoding time by 8.9% Use linear approximation for value >= 1024 BDRate increases slightly on hdres lowres: -0.002 midres: 0.007 hdres: 0.057 Change-Id: I55fd5e0bf0ab2206a286e11974f701cc48084be8
--- 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;