mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 17:20:36 +00:00
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:
parent
5a9d9a8ae0
commit
b8b0c39a63
1 changed files with 13 additions and 3 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue