From 06147100f263c35f418e971361672d4a73c00ebf Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Mon, 29 Jun 2015 13:16:09 +0200 Subject: [PATCH] decoder: h264: fix integration of second field into the DPB. If the new picture to be added to the DPB is not a first field, then it shall be the second field of the previous picture that was added before. This removes the need for dpb_find_picture() now that we track the immediately preceding decoded picture, in decode order. --- gst-libs/gst/vaapi/gstvaapidecoder_h264.c | 34 +++++------------------ 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/gst-libs/gst/vaapi/gstvaapidecoder_h264.c b/gst-libs/gst/vaapi/gstvaapidecoder_h264.c index ab86ba1a15..fa945eb5dc 100644 --- a/gst-libs/gst/vaapi/gstvaapidecoder_h264.c +++ b/gst-libs/gst/vaapi/gstvaapidecoder_h264.c @@ -759,23 +759,6 @@ dpb_evict(GstVaapiDecoderH264 *decoder, GstVaapiPictureH264 *picture, guint i) dpb_remove_index(decoder, i); } -/* Finds the frame store holding the supplied picture */ -static gint -dpb_find_picture(GstVaapiDecoderH264 *decoder, GstVaapiPictureH264 *picture) -{ - GstVaapiDecoderH264Private * const priv = &decoder->priv; - gint i, j; - - for (i = 0; i < priv->dpb_count; i++) { - GstVaapiFrameStore * const fs = priv->dpb[i]; - for (j = 0; j < fs->num_buffers; j++) { - if (fs->buffers[j] == picture) - return i; - } - } - return -1; -} - /* Finds the picture with the nearest previous POC and same structure */ static gint dpb_find_nearest_prev_poc(GstVaapiDecoderH264 *decoder, @@ -1049,18 +1032,15 @@ dpb_add(GstVaapiDecoderH264 *decoder, GstVaapiPictureH264 *picture) // Check if picture is the second field and the first field is still in DPB if (GST_VAAPI_PICTURE_IS_INTERLACED(picture) && !GST_VAAPI_PICTURE_IS_FIRST_FIELD(picture)) { - const gint found_index = dpb_find_picture(decoder, - GST_VAAPI_PICTURE_H264(picture->base.parent_picture)); - if (found_index >= 0) - return gst_vaapi_frame_store_add(priv->dpb[found_index], picture); - - // ... also check the previous picture that was immediately output fs = priv->prev_frames[picture->base.voc]; - if (fs && &fs->buffers[0]->base == picture->base.parent_picture) { - if (!gst_vaapi_frame_store_add(fs, picture)) - return FALSE; + if (!fs || &fs->buffers[0]->base != picture->base.parent_picture) + return FALSE; + if (!gst_vaapi_frame_store_add(fs, picture)) + return FALSE; + + if (fs->output_called) return dpb_output(decoder, fs); - } + return TRUE; } // Try to output the previous frame again if it was not submitted yet