Credit Andrew - fix vorbis audio which was scratchy and ensure aging plugin does...
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / histeq / histeq.h
1 /*
2  * CINELERRA
3  * Copyright (C) 2020 William Morrow
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 #ifndef HISTOGRAM_H
22 #define HISTOGRAM_H
23
24
25 #include "histeq.inc"
26 #include "loadbalance.h"
27 #include "bccolors.h"
28 #include "pluginvclient.h"
29
30 class HistEqConfig {
31 public:
32         HistEqConfig();
33         ~HistEqConfig();
34
35         int split;
36         int plot;
37         float blend;
38         float gain;
39
40         void copy_from(HistEqConfig &that);
41         int equivalent(HistEqConfig &that);
42         void interpolate(HistEqConfig &prev, HistEqConfig &next,
43                 int64_t prev_frame, int64_t next_frame, int64_t current_frame);
44 };
45
46 class HistEqSplit : public BC_CheckBox
47 {
48 public:
49         HistEqSplit(HistEqWindow *gui, HistEqMain *plugin, int x, int y);
50         ~HistEqSplit();
51         int handle_event();
52
53         HistEqWindow *gui;
54         HistEqMain *plugin;
55 };
56
57 class HistEqPlot : public BC_CheckBox
58 {
59 public:
60         HistEqPlot(HistEqWindow *gui, HistEqMain *plugin, int x, int y);
61         ~HistEqPlot();
62         int handle_event();
63
64         HistEqWindow *gui;
65         HistEqMain *plugin;
66 };
67
68 class HistEqBlend : public BC_FSlider
69 {
70 public:
71         HistEqBlend(HistEqWindow *gui, HistEqMain *plugin, int x, int y);
72         ~HistEqBlend();
73         int handle_event();
74
75         HistEqWindow *gui;
76         HistEqMain *plugin;
77 };
78
79 class HistEqGain : public BC_FSlider
80 {
81 public:
82         HistEqGain(HistEqWindow *gui, HistEqMain *plugin, int x, int y);
83         ~HistEqGain();
84         int handle_event();
85
86         HistEqWindow *gui;
87         HistEqMain *plugin;
88 };
89
90 class HistEqCanvas : public BC_SubWindow
91 {
92 public:
93         HistEqCanvas(HistEqWindow *gui, HistEqMain *plugin,
94                 int x, int y, int w, int h);
95         void clear();
96         void draw_bins(HistEqMain *plugin);
97         void draw_wts(HistEqMain *plugin);
98         void draw_reg(HistEqMain *plugin);
99         void draw_lut(HistEqMain *plugin);
100         void update(HistEqMain *plugin);
101
102         HistEqMain *plugin;
103         HistEqWindow *gui;
104 };
105
106 class HistEqWindow : public PluginClientWindow
107 {
108 public:
109         HistEqWindow(HistEqMain *plugin);
110         ~HistEqWindow();
111
112         HistEqMain *plugin;
113         HistEqSplit *split;
114         HistEqPlot *plot;
115         HistEqBlend *blend;
116         HistEqGain *gain;
117         HistEqCanvas *canvas;
118
119         void create_objects();
120         void update();
121 };
122
123 class HistEqMain : public PluginVClient
124 {
125 public:
126         HistEqMain(PluginServer *server);
127         ~HistEqMain();
128
129         int process_buffer(VFrame *frame, int64_t start_position, double frame_rate);
130         int is_realtime();
131         void save_data(KeyFrame *keyframe);
132         void read_data(KeyFrame *keyframe);
133         void update_gui();
134
135         void render_gui(void *data);
136
137         PLUGIN_CLASS_MEMBERS(HistEqConfig)
138
139         VFrame *input, *output;
140         HistEqEngine *engine;
141         int w, h;
142         int sz;
143         double a, b;
144         int binsz, bsz, *bins;
145         int lutsz, lsz, *lut;
146         int wsz;  float *wts;
147 };
148
149 class HistEqPackage : public LoadPackage
150 {
151 public:
152         HistEqPackage();
153         int y0, y1;
154 };
155
156 class HistEqUnit : public LoadClient
157 {
158 public:
159         HistEqUnit(HistEqEngine *server, HistEqMain *plugin);
160         ~HistEqUnit();
161         void process_package(LoadPackage *package);
162         HistEqEngine *server;
163         HistEqMain *plugin;
164         int valid;
165         int binsz, *bins;
166 };
167
168 class HistEqEngine : public LoadServer
169 {
170 public:
171         HistEqEngine(HistEqMain *plugin, int total_clients, int total_packages);
172         void process_packages(int operation, VFrame *data);
173         void init_packages();
174         LoadClient* new_client();
175         LoadPackage* new_package();
176         HistEqMain *plugin;
177         int operation;
178
179         enum { HISTEQ, APPLY };
180         VFrame *data;
181 };
182
183 #endif