1 /* GStreamer
2  * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3  * Copyright (C) <2007> Wim Taymans <wim.taymans@collabora.co.uk>
4  * Copyright (C) <2007> Edward Hervey <edward.hervey@collabora.co.uk>
5  * Copyright (C) <2007> Jan Schmidt <thaytan@noraisin.net>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 #ifndef __GST_ALPHA_H__
24 #define __GST_ALPHA_H__
25 
26 #include <gst/gst.h>
27 #include <gst/video/video.h>
28 #include <gst/video/gstvideofilter.h>
29 
30 G_BEGIN_DECLS
31 
32 #define GST_TYPE_ALPHA \
33   (gst_alpha_get_type())
34 #define GST_ALPHA(obj) \
35   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ALPHA,GstAlpha))
36 #define GST_ALPHA_CLASS(klass) \
37   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ALPHA,GstAlphaClass))
38 #define GST_IS_ALPHA(obj) \
39   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ALPHA))
40 #define GST_IS_ALPHA_CLASS(klass) \
41   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ALPHA))
42 
43 typedef struct _GstAlpha GstAlpha;
44 typedef struct _GstAlphaClass GstAlphaClass;
45 
46 /**
47  * GstAlphaMethod:
48  * @ALPHA_METHOD_SET: Set/adjust alpha channel
49  * @ALPHA_METHOD_GREEN: Chroma Key green
50  * @ALPHA_METHOD_BLUE: Chroma Key blue
51  * @ALPHA_METHOD_CUSTOM: Chroma Key on target_r/g/b
52  */
53 typedef enum
54 {
55   ALPHA_METHOD_SET,
56   ALPHA_METHOD_GREEN,
57   ALPHA_METHOD_BLUE,
58   ALPHA_METHOD_CUSTOM,
59 }
60 GstAlphaMethod;
61 
62 GST_DEBUG_CATEGORY_STATIC (gst_alpha_debug);
63 #define GST_CAT_DEFAULT gst_alpha_debug
64 
65 struct _GstAlpha
66 {
67   GstVideoFilter parent;
68 
69   /* <private> */
70 
71   /* caps */
72   GMutex lock;
73 
74   gboolean in_sdtv, out_sdtv;
75 
76   /* properties */
77   gdouble alpha;
78 
79   guint target_r;
80   guint target_g;
81   guint target_b;
82 
83   GstAlphaMethod method;
84 
85   gfloat angle;
86   gfloat noise_level;
87   guint black_sensitivity;
88   guint white_sensitivity;
89 
90   gboolean prefer_passthrough;
91 
92   /* processing function */
93   void (*process) (const GstVideoFrame *in_frame, GstVideoFrame *out_frame, GstAlpha *alpha);
94 
95   /* precalculated values for chroma keying */
96   gint8 cb, cr;
97   gint8 kg;
98   guint8 accept_angle_tg;
99   guint8 accept_angle_ctg;
100   guint8 one_over_kc;
101   guint8 kfgy_scale;
102   guint noise_level2;
103 };
104 
105 struct _GstAlphaClass
106 {
107   GstVideoFilterClass parent_class;
108 };
109 
110 GType gst_alpha_get_type (void);
111 
112 G_END_DECLS
113 
114 #endif /* __GST_ALPHA_H__ */
115