shithub: libvpx

Download patch

ref: e606cac04660880c462debde7e952b9b09855e57
parent: 2291563ba84b312ebefe26134dc27236d5ef81fb
author: Paul Wilkins <paulwilkins@google.com>
date: Mon Jun 24 11:19:16 EDT 2013

Change meaning of cpi->sf.first_step and rename.

Renamed cpi->sf.first_step to cpi->sf.reduce_first_step_size
and changed its meaning such that it is a delta applied to
reduce the default first step size (>> x) in the motion search
rather than an absolute value.

The default first step size is already changed according to the image
dimensions (smaller for smaller images). cpi->sf.reduce_first_step_size
now applies a further correction from the default.

Change-Id: Ia94e08bc24c67b604831f980909af7e982fcd16d

--- a/vp9/encoder/vp9_mbgraph.c
+++ b/vp9/encoder/vp9_mbgraph.c
@@ -35,8 +35,9 @@
   int_mv ref_full;
 
   // Further step/diamond searches as necessary
-  int step_param = cpi->sf.first_step +
+  int step_param = cpi->sf.reduce_first_step_size +
       (cpi->speed < 8 ? (cpi->speed > 5 ? 1 : 0) : 2);
+  step_param = MIN(step_param, (cpi->sf.max_step_search_steps - 2));
 
   vp9_clamp_mv_min_max(x, ref_mv);
 
--- a/vp9/encoder/vp9_mcomp.c
+++ b/vp9/encoder/vp9_mcomp.c
@@ -38,16 +38,17 @@
     x->mv_row_max = row_max;
 }
 
-int vp9_init_search_range(int width, int height) {
+int vp9_init_search_range(VP9_COMP *cpi, int size) {
   int sr = 0;
-  int frm = MIN(width, height);
 
-  while ((frm << sr) < MAX_FULL_PEL_VAL)
+  while ((size << sr) < MAX_FULL_PEL_VAL)
     sr++;
 
   if (sr)
     sr--;
 
+  sr += cpi->sf.reduce_first_step_size;
+  sr = MIN(sr, (cpi->sf.max_step_search_steps - 2));
   return sr;
 }
 
--- a/vp9/encoder/vp9_mcomp.h
+++ b/vp9/encoder/vp9_mcomp.h
@@ -24,15 +24,15 @@
 #define MAX_FIRST_STEP (1 << (MAX_MVSEARCH_STEPS-1))
 
 void vp9_clamp_mv_min_max(MACROBLOCK *x, int_mv *ref_mv);
-int vp9_init_search_range(int width, int height);
-
 int vp9_mv_bit_cost(int_mv *mv, int_mv *ref, int *mvjcost,
                            int *mvcost[2], int weight, int ishp);
 void vp9_init_dsmotion_compensation(MACROBLOCK *x, int stride);
 void vp9_init3smotion_compensation(MACROBLOCK *x,  int stride);
 
-// Runs sequence of diamond searches in smaller steps for RD
 struct VP9_COMP;
+int vp9_init_search_range(struct VP9_COMP *cpi, int size);
+
+// Runs sequence of diamond searches in smaller steps for RD
 int vp9_full_pixel_diamond(struct VP9_COMP *cpi, MACROBLOCK *x,
                            int_mv *mvp_full, int step_param,
                            int sadpb, int further_steps, int do_refine,
--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -680,7 +680,7 @@
   sf->half_pixel_search = 1;
   sf->iterative_sub_pixel = 1;
   sf->optimize_coefficients = !cpi->oxcf.lossless;
-  sf->first_step = 0;
+  sf->reduce_first_step_size = 0;
   sf->max_step_search_steps = MAX_MVSEARCH_STEPS;
   sf->comp_inter_joint_search_thresh = BLOCK_SIZE_AB4X4;
   sf->adpative_rd_thresh = 0;
@@ -721,7 +721,7 @@
       if (speed == 1) {
         sf->comp_inter_joint_search_thresh = BLOCK_SIZE_TYPES;
         sf->optimize_coefficients = 0;
-        sf->first_step = 1;
+        sf->reduce_first_step_size = 1;
         sf->use_avoid_tested_higherror = 1;
         sf->adjust_thresholds_by_speed = 1;
         sf->use_largest_txform = !(cpi->common.frame_type == KEY_FRAME ||
@@ -731,27 +731,27 @@
       if (speed == 2) {
         sf->comp_inter_joint_search_thresh = BLOCK_SIZE_SB8X8;
         sf->use_lastframe_partitioning = 1;
-        sf->first_step = 0;
+        sf->reduce_first_step_size = 0;
       }
       if (speed == 3) {
         sf->comp_inter_joint_search_thresh = BLOCK_SIZE_SB8X8;
         sf->partition_by_variance = 1;
-        sf->first_step = 0;
+        sf->reduce_first_step_size = 0;
       }
       if (speed == 4) {
-        sf->first_step = 0;
+        sf->reduce_first_step_size = 0;
         sf->comp_inter_joint_search_thresh = BLOCK_SIZE_SB8X8;
         sf->use_one_partition_size_always = 1;
         sf->always_this_block_size = BLOCK_SIZE_MB16X16;
       }
       if (speed == 2) {
-        sf->first_step = 0;
+        sf->reduce_first_step_size = 0;
         sf->comp_inter_joint_search_thresh = BLOCK_SIZE_SB8X8;
         sf->use_partitions_less_than = 1;
         sf->less_than_block_size = BLOCK_SIZE_MB16X16;
       }
       if (speed == 3) {
-        sf->first_step = 0;
+        sf->reduce_first_step_size = 0;
         sf->comp_inter_joint_search_thresh = BLOCK_SIZE_SB8X8;
         sf->use_partitions_greater_than = 1;
         sf->greater_than_block_size = BLOCK_SIZE_SB8X8;
--- a/vp9/encoder/vp9_onyx_int.h
+++ b/vp9/encoder/vp9_onyx_int.h
@@ -210,7 +210,7 @@
   int quarter_pixel_search;
   int thresh_mult[MAX_MODES];
   int max_step_search_steps;
-  int first_step;
+  int reduce_first_step_size;
   int optimize_coefficients;
   int search_best_filter;
   int static_segmentation;
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -1989,12 +1989,11 @@
   MB_MODE_INFO *mbmi = &xd->mode_info_context->mbmi;
   struct buf_2d backup_yv12[MAX_MB_PLANE] = {{0}};
   int bestsme = INT_MAX;
-  int further_steps, step_param = cpi->sf.first_step;
+  int further_steps, step_param;
   int sadpb = x->sadperbit16;
   int_mv mvp_full;
   int ref = mbmi->ref_frame[0];
   int_mv ref_mv = mbmi->ref_mvs[ref][0];
-  int sr = 0;
   const enum BlockSize block_size = get_plane_block_size(bsize, &xd->plane[0]);
 
   int tmp_col_min = x->mv_col_min;
@@ -2018,7 +2017,8 @@
 
   vp9_clamp_mv_min_max(x, &ref_mv);
 
-  sr = vp9_init_search_range(cpi->common.width, cpi->common.height);
+  step_param = vp9_init_search_range(
+                 cpi, MIN(cpi->common.width, cpi->common.height));
 
   // mvp_full.as_int = ref_mv[0].as_int;
   mvp_full.as_int =
@@ -2026,9 +2026,6 @@
 
   mvp_full.as_mv.col >>= 3;
   mvp_full.as_mv.row >>= 3;
-
-  // adjust search range according to sr from mv prediction
-  step_param = MAX(step_param, sr);
 
   // Further step/diamond searches as necessary
   further_steps = (cpi->sf.max_step_search_steps - 1) - step_param;
--- a/vp9/encoder/vp9_temporal_filter.c
+++ b/vp9/encoder/vp9_temporal_filter.c
@@ -148,9 +148,10 @@
 
   // Further step/diamond searches as necessary
   if (cpi->speed < 8)
-    step_param = cpi->sf.first_step + ((cpi->speed > 5) ? 1 : 0);
+    step_param = cpi->sf.reduce_first_step_size + ((cpi->speed > 5) ? 1 : 0);
   else
-    step_param = cpi->sf.first_step + 2;
+    step_param = cpi->sf.reduce_first_step_size + 2;
+  step_param = MIN(step_param, (cpi->sf.max_step_search_steps - 2));
 
   /*cpi->sf.search_method == HEX*/
   // TODO Check that the 16x16 vf & sdf are selected here