4 * Copyright (C) 2008-2014 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
27 #include "loadbalance.h"
30 // Affine transform library
32 #define AFFINE_OVERSAMPLE 2
39 void translate(double x, double y);
40 void scale(double x, double y);
41 // Result is put in dst
42 void multiply(AffineMatrix *dst);
43 void copy_from(AffineMatrix *src);
44 void invert(AffineMatrix *dst);
45 void transform_point(float x, float y, float *newx, float *newy);
51 class AffinePackage : public LoadPackage
58 class AffineUnit : public LoadClient
61 AffineUnit(AffineEngine *server);
62 void process_package(LoadPackage *package);
63 void calculate_matrix(
76 AffineMatrix *result);
77 // float transform_cubic(float dx, float jm1, float j, float jp1, float jp2);
81 class AffineEngine : public LoadServer
84 AffineEngine(int total_clients,
87 // Range of coords is 0 to 100 for coordinates in the image.
88 // The coordinate locations are clockwise around the image.
89 void process(VFrame *output, VFrame *input, VFrame *temp, int mode,
90 float x1, float y1, float x2, float y2,
91 float x3, float y3, float x4, float y4,
93 // Do rotation with the affine/perspective transform.
94 // This removes some of the extremely faint artifacts in the trig rotation.
95 void rotate(VFrame *output, VFrame *input, float angle);
96 void set_matrix(AffineMatrix *matrix);
97 // Set the viewport to transform. The transform is based on the input viewport.
98 // The output viewport clips the transformed output.
99 void set_in_viewport(int x, int y, int w, int h);
100 // Only used by motion tracker. Not used in OpenGL.
101 void set_out_viewport(int x, int y, int w, int h);
103 // Set the viewport for both input and output. Removed in HV 4.5.
104 // Compatibility function introduced to avoid having to rewrite old
105 // plugins. Should be removed when no plugin uses it any more.
106 void set_viewport(int x, int y, int w, int h);
107 // For rotation, set the pivot point. Also affects output in OpenGL.
108 // The default is in the middle of the viewport.
109 void set_in_pivot(int x, int y);
110 // Set the pivot point in the output. Only used by motion tracker.
111 void set_out_pivot(int x, int y);
112 // Set the pivot point for both input and output. Removed in HV 4.5.
113 // Compatibility function introduced to avoid having to rewrite old
115 void set_pivot(int x, int y);
118 void unset_viewport();
120 void set_interpolation(int type);
121 // To use OpenGL for the processing, set to 1
122 void set_opengl(int value);
123 void init_packages();
124 LoadClient* new_client();
125 LoadPackage* new_package();
128 VFrame *input, *output, *temp;
135 // multiply directly by a matrix.
149 // Transformation coordinates
150 float x1, y1, x2, y2, x3, y3, x4, y4;
151 // Viewport coordinates
152 int in_x, in_y, in_w, in_h;
153 int out_x, out_y, out_w, out_h;
155 int in_pivot_x, in_pivot_y;
156 int out_pivot_x, out_pivot_y;
159 int user_in_viewport;
160 int user_out_viewport;