shithub: libvpx

Download patch

ref: 6247b239bca25cadb5fb16b1bc6f4c77e764c4ff
parent: f8ff3e5d4783b6e30950927d6490986313a55d5f
author: Yaowu Xu <yaowu@google.com>
date: Thu Dec 13 18:53:11 EST 2012

reset segement map on key frame

This is to fix a decoder crash when decoder skips a number of frame to
continue decoding from a later key frame.

Change-Id: I3ba116eba6c3440e0528a21f53745f694302e4ad

--- a/vp9/decoder/vp9_decodframe.c
+++ b/vp9/decoder/vp9_decodframe.c
@@ -38,7 +38,7 @@
 
 #define COEFCOUNT_TESTING
 
-// #define DEC_DEBUG
+//#define DEC_DEBUG
 #ifdef DEC_DEBUG
 int dec_debug = 0;
 #endif
@@ -978,8 +978,8 @@
       }
 #endif
 #ifdef DEC_DEBUG
-      dec_debug = (pbi->common.current_video_frame == 46 &&
-                   mb_row == 5 && mb_col == 2);
+      dec_debug = (pbi->common.current_video_frame == 1 &&
+                   mb_row == 2 && mb_col == 8);
       if (dec_debug)
 #if CONFIG_SUPERBLOCKS
         printf("Enter Debug %d %d sb %d\n", mb_row, mb_col,
@@ -1139,7 +1139,10 @@
   MACROBLOCKD *const xd  = &pbi->mb;
 
   if (pc->frame_type == KEY_FRAME) {
-    /* Various keyframe initializations */
+
+    if (pc->last_frame_seg_map)
+      vpx_memset(pc->last_frame_seg_map, 0, (pc->mb_rows * pc->mb_cols));
+
     vp9_init_mv_probs(pc);
 
     vp9_init_mbmode_probs(pc);
@@ -1182,6 +1185,7 @@
     vp9_update_mode_info_border(pc, pc->mip);
     vp9_update_mode_info_in_image(pc, pc->mi);
 
+
   } else {
 
     if (!pc->use_bilinear_mc_filter)
@@ -1423,6 +1427,7 @@
     pc->ref_pred_probs[0] = 120;
     pc->ref_pred_probs[1] = 80;
     pc->ref_pred_probs[2] = 40;
+
   } else {
     for (i = 0; i < PREDICTION_PROBS; i++) {
       if (vp9_read_bit(&header_bc))
--- a/vp9/encoder/vp9_ratectrl.c
+++ b/vp9/encoder/vp9_ratectrl.c
@@ -249,6 +249,9 @@
   vp9_init_mbmode_probs(& cpi->common);
   vp9_default_bmode_probs(cm->fc.bmode_prob);
 
+  if(cm->last_frame_seg_map)
+    vpx_memset(cm->last_frame_seg_map, 0, (cm->mb_rows * cm->mb_cols));
+
   vp9_init_mv_probs(& cpi->common);
 
   // cpi->common.filter_level = 0;      // Reset every key frame.
--