shithub: libvpx

Download patch

ref: 4c2cfc19cf2ad0e8b6033a48632f168e9b9c193d
parent: 763f8318de2cee41d748539cee5810fc0efcad68
parent: dd606c1595e54e9a3a0acbc6e2f5c92f90f20871
author: Angie Chiang <angiebird@google.com>
date: Wed Dec 12 14:25:53 EST 2018

Merge changes I44da4884,I36e3bcae

* changes:
  Change interface of motion_compensated_prediction
  Move prepare_nb_full_mvs to vp9_mcomp.c

--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -5586,39 +5586,12 @@
 }
 
 #if CONFIG_NON_GREEDY_MV
-static void prepare_nb_full_mvs(const TplDepFrame *tpl_frame, int mi_row,
-                                int mi_col, int rf_idx, BLOCK_SIZE bsize,
-                                int_mv *nb_full_mvs) {
-  const int mi_unit = num_8x8_blocks_wide_lookup[bsize];
-  const int dirs[NB_MVS_NUM][2] = { { -1, 0 }, { 0, -1 }, { 1, 0 }, { 0, 1 } };
-  int i;
-  for (i = 0; i < NB_MVS_NUM; ++i) {
-    int r = dirs[i][0] * mi_unit;
-    int c = dirs[i][1] * mi_unit;
-    if (mi_row + r >= 0 && mi_row + r < tpl_frame->mi_rows && mi_col + c >= 0 &&
-        mi_col + c < tpl_frame->mi_cols) {
-      const TplDepStats *tpl_ptr =
-          &tpl_frame
-               ->tpl_stats_ptr[(mi_row + r) * tpl_frame->stride + mi_col + c];
-      if (tpl_ptr->ready[rf_idx]) {
-        nb_full_mvs[i].as_mv = get_full_mv(&tpl_ptr->mv_arr[rf_idx].as_mv);
-      } else {
-        nb_full_mvs[i].as_int = INVALID_MV;
-      }
-    } else {
-      nb_full_mvs[i].as_int = INVALID_MV;
-    }
-  }
-}
-#endif
-
-#if CONFIG_NON_GREEDY_MV
 uint32_t motion_compensated_prediction(VP9_COMP *cpi, ThreadData *td,
                                        int frame_idx, uint8_t *cur_frame_buf,
                                        uint8_t *ref_frame_buf, int stride,
                                        BLOCK_SIZE bsize, int mi_row, int mi_col,
-                                       TplDepStats *tpl_stats, int rf_idx) {
-  MV *mv = &tpl_stats->mv_arr[rf_idx].as_mv;
+                                       MV *mv, int rf_idx, double *mv_dist,
+                                       double *mv_cost) {
 #else   // CONFIG_NON_GREEDY_MV
 uint32_t motion_compensated_prediction(VP9_COMP *cpi, ThreadData *td,
                                        int frame_idx, uint8_t *cur_frame_buf,
@@ -5664,12 +5637,11 @@
 #if CONFIG_NON_GREEDY_MV
   (void)search_method;
   (void)sadpb;
-  prepare_nb_full_mvs(&cpi->tpl_stats[frame_idx], mi_row, mi_col, rf_idx, bsize,
-                      nb_full_mvs);
-  vp9_full_pixel_diamond_new(
-      cpi, x, &best_ref_mv1_full, step_param, lambda, 1, &cpi->fn_ptr[bsize],
-      nb_full_mvs, NB_MVS_NUM, &tpl_stats->mv_arr[rf_idx].as_mv,
-      &tpl_stats->mv_dist[rf_idx], &tpl_stats->mv_cost[rf_idx]);
+  vp9_prepare_nb_full_mvs(&cpi->tpl_stats[frame_idx], mi_row, mi_col, rf_idx,
+                          bsize, nb_full_mvs);
+  vp9_full_pixel_diamond_new(cpi, x, &best_ref_mv1_full, step_param, lambda, 1,
+                             &cpi->fn_ptr[bsize], nb_full_mvs, NB_MVS_NUM, mv,
+                             mv_dist, mv_cost);
 #else
   (void)frame_idx;
   (void)mi_row;
@@ -6113,7 +6085,8 @@
     motion_compensated_prediction(
         cpi, td, frame_idx, xd->cur_buf->y_buffer + mb_y_offset,
         ref_frame[rf_idx]->y_buffer + mb_y_offset, xd->cur_buf->y_stride, bsize,
-        mi_row, mi_col, tpl_stats, rf_idx);
+        mi_row, mi_col, &tpl_stats->mv_arr[rf_idx].as_mv, rf_idx,
+        &tpl_stats->mv_dist[rf_idx], &tpl_stats->mv_cost[rf_idx]);
   }
 }
 
@@ -6357,8 +6330,8 @@
 #if RE_COMPUTE_MV_INCONSISTENCY
           MV full_mv;
           int_mv nb_full_mvs[NB_MVS_NUM];
-          prepare_nb_full_mvs(tpl_frame, mi_row, mi_col, rf_idx, bsize,
-                              nb_full_mvs);
+          vp9_prepare_nb_full_mvs(tpl_frame, mi_row, mi_col, rf_idx, bsize,
+                                  nb_full_mvs);
           full_mv.row = this_tpl_stats->mv_arr[rf_idx].as_mv.row >> 3;
           full_mv.col = this_tpl_stats->mv_arr[rf_idx].as_mv.col >> 3;
           this_tpl_stats->mv_cost[rf_idx] =
--- a/vp9/encoder/vp9_mcomp.c
+++ b/vp9/encoder/vp9_mcomp.c
@@ -1879,6 +1879,32 @@
   }
   return bestsad;
 }
+
+void vp9_prepare_nb_full_mvs(const TplDepFrame *tpl_frame, int mi_row,
+                             int mi_col, int rf_idx, BLOCK_SIZE bsize,
+                             int_mv *nb_full_mvs) {
+  const int mi_width = num_8x8_blocks_wide_lookup[bsize];
+  const int mi_height = num_8x8_blocks_high_lookup[bsize];
+  const int dirs[NB_MVS_NUM][2] = { { -1, 0 }, { 0, -1 }, { 1, 0 }, { 0, 1 } };
+  int i;
+  for (i = 0; i < NB_MVS_NUM; ++i) {
+    int r = dirs[i][0] * mi_height;
+    int c = dirs[i][1] * mi_width;
+    if (mi_row + r >= 0 && mi_row + r < tpl_frame->mi_rows && mi_col + c >= 0 &&
+        mi_col + c < tpl_frame->mi_cols) {
+      const TplDepStats *tpl_ptr =
+          &tpl_frame
+               ->tpl_stats_ptr[(mi_row + r) * tpl_frame->stride + mi_col + c];
+      if (tpl_ptr->ready[rf_idx]) {
+        nb_full_mvs[i].as_mv = get_full_mv(&tpl_ptr->mv_arr[rf_idx].as_mv);
+      } else {
+        nb_full_mvs[i].as_int = INVALID_MV;
+      }
+    } else {
+      nb_full_mvs[i].as_int = INVALID_MV;
+    }
+  }
+}
 #endif  // CONFIG_NON_GREEDY_MV
 
 int vp9_diamond_search_sad_c(const MACROBLOCK *x, const search_site_config *cfg,
--- a/vp9/encoder/vp9_mcomp.h
+++ b/vp9/encoder/vp9_mcomp.h
@@ -143,6 +143,11 @@
   out_mv.col = mv->col >> 3;
   return out_mv;
 }
+
+struct TplDepFrame;
+void vp9_prepare_nb_full_mvs(const struct TplDepFrame *tpl_frame, int mi_row,
+                             int mi_col, int rf_idx, BLOCK_SIZE bsize,
+                             int_mv *nb_full_mvs);
 #endif  // CONFIG_NON_GREEDY_MV
 #ifdef __cplusplus
 }  // extern "C"