diff --git a/gst-libs/gst/opencv/gstopencvutils.cpp b/gst-libs/gst/opencv/gstopencvutils.cpp index 640486be19..e070c707b6 100644 --- a/gst-libs/gst/opencv/gstopencvutils.cpp +++ b/gst-libs/gst/opencv/gstopencvutils.cpp @@ -32,9 +32,6 @@ gst_opencv_parse_iplimage_params_from_caps (GstCaps * caps, gint * width, gint * height, gint * ipldepth, gint * channels, GError ** err) { GstVideoInfo info; - gint depth = 0; - guint i; - gchar *caps_str; if (!gst_video_info_from_caps (&info, caps)) { GST_ERROR ("Failed to get the videoinfo from caps"); @@ -43,22 +40,32 @@ gst_opencv_parse_iplimage_params_from_caps (GstCaps * caps, gint * width, return FALSE; } - *width = GST_VIDEO_INFO_WIDTH (&info); - *height = GST_VIDEO_INFO_HEIGHT (&info); - if (GST_VIDEO_INFO_IS_RGB (&info)) + return gst_opencv_iplimage_params_from_video_info (&info, width, height, + ipldepth, channels, err); +} + +gboolean +gst_opencv_iplimage_params_from_video_info (GstVideoInfo * info, gint * width, + gint * height, gint * ipldepth, gint * channels, GError ** err) +{ + gint depth = 0; + guint i; + + *width = GST_VIDEO_INFO_WIDTH (info); + *height = GST_VIDEO_INFO_HEIGHT (info); + if (GST_VIDEO_INFO_IS_RGB (info)) *channels = 3; - else if (GST_VIDEO_INFO_IS_GRAY (&info)) + else if (GST_VIDEO_INFO_IS_GRAY (info)) *channels = 1; else { - caps_str = gst_caps_to_string (caps); g_set_error (err, GST_CORE_ERROR, GST_CORE_ERROR_NEGOTIATION, - "Unsupported caps %s", caps_str); - g_free (caps_str); + "Unsupported video format %s", + gst_video_format_to_string (GST_VIDEO_INFO_FORMAT (info))); return FALSE; } - for (i = 0; i < GST_VIDEO_INFO_N_COMPONENTS (&info); i++) - depth += GST_VIDEO_INFO_COMP_DEPTH (&info, i); + for (i = 0; i < GST_VIDEO_INFO_N_COMPONENTS (info); i++) + depth += GST_VIDEO_INFO_COMP_DEPTH (info, i); if (depth / *channels == 8) { /* TODO signdness? */ diff --git a/gst-libs/gst/opencv/gstopencvutils.h b/gst-libs/gst/opencv/gstopencvutils.h index 13dfd9e078..4cd32d8b80 100644 --- a/gst-libs/gst/opencv/gstopencvutils.h +++ b/gst-libs/gst/opencv/gstopencvutils.h @@ -36,6 +36,10 @@ gboolean gst_opencv_parse_iplimage_params_from_caps (GstCaps * caps, gint * width, gint * height, gint * depth, gint * channels, GError ** err); +gboolean gst_opencv_iplimage_params_from_video_info + (GstVideoInfo * info, gint * width, gint * height, gint * depth, + gint * channels, GError ** err); + GstCaps * gst_opencv_caps_from_cv_image_type (int cv_type); G_END_DECLS diff --git a/gst-libs/gst/opencv/gstopencvvideofilter.cpp b/gst-libs/gst/opencv/gstopencvvideofilter.cpp index 7d02742729..7f520b10e0 100644 --- a/gst-libs/gst/opencv/gstopencvvideofilter.cpp +++ b/gst-libs/gst/opencv/gstopencvvideofilter.cpp @@ -192,7 +192,7 @@ gst_opencv_video_filter_set_info (GstVideoFilter * trans, GstCaps * incaps, GError *in_err = NULL; GError *out_err = NULL; - if (!gst_opencv_parse_iplimage_params_from_caps (incaps, &in_width, + if (!gst_opencv_iplimage_params_from_video_info (in_info, &in_width, &in_height, &in_depth, &in_channels, &in_err)) { GST_WARNING_OBJECT (transform, "Failed to parse input caps: %s", in_err->message); @@ -200,7 +200,7 @@ gst_opencv_video_filter_set_info (GstVideoFilter * trans, GstCaps * incaps, return FALSE; } - if (!gst_opencv_parse_iplimage_params_from_caps (outcaps, &out_width, + if (!gst_opencv_iplimage_params_from_video_info (out_info, &out_width, &out_height, &out_depth, &out_channels, &out_err)) { GST_WARNING_OBJECT (transform, "Failed to parse output caps: %s", out_err->message);