shithub: libvpx

Download patch

ref: bead2e8fb455ae770379f9ac1a21553db7765889
parent: 0fced0bca7376a93a1e061a0c0647f66a4b5add3
author: Deb Mukherjee <[email protected]>
date: Fri Mar 7 12:15:09 EST 2014

Support for a fast diamond search

Adds a fast diamond search which is about 5% faster than FAST_HEX
with only a 0.1% drop in psnr when turned on for both speeds 5 and 7.
This search is turned on for speed 7.

Change-Id: I497630aa88a5148926086bb3038e7975e5f4eb98

--- a/vp9/encoder/vp9_mcomp.c
+++ b/vp9/encoder/vp9_mcomp.c
@@ -884,6 +884,20 @@
                         center_mv, best_mv);
 }
 
+int vp9_fast_dia_search(const MACROBLOCK *x,
+                        MV *ref_mv,
+                        int search_param,
+                        int sad_per_bit,
+                        int do_init_search,
+                        const vp9_variance_fn_ptr_t *vfp,
+                        int use_mvcost,
+                        const MV *center_mv,
+                        MV *best_mv) {
+  return vp9_bigdia_search(x, ref_mv, MAX(MAX_MVSEARCH_STEPS - 2, search_param),
+                           sad_per_bit, do_init_search, vfp, use_mvcost,
+                           center_mv, best_mv);
+}
+
 #undef CHECK_BETTER
 
 int vp9_full_range_search_c(const MACROBLOCK *x, MV *ref_mv, MV *best_mv,
--- a/vp9/encoder/vp9_mcomp.h
+++ b/vp9/encoder/vp9_mcomp.h
@@ -76,6 +76,7 @@
 integer_mv_pattern_search_fn vp9_bigdia_search;
 integer_mv_pattern_search_fn vp9_square_search;
 integer_mv_pattern_search_fn vp9_fast_hex_search;
+integer_mv_pattern_search_fn vp9_fast_dia_search;
 
 typedef int (fractional_mv_step_fp) (
     const MACROBLOCK *x,
--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -872,7 +872,7 @@
   if (speed >= 7) {
     sf->partition_search_type = VAR_BASED_FIXED_PARTITION;
     sf->use_nonrd_pick_mode = 1;
-    sf->search_method = FAST_HEX;
+    sf->search_method = FAST_DIAMOND;
   }
   if (speed >= 8) {
     int i;
--- a/vp9/encoder/vp9_onyx_int.h
+++ b/vp9/encoder/vp9_onyx_int.h
@@ -137,7 +137,8 @@
   HEX = 2,
   BIGDIA = 3,
   SQUARE = 4,
-  FAST_HEX = 5
+  FAST_HEX = 5,
+  FAST_DIAMOND = 6
 } SEARCH_METHODS;
 
 typedef enum {
--- a/vp9/encoder/vp9_pickmode.c
+++ b/vp9/encoder/vp9_pickmode.c
@@ -86,7 +86,12 @@
   mvp_full.col >>= 3;
   mvp_full.row >>= 3;
 
-  if (cpi->sf.search_method == FAST_HEX) {
+  if (cpi->sf.search_method == FAST_DIAMOND) {
+    // NOTE: this returns SAD
+    vp9_fast_dia_search(x, &mvp_full, step_param, sadpb, 0,
+                        &cpi->fn_ptr[bsize], 1,
+                        &ref_mv, &tmp_mv->as_mv);
+  } else if (cpi->sf.search_method == FAST_HEX) {
     // NOTE: this returns SAD
     vp9_fast_hex_search(x, &mvp_full, step_param, sadpb, 0,
                         &cpi->fn_ptr[bsize], 1,
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -2457,7 +2457,14 @@
   // Further step/diamond searches as necessary
   further_steps = (cpi->sf.max_step_search_steps - 1) - step_param;
 
-  if (cpi->sf.search_method == FAST_HEX) {
+  if (cpi->sf.search_method == FAST_DIAMOND) {
+    bestsme = vp9_fast_dia_search(x, &mvp_full, step_param, sadpb, 0,
+                                  &cpi->fn_ptr[bsize], 1,
+                                  &ref_mv, &tmp_mv->as_mv);
+    if (bestsme < INT_MAX)
+      bestsme = vp9_get_mvpred_var(x, &tmp_mv->as_mv, &ref_mv,
+                                   &cpi->fn_ptr[bsize], 1);
+  } else if (cpi->sf.search_method == FAST_HEX) {
     bestsme = vp9_fast_hex_search(x, &mvp_full, step_param, sadpb, 0,
                                   &cpi->fn_ptr[bsize], 1,
                                   &ref_mv, &tmp_mv->as_mv);