Commit cfc420bf authored by Nicolas Dufresne's avatar Nicolas Dufresne

opencvvideofilter: Don't parse the caps twice

The GstVideoFilter already provide caps parsed into GstVideoInfo. Avoid
doing that twice by splitting the helper.

https://bugzilla.gnome.org/show_bug.cgi?id=775288
parent ed387765
......@@ -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? */
......
......@@ -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
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment