6747e6449f18eb4e4f9126f7619ef00d87e3e9e1
[goodguy/history.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_SZ }; // enable, x,y, tag
38
39 class CriKeyPoint
40 {
41 public:
42         int t, e;
43         float x, y;
44
45         CriKeyPoint(int t, int e, float x, float y);
46         ~CriKeyPoint();
47 };
48
49 class CriKeyConfig
50 {
51 public:
52         CriKeyConfig();
53         ~CriKeyConfig();
54
55         int equivalent(CriKeyConfig &that);
56         void copy_from(CriKeyConfig &that);
57         void interpolate(CriKeyConfig &prev, CriKeyConfig &next,
58                 long prev_frame, long next_frame, long current_frame);
59         void limits();
60         static void set_target(int is_yuv, int color, float *target);
61         static void set_color(int is_yuv, float *target, int &color);
62
63         ArrayList<CriKeyPoint *> points;
64         int add_point(int t, int e, float x, float y);
65         int add_point();
66         void del_point(int i);
67
68         int color;
69         float threshold;
70         int draw_mode;
71         int drag, selected;
72 };
73
74 class CriKeyPackage : public LoadPackage
75 {
76 public:
77         CriKeyPackage() : LoadPackage() {}
78         int y1, y2;
79 };
80
81 class CriKeyEngine : public LoadServer
82 {
83 public:
84         CriKeyEngine(CriKey *plugin, int total_clients, int total_packages)
85          : LoadServer(total_clients, total_packages) { this->plugin = plugin; }
86         ~CriKeyEngine() {}
87
88         void init_packages();
89         LoadPackage* new_package();
90         LoadClient* new_client();
91
92         CriKey *plugin;
93 };
94
95 class CriKeyUnit : public LoadClient
96 {
97 public:
98         CriKeyUnit(CriKeyEngine *server)
99          : LoadClient(server) { this->server = server; }
100         ~CriKeyUnit() {}
101
102         float edge_detect(float *data, float max, int do_max);
103         void process_package(LoadPackage *package);
104         CriKeyEngine *server;
105 };
106
107
108 class CriKey : public PluginVClient
109 {
110 public:
111         CriKey(PluginServer *server);
112         ~CriKey();
113 // required for all realtime plugins
114         PLUGIN_CLASS_MEMBERS2(CriKeyConfig)
115         int is_realtime();
116         void update_gui();
117         int new_point();
118         void save_data(KeyFrame *keyframe);
119         void read_data(KeyFrame *keyframe);
120         int process_buffer(VFrame *frame, int64_t start_position, double frame_rate);
121         void draw_alpha(VFrame *msk);
122         void draw_mask(VFrame *frm);
123         void draw_point(VFrame *msk, CriKeyPoint *pt);
124         static void set_target(int is_yuv, int color, float *target) {
125                 CriKeyConfig::set_target(is_yuv, color, target);
126         }
127         static void set_color(int is_yuv, float *target, int &color) {
128                 CriKeyConfig::set_color(is_yuv, target, color);
129         }
130
131         CriKeyEngine *engine;
132         VFrame *src, *dst, *msk;
133         int w, h, color_model, bpp, comp, is_yuv, is_float;
134
135         void get_color(int x, int y);
136         float target[3];
137 };
138
139 #endif