group selection rework, rm inv title clr, add titlebar alpha textbox, default proxy...
[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
34 class MaskEngine;
35
36 // Values for step
37 enum
38 {
39         DO_MASK,
40         DO_X_FEATHER,
41         DO_Y_FEATHER,
42         DO_APPLY
43 };
44
45 class MaskPackage : public LoadPackage
46 {
47 public:
48         MaskPackage();
49         ~MaskPackage();
50
51         int start_x, end_x, start_y, end_y;
52 };
53
54 class MaskUnit : public LoadClient
55 {
56 public:
57         MaskUnit(MaskEngine *engine);
58         ~MaskUnit();
59
60         void process_package(LoadPackage *package);
61         void draw_line_clamped(VFrame *frame,
62                 int x1, int y1, int x2, int y2, unsigned char value);
63         void do_feather(VFrame *output, VFrame *input,
64                 double feather, int start_y, int end_y, int start_x, int end_x);
65         void blur_strip(double *val_p, double *val_m,
66                 double *dst, double *src, int size, int max);
67
68         double n_p[5], n_m[5];
69         double d_p[5], d_m[5];
70         double bd_p[5], bd_m[5];
71
72         MaskEngine *engine;
73         VFrame *temp;
74 };
75
76
77 class MaskEngine : public LoadServer
78 {
79 public:
80         MaskEngine(int cpus);
81         ~MaskEngine();
82
83
84         void do_mask(VFrame *output,
85 // Position relative to project, compensated for playback direction
86                 int64_t start_position_project,
87                 MaskAutos *keyframe_set,
88                 MaskAuto *keyframe,
89                 MaskAuto *default_auto);
90         int points_equivalent(ArrayList<MaskPoint*> *new_points,
91                 ArrayList<MaskPoint*> *points);
92
93         void delete_packages();
94         void init_packages();
95         LoadClient* new_client();
96         LoadPackage* new_package();
97
98         VFrame *output;
99 // State of last mask
100         VFrame *mask;
101 // Temporary for feathering
102         VFrame *temp_mask;
103         ArrayList<ArrayList<MaskPoint*>*> point_sets;
104         int mode;
105         int step;
106         double feather;
107         int recalculate;
108         int value;
109 };
110
111
112
113 #endif