shithub: libvpx

Download patch

ref: 0aaf170c13e408a8c2be2e0275538744dde30249
parent: 09ed15d255d96e87ef388ddda7c276dd14042c37
author: Marco Paniconi <marpan@google.com>
date: Mon Nov 26 10:52:21 EST 2018

vp9-svc: Put check on usage of long term temporal ref.

If the scale factor of the golden long term reference
is different from the last reference then disable usage
of long term reference.

This should not happen, but add this as a check against
some possibly incorrect update of the svc configuration.

Change-Id: Ic1062d4384e005007d8c922813fa8ad188d8fa98

--- a/vp9/encoder/vp9_pickmode.c
+++ b/vp9/encoder/vp9_pickmode.c
@@ -1732,11 +1732,21 @@
   if (!cpi->use_svc ||
       (svc->use_gf_temporal_ref_current_layer &&
        !svc->layer_context[svc->temporal_layer_id].is_key_frame)) {
+    struct scale_factors *const sf_last = &cm->frame_refs[LAST_FRAME - 1].sf;
+    struct scale_factors *const sf_golden =
+        &cm->frame_refs[GOLDEN_FRAME - 1].sf;
     gf_temporal_ref = 1;
-    if (cpi->rc.avg_frame_low_motion > 70)
-      thresh_svc_skip_golden = 500;
-    else
-      thresh_svc_skip_golden = 0;
+    // For temporal long term prediction, check that the golden reference
+    // is same scale as last reference, otherwise disable.
+    if ((sf_last->x_scale_fp != sf_golden->x_scale_fp) ||
+        (sf_last->y_scale_fp != sf_golden->y_scale_fp)) {
+      gf_temporal_ref = 0;
+    } else {
+      if (cpi->rc.avg_frame_low_motion > 70)
+        thresh_svc_skip_golden = 500;
+      else
+        thresh_svc_skip_golden = 0;
+    }
   }
 
   init_ref_frame_cost(cm, xd, ref_frame_cost);