r860: Merge 2.1:
[cinelerra_cv.git] / plugins / polar / polar.h
blob9b64c02f43e0db3e7fe72aff17dbf6ac855cb549
1 #ifndef POLAR_H
2 #define POLAR_H
4 #define MAXDEPTH 100
5 #define MAXANGLE 360
7 class PolarMain;
8 class PolarEngine;
10 #include "bcbase.h"
11 #include "polarwindow.h"
12 #include "pluginvclient.h"
15 class PolarMain : public PluginVClient
17 public:
18 PolarMain(int argc, char *argv[]);
19 ~PolarMain();
21 // required for all realtime plugins
22 int process_realtime(long size, VFrame **input_ptr, VFrame **output_ptr);
23 int plugin_is_realtime();
24 int plugin_is_multi_channel();
25 char* plugin_title();
26 int start_gui();
27 int stop_gui();
28 int show_gui();
29 int hide_gui();
30 int set_string();
31 int load_defaults();
32 int save_defaults();
33 int save_data(char *text);
34 int read_data(char *text);
36 // parameters needed
37 int reconfigure(); // Rebuild tables
38 int depth;
39 int angle;
40 int polar_to_rectangular;
41 int backwards;
42 int inverse;
43 int automated_function;
44 int reconfigure_flag;
45 VFrame *temp_frame;
47 // a thread for the GUI
48 PolarThread *thread;
50 private:
51 BC_Hash *defaults;
52 PolarEngine **engine;
55 class PolarEngine : public Thread
57 public:
58 PolarEngine(PolarMain *plugin, int start_y, int end_y);
59 ~PolarEngine();
61 int start_process_frame(VFrame **output, VFrame **input, int size);
62 int wait_process_frame();
63 void run();
64 void get_pixel(const int &x, const int &y, VPixel *pixel, VPixel **input_rows);
65 int calc_undistorted_coords(int wx,
66 int wy,
67 double &x,
68 double &y);
69 inline VWORD bilinear(double &x, double &y, VWORD *values)
71 double m0, m1;
72 x = fmod(x, 1.0);
73 y = fmod(y, 1.0);
75 if(x < 0.0) x += 1.0;
76 if(y < 0.0) y += 1.0;
78 m0 = (double)values[0] + x * ((double)values[1] - values[0]);
79 m1 = (double)values[2] + x * ((double)values[3] - values[2]);
80 return (VWORD)(m0 + y * (m1 - m0));
83 PolarMain *plugin;
84 int start_y;
85 int end_y;
86 int size;
87 double cen_x, cen_y;
88 VFrame **output, **input;
89 int last_frame;
90 Mutex input_lock, output_lock;
94 #endif