diff options
author | Sebastian Dröge <sebastian.droege@collabora.co.uk> | 2009-06-09 18:25:13 +0200 |
---|---|---|
committer | Sebastian Dröge <sebastian.droege@collabora.co.uk> | 2009-06-19 11:01:59 +0200 |
commit | 80d5bd7168172cc9dc90c1ab1a571126a2186e18 (patch) | |
tree | 75ff2b802a0aa1a227adedcadf8bb5a348f8fd29 /gst/shapewipe | |
parent | 3b99292629c2ce6c38a9315699ece1546079846a (diff) | |
download | gst-plugins-bad-80d5bd7168172cc9dc90c1ab1a571126a2186e18.tar.gz gst-plugins-bad-80d5bd7168172cc9dc90c1ab1a571126a2186e18.tar.bz2 gst-plugins-bad-80d5bd7168172cc9dc90c1ab1a571126a2186e18.zip |
shapewipe: Try to work inplace if possible
This saves one new, large allocation per frame for the
most cases.
Diffstat (limited to 'gst/shapewipe')
-rw-r--r-- | gst/shapewipe/gstshapewipe.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/gst/shapewipe/gstshapewipe.c b/gst/shapewipe/gstshapewipe.c index c2c4ce2b..61aaf476 100644 --- a/gst/shapewipe/gstshapewipe.c +++ b/gst/shapewipe/gstshapewipe.c @@ -686,6 +686,7 @@ gst_shape_wipe_video_sink_chain (GstPad * pad, GstBuffer * buffer) GstFlowReturn ret = GST_FLOW_OK; GstBuffer *mask = NULL, *outbuf = NULL; GstClockTime timestamp; + gboolean new_outbuf = FALSE; timestamp = GST_BUFFER_TIMESTAMP (buffer); timestamp = @@ -711,13 +712,21 @@ gst_shape_wipe_video_sink_chain (GstPad * pad, GstBuffer * buffer) } g_mutex_unlock (self->mask_mutex); - ret = - gst_pad_alloc_buffer_and_set_caps (self->srcpad, GST_BUFFER_OFFSET_NONE, - GST_BUFFER_SIZE (buffer), GST_PAD_CAPS (self->srcpad), &outbuf); - if (G_UNLIKELY (ret != GST_FLOW_OK)) { - gst_buffer_unref (buffer); - gst_buffer_unref (mask); - return ret; + /* Try to blend inplace, if it's not possible + * get a new buffer from downstream. + */ + if (!gst_buffer_is_writable (buffer)) { + ret = + gst_pad_alloc_buffer_and_set_caps (self->srcpad, GST_BUFFER_OFFSET_NONE, + GST_BUFFER_SIZE (buffer), GST_PAD_CAPS (self->srcpad), &outbuf); + if (G_UNLIKELY (ret != GST_FLOW_OK)) { + gst_buffer_unref (buffer); + gst_buffer_unref (mask); + return ret; + } + new_outbuf = TRUE; + } else { + outbuf = buffer; } if (self->mask_bpp == 16) @@ -726,7 +735,9 @@ gst_shape_wipe_video_sink_chain (GstPad * pad, GstBuffer * buffer) ret = gst_shape_wipe_blend_8 (self, buffer, mask, outbuf); gst_buffer_unref (mask); - gst_buffer_unref (buffer); + if (new_outbuf) + gst_buffer_unref (buffer); + if (ret != GST_FLOW_OK) { gst_buffer_unref (outbuf); return ret; |