From: Gwenole Beauchesne Date: Thu, 3 Jul 2014 11:48:48 +0000 (+0200) Subject: decoder: h264: detect incorrectly paired fields in frames. X-Git-Tag: 0.5.9~44 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fupstream%2Fgstreamer-vaapi.git;a=commitdiff_plain;h=b5f1bdd59af69ce7eac569df8f7d474c4f8060bd decoder: h264: detect incorrectly paired fields in frames. When a DPB flush is required, e.g. at a natural and of stream or issued explicitly through an IDR, try to detect any frame left in the DPB that is interlaced but does not contain two decoded fields. In that case, mark the picture as having a single field only. This avoids a hang while decoding tv_cut.mkv. --- diff --git a/gst-libs/gst/vaapi/gstvaapidecoder_h264.c b/gst-libs/gst/vaapi/gstvaapidecoder_h264.c index 8297e78..6b57fa6 100644 --- a/gst-libs/gst/vaapi/gstvaapidecoder_h264.c +++ b/gst-libs/gst/vaapi/gstvaapidecoder_h264.c @@ -894,6 +894,20 @@ dpb_clear(GstVaapiDecoderH264 *decoder, GstVaapiPictureH264 *picture) static void dpb_flush(GstVaapiDecoderH264 *decoder, GstVaapiPictureH264 *picture) { + GstVaapiDecoderH264Private * const priv = &decoder->priv; + guint i; + + /* Detect broken frames and mark them as having a single field if + needed */ + for (i = 0; i < priv->dpb_count; i++) { + GstVaapiFrameStore * const fs = priv->dpb[i]; + if (!fs->output_needed || gst_vaapi_frame_store_is_complete(fs)) + continue; + GST_VAAPI_PICTURE_FLAG_SET(fs->buffers[0], + GST_VAAPI_PICTURE_FLAG_ONEFIELD); + } + + /* Output any frame remaining in DPB */ while (dpb_bump(decoder, picture)) ; dpb_clear(decoder, picture);