decoder: h264: fix long-term reference picture marking process.
authorCong Zhong <congx.zhong@intel.com>
Fri, 24 May 2013 11:00:54 +0000 (19:00 +0800)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Sat, 26 Apr 2014 20:16:19 +0000 (22:16 +0200)
Fix reference picture marking process with memory_management_control_op
set to 3 and 6, i.e. assign LongTermFrameIdx to a short-term reference
picture, or the current picture.

This fixes decoding of FRExt_MMCO4_Sony_B.

https://bugs.freedesktop.org/show_bug.cgi?id=64624
https://bugzilla.gnome.org/show_bug.cgi?id=724518

[squashed, edited to use GST_VAAPI_PICTURE_IS_COMPLETE() macro]
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
gst-libs/gst/vaapi/gstvaapidecoder_h264.c

index d392a42..b870c92 100644 (file)
@@ -2264,7 +2264,7 @@ exec_ref_pic_marking_adaptive_mmco_3(
     ref_picture->long_term_frame_idx = ref_pic_marking->long_term_frame_idx;
     gst_vaapi_picture_h264_set_reference(ref_picture,
         GST_VAAPI_PICTURE_FLAG_LONG_TERM_REFERENCE,
-        GST_VAAPI_PICTURE_IS_FRAME(picture));
+        GST_VAAPI_PICTURE_IS_COMPLETE(picture));
 }
 
 /* 8.2.5.4.4. Mark pictures with LongTermFramIdx > max_long_term_frame_idx
@@ -2325,9 +2325,22 @@ exec_ref_pic_marking_adaptive_mmco_6(
     GstH264RefPicMarking *ref_pic_marking
 )
 {
+    GstVaapiDecoderH264Private * const priv = &decoder->priv;
+    guint i;
+
+    for (i = 0; i < priv->long_ref_count; i++) {
+        if (priv->long_ref[i]->long_term_frame_idx == ref_pic_marking->long_term_frame_idx)
+            break;
+    }
+    if (i != priv->long_ref_count) {
+        gst_vaapi_picture_h264_set_reference(priv->long_ref[i], 0, TRUE);
+        ARRAY_REMOVE_INDEX(priv->long_ref, i);
+    }
+
     picture->long_term_frame_idx = ref_pic_marking->long_term_frame_idx;
     gst_vaapi_picture_h264_set_reference(picture,
-        GST_VAAPI_PICTURE_FLAG_LONG_TERM_REFERENCE, FALSE);
+        GST_VAAPI_PICTURE_FLAG_LONG_TERM_REFERENCE,
+        GST_VAAPI_PICTURE_IS_COMPLETE(picture));
 }
 
 /* 8.2.5.4. Adaptive memory control decoded reference picture marking process */