X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fplugins%2Fpolar%2Fpolar.C;h=3c8ba7a6cbda6388677724e24732b0c7f6b1d22b;hb=c5feedfabe3ee87dfae9a254c9b67c566ec15d2e;hp=1752588e029012b3d8c3b57ca7babe93041fa216;hpb=30bdb85eb33a8ee7ba675038a86c6be59c43d7bd;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/plugins/polar/polar.C b/cinelerra-5.1/plugins/polar/polar.C index 1752588e..3c8ba7a6 100644 --- a/cinelerra-5.1/plugins/polar/polar.C +++ b/cinelerra-5.1/plugins/polar/polar.C @@ -2,21 +2,21 @@ /* * CINELERRA * Copyright (C) 2008 Adam Williams - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * + * */ #include "bcdisplayinfo.h" @@ -51,12 +51,12 @@ public: void copy_from(PolarConfig &src); int equivalent(PolarConfig &src); - void interpolate(PolarConfig &prev, - PolarConfig &next, - long prev_frame, - long next_frame, + void interpolate(PolarConfig &prev, + PolarConfig &next, + long prev_frame, + long next_frame, long current_frame); - + int polar_to_rectangular; float depth; float angle; @@ -170,10 +170,10 @@ int PolarConfig::equivalent(PolarConfig &src) return EQUIV(this->angle, src.angle) && EQUIV(this->depth, src.depth); } -void PolarConfig::interpolate(PolarConfig &prev, - PolarConfig &next, - long prev_frame, - long next_frame, +void PolarConfig::interpolate(PolarConfig &prev, + PolarConfig &next, + long prev_frame, + long next_frame, long current_frame) { double next_scale = (double)(current_frame - prev_frame) / (next_frame - prev_frame); @@ -189,11 +189,11 @@ void PolarConfig::interpolate(PolarConfig &prev, PolarWindow::PolarWindow(PolarEffect *plugin) - : PluginClientWindow(plugin, - 270, - 100, - 270, - 100, + : PluginClientWindow(plugin, + 270, + 100, + 270, + 100, 0) { this->plugin = plugin; @@ -219,12 +219,12 @@ void PolarWindow::create_objects() PolarDepth::PolarDepth(PolarEffect *plugin, int x, int y) - : BC_FSlider(x, - y, + : BC_FSlider(x, + y, 0, 200, - 200, - (float)1, + 200, + (float)1, (float)100, plugin->config.depth) { @@ -242,13 +242,13 @@ int PolarDepth::handle_event() PolarAngle::PolarAngle(PolarEffect *plugin, int x, int y) - : BC_FSlider(x, - y, + : BC_FSlider(x, + y, 0, 200, - 200, - (float)1, - (float)360, + 200, + (float)1, + (float)360, plugin->config.angle) { this->plugin = plugin; @@ -270,19 +270,19 @@ PolarEffect::PolarEffect(PluginServer *server) need_reconfigure = 1; temp_frame = 0; engine = 0; - + } PolarEffect::~PolarEffect() { - + if(temp_frame) delete temp_frame; if(engine) delete engine; } -const char* PolarEffect::plugin_title() { return _("Polar"); } +const char* PolarEffect::plugin_title() { return N_("Polar"); } int PolarEffect::is_realtime() { return 1; } @@ -354,17 +354,14 @@ int PolarEffect::process_realtime(VFrame *input, VFrame *output) { if(input->get_rows()[0] == output->get_rows()[0]) { - if(!temp_frame) temp_frame = new VFrame(0, - -1, - input->get_w(), - input->get_h(), - input->get_color_model(), - -1); + if(!temp_frame) + temp_frame = new VFrame(input->get_w(), input->get_h(), + input->get_color_model(), 0); temp_frame->copy_from(input); this->input = temp_frame; } - - + + if(!engine) engine = new PolarEngine(this, PluginClient::smp + 1); engine->process_packages(); @@ -440,18 +437,18 @@ static int calc_undistorted_coords(int wx, { if(wy > cen_y) { - phi = M_PI - - atan(((double)(wx - cen_x)) / + phi = M_PI - + atan(((double)(wx - cen_x)) / ((double)(wy - cen_y))); - r = sqrt(SQR(wx - cen_x) + + r = sqrt(SQR(wx - cen_x) + SQR(wy - cen_y)); } - else + else if(wy < cen_y) { - phi = atan(((double)(wx - cen_x)) / + phi = atan(((double)(wx - cen_x)) / ((double)(cen_y - wy))); - r = sqrt(SQR(wx - cen_x) + + r = sqrt(SQR(wx - cen_x) + SQR(cen_y - wy)); } else @@ -460,24 +457,24 @@ static int calc_undistorted_coords(int wx, r = wx - cen_x; } } - else + else if(wx < cen_x) { if(wy < cen_y) { - phi = 2 * M_PI - + phi = 2 * M_PI - atan(((double)(cen_x -wx)) / ((double)(cen_y - wy))); - r = sqrt(SQR(cen_x - wx) + + r = sqrt(SQR(cen_x - wx) + SQR(cen_y - wy)); } - else + else if(wy > cen_y) { - phi = M_PI + - atan(((double)(cen_x - wx)) / + phi = M_PI + + atan(((double)(cen_x - wx)) / ((double)(wy - cen_y))); - r = sqrt(SQR(cen_x - wx) + + r = sqrt(SQR(cen_x - wx) + SQR(wy - cen_y)); } else @@ -488,15 +485,15 @@ static int calc_undistorted_coords(int wx, } if (wx != cen_x) { - m = fabs(((double)(wy - cen_y)) / + m = fabs(((double)(wy - cen_y)) / ((double)(wx - cen_x))); } else { m = 0; } - - if(m <= ((double)(y2 - y1) / + + if(m <= ((double)(y2 - y1) / (double)(x2 - x1))) { if(wx == cen_x) @@ -515,7 +512,7 @@ static int calc_undistorted_coords(int wx, ymax = cen_y - y1; xmax = ymax / m; } - + rmax = sqrt((double)(SQR(xmax) + SQR(ymax))); t = ((cen_y - y1) < (cen_x - x1)) ? (cen_y - y1) : (cen_x - x1); @@ -535,7 +532,7 @@ static int calc_undistorted_coords(int wx, xi = (int)(x_calc + 0.5); yi = (int)(y_calc + 0.5); - + if(WITHIN(0, xi, w - 1) && WITHIN(0, yi, h - 1)) { x = x_calc; @@ -556,7 +553,7 @@ static int calc_undistorted_coords(int wx, phi = (2 * M_PI) * (wx - x1) / xdiff; phi = fmod (phi + angl, 2 * M_PI); - + if(phi >= 1.5 * M_PI) phi2 = 2 * M_PI - phi; else @@ -573,7 +570,7 @@ static int calc_undistorted_coords(int wx, m = (double)1.0 / xx; else m = 0; - + if(m <= ((double)(ydiff) / (double)(xdiff))) { if(phi2 == 0) @@ -592,9 +589,9 @@ static int calc_undistorted_coords(int wx, ymax = ym - y1; xmax = ymax / m; } - + rmax = sqrt((double)(SQR(xmax) + SQR(ymax))); - + t = ((ym - y1) < (xm - x1)) ? (ym - y1) : (xm - x1); rmax = (rmax - t) / 100.0 * (100 - circle) + t; @@ -603,7 +600,7 @@ static int calc_undistorted_coords(int wx, r = rmax * (double)((wy - y1) / (double)(ydiff)); else r = rmax * (double)((y2 - wy) / (double)(ydiff)); - + xx = r * sin (phi2); yy = r * cos (phi2); @@ -632,9 +629,9 @@ static int calc_undistorted_coords(int wx, xi = (int)(x_calc + 0.5); yi = (int)(y_calc + 0.5); - - if(WITHIN(0, xi, w - 1) && - WITHIN(0, yi, h - 1)) + + if(WITHIN(0, xi, w - 1) && + WITHIN(0, yi, h - 1)) { x = x_calc; y = y_calc; @@ -747,7 +744,7 @@ void PolarUnit::process_package(LoadPackage *package) double cy; double cen_x = (double)(w - 1) / 2.0; double cen_y = (double)(h - 1) / 2.0; - + switch(plugin->input->get_color_model()) { case BC_RGB_FLOAT: