shithub: libvpx

Download patch

ref: ec7ab809c55ceca4cfd6c768e4ebc02feef6a51f
parent: d2641ff1df06ce974f2a1fac4336843c358acecd
author: Paul Wilkins <paulwilkins@google.com>
date: Fri Sep 28 12:54:03 EDT 2018

Adjustment of GOP intra factor for multi-layer.

This provides and alternative (still to be tuned for edge cases)
approach to adjusting the gop intra factor when multi-layer coding
is in effect that does not alter single layer coding.

Change-Id: Iba86d65a6e68e86aa031b7e1f0b6a4c55761b1b8

--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -2482,6 +2482,8 @@
   const int is_key_frame = frame_is_intra_only(cm);
   const int arf_active_or_kf = is_key_frame || rc->source_alt_ref_active;
 
+  double gop_intra_factor = 1.0;
+
   // Reset the GF group data structures unless this is a key
   // frame in which case it will already have been done.
   if (is_key_frame == 0) {
@@ -2549,6 +2551,17 @@
       active_max_gf_interval = rc->frames_to_key / 2;
   }
 
+  if (cpi->multi_layer_arf) {
+    int layers = 0;
+    int max_layers = VPXMIN(MAX_ARF_LAYERS, cpi->oxcf.enable_auto_arf);
+
+    // Adapt the intra_error factor to active_max_gf_interval limit.
+    for (i = active_max_gf_interval; i > 0; i >>= 1) ++layers;
+
+    layers = VPXMIN(max_layers, layers);
+    gop_intra_factor += (layers * 0.25);
+  }
+
   i = 0;
   while (i < rc->static_scene_max_gf_interval && i < rc->frames_to_key) {
     ++i;
@@ -2625,7 +2638,7 @@
             (!flash_detected) &&
             ((mv_ratio_accumulator > mv_ratio_accumulator_thresh) ||
              (abs_mv_in_out_accumulator > abs_mv_in_out_thresh) ||
-             (sr_accumulator > next_frame.intra_error)))) {
+             (sr_accumulator > gop_intra_factor * next_frame.intra_error)))) {
       break;
     }