1 /* Generic video compositor plugin
2 * Copyright (C) 2008 Wim Taymans <wim@fluendo.com>
3 * Copyright (C) 2010 Sebastian Dröge <sebastian.droege@collabora.co.uk>
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.
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.
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.
21 #ifndef __GST_COMPOSITOR_H__
22 #define __GST_COMPOSITOR_H__
25 #include <gst/video/video.h>
26 #include <gst/video/gstvideoaggregator.h>
27 #include <gst/base/base.h>
33 #define GST_TYPE_COMPOSITOR (gst_compositor_get_type())
34 G_DECLARE_FINAL_TYPE (GstCompositor, gst_compositor, GST, COMPOSITOR,
37 #define GST_TYPE_COMPOSITOR_PAD (gst_compositor_pad_get_type())
38 G_DECLARE_FINAL_TYPE (GstCompositorPad, gst_compositor_pad, GST, COMPOSITOR_PAD,
39 GstVideoAggregatorParallelConvertPad)
42 * GstCompositorBackground:
43 * @COMPOSITOR_BACKGROUND_CHECKER: checker pattern background
44 * @COMPOSITOR_BACKGROUND_BLACK: solid color black background
45 * @COMPOSITOR_BACKGROUND_WHITE: solid color white background
46 * @COMPOSITOR_BACKGROUND_TRANSPARENT: background is left transparent and layers are composited using "A OVER B" composition rules. This is only applicable to AYUV and ARGB (and variants) as it preserves the alpha channel and allows for further mixing.
48 * The different backgrounds compositor can blend over.
52 COMPOSITOR_BACKGROUND_CHECKER,
53 COMPOSITOR_BACKGROUND_BLACK,
54 COMPOSITOR_BACKGROUND_WHITE,
55 COMPOSITOR_BACKGROUND_TRANSPARENT,
56 } GstCompositorBackground;
59 * GstCompositorOperator:
60 * @COMPOSITOR_OPERATOR_SOURCE: Copy the source over the destination,
61 * without the destination pixels.
62 * @COMPOSITOR_OPERATOR_OVER: Blend the source over the destination.
63 * @COMPOSITOR_OPERATOR_ADD: Similar to over but add the source and
64 * destination alpha. Requires output with alpha
67 * The different blending operators that can be used by compositor.
69 * See https://www.cairographics.org/operators/ for some explanation and
75 COMPOSITOR_OPERATOR_SOURCE,
76 COMPOSITOR_OPERATOR_OVER,
77 COMPOSITOR_OPERATOR_ADD,
78 } GstCompositorOperator;
81 * GstCompositorSizingPolicy:
82 * @COMPOSITOR_SIZING_POLICY_NONE: Scaling image without padding
83 * @COMPOSITOR_SIZING_POLICY_KEEP_ASPECT_RATIO: Scaling image to fit destination
84 * resolution with preserving aspect ratio. Resulting image will be centered
85 * in the configured destination rectangle and it might have padding area
86 * if aspect ratio of destination rectangle is different from that of
93 COMPOSITOR_SIZING_POLICY_NONE,
94 COMPOSITOR_SIZING_POLICY_KEEP_ASPECT_RATIO,
95 } GstCompositorSizingPolicy;
97 /* copied from video-converter.c */
98 typedef void (*GstParallelizedTaskFunc) (gpointer user_data);
100 typedef struct _GstParallelizedTaskRunner GstParallelizedTaskRunner;
102 struct _GstParallelizedTaskRunner
108 GstQueueArray *tasks;
110 GstParallelizedTaskFunc func;
116 gboolean async_tasks;
122 * The opaque #GstCompositor structure.
124 struct _GstCompositor
126 GstVideoAggregator videoaggregator;
127 GstCompositorBackground background;
129 /* Property to allow overriding the default behaviour of
130 * pad.width == 0 or pad.height == 0: by default it means the input
131 * image should be left unscaled in that dimension, but it may be desirable
132 * to have it simply mean the image should not be composited into the output
133 * image, for example when animating the property.
135 gboolean zero_size_is_unscaled;
137 /* The 'blend' compositing function does not preserve the alpha value of the
138 * background, while 'overlay' does; i.e., COMPOSITOR_OPERATOR_ADD is the
139 * same as COMPOSITOR_OPERATOR_OVER when using the 'blend' BlendFunction. */
140 BlendFunction blend, overlay;
141 FillCheckerFunction fill_checker;
142 FillColorFunction fill_color;
144 GstParallelizedTaskRunner *blend_runner;
150 * The opaque #GstCompositorPad structure.
152 struct _GstCompositorPad
154 GstVideoAggregatorParallelConvertPad parent;
160 GstCompositorSizingPolicy sizing_policy;
162 GstCompositorOperator op;
164 /* offset values for xpos and ypos used when sizing-policy is equal to
165 * keep-aspect-ratio */
170 GST_ELEMENT_REGISTER_DECLARE (compositor);
173 #endif /* __GST_COMPOSITOR_H__ */