shithub: libvpx

Download patch

ref: 56735e5532e86968a094802b89e895c5575d1d4e
parent: c70552c01ed48f46ba9f6ba41c9555b34fd37bce
parent: 058046c8808f6ea462bd57898276c9ac343aa46a
author: Jingning Han <jingning@google.com>
date: Tue Aug 14 11:50:50 EDT 2018

Merge "Fix potential encoder failure case in tpl model"

--- 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;