shithub: libvpx

Download patch

ref: 058046c8808f6ea462bd57898276c9ac343aa46a
parent: 25ca4edf74151dcd871c4012ac9748831526f49f
author: Jingning Han <[email protected]>
date: Mon Aug 13 12:52:11 EDT 2018

Fix potential encoder failure case in tpl model

When the group of picture runs over 24 in length, skip the use of
temporal dependency model, since the model assumes maximum 25
lookahead frames.

Change-Id: I6386dd33bcdaf1229fae978130b4c3b43d071918

--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -3640,6 +3640,8 @@
 
   if (cpi->common.show_frame) return orig_rdmult;
 
+  if (cpi->twopass.gf_group.index >= MAX_LAG_BUFFERS) return orig_rdmult;
+
   for (row = mi_row; row < mi_row + mi_high; ++row) {
     for (col = mi_col; col < mi_col + mi_wide; ++col) {
       TplDepStats *this_stats = &tpl_stats[row * tpl_stride + col];
@@ -5450,6 +5452,7 @@
   MACROBLOCK *const x = &td->mb;
   VP9_COMMON *const cm = &cpi->common;
   MACROBLOCKD *const xd = &x->e_mbd;
+  const int gf_group_index = cpi->twopass.gf_group.index;
 
   xd->mi = cm->mi_grid_visible;
   xd->mi[0] = cm->mi;
@@ -5516,7 +5519,8 @@
 
     if (sf->partition_search_type == SOURCE_VAR_BASED_PARTITION)
       source_var_based_partition_search_method(cpi);
-  } else if (cpi->twopass.gf_group.index && cpi->sf.enable_tpl_model) {
+  } else if (gf_group_index && gf_group_index < MAX_LAG_BUFFERS &&
+             cpi->sf.enable_tpl_model) {
     TplDepFrame *tpl_frame = &cpi->tpl_stats[cpi->twopass.gf_group.index];
     TplDepStats *tpl_stats = tpl_frame->tpl_stats_ptr;