GstCaps *
gst_opencv_caps_from_cv_image_type (int cv_type)
{
- GstCaps *caps = gst_caps_new_empty ();
+ GstCaps *c = gst_caps_new_empty ();
switch (cv_type) {
case CV_8UC1:
- gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_GRAY8));
+ gst_caps_append (c, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("GRAY8")));
break;
case CV_8UC3:
- gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_RGB));
- gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_BGR));
+ gst_caps_append (c, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("RGB")));
+ gst_caps_append (c, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("BGR")));
break;
case CV_8UC4:
- gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_RGBx));
- gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_xRGB));
- gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_BGRx));
- gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_xBGR));
- gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_RGBA));
- gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_ARGB));
- gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_BGRA));
- gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_ABGR));
+ gst_caps_append (c, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("RGBx")));
+ gst_caps_append (c, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("xRGB")));
+ gst_caps_append (c, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("BGRx")));
+ gst_caps_append (c, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("xBGR")));
+ gst_caps_append (c, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("RGBA")));
+ gst_caps_append (c, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("ARGB")));
+ gst_caps_append (c, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("BGRA")));
+ gst_caps_append (c, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("ABGR")));
break;
case CV_16UC1:
- gst_caps_append (caps,
- gst_caps_from_string (GST_VIDEO_CAPS_GRAY16 ("1234")));
- gst_caps_append (caps,
- gst_caps_from_string (GST_VIDEO_CAPS_GRAY16 ("4321")));
+ gst_caps_append (c,
+ gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("GRAY16_LE")));
+ gst_caps_append (c,
+ gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("GRAY16_BE")));
break;
}
- return caps;
+ return c;
}
{
GstOpencvVideoFilter *transform;
GstOpencvVideoFilterClass *fclass;
+ GstFlowReturn ret;
transform = GST_OPENCV_VIDEO_FILTER (trans);
fclass = GST_OPENCV_VIDEO_FILTER_GET_CLASS (transform);
g_return_val_if_fail (transform->cvImage != NULL, GST_FLOW_ERROR);
g_return_val_if_fail (transform->out_cvImage != NULL, GST_FLOW_ERROR);
- transform->cvImage->imageData = (char *) GST_BUFFER_DATA (inbuf);
- transform->out_cvImage->imageData = (char *) GST_BUFFER_DATA (outbuf);
- return fclass->cv_trans_func (transform, inbuf, transform->cvImage, outbuf,
+ transform->cvImage->imageData = (char *) gst_buffer_map (inbuf,
+ NULL, NULL, GST_MAP_READ);
+ transform->out_cvImage->imageData = (char *) gst_buffer_map (outbuf,
+ NULL, NULL, GST_MAP_WRITE);
+
+ ret = fclass->cv_trans_func (transform, inbuf, transform->cvImage, outbuf,
transform->out_cvImage);
+
+ gst_buffer_unmap (inbuf, transform->cvImage->imageData, -1);
+ gst_buffer_unmap (outbuf, transform->out_cvImage->imageData, -1);
+
+ return ret;
}
static GstFlowReturn
{
GstOpencvVideoFilter *transform;
GstOpencvVideoFilterClass *fclass;
+ GstFlowReturn ret;
transform = GST_OPENCV_VIDEO_FILTER (trans);
fclass = GST_OPENCV_VIDEO_FILTER_GET_CLASS (transform);
* level */
buffer = gst_buffer_make_writable (buffer);
- transform->cvImage->imageData = (char *) GST_BUFFER_DATA (buffer);
+ transform->cvImage->imageData = (char *) gst_buffer_map (buffer,
+ NULL, NULL, GST_MAP_READWRITE);
/* FIXME how to release buffer? */
- return fclass->cv_trans_ip_func (transform, buffer, transform->cvImage);
+ ret = fclass->cv_trans_ip_func (transform, buffer, transform->cvImage);
+
+ gst_buffer_unmap (buffer, transform->cvImage->imageData, -1);
+
+ return ret;
}
static gboolean