00001 #ifndef WHIRL_H
00002 #define WHIRL_H
00003
00004 #define MAXANGLE 360
00005 #define MAXPINCH 100
00006 #define MAXRADIUS 100
00007
00008 class WhirlMain;
00009 class WhirlEngine;
00010
00011 #include "bcbase.h"
00012 #include "whirlwindow.h"
00013 #include "pluginvclient.h"
00014
00015
00016 class WhirlMain : public PluginVClient
00017 {
00018 public:
00019 WhirlMain(int argc, char *argv[]);
00020 ~WhirlMain();
00021
00022
00023 int process_realtime(long size, VFrame **input_ptr, VFrame **output_ptr);
00024 int plugin_is_realtime();
00025 int plugin_is_multi_channel();
00026 char* plugin_title();
00027 int start_realtime();
00028 int stop_realtime();
00029 int start_gui();
00030 int stop_gui();
00031 int show_gui();
00032 int hide_gui();
00033 int set_string();
00034 int load_defaults();
00035 int save_defaults();
00036 int save_data(char *text);
00037 int read_data(char *text);
00038
00039
00040 int reconfigure();
00041 int angle;
00042 int pinch;
00043 int radius;
00044 int automated_function;
00045 int reconfigure_flag;
00046 VFrame *temp_frame;
00047
00048
00049 WhirlThread *thread;
00050
00051 private:
00052 BC_Hash *defaults;
00053 WhirlEngine **engine;
00054 };
00055
00056 class WhirlEngine : public Thread
00057 {
00058 public:
00059 WhirlEngine(WhirlMain *plugin, int start_y, int end_y);
00060 ~WhirlEngine();
00061
00062 int start_process_frame(VFrame **output, VFrame **input, int size);
00063 int wait_process_frame();
00064 void run();
00065
00066 int calc_undistorted_coords(double wx,
00067 double wy,
00068 double &whirl,
00069 double &pinch,
00070 double &x,
00071 double &y);
00072 inline VWORD bilinear(double x, double y, VWORD *values)
00073 {
00074 double m0, m1;
00075 x = fmod(x, 1.0);
00076 y = fmod(y, 1.0);
00077
00078 if(x < 0.0) x += 1.0;
00079 if(y < 0.0) y += 1.0;
00080
00081 m0 = (double)values[0] + x * ((double)values[1] - values[0]);
00082 m1 = (double)values[2] + x * ((double)values[3] - values[2]);
00083 return (VWORD)(m0 + y * (m1 - m0));
00084 }
00085 void get_pixel(const int &x, const int &y, VPixel *pixel, VPixel **input_rows);
00086
00087 WhirlMain *plugin;
00088 int start_y;
00089 int end_y;
00090 int size;
00091 VFrame **output, **input;
00092 int last_frame;
00093 Mutex input_lock, output_lock;
00094 double radius, radius2, radius3, pinch;
00095 double scale_x, scale_y;
00096 double cen_x, cen_y;
00097 };
00098
00099
00100 #endif