From 69713537bb4cb223c37adf631c2a3654e2e41cc3 Mon Sep 17 00:00:00 2001
From: Wind Yuan <feng.yuan@intel.com>
Date: Thu, 28 Feb 2013 16:06:13 +0800
Subject: [PATCH 2/3] h264: remove reference if picture frame_num is same

---
 gst-libs/gst/vaapi/gstvaapidecoder_h264.c |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/gst-libs/gst/vaapi/gstvaapidecoder_h264.c b/gst-libs/gst/vaapi/gstvaapidecoder_h264.c
index 59f0803..6a25eea 100755
--- a/gst-libs/gst/vaapi/gstvaapidecoder_h264.c
+++ b/gst-libs/gst/vaapi/gstvaapidecoder_h264.c
@@ -2066,6 +2066,23 @@ init_picture_ref_lists(GstVaapiDecoderH264 *decoder)
 }
 
 static void
+remove_short_reference(GstVaapiDecoderH264* decoder, gint32 frame_num)
+{
+    GstVaapiDecoderH264Private * const priv = decoder->priv;
+    GstVaapiPictureH264 *ref_picture;
+    guint i;
+
+    for (i = 0; i < priv->short_ref_count; ++i) {
+        if (priv->short_ref[i]->frame_num == frame_num) {
+            ref_picture = priv->short_ref[i];
+            gst_vaapi_picture_h264_set_reference(ref_picture, 0, FALSE);
+            ARRAY_REMOVE_INDEX(priv->short_ref, i);
+            return;
+        }
+    }
+}
+
+static void
 init_picture_refs(
     GstVaapiDecoderH264 *decoder,
     GstVaapiPictureH264 *picture,
@@ -2461,6 +2478,8 @@ exec_ref_pic_marking(GstVaapiDecoderH264 *decoder, GstVaapiPictureH264 *picture)
             if (!exec_ref_pic_marking_sliding_window(decoder))
                 return FALSE;
         }
+        if (!priv->prev_pic_has_mmco5)
+            remove_short_reference(decoder, picture->frame_num);
     }
     return TRUE;
 }
-- 
1.7.9.5