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: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/683>
This commit is contained in:
Sebastian Dröge 2020-06-03 15:06:08 +03:00
parent caaa5ac864
commit fb7ab33e03

View file

@ -2198,7 +2198,7 @@ gst_video_encoder_send_header_unlocked (GstVideoEncoder * encoder,
GstVideoEncoderPrivate *priv = encoder->priv; GstVideoEncoderPrivate *priv = encoder->priv;
if (G_UNLIKELY (priv->new_headers)) { if (G_UNLIKELY (priv->new_headers)) {
GList *tmp, *copy = NULL; GList *tmp;
GST_DEBUG_OBJECT (encoder, "Sending headers"); 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) { for (tmp = priv->headers; tmp; tmp = tmp->next) {
GstBuffer *tmpbuf = GST_BUFFER (tmp->data); GstBuffer *tmpbuf = GST_BUFFER (tmp->data);
copy = g_list_append (copy, gst_buffer_make_writable (tmpbuf)); tmp->data = tmpbuf = 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);
GST_OBJECT_LOCK (encoder); GST_OBJECT_LOCK (encoder);
priv->bytes += gst_buffer_get_size (tmpbuf); priv->bytes += gst_buffer_get_size (tmpbuf);