]> granicus.if.org Git - libvpx/commitdiff
Use mesh full pixel motion search to build the source ARF
authorJingning Han <jingning@google.com>
Tue, 31 Jul 2018 16:43:17 +0000 (09:43 -0700)
committerJingning Han <jingning@google.com>
Thu, 2 Aug 2018 01:15:08 +0000 (18:15 -0700)
Append mesh search to the diamond shape search to refine
the full pixel motion estimation for source ARF generation.
It improves the average compression performance.

Speed 0
        avg PSNR     overall PSNR     SSIM
mid      -0.18%        -0.18%        -0.22%
hd       -0.25%        -0.23%        -0.36%
nflx2k   -0.22%        -0.23%        -0.37%

Speed 1
       avg PSNR     overall PSNR      SSIM
mid     -0.10%         -0.08%        -0.11%
hd      -0.25%         -0.27%        -0.38%
nflx2k  -0.20%         -0.20%        -0.34%

The additional encoding time is close to the sample noise
range. For bus_cif at 1000 kbps, the speed 0 encoding time
goes from 83.0 s -> 83.6 s.

Change-Id: I48647f50ec3e8f7ae4550a4bde831f569f46ecf3

vp9/encoder/vp9_mcomp.c
vp9/encoder/vp9_speed_features.c
vp9/encoder/vp9_speed_features.h
vp9/encoder/vp9_temporal_filter.c

index ba72c0be5ed36d2bc8587cc5cdb2c45fc0d71296..5c19cc0390ad9e38c24712519f2df4df859bcfca 100644 (file)
@@ -2186,6 +2186,8 @@ int vp9_full_pixel_search(VP9_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize,
   const SEARCH_METHODS method = (SEARCH_METHODS)search_method;
   vp9_variance_fn_ptr_t *fn_ptr = &cpi->fn_ptr[bsize];
   int var = 0;
+  int run_mesh_search = (method == MESH);
+
   if (cost_list) {
     cost_list[0] = INT_MAX;
     cost_list[1] = INT_MAX;
@@ -2216,29 +2218,32 @@ int vp9_full_pixel_search(VP9_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize,
                           fn_ptr, 1, ref_mv, tmp_mv);
       break;
     default:
-      assert(method == NSTEP);
+      assert(method == NSTEP || method == MESH);
       var = full_pixel_diamond(cpi, x, mvp_full, step_param, error_per_bit,
                                MAX_MVSEARCH_STEPS - 1 - step_param, 1,
                                cost_list, fn_ptr, ref_mv, tmp_mv);
 
-      // Should we allow a follow on exhaustive search?
-      if ((sf->exhaustive_searches_thresh < INT_MAX) &&
-          !cpi->rc.is_src_frame_alt_ref) {
-        int64_t exhuastive_thr = sf->exhaustive_searches_thresh;
-        exhuastive_thr >>=
-            8 - (b_width_log2_lookup[bsize] + b_height_log2_lookup[bsize]);
-
-        // Threshold variance for an exhaustive full search.
-        if (var > exhuastive_thr) {
-          int var_ex;
-          MV tmp_mv_ex;
-          var_ex = full_pixel_exhaustive(cpi, x, tmp_mv, error_per_bit,
-                                         cost_list, fn_ptr, ref_mv, &tmp_mv_ex);
-
-          if (var_ex < var) {
-            var = var_ex;
-            *tmp_mv = tmp_mv_ex;
-          }
+      // Should we allow a follow on exhaustive search, in regular rd search
+      // mode.
+      if (run_mesh_search == 0) {
+        if ((sf->exhaustive_searches_thresh < INT_MAX) &&
+            !cpi->rc.is_src_frame_alt_ref) {
+          int64_t exhuastive_thr = sf->exhaustive_searches_thresh;
+          exhuastive_thr >>=
+              8 - (b_width_log2_lookup[bsize] + b_height_log2_lookup[bsize]);
+          if (var > exhuastive_thr) run_mesh_search = 1;
+        }
+      }
+
+      if (run_mesh_search) {
+        int var_ex;
+        MV tmp_mv_ex;
+        var_ex = full_pixel_exhaustive(cpi, x, tmp_mv, error_per_bit, cost_list,
+                                       fn_ptr, ref_mv, &tmp_mv_ex);
+
+        if (var_ex < var) {
+          var = var_ex;
+          *tmp_mv = tmp_mv_ex;
         }
       }
       break;
index 6d179f7bd6b86e41f50a8ab84efa5d3eb9ff8c42..fb3d231e94622462368559e0080d98c85432d39b 100644 (file)
@@ -201,17 +201,18 @@ static void set_good_speed_feature_framesize_independent(VP9_COMP *cpi,
 
   if (cpi->twopass.fr_content_type == FC_GRAPHICS_ANIMATION) {
     sf->exhaustive_searches_thresh = (1 << 22);
-    for (i = 0; i < MAX_MESH_STEP; ++i) {
-      int mesh_density_level = 0;
-      sf->mesh_patterns[i].range =
-          good_quality_mesh_patterns[mesh_density_level][i].range;
-      sf->mesh_patterns[i].interval =
-          good_quality_mesh_patterns[mesh_density_level][i].interval;
-    }
   } else {
     sf->exhaustive_searches_thresh = INT_MAX;
   }
 
+  for (i = 0; i < MAX_MESH_STEP; ++i) {
+    const int mesh_density_level = 0;
+    sf->mesh_patterns[i].range =
+        good_quality_mesh_patterns[mesh_density_level][i].range;
+    sf->mesh_patterns[i].interval =
+        good_quality_mesh_patterns[mesh_density_level][i].interval;
+  }
+
   if (speed >= 1) {
     sf->enable_tpl_model = 0;
     sf->prune_ref_frame_for_rect_partitions = 0;
index fd4973fb27e381afedb9e2c1cf441e4d6b209444..406b40755dec6fa9f82fdb12ad2dceee0aa5acc4 100644 (file)
@@ -57,7 +57,8 @@ typedef enum {
   BIGDIA = 3,
   SQUARE = 4,
   FAST_HEX = 5,
-  FAST_DIAMOND = 6
+  FAST_DIAMOND = 6,
+  MESH = 7
 } SEARCH_METHODS;
 
 typedef enum {
index 9a357c1055d6dee3d612a5bfac6e63ce54f349f4..99a03edf37dd091fe7c25a1a4ccf412dbdbe251a 100644 (file)
@@ -230,7 +230,7 @@ static uint32_t temporal_filter_find_matching_mb_c(VP9_COMP *cpi,
   MACROBLOCK *const x = &td->mb;
   MACROBLOCKD *const xd = &x->e_mbd;
   MV_SPEED_FEATURES *const mv_sf = &cpi->sf.mv;
-  const SEARCH_METHODS search_method = NSTEP;
+  const SEARCH_METHODS search_method = MESH;
   int step_param;
   int sadpb = x->sadperbit16;
   uint32_t bestsme = UINT_MAX;