add x10tv ati remote rework, android remote rework, wintv remote tweaks
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / affine.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008-2014 Adam Williams <broadcast at earthling dot net>
5  *
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.
10  *
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.
15  *
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
19  *
20  */
21
22 #ifndef AFFINE_H
23 #define AFFINE_H
24
25
26 #include "affine.inc"
27 #include "loadbalance.h"
28 #include "vframe.inc"
29
30 // Affine transform library
31
32 #define AFFINE_OVERSAMPLE 2
33
34 class AffineMatrix
35 {
36 public:
37         AffineMatrix();
38         void identity();
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 // in x1,y1 x2,y1  out x1,y1  x2,y2
46 //    x1,y2 x2,y2      x3,y3  x4,y4
47         void set_matrix(double in_x1, double in_y1, double in_x2, double in_y2,
48                 double out_x1, double out_y1, double out_x2, double out_y2,
49                 double out_x3, double out_y3, double out_x4, double out_y4);
50         void transform_point(float x, float y, float *newx, float *newy);
51         double determinant();
52         void dump();
53         double values[3][3];
54 };
55
56 class AffinePackage : public LoadPackage
57 {
58 public:
59         AffinePackage();
60         int y1, y2;
61 };
62
63 class AffineUnit : public LoadClient
64 {
65 public:
66         AffineUnit(AffineEngine *server);
67         void process_package(LoadPackage *package);
68 //      float transform_cubic(float dx, float jm1, float j, float jp1, float jp2);
69         AffineEngine *server;
70 };
71
72 class AffineEngine : public LoadServer
73 {
74 public:
75         AffineEngine(int total_clients,
76                 int total_packages);
77
78 // Range of coords is 0 to 100 for coordinates in the image.
79 // The coordinate locations are clockwise around the image.
80         void process(VFrame *output, VFrame *input, VFrame *temp, int mode,
81                 float x1, float y1, float x2, float y2,
82                 float x3, float y3, float x4, float y4,
83                 int forward);
84         void set_matrix(
85                 double in_x1, double in_y1, double in_x2, double in_y2,
86                 double out_x1, double out_y1, double out_x2, double out_y2,
87                 double out_x3, double out_y3, double out_x4, double out_y4);
88 // Do rotation with the affine/perspective transform.
89 // This removes some of the extremely faint artifacts in the trig rotation.
90         void rotate(VFrame *output, VFrame *input, float angle);
91 // Set the viewport to transform.  The transform is based on the input viewport.
92 // The output viewport clips the transformed output.
93         void set_in_viewport(int x, int y, int w, int h);
94 // Only used by motion tracker.  Not used in OpenGL.
95         void set_out_viewport(int x, int y, int w, int h);
96
97 // Set the viewport for both input and output.  Removed in HV 4.5.
98 // Compatibility function introduced to avoid having to rewrite old
99 // plugins.  Should be removed when no plugin uses it any more.
100         void set_viewport(int x, int y, int w, int h);
101 // For rotation, set the pivot point.  Also affects output in OpenGL.
102 // The default is in the middle of the viewport.
103         void set_in_pivot(int x, int y);
104 // Set the pivot point in the output.  Only used by motion tracker.
105         void set_out_pivot(int x, int y);
106 // Set the pivot point for both input and output.  Removed in HV 4.5.
107 // Compatibility function introduced to avoid having to rewrite old
108 // plugins.
109         void set_pivot(int x, int y);
110 // Never used
111         void unset_pivot();
112         void unset_viewport();
113 // default: AF_CUBIC
114         void set_interpolation(int type);
115 // To use OpenGL for the processing, set to 1
116         void set_opengl(int value);
117         void init_packages();
118         LoadClient* new_client();
119         LoadPackage* new_package();
120
121
122         VFrame *input, *output, *temp;
123         int mode;
124         enum {
125                 PERSPECTIVE,
126                 SHEER,
127                 STRETCH,
128                 ROTATE,
129 // multiply directly by a matrix.
130                 TRANSFORM
131         };
132         int interpolation;
133         enum {
134                 AF_DEFAULT,
135                 AF_NEAREST,
136                 AF_LINEAR,
137                 AF_CUBIC,
138                 AF_MODES
139         };
140
141 // arbitrary matrix
142         AffineMatrix matrix;
143 // Transformation coordinates
144         float x1, y1, x2, y2, x3, y3, x4, y4;
145 // Viewport coordinates
146         int in_x, in_y, in_w, in_h;
147         int out_x, out_y, out_w, out_h;
148 // Pivot coordinates
149         int in_pivot_x, in_pivot_y;
150         int out_pivot_x, out_pivot_y;
151         int user_in_pivot;
152         int user_out_pivot;
153         int user_in_viewport;
154         int user_out_viewport;
155         int forward;
156         int use_opengl;
157         int total_packages;
158 };
159
160
161
162 #endif