ref: 9d55a8f6790809460f754d1331b3830ab1e6bf2c
parent: ac5e269b9469002b640983ba3abfa37497fc4580
parent: 7fb0c5cce9c91d7391a33580126a204f8ce43ce5
author: Angie Chiang <angiebird@google.com>
date: Wed Jun 19 12:45:15 EDT 2019
Merge "Implement log2_fast for vp9_nb_mvs_inconsistency"
--- a/vp9/encoder/vp9_mcomp.c
+++ b/vp9/encoder/vp9_mcomp.c
@@ -1731,6 +1731,167 @@
#define MAX_RANGE 256
#define MIN_INTERVAL 1
#if CONFIG_NON_GREEDY_MV
+
+#define LOG2_TABLE_SIZE 1024
+static const double log2_table[LOG2_TABLE_SIZE] = {
+ 0.000000, // This is a dummy value
+ 0.000000, 1.000000, 1.584963, 2.000000, 2.321928, 2.584963, 2.807355,
+ 3.000000, 3.169925, 3.321928, 3.459432, 3.584963, 3.700440, 3.807355,
+ 3.906891, 4.000000, 4.087463, 4.169925, 4.247928, 4.321928, 4.392317,
+ 4.459432, 4.523562, 4.584963, 4.643856, 4.700440, 4.754888, 4.807355,
+ 4.857981, 4.906891, 4.954196, 5.000000, 5.044394, 5.087463, 5.129283,
+ 5.169925, 5.209453, 5.247928, 5.285402, 5.321928, 5.357552, 5.392317,
+ 5.426265, 5.459432, 5.491853, 5.523562, 5.554589, 5.584963, 5.614710,
+ 5.643856, 5.672425, 5.700440, 5.727920, 5.754888, 5.781360, 5.807355,
+ 5.832890, 5.857981, 5.882643, 5.906891, 5.930737, 5.954196, 5.977280,
+ 6.000000, 6.022368, 6.044394, 6.066089, 6.087463, 6.108524, 6.129283,
+ 6.149747, 6.169925, 6.189825, 6.209453, 6.228819, 6.247928, 6.266787,
+ 6.285402, 6.303781, 6.321928, 6.339850, 6.357552, 6.375039, 6.392317,
+ 6.409391, 6.426265, 6.442943, 6.459432, 6.475733, 6.491853, 6.507795,
+ 6.523562, 6.539159, 6.554589, 6.569856, 6.584963, 6.599913, 6.614710,
+ 6.629357, 6.643856, 6.658211, 6.672425, 6.686501, 6.700440, 6.714246,
+ 6.727920, 6.741467, 6.754888, 6.768184, 6.781360, 6.794416, 6.807355,
+ 6.820179, 6.832890, 6.845490, 6.857981, 6.870365, 6.882643, 6.894818,
+ 6.906891, 6.918863, 6.930737, 6.942515, 6.954196, 6.965784, 6.977280,
+ 6.988685, 7.000000, 7.011227, 7.022368, 7.033423, 7.044394, 7.055282,
+ 7.066089, 7.076816, 7.087463, 7.098032, 7.108524, 7.118941, 7.129283,
+ 7.139551, 7.149747, 7.159871, 7.169925, 7.179909, 7.189825, 7.199672,
+ 7.209453, 7.219169, 7.228819, 7.238405, 7.247928, 7.257388, 7.266787,
+ 7.276124, 7.285402, 7.294621, 7.303781, 7.312883, 7.321928, 7.330917,
+ 7.339850, 7.348728, 7.357552, 7.366322, 7.375039, 7.383704, 7.392317,
+ 7.400879, 7.409391, 7.417853, 7.426265, 7.434628, 7.442943, 7.451211,
+ 7.459432, 7.467606, 7.475733, 7.483816, 7.491853, 7.499846, 7.507795,
+ 7.515700, 7.523562, 7.531381, 7.539159, 7.546894, 7.554589, 7.562242,
+ 7.569856, 7.577429, 7.584963, 7.592457, 7.599913, 7.607330, 7.614710,
+ 7.622052, 7.629357, 7.636625, 7.643856, 7.651052, 7.658211, 7.665336,
+ 7.672425, 7.679480, 7.686501, 7.693487, 7.700440, 7.707359, 7.714246,
+ 7.721099, 7.727920, 7.734710, 7.741467, 7.748193, 7.754888, 7.761551,
+ 7.768184, 7.774787, 7.781360, 7.787903, 7.794416, 7.800900, 7.807355,
+ 7.813781, 7.820179, 7.826548, 7.832890, 7.839204, 7.845490, 7.851749,
+ 7.857981, 7.864186, 7.870365, 7.876517, 7.882643, 7.888743, 7.894818,
+ 7.900867, 7.906891, 7.912889, 7.918863, 7.924813, 7.930737, 7.936638,
+ 7.942515, 7.948367, 7.954196, 7.960002, 7.965784, 7.971544, 7.977280,
+ 7.982994, 7.988685, 7.994353, 8.000000, 8.005625, 8.011227, 8.016808,
+ 8.022368, 8.027906, 8.033423, 8.038919, 8.044394, 8.049849, 8.055282,
+ 8.060696, 8.066089, 8.071462, 8.076816, 8.082149, 8.087463, 8.092757,
+ 8.098032, 8.103288, 8.108524, 8.113742, 8.118941, 8.124121, 8.129283,
+ 8.134426, 8.139551, 8.144658, 8.149747, 8.154818, 8.159871, 8.164907,
+ 8.169925, 8.174926, 8.179909, 8.184875, 8.189825, 8.194757, 8.199672,
+ 8.204571, 8.209453, 8.214319, 8.219169, 8.224002, 8.228819, 8.233620,
+ 8.238405, 8.243174, 8.247928, 8.252665, 8.257388, 8.262095, 8.266787,
+ 8.271463, 8.276124, 8.280771, 8.285402, 8.290019, 8.294621, 8.299208,
+ 8.303781, 8.308339, 8.312883, 8.317413, 8.321928, 8.326429, 8.330917,
+ 8.335390, 8.339850, 8.344296, 8.348728, 8.353147, 8.357552, 8.361944,
+ 8.366322, 8.370687, 8.375039, 8.379378, 8.383704, 8.388017, 8.392317,
+ 8.396605, 8.400879, 8.405141, 8.409391, 8.413628, 8.417853, 8.422065,
+ 8.426265, 8.430453, 8.434628, 8.438792, 8.442943, 8.447083, 8.451211,
+ 8.455327, 8.459432, 8.463524, 8.467606, 8.471675, 8.475733, 8.479780,
+ 8.483816, 8.487840, 8.491853, 8.495855, 8.499846, 8.503826, 8.507795,
+ 8.511753, 8.515700, 8.519636, 8.523562, 8.527477, 8.531381, 8.535275,
+ 8.539159, 8.543032, 8.546894, 8.550747, 8.554589, 8.558421, 8.562242,
+ 8.566054, 8.569856, 8.573647, 8.577429, 8.581201, 8.584963, 8.588715,
+ 8.592457, 8.596190, 8.599913, 8.603626, 8.607330, 8.611025, 8.614710,
+ 8.618386, 8.622052, 8.625709, 8.629357, 8.632995, 8.636625, 8.640245,
+ 8.643856, 8.647458, 8.651052, 8.654636, 8.658211, 8.661778, 8.665336,
+ 8.668885, 8.672425, 8.675957, 8.679480, 8.682995, 8.686501, 8.689998,
+ 8.693487, 8.696968, 8.700440, 8.703904, 8.707359, 8.710806, 8.714246,
+ 8.717676, 8.721099, 8.724514, 8.727920, 8.731319, 8.734710, 8.738092,
+ 8.741467, 8.744834, 8.748193, 8.751544, 8.754888, 8.758223, 8.761551,
+ 8.764872, 8.768184, 8.771489, 8.774787, 8.778077, 8.781360, 8.784635,
+ 8.787903, 8.791163, 8.794416, 8.797662, 8.800900, 8.804131, 8.807355,
+ 8.810572, 8.813781, 8.816984, 8.820179, 8.823367, 8.826548, 8.829723,
+ 8.832890, 8.836050, 8.839204, 8.842350, 8.845490, 8.848623, 8.851749,
+ 8.854868, 8.857981, 8.861087, 8.864186, 8.867279, 8.870365, 8.873444,
+ 8.876517, 8.879583, 8.882643, 8.885696, 8.888743, 8.891784, 8.894818,
+ 8.897845, 8.900867, 8.903882, 8.906891, 8.909893, 8.912889, 8.915879,
+ 8.918863, 8.921841, 8.924813, 8.927778, 8.930737, 8.933691, 8.936638,
+ 8.939579, 8.942515, 8.945444, 8.948367, 8.951285, 8.954196, 8.957102,
+ 8.960002, 8.962896, 8.965784, 8.968667, 8.971544, 8.974415, 8.977280,
+ 8.980140, 8.982994, 8.985842, 8.988685, 8.991522, 8.994353, 8.997179,
+ 9.000000, 9.002815, 9.005625, 9.008429, 9.011227, 9.014020, 9.016808,
+ 9.019591, 9.022368, 9.025140, 9.027906, 9.030667, 9.033423, 9.036174,
+ 9.038919, 9.041659, 9.044394, 9.047124, 9.049849, 9.052568, 9.055282,
+ 9.057992, 9.060696, 9.063395, 9.066089, 9.068778, 9.071462, 9.074141,
+ 9.076816, 9.079485, 9.082149, 9.084808, 9.087463, 9.090112, 9.092757,
+ 9.095397, 9.098032, 9.100662, 9.103288, 9.105909, 9.108524, 9.111136,
+ 9.113742, 9.116344, 9.118941, 9.121534, 9.124121, 9.126704, 9.129283,
+ 9.131857, 9.134426, 9.136991, 9.139551, 9.142107, 9.144658, 9.147205,
+ 9.149747, 9.152285, 9.154818, 9.157347, 9.159871, 9.162391, 9.164907,
+ 9.167418, 9.169925, 9.172428, 9.174926, 9.177420, 9.179909, 9.182394,
+ 9.184875, 9.187352, 9.189825, 9.192293, 9.194757, 9.197217, 9.199672,
+ 9.202124, 9.204571, 9.207014, 9.209453, 9.211888, 9.214319, 9.216746,
+ 9.219169, 9.221587, 9.224002, 9.226412, 9.228819, 9.231221, 9.233620,
+ 9.236014, 9.238405, 9.240791, 9.243174, 9.245553, 9.247928, 9.250298,
+ 9.252665, 9.255029, 9.257388, 9.259743, 9.262095, 9.264443, 9.266787,
+ 9.269127, 9.271463, 9.273796, 9.276124, 9.278449, 9.280771, 9.283088,
+ 9.285402, 9.287712, 9.290019, 9.292322, 9.294621, 9.296916, 9.299208,
+ 9.301496, 9.303781, 9.306062, 9.308339, 9.310613, 9.312883, 9.315150,
+ 9.317413, 9.319672, 9.321928, 9.324181, 9.326429, 9.328675, 9.330917,
+ 9.333155, 9.335390, 9.337622, 9.339850, 9.342075, 9.344296, 9.346514,
+ 9.348728, 9.350939, 9.353147, 9.355351, 9.357552, 9.359750, 9.361944,
+ 9.364135, 9.366322, 9.368506, 9.370687, 9.372865, 9.375039, 9.377211,
+ 9.379378, 9.381543, 9.383704, 9.385862, 9.388017, 9.390169, 9.392317,
+ 9.394463, 9.396605, 9.398744, 9.400879, 9.403012, 9.405141, 9.407268,
+ 9.409391, 9.411511, 9.413628, 9.415742, 9.417853, 9.419960, 9.422065,
+ 9.424166, 9.426265, 9.428360, 9.430453, 9.432542, 9.434628, 9.436712,
+ 9.438792, 9.440869, 9.442943, 9.445015, 9.447083, 9.449149, 9.451211,
+ 9.453271, 9.455327, 9.457381, 9.459432, 9.461479, 9.463524, 9.465566,
+ 9.467606, 9.469642, 9.471675, 9.473706, 9.475733, 9.477758, 9.479780,
+ 9.481799, 9.483816, 9.485829, 9.487840, 9.489848, 9.491853, 9.493855,
+ 9.495855, 9.497852, 9.499846, 9.501837, 9.503826, 9.505812, 9.507795,
+ 9.509775, 9.511753, 9.513728, 9.515700, 9.517669, 9.519636, 9.521600,
+ 9.523562, 9.525521, 9.527477, 9.529431, 9.531381, 9.533330, 9.535275,
+ 9.537218, 9.539159, 9.541097, 9.543032, 9.544964, 9.546894, 9.548822,
+ 9.550747, 9.552669, 9.554589, 9.556506, 9.558421, 9.560333, 9.562242,
+ 9.564149, 9.566054, 9.567956, 9.569856, 9.571753, 9.573647, 9.575539,
+ 9.577429, 9.579316, 9.581201, 9.583083, 9.584963, 9.586840, 9.588715,
+ 9.590587, 9.592457, 9.594325, 9.596190, 9.598053, 9.599913, 9.601771,
+ 9.603626, 9.605480, 9.607330, 9.609179, 9.611025, 9.612868, 9.614710,
+ 9.616549, 9.618386, 9.620220, 9.622052, 9.623881, 9.625709, 9.627534,
+ 9.629357, 9.631177, 9.632995, 9.634811, 9.636625, 9.638436, 9.640245,
+ 9.642052, 9.643856, 9.645658, 9.647458, 9.649256, 9.651052, 9.652845,
+ 9.654636, 9.656425, 9.658211, 9.659996, 9.661778, 9.663558, 9.665336,
+ 9.667112, 9.668885, 9.670656, 9.672425, 9.674192, 9.675957, 9.677720,
+ 9.679480, 9.681238, 9.682995, 9.684749, 9.686501, 9.688250, 9.689998,
+ 9.691744, 9.693487, 9.695228, 9.696968, 9.698705, 9.700440, 9.702173,
+ 9.703904, 9.705632, 9.707359, 9.709084, 9.710806, 9.712527, 9.714246,
+ 9.715962, 9.717676, 9.719389, 9.721099, 9.722808, 9.724514, 9.726218,
+ 9.727920, 9.729621, 9.731319, 9.733015, 9.734710, 9.736402, 9.738092,
+ 9.739781, 9.741467, 9.743151, 9.744834, 9.746514, 9.748193, 9.749869,
+ 9.751544, 9.753217, 9.754888, 9.756556, 9.758223, 9.759888, 9.761551,
+ 9.763212, 9.764872, 9.766529, 9.768184, 9.769838, 9.771489, 9.773139,
+ 9.774787, 9.776433, 9.778077, 9.779719, 9.781360, 9.782998, 9.784635,
+ 9.786270, 9.787903, 9.789534, 9.791163, 9.792790, 9.794416, 9.796040,
+ 9.797662, 9.799282, 9.800900, 9.802516, 9.804131, 9.805744, 9.807355,
+ 9.808964, 9.810572, 9.812177, 9.813781, 9.815383, 9.816984, 9.818582,
+ 9.820179, 9.821774, 9.823367, 9.824959, 9.826548, 9.828136, 9.829723,
+ 9.831307, 9.832890, 9.834471, 9.836050, 9.837628, 9.839204, 9.840778,
+ 9.842350, 9.843921, 9.845490, 9.847057, 9.848623, 9.850187, 9.851749,
+ 9.853310, 9.854868, 9.856426, 9.857981, 9.859535, 9.861087, 9.862637,
+ 9.864186, 9.865733, 9.867279, 9.868823, 9.870365, 9.871905, 9.873444,
+ 9.874981, 9.876517, 9.878051, 9.879583, 9.881114, 9.882643, 9.884171,
+ 9.885696, 9.887221, 9.888743, 9.890264, 9.891784, 9.893302, 9.894818,
+ 9.896332, 9.897845, 9.899357, 9.900867, 9.902375, 9.903882, 9.905387,
+ 9.906891, 9.908393, 9.909893, 9.911392, 9.912889, 9.914385, 9.915879,
+ 9.917372, 9.918863, 9.920353, 9.921841, 9.923327, 9.924813, 9.926296,
+ 9.927778, 9.929258, 9.930737, 9.932215, 9.933691, 9.935165, 9.936638,
+ 9.938109, 9.939579, 9.941048, 9.942515, 9.943980, 9.945444, 9.946906,
+ 9.948367, 9.949827, 9.951285, 9.952741, 9.954196, 9.955650, 9.957102,
+ 9.958553, 9.960002, 9.961450, 9.962896, 9.964341, 9.965784, 9.967226,
+ 9.968667, 9.970106, 9.971544, 9.972980, 9.974415, 9.975848, 9.977280,
+ 9.978710, 9.980140, 9.981567, 9.982994, 9.984418, 9.985842, 9.987264,
+ 9.988685, 9.990104, 9.991522, 9.992938, 9.994353, 9.995767, 9.997179,
+ 9.998590,
+};
+
+static double log2_fast(int v) {
+ assert(v > 0);
+ if (v < LOG2_TABLE_SIZE) {
+ return log2_table[v];
+ } else {
+ return log2(v);
+ }
+}
double vp9_nb_mvs_inconsistency(const MV *mv, const int_mv *nb_mvs,
int mv_num) {
int i;
@@ -1740,10 +1901,9 @@
for (i = 0; i < mv_num; ++i) {
if (nb_mvs[i].as_int != INVALID_MV) {
MV nb_mv = nb_mvs[i].as_mv;
- const double row_diff = mv->row - nb_mv.row;
- const double col_diff = mv->col - nb_mv.col;
- double cost = row_diff * row_diff + col_diff * col_diff;
- cost = log2(1 + cost);
+ 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);
if (update == 0) {
best_cost = cost;
update = 1;