From: Thiago Santos Date: Sun, 16 May 2010 14:42:08 +0000 (-0300) Subject: cvsmooth: Add support for video/x-raw-gray X-Git-Tag: 1.19.3~507^2~16524 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=971fe3ae0cc7f61a591d84e8cecc853c6f266e03;p=platform%2Fupstream%2Fgstreamer.git cvsmooth: Add support for video/x-raw-gray --- diff --git a/ext/opencv/basicfilters/gstcvsmooth.c b/ext/opencv/basicfilters/gstcvsmooth.c index 4a3fba7..ec24b2c 100644 --- a/ext/opencv/basicfilters/gstcvsmooth.c +++ b/ext/opencv/basicfilters/gstcvsmooth.c @@ -55,13 +55,15 @@ GST_DEBUG_CATEGORY_STATIC (gst_cv_smooth_debug); static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_STATIC_CAPS ("video/x-raw-rgb, depth=(int)24, bpp=(int)24") + GST_STATIC_CAPS ("video/x-raw-rgb, depth=(int)24, bpp=(int)24;" + "video/x-raw-gray, depth=(int)8, bpp=(int)8") ); static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_STATIC_CAPS ("video/x-raw-rgb, depth=(int)24, bpp=(int)24") + GST_STATIC_CAPS ("video/x-raw-rgb, depth=(int)24, bpp=(int)24;" + "video/x-raw-gray, depth=(int)8, bpp=(int)8") ); /* Filter signals and args */ diff --git a/ext/opencv/gstopencvbasetrans.c b/ext/opencv/gstopencvbasetrans.c index 4dfd586..747d250 100644 --- a/ext/opencv/gstopencvbasetrans.c +++ b/ext/opencv/gstopencvbasetrans.c @@ -212,14 +212,14 @@ gst_opencv_base_transform_set_caps (GstBaseTransform * trans, GstCaps * incaps, { GstOpencvBaseTransform *transform = GST_OPENCV_BASE_TRANSFORM (trans); gint in_width, in_height; - gint in_depth, in_type, in_channels; + gint in_depth, in_channels; gint out_width, out_height; - gint out_depth, out_type, out_channels; + gint out_depth, out_channels; GError *in_err = NULL; GError *out_err = NULL; if (!gst_opencv_parse_iplimage_params_from_caps (incaps, &in_width, - &in_height, &in_depth, &in_type, &in_channels, &in_err)) { + &in_height, &in_depth, &in_channels, &in_err)) { GST_WARNING_OBJECT (transform, "Failed to parse input caps: %s", in_err->message); g_error_free (in_err); @@ -227,7 +227,7 @@ gst_opencv_base_transform_set_caps (GstBaseTransform * trans, GstCaps * incaps, } if (!gst_opencv_parse_iplimage_params_from_caps (outcaps, &out_width, - &out_height, &out_depth, &out_type, &out_channels, &out_err)) { + &out_height, &out_depth, &out_channels, &out_err)) { GST_WARNING_OBJECT (transform, "Failed to parse output caps: %s", out_err->message); g_error_free (out_err); diff --git a/ext/opencv/gstopencvutils.c b/ext/opencv/gstopencvutils.c index 653e3c7..0b58397 100644 --- a/ext/opencv/gstopencvutils.c +++ b/ext/opencv/gstopencvutils.c @@ -27,45 +27,46 @@ gst_opencv_get_ipl_depth_and_channels (GstStructure * structure, { gint depth, bpp; - if (gst_structure_has_name (structure, "video/x-raw-rgb")) { - *channels = 3; - - if (!gst_structure_get_int (structure, "depth", &depth) || - !gst_structure_get_int (structure, "bpp", &bpp)) { - g_set_error (err, GST_CORE_ERROR, GST_CORE_ERROR_NEGOTIATION, - "No depth/bpp in caps"); - return FALSE; - } - - if (depth != bpp) { - g_set_error (err, GST_CORE_ERROR, GST_CORE_ERROR_NEGOTIATION, - "Depth and bpp should be equal"); - return FALSE; - } + if (!gst_structure_get_int (structure, "depth", &depth) || + !gst_structure_get_int (structure, "bpp", &bpp)) { + g_set_error (err, GST_CORE_ERROR, GST_CORE_ERROR_NEGOTIATION, + "No depth/bpp in caps"); + return FALSE; + } - if (depth == 24) { - /* TODO signdness? */ - *ipldepth = IPL_DEPTH_8U; - } else { - g_set_error (err, GST_CORE_ERROR, GST_CORE_ERROR_NEGOTIATION, - "Unsupported depth: %d", depth); - return FALSE; - } + if (depth != bpp) { + g_set_error (err, GST_CORE_ERROR, GST_CORE_ERROR_NEGOTIATION, + "Depth and bpp should be equal"); + return FALSE; + } - return TRUE; + if (gst_structure_has_name (structure, "video/x-raw-rgb")) { + *channels = 3; + } else if (gst_structure_has_name (structure, "video/x-raw-gray")) { + *channels = 1; } else { g_set_error (err, GST_CORE_ERROR, GST_CORE_ERROR_NEGOTIATION, "Unsupported caps %s", gst_structure_get_name (structure)); return FALSE; } + + if (depth / *channels == 8) { + /* TODO signdness? */ + *ipldepth = IPL_DEPTH_8U; + } else { + g_set_error (err, GST_CORE_ERROR, GST_CORE_ERROR_NEGOTIATION, + "Unsupported depth/channels %d/%d", depth, *channels); + return FALSE; + } + + return TRUE; } gboolean -gst_opencv_parse_iplimage_params_from_caps (GstCaps * caps, gint * width, - gint * height, gint * ipldepth, gint * type, gint * channels, GError ** err) +gst_opencv_parse_iplimage_params_from_structure (GstStructure * structure, + gint * width, gint * height, gint * ipldepth, gint * channels, + GError ** err) { - GstStructure *structure = gst_caps_get_structure (caps, 0); - if (!gst_opencv_get_ipl_depth_and_channels (structure, ipldepth, channels, err)) { return FALSE; @@ -80,3 +81,11 @@ gst_opencv_parse_iplimage_params_from_caps (GstCaps * caps, gint * width, return TRUE; } + +gboolean +gst_opencv_parse_iplimage_params_from_caps (GstCaps * caps, gint * width, + gint * height, gint * ipldepth, gint * channels, GError ** err) +{ + return gst_opencv_parse_iplimage_params_from_structure ( + gst_caps_get_structure (caps, 0), width, height, ipldepth, channels, err); +} diff --git a/ext/opencv/gstopencvutils.h b/ext/opencv/gstopencvutils.h index 3438600..d4602a7 100644 --- a/ext/opencv/gstopencvutils.h +++ b/ext/opencv/gstopencvutils.h @@ -33,7 +33,10 @@ gboolean gst_opencv_get_ipldepth (gint depth, gint bpp, gint * ipldepth); gboolean gst_opencv_parse_iplimage_params_from_caps - (GstCaps * caps, gint * width, gint * height, gint * depth, gint * type, + (GstCaps * caps, gint * width, gint * height, gint * depth, + gint * channels, GError ** err); +gboolean gst_opencv_parse_iplimage_params_from_structure + (GstStructure * structure, gint * width, gint * height, gint * depth, gint * channels, GError ** err); #endif /* __GST_OPENCV_UTILS__ */