From 342f02015bf78c9293d618734d840635379ee1a0 Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Thu, 30 Jun 2022 18:41:01 +1000 Subject: [PATCH] gl: Don't use the full transform_caps() method for reconfiguration check When checking if we need to reconfigure when uploading, check specifically the output caps of the current method will result in compatible/incompatible caps, not the full set of output caps from all upload methods. Part-of: --- .../gst-plugins-base/gst-libs/gst/gl/gstglupload.c | 24 +++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/subprojects/gst-plugins-base/gst-libs/gst/gl/gstglupload.c b/subprojects/gst-plugins-base/gst-libs/gst/gl/gstglupload.c index 4e55ebc..e2cd82d 100644 --- a/subprojects/gst-plugins-base/gst-libs/gst/gl/gstglupload.c +++ b/subprojects/gst-plugins-base/gst-libs/gst/gl/gstglupload.c @@ -2544,6 +2544,9 @@ gst_gl_upload_perform_with_buffer (GstGLUpload * upload, GstBuffer * buffer, GstGLUploadReturn ret = GST_GL_UPLOAD_ERROR; GstBuffer *outbuf = NULL; gpointer last_impl = upload->priv->method_impl; +#if !defined (GST_DISABLE_DEBUG) + const UploadMethod *last_method = upload->priv->method; +#endif g_return_val_if_fail (GST_IS_GL_UPLOAD (upload), FALSE); g_return_val_if_fail (GST_IS_BUFFER (buffer), FALSE); @@ -2589,14 +2592,25 @@ restart: gst_buffer_replace (&outbuf, NULL); goto restart; } else if (ret == GST_GL_UPLOAD_DONE || ret == GST_GL_UPLOAD_RECONFIGURE) { - if (last_impl != upload->priv->method_impl) { - GstCaps *caps = gst_gl_upload_transform_caps (upload, upload->context, - GST_PAD_SINK, upload->priv->in_caps, NULL); - if (!gst_caps_is_subset (caps, upload->priv->out_caps)) { + if (last_impl != upload->priv->method_impl + && upload->priv->method_impl != NULL) { + /* Transform the input caps using the new method. If they are compatible with the + * existing upload method, we can skip reconfiguration */ + GstCaps *caps = + upload->priv->method->transform_caps (upload->priv->method_impl, + upload->context, GST_PAD_SINK, upload->priv->in_caps); + + GST_LOG_OBJECT (upload, + "Changing uploader from %s to %s with src caps %" GST_PTR_FORMAT + " and old src caps %" GST_PTR_FORMAT, + last_method != NULL ? last_method->name : "None", + upload->priv->method->name, caps, upload->priv->out_caps); + + if (caps == NULL || !gst_caps_is_subset (caps, upload->priv->out_caps)) { gst_buffer_replace (&outbuf, NULL); ret = GST_GL_UPLOAD_RECONFIGURE; } - gst_caps_unref (caps); + gst_caps_replace (&caps, NULL); } /* we are done */ } else { -- 2.7.4