ecc4f18ac3e1ba9ec0992e262f6eb446b84d8d8f
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / colorbalance / colorbalance.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 1997-2011 Adam Williams <broadcast at earthling dot net>
5  *
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.
10  *
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.
15  *
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
19  *
20  */
21
22 #ifndef COLORBALANCE_H
23 #define COLORBALANCE_H
24
25 class ColorBalanceMain;
26
27 #include "colorbalancewindow.h"
28 #include "condition.h"
29 #include "bccolors.h"
30 #include "guicast.h"
31 #include "pluginvclient.h"
32 #include "thread.h"
33
34 #define SHADOWS 0
35 #define MIDTONES 1
36 #define HIGHLIGHTS 2
37
38 class ColorBalanceConfig
39 {
40 public:
41         ColorBalanceConfig();
42
43         int equivalent(ColorBalanceConfig &that);
44         void copy_from(ColorBalanceConfig &that);
45         void interpolate(ColorBalanceConfig &prev,
46                 ColorBalanceConfig &next,
47                 int64_t prev_frame,
48                 int64_t next_frame,
49                 int64_t current_frame);
50
51 // -1000 - 1000
52         float cyan;
53         float magenta;
54     float yellow;
55     int preserve;
56     int lock_params;
57 };
58
59 class ColorBalanceEngine : public Thread
60 {
61 public:
62         ColorBalanceEngine(ColorBalanceMain *plugin);
63         ~ColorBalanceEngine();
64
65         int start_process_frame(VFrame *output, VFrame *input, int row_start, int row_end);
66         int wait_process_frame();
67         void run();
68
69         ColorBalanceMain *plugin;
70         int row_start, row_end;
71         int last_frame;
72         Condition input_lock, output_lock;
73         VFrame *input, *output;
74         float cyan_f, magenta_f, yellow_f;
75 };
76
77 class ColorBalanceMain : public PluginVClient
78 {
79 public:
80         ColorBalanceMain(PluginServer *server);
81         ~ColorBalanceMain();
82
83 // required for all realtime plugins
84         PLUGIN_CLASS_MEMBERS(ColorBalanceConfig);
85         int process_buffer(VFrame *frame,
86                 int64_t start_position,
87                 double frame_rate);
88         int is_realtime();
89         void update_gui();
90         void save_data(KeyFrame *keyframe);
91         void read_data(KeyFrame *keyframe);
92         int handle_opengl();
93
94         void get_aggregation(int *aggregate_interpolate,
95                 int *aggregate_gamma);
96
97
98         int64_t calculate_slider(float in);
99         float calculate_transfer(float in);
100
101 // parameters needed for processor
102         int reconfigure();
103     int synchronize_params(ColorBalanceSlider *slider, float difference);
104     int test_boundary(float &value);
105
106         ColorBalanceEngine **engine;
107         int total_engines;
108
109
110     int r_lookup_8[0x100];
111     int g_lookup_8[0x100];
112     int b_lookup_8[0x100];
113     int r_lookup_16[0x10000];
114     int g_lookup_16[0x10000];
115     int b_lookup_16[0x10000];
116     int redo_buffers;
117         int need_reconfigure;
118 };
119
120
121
122 #endif