Credit Andrew - updating patches for FFmpeg 7.0 as needed since 6.1, now at 7.0,...
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / deinterlace-cv / deinterlace-cv.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  * Copyright (C) 2003-2016 Cinelerra CV contributors
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  *
21  */
22
23 #ifndef DEINTERLACE_H
24 #define DEINTERLACE_H
25
26 // the simplest plugin possible
27
28 class DeInterlaceMain;
29
30 #include "bchash.inc"
31 #include "deinterwindow-cv.h"
32 #include "pluginvclient.h"
33 #include "vframe.inc"
34
35
36
37 #define THRESHOLD_SCALAR 1000
38
39 enum
40 {
41         DEINTERLACE_NONE,
42         DEINTERLACE_KEEP,
43         DEINTERLACE_AVG_1F,
44         DEINTERLACE_AVG,
45         DEINTERLACE_BOBWEAVE,
46         DEINTERLACE_SWAP,
47         DEINTERLACE_TEMPORALSWAP,
48 };
49
50 class DeInterlaceConfig
51 {
52 public:
53         DeInterlaceConfig();
54
55         int equivalent(DeInterlaceConfig &that);
56         void copy_from(DeInterlaceConfig &that);
57         void interpolate(DeInterlaceConfig &prev,
58                 DeInterlaceConfig &next,
59                 int64_t prev_frame,
60                 int64_t next_frame,
61                 int64_t current_frame);
62
63         int mode;
64         int adaptive;
65         int threshold;
66         volatile int dominance; /* top or bottom field */
67 };
68
69 class DeInterlaceMain : public PluginVClient
70 {
71 public:
72         DeInterlaceMain(PluginServer *server);
73         ~DeInterlaceMain();
74
75
76         PLUGIN_CLASS_MEMBERS(DeInterlaceConfig);
77
78
79 // required for all realtime plugins
80         int process_buffer(VFrame *frame,
81                 int64_t start_position,
82                 double frame_rate);
83         int is_realtime();
84         int hide_gui();
85         void update_gui();
86         void save_data(KeyFrame *keyframe);
87         void read_data(KeyFrame *keyframe);
88         void render_gui(void *data);
89
90         void deinterlace_avg_top(VFrame *input, VFrame *output, int dominance);
91         void deinterlace_top(VFrame *input, VFrame *output, int dominance);
92         void deinterlace_avg(VFrame *input, VFrame *output);
93         void deinterlace_swap(VFrame *input, VFrame *output, int dominance);
94         void deinterlace_temporalswap(VFrame *input, VFrame *prevframe, VFrame *output, int dominance);
95         void deinterlace_bobweave(VFrame *input, VFrame *prevframe, VFrame *output, int dominance);
96
97         int changed_rows;
98         VFrame *temp;
99         VFrame *temp_prevframe;
100 };
101
102
103 #endif