basetransform: Avoid useless codepath
authorEdward Hervey <edward@centricular.com>
Thu, 15 Sep 2022 14:22:23 +0000 (16:22 +0200)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Thu, 22 Sep 2022 13:45:50 +0000 (13:45 +0000)
If QoS is disabled, skip the whole computation (avoids calculating values which
won't be needed)

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

subprojects/gstreamer/libs/gst/base/gstbasetransform.c

index 38fbb4d..ec5ef76 100644 (file)
@@ -2034,6 +2034,7 @@ default_submit_input_buffer (GstBaseTransform * trans, gboolean is_discont,
   GstFlowReturn ret = GST_FLOW_OK;
   GstClockTime running_time;
   GstClockTime timestamp;
+  gboolean qos_enabled;
 
   if (G_UNLIKELY (!gst_base_transform_reconfigure_unlocked (trans)))
     goto not_negotiated;
@@ -2056,6 +2057,14 @@ default_submit_input_buffer (GstBaseTransform * trans, gboolean is_discont,
   if (!priv->negotiated && !priv->passthrough && (bclass->set_caps != NULL))
     goto not_negotiated;
 
+  GST_OBJECT_LOCK (trans);
+  qos_enabled = priv->qos_enabled;
+  GST_OBJECT_UNLOCK (trans);
+
+  /* Skip all qos handling if disabled */
+  if (!qos_enabled)
+    goto no_qos;
+
   /* can only do QoS if the segment is in TIME */
   if (trans->segment.format != GST_FORMAT_TIME)
     goto no_qos;
@@ -2077,8 +2086,7 @@ default_submit_input_buffer (GstBaseTransform * trans, gboolean is_discont,
     proportion = priv->proportion;
     /* check for QoS, don't perform conversion for buffers
      * that are known to be late. */
-    need_skip = priv->qos_enabled &&
-        earliest_time != -1 && running_time <= earliest_time;
+    need_skip = earliest_time != -1 && running_time <= earliest_time;
     GST_OBJECT_UNLOCK (trans);
 
     if (need_skip) {