r125: This commit was manufactured by cvs2svn to create tag 'r1_1_7-last'.
[cinelerra_cv/mob.git] / hvirtual / plugins / denoise / denoise.h
blob167641ec82296ac3d9b90e7951593dc742114865
1 #ifndef DENOISE_H
2 #define DENOISE_H
6 #include "defaults.inc"
7 #include "guicast.h"
8 #include "mutex.h"
9 #include "pluginaclient.h"
10 #include "vframe.inc"
12 class DenoiseEffect;
13 typedef enum { DECOMP, RECON } wavetype;
15 class DenoiseLevel : public BC_FPot
17 public:
18 DenoiseLevel(DenoiseEffect *plugin, int x, int y);
19 int handle_event();
20 DenoiseEffect *plugin;
23 class DenoiseWindow : public BC_Window
25 public:
26 DenoiseWindow(DenoiseEffect *plugin, int x, int y);
27 void create_objects();
28 void update();
29 int close_event();
30 DenoiseLevel *scale;
31 DenoiseEffect *plugin;
34 PLUGIN_THREAD_HEADER(DenoiseEffect, DenoiseThread, DenoiseWindow)
36 class DenoiseConfig
38 public:
39 DenoiseConfig();
40 void copy_from(DenoiseConfig &that);
41 int equivalent(DenoiseConfig &that);
42 void interpolate(DenoiseConfig &prev,
43 DenoiseConfig &next,
44 int64_t prev_frame,
45 int64_t next_frame,
46 int64_t current_frame);
47 double level;
50 class Tree
52 public:
53 Tree(int input_length, int levels);
54 ~Tree();
56 int input_length;
57 int levels;
58 double **values;
61 class WaveletCoeffs
63 public:
64 WaveletCoeffs(double alpha, double beta);
65 ~WaveletCoeffs();
67 double values[6];
68 int length;
71 class WaveletFilters
73 public:
74 WaveletFilters(WaveletCoeffs *wave_coeffs, wavetype transform);
75 ~WaveletFilters();
77 double g[6], h[6];
78 int length;
81 class DenoiseEffect : public PluginAClient
83 public:
84 DenoiseEffect(PluginServer *server);
85 ~DenoiseEffect();
87 int is_realtime();
88 void read_data(KeyFrame *keyframe);
89 void save_data(KeyFrame *keyframe);
90 int process_realtime(int64_t size, double *input_ptr, double *output_ptr);
95 int load_defaults();
96 int save_defaults();
97 void reset();
98 void update_gui();
99 void delete_dsp();
101 void process_window();
102 double dot_product(double *data, double *filter, char filtlen);
103 int convolve_dec_2(double *input_sequence,
104 int64_t length,
105 double *filter,
106 int filtlen,
107 double *output_sequence);
108 int64_t decompose_branches(double *in_data,
109 int64_t length,
110 WaveletFilters *decomp_filter,
111 double *out_low,
112 double *out_high);
113 int wavelet_decomposition(double *in_data,
114 int64_t in_length,
115 double **out_data);
116 int tree_copy(double **output,
117 double **input,
118 int length,
119 int levels);
120 int threshold(int window_size, double gammas, int levels);
121 double dot_product_even(double *data, double *filter, int filtlen);
122 double dot_product_odd(double *data, double *filter, int filtlen);
123 int convolve_int_2(double *input_sequence,
124 int64_t length,
125 double *filter,
126 int filtlen,
127 int sum_output,
128 double *output_sequence);
129 int64_t reconstruct_branches(double *in_low,
130 double *in_high,
131 int64_t in_length,
132 WaveletFilters *recon_filter,
133 double *output);
134 int wavelet_reconstruction(double **in_data,
135 int64_t in_length,
136 double *out_data);
139 PLUGIN_CLASS_MEMBERS(DenoiseConfig, DenoiseThread)
141 // buffer for storing fragments until a complete window size is armed
142 double *input_buffer;
143 int64_t input_size;
144 int64_t input_allocation;
145 // buffer for storing fragments until a fragment is ready to be read
146 double *output_buffer;
147 int64_t output_size;
148 int64_t output_allocation;
149 double *dsp_in;
150 double *dsp_out;
151 // buffer for capturing output of a single iteration
152 double *dsp_iteration;
153 Tree *ex_coeff_d, *ex_coeff_r, *ex_coeff_rn;
154 WaveletCoeffs *wave_coeff_d, *wave_coeff_r;
155 WaveletFilters *decomp_filter, *recon_filter;
156 // scaling factor for transferring from input_buffer
157 double in_scale;
158 // power converted to scaling factor
159 double out_scale;
161 // depends on the type of music
162 int64_t levels;
163 // higher number reduces aliasing due to a high noise_level
164 // also increases high end
165 int64_t iterations;
166 // daub6 coeffs
167 double alpha;
168 double beta;
169 // power
170 float output_level;
171 // higher number kills more noise at the expense of more aliasing
172 float noise_level;
173 int64_t window_size;
174 int first_window;
175 int initialized;
179 #endif