add auto zoombar/status color, fix 3 batchrender boobies, rotate plugin tweaks, add...
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / interpolatevideo / interpolatevideo.h
1 /*
2  * CINELERRA
3  * Copyright (C) 1997-2011 Adam Williams <broadcast at earthling dot net>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  * *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  *
19  */
20
21 #ifndef INTERPOLATEVIDEO_H
22 #define INTERPOLATEVIDEO_H
23
24 /*
25  * #include "arraylist.h"
26  * #include "bcdisplayinfo.h"
27  *  *  *  * #include "keyframe.h"
28  *  * #include "vframe.h"
29  */
30
31 #include "opticflow.inc"
32 #include "pluginvclient.h"
33
34 #include <string.h>
35 #include <stdint.h>
36
37
38 // In pixels
39 #define MIN_SEARCH_RADIUS 4
40 #define MAX_SEARCH_RADIUS 256
41 #define MIN_MACROBLOCK_SIZE 8
42 #define MAX_MACROBLOCK_SIZE 256
43 #define MAX_SEARCH_STEPS 1024
44 // Enough packages to keep busy if macroblocks turn invalid,
45 // yet not bog down the mutexes
46 #define MAX_PACKAGES ((PluginClient::get_project_smp() + 1) * 16)
47
48 class InterpolateVideo;
49 class InterpolateVideoWindow;
50
51
52 class InterpolateVideoConfig
53 {
54 public:
55         InterpolateVideoConfig();
56
57         void copy_from(InterpolateVideoConfig *config);
58         int equivalent(InterpolateVideoConfig *config);
59
60 // Frame rate of input
61         double input_rate;
62 // If 1, use the keyframes as beginning and end frames and ignore input rate
63         int use_keyframes;
64         int optic_flow;
65         int draw_vectors;
66         int search_radius;
67         int macroblock_size;
68 };
69
70
71
72
73 class InterpolateVideo : public PluginVClient
74 {
75 public:
76         InterpolateVideo(PluginServer *server);
77         ~InterpolateVideo();
78
79         PLUGIN_CLASS_MEMBERS2(InterpolateVideoConfig)
80
81         int process_buffer(VFrame *frame,
82                 int64_t start_position,
83                 double frame_rate);
84         int is_realtime();
85         void save_data(KeyFrame *keyframe);
86         void read_data(KeyFrame *keyframe);
87         void update_gui();
88
89         void fill_border(double frame_rate, int64_t start_position);
90         void create_macroblocks();
91         void draw_vectors(int processed);
92         int angles_overlap(float dst2_angle1,
93                 float dst2_angle2,
94                 float dst1_angle1,
95                 float dst1_angle2);
96         void blend_macroblock(int number);
97         void optic_flow();
98         void average();
99         void draw_pixel(VFrame *frame, int x, int y);
100         void draw_line(VFrame *frame, int x1, int y1, int x2, int y2);
101         void draw_arrow(VFrame *frame,
102                 int x1,
103                 int y1,
104                 int x2,
105                 int y2);
106         void draw_rect(VFrame *frame,
107                 int x1,
108                 int y1,
109                 int x2,
110                 int y2);
111
112         ArrayList<OpticFlowMacroblock*> macroblocks;
113         ArrayList<int> invalid_blocks;
114         OpticFlow *optic_flow_engine;
115         Warp *warp_engine;
116         BlendMacroblock *blend_engine;
117         int x_macroblocks;
118         int y_macroblocks;
119 // Last motion scanned positions
120         int64_t motion_number[2];
121
122
123
124 // beginning and end frames
125         VFrame *frames[2];
126 // Last requested positions
127         int64_t frame_number[2];
128         int last_macroblock_size;
129         int last_search_radius;
130         int total_macroblocks;
131 // Last output position
132         int64_t last_position;
133         double last_rate;
134         float lowest_fraction;
135
136 // Current requested positions
137         int64_t range_start;
138         int64_t range_end;
139
140 // Input rate determined by keyframe mode
141         double active_input_rate;
142 };
143
144
145
146
147
148
149
150 #endif
151
152