dvb chan tuner api upgrade, slip/ripple handle drag keyfrm fix, load menu tweaks
[goodguy/cinelerra.git] / cinelerra-5.1 / guicast / rotateframe.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 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 ROTATEFRAME_H
23 #define ROTATEFRAME_H
24
25 #include "condition.inc"
26 #include "thread.h"
27 #include "vframe.inc"
28
29 class RotateEngine;
30
31 typedef struct
32 {
33         float x, y;
34 } SourceCoord;
35
36 class RotateFrame
37 {
38 public:
39         RotateFrame(int cpus, int width, int height);
40         ~RotateFrame();
41
42 // angle is 0 - 360
43         void rotate(VFrame *output,
44                 VFrame *input,
45                 double angle,
46                 int interpolate);
47         int rotate_rightangle(VFrame *input,
48                 VFrame *output,
49                 int angle);
50         int rotate_obliqueangle(VFrame *input,
51                 VFrame *output,
52                 double angle,
53                 int interpolate);
54         int get_rightdimensions(VFrame *frame,
55                 int &diameter,
56                 int &in_x1,
57                 int &in_y1,
58                 int &in_x2,
59                 int &in_y2,
60                 int &out_x1,
61                 int &out_y1,
62                 int &out_x2,
63                 int &out_y2);
64
65         int cpus;
66         RotateEngine **engine;
67 // Matrix of source pixel offsets
68         int *int_matrix, **int_rows;
69 // Interpolation uses input coordinates for each output coordinate.
70         SourceCoord *float_matrix, **float_rows;
71         VFrame *output, *input;
72         int interpolate;
73         int last_interpolate;
74 // Compare new angle with old angle
75         double last_angle;
76         double angle;
77 };
78
79
80 class RotateEngine : public Thread
81 {
82 public:
83         RotateEngine(RotateFrame *plugin, int row1, int row2);
84         ~RotateEngine();
85
86         int generate_matrix(int interpolate);
87         int perform_rotation(VFrame *input,
88                 VFrame *output,
89                 int interpolate);
90         int wait_completion();
91         int create_matrix();
92         int coords_to_pixel(int &input_y, int &input_x);
93         int coords_to_pixel(SourceCoord &float_pixel, float &input_y, float &input_x);
94         int perform_rotation();
95         void run();
96
97         int row1, row2;
98         int interpolate;
99         int do_matrix, do_rotation;
100         int done;
101         RotateFrame *plugin;
102         Condition *input_lock;
103         Condition *output_lock;
104         VFrame *output;
105         VFrame *input;
106 };
107
108 #endif