shithub: libvpx

Download patch

ref: 3223a3f892c9372f861b7e5f7973df6fefad0885
parent: c12398fe812e75173ff5df43bb283a7d80d88b75
author: Marco Paniconi <marpan@google.com>
date: Sun Mar 11 18:09:14 EDT 2018

vp9-SVC: Fix to choose_partition when LAST ref is NULL.

This causes assert to trigger in choose_partitioning().
This can happen in some cases when enhancement layers
are enabled midway during the stream.

Change-Id: I69c3c8b4b1e3f1c7d8d7294d633ca5ddca148e8b

--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -1244,7 +1244,7 @@
 
   // For the variance computation under SVC mode, we treat the frame as key if
   // the reference (base layer frame) is key frame (i.e., is_key_frame == 1).
-  const int is_key_frame =
+  int is_key_frame =
       (cm->frame_type == KEY_FRAME ||
        (is_one_pass_cbr_svc(cpi) &&
         cpi->svc.layer_context[cpi->svc.temporal_layer_id].is_key_frame));
@@ -1254,6 +1254,15 @@
   int variance4x4downsample[16];
   int segment_id;
   int sb_offset = (cm->mi_stride >> 3) * (mi_row >> 3) + (mi_col >> 3);
+
+  // For SVC: check if LAST frame is NULL and if so treat this frame as a key
+  // frame, for the purpose of the superblock partitioning. This can happen
+  // (LAST is NULL) in some cases where enhancement spatial layers are enabled
+  // dyanmically in the stream and the only reference is the spatial
+  // reference (GOLDEN).
+  if (cpi->use_svc) {
+    if (get_ref_frame_buffer(cpi, LAST_FRAME) == NULL) is_key_frame = 1;
+  }
 
   set_offsets(cpi, tile, x, mi_row, mi_col, BLOCK_64X64);
   segment_id = xd->mi[0]->segment_id;