Use adapt_partition for ARF in 1 pass.
authorMarco <marpan@google.com>
Tue, 3 Oct 2017 17:55:55 +0000 (10:55 -0700)
committerMarco <marpan@google.com>
Tue, 3 Oct 2017 18:49:55 +0000 (11:49 -0700)
For speed 6 real-time mode: use adapt_partition
on ARF frame instead of REFERENCE_PARTITION (which is slower).
This requires enabling compute_source_sad_onepass for no-show_frames.

Speedup of ~3-5% on some clips that heavily use ARF,
small loss (~0.2%) in quality on ytlive set.

Change-Id: Ib50acc97df06458244a6ac55d2bd882c30012536

vp9/encoder/vp9_encodeframe.c
vp9/encoder/vp9_encoder.c
vp9/encoder/vp9_speed_features.c

index a401176..4d7d285 100644 (file)
@@ -4183,7 +4183,7 @@ static void encode_nonrd_sb_row(VP9_COMP *cpi, ThreadData *td,
       if (sf->adapt_partition_source_sad &&
           (cpi->oxcf.rc_mode == VPX_VBR && !cpi->rc.is_src_frame_alt_ref &&
            source_sad > sf->adapt_partition_thresh &&
-           cpi->refresh_golden_frame))
+           (cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame)))
         partition_search_type = REFERENCE_PARTITION;
     }
 
index 37ecca7..765c057 100644 (file)
@@ -3438,8 +3438,7 @@ static void encode_without_recode_loop(VP9_COMP *cpi, size_t *size,
   // Flag to check if its valid to compute the source sad (used for
   // scene detection and for superblock content state in CBR mode).
   // The flag may get reset below based on SVC or resizing state.
-  cpi->compute_source_sad_onepass =
-      cpi->oxcf.mode == REALTIME && cm->show_frame;
+  cpi->compute_source_sad_onepass = cpi->oxcf.mode == REALTIME;
 
   vpx_clear_system_state();
 
@@ -3532,7 +3531,7 @@ static void encode_without_recode_loop(VP9_COMP *cpi, size_t *size,
   // For other cases (e.g., CBR mode) use it for 5 <= speed < 8 for now
   // (need to check encoding time cost for doing this for speed 8).
   cpi->rc.high_source_sad = 0;
-  if (cpi->compute_source_sad_onepass &&
+  if (cpi->compute_source_sad_onepass && cm->show_frame &&
       (cpi->oxcf.rc_mode == VPX_VBR ||
        cpi->oxcf.content == VP9E_CONTENT_SCREEN ||
        (cpi->oxcf.speed >= 5 && cpi->oxcf.speed < 8 && !cpi->use_svc)))
index c9821de..4dcecd5 100644 (file)
@@ -527,12 +527,6 @@ static void set_rt_speed_feature_framesize_independent(
 
   if (speed >= 6) {
     sf->partition_search_type = VAR_BASED_PARTITION;
-    if (cpi->oxcf.rc_mode == VPX_VBR && cpi->oxcf.lag_in_frames > 0 &&
-        !is_keyframe) {
-      if (sf->use_altref_onepass && cpi->refresh_alt_ref_frame) {
-        sf->partition_search_type = REFERENCE_PARTITION;
-      }
-    }
     // Turn on this to use non-RD key frame coding mode.
     sf->use_nonrd_pick_mode = 1;
     sf->mv.search_method = NSTEP;
@@ -545,6 +539,8 @@ static void set_rt_speed_feature_framesize_independent(
       sf->adapt_partition_source_sad = 1;
       sf->adapt_partition_thresh =
           (cm->width * cm->height <= 640 * 360) ? 40000 : 80000;
+      if (sf->use_altref_onepass && cpi->refresh_alt_ref_frame && !is_keyframe)
+        sf->adapt_partition_thresh = (3 * sf->adapt_partition_thresh) >> 2;
       if (cpi->content_state_sb_fd == NULL &&
           (!cpi->use_svc ||
            cpi->svc.spatial_layer_id == cpi->svc.number_spatial_layers - 1)) {