codecs: h264decoder: Fix for MMCO type 2
authorSeungha Yang <seungha@centricular.com>
Thu, 5 Nov 2020 09:42:37 +0000 (18:42 +0900)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Thu, 5 Nov 2020 14:56:28 +0000 (14:56 +0000)
As per 8.2.5.4.2, we should mark a picture which has
LongTermPicNum == long_term_pic_num as "unused for reference",
not pic_num.

Passing conformance bitstream test with MR2_MW_A

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1768>

gst-libs/gst/codecs/gsth264decoder.c
gst-libs/gst/codecs/gsth264picture.c
gst-libs/gst/codecs/gsth264picture.h

index 20e6cea..4e1d595 100644 (file)
@@ -2207,7 +2207,7 @@ modify_ref_pic_list (GstH264Decoder * self, int list)
       case 2:
         /* (8-28) */
         g_assert (num_ref_idx_lX_active_minus1 + 1 < 32);
-        pic = gst_h264_dpb_get_long_ref_by_pic_num (priv->dpb,
+        pic = gst_h264_dpb_get_long_ref_by_long_term_pic_num (priv->dpb,
             list_mod->value.long_term_pic_num);
         if (!pic) {
           GST_WARNING_OBJECT (self, "Malformed stream, no pic num %d",
index 79a3359..54bc760 100644 (file)
@@ -333,16 +333,19 @@ gst_h264_dpb_get_short_ref_by_pic_num (GstH264Dpb * dpb, gint pic_num)
 }
 
 /**
- * gst_h264_dpb_get_long_ref_by_pic_num:
+ * gst_h264_dpb_get_long_ref_by_long_term_pic_num:
  * @dpb: a #GstH264Dpb
- * @pic_num: a picture number
+ * @pic_num: a long term picture number
  *
- * Find a long term reference picture which has matching picture number
+ * Find a long term reference picture which has matching long term picture number
  *
  * Returns: (nullable) (transfer none): a #GstH264Picture
+ *
+ * Since: 1.20
  */
 GstH264Picture *
-gst_h264_dpb_get_long_ref_by_pic_num (GstH264Dpb * dpb, gint pic_num)
+gst_h264_dpb_get_long_ref_by_long_term_pic_num (GstH264Dpb * dpb,
+    gint long_term_pic_num)
 {
   gint i;
 
@@ -352,11 +355,12 @@ gst_h264_dpb_get_long_ref_by_pic_num (GstH264Dpb * dpb, gint pic_num)
     GstH264Picture *picture =
         g_array_index (dpb->pic_list, GstH264Picture *, i);
 
-    if (picture->ref && picture->long_term && picture->pic_num == pic_num)
+    if (picture->ref && picture->long_term &&
+        picture->long_term_pic_num == long_term_pic_num)
       return picture;
   }
 
-  GST_WARNING ("No long term reference picture for %d", pic_num);
+  GST_WARNING ("No long term reference picture for %d", long_term_pic_num);
 
   return NULL;
 }
@@ -736,7 +740,7 @@ gst_h264_dpb_perform_memory_management_control_operation (GstH264Dpb * dpb,
     case 2:
       /* 8.2.5.4.2 Mark a long term reference picture as unused so it can be
        * removed if outputted */
-      other = gst_h264_dpb_get_long_ref_by_pic_num (dpb,
+      other = gst_h264_dpb_get_long_ref_by_long_term_pic_num (dpb,
           ref_pic_marking->long_term_pic_num);
       if (other) {
         other->ref = FALSE;
index ad90c21..727c46d 100644 (file)
@@ -180,8 +180,8 @@ GstH264Picture * gst_h264_dpb_get_short_ref_by_pic_num (GstH264Dpb * dpb,
                                                         gint pic_num);
 
 GST_CODECS_API
-GstH264Picture * gst_h264_dpb_get_long_ref_by_pic_num  (GstH264Dpb * dpb,
-                                                        gint pic_num);
+GstH264Picture * gst_h264_dpb_get_long_ref_by_long_term_pic_num (GstH264Dpb * dpb,
+                                                                 gint long_term_pic_num);
 
 GST_CODECS_API
 GstH264Picture * gst_h264_dpb_get_lowest_frame_num_short_ref (GstH264Dpb * dpb);