3 * Copyright (C) 1997-2014 Adam Williams <broadcast at earthling dot net>
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.
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.
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
26 #include "loadbalance.h"
27 #include "pluginvclient.h"
38 #define KEY_SEARCH_ALL 1
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);
52 static void set_target(int is_yuv, int color, float *target);
53 static void set_color(int is_yuv, float *target, int &color);
57 int draw_mode, key_mode;
58 float point_x, point_y;
62 class CriKeyPackage : public LoadPackage
65 CriKeyPackage() : LoadPackage() {}
69 class CriKeyEngine : public LoadServer
72 CriKeyEngine(CriKey *plugin, int total_clients, int total_packages)
73 : LoadServer(total_clients, total_packages) { this->plugin = plugin; }
77 LoadPackage* new_package();
78 LoadClient* new_client();
83 class CriKeyUnit : public LoadClient
86 CriKeyUnit(CriKeyEngine *server)
87 : LoadClient(server) { this->server = server; }
90 float edge_detect(float *data, float max, int do_max);
91 void process_package(LoadPackage *package);
96 class CriKey : public PluginVClient
99 CriKey(PluginServer *server);
101 // required for all realtime plugins
102 PLUGIN_CLASS_MEMBERS2(CriKeyConfig)
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);
118 static void set_color(int is_yuv, float *target, int &color) {
119 CriKeyConfig::set_color(is_yuv, target, color);
122 CriKeyEngine *engine;
123 VFrame *src, *dst, *msk;
124 int w, h, color_model, bpp, comp, is_yuv, is_float;
126 void get_color(int x, int y);