mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-28 04:31:06 +00:00
860ccd414d
Conflicts: NEWS RELEASE common configure.ac docs/libs/gst-plugins-bad-libs-sections.txt docs/plugins/gst-plugins-bad-plugins.args docs/plugins/gst-plugins-bad-plugins.hierarchy docs/plugins/gst-plugins-bad-plugins.interfaces docs/plugins/inspect/plugin-adpcmdec.xml docs/plugins/inspect/plugin-adpcmenc.xml docs/plugins/inspect/plugin-assrender.xml docs/plugins/inspect/plugin-audiovisualizers.xml docs/plugins/inspect/plugin-autoconvert.xml docs/plugins/inspect/plugin-bayer.xml docs/plugins/inspect/plugin-bz2.xml docs/plugins/inspect/plugin-camerabin2.xml docs/plugins/inspect/plugin-celt.xml docs/plugins/inspect/plugin-dataurisrc.xml docs/plugins/inspect/plugin-debugutilsbad.xml docs/plugins/inspect/plugin-dtmf.xml docs/plugins/inspect/plugin-dtsdec.xml docs/plugins/inspect/plugin-dvbsuboverlay.xml docs/plugins/inspect/plugin-dvdspu.xml docs/plugins/inspect/plugin-faac.xml docs/plugins/inspect/plugin-faad.xml docs/plugins/inspect/plugin-gsm.xml docs/plugins/inspect/plugin-h264parse.xml docs/plugins/inspect/plugin-mms.xml docs/plugins/inspect/plugin-modplug.xml docs/plugins/inspect/plugin-mpeg2enc.xml docs/plugins/inspect/plugin-mpegdemux2.xml docs/plugins/inspect/plugin-mpegtsdemux.xml docs/plugins/inspect/plugin-mpegvideoparse.xml docs/plugins/inspect/plugin-mplex.xml docs/plugins/inspect/plugin-pcapparse.xml docs/plugins/inspect/plugin-rawparse.xml docs/plugins/inspect/plugin-rtpmux.xml docs/plugins/inspect/plugin-rtpvp8.xml docs/plugins/inspect/plugin-scaletempo.xml docs/plugins/inspect/plugin-schro.xml docs/plugins/inspect/plugin-sdp.xml docs/plugins/inspect/plugin-segmentclip.xml docs/plugins/inspect/plugin-shm.xml docs/plugins/inspect/plugin-videomaxrate.xml docs/plugins/inspect/plugin-videoparsersbad.xml docs/plugins/inspect/plugin-vp8.xml docs/plugins/inspect/plugin-y4mdec.xml ext/celt/gstceltdec.c ext/dts/gstdtsdec.c ext/modplug/gstmodplug.cc ext/opus/gstopusenc.c gst-libs/gst/video/gstbasevideocodec.c gst-libs/gst/video/gstbasevideocodec.h gst-libs/gst/video/gstbasevideodecoder.c gst-libs/gst/video/gstbasevideodecoder.h gst-libs/gst/video/gstbasevideoencoder.c gst-libs/gst/video/gstbasevideoencoder.h gst/adpcmdec/Makefile.am gst/audiovisualizers/gstbaseaudiovisualizer.c gst/h264parse/gsth264parse.c gst/mpegdemux/mpegtsparse.c gst/mpegtsdemux/mpegtsbase.c gst/mpegtsdemux/mpegtspacketizer.c gst/mpegtsdemux/mpegtsparse.c gst/mpegtsdemux/tsdemux.c gst/mpegtsdemux/tsdemux.h gst/mxf/mxfdemux.c gst/rawparse/gstaudioparse.c gst/videoparsers/gsth263parse.c gst/videoparsers/gsth264parse.c sys/d3dvideosink/d3dvideosink.c sys/decklink/gstdecklinksink.cpp sys/dvb/gstdvbsrc.c sys/shm/gstshmsrc.c sys/vdpau/h264/gstvdph264dec.c sys/vdpau/mpeg/gstvdpmpegdec.c tests/examples/opencv/gst_element_print_properties.c win32/common/config.h
130 lines
4.3 KiB
C
130 lines
4.3 KiB
C
/* GStreamer
|
|
* Copyright (C) <2010> Thiago Santos <thiago.sousa.santos@collabora.co.uk>
|
|
*
|
|
* gstopencvutils.c: miscellaneous utility functions
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Library General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Library General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Library General Public
|
|
* License along with this library; if not, write to the
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
* Boston, MA 02111-1307, USA.
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
#include "config.h"
|
|
#endif
|
|
|
|
#include "gstopencvutils.h"
|
|
|
|
static gboolean
|
|
gst_opencv_get_ipl_depth_and_channels (GstStructure * structure,
|
|
gint * ipldepth, gint * channels, GError ** err)
|
|
{
|
|
gint depth, bpp;
|
|
|
|
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_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 if (depth / *channels == 16) {
|
|
*ipldepth = IPL_DEPTH_16U;
|
|
} 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_structure (GstStructure * structure,
|
|
gint * width, gint * height, gint * ipldepth, gint * channels,
|
|
GError ** err)
|
|
{
|
|
if (!gst_opencv_get_ipl_depth_and_channels (structure, ipldepth, channels,
|
|
err)) {
|
|
return FALSE;
|
|
}
|
|
|
|
if (!gst_structure_get_int (structure, "width", width) ||
|
|
!gst_structure_get_int (structure, "height", height)) {
|
|
g_set_error (err, GST_CORE_ERROR, GST_CORE_ERROR_NEGOTIATION,
|
|
"No width/height in caps");
|
|
return FALSE;
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
GstCaps *
|
|
gst_opencv_caps_from_cv_image_type (int cv_type)
|
|
{
|
|
GstCaps *c = gst_caps_new_empty ();
|
|
switch (cv_type) {
|
|
case CV_8UC1:
|
|
gst_caps_append (c, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("GRAY8")));
|
|
break;
|
|
case CV_8UC3:
|
|
gst_caps_append (c, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("RGB")));
|
|
gst_caps_append (c, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("BGR")));
|
|
break;
|
|
case CV_8UC4:
|
|
gst_caps_append (c, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("RGBx")));
|
|
gst_caps_append (c, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("xRGB")));
|
|
gst_caps_append (c, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("BGRx")));
|
|
gst_caps_append (c, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("xBGR")));
|
|
gst_caps_append (c, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("RGBA")));
|
|
gst_caps_append (c, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("ARGB")));
|
|
gst_caps_append (c, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("BGRA")));
|
|
gst_caps_append (c, gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("ABGR")));
|
|
break;
|
|
case CV_16UC1:
|
|
gst_caps_append (c,
|
|
gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("GRAY16_LE")));
|
|
gst_caps_append (c,
|
|
gst_caps_from_string (GST_VIDEO_CAPS_MAKE ("GRAY16_BE")));
|
|
break;
|
|
}
|
|
return c;
|
|
}
|