[gst-cvs] gst-plugins-bad: pyramidsegment: Allocate a new buffer for output
Thiago Sousa Santos
thiagoss at kemper.freedesktop.org
Wed Sep 8 13:23:32 PDT 2010
Module: gst-plugins-bad
Branch: master
Commit: b8b0c39a63ecc6c368d6bd60562d5b907c566cb8
URL: http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/commit/?id=b8b0c39a63ecc6c368d6bd60562d5b907c566cb8
Author: Thiago Santos <thiago.sousa.santos at collabora.co.uk>
Date: Mon Apr 26 17:18:54 2010 -0300
pyramidsegment: Allocate a new buffer for output
Use a newly allocated buffer for output, and release the intermediary
image used.
Also add a TODO for performance improvement
---
ext/opencv/pyramidsegment/gstpyramidsegment.c | 16 +++++++++++++---
1 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/ext/opencv/pyramidsegment/gstpyramidsegment.c b/ext/opencv/pyramidsegment/gstpyramidsegment.c
index 7e3e8fe..f6a4793 100644
--- a/ext/opencv/pyramidsegment/gstpyramidsegment.c
+++ b/ext/opencv/pyramidsegment/gstpyramidsegment.c
@@ -293,6 +293,7 @@ static GstFlowReturn
gst_pyramidsegment_chain (GstPad * pad, GstBuffer * buf)
{
Gstpyramidsegment *filter;
+ GstBuffer *outbuf;
filter = GST_PYRAMIDSEGMENT (GST_OBJECT_PARENT (pad));
@@ -302,10 +303,19 @@ gst_pyramidsegment_chain (GstPad * pad, GstBuffer * buf)
cvPyrSegmentation (filter->cvImage, filter->cvSegmentedImage, filter->storage,
&(filter->comp), filter->level, filter->threshold1, filter->threshold2);
- gst_buffer_set_data (buf, (guint8 *) filter->cvSegmentedImage->imageData,
- filter->cvSegmentedImage->imageSize);
+ /* TODO look if there is a way in opencv to reuse the image data and
+ * delete only the struct headers. Would avoid a memcpy here */
- return gst_pad_push (filter->srcpad, buf);
+ outbuf = gst_buffer_new_and_alloc (filter->cvSegmentedImage->imageSize);
+ gst_buffer_copy_metadata (outbuf, buf, GST_BUFFER_COPY_ALL);
+ memcpy (GST_BUFFER_DATA (outbuf), filter->cvSegmentedImage->imageData,
+ GST_BUFFER_SIZE (outbuf));
+
+ gst_buffer_unref (buf);
+ cvReleaseImage (&filter->cvSegmentedImage);
+ g_assert (filter->cvSegmentedImage == NULL);
+
+ return gst_pad_push (filter->srcpad, outbuf);
}
More information about the Gstreamer-commits
mailing list