• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GStreamer
2  * Copyright (C) 2018 Matthew Waters <matthew@centricular.com>
3  *
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.
8  *
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.
13  *
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 St, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19 
20 
21 #ifndef __GST_GL_ALPHA_H__
22 #define __GST_GL_ALPHA_H__
23 
24 #include <gst/gst.h>
25 #include <gst/video/video.h>
26 #include <gst/gl/gl.h>
27 
28 G_BEGIN_DECLS
29 
30 #define GST_TYPE_GL_ALPHA \
31   (gst_gl_alpha_get_type())
32 #define GST_GL_ALPHA(obj) \
33   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GL_ALPHA,GstGLAlpha))
34 #define GST_GL_ALPHA_CLASS(klass) \
35   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_GL_ALPHA,GstGLAlphaClass))
36 #define GST_IS_GL_ALPHA(obj) \
37   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GL_ALPHA))
38 #define GST_IS_GL_ALPHA_CLASS(klass) \
39   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GL_ALPHA))
40 
41 typedef struct _GstGLAlpha GstGLAlpha;
42 typedef struct _GstGLAlphaClass GstGLAlphaClass;
43 
44 /**
45  * GstGLAlphaMethod:
46  * @ALPHA_METHOD_SET: Set/adjust alpha channel
47  * @ALPHA_METHOD_GREEN: Chroma Key green
48  * @ALPHA_METHOD_BLUE: Chroma Key blue
49  * @ALPHA_METHOD_CUSTOM: Chroma Key on target_r/g/b
50  */
51 typedef enum
52 {
53   ALPHA_METHOD_SET,
54   ALPHA_METHOD_GREEN,
55   ALPHA_METHOD_BLUE,
56   ALPHA_METHOD_CUSTOM,
57 }
58 GstGLAlphaMethod;
59 
60 /**
61  * GstGLAlpha:
62  *
63  * Opaque data structure.
64  */
65 struct _GstGLAlpha {
66   GstGLFilter videofilter;
67 
68   GstGLShader *alpha_shader;
69   GstGLShader *chroma_key_shader;
70 
71   /* properties */
72   gdouble alpha;
73 
74   guint target_r;
75   guint target_g;
76   guint target_b;
77 
78   GstGLAlphaMethod method;
79 
80   gfloat angle;
81   gfloat noise_level;
82   guint black_sensitivity;
83   guint white_sensitivity;
84 
85   /* precalculated values for chroma keying */
86   gfloat cb, cr;
87   gfloat kg;
88   gfloat accept_angle_tg;
89   gfloat accept_angle_ctg;
90   gfloat one_over_kc;
91   gfloat kfgy_scale;
92   gfloat noise_level2;
93 };
94 
95 struct _GstGLAlphaClass {
96   GstGLFilterClass parent_class;
97 };
98 
99 GType gst_gl_alpha_get_type(void);
100 
101 G_END_DECLS
102 
103 #endif /* __GST_GL_ALPHA_H__ */
104