shithub: libvpx

Download patch

ref: 1099f368e3d5ecdf1f336964f2d7d89b98fa95e9
parent: a513af4baa07da313a033dfde3c8c5164b53041e
author: Daniel Kang <ddkang@google.com>
date: Tue Aug 7 11:29:16 EDT 2012

clamp_mv_min_max -> vp8_clamp_mv_min_max

It's now used in more places

Change-Id: I63f8e1d827404e0b4f203bdb1df361e565d0779d

--- a/vp8/encoder/mbgraph.c
+++ b/vp8/encoder/mbgraph.c
@@ -38,10 +38,6 @@
   int *mvcost_hp[2]    = { &dummy_cost_hp[mv_max_hp + 1], &dummy_cost_hp[mv_max_hp + 1] };
   int *mvsadcost_hp[2] = { &dummy_cost_hp[mv_max_hp + 1], &dummy_cost_hp[mv_max_hp + 1] };
 
-  int col_min = (ref_mv->as_mv.col >> 3) - MAX_FULL_PEL_VAL + ((ref_mv->as_mv.col & 7) ? 1 : 0);
-  int row_min = (ref_mv->as_mv.row >> 3) - MAX_FULL_PEL_VAL + ((ref_mv->as_mv.row & 7) ? 1 : 0);
-  int col_max = (ref_mv->as_mv.col >> 3) + MAX_FULL_PEL_VAL;
-  int row_max = (ref_mv->as_mv.row >> 3) + MAX_FULL_PEL_VAL;
   int tmp_col_min = x->mv_col_min;
   int tmp_col_max = x->mv_col_max;
   int tmp_row_min = x->mv_row_min;
@@ -57,15 +53,7 @@
     further_steps = 0;
   }
 
-  /* Get intersection of UMV window and valid MV window to reduce # of checks in diamond search. */
-  if (x->mv_col_min < col_min)
-    x->mv_col_min = col_min;
-  if (x->mv_col_max > col_max)
-    x->mv_col_max = col_max;
-  if (x->mv_row_min < row_min)
-    x->mv_row_min = row_min;
-  if (x->mv_row_max > row_max)
-    x->mv_row_max = row_max;
+  vp8_clamp_mv_min_max(x, ref_mv);
 
   ref_full.as_mv.col = ref_mv->as_mv.col >> 3;
   ref_full.as_mv.row = ref_mv->as_mv.row >> 3;
--- a/vp8/encoder/mcomp.c
+++ b/vp8/encoder/mcomp.c
@@ -9,6 +9,7 @@
  */
 
 
+#include "vp8/encoder/onyx_int.h"
 #include "mcomp.h"
 #include "vpx_mem/vpx_mem.h"
 #include "vpx_ports/config.h"
@@ -21,6 +22,25 @@
 static int mv_ref_ct [31] [4] [2];
 static int mv_mode_cts [4] [2];
 #endif
+
+void vp8_clamp_mv_min_max(MACROBLOCK *x, int_mv *ref_mv) {
+  int col_min = (ref_mv->as_mv.col >> 3) - MAX_FULL_PEL_VAL +
+      ((ref_mv->as_mv.col & 7) ? 1 : 0);
+  int row_min = (ref_mv->as_mv.row >> 3) - MAX_FULL_PEL_VAL +
+      ((ref_mv->as_mv.row & 7) ? 1 : 0);
+  int col_max = (ref_mv->as_mv.col >> 3) + MAX_FULL_PEL_VAL;
+  int row_max = (ref_mv->as_mv.row >> 3) + MAX_FULL_PEL_VAL;
+
+  /* Get intersection of UMV window and valid MV window to reduce # of checks in diamond search. */
+  if (x->mv_col_min < col_min)
+    x->mv_col_min = col_min;
+  if (x->mv_col_max > col_max)
+    x->mv_col_max = col_max;
+  if (x->mv_row_min < row_min)
+    x->mv_row_min = row_min;
+  if (x->mv_row_max > row_max)
+    x->mv_row_max = row_max;
+}
 
 int vp8_mv_bit_cost(int_mv *mv, int_mv *ref, int *mvcost[2],
                     int Weight, int ishp) {
--- a/vp8/encoder/mcomp.h
+++ b/vp8/encoder/mcomp.h
@@ -25,6 +25,7 @@
 #define MAX_FULL_PEL_VAL ((1 << (MAX_MVSEARCH_STEPS)) - 1)      // Max full pel mv specified in 1 pel units
 #define MAX_FIRST_STEP (1 << (MAX_MVSEARCH_STEPS-1))            // Maximum size of the first step in full pel units
 
+extern void vp8_clamp_mv_min_max(MACROBLOCK *x, int_mv *ref_mv);
 extern int vp8_mv_bit_cost(int_mv *mv, int_mv *ref, int *mvcost[2],
                            int Weight, int ishp);
 extern void vp8_init_dsmotion_compensation(MACROBLOCK *x, int stride);
--- a/vp8/encoder/rdopt.c
+++ b/vp8/encoder/rdopt.c
@@ -2017,23 +2017,6 @@
   *sp = MAX_MVSEARCH_STEPS - 1 - step;
 }
 
-static void clamp_mv_min_max(MACROBLOCK *x, int_mv *best_ref_mv) {
-  int col_min = (best_ref_mv->as_mv.col >> 3) - MAX_FULL_PEL_VAL + ((best_ref_mv->as_mv.col & 7) ? 1 : 0);
-  int row_min = (best_ref_mv->as_mv.row >> 3) - MAX_FULL_PEL_VAL + ((best_ref_mv->as_mv.row & 7) ? 1 : 0);
-  int col_max = (best_ref_mv->as_mv.col >> 3) + MAX_FULL_PEL_VAL;
-  int row_max = (best_ref_mv->as_mv.row >> 3) + MAX_FULL_PEL_VAL;
-
-  /* Get intersection of UMV window and valid MV window to reduce # of checks in diamond search. */
-  if (x->mv_col_min < col_min)
-    x->mv_col_min = col_min;
-  if (x->mv_col_max > col_max)
-    x->mv_col_max = col_max;
-  if (x->mv_row_min < row_min)
-    x->mv_row_min = row_min;
-  if (x->mv_row_max > row_max)
-    x->mv_row_max = row_max;
-}
-
 static int vp8_rd_pick_best_mbsegmentation(VP8_COMP *cpi, MACROBLOCK *x,
                                            int_mv *best_ref_mv, int_mv *second_best_ref_mv, int64_t best_rd,
                                            int *mdcounts, int *returntotrate,
@@ -2074,7 +2057,7 @@
       int tmp_row_min = x->mv_row_min;
       int tmp_row_max = x->mv_row_max;
 
-      clamp_mv_min_max(x, best_ref_mv);
+      vp8_clamp_mv_min_max(x, best_ref_mv);
 
       /* Get 8x8 result */
       bsi.sv_mvp[0].as_int = bsi.mvs[0].as_int;
@@ -3139,7 +3122,7 @@
           int tmp_row_min = x->mv_row_min;
           int tmp_row_max = x->mv_row_max;
 
-          clamp_mv_min_max(x, &best_ref_mv);
+          vp8_clamp_mv_min_max(x, &best_ref_mv);
 
           if (!saddone) {
             vp8_cal_sad(cpi, xd, x, recon_yoffset, &near_sadidx[0]);
--