mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-12 10:25:33 +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");
|
GST_DEBUG_OBJECT (trans, "doing inplace transform");
|
||||||
|
|
||||||
if (inbuf != *outbuf) {
|
if (inbuf != *outbuf) {
|
||||||
/* different buffers, copy the input to the output first, we then do an
|
guint8 *indata, *outdata;
|
||||||
* in-place transform on the output buffer. */
|
|
||||||
memcpy (GST_BUFFER_DATA (*outbuf), GST_BUFFER_DATA (inbuf),
|
/* Different buffer. The data can still be the same when we are dealing
|
||||||
GST_BUFFER_SIZE (inbuf));
|
* 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);
|
ret = bclass->transform_ip (trans, *outbuf);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue