From: Gwenole Beauchesne Date: Fri, 27 Jun 2014 18:44:24 +0000 (+0200) Subject: decoder: h264: fix the DPB compaction process. X-Git-Tag: 0.5.9~57 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fupstream%2Fgstreamer-vaapi.git;a=commitdiff_plain;h=9169c520cb6b84ba3f80e1ec38d60e461267646a decoder: h264: fix the DPB compaction process. Fix the compaction process when the DPB is cleared for a specific view, i.e. fix the process of filling in the holes resulting from removing frame buffers matching the current picture. --- diff --git a/gst-libs/gst/vaapi/gstvaapidecoder_h264.c b/gst-libs/gst/vaapi/gstvaapidecoder_h264.c index e223318..24d1aae 100644 --- a/gst-libs/gst/vaapi/gstvaapidecoder_h264.c +++ b/gst-libs/gst/vaapi/gstvaapidecoder_h264.c @@ -847,9 +847,15 @@ dpb_clear(GstVaapiDecoderH264 *decoder, GstVaapiPictureH264 *picture) gst_vaapi_frame_store_replace(&priv->dpb[i], NULL); } + /* Compact the resulting DPB, i.e. remove holes */ for (i = 0, n = 0; i < priv->dpb_count; i++) { - if (priv->dpb[i]) - priv->dpb[n++] = priv->dpb[i]; + if (priv->dpb[i]) { + if (i != n) { + priv->dpb[n] = priv->dpb[i]; + priv->dpb[i] = NULL; + } + n++; + } } priv->dpb_count = n; @@ -859,7 +865,7 @@ dpb_clear(GstVaapiDecoderH264 *decoder, GstVaapiPictureH264 *picture) GST_VAAPI_PICTURE_FLAG_IS_SET(picture, GST_VAAPI_PICTURE_FLAG_AU_START))) { for (i = 0; i < priv->max_views; i++) - gst_vaapi_picture_replace(&priv->prev_frames[i], NULL); + gst_vaapi_frame_store_replace(&priv->prev_frames[i], NULL); } } @@ -1026,7 +1032,7 @@ mvc_reset(GstVaapiDecoderH264 *decoder) // Resize array of previous frame buffers for (i = priv->max_views; i < priv->prev_frames_alloc; i++) - gst_vaapi_picture_replace(&priv->prev_frames[i], NULL); + gst_vaapi_frame_store_replace(&priv->prev_frames[i], NULL); priv->prev_frames = g_try_realloc_n(priv->prev_frames, priv->max_views, sizeof(*priv->prev_frames));