2
* Copyright (C) 2006 Mark Nauwelaerts <mnauw@users.sourceforge.net>
4
* This library is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Library General Public
6
* License as published by the Free Software Foundation; either
7
* version 2 of the License, or (at your option) any later version.
9
* This library is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Library General Public License for more details.
14
* You should have received a copy of the GNU Library General Public
15
* License along with this library; if not, write to the
16
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
* Boston, MA 02110-1307, USA.
21
* SECTION:element-rbswap
25
* Swaps red (Cr) and blue (Cb) in video frames.
26
* This should rarely be needed, but may be required in unusual cases,
27
* e.g. if people have blue faces.
29
* <title>History</title>
33
* It is akin to transcode's rgbswap [Thomas Oestreich]
36
* Similar basic operation also available in e.g. mplayer's swapuv, etc
49
#include "plugin-tc.h"
54
#define GST_TYPE_RB_SWAP \
55
(gst_rb_swap_get_type())
56
#define GST_RB_SWAP(obj) \
57
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_RB_SWAP,GstRbSwap))
58
#define GST_RB_SWAP_CLASS(klass) \
59
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_RB_SWAP,GstRbSwapClass))
60
#define GST_IS_RB_SWAP(obj) \
61
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RB_SWAP))
62
#define GST_IS_RB_SWAP_CLASS(klass) \
63
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RB_SWAP))
66
typedef struct _GstRbSwap GstRbSwap;
67
typedef struct _GstRbSwapClass GstRbSwapClass;
71
GstVideoFilter videofilter;
80
struct _GstRbSwapClass
82
GstVideoFilterClass parent_class;
85
GST_DEBUG_CATEGORY_STATIC (rb_swap_debug);
86
#define GST_CAT_DEFAULT rb_swap_debug
89
/* signals and args */
103
#define DEFAULT_DELAY 0
105
static GstElementDetails rb_swap_details =
106
GST_ELEMENT_DETAILS ("Rbswap",
107
"Filter/Effect/Video",
108
"Swap red and blue components",
109
"Mark Nauwelaerts <mnauw@users.sourceforge.net>");
111
static GstStaticPadTemplate gst_rb_swap_src_template =
112
GST_STATIC_PAD_TEMPLATE (GST_BASE_TRANSFORM_SRC_NAME,
115
GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("{ IYUV, I420, YV12 }"))
118
static GstStaticPadTemplate gst_rb_swap_sink_template =
119
GST_STATIC_PAD_TEMPLATE (GST_BASE_TRANSFORM_SINK_NAME,
122
GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("{ IYUV, I420, YV12 }"))
126
static GstCaps* gst_rb_swap_transform_caps (GstBaseTransform * trans,
127
GstPadDirection direction, GstCaps * caps);
128
static GstFlowReturn gst_rb_swap_transform_ip (GstBaseTransform * btrans,
131
static void gst_rb_swap_set_property (GObject * object, guint prop_id,
132
const GValue * value, GParamSpec * pspec);
133
static void gst_rb_swap_get_property (GObject * object, guint prop_id,
134
GValue * value, GParamSpec * pspec);
136
GST_BOILERPLATE (GstRbSwap, gst_rb_swap, GstVideoFilter, GST_TYPE_VIDEO_FILTER);
138
GST_VIDEO_FILTER_GET_UNIT_SIZE_BOILERPLATE (gst_rb_swap);
141
gst_rb_swap_base_init (gpointer g_class)
143
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
145
gst_element_class_set_details (element_class, &rb_swap_details);
147
gst_element_class_add_pad_template (element_class,
148
gst_static_pad_template_get (&gst_rb_swap_sink_template));
149
gst_element_class_add_pad_template (element_class,
150
gst_static_pad_template_get (&gst_rb_swap_src_template));
154
gst_rb_swap_class_init (GstRbSwapClass * g_class)
156
GObjectClass *gobject_class;
157
GstBaseTransformClass *trans_class;
159
gobject_class = G_OBJECT_CLASS (g_class);
160
trans_class = GST_BASE_TRANSFORM_CLASS (g_class);
162
GST_DEBUG_CATEGORY_INIT (rb_swap_debug, "rbswap", 0, "rbswap");
164
gobject_class->set_property = gst_rb_swap_set_property;
165
gobject_class->get_property = gst_rb_swap_get_property;
167
trans_class->get_unit_size = GST_DEBUG_FUNCPTR (gst_rb_swap_get_unit_size);
168
trans_class->transform_caps = GST_DEBUG_FUNCPTR (gst_rb_swap_transform_caps);
169
/* dummy seems needed */
170
trans_class->transform_ip = GST_DEBUG_FUNCPTR (gst_rb_swap_transform_ip);
174
gst_rb_swap_init (GstRbSwap * filter, GstRbSwapClass * g_class)
180
gst_rb_swap_transform_caps (GstBaseTransform * trans,
181
GstPadDirection direction, GstCaps * caps)
184
GstStructure *structure;
187
GST_DEBUG_OBJECT (trans, "receiving caps: %" GST_PTR_FORMAT, caps);
189
ret = gst_caps_copy (caps);
191
/* this function is always called with a simple caps */
192
g_return_val_if_fail (GST_CAPS_IS_SIMPLE (ret), NULL);
194
structure = gst_caps_get_structure (ret, 0);
196
gst_structure_get_fourcc (structure, "format", &fourcc);
198
case GST_MAKE_FOURCC ('I', '4', '2', '0'):
199
case GST_MAKE_FOURCC ('I', 'Y', 'U', 'V'):
201
fourcc = GST_MAKE_FOURCC ('Y', 'V', '1', '2');
203
case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
205
fourcc = GST_MAKE_FOURCC ('I', '4', '2', '0');
208
g_return_val_if_reached (NULL);
212
gst_structure_set (structure, "format", GST_TYPE_FOURCC, fourcc, NULL);
214
GST_DEBUG_OBJECT (trans, "returning caps: %" GST_PTR_FORMAT, ret);
220
gst_rb_swap_transform_ip (GstBaseTransform * btrans, GstBuffer * in)
226
gst_rb_swap_set_property (GObject * object, guint prop_id,
227
const GValue * value, GParamSpec * pspec)
231
g_return_if_fail (GST_IS_RB_SWAP (object));
232
src = GST_RB_SWAP (object);
236
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
242
gst_rb_swap_get_property (GObject * object, guint prop_id, GValue * value,
247
g_return_if_fail (GST_IS_RB_SWAP (object));
248
src = GST_RB_SWAP (object);
252
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);