From 2626c02149ab7947cec9890215a76bddb643554c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20Bertolus?= Date: Tue, 29 Mar 2016 17:19:41 +0200 Subject: [PATCH] videorate: avoid useless buffer copy in drop-only mode Make writable the buffer before pushing it lead to a buffer copy. It's because a reference is keep for the previous buffer. The previous buffer reference is only need to duplicate the buffer. In drop-only mode, the previous buffer is release just after pushing the buffer so a copy is done but it's useless. https://bugzilla.gnome.org/show_bug.cgi?id=764319 --- gst/videorate/gstvideorate.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gst/videorate/gstvideorate.c b/gst/videorate/gstvideorate.c index c004dba..11d9346 100644 --- a/gst/videorate/gstvideorate.c +++ b/gst/videorate/gstvideorate.c @@ -608,8 +608,12 @@ gst_video_rate_flush_prev (GstVideoRate * videorate, gboolean duplicate) if (!videorate->prevbuf) goto eos_before_buffers; + outbuf = gst_buffer_ref (videorate->prevbuf); + if (videorate->drop_only) + gst_buffer_replace (&videorate->prevbuf, NULL); + /* make sure we can write to the metadata */ - outbuf = gst_buffer_make_writable (gst_buffer_ref (videorate->prevbuf)); + outbuf = gst_buffer_make_writable (outbuf); GST_BUFFER_OFFSET (outbuf) = videorate->out; GST_BUFFER_OFFSET_END (outbuf) = videorate->out + 1; -- 2.7.4