remove xmlto depend from giflib for deb blds
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / C41 / c41.h
1 #ifndef __C41_H__
2 #define __C41_H__
3
4 #include "guicast.h"
5 #include "pluginvclient.h"
6 #include "vframe.inc"
7
8 // C41_FAST_POW increases processing speed more than 10 times
9 // Depending on gcc version, used optimizations and cpu C41_FAST_POW may not work
10 // With gcc versiion >= 4.4 it seems safe to enable C41_FAST_POW
11 // Test some samples after you have enabled it
12 #define C41_FAST_POW
13
14 #ifdef C41_FAST_POW
15 #define POWF myPow
16 #else
17 #define POWF powf
18 #endif
19
20 // Shave the image in order to avoid black borders
21 // The min max pixel value difference must be at least 0.05
22 #define C41_SHAVE_TOLERANCE 0.05
23 #define C41_SHAVE_MARGIN 0.1
24
25 #include <stdint.h>
26 #include <string.h>
27
28 class C41Effect;
29 class C41Window;
30 class C41Config;
31 class C41Enable;
32 class C41TextBox;
33 class C41Button;
34 class C41BoxButton;
35 class C41Slider;
36
37 struct magic
38 {
39         float min_r, max_r;
40         float min_g, max_g;
41         float min_b, max_b;
42         float light;
43         float gamma_g, gamma_b;
44         float coef1, coef2;
45         int shave_min_row, shave_max_row;
46         int shave_min_col, shave_max_col;
47 };
48
49 class C41Config
50 {
51 public:
52         C41Config();
53
54         void copy_from(C41Config &src);
55         int equivalent(C41Config &src);
56         void interpolate(C41Config &prev, C41Config &next,
57                 long prev_frame, long next_frame, long current_frame);
58
59         int active, compute_magic;
60         int postproc, show_box;
61         float fix_min_r, fix_min_g, fix_min_b;
62         float fix_light, fix_gamma_g, fix_gamma_b;
63         float fix_coef1, fix_coef2;
64         int min_col, max_col, min_row, max_row;
65         int window_w, window_h;
66 };
67
68 class C41Enable : public BC_CheckBox
69 {
70 public:
71         C41Enable(C41Effect *plugin, int *output, int x, int y, const char *text);
72         int handle_event();
73
74         C41Effect *plugin;
75         int *output;
76 };
77
78 class C41TextBox : public BC_TextBox
79 {
80 public:
81         C41TextBox(C41Effect *plugin, float *value, int x, int y);
82         int handle_event();
83
84         C41Effect *plugin;
85         float *boxValue;
86 };
87
88 class C41Button : public BC_GenericButton
89 {
90 public:
91         C41Button(C41Effect *plugin, C41Window *window, int x, int y);
92         int handle_event();
93
94         C41Effect *plugin;
95         C41Window *window;
96 };
97
98 class C41BoxButton : public BC_GenericButton
99 {
100 public:
101         C41BoxButton(C41Effect *plugin, C41Window *window, int x, int y);
102         int handle_event();
103
104         C41Effect *plugin;
105         C41Window *window;
106 };
107
108 class C41Slider : public BC_ISlider
109 {
110 public:
111         C41Slider(C41Effect *plugin, int *output, int x, int y, int is_row);
112
113         int handle_event();
114         int update(int v);
115
116         C41Effect *plugin;
117         int is_row, max;
118         int *output;
119 };
120
121 class C41Window : public PluginClientWindow
122 {
123 public:
124         C41Window(C41Effect *client);
125
126         void update();
127         void update_magic();
128
129         C41Enable *active;
130         C41Enable *compute_magic;
131         C41Enable *postproc;
132         C41Enable *show_box;
133         BC_Title *min_r;
134         BC_Title *min_g;
135         BC_Title *min_b;
136         BC_Title *light;
137         BC_Title *gamma_g;
138         BC_Title *gamma_b;
139         BC_Title *coef1;
140         BC_Title *coef2;
141         BC_Title *box_col_min;
142         BC_Title *box_col_max;
143         BC_Title *box_row_min;
144         BC_Title *box_row_max;
145         C41TextBox *fix_min_r;
146         C41TextBox *fix_min_g;
147         C41TextBox *fix_min_b;
148         C41TextBox *fix_light;
149         C41TextBox *fix_gamma_g;
150         C41TextBox *fix_gamma_b;
151         C41TextBox *fix_coef1;
152         C41TextBox *fix_coef2;
153         C41Button *lock;
154         C41BoxButton *boxlock;
155         C41Slider *min_row;
156         C41Slider *max_row;
157         C41Slider *min_col;
158         C41Slider *max_col;
159
160         int slider_max_col;
161         int slider_max_row;
162 };
163
164 class C41Effect : public PluginVClient
165 {
166 public:
167         C41Effect(PluginServer *server);
168         ~C41Effect();
169
170         PLUGIN_CLASS_MEMBERS(C41Config);
171         int is_realtime();
172         int is_synthesis();
173
174         int process_realtime(VFrame *input_ptr, VFrame *output_ptr);
175         void save_data(KeyFrame *keyframe);
176         void read_data(KeyFrame *keyframe);
177         void render_gui(void* data);
178 #if defined(C41_FAST_POW)
179         float myLog2(float i) __attribute__ ((optimize(0)));
180         float myPow2(float i) __attribute__ ((optimize(0)));
181         float myPow(float a, float b);
182 #endif
183         void pix_fix(float &pix, float min, float gamma);
184         VFrame *frame, *tmp_frame, *blurry_frame;
185         struct magic values;
186
187         int shave_min_row, shave_max_row, shave_min_col, shave_max_col;
188         int min_col, max_col, min_row, max_row;
189         float pix_max;
190         int pix_len;
191 };
192
193
194 #endif