opencv: port baseclass to 0.11

This commit is contained in:
Stefan Sauer 2011-11-25 23:11:32 +01:00
parent b78b980d72
commit 181be8d52b
2 changed files with 37 additions and 22 deletions

View file

@ -96,31 +96,31 @@ gst_opencv_parse_iplimage_params_from_caps (GstCaps * caps, gint * width,
GstCaps * GstCaps *
gst_opencv_caps_from_cv_image_type (int cv_type) 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) { switch (cv_type) {
case CV_8UC1: 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; break;
case CV_8UC3: case CV_8UC3:
gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_RGB)); gst_caps_append (c, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("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 ("BGR")));
break; break;
case CV_8UC4: case CV_8UC4:
gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_RGBx)); gst_caps_append (c, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("RGBx")));
gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_xRGB)); gst_caps_append (c, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("xRGB")));
gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_BGRx)); gst_caps_append (c, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("BGRx")));
gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_xBGR)); gst_caps_append (c, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("xBGR")));
gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_RGBA)); gst_caps_append (c, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("RGBA")));
gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_ARGB)); gst_caps_append (c, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("ARGB")));
gst_caps_append (caps, gst_caps_from_string (GST_VIDEO_CAPS_BGRA)); gst_caps_append (c, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("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 ("ABGR")));
break; break;
case CV_16UC1: case CV_16UC1:
gst_caps_append (caps, gst_caps_append (c,
gst_caps_from_string (GST_VIDEO_CAPS_GRAY16 ("1234"))); gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("GRAY16_LE")));
gst_caps_append (caps, gst_caps_append (c,
gst_caps_from_string (GST_VIDEO_CAPS_GRAY16 ("4321"))); gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("GRAY16_BE")));
break; break;
} }
return caps; return c;
} }

View file

@ -167,6 +167,7 @@ gst_opencv_video_filter_transform (GstBaseTransform * trans,
{ {
GstOpencvVideoFilter *transform; GstOpencvVideoFilter *transform;
GstOpencvVideoFilterClass *fclass; GstOpencvVideoFilterClass *fclass;
GstFlowReturn ret;
transform = GST_OPENCV_VIDEO_FILTER (trans); transform = GST_OPENCV_VIDEO_FILTER (trans);
fclass = GST_OPENCV_VIDEO_FILTER_GET_CLASS (transform); fclass = GST_OPENCV_VIDEO_FILTER_GET_CLASS (transform);
@ -175,10 +176,18 @@ gst_opencv_video_filter_transform (GstBaseTransform * trans,
g_return_val_if_fail (transform->cvImage != NULL, GST_FLOW_ERROR); g_return_val_if_fail (transform->cvImage != NULL, GST_FLOW_ERROR);
g_return_val_if_fail (transform->out_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->cvImage->imageData = (char *) gst_buffer_map (inbuf,
transform->out_cvImage->imageData = (char *) GST_BUFFER_DATA (outbuf); NULL, NULL, GST_MAP_READ);
return fclass->cv_trans_func (transform, inbuf, transform->cvImage, outbuf, 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); transform->out_cvImage);
gst_buffer_unmap (inbuf, transform->cvImage->imageData, -1);
gst_buffer_unmap (outbuf, transform->out_cvImage->imageData, -1);
return ret;
} }
static GstFlowReturn static GstFlowReturn
@ -187,6 +196,7 @@ gst_opencv_video_filter_transform_ip (GstBaseTransform * trans,
{ {
GstOpencvVideoFilter *transform; GstOpencvVideoFilter *transform;
GstOpencvVideoFilterClass *fclass; GstOpencvVideoFilterClass *fclass;
GstFlowReturn ret;
transform = GST_OPENCV_VIDEO_FILTER (trans); transform = GST_OPENCV_VIDEO_FILTER (trans);
fclass = GST_OPENCV_VIDEO_FILTER_GET_CLASS (transform); fclass = GST_OPENCV_VIDEO_FILTER_GET_CLASS (transform);
@ -198,10 +208,15 @@ gst_opencv_video_filter_transform_ip (GstBaseTransform * trans,
* level */ * level */
buffer = gst_buffer_make_writable (buffer); 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? */ /* 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 static gboolean