decoder: h264: fix assignment of LongTermFrameIdx. upstream/0.2.6+1195+gc12d80e
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>
Mon, 12 May 2014 17:23:04 +0000 (19:23 +0200)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Mon, 12 May 2014 17:29:37 +0000 (19:29 +0200)
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

index d12cbca..0f10b9e 100644 (file)
@@ -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 */