igor b reset btns, reframert bug fix
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / sharpen / sharpen.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #ifndef SHARPEN_H
23 #define SHARPEN_H
24
25 // the simplest plugin possible
26 // Sharpen leaves the last line too bright
27
28 class SharpenMain;
29 #define MAXSHARPNESS 100
30
31 #include "condition.inc"
32 #include "bchash.h"
33 #include "pluginvclient.h"
34 #include "sharpenwindow.h"
35
36 #include <sys/types.h>
37
38 class SharpenEngine;
39
40 class SharpenConfig
41 {
42 public:
43         SharpenConfig();
44
45         void copy_from(SharpenConfig &that);
46         int equivalent(SharpenConfig &that);
47         void reset();
48         void interpolate(SharpenConfig &prev,
49                 SharpenConfig &next,
50                 long prev_frame,
51                 long next_frame,
52                 long current_frame);
53
54
55
56         int horizontal;
57         int interlace;
58         int luminance;
59         float sharpness;
60 };
61
62 class SharpenMain : public PluginVClient
63 {
64 public:
65         SharpenMain(PluginServer *server);
66         ~SharpenMain();
67
68 // required for all realtime plugins
69         PLUGIN_CLASS_MEMBERS(SharpenConfig)
70         int process_realtime(VFrame *input_ptr, VFrame *output_ptr);
71         int is_realtime();
72         void update_gui();
73         void save_data(KeyFrame *keyframe);
74         void read_data(KeyFrame *keyframe);
75
76 // parameters needed for sharpness
77         int row_step;
78
79         int pos_lut[0x10000], neg_lut[0x10000];
80         VFrame *output, *input;
81
82 private:
83         int get_luts(int *pos_lut, int *neg_lut, int color_model);
84         SharpenEngine **engine;
85         int total_engines;
86 };
87
88
89 class SharpenEngine : public Thread
90 {
91 public:
92         SharpenEngine(SharpenMain *plugin);
93         ~SharpenEngine();
94
95         int start_process_frame(VFrame *output, VFrame *input, int field);
96         int wait_process_frame();
97         void run();
98
99         void filter(int components,
100                 int vmax,
101                 int w,
102                 unsigned char *src,
103                 unsigned char *dst,
104                 int *neg0,
105                 int *neg1,
106                 int *neg2);
107         void filter(int components,
108                 int vmax,
109                 int w,
110                 u_int16_t *src,
111                 u_int16_t *dst,
112                 int *neg0,
113                 int *neg1,
114                 int *neg2);
115         void filter(int components,
116                 int vmax,
117                 int w,
118                 float *src,
119                 float *dst,
120                 float *neg0,
121                 float *neg1,
122                 float *neg2);
123
124
125         void filter_888(int w,
126                 unsigned char *src,
127                 unsigned char *dst,
128                 int *neg0,
129                 int *neg1,
130                 int *neg2);
131         void filter_8888(int w,
132                 unsigned char *src,
133                 unsigned char *dst,
134                 int *neg0,
135                 int *neg1,
136                 int *neg2);
137         void filter_161616(int w,
138                 u_int16_t *src,
139                 u_int16_t *dst,
140                 int *neg0,
141                 int *neg1,
142                 int *neg2);
143         void filter_16161616(int w,
144                 u_int16_t *src,
145                 u_int16_t *dst,
146                 int *neg0,
147                 int *neg1,
148                 int *neg2);
149
150         int filter(int w,
151                 unsigned char *src,
152                 unsigned char *dst,
153                 int *neg0,
154                 int *neg1,
155                 int *neg2);
156
157         float calculate_pos(float value);
158         float calculate_neg(float value);
159
160
161         SharpenMain *plugin;
162         int field;
163         VFrame *output, *input;
164         int last_frame;
165         Condition *input_lock, *output_lock;
166         unsigned char *src_rows[4], *dst_row;
167         unsigned char *neg_rows[4];
168         float sharpness_coef;
169 };
170
171 #endif