mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 09:10:36 +00:00
shapewipe: Try to work inplace if possible
This saves one new, large allocation per frame for the most cases.
This commit is contained in:
parent
3b99292629
commit
80d5bd7168
1 changed files with 19 additions and 8 deletions
|
@ -686,6 +686,7 @@ gst_shape_wipe_video_sink_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
GstFlowReturn ret = GST_FLOW_OK;
|
GstFlowReturn ret = GST_FLOW_OK;
|
||||||
GstBuffer *mask = NULL, *outbuf = NULL;
|
GstBuffer *mask = NULL, *outbuf = NULL;
|
||||||
GstClockTime timestamp;
|
GstClockTime timestamp;
|
||||||
|
gboolean new_outbuf = FALSE;
|
||||||
|
|
||||||
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
||||||
timestamp =
|
timestamp =
|
||||||
|
@ -711,6 +712,10 @@ gst_shape_wipe_video_sink_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
}
|
}
|
||||||
g_mutex_unlock (self->mask_mutex);
|
g_mutex_unlock (self->mask_mutex);
|
||||||
|
|
||||||
|
/* Try to blend inplace, if it's not possible
|
||||||
|
* get a new buffer from downstream.
|
||||||
|
*/
|
||||||
|
if (!gst_buffer_is_writable (buffer)) {
|
||||||
ret =
|
ret =
|
||||||
gst_pad_alloc_buffer_and_set_caps (self->srcpad, GST_BUFFER_OFFSET_NONE,
|
gst_pad_alloc_buffer_and_set_caps (self->srcpad, GST_BUFFER_OFFSET_NONE,
|
||||||
GST_BUFFER_SIZE (buffer), GST_PAD_CAPS (self->srcpad), &outbuf);
|
GST_BUFFER_SIZE (buffer), GST_PAD_CAPS (self->srcpad), &outbuf);
|
||||||
|
@ -719,6 +724,10 @@ gst_shape_wipe_video_sink_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
gst_buffer_unref (mask);
|
gst_buffer_unref (mask);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
new_outbuf = TRUE;
|
||||||
|
} else {
|
||||||
|
outbuf = buffer;
|
||||||
|
}
|
||||||
|
|
||||||
if (self->mask_bpp == 16)
|
if (self->mask_bpp == 16)
|
||||||
ret = gst_shape_wipe_blend_16 (self, buffer, mask, outbuf);
|
ret = gst_shape_wipe_blend_16 (self, buffer, mask, outbuf);
|
||||||
|
@ -726,7 +735,9 @@ gst_shape_wipe_video_sink_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
ret = gst_shape_wipe_blend_8 (self, buffer, mask, outbuf);
|
ret = gst_shape_wipe_blend_8 (self, buffer, mask, outbuf);
|
||||||
|
|
||||||
gst_buffer_unref (mask);
|
gst_buffer_unref (mask);
|
||||||
|
if (new_outbuf)
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
|
|
||||||
if (ret != GST_FLOW_OK) {
|
if (ret != GST_FLOW_OK) {
|
||||||
gst_buffer_unref (outbuf);
|
gst_buffer_unref (outbuf);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in a new issue