switch from eclipse to android studio
[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 interpolate(SharpenConfig &prev,
48                 SharpenConfig &next,
49                 long prev_frame,
50                 long next_frame,
51                 long current_frame);
52
53
54
55         int horizontal;
56         int interlace;
57         int luminance;
58         float sharpness;
59 };
60
61 class SharpenMain : public PluginVClient
62 {
63 public:
64         SharpenMain(PluginServer *server);
65         ~SharpenMain();
66
67 // required for all realtime plugins
68         PLUGIN_CLASS_MEMBERS(SharpenConfig)
69         int process_realtime(VFrame *input_ptr, VFrame *output_ptr);
70         int is_realtime();
71         void update_gui();
72         void save_data(KeyFrame *keyframe);
73         void read_data(KeyFrame *keyframe);
74
75 // parameters needed for sharpness
76         int row_step;
77
78         int pos_lut[0x10000], neg_lut[0x10000];
79         VFrame *output, *input;
80
81 private:
82         int get_luts(int *pos_lut, int *neg_lut, int color_model);
83         SharpenEngine **engine;
84         int total_engines;
85 };
86
87
88 class SharpenEngine : public Thread
89 {
90 public:
91         SharpenEngine(SharpenMain *plugin);
92         ~SharpenEngine();
93
94         int start_process_frame(VFrame *output, VFrame *input, int field);
95         int wait_process_frame();
96         void run();
97
98         void filter(int components,
99                 int vmax,
100                 int w,
101                 unsigned char *src,
102                 unsigned char *dst,
103                 int *neg0,
104                 int *neg1,
105                 int *neg2);
106         void filter(int components,
107                 int vmax,
108                 int w,
109                 u_int16_t *src,
110                 u_int16_t *dst,
111                 int *neg0,
112                 int *neg1,
113                 int *neg2);
114         void filter(int components,
115                 int vmax,
116                 int w,
117                 float *src,
118                 float *dst,
119                 float *neg0,
120                 float *neg1,
121                 float *neg2);
122
123
124         void filter_888(int w,
125                 unsigned char *src,
126                 unsigned char *dst,
127                 int *neg0,
128                 int *neg1,
129                 int *neg2);
130         void filter_8888(int w,
131                 unsigned char *src,
132                 unsigned char *dst,
133                 int *neg0,
134                 int *neg1,
135                 int *neg2);
136         void filter_161616(int w,
137                 u_int16_t *src,
138                 u_int16_t *dst,
139                 int *neg0,
140                 int *neg1,
141                 int *neg2);
142         void filter_16161616(int w,
143                 u_int16_t *src,
144                 u_int16_t *dst,
145                 int *neg0,
146                 int *neg1,
147                 int *neg2);
148
149         int filter(int w,
150                 unsigned char *src,
151                 unsigned char *dst,
152                 int *neg0,
153                 int *neg1,
154                 int *neg2);
155
156         float calculate_pos(float value);
157         float calculate_neg(float value);
158
159
160         SharpenMain *plugin;
161         int field;
162         VFrame *output, *input;
163         int last_frame;
164         Condition *input_lock, *output_lock;
165         unsigned char *src_rows[4], *dst_row;
166         unsigned char *neg_rows[4];
167         float sharpness_coef;
168 };
169
170 #endif