2 DeScratch - Scratches Removing Filter
3 Plugin for Avisynth 2.5
4 Copyright (c)2003-2016 Alexander G. Balakhnin aka Fizick
7 This program is FREE software under GPL licence v2.
9 This plugin removes vertical scratches from digitized films.
10 Reworked for cin5 by William Morrow. 03/2018, from the laws of Fizick's
11 Adapted strategy to mark, test, draw during port.
15 #ifndef __DESCRATCH_H__
16 #define __DESCRATCH_H__
20 #include "bcmenuitem.h"
21 #include "bcpopupmenu.h"
26 #include "overlayframe.h"
27 #include "pluginvclient.h"
29 // so that write_pgm can create grey images of inf
31 #define SD_EXTREM 0x80
32 #define SD_TESTED 0x40
34 #define SD_REJECT 0x10
41 class DeScratchConfig;
43 class DeScratchWindow;
44 class DeScratchModeItem;
46 class DeScratchISlider;
47 class DeScratchFSlider;
49 class DeScratchEdgeOnly;
59 int equivalent(DeScratchConfig &that);
60 void copy_from(DeScratchConfig &that);
61 void interpolate(DeScratchConfig &prev, DeScratchConfig &next,
62 int64_t prev_frame, int64_t next_frame, int64_t current_frame);
82 class DeScratchMain : public PluginVClient
85 DeScratchMain(PluginServer *server);
88 PLUGIN_CLASS_MEMBERS(DeScratchConfig)
89 uint8_t *inf; int sz_inf;
93 OverlayFrame *overlay_frame;
96 void save_data(KeyFrame *keyframe);
97 void read_data(KeyFrame *keyframe);
99 void set_extrems_plane(int width, int comp, int thresh);
101 void test_scratches();
102 void mark_scratches_plane();
103 void remove_scratches_plane(int comp);
104 void blur(int scale);
106 void pass(int comp, int thresh);
107 void plane_pass(int comp, int mode);
108 void plane_proc(int comp, int mode);
109 int process_realtime(VFrame *input, VFrame *output);
113 class DeScratchWindow : public PluginClientWindow
116 DeScratchWindow(DeScratchMain *plugin);
119 void create_objects();
121 DeScratchMain *plugin;
122 DeScratchMode *y_mode, *u_mode, *v_mode;
123 DeScratchISlider *threshold;
124 DeScratchFSlider *asymmetry;
125 DeScratchISlider *min_width, *max_width;
126 DeScratchFSlider *min_len, *max_len;
127 DeScratchISlider *blur_len;
128 DeScratchFSlider *gap_len;
129 DeScratchFSlider *max_angle;
130 DeScratchISlider *border;
132 DeScratchEdgeOnly *edge_only;
133 DeScratchFSlider *ffade;
134 DeScratchReset *reset;
137 class DeScratchModeItem : public BC_MenuItem
140 DeScratchModeItem(DeScratchMode *popup, int type, const char *text);
141 ~DeScratchModeItem();
144 DeScratchMode *popup;
148 class DeScratchMode : public BC_PopupMenu
151 DeScratchMode(DeScratchWindow *win, int x, int y, int *value);
153 void create_objects();
156 void set_value(int v);
158 DeScratchWindow *win;
162 class DeScratchISlider : public BC_ISlider
165 DeScratchISlider(DeScratchWindow *win,
166 int x, int y, int w, int min, int max, int *output);
170 DeScratchWindow *win;
174 class DeScratchFSlider : public BC_FSlider
177 DeScratchFSlider(DeScratchWindow *win,
178 int x, int y, int w, float min, float max, float *output);
182 DeScratchWindow *win;
186 class DeScratchMark : public BC_CheckBox
189 DeScratchMark(DeScratchWindow *win, int x, int y);
193 DeScratchWindow *win;
196 class DeScratchEdgeOnly : public BC_CheckBox
199 DeScratchEdgeOnly(DeScratchWindow *win, int x, int y);
200 ~DeScratchEdgeOnly();
203 DeScratchWindow *win;
206 class DeScratchReset : public BC_GenericButton
209 DeScratchReset(DeScratchWindow *win, int x, int y);
212 DeScratchWindow *win;