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:
Wim Taymans 2010-09-23 18:18:54 +02:00
parent 7203806ffb
commit 90d65cb446

View file

@ -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 {