videotestsrc: allow per feature registration
[platform/upstream/gstreamer.git] / gst / videotestsrc / gstvideotestsrc.h
1 /* GStreamer
2  * Copyright (C) <2002> David A. Schleef <ds@schleef.org>
3  * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20
21 #ifndef __GST_VIDEO_TEST_SRC_H__
22 #define __GST_VIDEO_TEST_SRC_H__
23
24 #include <gst/gst.h>
25 #include <gst/base/gstpushsrc.h>
26
27 #include <gst/video/gstvideometa.h>
28 #include <gst/video/gstvideopool.h>
29
30 G_BEGIN_DECLS
31
32 #define GST_TYPE_VIDEO_TEST_SRC (gst_video_test_src_get_type())
33 G_DECLARE_FINAL_TYPE (GstVideoTestSrc, gst_video_test_src, GST, VIDEO_TEST_SRC,
34     GstPushSrc)
35
36 /**
37  * GstVideoTestSrcPattern:
38  * @GST_VIDEO_TEST_SRC_SMPTE: A standard SMPTE test pattern
39  * @GST_VIDEO_TEST_SRC_SNOW: Random noise
40  * @GST_VIDEO_TEST_SRC_BLACK: A black image
41  * @GST_VIDEO_TEST_SRC_WHITE: A white image
42  * @GST_VIDEO_TEST_SRC_RED: A red image
43  * @GST_VIDEO_TEST_SRC_GREEN: A green image
44  * @GST_VIDEO_TEST_SRC_BLUE: A blue image
45  * @GST_VIDEO_TEST_SRC_CHECKERS1: Checkers pattern (1px)
46  * @GST_VIDEO_TEST_SRC_CHECKERS2: Checkers pattern (2px)
47  * @GST_VIDEO_TEST_SRC_CHECKERS4: Checkers pattern (4px)
48  * @GST_VIDEO_TEST_SRC_CHECKERS8: Checkers pattern (8px)
49  * @GST_VIDEO_TEST_SRC_CIRCULAR: Circular pattern
50  * @GST_VIDEO_TEST_SRC_BLINK: Alternate between black and white
51  * @GST_VIDEO_TEST_SRC_SMPTE75: SMPTE test pattern (75% color bars)
52  * @GST_VIDEO_TEST_SRC_ZONE_PLATE: Zone plate
53  * @GST_VIDEO_TEST_SRC_GAMUT: Gamut checking pattern
54  * @GST_VIDEO_TEST_SRC_CHROMA_ZONE_PLATE: Chroma zone plate
55  * @GST_VIDEO_TEST_SRC_BALL: Moving ball
56  * @GST_VIDEO_TEST_SRC_SMPTE100: SMPTE test pattern (100% color bars)
57  * @GST_VIDEO_TEST_SRC_SOLID: A solid color, defined by the
58  * #GstVideoTestSrc:foreground-color property
59  * @GST_VIDEO_TEST_SRC_BAR: Bar with foreground color
60  * @GST_VIDEO_TEST_SRC_PINWHEEL: Pinwheel
61  * @GST_VIDEO_TEST_SRC_SPOKES: Spokes
62  * @GST_VIDEO_TEST_SRC_GRADIENT: Gradient
63  * @GST_VIDEO_TEST_SRC_COLORS: All colors
64  *
65  * The test pattern to produce.
66  *
67  * The Gamut pattern creates a checkerboard pattern of colors at the
68  * edge of the YCbCr gamut and nearby colors that are out of gamut.
69  * The pattern is divided into 4 regions: black, white, red, and blue.
70  * After conversion to RGB, the out-of-gamut colors should be converted
71  * to the same value as their in-gamut neighbors.  If the checkerboard
72  * pattern is still visible after conversion, this indicates a faulty
73  * conversion.  Image manipulation, such as adjusting contrast or
74  * brightness, can also cause the pattern to be visible.
75  *
76  * The Zone Plate pattern is based on BBC R&D Report 1978/23, and can
77  * be used to test spatial frequency response of a system.  This
78  * pattern generator is controlled by the xoffset and yoffset parameters
79  * and also by all the parameters starting with 'k'.  The default
80  * parameters produce a grey pattern.  Try 'videotestsrc
81  * pattern=zone-plate kx2=20 ky2=20 kt=1' to produce something
82  * interesting.
83  */
84 typedef enum {
85   GST_VIDEO_TEST_SRC_SMPTE,
86   GST_VIDEO_TEST_SRC_SNOW,
87   GST_VIDEO_TEST_SRC_BLACK,
88   GST_VIDEO_TEST_SRC_WHITE,
89   GST_VIDEO_TEST_SRC_RED,
90   GST_VIDEO_TEST_SRC_GREEN,
91   GST_VIDEO_TEST_SRC_BLUE,
92   GST_VIDEO_TEST_SRC_CHECKERS1,
93   GST_VIDEO_TEST_SRC_CHECKERS2,
94   GST_VIDEO_TEST_SRC_CHECKERS4,
95   GST_VIDEO_TEST_SRC_CHECKERS8,
96   GST_VIDEO_TEST_SRC_CIRCULAR,
97   GST_VIDEO_TEST_SRC_BLINK,
98   GST_VIDEO_TEST_SRC_SMPTE75,
99   GST_VIDEO_TEST_SRC_ZONE_PLATE,
100   GST_VIDEO_TEST_SRC_GAMUT,
101   GST_VIDEO_TEST_SRC_CHROMA_ZONE_PLATE,
102   GST_VIDEO_TEST_SRC_SOLID,
103   GST_VIDEO_TEST_SRC_BALL,
104   GST_VIDEO_TEST_SRC_SMPTE100,
105   GST_VIDEO_TEST_SRC_BAR,
106   GST_VIDEO_TEST_SRC_PINWHEEL,
107   GST_VIDEO_TEST_SRC_SPOKES,
108   GST_VIDEO_TEST_SRC_GRADIENT,
109   GST_VIDEO_TEST_SRC_COLORS
110 } GstVideoTestSrcPattern;
111
112 typedef enum {
113   GST_VIDEO_TEST_SRC_FRAMES,
114   GST_VIDEO_TEST_SRC_WALL_TIME,
115   GST_VIDEO_TEST_SRC_RUNNING_TIME
116 } GstVideoTestSrcAnimationMode;
117
118
119 typedef enum {
120   GST_VIDEO_TEST_SRC_WAVY,
121   GST_VIDEO_TEST_SRC_SWEEP,
122   GST_VIDEO_TEST_SRC_HSWEEP
123 } GstVideoTestSrcMotionType;
124
125 /**
126  * GstVideoTestSrc:
127  *
128  * Opaque data structure.
129  */
130 struct _GstVideoTestSrc {
131   GstPushSrc element;
132
133   /*< private >*/
134
135   /* type of output */
136   GstVideoTestSrcPattern pattern_type;
137
138   /* video state */
139   GstVideoInfo info; /* protected by the object or stream lock */
140   GstVideoChromaResample *subsample;
141   gboolean bayer;
142   gint x_invert;
143   gint y_invert;
144
145   /* private */
146   /* FIXME 2.0: Change type to GstClockTime */
147   gint64 timestamp_offset;              /* base offset */
148
149   /* running time and frames for current caps */
150   GstClockTime running_time;            /* total running time */
151   gint64 n_frames;                      /* total frames sent */
152   gboolean reverse;
153
154   /* previous caps running time and frames */
155   GstClockTime accum_rtime;              /* accumulated running_time */
156   gint64 accum_frames;                  /* accumulated frames */
157
158   /* zoneplate */
159   gint k0;
160   gint kx;
161   gint ky;
162   gint kt;
163   gint kxt;
164   gint kyt;
165   gint kxy;
166   gint kx2;
167   gint ky2;
168   gint kt2;
169   gint xoffset;
170   gint yoffset;
171
172   /* solid color */
173   guint foreground_color;
174   guint background_color;
175
176   /* moving color bars */
177   gint horizontal_offset;
178   gint horizontal_speed;
179
180   /* smpte & snow */
181   guint random_state;
182
183   /* Ball motion */
184   GstVideoTestSrcAnimationMode animation_mode;
185   GstVideoTestSrcMotionType motion_type;
186   gboolean flip;
187
188   void (*make_image) (GstVideoTestSrc *v, GstClockTime pts, GstVideoFrame *frame);
189
190   /* temporary AYUV/ARGB scanline */
191   guint8 *tmpline_u8;
192   guint8 *tmpline;
193   guint8 *tmpline2;
194   guint16 *tmpline_u16;
195
196   guint n_lines;
197   gint offset;
198   gpointer *lines;
199 };
200
201 GST_ELEMENT_REGISTER_DECLARE (videotestsrc);
202
203 G_END_DECLS
204
205 #endif /* __GST_VIDEO_TEST_SRC_H__ */