edl plugin names eng, fix segv for opengl brender, renderfarm rework strategy, perf...
[goodguy/history.git] / cinelerra-5.1 / plugins / whirl / whirl.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 WHIRL_H
23 #define WHIRL_H
24
25 #define MAXANGLE 360
26 #define MAXPINCH 100
27 #define MAXRADIUS 100
28
29 class WhirlMain;
30 class WhirlEngine;
31
32 #include "bcbase.h"
33 #include "whirlwindow.h"
34 #include "pluginvclient.h"
35
36
37 class WhirlMain : public PluginVClient
38 {
39 public:
40         WhirlMain(int argc, char *argv[]);
41         ~WhirlMain();
42
43 // required for all realtime plugins
44         int process_realtime(long size, VFrame **input_ptr, VFrame **output_ptr);
45         int plugin_is_realtime();
46         int plugin_is_multi_channel();
47         const char* plugin_title();
48         int start_realtime();
49         int stop_realtime();
50         PluginClientWindow* new_window();
51         int save_data(char *text);
52         int read_data(char *text);
53
54 // parameters needed
55         int reconfigure();    // Rebuild tables
56         int angle;
57         int pinch;
58         int radius;
59         int automated_function;
60         int reconfigure_flag;
61         VFrame *temp_frame;
62
63
64 private:
65         WhirlEngine **engine;
66 };
67
68 class WhirlEngine : public Thread
69 {
70 public:
71         WhirlEngine(WhirlMain *plugin, int start_y, int end_y);
72         ~WhirlEngine();
73
74         int start_process_frame(VFrame **output, VFrame **input, int size);
75         int wait_process_frame();
76         void run();
77
78         int calc_undistorted_coords(double  wx,
79                          double wy,
80                          double &whirl,
81                          double &pinch,
82                          double &x,
83                          double &y);
84         inline VWORD bilinear(double x, double y, VWORD *values)
85         {
86                 double m0, m1;
87                 x = fmod(x, 1.0);
88                 y = fmod(y, 1.0);
89
90                 if(x < 0.0) x += 1.0;
91                 if(y < 0.0) y += 1.0;
92
93                 m0 = (double)values[0] + x * ((double)values[1] - values[0]);
94                 m1 = (double)values[2] + x * ((double)values[3] - values[2]);
95                 return (VWORD)(m0 + y * (m1 - m0));
96         }
97         void get_pixel(const int &x, const int &y, VPixel *pixel, VPixel **input_rows);
98
99         WhirlMain *plugin;
100         int start_y;
101         int end_y;
102         int size;
103         VFrame **output, **input;
104         int last_frame;
105         Mutex input_lock, output_lock;
106         double radius, radius2, radius3, pinch;
107         double scale_x, scale_y;
108         double cen_x, cen_y;
109 };
110
111
112 #endif