mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-09-27 14:31:01 +00:00
audioconvert: Don't map the input buffer in in-place mode
Input and output buffer are the same, let's not do unnecessary work. https://bugzilla.gnome.org/show_bug.cgi?id=775369
This commit is contained in:
parent
71e819ae7d
commit
1e64800278
1 changed files with 18 additions and 11 deletions
|
@ -709,7 +709,7 @@ gst_audio_convert_transform (GstBaseTransform * base, GstBuffer * inbuf,
|
||||||
{
|
{
|
||||||
GstFlowReturn ret;
|
GstFlowReturn ret;
|
||||||
GstAudioConvert *this = GST_AUDIO_CONVERT (base);
|
GstAudioConvert *this = GST_AUDIO_CONVERT (base);
|
||||||
GstMapInfo srcmap, dstmap;
|
GstMapInfo srcmap = { NULL, }, dstmap;
|
||||||
gint insize, outsize;
|
gint insize, outsize;
|
||||||
gboolean inbuf_writable;
|
gboolean inbuf_writable;
|
||||||
GstAudioConverterFlags flags;
|
GstAudioConverterFlags flags;
|
||||||
|
@ -726,18 +726,24 @@ gst_audio_convert_transform (GstBaseTransform * base, GstBuffer * inbuf,
|
||||||
if (insize == 0 || outsize == 0)
|
if (insize == 0 || outsize == 0)
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
|
|
||||||
inbuf_writable = gst_buffer_is_writable (inbuf)
|
|
||||||
&& gst_buffer_n_memory (inbuf) == 1
|
|
||||||
&& gst_memory_is_writable (gst_buffer_peek_memory (inbuf, 0));
|
|
||||||
|
|
||||||
/* get src and dst data */
|
/* get src and dst data */
|
||||||
gst_buffer_map (inbuf, &srcmap,
|
if (inbuf != outbuf) {
|
||||||
inbuf_writable ? GST_MAP_READWRITE : GST_MAP_READ);
|
inbuf_writable = gst_buffer_is_writable (inbuf)
|
||||||
|
&& gst_buffer_n_memory (inbuf) == 1
|
||||||
|
&& gst_memory_is_writable (gst_buffer_peek_memory (inbuf, 0));
|
||||||
|
|
||||||
|
gst_buffer_map (inbuf, &srcmap,
|
||||||
|
inbuf_writable ? GST_MAP_READWRITE : GST_MAP_READ);
|
||||||
|
} else {
|
||||||
|
inbuf_writable = TRUE;
|
||||||
|
}
|
||||||
gst_buffer_map (outbuf, &dstmap, GST_MAP_WRITE);
|
gst_buffer_map (outbuf, &dstmap, GST_MAP_WRITE);
|
||||||
|
|
||||||
/* check in and outsize */
|
/* check in and outsize */
|
||||||
if (srcmap.size < insize)
|
if (inbuf != outbuf) {
|
||||||
goto wrong_size;
|
if (srcmap.size < insize)
|
||||||
|
goto wrong_size;
|
||||||
|
}
|
||||||
if (dstmap.size < outsize)
|
if (dstmap.size < outsize)
|
||||||
goto wrong_size;
|
goto wrong_size;
|
||||||
|
|
||||||
|
@ -751,7 +757,7 @@ gst_audio_convert_transform (GstBaseTransform * base, GstBuffer * inbuf,
|
||||||
gpointer out[1] = { dstmap.data };
|
gpointer out[1] = { dstmap.data };
|
||||||
|
|
||||||
if (!gst_audio_converter_samples (this->convert, flags,
|
if (!gst_audio_converter_samples (this->convert, flags,
|
||||||
in, samples, out, samples))
|
inbuf != outbuf ? in : out, samples, out, samples))
|
||||||
goto convert_error;
|
goto convert_error;
|
||||||
} else {
|
} else {
|
||||||
/* Create silence buffer */
|
/* Create silence buffer */
|
||||||
|
@ -761,7 +767,8 @@ gst_audio_convert_transform (GstBaseTransform * base, GstBuffer * inbuf,
|
||||||
|
|
||||||
done:
|
done:
|
||||||
gst_buffer_unmap (outbuf, &dstmap);
|
gst_buffer_unmap (outbuf, &dstmap);
|
||||||
gst_buffer_unmap (inbuf, &srcmap);
|
if (inbuf != outbuf)
|
||||||
|
gst_buffer_unmap (inbuf, &srcmap);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue