shithub: libvpx

Download patch

ref: c8678fb7f38024345462cfab3b34d649548ff445
parent: fe7b869104806752a26a262dc60923639d9a384f
author: Marco <marpan@google.com>
date: Tue Oct 3 06:55:55 EDT 2017

Use adapt_partition for ARF in 1 pass.

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

--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -4183,7 +4183,7 @@
       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;
     }
 
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -3438,8 +3438,7 @@
   // 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 @@
   // 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)))
--- a/vp9/encoder/vp9_speed_features.c
+++ b/vp9/encoder/vp9_speed_features.c
@@ -527,12 +527,6 @@
 
   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 @@
       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)) {