mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 17:20:36 +00:00
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.
This commit is contained in:
parent
069c1369a2
commit
42984056db
1 changed files with 8 additions and 3 deletions
|
@ -288,6 +288,7 @@ static GstFlowReturn
|
||||||
gst_edgedetect_chain (GstPad * pad, GstBuffer * buf)
|
gst_edgedetect_chain (GstPad * pad, GstBuffer * buf)
|
||||||
{
|
{
|
||||||
Gstedgedetect *filter;
|
Gstedgedetect *filter;
|
||||||
|
GstBuffer *outbuf;
|
||||||
|
|
||||||
filter = GST_EDGEDETECT (GST_OBJECT_PARENT (pad));
|
filter = GST_EDGEDETECT (GST_OBJECT_PARENT (pad));
|
||||||
|
|
||||||
|
@ -305,10 +306,14 @@ gst_edgedetect_chain (GstPad * pad, GstBuffer * buf)
|
||||||
} else {
|
} else {
|
||||||
cvCvtColor (filter->cvEdge, filter->cvCEdge, CV_GRAY2RGB);
|
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
|
/* entry point to initialize the plug-in
|
||||||
|
|
Loading…
Reference in a new issue