]> granicus.if.org Git - libvpx/commitdiff
vp9 screen-content: Adjustments for screen content.
authorMarco Paniconi <marpan@google.com>
Tue, 6 Nov 2018 01:49:39 +0000 (17:49 -0800)
committerMarco Paniconi <marpan@google.com>
Tue, 6 Nov 2018 19:01:52 +0000 (11:01 -0800)
Increase search area, use NSTEP, and in some cases avoid
bsize below 16x16. This for base spatial layer when many blocks
in the frame have motion (from scene detection analysis).

Improves quality for scrolling motion.

Change-Id: If77b43e738a6c43610d4727a95712667088db564

vp9/encoder/vp9_encodeframe.c
vp9/encoder/vp9_ratectrl.c
vp9/encoder/vp9_ratectrl.h
vp9/encoder/vp9_speed_features.c

index fb25fbc5c9a64c8551aa287d956e29a99ea16b5f..4aae37706dccd2913b4481071600a6fde828a7d8 100644 (file)
@@ -1378,6 +1378,20 @@ static int choose_partitioning(VP9_COMP *cpi, const TileInfo *const tile,
       x->sb_use_mv_part = 1;
       x->sb_mvcol_part = mi->mv[0].as_mv.col;
       x->sb_mvrow_part = mi->mv[0].as_mv.row;
+      if (cpi->oxcf.content == VP9E_CONTENT_SCREEN &&
+          cpi->svc.spatial_layer_id == 0 &&
+          cpi->rc.high_num_blocks_with_motion && !x->zero_temp_sad_source &&
+          cm->width >= 1280 && cm->height >= 720) {
+        // Disable split below 16x16 block size when scroll motion is detected.
+        // TODO(marpan/jianj): Improve this condition: issue is that search
+        // range is hard-coded/limited in vp9_int_pro_motion_estimation() so
+        // scroll motion may not be detected here.
+        if ((abs(x->sb_mvrow_part) >= 48 && abs(x->sb_mvcol_part) <= 8) ||
+            y_sad < 100000) {
+          compute_minmax_variance = 0;
+          thresholds[2] = INT64_MAX;
+        }
+      }
     }
 
     y_sad_last = y_sad;
index c8931ae825490a08d8c66e69bf9c1dbb670a3bdc..b6526a262ad225ec257a87c6a90b620a3a8da2bc 100644 (file)
@@ -363,6 +363,7 @@ void vp9_rc_init(const VP9EncoderConfig *oxcf, int pass, RATE_CONTROL *rc) {
   rc->high_source_sad = 0;
   rc->reset_high_source_sad = 0;
   rc->high_source_sad_lagindex = -1;
+  rc->high_num_blocks_with_motion = 0;
   rc->hybrid_intra_scene_change = 0;
   rc->re_encode_maxq_scene_change = 0;
   rc->alt_ref_gf_group = 0;
@@ -2670,6 +2671,7 @@ void vp9_scene_detection_onepass(VP9_COMP *cpi) {
   if (cm->use_highbitdepth) return;
 #endif
   rc->high_source_sad = 0;
+  rc->high_num_blocks_with_motion = 0;
   if (cpi->svc.spatial_layer_id == 0 && src_width == last_src_width &&
       src_height == last_src_height) {
     YV12_BUFFER_CONFIG *frames[MAX_LAG_BUFFERS] = { NULL };
@@ -2788,6 +2790,8 @@ void vp9_scene_detection_onepass(VP9_COMP *cpi) {
         } else {
           rc->avg_source_sad[lagframe_idx] = avg_sad;
         }
+        if (num_zero_temp_sad < (num_samples >> 1))
+          rc->high_num_blocks_with_motion = 1;
       }
     }
     // For CBR non-screen content mode, check if we should reset the rate
index a9f75555e5cad56c2438b6fe0f2850e317669e16..4e827668b0de99697208bd86d17435c535f6a10a 100644 (file)
@@ -175,6 +175,7 @@ typedef struct {
   uint64_t avg_source_sad[MAX_LAG_BUFFERS];
   uint64_t prev_avg_source_sad_lag;
   int high_source_sad_lagindex;
+  int high_num_blocks_with_motion;
   int alt_ref_gf_group;
   int last_frame_is_src_altref;
   int high_source_sad;
index 1f90442654a0e2c397d78eb6330ec5b495a13829..2b0d5e14636a5b2bc338f12b2471c2a212a87776 100644 (file)
@@ -794,6 +794,13 @@ static void set_rt_speed_feature_framesize_independent(
     sf->partition_search_type = FIXED_PARTITION;
     sf->always_this_block_size = BLOCK_64X64;
   }
+  // Special case for screen content: increase motion search when high motion
+  // is detected.
+  if (cpi->oxcf.content == VP9E_CONTENT_SCREEN && cpi->oxcf.speed > 5 &&
+      cpi->rc.high_num_blocks_with_motion && cpi->svc.spatial_layer_id == 0) {
+    sf->mv.search_method = NSTEP;
+    sf->mv.fullpel_search_step_param = 2;
+  }
 }
 
 void vp9_set_speed_features_framesize_dependent(VP9_COMP *cpi) {