From 0261b7d3fac02f2e43a75be3290fe56fe47cf5ac Mon Sep 17 00:00:00 2001 From: zhongcong Date: Sat, 4 May 2013 17:43:43 +0800 Subject: [PATCH] h264: fix h264 ssim bug fix bug when remove reference if picture frame_num is same Signed-off-by: zhongcong --- gst-libs/gst/vaapi/gstvaapidecoder_h264.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/gst-libs/gst/vaapi/gstvaapidecoder_h264.c b/gst-libs/gst/vaapi/gstvaapidecoder_h264.c index ac2b5ce..bbbf6a6 100755 --- a/gst-libs/gst/vaapi/gstvaapidecoder_h264.c +++ b/gst-libs/gst/vaapi/gstvaapidecoder_h264.c @@ -2104,17 +2104,20 @@ init_picture_ref_lists(GstVaapiDecoderH264 *decoder) } static void -remove_short_reference(GstVaapiDecoderH264* decoder, gint32 frame_num) +remove_short_reference(GstVaapiDecoderH264* decoder, GstVaapiPictureH264 *picture) { GstVaapiDecoderH264Private * const priv = decoder->priv; GstVaapiPictureH264 *ref_picture; guint i; + gint32 frame_num = picture->frame_num; 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); + if (ref_picture != picture->other_field){ + gst_vaapi_picture_h264_set_reference(ref_picture, 0, FALSE); + ARRAY_REMOVE_INDEX(priv->short_ref, i); + } return; } } @@ -2204,7 +2207,7 @@ process_for_gaps_in_frame_num( init_picture_refs_pic_num(decoder, dummy_pic, slice_hdr); exec_ref_pic_marking_sliding_window(decoder); - remove_short_reference(decoder, dummy_pic->frame_num); + remove_short_reference(decoder, dummy_pic); /* add to short reference */ priv->short_ref[priv->short_ref_count++] = dummy_pic; dpb_add(decoder,dummy_pic); @@ -2563,8 +2566,9 @@ 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); + if (!priv->prev_pic_has_mmco5 && + GST_VAAPI_PICTURE_IS_SHORT_TERM_REFERENCE(picture)) + remove_short_reference(decoder, picture); } return TRUE; } @@ -2795,6 +2799,8 @@ decode_picture(GstVaapiDecoderH264 *decoder, GstH264NalUnit *nalu, GstH264SliceH GST_ERROR("failed to allocate field picture"); return GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED; } + picture->other_field = priv->current_picture; + priv->current_picture->other_field = picture; } else { /* Create new picture */ -- 1.7.9.5