From b2701418d706024716f2c6097906c332f08b70db Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Thu, 15 Sep 2022 16:22:23 +0200 Subject: [PATCH] basetransform: Avoid useless codepath If QoS is disabled, skip the whole computation (avoids calculating values which won't be needed) Part-of: --- .../gstreamer/libs/gst/base/gstbasetransform.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/subprojects/gstreamer/libs/gst/base/gstbasetransform.c b/subprojects/gstreamer/libs/gst/base/gstbasetransform.c index 38fbb4d06d..ec5ef76950 100644 --- a/subprojects/gstreamer/libs/gst/base/gstbasetransform.c +++ b/subprojects/gstreamer/libs/gst/base/gstbasetransform.c @@ -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) {