summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorThiago Santos <thiago.sousa.santos@collabora.co.uk>2010-04-26 16:17:23 -0300
committerThiago Santos <thiago.sousa.santos@collabora.co.uk>2010-09-08 17:15:49 -0300
commit42984056db42cd07f02bc8c153bb0933fb41a3c2 (patch)
tree69c09b4ef73bd18a5b70859eb9423af37fb9149f /ext
parent069c1369a242c3318630d271cfbb198854d29e71 (diff)
edgedetect: Fix chain buffer handling
Allocate a new output buffer instead of using the input buffer pointing to the internal cvCEdge opencv's IplImage data, which might change, consequently changing the buffer.
Diffstat (limited to 'ext')
-rw-r--r--ext/opencv/edgedetect/gstedgedetect.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/ext/opencv/edgedetect/gstedgedetect.c b/ext/opencv/edgedetect/gstedgedetect.c
index aa7b37763..77e1d62b0 100644
--- a/ext/opencv/edgedetect/gstedgedetect.c
+++ b/ext/opencv/edgedetect/gstedgedetect.c
@@ -288,6 +288,7 @@ static GstFlowReturn
gst_edgedetect_chain (GstPad * pad, GstBuffer * buf)
{
Gstedgedetect *filter;
+ GstBuffer *outbuf;
filter = GST_EDGEDETECT (GST_OBJECT_PARENT (pad));
@@ -305,10 +306,14 @@ gst_edgedetect_chain (GstPad * pad, GstBuffer * buf)
} else {
cvCvtColor (filter->cvEdge, filter->cvCEdge, CV_GRAY2RGB);
}
- gst_buffer_set_data (buf, (guint8 *) filter->cvCEdge->imageData,
- filter->cvCEdge->imageSize);
- return gst_pad_push (filter->srcpad, buf);
+ outbuf = gst_buffer_new_and_alloc (filter->cvCEdge->imageSize);
+ gst_buffer_copy_metadata (outbuf, buf, GST_BUFFER_COPY_ALL);
+ memcpy (GST_BUFFER_DATA (outbuf), filter->cvCEdge->imageData,
+ GST_BUFFER_SIZE (outbuf));
+
+ gst_buffer_unref (buf);
+ return gst_pad_push (filter->srcpad, outbuf);
}
/* entry point to initialize the plug-in