add descratch plugin, single frame silence insert, docs
[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 0x60
19 #define SD_GOOD   0x40
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 DeScratchReset;
36
37
38 class DeScratchConfig
39 {
40 public:
41         DeScratchConfig();
42         ~DeScratchConfig();
43         void reset();
44         int equivalent(DeScratchConfig &that);
45         void copy_from(DeScratchConfig &that);
46         void interpolate(DeScratchConfig &prev, DeScratchConfig &next,
47                 int64_t prev_frame, int64_t next_frame, int64_t current_frame);
48
49         int threshold;
50         int asymmetry;
51         int min_width;
52         int max_width;
53         float min_len;
54         float max_len;
55         float max_angle;
56         int blur_len;
57         float gap_len;
58         int mode_y;
59         int mode_u;
60         int mode_v;
61         int mark;
62         float ffade;
63         int border;
64 };
65
66 class DeScratchMain : public PluginVClient
67 {
68 public:
69         DeScratchMain(PluginServer *server);
70         ~DeScratchMain();
71
72         PLUGIN_CLASS_MEMBERS(DeScratchConfig)
73         uint8_t *inf;  int sz_inf;
74         int src_w, src_h;
75         VFrame *src, *dst;
76         VFrame *tmp_frame, *blurry;
77         OverlayFrame *overlay_frame;
78         int is_realtime();
79         void update_gui();
80         void save_data(KeyFrame *keyframe);
81         void read_data(KeyFrame *keyframe);
82
83         void get_extrems_plane(int comp, int thresh);
84         void remove_min_extrems_plane(int comp, int thresh);
85         void close_gaps();
86         void test_scratches();
87         void mark_scratches_plane(int comp, int mask, int value);
88         void remove_scratches_plane(int comp);
89         void pass(int comp, int thresh);
90         void blur(int scale);
91         void copy(int comp);
92         void plane_pass(int comp, int mode);
93         int process_realtime(VFrame *input, VFrame *output);
94 };
95
96
97 class DeScratchWindow : public PluginClientWindow
98 {
99 public:
100         DeScratchWindow(DeScratchMain *plugin);
101         ~DeScratchWindow();
102         void update_gui();
103         void create_objects();
104         
105         DeScratchMain *plugin;
106         DeScratchMode *y_mode, *u_mode, *v_mode;
107         DeScratchISlider *threshold, *asymmetry;
108         DeScratchISlider *min_width, *max_width;
109         DeScratchFSlider *min_len, *max_len;
110         DeScratchISlider *blur_len;
111         DeScratchFSlider *gap_len;
112         DeScratchFSlider *max_angle;
113         DeScratchISlider *border;
114         DeScratchMark *mark;
115         DeScratchFSlider *ffade;
116         DeScratchReset *reset;
117 };
118
119 class DeScratchModeItem : public BC_MenuItem
120 {
121 public:
122         DeScratchModeItem(DeScratchMode *popup, int type, const char *text);
123         ~DeScratchModeItem();
124         int handle_event();
125
126         DeScratchMode *popup;
127         int type;
128 };
129
130 class DeScratchMode : public BC_PopupMenu
131 {
132 public:
133         DeScratchMode(DeScratchWindow *win, int x, int y, int *value);
134         ~DeScratchMode();
135         void create_objects();
136         int handle_event();
137         void update(int v);
138         void set_value(int v);
139
140         DeScratchWindow *win;
141         int *value;
142 };
143
144 class DeScratchISlider : public BC_ISlider
145 {
146 public:
147         DeScratchISlider(DeScratchWindow *win,
148                 int x, int y, int w, int min, int max, int *output);
149         ~DeScratchISlider();
150         int handle_event();
151
152         DeScratchWindow *win;
153         int *output;
154 };
155
156 class DeScratchFSlider : public BC_FSlider
157 {
158 public:
159         DeScratchFSlider(DeScratchWindow *win,
160                 int x, int y, int w, float min, float max, float *output);
161         ~DeScratchFSlider();
162         int handle_event();
163
164         DeScratchWindow *win;
165         float *output;
166 };
167
168 class DeScratchMark : public BC_CheckBox
169 {
170 public:
171         DeScratchMark(DeScratchWindow *win, int x, int y);
172         ~DeScratchMark();
173         int handle_event();
174
175         DeScratchWindow *win;
176 };
177
178 class DeScratchReset : public BC_GenericButton
179 {
180 public:
181         DeScratchReset(DeScratchWindow *win, int x, int y);
182         int handle_event();
183
184         DeScratchWindow *win;
185 };
186
187 #endif