/* * wave.c -- wave filter * Author: Leny Grisel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "filter_wave.h" #include #include #include #include #include // this is a utility function used by DoWave below static uint8_t getPoint(uint8_t *src, int w, int h, int x, int y, int z) { if (x<0) x+=-((-x)%w)+w; else if (x>=w) x=x%w; if (y<0) y+=-((-y)%h)+h; else if (y>=h) y=y%h; return src[(x+y*w)*4+z]; } // the main meat of the algorithm lies here static void DoWave(uint8_t *src, int src_w, int src_h, uint8_t *dst, mlt_position position, int speed, int factor, int deformX, int deformY) { register int x, y; int decalY, decalX, z; float amplitude, phase, pulsation; register int uneven = src_w % 2; int w = (src_w - uneven ) / 2; amplitude = factor; pulsation = 0.5 / factor; // smaller means bigger period phase = position * pulsation * speed / 10; // smaller means longer for (y=0;yprocess = filter_process; mlt_properties_set( MLT_FILTER_PROPERTIES( this ), "start", arg == NULL ? "10" : arg); mlt_properties_set( MLT_FILTER_PROPERTIES( this ), "speed", arg == NULL ? "5" : arg); mlt_properties_set( MLT_FILTER_PROPERTIES( this ), "deformX", arg == NULL ? "1" : arg); mlt_properties_set( MLT_FILTER_PROPERTIES( this ), "deformY", arg == NULL ? "1" : arg); } return this; }