h264decoder: Enable low-latency bumping in case of pic_order_cnt_type 2
authorSeungha Yang <seungha@centricular.com>
Mon, 10 Apr 2023 11:10:50 +0000 (20:10 +0900)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Mon, 10 Apr 2023 17:05:53 +0000 (17:05 +0000)
In case of POC type 2, output order is equal to decoding order
(no frame reordering)

Fixes: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/2447
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4383>

subprojects/gst-plugins-bad/gst-libs/gst/codecs/gsth264decoder.c
subprojects/gst-plugins-bad/gst-libs/gst/codecs/gsth264picture.c

index a72d516..86a45aa 100644 (file)
@@ -2164,9 +2164,9 @@ gst_h264_decoder_finish_picture (GstH264Decoder * self,
 
   gst_h264_picture_unref (picture);
 
-  /* For the live mode, we try to bump here to avoid waiting
-     for another decoding circle. */
-  if (priv->is_live && priv->compliance != GST_H264_DECODER_COMPLIANCE_STRICT)
+  /* For low-latency output, we try to bump here to avoid waiting
+   * for another decoding circle. */
+  if (bump_level != GST_H264_DPB_BUMP_NORMAL_LATENCY)
     _bump_dpb (self, bump_level, NULL, ret);
 }
 
@@ -2320,9 +2320,14 @@ gst_h264_decoder_set_latency (GstH264Decoder * self, const GstH264SPS * sps,
 
   bump_level = get_bump_level (self);
   if (bump_level != GST_H264_DPB_BUMP_NORMAL_LATENCY) {
-    guint32 max_reorder_frames =
-        gst_h264_dpb_get_max_num_reorder_frames (priv->dpb);
-    frames_delay = MIN (max_dpb_size, max_reorder_frames);
+    if (sps->pic_order_cnt_type == 2) {
+      /* POC type 2 has does not allow frame reordering */
+      frames_delay = 0;
+    } else {
+      guint32 max_reorder_frames =
+          gst_h264_dpb_get_max_num_reorder_frames (priv->dpb);
+      frames_delay = MIN (max_dpb_size, max_reorder_frames);
+    }
   }
 
   /* Consider output delay wanted by subclass */
index 02f328b..7ab5ffe 100644 (file)
@@ -760,6 +760,12 @@ gst_h264_dpb_needs_bump (GstH264Dpb * dpb, GstH264Picture * to_insert,
     if (!gst_h264_dpb_has_empty_frame_buffer (dpb))
       goto normal_bump;
 
+    /* In case of POC type 2, decoding order is equal to output order */
+    if (picture->pic_order_cnt_type == 2) {
+      GST_TRACE ("POC type == 2, bumping");
+      return TRUE;
+    }
+
     /* 7.4.1.2.2: The values of picture order count for the coded pictures
        in consecutive access units in decoding order containing non-reference
        pictures shall be non-decreasing. Safe. */