3 * Copyright (C) 1997-2011 Adam Williams <broadcast at earthling dot net>
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.
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.
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
21 #ifndef INTERPOLATEVIDEO_H
22 #define INTERPOLATEVIDEO_H
25 * #include "arraylist.h"
26 * #include "bcdisplayinfo.h"
27 * * * * #include "keyframe.h"
28 * * #include "vframe.h"
31 #include "opticflow.inc"
32 #include "pluginvclient.h"
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)
48 class InterpolateVideo;
49 class InterpolateVideoWindow;
52 class InterpolateVideoConfig
55 InterpolateVideoConfig();
57 void copy_from(InterpolateVideoConfig *config);
58 int equivalent(InterpolateVideoConfig *config);
60 // Frame rate of input
62 // If 1, use the keyframes as beginning and end frames and ignore input rate
73 class InterpolateVideo : public PluginVClient
76 InterpolateVideo(PluginServer *server);
79 PLUGIN_CLASS_MEMBERS2(InterpolateVideoConfig)
81 int process_buffer(VFrame *frame,
82 int64_t start_position,
85 void save_data(KeyFrame *keyframe);
86 void read_data(KeyFrame *keyframe);
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,
96 void blend_macroblock(int number);
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,
106 void draw_rect(VFrame *frame,
112 ArrayList<OpticFlowMacroblock*> macroblocks;
113 ArrayList<int> invalid_blocks;
114 OpticFlow *optic_flow_engine;
116 BlendMacroblock *blend_engine;
119 // Last motion scanned positions
120 int64_t motion_number[2];
124 // beginning and end frames
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;
134 float lowest_fraction;
136 // Current requested positions
140 // Input rate determined by keyframe mode
141 double active_input_rate;