mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 17:20:36 +00:00
basetransform: avoid useless memcpy
Because of the awkward refcounting in prepare_output_buffer, we might end up with writable buffers that point to the same data. Check for those cases so that we avoid a useless memcpy and keep valgrind quiet. Fixes #628176
This commit is contained in:
parent
7203806ffb
commit
90d65cb446
1 changed files with 11 additions and 4 deletions
|
@ -2181,10 +2181,17 @@ no_qos:
|
|||
GST_DEBUG_OBJECT (trans, "doing inplace transform");
|
||||
|
||||
if (inbuf != *outbuf) {
|
||||
/* different buffers, copy the input to the output first, we then do an
|
||||
* in-place transform on the output buffer. */
|
||||
memcpy (GST_BUFFER_DATA (*outbuf), GST_BUFFER_DATA (inbuf),
|
||||
GST_BUFFER_SIZE (inbuf));
|
||||
guint8 *indata, *outdata;
|
||||
|
||||
/* Different buffer. The data can still be the same when we are dealing
|
||||
* with subbuffers of the same buffer. Note that because of the FIXME in
|
||||
* prepare_output_buffer() we have decreased the refcounts of inbuf and
|
||||
* outbuf to keep them writable */
|
||||
indata = GST_BUFFER_DATA (inbuf);
|
||||
outdata = GST_BUFFER_DATA (*outbuf);
|
||||
|
||||
if (indata != outdata)
|
||||
memcpy (outdata, indata, GST_BUFFER_SIZE (inbuf));
|
||||
}
|
||||
ret = bclass->transform_ip (trans, *outbuf);
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue