From fb7ab33e03b627e9cba80eb90b658952e89370a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 3 Jun 2020 15:06:08 +0300 Subject: [PATCH] videoencoder: Simplify header buffer metadata updating Instead of doing a shallow copy of the list just to call make_writable() on each buffer, do that inline in the same loop and modify the list contents. Part-of: --- gst-libs/gst/video/gstvideoencoder.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/gst-libs/gst/video/gstvideoencoder.c b/gst-libs/gst/video/gstvideoencoder.c index 3472b95571..a6add32293 100644 --- a/gst-libs/gst/video/gstvideoencoder.c +++ b/gst-libs/gst/video/gstvideoencoder.c @@ -2198,7 +2198,7 @@ gst_video_encoder_send_header_unlocked (GstVideoEncoder * encoder, GstVideoEncoderPrivate *priv = encoder->priv; if (G_UNLIKELY (priv->new_headers)) { - GList *tmp, *copy = NULL; + GList *tmp; GST_DEBUG_OBJECT (encoder, "Sending headers"); @@ -2206,13 +2206,7 @@ gst_video_encoder_send_header_unlocked (GstVideoEncoder * encoder, for (tmp = priv->headers; tmp; tmp = tmp->next) { GstBuffer *tmpbuf = GST_BUFFER (tmp->data); - copy = g_list_append (copy, gst_buffer_make_writable (tmpbuf)); - } - g_list_free (priv->headers); - priv->headers = copy; - - for (tmp = priv->headers; tmp; tmp = tmp->next) { - GstBuffer *tmpbuf = GST_BUFFER (tmp->data); + tmp->data = tmpbuf = gst_buffer_make_writable (tmpbuf); GST_OBJECT_LOCK (encoder); priv->bytes += gst_buffer_get_size (tmpbuf);