shithub: libvpx

Download patch

ref: 1fcd5cca3c810d37b8d81c69b6ebfe04c9f4cd4c
parent: 0d88e15454b632d92404dd6a7181c58d9985e2a2
author: Jerome Jiang <jianj@google.com>
date: Fri May 12 11:57:23 EDT 2017

vp9: speed 8: Fix seg fault in partition copy when drop frames.

BUG=webm:1433

Change-Id: I4f3984ef28660d3218d48007d7c977bdbdaf8af6

--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -4077,6 +4077,7 @@
       ++cm->current_video_frame;
       cpi->ext_refresh_frame_flags_pending = 0;
       cpi->svc.rc_drop_superframe = 1;
+      cpi->last_frame_dropped = 1;
       // TODO(marpan): Advancing the svc counters on dropped frames can break
       // the referencing scheme for the fixed svc patterns defined in
       // vp9_one_pass_cbr_svc_start_layer(). Look into fixing this issue, but
@@ -4083,6 +4084,7 @@
       // for now, don't advance the svc frame counters on dropped frame.
       // if (cpi->use_svc)
       //   vp9_inc_frame_in_layer(cpi);
+
       return;
     }
   }
@@ -4099,6 +4101,8 @@
   } else {
     encode_with_recode_loop(cpi, size, dest);
   }
+
+  cpi->last_frame_dropped = 0;
 
   // Disable segmentation if it decrease rate/distortion ratio
   if (cpi->oxcf.aq_mode == LOOKAHEAD_AQ)
--- a/vp9/encoder/vp9_encoder.h
+++ b/vp9/encoder/vp9_encoder.h
@@ -704,6 +704,8 @@
   uint8_t *prev_variance_low;
   uint8_t *copied_frame_cnt;
   uint8_t max_copied_frame;
+  // If the last frame is dropped, we don't copy partition.
+  uint8_t last_frame_dropped;
 
   // For each superblock: keeps track of the last time (in frame distance) the
   // the superblock did not have low source sad.
--- a/vp9/encoder/vp9_speed_features.c
+++ b/vp9/encoder/vp9_speed_features.c
@@ -565,8 +565,9 @@
   if (speed >= 8) {
     sf->adaptive_rd_thresh = 4;
     // Enable partition copy
-    if (!cpi->use_svc && !cpi->resize_pending && cpi->resize_state == ORIG &&
-        !cpi->external_resize && cpi->oxcf.resize_mode == RESIZE_NONE) {
+    if (!cpi->last_frame_dropped && !cpi->use_svc && !cpi->resize_pending &&
+        cpi->resize_state == ORIG && !cpi->external_resize &&
+        cpi->oxcf.resize_mode == RESIZE_NONE) {
       sf->copy_partition_flag = 1;
       cpi->max_copied_frame = 4;
     }