remove whitespace at eol
[goodguy/history.git] / cinelerra-5.1 / plugins / ivtc / ivtc.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 IVTC_H
23 #define IVTC_H
24
25 class IVTCMain;
26 class IVTCEngine;
27
28 #include "bchash.h"
29 #include "loadbalance.h"
30 #include "mutex.h"
31 #include "pluginvclient.h"
32 #include "ivtcwindow.h"
33 #include <sys/types.h>
34
35 class IVTCEngine;
36
37 class IVTCConfig
38 {
39 public:
40         IVTCConfig();
41         int frame_offset;
42 // 0 - even     1 - odd
43         int first_field;
44         int automatic;
45         float auto_threshold;
46         int pattern;
47         enum
48         {
49                 PULLDOWN32,
50                 SHIFTFIELD,
51                 AUTOMATIC
52         };
53 };
54
55 class IVTCMain : public PluginVClient
56 {
57 public:
58         IVTCMain(PluginServer *server);
59         ~IVTCMain();
60
61 // required for all realtime plugins
62         int process_realtime(VFrame *input_ptr, VFrame *output_ptr);
63         int is_realtime();
64         void save_data(KeyFrame *keyframe);
65         void read_data(KeyFrame *keyframe);
66         PLUGIN_CLASS_MEMBERS(IVTCConfig)
67         void update_gui();
68         void render_stop();
69
70         void compare_fields(VFrame *frame1,
71                 VFrame *frame2,
72                 int64_t &field1,
73                 int64_t &field2);
74         int64_t compare(VFrame *current_avg,
75                 VFrame *current_orig,
76                 VFrame *previous,
77                 int field);
78
79         void deinterlace_avg(VFrame *output, VFrame *input, int dominance);
80
81
82         VFrame *temp_frame[2];
83         VFrame *input, *output;
84
85 // Automatic IVTC variables
86 // Difference between averaged current even lines and original even lines
87         int64_t even_vs_current;
88 // Difference between averaged current even lines and previous even lines
89         int64_t even_vs_prev;
90 // Difference between averaged current odd lines and original odd lines
91         int64_t odd_vs_current;
92 // Difference between averaged current odd lines and previous odd lines
93         int64_t odd_vs_prev;
94
95 // Closest combination of fields in previous calculation.
96 // If the lowest current combination is too big and the previous strategy
97 // was direct copy, copy the previous frame.
98         int64_t previous_min;
99         int previous_strategy;
100         IVTCEngine *engine;
101 };
102
103
104 class IVTCPackage : public LoadPackage
105 {
106 public:
107         IVTCPackage();
108         int y1, y2;
109 };
110
111 class IVTCUnit : public LoadClient
112 {
113 public:
114         IVTCUnit(IVTCEngine *server, IVTCMain *plugin);
115         void process_package(LoadPackage *package);
116         void clear_totals();
117         IVTCEngine *server;
118         IVTCMain *plugin;
119         int64_t even_vs_current;
120         int64_t even_vs_prev;
121         int64_t odd_vs_current;
122         int64_t odd_vs_prev;
123 };
124
125
126 class IVTCEngine : public LoadServer
127 {
128 public:
129         IVTCEngine(IVTCMain *plugin, int cpus);
130         ~IVTCEngine();
131         void init_packages();
132         LoadClient* new_client();
133         LoadPackage* new_package();
134         IVTCMain *plugin;
135 };
136
137 #endif