]> granicus.if.org Git - libvpx/commitdiff
Prevent parameters that can cause invalid ARF groups.
authorpaulwilkins <paulwilkins@google.com>
Wed, 16 Aug 2017 12:34:49 +0000 (13:34 +0100)
committerpaulwilkins <paulwilkins@google.com>
Wed, 16 Aug 2017 13:33:59 +0000 (14:33 +0100)
Having a very low "lag_in_frames" value could cause the encoder to create
incorrect / corrupt ARF groups including displayed frames that update the
ARF buffer and false overlay frames that are coded at low rate but are not
actually overlays of a real ARF frame.

This is linked to a reported unit test "slow down" where the chosen parameters
(lag of 3 frames) gave rise to such "broken" ARF group(s).

See also BUG=webm:1454

Change-Id: If52d0236243ed5552537d1ea9ed3fed8c867232c

vp9/encoder/vp9_encoder.h
vp9/vp9_cx_iface.c

index d4c7597c6d44d69e45592e5467e0a19fee7578b7..d735fe08beea15ac3fe966666fd82929220e4794 100644 (file)
@@ -867,9 +867,10 @@ static INLINE int denoise_svc(const struct VP9_COMP *const cpi) {
 }
 #endif
 
+#define MIN_LOOKAHEAD_FOR_ARFS 4
 static INLINE int is_altref_enabled(const VP9_COMP *const cpi) {
   return !(cpi->oxcf.mode == REALTIME && cpi->oxcf.rc_mode == VPX_CBR) &&
-         cpi->oxcf.lag_in_frames > 0 &&
+         cpi->oxcf.lag_in_frames >= MIN_LOOKAHEAD_FOR_ARFS &&
          (cpi->oxcf.enable_auto_arf &&
           (!is_two_pass_svc(cpi) ||
            cpi->oxcf.ss_enable_auto_arf[cpi->svc.spatial_layer_id]));
index 876aef3e687d7ac09e9e797ac3e1facea2fb03ee..7b6aa4bf5b86a8b63da402ebe495f61797e18d93 100644 (file)
@@ -191,6 +191,13 @@ static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx,
                 (MAX_LAG_BUFFERS - 1));
   }
 
+  // For formation of valid ARF groups lag_in _frames should be 0 or greater
+  // than the max_gf_interval + 2
+  if (cfg->g_lag_in_frames > 0 && extra_cfg->max_gf_interval > 0 &&
+      cfg->g_lag_in_frames < extra_cfg->max_gf_interval + 2) {
+    ERROR("Set lag in frames to 0 (low delay) or >= (max-gf-interval + 2)");
+  }
+
   if (cfg->rc_resize_allowed == 1) {
     RANGE_CHECK(cfg, rc_scaled_width, 0, cfg->g_w);
     RANGE_CHECK(cfg, rc_scaled_height, 0, cfg->g_h);