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
This commit is contained in:
Thiago Santos 2010-04-26 17:18:54 -03:00
parent 5a9d9a8ae0
commit b8b0c39a63

View file

@ -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);
}