h265decoder: Fix for latency report when src caps is not configured
authorSeungha Yang <seungha@centricular.com>
Thu, 6 Apr 2023 10:40:12 +0000 (19:40 +0900)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Mon, 10 Apr 2023 17:05:53 +0000 (17:05 +0000)
Depending on subclass, negotiation might not happen on new_sequence()

Fixing regression introduced by the commit
4a4823b9728fbb944e05d89e0fee681ab5b33e25

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

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

index 201cc6b..70f0be9 100644 (file)
@@ -363,17 +363,19 @@ gst_h265_decoder_set_latency (GstH265Decoder * self, const GstH265SPS * sps,
   guint frames_delay;
 
   caps = gst_pad_get_current_caps (GST_VIDEO_DECODER_SRC_PAD (self));
-  if (!caps)
-    return;
-
-  structure = gst_caps_get_structure (caps, 0);
-  if (gst_structure_get_fraction (structure, "framerate", &fps_n, &fps_d)) {
-    if (fps_n == 0) {
-      /* variable framerate: see if we have a max-framerate */
-      gst_structure_get_fraction (structure, "max-framerate", &fps_n, &fps_d);
+  if (!caps && self->input_state)
+    caps = gst_caps_ref (self->input_state->caps);
+
+  if (caps) {
+    structure = gst_caps_get_structure (caps, 0);
+    if (gst_structure_get_fraction (structure, "framerate", &fps_n, &fps_d)) {
+      if (fps_n == 0) {
+        /* variable framerate: see if we have a max-framerate */
+        gst_structure_get_fraction (structure, "max-framerate", &fps_n, &fps_d);
+      }
     }
+    gst_caps_unref (caps);
   }
-  gst_caps_unref (caps);
 
   /* if no fps or variable, then 25/1 */
   if (fps_n == 0) {