From c12d80eb88359a4a5babe8ca3a7fd82397c7838a Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Mon, 12 May 2014 19:23:04 +0200 Subject: [PATCH] decoder: h264: fix assignment of LongTermFrameIdx. Complement fix committed as e95a42e. The H.264 AVC standard has to say: if the field is part of a reference frame or a complementary reference field pair, and the other field of the same reference frame or complementary reference field pair is also marked as "used for long-term reference", the reference frame or complementary reference field pair is also marked as "used for long-term reference" and assigned LongTermFrameIdx equal to long_term_frame_idx. This fixes decoding of MR9_BT_B in strict mode. https://bugs.freedesktop.org/show_bug.cgi?id=64624 https://bugzilla.gnome.org/show_bug.cgi?id=724518 --- gst-libs/gst/vaapi/gstvaapidecoder_h264.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/gst-libs/gst/vaapi/gstvaapidecoder_h264.c b/gst-libs/gst/vaapi/gstvaapidecoder_h264.c index d12cbca462..0f10b9eeea 100644 --- a/gst-libs/gst/vaapi/gstvaapidecoder_h264.c +++ b/gst-libs/gst/vaapi/gstvaapidecoder_h264.c @@ -2240,7 +2240,7 @@ exec_ref_pic_marking_adaptive_mmco_3( ) { GstVaapiDecoderH264Private * const priv = &decoder->priv; - GstVaapiPictureH264 *ref_picture; + GstVaapiPictureH264 *ref_picture, *other_field; gint32 i, picNumX; for (i = 0; i < priv->long_ref_count; i++) { @@ -2265,6 +2265,12 @@ exec_ref_pic_marking_adaptive_mmco_3( gst_vaapi_picture_h264_set_reference(ref_picture, GST_VAAPI_PICTURE_FLAG_LONG_TERM_REFERENCE, GST_VAAPI_PICTURE_IS_COMPLETE(picture)); + + /* Assign LongTermFrameIdx to the other field if it was also + marked as "used for long-term reference */ + other_field = ref_picture->other_field; + if (other_field && GST_VAAPI_PICTURE_IS_LONG_TERM_REFERENCE(other_field)) + other_field->long_term_frame_idx = ref_pic_marking->long_term_frame_idx; } /* 8.2.5.4.4. Mark pictures with LongTermFramIdx > max_long_term_frame_idx @@ -2326,6 +2332,7 @@ exec_ref_pic_marking_adaptive_mmco_6( ) { GstVaapiDecoderH264Private * const priv = &decoder->priv; + GstVaapiPictureH264 *other_field; guint i; for (i = 0; i < priv->long_ref_count; i++) { @@ -2341,6 +2348,12 @@ exec_ref_pic_marking_adaptive_mmco_6( gst_vaapi_picture_h264_set_reference(picture, GST_VAAPI_PICTURE_FLAG_LONG_TERM_REFERENCE, GST_VAAPI_PICTURE_IS_COMPLETE(picture)); + + /* Assign LongTermFrameIdx to the other field if it was also + marked as "used for long-term reference */ + other_field = (GstVaapiPictureH264 *)picture->base.parent_picture; + if (other_field && GST_VAAPI_PICTURE_IS_LONG_TERM_REFERENCE(other_field)) + other_field->long_term_frame_idx = ref_pic_marking->long_term_frame_idx; } /* 8.2.5.4. Adaptive memory control decoded reference picture marking process */