x265 upgrade to 2.5, cinfinity cc lic, keyframe reticle redraw, crikey/titler event...
[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 EDGE_H
24 #define EDGE_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 #define KEY_SEARCH      0
38 #define KEY_SEARCH_ALL  1
39 #define KEY_POINT       2
40 #define KEY_MODES       3
41
42 class CriKeyConfig
43 {
44 public:
45         CriKeyConfig();
46
47         int equivalent(CriKeyConfig &that);
48         void copy_from(CriKeyConfig &that);
49         void interpolate(CriKeyConfig &prev, CriKeyConfig &next,
50                 long prev_frame, long next_frame, long current_frame);
51         void limits();
52         static void set_target(int is_yuv, int color, float *target);
53         static void set_color(int is_yuv, float *target, int &color);
54
55         int color;
56         float threshold;
57         int draw_mode, key_mode;
58         float point_x, point_y;
59         int drag;
60 };
61
62 class CriKeyPackage : public LoadPackage
63 {
64 public:
65         CriKeyPackage() : LoadPackage() {}
66         int y1, y2;
67 };
68
69 class CriKeyEngine : public LoadServer
70 {
71 public:
72         CriKeyEngine(CriKey *plugin, int total_clients, int total_packages)
73          : LoadServer(total_clients, total_packages) { this->plugin = plugin; }
74         ~CriKeyEngine() {}
75
76         void init_packages();
77         LoadPackage* new_package();
78         LoadClient* new_client();
79
80         CriKey *plugin;
81 };
82
83 class CriKeyUnit : public LoadClient
84 {
85 public:
86         CriKeyUnit(CriKeyEngine *server)
87          : LoadClient(server) { this->server = server; }
88         ~CriKeyUnit() {}
89
90         float edge_detect(float *data, float max, int do_max);
91         void process_package(LoadPackage *package);
92         CriKeyEngine *server;
93 };
94
95
96 class CriKey : public PluginVClient
97 {
98 public:
99         CriKey(PluginServer *server);
100         ~CriKey();
101 // required for all realtime plugins
102         PLUGIN_CLASS_MEMBERS2(CriKeyConfig)
103         int is_realtime();
104         void update_gui();
105         void save_data(KeyFrame *keyframe);
106         void read_data(KeyFrame *keyframe);
107         int process_buffer(VFrame *frame, int64_t start_position, double frame_rate);
108         void draw_alpha(VFrame *msk);
109         void draw_mask(VFrame *msk);
110         float diff_uint8(uint8_t *tp);
111         float diff_float(uint8_t *tp);
112         float (CriKey::*diff_pixel)(uint8_t *dp);
113         void min_key(int &ix, int &iy);
114         bool find_key(int &ix, int &iy, float threshold);
115         static void set_target(int is_yuv, int color, float *target) {
116                 CriKeyConfig::set_target(is_yuv, color, target);
117         }
118         static void set_color(int is_yuv, float *target, int &color) {
119                 CriKeyConfig::set_color(is_yuv, target, color);
120         }
121
122         CriKeyEngine *engine;
123         VFrame *src, *dst, *msk;
124         int w, h, color_model, bpp, comp, is_yuv, is_float;
125
126         void get_color(int x, int y);
127         float target[3];
128 };
129
130 #endif