/* * Cinelerra :: Blue Banana - color modification plugin for Cinelerra-CV * Copyright (C) 2012-2013 Monty * * 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 #include #include #include "bluebanana.h" #include "bluebananaconfig.h" #include "language.h" static float halfsin2(float x){ if(x<-M_PI/2)return 0; if(x>M_PI/2)return 1; return .5+.5*sin(x); } static float scale_gamma (float hdel, float lo, float hi, float gamma){ lo /= 100.; hi /= 100.; // apply gamma if(hdel<0){ /* this is contrived, so do something that looks good */ /* poor man's tangent */ hdel *= pow(.001,1/gamma)*1000; }else{ hdel = pow(hdel,1/gamma); } // apply range scaling return hdel*(hi-lo)+lo; } static int select_setup(char *pattern, int change){ int n = 0; if(change){ float gsq = change*change+1.1; int x = -1; int y = abs(change); while(1){ while( x*x+y*y < gsq){ x--; if(n==FSrange*4){ fprintf(stderr,_("Internal error; pattern array overflow\n")); return n; } pattern[n++]=(change>0 ? 'H' : 'h'); } if(!y)break; y--; if(n==FSrange*4){ fprintf(stderr,_("Internal error; pattern array overflow\n")); return n; } pattern[n++]=(change>0 ? 'V' : 'v'); } } return n; } void BluebananaMain::update_lookups(int serverside){ // compare config contents with current lookup table state. Update // as needed. int i; // Alpha lookup table for hue selection if(lookup_cache.Hsel_lo != config.Hsel_lo || lookup_cache.Hsel_hi != config.Hsel_hi || lookup_cache.Hsel_over != config.Hsel_over){ float scale = M_PI/(config.Hsel_over+.0000001); for(i=0; i4.f)val=4.f; float bin; float del = modff(val*ADJUST_LOOKUP_SCALE,&bin); return lookup[(int)bin]*(1.f-del)+lookup[(int)bin+1]*del; } }