shithub: libvpx

Download patch

ref: e43f0a4bef8475149c75186ad0d76bf4b1d6ae80
parent: ce4336c2ab60d185b431345987b2188511760e54
author: Angie Chiang <angiebird@google.com>
date: Tue Feb 5 09:45:09 EST 2019

Compute future_rd_diff in predict_mv_mode

The future_rd_diff computes the future rd difference between
new mv mode and ref mv mode.

Change-Id: I4bf9e2ad34257ba9cfec95419c2c5eca469584e9

--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -6251,7 +6251,7 @@
                             GF_PICTURE *gf_picture, int frame_idx,
                             TplDepFrame *tpl_frame, int rf_idx,
                             BLOCK_SIZE bsize, int mi_row, int mi_col,
-                            double *rd) {
+                            double *future_rd_diff) {
   const int mi_height = num_8x8_blocks_high_lookup[bsize];
   const int mi_width = num_8x8_blocks_wide_lookup[bsize];
   int tmp_mv_mode_arr[kMvPreCheckSize];
@@ -6261,6 +6261,8 @@
   int stride = tpl_frame->stride;
   double new_mv_rd = 0;
   double no_new_mv_rd = 0;
+  double this_new_mv_rd = 0;
+  double this_no_new_mv_rd = 0;
   int idx;
   int tmp_idx;
   assert(kMvPreCheckSize == (kMvPreCheckLines * (kMvPreCheckLines + 1)) >> 1);
@@ -6280,6 +6282,9 @@
         mv_mode_arr[nb_row * stride + nb_col] =
             find_best_ref_mv_mode(cpi, x, gf_picture, frame_idx, tpl_frame,
                                   rf_idx, bsize, nb_row, nb_col, &this_rd, mv);
+        if (r == 0 && c == 0) {
+          this_no_new_mv_rd = this_rd;
+        }
         no_new_mv_rd += this_rd;
         tmp_mv_mode_arr[tmp_idx] = mv_mode_arr[nb_row * stride + nb_col];
         tmp_select_mv_arr[tmp_idx] = select_mv_arr[nb_row * stride + nb_col];
@@ -6290,9 +6295,10 @@
 
   // new mv
   mv_mode_arr[mi_row * stride + mi_col] = NEW_MV_MODE;
-  new_mv_rd = eval_mv_mode(NEW_MV_MODE, cpi, x, gf_picture, frame_idx,
-                           tpl_frame, rf_idx, bsize, mi_row, mi_col,
-                           &select_mv_arr[mi_row * stride + mi_col]);
+  this_new_mv_rd = eval_mv_mode(NEW_MV_MODE, cpi, x, gf_picture, frame_idx,
+                                tpl_frame, rf_idx, bsize, mi_row, mi_col,
+                                &select_mv_arr[mi_row * stride + mi_col]);
+  new_mv_rd = this_new_mv_rd;
   // We start from idx = 1 because idx = 0 is evaluated as NEW_MV_MODE
   // beforehand.
   for (idx = 1; idx < kMvPreCheckLines; ++idx) {
@@ -6315,7 +6321,6 @@
   // update best_mv_mode
   tmp_idx = 0;
   if (no_new_mv_rd < new_mv_rd) {
-    *rd = no_new_mv_rd;
     for (idx = 0; idx < kMvPreCheckLines; ++idx) {
       int r;
       for (r = 0; r <= idx; ++r) {
@@ -6329,8 +6334,10 @@
         }
       }
     }
+    *future_rd_diff = 0;
   } else {
-    *rd = new_mv_rd;
+    *future_rd_diff =
+        (no_new_mv_rd - this_no_new_mv_rd) - (new_mv_rd - this_new_mv_rd);
   }
 }
 
@@ -6347,7 +6354,7 @@
     int r;
     for (r = VPXMAX(idx - unit_cols + 1, 0); r <= VPXMIN(idx, unit_rows - 1);
          ++r) {
-      double rd;  // TODO(angiebird): Use this information later.
+      double future_rd_diff;  // TODO(angiebird): Use this information later.
       int c = idx - r;
       int mi_row = r * mi_height;
       int mi_col = c * mi_width;
@@ -6355,7 +6362,7 @@
       assert(mi_row >= 0 && mi_row < tpl_frame->mi_rows);
       assert(mi_col >= 0 && mi_col < tpl_frame->mi_cols);
       predict_mv_mode(cpi, x, gf_picture, frame_idx, tpl_frame, rf_idx, bsize,
-                      mi_row, mi_col, &rd);
+                      mi_row, mi_col, &future_rd_diff);
     }
   }
 }