remove whitespace at eol
[goodguy/history.git] / cinelerra-5.1 / plugins / polar / polar.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 POLAR_H
23 #define POLAR_H
24
25 #define MAXDEPTH 100
26 #define MAXANGLE 360
27
28 class PolarMain;
29 class PolarEngine;
30
31 #include "bcbase.h"
32 #include "polarwindow.h"
33 #include "pluginvclient.h"
34
35
36 class PolarMain : public PluginVClient
37 {
38 public:
39         PolarMain(int argc, char *argv[]);
40         ~PolarMain();
41
42 // required for all realtime plugins
43         PLUGIN_CLASS_MEMBERS(PolarConfig)
44         int process_realtime(long size, VFrame **input_ptr, VFrame **output_ptr);
45         int plugin_is_realtime();
46         int plugin_is_multi_channel();
47         int save_data(char *text);
48         int read_data(char *text);
49
50 // parameters needed
51         int reconfigure();    // Rebuild tables
52         int depth;
53         int angle;
54         int polar_to_rectangular;
55         int backwards;
56         int inverse;
57         int automated_function;
58         int reconfigure_flag;
59         VFrame *temp_frame;
60
61
62 private:
63         PolarEngine **engine;
64 };
65
66 class PolarEngine : public Thread
67 {
68 public:
69         PolarEngine(PolarMain *plugin, int start_y, int end_y);
70         ~PolarEngine();
71
72         int start_process_frame(VFrame **output, VFrame **input, int size);
73         int wait_process_frame();
74         void run();
75         void get_pixel(const int &x, const int &y, VPixel *pixel, VPixel **input_rows);
76         int calc_undistorted_coords(int wx,
77                          int wy,
78                          double &x,
79                          double &y);
80         inline VWORD bilinear(double &x, double &y, VWORD *values)
81         {
82                 double m0, m1;
83                 x = fmod(x, 1.0);
84                 y = fmod(y, 1.0);
85
86                 if(x < 0.0) x += 1.0;
87                 if(y < 0.0) y += 1.0;
88
89                 m0 = (double)values[0] + x * ((double)values[1] - values[0]);
90                 m1 = (double)values[2] + x * ((double)values[3] - values[2]);
91                 return (VWORD)(m0 + y * (m1 - m0));
92         }
93
94         PolarMain *plugin;
95         int start_y;
96         int end_y;
97         int size;
98         double cen_x, cen_y;
99         VFrame **output, **input;
100         int last_frame;
101         Mutex input_lock, output_lock;
102 };
103
104
105 #endif