descratch again reworked + icons, add agingtv plugin params, add alias chkbox in...
[goodguy/history.git] / cinelerra-5.1 / plugins / descratch / descratch.h
1 #ifndef __DESCRATCH_H__
2 #define __DESCRATCH_H__
3
4 #include "bcbutton.h"
5 #include "bchash.h"
6 #include "bcmenuitem.h"
7 #include "bcpopupmenu.h"
8 #include "bcslider.h"
9 #include "bctitle.h"
10 #include "bctoggle.h"
11 #include "mutex.h"
12 #include "overlayframe.h"
13 #include "pluginvclient.h"
14
15 // so that write_pgm can create grey images of inf
16 #define SD_NULL 0
17 #define SD_EXTREM 0x80
18 #define SD_TESTED 0x40
19 #define SD_GOOD   0x20
20 #define SD_REJECT 0x10
21
22 #define MODE_NONE 0
23 #define MODE_LOW 1
24 #define MODE_HIGH 2
25 #define MODE_ALL 3
26
27 class DeScratchConfig;
28 class DeScratchMain;
29 class DeScratchWindow;
30 class DeScratchModeItem;
31 class DeScratchMode;
32 class DeScratchISlider;
33 class DeScratchFSlider;
34 class DeScratchMark;
35 class DeScratchEdgeOnly;
36 class DeScratchReset;
37
38
39 class DeScratchConfig
40 {
41 public:
42         DeScratchConfig();
43         ~DeScratchConfig();
44         void reset();
45         int equivalent(DeScratchConfig &that);
46         void copy_from(DeScratchConfig &that);
47         void interpolate(DeScratchConfig &prev, DeScratchConfig &next,
48                 int64_t prev_frame, int64_t next_frame, int64_t current_frame);
49
50         int threshold;
51         float asymmetry;
52         int min_width;
53         int max_width;
54         float min_len;
55         float max_len;
56         float max_angle;
57         int blur_len;
58         float gap_len;
59         int mode_y;
60         int mode_u;
61         int mode_v;
62         int mark;
63         float ffade;
64         int border;
65         int edge_only;
66 };
67
68 class DeScratchMain : public PluginVClient
69 {
70 public:
71         DeScratchMain(PluginServer *server);
72         ~DeScratchMain();
73
74         PLUGIN_CLASS_MEMBERS(DeScratchConfig)
75         uint8_t *inf;  int sz_inf;
76         int src_w, src_h;
77         VFrame *src, *dst;
78         VFrame *tmpy, *blury;
79         OverlayFrame *overlay_frame;
80         int is_realtime();
81         void update_gui();
82         void save_data(KeyFrame *keyframe);
83         void read_data(KeyFrame *keyframe);
84
85         void set_extrems_plane(int width, int comp, int thresh);
86         void close_gaps();
87         void test_scratches();
88         void mark_scratches_plane();
89         void remove_scratches_plane(int comp);
90         void blur(int scale);
91         void copy(int comp);
92         void pass(int comp, int thresh);
93         void plane_pass(int comp, int mode);
94         void plane_proc(int comp, int mode);
95         int process_realtime(VFrame *input, VFrame *output);
96 };
97
98
99 class DeScratchWindow : public PluginClientWindow
100 {
101 public:
102         DeScratchWindow(DeScratchMain *plugin);
103         ~DeScratchWindow();
104         void update_gui();
105         void create_objects();
106         
107         DeScratchMain *plugin;
108         DeScratchMode *y_mode, *u_mode, *v_mode;
109         DeScratchISlider *threshold;
110         DeScratchFSlider *asymmetry;
111         DeScratchISlider *min_width, *max_width;
112         DeScratchFSlider *min_len, *max_len;
113         DeScratchISlider *blur_len;
114         DeScratchFSlider *gap_len;
115         DeScratchFSlider *max_angle;
116         DeScratchISlider *border;
117         DeScratchMark *mark;
118         DeScratchEdgeOnly *edge_only;
119         DeScratchFSlider *ffade;
120         DeScratchReset *reset;
121 };
122
123 class DeScratchModeItem : public BC_MenuItem
124 {
125 public:
126         DeScratchModeItem(DeScratchMode *popup, int type, const char *text);
127         ~DeScratchModeItem();
128         int handle_event();
129
130         DeScratchMode *popup;
131         int type;
132 };
133
134 class DeScratchMode : public BC_PopupMenu
135 {
136 public:
137         DeScratchMode(DeScratchWindow *win, int x, int y, int *value);
138         ~DeScratchMode();
139         void create_objects();
140         int handle_event();
141         void update(int v);
142         void set_value(int v);
143
144         DeScratchWindow *win;
145         int *value;
146 };
147
148 class DeScratchISlider : public BC_ISlider
149 {
150 public:
151         DeScratchISlider(DeScratchWindow *win,
152                 int x, int y, int w, int min, int max, int *output);
153         ~DeScratchISlider();
154         int handle_event();
155
156         DeScratchWindow *win;
157         int *output;
158 };
159
160 class DeScratchFSlider : public BC_FSlider
161 {
162 public:
163         DeScratchFSlider(DeScratchWindow *win,
164                 int x, int y, int w, float min, float max, float *output);
165         ~DeScratchFSlider();
166         int handle_event();
167
168         DeScratchWindow *win;
169         float *output;
170 };
171
172 class DeScratchMark : public BC_CheckBox
173 {
174 public:
175         DeScratchMark(DeScratchWindow *win, int x, int y);
176         ~DeScratchMark();
177         int handle_event();
178
179         DeScratchWindow *win;
180 };
181
182 class DeScratchEdgeOnly : public BC_CheckBox
183 {
184 public:
185         DeScratchEdgeOnly(DeScratchWindow *win, int x, int y);
186         ~DeScratchEdgeOnly();
187         int handle_event();
188
189         DeScratchWindow *win;
190 };
191
192 class DeScratchReset : public BC_GenericButton
193 {
194 public:
195         DeScratchReset(DeScratchWindow *win, int x, int y);
196         int handle_event();
197
198         DeScratchWindow *win;
199 };
200
201 #endif