h264decoder: Fix for unhandled low-delay decoding case
authorSeungha Yang <seungha@centricular.com>
Wed, 4 May 2022 15:24:26 +0000 (00:24 +0900)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Thu, 5 May 2022 14:54:54 +0000 (14:54 +0000)
Baseclass calls get_preferred_output_delay() in a chain of
sequence header parsing and then new_sequence() is called
with required DPB size (includes render-delay) information.
Thus latency query should happen before the sequence header
parsing for subclass to report required render-delay accordingly
via get_preferred_output_delay() method.
(e.g., zero delay in case of live pipeline)

This commit is to fix wrong liveness signalling in case of
upstream packetized format.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2363>

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

index 96657d0..0b60d11 100644 (file)
@@ -1408,6 +1408,16 @@ gst_h264_decoder_set_format (GstVideoDecoder * decoder,
 
   self->input_state = gst_video_codec_state_ref (state);
 
+  /* in case live streaming, we will run on low-latency mode */
+  priv->is_live = FALSE;
+  query = gst_query_new_latency ();
+  if (gst_pad_peer_query (GST_VIDEO_DECODER_SINK_PAD (self), query))
+    gst_query_parse_latency (query, &priv->is_live, NULL, NULL);
+  gst_query_unref (query);
+
+  if (priv->is_live)
+    GST_DEBUG_OBJECT (self, "Live source, will run on low-latency mode");
+
   if (state->caps) {
     GstH264DecoderFormat format;
     GstH264DecoderAlign align;
@@ -1462,16 +1472,6 @@ gst_h264_decoder_set_format (GstVideoDecoder * decoder,
     gst_buffer_unmap (state->codec_data, &map);
   }
 
-  /* in case live streaming, we will run on low-latency mode */
-  priv->is_live = FALSE;
-  query = gst_query_new_latency ();
-  if (gst_pad_peer_query (GST_VIDEO_DECODER_SINK_PAD (self), query))
-    gst_query_parse_latency (query, &priv->is_live, NULL, NULL);
-  gst_query_unref (query);
-
-  if (priv->is_live)
-    GST_DEBUG_OBJECT (self, "Live source, will run on low-latency mode");
-
   return TRUE;
 }