1
/* GStreamer video utils
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.
22
* @short_description: Useful boilerplate for video filters
25
#ifndef __GST_VIDEO_UTILS_H__
26
#define __GST_VIDEO_UTILS_H__
32
* GST_VIDEO_FILTER_SET_CAPS_BOILERPLATE_FULL:
33
* @type: the name of the type struct
34
* @type_as_function: the prefix for the functions
35
* @hook_function: a function with #GstBaseTransform set_caps signature
36
* that can extract custom additional info or accept/reject caps
38
* Define a typical set_caps function for a video filter,
39
* allowing for additional custom verification and initialization.
41
#define GST_VIDEO_FILTER_SET_CAPS_BOILERPLATE_FULL(type, type_as_function, hook_function) \
43
type_as_function ## _set_caps (GstBaseTransform * btrans, GstCaps * incaps, \
46
type *filter = (type *) (btrans); \
47
GstStructure *structure; \
48
gboolean ret = FALSE; \
50
structure = gst_caps_get_structure (incaps, 0); \
52
if (gst_structure_get_int (structure, "width", &filter->width) && \
53
gst_structure_get_int (structure, "height", &filter->height)) { \
54
ret = hook_function (filter, incaps, outcaps); \
61
#define __GST_NO_HOOK(filter, incaps, outcaps) TRUE
64
* GST_VIDEO_FILTER_SET_CAPS_BOILERPLATE:
65
* @type: the name of the type struct
66
* @type_as_function: the prefix for the functions
68
* Define a typical set_caps function for a video filter.
70
#define GST_VIDEO_FILTER_SET_CAPS_BOILERPLATE(type, type_as_function) \
71
GST_VIDEO_FILTER_SET_CAPS_BOILERPLATE_FULL(type, type_as_function, \
76
* GST_VIDEO_FILTER_GET_UNIT_SIZE_BOILERPLATE:
77
* @type_as_function: the prefix for the functions
79
* Define a typical get_unit_size function for a video filter that provides
80
* proper unit size for x-raw-rgb and some standard x-raw-yuv
81
* colorspaces (YUY2, YUYV, YVYU, IYUV, I420, YV12).
83
#define GST_VIDEO_FILTER_GET_UNIT_SIZE_BOILERPLATE(type_as_function) \
85
type_as_function ## _get_unit_size (GstBaseTransform * btrans, GstCaps * caps, \
88
GstStructure *structure; \
89
gboolean ret = FALSE; \
92
structure = gst_caps_get_structure (caps, 0); \
94
if (gst_structure_get_int (structure, "width", &width) && \
95
gst_structure_get_int (structure, "height", &height)) { \
96
if (gst_structure_has_name (structure, "video/x-raw-rgb")) { \
99
if (gst_structure_get_int (structure, "bpp", &bpp)) { \
101
*size = width * height * bpp / 8; \
107
if (gst_structure_get_fourcc (structure, "format", &fourcc)) { \
110
case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'): \
111
case GST_MAKE_FOURCC ('Y', 'U', 'Y', 'V'): \
112
case GST_MAKE_FOURCC ('Y', 'V', 'Y', 'U'): \
113
*size = width * height * 2; \
115
case GST_MAKE_FOURCC ('I', 'Y', 'U', 'V'): \
116
case GST_MAKE_FOURCC ('I', '4', '2', '0'): \
117
case GST_MAKE_FOURCC ('Y', 'V', '1', '2'): \
119
*size = GST_VIDEO_I420_SIZE (width, height); \
123
GST_DEBUG_OBJECT (btrans, "our frame size is %d bytes (%dx%d)", *size, \
132
#endif /* __GST_VIDEO_UTILS_H__ */