shithub: libvpx

Download patch

ref: 0113fc35160342e3ad636e2ca7b77a6e8956b2a2
parent: e728637b8be3f5d0704a501aed5ac6e44897a584
author: Angie Chiang <angiebird@google.com>
date: Wed Jun 19 12:25:00 EDT 2019

Make type of lambda int in TplDepFrame

Change-Id: I8fdf1ad4790201b1624c8408d92983aeb0b08302

--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -5893,7 +5893,7 @@
 #if CONFIG_NON_GREEDY_MV
   // lambda is used to adjust the importance of motion vector consitency.
   // TODO(angiebird): Figure out lambda's proper value.
-  double lambda = cpi->tpl_stats[frame_idx].lambda;
+  const int lambda = cpi->tpl_stats[frame_idx].lambda;
   int_mv nb_full_mvs[NB_MVS_NUM];
   double mv_dist;
   double mv_cost;
@@ -6799,7 +6799,8 @@
   int fs_loc_heap_size;
   int mi_row, mi_col;
 
-  tpl_frame->lambda = (pw * ph) / 4;
+  tpl_frame->lambda = (pw * ph) >> 2;
+  assert(pw * ph == tpl_frame->lambda << 2);
 
   fs_loc_sort_size = 0;
   for (mi_row = 0; mi_row < cm->mi_rows; mi_row += mi_height) {
--- a/vp9/encoder/vp9_encoder.h
+++ b/vp9/encoder/vp9_encoder.h
@@ -321,7 +321,7 @@
   int mi_cols;
   int base_qindex;
 #if CONFIG_NON_GREEDY_MV
-  double lambda;
+  int lambda;
   int_mv *pyramid_mv_arr[3][SQUARE_BLOCK_SIZES];
   int *mv_mode_arr[3];
   double *rd_diff_arr[3];
--- a/vp9/encoder/vp9_mcomp.c
+++ b/vp9/encoder/vp9_mcomp.c
@@ -1926,7 +1926,7 @@
 static double exhaustive_mesh_search_new(const MACROBLOCK *x, MV *best_mv,
                                          int range, int step,
                                          const vp9_variance_fn_ptr_t *fn_ptr,
-                                         const MV *center_mv, double lambda,
+                                         const MV *center_mv, int lambda,
                                          const int_mv *nb_full_mvs,
                                          int full_mv_num) {
   const MACROBLOCKD *const xd = &x->e_mbd;
@@ -2017,7 +2017,7 @@
 static double full_pixel_exhaustive_new(const VP9_COMP *cpi, MACROBLOCK *x,
                                         MV *centre_mv_full,
                                         const vp9_variance_fn_ptr_t *fn_ptr,
-                                        MV *dst_mv, double lambda,
+                                        MV *dst_mv, int lambda,
                                         const int_mv *nb_full_mvs,
                                         int full_mv_num) {
   const SPEED_FEATURES *const sf = &cpi->sf;
@@ -2069,12 +2069,14 @@
   return bestsme;
 }
 
-static double diamond_search_sad_new(
-    const MACROBLOCK *x, const search_site_config *cfg, const MV *init_full_mv,
-    MV *best_full_mv, double *best_mv_dist, double *best_mv_cost,
-    int search_param, double lambda, int *num00,
-    const vp9_variance_fn_ptr_t *fn_ptr, const int_mv *nb_full_mvs,
-    int full_mv_num) {
+static double diamond_search_sad_new(const MACROBLOCK *x,
+                                     const search_site_config *cfg,
+                                     const MV *init_full_mv, MV *best_full_mv,
+                                     double *best_mv_dist, double *best_mv_cost,
+                                     int search_param, int lambda, int *num00,
+                                     const vp9_variance_fn_ptr_t *fn_ptr,
+                                     const int_mv *nb_full_mvs,
+                                     int full_mv_num) {
   int i, j, step;
 
   const MACROBLOCKD *const xd = &x->e_mbd;
@@ -2580,7 +2582,7 @@
               point as the best match, we will do a final 1-away diamond
               refining search  */
 double vp9_full_pixel_diamond_new(const VP9_COMP *cpi, MACROBLOCK *x,
-                                  MV *mvp_full, int step_param, double lambda,
+                                  MV *mvp_full, int step_param, int lambda,
                                   int do_refine,
                                   const vp9_variance_fn_ptr_t *fn_ptr,
                                   const int_mv *nb_full_mvs, int full_mv_num,
@@ -2775,7 +2777,7 @@
 #if CONFIG_NON_GREEDY_MV
 double vp9_refining_search_sad_new(const MACROBLOCK *x, MV *best_full_mv,
                                    double *best_mv_dist, double *best_mv_cost,
-                                   double lambda, int search_range,
+                                   int lambda, int search_range,
                                    const vp9_variance_fn_ptr_t *fn_ptr,
                                    const int_mv *nb_full_mvs, int full_mv_num) {
   const MACROBLOCKD *const xd = &x->e_mbd;
--- a/vp9/encoder/vp9_mcomp.h
+++ b/vp9/encoder/vp9_mcomp.h
@@ -130,12 +130,12 @@
 struct TplDepStats;
 double vp9_refining_search_sad_new(const MACROBLOCK *x, MV *best_full_mv,
                                    double *best_mv_dist, double *best_mv_cost,
-                                   double lambda, int search_range,
+                                   int lambda, int search_range,
                                    const vp9_variance_fn_ptr_t *fn_ptr,
                                    const int_mv *nb_full_mvs, int full_mv_num);
 
 double vp9_full_pixel_diamond_new(const struct VP9_COMP *cpi, MACROBLOCK *x,
-                                  MV *mvp_full, int step_param, double lambda,
+                                  MV *mvp_full, int step_param, int lambda,
                                   int do_refine,
                                   const vp9_variance_fn_ptr_t *fn_ptr,
                                   const int_mv *nb_full_mvs, int full_mv_num,
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -2497,7 +2497,6 @@
 #if CONFIG_NON_GREEDY_MV
   double mv_dist = 0;
   double mv_cost = 0;
-  double lambda = (pw * ph) / 4;
   double bestsme;
   int_mv nb_full_mvs[NB_MVS_NUM];
   const int nb_full_mv_num = NB_MVS_NUM;
@@ -2504,6 +2503,8 @@
   int gf_group_idx = cpi->twopass.gf_group.index;
   int gf_rf_idx = ref_frame_to_gf_rf_idx(ref);
   BLOCK_SIZE square_bsize = get_square_block_size(bsize);
+  const int lambda = (pw * ph) / 4;
+  assert(pw * ph == lambda << 2);
   vp9_prepare_nb_full_mvs(&cpi->tpl_stats[gf_group_idx], mi_row, mi_col,
                           gf_rf_idx, square_bsize, nb_full_mvs);
 #else   // CONFIG_NON_GREEDY_MV