From: Tero Rintaluoma <teror@google.com>
Date: Thu, 5 Dec 2013 09:42:47 +0000 (+0200)
Subject: Fix show existing frame
X-Git-Tag: v1.4.0~2764^2
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=047b0b01bbe8668c02438532520ea3c92b87f2f3;p=libvpx

Fix show existing frame

- Disable mode info update in case where current frame is coded
  as "show existing frame".
- Should fix issue 676.

Change-Id: Ibee681850eb307f982da6528d3e31cb94f881c08
---

diff --git a/vp9/common/vp9_onyxc_int.h b/vp9/common/vp9_onyxc_int.h
index 751accf02..b28d45699 100644
--- a/vp9/common/vp9_onyxc_int.h
+++ b/vp9/common/vp9_onyxc_int.h
@@ -133,6 +133,7 @@ typedef struct VP9Common {
 
   int show_frame;
   int last_show_frame;
+  int show_existing_frame;
 
   // Flag signaling that the frame is encoded using only INTRA modes.
   int intra_only;
diff --git a/vp9/decoder/vp9_decodeframe.c b/vp9/decoder/vp9_decodeframe.c
index 9b6740eea..9d82cacd7 100644
--- a/vp9/decoder/vp9_decodeframe.c
+++ b/vp9/decoder/vp9_decodeframe.c
@@ -1067,7 +1067,8 @@ static size_t read_uncompressed_header(VP9D_COMP *pbi,
   cm->version = vp9_rb_read_bit(rb);
   RESERVED;
 
-  if (vp9_rb_read_bit(rb)) {
+  cm->show_existing_frame = vp9_rb_read_bit(rb);
+  if (cm->show_existing_frame) {
     // show an existing frame directly
     int frame_to_show = cm->ref_frame_map[vp9_rb_read_literal(rb, 3)];
     ref_cnt_fb(cm->fb_idx_ref_cnt, &cm->new_fb_idx, frame_to_show);
diff --git a/vp9/decoder/vp9_onyxd_if.c b/vp9/decoder/vp9_onyxd_if.c
index 740ad72cb..b06a50f9c 100644
--- a/vp9/decoder/vp9_onyxd_if.c
+++ b/vp9/decoder/vp9_onyxd_if.c
@@ -392,23 +392,25 @@ int vp9_receive_compressed_data(VP9D_PTR ptr,
 
   cm->last_show_frame = cm->show_frame;
   if (cm->show_frame) {
-    // current mip will be the prev_mip for the next frame
-    MODE_INFO *temp = cm->prev_mip;
-    MODE_INFO **temp2 = cm->prev_mi_grid_base;
-    cm->prev_mip = cm->mip;
-    cm->mip = temp;
-    cm->prev_mi_grid_base = cm->mi_grid_base;
-    cm->mi_grid_base = temp2;
-
-    // update the upper left visible macroblock ptrs
-    cm->mi = cm->mip + cm->mode_info_stride + 1;
-    cm->prev_mi = cm->prev_mip + cm->mode_info_stride + 1;
-    cm->mi_grid_visible = cm->mi_grid_base + cm->mode_info_stride + 1;
-    cm->prev_mi_grid_visible = cm->prev_mi_grid_base + cm->mode_info_stride + 1;
-
-    pbi->mb.mi_8x8 = cm->mi_grid_visible;
-    pbi->mb.mi_8x8[0] = cm->mi;
-
+    if (!cm->show_existing_frame) {
+      // current mip will be the prev_mip for the next frame
+      MODE_INFO *temp = cm->prev_mip;
+      MODE_INFO **temp2 = cm->prev_mi_grid_base;
+      cm->prev_mip = cm->mip;
+      cm->mip = temp;
+      cm->prev_mi_grid_base = cm->mi_grid_base;
+      cm->mi_grid_base = temp2;
+
+      // update the upper left visible macroblock ptrs
+      cm->mi = cm->mip + cm->mode_info_stride + 1;
+      cm->prev_mi = cm->prev_mip + cm->mode_info_stride + 1;
+      cm->mi_grid_visible = cm->mi_grid_base + cm->mode_info_stride + 1;
+      cm->prev_mi_grid_visible = cm->prev_mi_grid_base +
+                                 cm->mode_info_stride + 1;
+
+      pbi->mb.mi_8x8 = cm->mi_grid_visible;
+      pbi->mb.mi_8x8[0] = cm->mi;
+    }
     cm->current_video_frame++;
   }