add x10tv ati remote rework, android remote rework, wintv remote tweaks
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / maskengine.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #ifndef MASKENGINE_H
23 #define MASKENGINE_H
24
25
26 #include "condition.inc"
27 #include "loadbalance.h"
28 #include "maskautos.inc"
29 #include "maskauto.inc"
30 #include "mutex.inc"
31 #include "vframe.inc"
32
33 typedef uint16_t temp_t; // temp is A16
34
35 class MaskEngine;
36
37 // Values for step
38 enum
39 {
40         DO_MASK,
41         DO_FEATHER_X,
42         DO_FEATHER_Y,
43         DO_MASK_BLEND,
44         DO_APPLY,
45 };
46
47
48 class MaskPackage : public LoadPackage
49 {
50 public:
51         MaskPackage();
52         ~MaskPackage();
53
54         int start_x, end_x;
55         int start_y, end_y;
56 };
57
58 class MaskUnit : public LoadClient
59 {
60 public:
61         MaskUnit(MaskEngine *engine);
62         ~MaskUnit();
63
64         void clear_mask(VFrame *msk, int a);
65         void draw_line(int x1, int y1, int x2, int y2);
66         void draw_fill();
67         void draw_feather(int ix1,int iy1, int ix2,int iy2);
68         void draw_edge(int ix, int iy);
69         void draw_filled_polygon(MaskEdge &edge);
70         void feather_x(VFrame *in, VFrame *out);
71         void feather_y(VFrame *in, VFrame *out);
72         void mask_blend(VFrame *in, VFrame *mask, float r, float v);
73         void apply_mask_alpha(VFrame *output, VFrame *mask);
74
75         void process_package(LoadPackage *package);
76
77         MaskEngine *engine;
78         MaskPackage *pkg;
79         int mask_model;
80         int bc, fc;
81         int start_x, end_x;
82         int start_y, end_y;
83 };
84
85 class MaskEngine : public LoadServer
86 {
87 public:
88         MaskEngine(int cpus);
89         ~MaskEngine();
90
91         void do_mask(VFrame *output,
92 // Position relative to project, compensated for playback direction
93                 int64_t start_position_project,
94                 MaskAutos *keyframe_set,
95                 MaskAuto *keyframe,
96                 MaskAuto *default_auto);
97         int points_equivalent(MaskPoints *new_points,
98                 MaskPoints *points);
99         void clear_mask(VFrame *msk, int a);
100         void draw_point_spot(float r);
101
102         void delete_packages();
103         void init_packages();
104         LoadClient* new_client();
105         LoadPackage* new_package();
106
107         VFrame *output;
108         VFrame *mask, *in, *out;
109         MaskEdges edges;
110         MaskPointSets point_sets;
111         ArrayList<float> faders;
112         ArrayList<float> feathers;
113         int step, total_submasks;
114         int recalculate;
115         MaskEdge *edge;
116         float r, v;
117         float *psf;
118         int psz;
119 };
120
121
122
123 #endif