4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
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.
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.
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
26 #include "histogramengine.inc"
27 #include "loadbalance.h"
28 #include "thresholdwindow.inc"
30 #include "pluginvclient.h"
33 class ThresholdEngine;
36 // Color components are in range [0, 255].
40 RGBA(); // Initialize to transparent black.
41 RGBA(int r, int g, int b, int a);
42 void set(int r, int g, int b, int a);
43 void set(int rgb, int alpha); // red in byte 2, green in byte 1, blue in byte 0.
44 int getRGB() const; // Encode red in byte 2, green in byte 1, blue in byte 0.
46 // Set R, G, B, A properties from this RGBA.
47 void set_property(XMLTag & tag, const char * prefix) const;
49 // Load R, G, B, A properties and return in an RGBA.
50 // Use values in this RGBA as default.
51 RGBA get_property(XMLTag & tag, const char * prefix) const;
56 bool operator==(const RGBA & a, const RGBA & b);
58 // General purpose scale function.
60 T interpolate(const T & prev, const double & prev_scale, const T & next, const double & next_scale);
62 // Specialization for RGBA class.
64 RGBA interpolate(const RGBA & prev_color, const double & prev_scale, const RGBA &next_color, const double & next_scale);
72 int equivalent(ThresholdConfig &that);
73 void copy_from(ThresholdConfig &that);
74 void interpolate(ThresholdConfig &prev,
75 ThresholdConfig &next,
78 int64_t current_frame);
92 class ThresholdMain : public PluginVClient
95 ThresholdMain(PluginServer *server);
98 int process_buffer(VFrame *frame,
99 int64_t start_position,
102 void save_data(KeyFrame *keyframe);
103 void read_data(KeyFrame *keyframe);
105 void render_gui(void *data);
106 void calculate_histogram(VFrame *frame);
109 PLUGIN_CLASS_MEMBERS(ThresholdConfig);
110 HistogramEngine *engine;
111 ThresholdEngine *threshold_engine;
119 class ThresholdPackage : public LoadPackage
128 class ThresholdUnit : public LoadClient
131 ThresholdUnit(ThresholdEngine *server);
132 void process_package(LoadPackage *package);
134 ThresholdEngine *server;
136 template<typename TYPE, int COMPONENTS, bool USE_YUV>
137 void render_data(LoadPackage *package);
141 class ThresholdEngine : public LoadServer
144 ThresholdEngine(ThresholdMain *plugin);
147 void process_packages(VFrame *data);
148 void init_packages();
149 LoadClient* new_client();
150 LoadPackage* new_package();
152 ThresholdMain *plugin;