Safely swap the show frame buffer pointer in show_existing mode
authorJingning Han <jingning@google.com>
Tue, 21 Aug 2018 18:12:48 +0000 (11:12 -0700)
committerJingning Han <jingning@google.com>
Tue, 21 Aug 2018 18:14:24 +0000 (11:14 -0700)
Point the current frame buffer towards the existing reference frame.
In the meantime, release the original new_fb pointer.

Change-Id: Ic83a698cac5cdaaabdf61acffb936ec130a84d1c

vp9/encoder/vp9_encoder.c

index 0151e1b..d9d38b7 100644 (file)
@@ -4839,8 +4839,10 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi, size_t *size,
   // current ARF will be directly used as the final reconstructed frame. This is
   // an encoder control scheme. One could in principle explore other
   // possibilities to arrange the reference frame buffer and their coding order.
-  if (cm->show_existing_frame)
-    cm->new_fb_idx = cm->ref_frame_map[cpi->alt_fb_idx];
+  if (cm->show_existing_frame) {
+    ref_cnt_fb(cm->buffer_pool->frame_bufs, &cm->new_fb_idx,
+               cm->ref_frame_map[cpi->alt_fb_idx]);
+  }
 
   cpi->last_frame_dropped = 0;
   cpi->svc.last_layer_dropped[cpi->svc.spatial_layer_id] = 0;