3 * Copyright (C) 2020 William Morrow
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 __MOTION_51_H__
22 #define __MOTION_51_H__
30 #include "filexml.inc"
31 #include "keyframe.inc"
32 #include "loadbalance.h"
33 #include "motion51.inc"
34 #include "overlayframe.inc"
35 #include "pluginvclient.h"
41 class Motion51ScanUnit;
42 class Motion51ScanPackage;
44 class Motion51VVFrame;
52 int equivalent(Motion51Config &that);
53 void copy_from(Motion51Config &that);
54 void interpolate(Motion51Config &prev, Motion51Config &next,
55 int64_t prev_frame, int64_t next_frame, int64_t current_frame);
57 float block_x, block_y, block_w, block_h;
60 float horiz_limit, vert_limit, twist_limit;
61 float shake_fade, twist_fade;
64 char tracking_file[BCTEXTLEN];
69 class Motion51Main : public PluginVClient
72 Motion51Main(PluginServer *server);
75 int process_buffer(VFrame **frame, int64_t position, double frame_rate);
76 int is_multichannel();
78 void save_data(KeyFrame *keyframe);
79 void read_data(KeyFrame *keyframe);
81 void reset_sample(int sz, double r);
82 void get_samples(VFrame *img, double *pix[3], double x, double y);
83 void centroid(double *pix[3], double *ctr_v, double *ctr_x, double *ctr_y);
84 void draw_vectors(VFrame *img);
86 int64_t get_ref_position();
87 void update_tracking_cache();
88 int load_tracking_cache(int64_t position);
89 void save_tracking_cache(int64_t position);
91 void match(VFrame *ref, VFrame *cur);
92 int transform_target(int use_opengl);
94 VFrame* new_temp(VFrame *&tmp, VFrame *ref);
96 PLUGIN_CLASS_MEMBERS2(Motion51Config)
98 char cache_file[BCTEXTLEN];
99 FILE *cache_fp, *active_fp;
100 void set_tracking_path();
101 int open_cache_file();
102 void close_cache_file();
103 int load_cache_line();
104 int locate_cache_line(int64_t key);
105 int get_cache_line(int64_t key);
106 int put_cache_line(const char *line);
107 void update_cache_file();
108 void (*get_pixel)(double *pix[3], double rx, double ry,
109 uint8_t **rows, int psz, int iw1, int ih1);
113 int64_t out_position;
115 int64_t ref_position;
117 AffineEngine *affine;
118 Motion51Scan *motion_scan;
120 char cache_line[BCSTRLEN];
121 int64_t cache_key, active_key;
122 int64_t tracking_position;
123 float out_w, out_h, out_r;
125 double rx, ry, rr, rw, rh;
126 float current_dx, current_dy;
127 int x_steps, y_steps, r_steps;
128 double cir_r; int cir_sz;
130 float total_dx, total_dy;
134 class Motion51ScanPackage : public LoadPackage
137 Motion51ScanPackage() {}
138 ~Motion51ScanPackage() {}
141 class Motion51ScanUnit : public LoadClient
144 Motion51ScanUnit(Motion51Scan *server, Motion51Main *plugin);
146 void process_package(LoadPackage *package);
148 Motion51Scan *server;
149 Motion51Main *plugin;
153 class Motion51Scan : public LoadServer
156 Motion51Scan(Motion51Main *plugin, int total_clients, int x_steps, int y_steps);
158 friend class Motion51ScanUnit;
160 Motion51Main *plugin;
165 int x_steps, y_steps;
166 double bx, by, br, bw, bh;
168 double *rpix[3], rpwr[3];
169 double rctr_v[3], rctr_x[3], rctr_y[3];
170 double *ref_real[3], *ref_imag[3];
171 double cor_value, value;
172 double dx_result, dy_result, dt_result;
174 void init_packages();
175 LoadClient *new_client() { return new Motion51ScanUnit(this, plugin); }
176 LoadPackage *new_package() { return new Motion51ScanPackage(); }
177 void scan(VFrame *ref, VFrame *cur, int sz);
178 double compare(double cx, double cy, double ct);
181 class Motion51VVFrame : public VFrame
184 Motion51VVFrame(VFrame *vfrm, int n);
185 int draw_pixel(int x, int y);