00001 #ifndef THRESHOLD_H
00002 #define THRESHOLD_H
00003
00004
00005 #include "histogramengine.inc"
00006 #include "loadbalance.h"
00007 #include "thresholdwindow.inc"
00008 #include "plugincolors.inc"
00009 #include "pluginvclient.h"
00010
00011
00012 class ThresholdEngine;
00013 class RGBA;
00014
00015
00016 class RGBA
00017 {
00018 public:
00019 RGBA();
00020 RGBA(int r, int g, int b, int a);
00021 void set(int r, int g, int b, int a);
00022 void set(int rgb, int alpha);
00023 int getRGB() const;
00024
00025
00026
00027 RGBA load_default(BC_Hash * defaults, const char * prefix) const;
00028
00029
00030 void save_defaults(BC_Hash * defaults, const char * prefix) const;
00031
00032
00033 void set_property(XMLTag & tag, const char * prefix) const;
00034
00035
00036
00037 RGBA get_property(XMLTag & tag, const char * prefix) const;
00038
00039 int r, g, b, a;
00040 };
00041
00042 bool operator==(const RGBA & a, const RGBA & b);
00043
00044
00045 template<typename T>
00046 T interpolate(const T & prev, const double & prev_scale, const T & next, const double & next_scale);
00047
00048
00049 template<>
00050 RGBA interpolate(const RGBA & prev_color, const double & prev_scale, const RGBA &next_color, const double & next_scale);
00051
00052
00053
00054 class ThresholdConfig
00055 {
00056 public:
00057 ThresholdConfig();
00058 int equivalent(ThresholdConfig &that);
00059 void copy_from(ThresholdConfig &that);
00060 void interpolate(ThresholdConfig &prev,
00061 ThresholdConfig &next,
00062 int64_t prev_frame,
00063 int64_t next_frame,
00064 int64_t current_frame);
00065 void reset();
00066 void boundaries();
00067
00068 float min;
00069 float max;
00070 int plot;
00071 RGBA low_color;
00072 RGBA mid_color;
00073 RGBA high_color;
00074 };
00075
00076
00077
00078 class ThresholdMain : public PluginVClient
00079 {
00080 public:
00081 ThresholdMain(PluginServer *server);
00082 ~ThresholdMain();
00083
00084 int process_buffer(VFrame *frame,
00085 int64_t start_position,
00086 double frame_rate);
00087 int is_realtime();
00088 int load_defaults();
00089 int save_defaults();
00090 void save_data(KeyFrame *keyframe);
00091 void read_data(KeyFrame *keyframe);
00092 void update_gui();
00093 void render_gui(void *data);
00094 void calculate_histogram(VFrame *frame);
00095 int handle_opengl();
00096
00097 PLUGIN_CLASS_MEMBERS(ThresholdConfig, ThresholdThread);
00098 HistogramEngine *engine;
00099 ThresholdEngine *threshold_engine;
00100 };
00101
00102
00103
00104
00105
00106
00107 class ThresholdPackage : public LoadPackage
00108 {
00109 public:
00110 ThresholdPackage();
00111 int start;
00112 int end;
00113 };
00114
00115
00116 class ThresholdUnit : public LoadClient
00117 {
00118 public:
00119 ThresholdUnit(ThresholdEngine *server);
00120 void process_package(LoadPackage *package);
00121
00122 ThresholdEngine *server;
00123 private:
00124 template<typename TYPE, int COMPONENTS, bool USE_YUV>
00125 void render_data(LoadPackage *package);
00126 };
00127
00128
00129 class ThresholdEngine : public LoadServer
00130 {
00131 public:
00132 ThresholdEngine(ThresholdMain *plugin);
00133 ~ThresholdEngine();
00134
00135 void process_packages(VFrame *data);
00136 void init_packages();
00137 LoadClient* new_client();
00138 LoadPackage* new_package();
00139
00140 YUV *yuv;
00141 ThresholdMain *plugin;
00142 VFrame *data;
00143 };
00144
00145
00146
00147
00148
00149
00150 #endif