summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorThiago Santos <thiago.sousa.santos@collabora.co.uk>2010-05-16 11:42:08 -0300
committerThiago Santos <thiago.sousa.santos@collabora.co.uk>2010-09-08 17:15:50 -0300
commit971fe3ae0cc7f61a591d84e8cecc853c6f266e03 (patch)
treec8df124895c50683d00d82c11e1da4eb781d3ad9 /ext
parent824d69d5ad917e7814530642db706e0dc8e7c186 (diff)
cvsmooth: Add support for video/x-raw-gray
Diffstat (limited to 'ext')
-rw-r--r--ext/opencv/basicfilters/gstcvsmooth.c6
-rw-r--r--ext/opencv/gstopencvbasetrans.c8
-rw-r--r--ext/opencv/gstopencvutils.c65
-rw-r--r--ext/opencv/gstopencvutils.h5
4 files changed, 49 insertions, 35 deletions
diff --git a/ext/opencv/basicfilters/gstcvsmooth.c b/ext/opencv/basicfilters/gstcvsmooth.c
index 4a3fba7fc..ec24b2c8a 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 4dfd58681..747d25078 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 653e3c7e3..0b5839739 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 3438600aa..d4602a7c6 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__ */