no longer need ffmpeg patch0 which was for Termux
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / crikey / crikey.h
1 /*
2  * CINELERRA
3  * Copyright (C) 1997-2014 Adam Williams <broadcast at earthling dot net>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program 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
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  *
19  */
20
21
22
23 #ifndef __CRIKEY_H__
24 #define __CRIKEY_H__
25
26 #include "loadbalance.h"
27 #include "pluginvclient.h"
28
29 class CriKeyEngine;
30 class CriKey;
31
32 #define DRAW_ALPHA      0
33 #define DRAW_EDGE       1
34 #define DRAW_MASK       2
35 #define DRAW_MODES      3
36
37 enum { PT_E, PT_X, PT_Y, PT_T, PT_TAG, PT_SZ }; // enable, x,y,threshold, tag
38
39 class CriKeyPoint
40 {
41 public:
42         int tag, e;
43         float x, y, t;
44
45         CriKeyPoint(int tag, int e, float x, float y, float t);
46         ~CriKeyPoint();
47         void update_parameter(CriKeyPoint *prev, CriKeyPoint *src);
48 };
49 class CriKeyPoints : public ArrayList<CriKeyPoint *>
50 {
51 public:
52         CriKeyPoints() {}
53         ~CriKeyPoints() { remove_all_objects(); }
54 };
55
56 class CriKeyConfig
57 {
58 public:
59         CriKeyConfig();
60         ~CriKeyConfig();
61
62         void save_data(KeyFrame *keyframe);
63         void read_data(KeyFrame *keyframe);
64         int equivalent(CriKeyConfig &that);
65         void copy_from(CriKeyConfig &that);
66         void interpolate(CriKeyConfig &prev, CriKeyConfig &next,
67                 long prev_frame, long next_frame, long current_frame);
68         void limits();
69
70         CriKeyPoints points;
71         int add_point(int tag, int e, float x, float y, float t);
72         int add_point();
73         void del_point(int i);
74
75         float threshold;
76         int draw_mode;
77 };
78
79 class CriKeyPackage : public LoadPackage
80 {
81 public:
82         CriKeyPackage() : LoadPackage() {}
83         int y1, y2;
84 };
85
86 class CriKeyEngine : public LoadServer
87 {
88 public:
89         CriKeyEngine(CriKey *plugin, int total_clients, int total_packages)
90          : LoadServer(total_clients, total_packages) { this->plugin = plugin; }
91         ~CriKeyEngine() {}
92
93         void init_packages();
94         LoadPackage* new_package();
95         LoadClient* new_client();
96
97         CriKey *plugin;
98         int set_color(int x, int y, float t);
99         float color[3], threshold;
100 };
101
102 class CriKeyUnit : public LoadClient
103 {
104 public:
105         CriKeyUnit(CriKeyEngine *server)
106          : LoadClient(server) { this->server = server; }
107         ~CriKeyUnit() {}
108
109         float edge_detect(float *data, float max, int do_max);
110         void process_package(LoadPackage *package);
111         CriKeyEngine *server;
112 };
113
114
115 class CriKey : public PluginVClient
116 {
117 public:
118         CriKey(PluginServer *server);
119         ~CriKey();
120 // required for all realtime plugins
121         PLUGIN_CLASS_MEMBERS2(CriKeyConfig)
122         int is_realtime();
123         void render_gui(void *data);
124         int is_dragging();
125         int new_point();
126         void update_gui();
127         int set_target(float *color, int x, int y);
128         void save_data(KeyFrame *keyframe);
129         void read_data(KeyFrame *keyframe);
130         int process_buffer(VFrame *frame, int64_t start_position, double frame_rate);
131         void draw_alpha(VFrame *msk);
132         void draw_edge(VFrame *frm);
133         void draw_mask(VFrame *frm);
134         void draw_point(VFrame *msk, CriKeyPoint *pt);
135         void span_keyframes(KeyFrame *src, int64_t start, int64_t end);
136         void update_parameter(CriKeyConfig &prev_config, CriKeyConfig &src_config,
137                 KeyFrame *keyframe);
138
139         CriKeyEngine *engine;
140         VFrame *src, *edg, *msk;
141         int w, h, color_model, bpp, comp;
142         int is_yuv, is_float;
143         int drag, selected;
144 };
145
146 #endif