4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
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.
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.
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
22 #ifndef __MOTION_51_H__
23 #define __MOTION_51_H__
31 #include "filexml.inc"
32 #include "keyframe.inc"
33 #include "loadbalance.h"
34 #include "motion51.inc"
35 #include "overlayframe.inc"
36 #include "pluginvclient.h"
42 class Motion51ScanUnit;
43 class Motion51ScanPackage;
45 class Motion51VVFrame;
53 int equivalent(Motion51Config &that);
54 void copy_from(Motion51Config &that);
55 void interpolate(Motion51Config &prev, Motion51Config &next,
56 int64_t prev_frame, int64_t next_frame, int64_t current_frame);
58 float block_x, block_y, block_w, block_h;
61 float horiz_limit, vert_limit, twist_limit;
62 float shake_fade, twist_fade;
65 char tracking_file[BCTEXTLEN];
70 class Motion51Main : public PluginVClient
73 Motion51Main(PluginServer *server);
76 int process_buffer(VFrame **frame, int64_t position, double frame_rate);
77 int is_multichannel();
79 void save_data(KeyFrame *keyframe);
80 void read_data(KeyFrame *keyframe);
82 void reset_sample(int sz, double r);
83 void get_samples(VFrame *img, double *pix[3], double x, double y);
84 void centroid(double *pix[3], double *ctr_v, double *ctr_x, double *ctr_y);
85 void draw_vectors(VFrame *img);
87 int64_t get_ref_position();
88 void update_tracking_cache();
89 int load_tracking_cache(int64_t position);
90 void save_tracking_cache(int64_t position);
92 void match(VFrame *ref, VFrame *cur);
93 int transform_target(int use_opengl);
95 VFrame* new_temp(VFrame *&tmp, VFrame *ref);
97 PLUGIN_CLASS_MEMBERS2(Motion51Config)
99 char cache_file[BCTEXTLEN];
100 FILE *cache_fp, *active_fp;
101 void set_tracking_path();
102 int open_cache_file();
103 void close_cache_file();
104 int load_cache_line();
105 int locate_cache_line(int64_t key);
106 int get_cache_line(int64_t key);
107 int put_cache_line(const char *line);
108 void update_cache_file();
109 void (*get_pixel)(double *pix[3], double rx, double ry,
110 uint8_t **rows, int psz, int iw1, int ih1);
114 int64_t out_position;
116 int64_t ref_position;
118 AffineEngine *affine;
119 Motion51Scan *motion_scan;
121 char cache_line[BCSTRLEN];
122 int64_t cache_key, active_key;
123 int64_t tracking_position;
124 float out_w, out_h, out_r;
126 double rx, ry, rr, rw, rh;
127 float current_dx, current_dy;
128 int x_steps, y_steps, r_steps;
129 double cir_r; int cir_sz;
131 float total_dx, total_dy;
135 class Motion51ScanPackage : public LoadPackage
138 Motion51ScanPackage() {}
139 ~Motion51ScanPackage() {}
142 class Motion51ScanUnit : public LoadClient
145 Motion51ScanUnit(Motion51Scan *server, Motion51Main *plugin);
147 void process_package(LoadPackage *package);
149 Motion51Scan *server;
150 Motion51Main *plugin;
154 class Motion51Scan : public LoadServer
157 Motion51Scan(Motion51Main *plugin, int total_clients, int x_steps, int y_steps);
159 friend class Motion51ScanUnit;
161 Motion51Main *plugin;
166 int x_steps, y_steps;
167 double bx, by, br, bw, bh;
169 double *rpix[3], rpwr[3];
170 double rctr_v[3], rctr_x[3], rctr_y[3];
171 double *ref_real[3], *ref_imag[3];
172 double cor_value, value;
173 double dx_result, dy_result, dt_result;
175 void init_packages();
176 LoadClient *new_client() { return new Motion51ScanUnit(this, plugin); }
177 LoadPackage *new_package() { return new Motion51ScanPackage(); }
178 void scan(VFrame *ref, VFrame *cur, int sz);
179 double compare(double cx, double cy, double ct);
182 class Motion51VVFrame : public VFrame
185 Motion51VVFrame(VFrame *vfrm, int n);
186 int draw_pixel(int x, int y);