2002-03-30 16:16:49 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2003-06-29 19:46:13 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2002-03-30 16:16:49 +00:00
|
|
|
#include <gst/gst.h>
|
2003-07-06 20:49:52 +00:00
|
|
|
#include <gst/video/video.h>
|
2002-03-30 16:16:49 +00:00
|
|
|
#include <lcs/lcs.h>
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
#include <string.h>
|
2002-03-30 16:16:49 +00:00
|
|
|
|
|
|
|
#define GST_TYPE_COLORSPACE \
|
|
|
|
(gst_colorspace_get_type())
|
|
|
|
#define GST_COLORSPACE(obj) \
|
|
|
|
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_COLORSPACE,GstColorspace))
|
|
|
|
#define GST_COLORSPACE_CLASS(klass) \
|
|
|
|
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ULAW,GstColorspace))
|
|
|
|
#define GST_IS_COLORSPACE(obj) \
|
|
|
|
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_COLORSPACE))
|
|
|
|
#define GST_IS_COLORSPACE_CLASS(obj) \
|
|
|
|
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_COLORSPACE))
|
|
|
|
|
|
|
|
typedef struct _GstColorspace GstColorspace;
|
|
|
|
typedef struct _GstColorspaceClass GstColorspaceClass;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
struct _GstColorspace
|
|
|
|
{
|
|
|
|
GstElement element;
|
|
|
|
|
|
|
|
GstPad *sinkpad, *srcpad;
|
2002-03-30 16:16:49 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
LCSConverter *converter;
|
2002-03-30 16:16:49 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gboolean passthrough;
|
|
|
|
gint width, height;
|
|
|
|
double framerate;
|
|
|
|
gboolean disabled;
|
2002-03-30 16:16:49 +00:00
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
struct _GstColorspaceClass
|
|
|
|
{
|
2002-03-30 16:16:49 +00:00
|
|
|
GstElementClass parent_class;
|
|
|
|
};
|
|
|
|
|
2002-09-18 19:02:52 +00:00
|
|
|
/* elementfactory information */
|
2002-03-30 16:16:49 +00:00
|
|
|
static GstElementDetails colorspace_details = {
|
|
|
|
"Colorspace converter",
|
|
|
|
"Filter/Effect",
|
|
|
|
"Converts video from one colorspace to another",
|
2003-11-02 14:26:13 +00:00
|
|
|
"Wim Taymans <wim.taymans@chello.be>"
|
2002-03-30 16:16:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* Stereo signals and args */
|
2004-03-14 22:34:33 +00:00
|
|
|
enum
|
|
|
|
{
|
2002-03-30 16:16:49 +00:00
|
|
|
/* FILL ME */
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
enum
|
|
|
|
{
|
2002-03-30 16:16:49 +00:00
|
|
|
ARG_0,
|
|
|
|
ARG_SOURCE,
|
|
|
|
ARG_DEST,
|
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static GType gst_colorspace_get_type (void);
|
2002-03-30 16:16:49 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void gst_colorspace_class_init (GstColorspaceClass * klass);
|
|
|
|
static void gst_colorspace_base_init (GstColorspaceClass * klass);
|
|
|
|
static void gst_colorspace_init (GstColorspace * space);
|
2002-03-30 16:16:49 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void gst_colorspace_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_colorspace_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec);
|
2002-03-30 16:16:49 +00:00
|
|
|
|
2003-01-10 13:38:32 +00:00
|
|
|
static GstPadLinkReturn
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_colorspace_link (GstPad * pad, const GstCaps * caps);
|
|
|
|
static void gst_colorspace_chain (GstPad * pad, GstData * _data);
|
|
|
|
static GstElementStateReturn gst_colorspace_change_state (GstElement * element);
|
2002-03-30 16:16:49 +00:00
|
|
|
|
|
|
|
static GstElementClass *parent_class = NULL;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2002-03-30 16:16:49 +00:00
|
|
|
/*static guint gst_colorspace_signals[LAST_SIGNAL] = { 0 }; */
|
|
|
|
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
static GstStaticPadTemplate gst_colorspace_src_template =
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("src",
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB "; "
|
|
|
|
GST_VIDEO_CAPS_BGR "; "
|
|
|
|
GST_VIDEO_CAPS_RGBx "; "
|
|
|
|
GST_VIDEO_CAPS_xRGB "; "
|
|
|
|
GST_VIDEO_CAPS_BGRx "; "
|
|
|
|
GST_VIDEO_CAPS_xBGR "; "
|
|
|
|
GST_VIDEO_CAPS_RGB_16 "; "
|
|
|
|
GST_VIDEO_CAPS_RGB_15 "; "
|
|
|
|
GST_VIDEO_CAPS_YUV ("{ I420, YV12, YUY2, YVYU, UYVY, YUV9, YVU9, "
|
|
|
|
"Y800, Y41P, Y41B, Y42B, IUY2 }")
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
)
|
2004-03-14 22:34:33 +00:00
|
|
|
);
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
|
|
|
|
static GstStaticPadTemplate gst_colorspace_sink_template =
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB "; "
|
|
|
|
GST_VIDEO_CAPS_BGR "; "
|
|
|
|
GST_VIDEO_CAPS_RGBx "; "
|
|
|
|
GST_VIDEO_CAPS_xRGB "; "
|
|
|
|
GST_VIDEO_CAPS_BGRx "; "
|
|
|
|
GST_VIDEO_CAPS_xBGR "; "
|
|
|
|
GST_VIDEO_CAPS_RGB_16 "; "
|
|
|
|
GST_VIDEO_CAPS_RGB_15 "; "
|
|
|
|
GST_VIDEO_CAPS_YUV ("{ I420, YV12, YUY2, YVYU, UYVY, YUV9, YVU9, "
|
|
|
|
"Y800, Y41P, Y41B, Y42B, IUY2 }")
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
)
|
2004-03-14 22:34:33 +00:00
|
|
|
);
|
2002-03-30 16:16:49 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static const LCSFormat *
|
|
|
|
colorspace_find_lcs_format (const GstCaps * caps)
|
2002-03-30 16:16:49 +00:00
|
|
|
{
|
|
|
|
const LCSFormat *format = NULL;
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
const char *name;
|
|
|
|
const GstStructure *structure = gst_caps_get_structure (caps, 0);
|
|
|
|
|
|
|
|
name = gst_structure_get_name (structure);
|
|
|
|
|
|
|
|
if (strcmp (name, "video/x-raw-rgb") == 0) {
|
|
|
|
LCSRGBPackedFormat *rgb_fmt = g_new (LCSRGBPackedFormat, 1);
|
|
|
|
gint mask;
|
|
|
|
gchar *format_name;
|
|
|
|
int endianness;
|
|
|
|
|
|
|
|
format = (const LCSFormat *) rgb_fmt;
|
|
|
|
|
|
|
|
((LCSFormat *) rgb_fmt)->type = LCS_FORMAT_RGB_PACKED;
|
|
|
|
gst_structure_get_int (structure, "bpp",
|
2004-03-14 22:34:33 +00:00
|
|
|
&((LCSFormat *) rgb_fmt)->bits_per_pixel);
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
gst_structure_get_int (structure, "red_mask", &mask);
|
|
|
|
lcs_utils_mask_to_shift (mask, &rgb_fmt->bits_per_component[LCS_R],
|
2004-03-14 22:34:33 +00:00
|
|
|
&rgb_fmt->component_bit_offset[LCS_R]);
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
gst_structure_get_int (structure, "green_mask", &mask);
|
|
|
|
lcs_utils_mask_to_shift (mask, &rgb_fmt->bits_per_component[LCS_G],
|
2004-03-14 22:34:33 +00:00
|
|
|
&rgb_fmt->component_bit_offset[LCS_G]);
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
gst_structure_get_int (structure, "blue_mask", &mask);
|
|
|
|
lcs_utils_mask_to_shift (mask, &rgb_fmt->bits_per_component[LCS_B],
|
2004-03-14 22:34:33 +00:00
|
|
|
&rgb_fmt->component_bit_offset[LCS_B]);
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
rgb_fmt->bits_per_component[LCS_A] = 0;
|
|
|
|
rgb_fmt->component_bit_offset[LCS_A] = 0;
|
|
|
|
gst_structure_get_int (structure, "endianness", &endianness);
|
|
|
|
rgb_fmt->endianness = endianness;
|
|
|
|
|
|
|
|
format_name = g_strdup_printf ("GST_RGB_%d", format->bits_per_pixel);
|
|
|
|
lcs_register_format (format_name, (LCSFormat *) rgb_fmt, 1);
|
2004-03-14 22:34:33 +00:00
|
|
|
} else if (strcmp (name, "video/x-raw-yuv") == 0) {
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
guint32 space;
|
2002-03-30 16:16:49 +00:00
|
|
|
gchar fourcc[5];
|
|
|
|
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
gst_structure_get_fourcc (structure, "format", &space);
|
2002-03-30 16:16:49 +00:00
|
|
|
lcs_utils_fourcc_to_string (space, fourcc);
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
fourcc[4] = '\0';
|
|
|
|
format = lcs_find_format (fourcc);
|
|
|
|
} else {
|
2004-03-14 22:34:33 +00:00
|
|
|
g_assert_not_reached ();
|
2002-03-30 16:16:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return format;
|
|
|
|
}
|
|
|
|
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
static guint32
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_colorspace_caps_get_fourcc (const GstCaps * caps)
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
{
|
|
|
|
guint32 format;
|
|
|
|
GstStructure *structure;
|
|
|
|
|
|
|
|
structure = gst_caps_get_structure (caps, 0);
|
|
|
|
if (strcmp (gst_structure_get_name (structure), "video/x-raw-rgb") == 0) {
|
2004-03-14 22:34:33 +00:00
|
|
|
format = GST_MAKE_FOURCC ('R', 'G', 'B', ' ');
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
} else {
|
|
|
|
gst_structure_get_fourcc (structure, "format", &format);
|
|
|
|
}
|
|
|
|
return format;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static gboolean
|
|
|
|
colorspace_setup_converter (GstColorspace * space, const GstCaps * from_caps,
|
|
|
|
const GstCaps * to_caps)
|
2002-03-30 16:16:49 +00:00
|
|
|
{
|
|
|
|
const LCSFormat *from_format = NULL;
|
|
|
|
const LCSFormat *to_format = NULL;
|
2002-07-08 19:33:55 +00:00
|
|
|
guint32 from_space, to_space;
|
2002-03-30 16:16:49 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (to_caps != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (from_caps != NULL, FALSE);
|
|
|
|
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
from_space = gst_colorspace_caps_get_fourcc (from_caps);
|
|
|
|
to_space = gst_colorspace_caps_get_fourcc (to_caps);
|
2002-07-08 19:33:55 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
from_format = colorspace_find_lcs_format (from_caps);
|
|
|
|
to_format = colorspace_find_lcs_format (to_caps);
|
|
|
|
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
GST_DEBUG ("trying from " GST_FOURCC_FORMAT " to " GST_FOURCC_FORMAT,
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_FOURCC_ARGS (from_space), GST_FOURCC_ARGS (to_space));
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
space->converter = lcs_find_converter (from_format, to_format, LCS_FLAG_FAST);
|
2002-03-30 16:16:49 +00:00
|
|
|
|
|
|
|
if (space->converter) {
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
GST_DEBUG ("trying from " GST_FOURCC_FORMAT " to " GST_FOURCC_FORMAT,
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_FOURCC_ARGS (from_space), GST_FOURCC_ARGS (to_space));
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
space->disabled = FALSE;
|
2002-03-30 16:16:49 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static GstCaps *
|
|
|
|
gst_colorspace_getcaps (GstPad * pad)
|
2002-03-30 16:16:49 +00:00
|
|
|
{
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
#if unused
|
2002-03-30 16:16:49 +00:00
|
|
|
GstColorspace *space;
|
|
|
|
GstCaps *result;
|
|
|
|
GstCaps *peercaps;
|
|
|
|
GstCaps *ourcaps;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2002-03-30 16:16:49 +00:00
|
|
|
space = GST_COLORSPACE (gst_pad_get_parent (pad));
|
|
|
|
|
|
|
|
/* we can do everything our peer can... */
|
|
|
|
peercaps = gst_caps_copy (gst_pad_get_allowed_caps (space->srcpad));
|
|
|
|
/* and our own template of course */
|
2002-04-11 20:42:26 +00:00
|
|
|
ourcaps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
|
2002-03-30 16:16:49 +00:00
|
|
|
|
|
|
|
/* merge them together, we prefer the peercaps first */
|
|
|
|
result = gst_caps_prepend (ourcaps, peercaps);
|
|
|
|
|
|
|
|
return result;
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
#endif
|
|
|
|
return gst_caps_copy (gst_pad_get_pad_template_caps (pad));
|
2002-03-30 16:16:49 +00:00
|
|
|
}
|
|
|
|
|
2003-01-10 13:38:32 +00:00
|
|
|
static GstPadLinkReturn
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_colorspace_link (GstPad * pad, const GstCaps * caps)
|
2002-03-30 16:16:49 +00:00
|
|
|
{
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
GstStructure *structure;
|
|
|
|
GstPad *otherpad;
|
|
|
|
GstCaps *othercaps;
|
2002-03-30 16:16:49 +00:00
|
|
|
GstColorspace *space;
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
double framerate;
|
|
|
|
GstPadLinkReturn ret;
|
2002-03-30 16:16:49 +00:00
|
|
|
|
|
|
|
space = GST_COLORSPACE (gst_pad_get_parent (pad));
|
|
|
|
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
otherpad = (pad == space->srcpad) ? space->sinkpad : space->srcpad;
|
2002-03-30 16:16:49 +00:00
|
|
|
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
structure = gst_caps_get_structure (caps, 0);
|
2002-03-30 16:16:49 +00:00
|
|
|
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
gst_structure_get_int (structure, "width", &width);
|
|
|
|
gst_structure_get_int (structure, "height", &height);
|
|
|
|
gst_structure_get_double (structure, "framerate", &framerate);
|
2002-03-30 16:16:49 +00:00
|
|
|
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
ret = gst_pad_try_set_caps (otherpad, caps);
|
|
|
|
if (GST_PAD_LINK_SUCCESSFUL (ret)) {
|
|
|
|
/* passthrough */
|
|
|
|
space->passthrough = TRUE;
|
|
|
|
return GST_PAD_LINK_OK;
|
2002-03-30 16:16:49 +00:00
|
|
|
}
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
space->passthrough = FALSE;
|
2002-03-30 16:16:49 +00:00
|
|
|
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
if (gst_pad_is_negotiated (otherpad)) {
|
|
|
|
othercaps = gst_caps_copy (gst_pad_get_negotiated_caps (otherpad));
|
2002-03-30 16:16:49 +00:00
|
|
|
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
gst_caps_set_simple (othercaps,
|
2004-03-14 22:34:33 +00:00
|
|
|
"width", G_TYPE_INT, width,
|
|
|
|
"height", G_TYPE_INT, height,
|
|
|
|
"framerate", G_TYPE_DOUBLE, framerate, NULL);
|
2002-03-30 16:16:49 +00:00
|
|
|
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
ret = gst_pad_try_set_caps (otherpad, othercaps);
|
|
|
|
if (!GST_PAD_LINK_SUCCESSFUL (ret)) {
|
|
|
|
return ret;
|
|
|
|
}
|
2002-03-30 16:16:49 +00:00
|
|
|
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
if (colorspace_setup_converter (space, caps, othercaps)) {
|
2002-03-30 16:16:49 +00:00
|
|
|
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
space->width = width;
|
|
|
|
space->height = height;
|
|
|
|
space->framerate = framerate;
|
|
|
|
} else {
|
|
|
|
return GST_PAD_LINK_REFUSED;
|
2002-03-30 16:16:49 +00:00
|
|
|
}
|
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
return GST_PAD_LINK_OK;
|
2002-03-30 16:16:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GType
|
|
|
|
gst_colorspace_get_type (void)
|
|
|
|
{
|
|
|
|
static GType colorspace_type = 0;
|
|
|
|
|
|
|
|
if (!colorspace_type) {
|
|
|
|
static const GTypeInfo colorspace_info = {
|
2004-03-14 22:34:33 +00:00
|
|
|
sizeof (GstColorspaceClass),
|
|
|
|
(GBaseInitFunc) gst_colorspace_base_init,
|
2002-03-30 16:16:49 +00:00
|
|
|
NULL,
|
2004-03-14 22:34:33 +00:00
|
|
|
(GClassInitFunc) gst_colorspace_class_init,
|
2002-03-30 16:16:49 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2004-03-14 22:34:33 +00:00
|
|
|
sizeof (GstColorspace),
|
2002-03-30 16:16:49 +00:00
|
|
|
0,
|
2004-03-14 22:34:33 +00:00
|
|
|
(GInstanceInitFunc) gst_colorspace_init,
|
2002-03-30 16:16:49 +00:00
|
|
|
};
|
2004-03-14 22:34:33 +00:00
|
|
|
colorspace_type =
|
|
|
|
g_type_register_static (GST_TYPE_ELEMENT, "GstColorspaceLCS",
|
|
|
|
&colorspace_info, 0);
|
2002-03-30 16:16:49 +00:00
|
|
|
}
|
|
|
|
return colorspace_type;
|
|
|
|
}
|
|
|
|
|
2003-11-02 14:26:13 +00:00
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_colorspace_base_init (GstColorspaceClass * klass)
|
2003-11-02 14:26:13 +00:00
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
|
|
|
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
gst_element_class_add_pad_template (element_class,
|
|
|
|
gst_static_pad_template_get (&gst_colorspace_src_template));
|
|
|
|
gst_element_class_add_pad_template (element_class,
|
|
|
|
gst_static_pad_template_get (&gst_colorspace_sink_template));
|
2003-11-02 14:26:13 +00:00
|
|
|
gst_element_class_set_details (element_class, &colorspace_details);
|
|
|
|
}
|
|
|
|
|
2002-03-30 16:16:49 +00:00
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_colorspace_class_init (GstColorspaceClass * klass)
|
2002-03-30 16:16:49 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstElementClass *gstelement_class;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gstelement_class = (GstElementClass *) klass;
|
2002-03-30 16:16:49 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
|
2002-03-30 16:16:49 +00:00
|
|
|
|
|
|
|
gobject_class->set_property = gst_colorspace_set_property;
|
|
|
|
gobject_class->get_property = gst_colorspace_get_property;
|
|
|
|
|
|
|
|
gstelement_class->change_state = gst_colorspace_change_state;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_colorspace_init (GstColorspace * space)
|
2002-03-30 16:16:49 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
space->sinkpad =
|
|
|
|
gst_pad_new_from_template (gst_static_pad_template_get
|
|
|
|
(&gst_colorspace_sink_template), "sink");
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
gst_pad_set_link_function (space->sinkpad, gst_colorspace_link);
|
2002-03-30 16:16:49 +00:00
|
|
|
gst_pad_set_getcaps_function (space->sinkpad, gst_colorspace_getcaps);
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_pad_set_chain_function (space->sinkpad, gst_colorspace_chain);
|
|
|
|
gst_element_add_pad (GST_ELEMENT (space), space->sinkpad);
|
2002-03-30 16:16:49 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
space->srcpad =
|
|
|
|
gst_pad_new_from_template (gst_static_pad_template_get
|
|
|
|
(&gst_colorspace_src_template), "src");
|
|
|
|
gst_element_add_pad (GST_ELEMENT (space), space->srcpad);
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
gst_pad_set_link_function (space->srcpad, gst_colorspace_link);
|
2002-03-30 16:16:49 +00:00
|
|
|
|
|
|
|
space->disabled = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_colorspace_chain (GstPad * pad, GstData * _data)
|
2002-03-30 16:16:49 +00:00
|
|
|
{
|
2003-10-08 16:08:19 +00:00
|
|
|
GstBuffer *buf = GST_BUFFER (_data);
|
2002-03-30 16:16:49 +00:00
|
|
|
GstColorspace *space;
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
GstBuffer *outbuf;
|
2002-03-30 16:16:49 +00:00
|
|
|
|
|
|
|
g_return_if_fail (pad != NULL);
|
|
|
|
g_return_if_fail (GST_IS_PAD (pad));
|
|
|
|
g_return_if_fail (buf != NULL);
|
|
|
|
|
|
|
|
space = GST_COLORSPACE (gst_pad_get_parent (pad));
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2002-03-30 16:16:49 +00:00
|
|
|
g_return_if_fail (space != NULL);
|
|
|
|
g_return_if_fail (GST_IS_COLORSPACE (space));
|
|
|
|
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
if (space->passthrough) {
|
2002-03-30 16:16:49 +00:00
|
|
|
outbuf = buf;
|
2004-03-14 22:34:33 +00:00
|
|
|
} else {
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
unsigned long size;
|
2002-03-30 16:16:49 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
lcs_format_buffer_size (lcs_converter_get_dest_format (space->converter),
|
|
|
|
space->width, space->height, &size);
|
2002-03-30 16:16:49 +00:00
|
|
|
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
outbuf = gst_pad_alloc_buffer (space->srcpad, GST_BUFFER_OFFSET_NONE, size);
|
2002-03-30 16:16:49 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
lcs_convert_auto (space->converter,
|
|
|
|
GST_BUFFER_DATA (buf),
|
|
|
|
GST_BUFFER_DATA (outbuf), space->width, space->height);
|
2002-03-30 16:16:49 +00:00
|
|
|
|
|
|
|
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buf);
|
2002-03-30 16:16:49 +00:00
|
|
|
|
|
|
|
gst_buffer_unref (buf);
|
|
|
|
}
|
2003-10-08 16:08:19 +00:00
|
|
|
gst_pad_push (space->srcpad, GST_DATA (outbuf));
|
2002-03-30 16:16:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GstElementStateReturn
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_colorspace_change_state (GstElement * element)
|
2002-03-30 16:16:49 +00:00
|
|
|
{
|
|
|
|
GstColorspace *space;
|
|
|
|
|
|
|
|
space = GST_COLORSPACE (element);
|
|
|
|
|
|
|
|
switch (GST_STATE_TRANSITION (element)) {
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
case GST_STATE_PAUSED_TO_READY:
|
2002-03-30 16:16:49 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
parent_class->change_state (element);
|
|
|
|
|
|
|
|
return GST_STATE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_colorspace_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
2002-03-30 16:16:49 +00:00
|
|
|
{
|
|
|
|
GstColorspace *space;
|
|
|
|
|
|
|
|
/* it's not null if we got it, but it might not be ours */
|
2004-03-14 22:34:33 +00:00
|
|
|
g_return_if_fail (GST_IS_COLORSPACE (object));
|
|
|
|
space = GST_COLORSPACE (object);
|
2002-03-30 16:16:49 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_colorspace_get_property (GObject * object, guint prop_id, GValue * value,
|
|
|
|
GParamSpec * pspec)
|
2002-03-30 16:16:49 +00:00
|
|
|
{
|
|
|
|
GstColorspace *space;
|
|
|
|
|
|
|
|
/* it's not null if we got it, but it might not be ours */
|
2004-03-14 22:34:33 +00:00
|
|
|
g_return_if_fail (GST_IS_COLORSPACE (object));
|
|
|
|
space = GST_COLORSPACE (object);
|
2002-03-30 16:16:49 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
plugin_init (GstPlugin * plugin)
|
2002-03-30 16:16:49 +00:00
|
|
|
{
|
|
|
|
lcs_init (NULL, NULL);
|
|
|
|
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
return gst_element_register (plugin, "lcscolorspace", GST_RANK_NONE,
|
|
|
|
GST_TYPE_COLORSPACE);
|
2002-03-30 16:16:49 +00:00
|
|
|
}
|
|
|
|
|
ext/lcs/gstcolorspace.c: Merge Ronald's patch (bug #117897) and update for new caps and negotiation. Seems to work, ...
Original commit message from CVS:
* ext/lcs/gstcolorspace.c: (colorspace_find_lcs_format),
(gst_colorspace_caps_get_fourcc), (colorspace_setup_converter),
(gst_colorspace_getcaps), (gst_colorspace_link),
(gst_colorspace_base_init), (gst_colorspace_init),
(gst_colorspace_chain), (gst_colorspace_change_state),
(plugin_init): Merge Ronald's patch (bug #117897) and update
for new caps and negotiation. Seems to work, although it
shows off bugs in lcs.
2004-02-12 02:48:34 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
|
|
|
GST_VERSION_MINOR,
|
|
|
|
"colorspacelcs",
|
|
|
|
"LCS colorspace convertor",
|
|
|
|
plugin_init, VERSION, "LGPL", GST_PACKAGE, GST_ORIGIN)
|