View Full Version : vcfreq a plugin for vapoursynth
vcmohan
22nd November 2014, 12:53
vcfreq is a plugin for vapoursynth. It operates in frequency domain to filter out certain types of regular noises. A large range of cascading filters can be specified.
The functions available in this plugin are
1.F1Quiver
2.F2Quiver
Full description of this plugin is at vcfreq (http://www.avisynth.nl/users/vcmohan/vcfreq/vcfreq.html)
This plugin requires a fftw3f.3.dl (http://www.avisynth.nl/users/vcmohan/libfftw3f-3.zip)l to be present in path. Currently works in windows only.
Comments, suggestions are welcome
feisty2
17th February 2016, 14:55
is there some memory leak in the plugin?
the plugin consumed almost all 16GB of the RAM of my computer as the processing went on and then terminated by the OS...
feisty2
18th February 2016, 11:18
@vcmohan
I tried to fix the memory leak but...
can't even compile the untouched source code, there're like.. errors everywhere...
some tips to make it work plz?
vcmohan
18th February 2016, 12:30
Sorry for that. Is it that all functions in it have memory leak or did you try a particular one. If so can you give the script used?
Offhand I can see one possible problem. vcfreq assumes the number of cpus to be the number of threads active. This is communicated to the fftw3 dll.
feisty2
18th February 2016, 13:05
I've only used vcfreq.Sharp so far cuz I need to perform a deconvolution..
the script's just
core.vcfreq.Sharp (clip, line=0, wn=0.99, x=1, y=1, fr=25, scale=0.0059)
vspipe kept consuming RAM right from the very first frame and crashed around frame 2800 on a GrayS 720x576 vid as there was no more RAM left..
vcmohan
19th February 2016, 13:36
I have uploaded the corrected version of vcfreq plugin. Please check if it is working ok. These were compiled on 201m community visual studio compiler.
feisty2
19th February 2016, 15:15
:thanks::thanks:
the new version works!
sl1pkn07
19th February 2016, 17:27
any chance for can be builded on linux?
greetings
Myrsloik
17th August 2016, 18:52
Here's my modified source and x64 dll (https://www.dropbox.com/s/eyhceb84txhw90z/vcfreq_src_x64.7z?dl=1) that should be compilable on linux if you have a float fftw3 lying around. I didn't test it though. Report your findings and so on. Just done as a 30 min code stabbing session while eating dinner.
Changes:
Removes the loadlibrary loading of fftw3 and instead uses the official fftw3.h
Replaced all homegrown pi constants with the more accurate M_PI
Removed all unused variables where it was obvious no use was ever intended
Fixed an extreme number of type conversion warnings, some of them by making sure all calculations stay in float precision
And can someone check this piece of code?
void pointNotchFilter2D( float * freqFilter, int* spec, int ht, int wd)
{
// point centered notch filter
float xf = spec[2] * wd / (NYQUIST);
float yf = spec[3] * ht / (NYQUIST );
int degree = 2 * spec[4];
// calculate notch radial sqr
float d0sq = sqrt (xf*xf + yf*yf);
d0sq = (ht * ht + wd * wd)/ 4;
It looks very suspect. Like it should be multiplied or divided or something instead of the first value assigned to d0sq just being discarded.
sl1pkn07
17th August 2016, 19:25
with GCC:
In file included from vcfreq.cpp:66:0:
FQSharphelper.cpp: In function 'void getRealInput(float*, const finc*, int, int, int, int, int, int, bool)':
FQSharphelper.cpp:251:30: error: too many arguments to function 'int getSign(int)'
data1[ w] = getSign( h, w) * fptr1[w];
^
FQSharphelper.cpp:217:5: note: declared here
int getSign(int i)
^
FQSharphelper.cpp: In function 'void getRealOutput(float*, finc*, int, int, int, int, int, bool, finc, finc)':
FQSharphelper.cpp:319:39: error: too many arguments to function 'int getSign(int)'
int val = data1[ w] * getSign(h, w);
^
FQSharphelper.cpp:217:5: note: declared here
int getSign(int i)
^
FQSharphelper.cpp: In instantiation of 'void getRealInput(float*, const finc*, int, int, int, int, int, int, bool) [with finc = unsigned char]':
FQBlur.cpp:254:78: required from here
FQSharphelper.cpp:251:24: error: too many arguments to function 'int getSign(int)'
data1[ w] = getSign( h, w) * fptr1[w];
^
FQSharphelper.cpp:217:5: note: declared here
int getSign(int i)
^
FQSharphelper.cpp: In instantiation of 'void getRealOutput(float*, finc*, int, int, int, int, int, bool, finc, finc) [with finc = unsigned char]':
FQBlur.cpp:267:51: required from here
FQSharphelper.cpp:319:34: error: too many arguments to function 'int getSign(int)'
int val = data1[ w] * getSign(h, w);
^
FQSharphelper.cpp:217:5: note: declared here
int getSign(int i)
^
FQSharphelper.cpp: In instantiation of 'void getRealInput(float*, const finc*, int, int, int, int, int, int, bool) [with finc = short unsigned int]':
FQBlur.cpp:278:80: required from here
FQSharphelper.cpp:251:24: error: too many arguments to function 'int getSign(int)'
data1[ w] = getSign( h, w) * fptr1[w];
^
FQSharphelper.cpp:217:5: note: declared here
int getSign(int i)
^
FQSharphelper.cpp: In instantiation of 'void getRealOutput(float*, finc*, int, int, int, int, int, bool, finc, finc) [with finc = short unsigned int]':
FQBlur.cpp:291:51: required from here
FQSharphelper.cpp:319:34: error: too many arguments to function 'int getSign(int)'
int val = data1[ w] * getSign(h, w);
^
FQSharphelper.cpp:217:5: note: declared here
int getSign(int i)
^
FQSharphelper.cpp: In instantiation of 'void getRealInput(float*, const finc*, int, int, int, int, int, int, bool) [with finc = float]':
FQBlur.cpp:302:80: required from here
FQSharphelper.cpp:251:24: error: too many arguments to function 'int getSign(int)'
data1[ w] = getSign( h, w) * fptr1[w];
^
FQSharphelper.cpp:217:5: note: declared here
int getSign(int i)
^
FQSharphelper.cpp: In instantiation of 'void getRealOutput(float*, finc*, int, int, int, int, int, bool, finc, finc) [with finc = float]':
FQBlur.cpp:316:51: required from here
FQSharphelper.cpp:319:34: error: too many arguments to function 'int getSign(int)'
int val = data1[ w] * getSign(h, w);
^
FQSharphelper.cpp:217:5: note: declared here
int getSign(int i)
^
make: *** [Makefile:2: all] Error 1
with clang
In file included from vcfreq.cpp:66:
./FQSharphelper.cpp:251:17: error: no matching function for call to 'getSign'
data1[ w] = getSign( h, w) * fptr1[w];
^~~~~~~
./FQSharphelper.cpp:217:5: note: candidate function not viable: requires single argument 'i', but 2 arguments were provided
int getSign(int i)
^
./FQSharphelper.cpp:319:27: error: no matching function for call to 'getSign'
int val = data1[ w] * getSign(h, w);
^~~~~~~
./FQSharphelper.cpp:217:5: note: candidate function not viable: requires single argument 'i', but 2 arguments were provided
int getSign(int i)
^
2 errors generated.
make: *** [Makefile:2: all] Error 1
note: #include "FQSharpHelper.cpp" -> #include "FQSharphelper.cpp" in vcfreq.cpp (case sensitive)
Myrsloik
17th August 2016, 19:38
I think I've fixed that now. Redownload and try again. I think the other overload was declared too late or something.
sl1pkn07
17th August 2016, 19:45
done.
now build ok in linux ^o^
vcmohan
19th August 2016, 12:50
And can someone check this piece of code?
void pointNotchFilter2D( float * freqFilter, int* spec, int ht, int wd)
{
// point centered notch filter
float xf = spec[2] * wd / (NYQUIST);
float yf = spec[3] * ht / (NYQUIST );
int degree = 2 * spec[4];
// calculate notch radial sqr
float d0sq = sqrt (xf*xf + yf*yf);
d0sq = (ht * ht + wd * wd)/ 4;
It looks very suspect. Like it should be multiplied or divided or something instead of the first value assigned to d0sq just being discarded.Thanks for pointing out problematic code. Sorry when I uploaded the revised dll in May I missed to upload the updated source. I have done that now. Yes instead of the included lte file
the official fftw3 header can be used, but I found it to be so difficult to understand started using Fizik's lte version with suitable modifications.
As regards numerous warnings, yes I am guilty and lazy. Thankful for correcting.
StainlessS
19th August 2016, 15:17
yes I am guilty and lazy
As are we all, we are all here a consortium of individuals all at common purpose.
Sometimes we dont make mistakes, sometimes we do, but, every time we advance
and take from what we have learnt, thank you VC Mohan, you really are pretty good, when
not making mistakes, and that is what really counts :)
EDIT: Big Kiss vc, XXX. http://www.cosgan.de/images/smilie/liebe/d040.gif
EDIT: I picture myself as the one on the left, and you being the girly one on the right (with the blue hair, whats with that?)
I think your character is way too aggressive, I feel maybe that I'm being abused, please control yourself.
KingLir
7th March 2017, 11:51
Here's my modified source and x64 dll (https://dl.dropboxusercontent.com/u/73468194/vcfreq_src_x64.7z)
Changes:
Removes the loadlibrary loading of fftw3 and instead uses the official fftw3.h
Replaced all homegrown pi constants with the more accurate M_PI
Removed all unused variables where it was obvious no use was ever intended
Fixed an extreme number of type conversion warnings, some of them by making sure all calculations stay in float precision
Thanks! This builds OK also on macOS with the following:
gcc -c -fPIC ${CFLAGS} ${CPPFLAGS} -I. $(pkg-config --cflags vapoursynth) -o main.o vcfreq.cpp
g++ -dynamiclib -undefined suppress -flat_namespace *.o -o libvcfreq.dylib
sl1pkn07
16th December 2017, 21:13
the link is down @mirsloik
Chthon
8th April 2018, 05:04
Please kindly repost the fixed-for-linux source code.
Are_
9th April 2018, 01:03
https://www.dropbox.com/s/fyid7xne75zs9kl/vapoursynth-vcfreq-2016.08.17.tar.bz2
Chthon
9th April 2018, 13:07
Thank you Are_ .
Edit: A few notes for anyone else trying to compile:
1. Looking at the newer source on the official page, it looks likes vc's fix for the issue pointed out in post #9 is to comment out both lines. This seems fine, since the variable is unused anyway.
2. It looks like there's another bug. The for loop at the bottom of Factorize.cpp is missing its {}s. I *think* the closing brace should go on line 52 (???).
3. libfftw3f_threads is a dependency (at least for the fixed version). If you don't link it at compile time, core.vcfreq.Sharp() will crash with an undefined symbol error for fftwf_init_threads.
4. I was able to compile with
g++ -Wall -shared -fPIC -I. -L/usr/local/lib/vsplugins/lib -lfftw3f_threads -o libvcfreq.so vcfreq.cpp
after copying the vapoursynth headers into the working directory.
(My libfftw3f_threads.so is in usr/local/lib/vsplugins/lib; adjust accordingly.)
Myrsloik
9th April 2018, 13:19
I updated my old and broken dropbox link. Not sure if I really want to fork the project since I'd have basically no time to maintain it anyway. Would be a shame if the changes were lost tough...
Chthon
9th April 2018, 15:49
I updated my old and broken dropbox link. Not sure if I really want to fork the project since I'd have basically no time to maintain it anyway. Would be a shame if the changes were lost tough...
I don't suppose you could figure out what to do with that for loop in Factorize.cpp? I'm having a lot of trouble following the code's intent well enough to be sure about that close bracket's placement.
foxyshadis
10th April 2018, 05:50
2. It looks like there's another bug. The for loop at the bottom of Factorize.cpp is missing its {}s. I *think* the closing brace should go on line 52 (???).
No bug there, implicit braces around the following block, the if.
The bigger problem is that with oddball resolutions it'll turn into an infinite loop, and zero bounds checking means you can get memory corruption if you have an overly factorizable resolution -- though even 8k resolutions would probably be safe.
Mug Funky
27th November 2019, 01:29
Thank you Are_ .
Edit: A few notes for anyone else trying to compile:
1. Looking at the newer source on the official page, it looks likes vc's fix for the issue pointed out in post #9 is to comment out both lines. This seems fine, since the variable is unused anyway.
2. It looks like there's another bug. The for loop at the bottom of Factorize.cpp is missing its {}s. I *think* the closing brace should go on line 52 (???).
3. libfftw3f_threads is a dependency (at least for the fixed version). If you don't link it at compile time, core.vcfreq.Sharp() will crash with an undefined symbol error for fftwf_init_threads.
4. I was able to compile with
g++ -Wall -shared -fPIC -I. -L/usr/local/lib/vsplugins/lib -lfftw3f_threads -o libvcfreq.so vcfreq.cpp
after copying the vapoursynth headers into the working directory.
(My libfftw3f_threads.so is in usr/local/lib/vsplugins/lib; adjust accordingly.)
i'm trying to do this today as i have a client's footage with LED lighting that has caused wiblly-wobbly phasey-wasey effects with the camera's rolling shutter.
no matter how i poke that g++ line, i'm still getting crash with "undefined symbol: fftwf_init_threads".
running python 3.6, ubuntu 18.04
Are_
27th November 2019, 01:53
With this line too?:
g++ -Wall -shared -fPIC -I. $(pkg-config --cflags vapoursynth) $(pkg-config --libs fftw3f_threads) -o libvcfreq.so vcfreq.cpp
And you have fftw correctly installed? v3.x.x one?
Mug Funky
28th November 2019, 03:00
i have fftw3f installed (pkg-config shows ver 3.3.7), but that line fails saying fftw3f_threads is not around. is this a custom package?
[edit]
also i wasn't aware of vapoursynth having pkg-config abilities. i've just been copying the files... i'm not a developer, just a tinkerer unfortunately
Are_
28th November 2019, 04:25
I don't know much about Ubuntu, but make sure you have libfftw3-dev installed, if that still doesn't work try this line instead:
g++ -Wall -shared -fPIC -I. $(pkg-config --cflags vapoursynth) -lfftw3f_threads -lfftw3f -o libvcfreq.so vcfreq.cpp
Mug Funky
28th November 2019, 10:00
thanks, but so far still no fun:
vsedit: symbol lookup error: /usr/lib/x86_64-linux-gnu/vapoursynth/libvcfreq.so: undefined symbol: fftwf_init_threads
and output of ldd:
$ ldd libvcfreq.so
linux-vdso.so.1 (0x00007ffd582ad000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f21a6676000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f21a62d8000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f21a5ee7000)
/lib64/ld-linux-x86-64.so.2 (0x00007f21a6c16000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f21a5ccf000)
[edit]
it seems like maybe libfftw3f_threads is a separate package that ubuntu doesn't include in it's repos. i've googled a bit but my google game must be off because i haven't found anything relevant
[edit]
ok i have all the libfftw files with the _threads variants. what's the dealio? should a properly functioning libvcfreq.so show a link to fftw in the ldd results?
Are_
28th November 2019, 15:20
The library is supposed to be installed by libfftw3-dev (https://launchpad.net/ubuntu/bionic/amd64/libfftw3-dev/3.3.7-1), but the package seems to be missing the pkg-conf part, thats why I suggested you to not use it.
It should show with ldd:
$ ldd /usr/lib64/vapoursynth/libvcfreq.so
linux-vdso.so.1 (0x00007ffe1373e000)
libfftw3f_threads.so.3 => /usr/lib64/libfftw3f_threads.so.3 (0x00007fc3564ed000)
libfftw3f.so.3 => /usr/lib64/libfftw3f.so.3 (0x00007fc3561e4000)
libc.so.6 => /lib64/libc.so.6 (0x00007fc356012000)
libm.so.6 => /lib64/libm.so.6 (0x00007fc355ed4000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fc355eb1000)
/lib64/ld-linux-x86-64.so.2 (0x00007fc356560000)
Maybe try this, if this doesn't work I think I will be out of ideas :(
g++ -Wall -shared -fPIC -I. $(pkg-config --cflags vapoursynth) -L/usr/lib/x86_64-linux-gnu -lfftw3f_threads -lfftw3f -o libvcfreq.so vcfreq.cpp
Mug Funky
28th November 2019, 18:21
i'm now wondering whether libpthread isn't the problem, but that's just weird as most apps are multithreaded and i regularly build ffmpeg and darktable from git without them spitting chips at me (and they use all cores).
the only pthreaddy package ubuntu seems to use is libpthread-stubs because apparently linux just sort of supports all the pthread functions as standard in glibc?
i hate dependency hell.
i'm tempted to just ask for your libvcfreq.so and just see if it runs here...
Mug Funky
28th November 2019, 22:42
this line has got ldd showing pthreads, but still no sign of fftw3f_threads:
g++ -shared -fPIC -I. $(pkg-config --cflags gthread-2.0) -I/usr/include -o libvcfreq.so vcfreq.cpp
Are_
28th November 2019, 22:58
Here you have, vcfreq compiled with GCC 9.2.0 (https://www.dropbox.com/s/b6p92d8i9wk7q8n/vapoursynth-vcfreq-2016.08.17.tar.xz?dl=0) with "g++ -march=x86-64 -msse2 -O2 -Wall -shared -fPIC -I. $(pkg-config --cflags vapoursynth) $(pkg-config --libs fftw3f_threads) -o libvcfreq.so vcfreq.cpp" command line. Good luck.
Mug Funky
29th November 2019, 02:10
sadly this did not work as is.
i'm trying to build fftw3 now to a safe prefix and linking to that, but still it's not cooperating.
when i set it to -static the errors are telling - all of them complain about fftw3
Are_
29th November 2019, 03:23
I knew it was going to be something silly, try this out because I'm pretty sure it's going to work:
g++ -msse2 -O2 -Wall -shared -fPIC -I. $(pkg-config --cflags vapoursynth) -o libvcfreq.so vcfreq.cpp -lfftw3f_threads -lfftw3f
[EDIT]
And this vcfreq library (https://www.dropbox.com/s/jdoscdj5vbg06fe/vapoursynth-vcfreq-2016.08.17-Ubuntu-18.04.tar.xz?dl=0) should work on your system too.
Mug Funky
29th November 2019, 13:00
ok that line worked and the plugin seems to be working too.
did i really just need to link both libfftw3f and libfftw3f_threads to make it work? what a wild ride that was.
Are_
29th November 2019, 13:14
Not only that, they had to be in the correct place in de command line, it worked anywhere with my compiler but not in the one Ubuntu comes... nonsense. :p
Mug Funky
29th November 2019, 23:51
this is why i like a good configure script and makefile...
stefanmathiasson
12th May 2020, 10:12
I managed to compile vcfreq with
gcc -c -fPIC ${CFLAGS} ${CPPFLAGS} -I. $(pkg-config --cflags vapoursynth) -o main.o vcfreq.cpp
g++ -dynamiclib -undefined suppress -flat_namespace *.o -o libvcfreq.dylib
and the files linked in post #18 (https://forum.doom9.org/showpost.php?p=1838949&postcount=18). vcfreq loads fine, but crashes VapourSynth immediately when I try to preview anything, no matter if I try to use F1Quiver, Sharp etc. It's similar to the problems described in post #5 (https://forum.doom9.org/showpost.php?p=1757689&postcount=5), but I think that Issue was fixed in the Dropbox files? Where any of you able to successfully run it on OSX or am I missing something here?
Any help appreciated!
Myrsloik
12th May 2020, 10:17
I managed to compile vcfreq with
gcc -c -fPIC ${CFLAGS} ${CPPFLAGS} -I. $(pkg-config --cflags vapoursynth) -o main.o vcfreq.cpp
g++ -dynamiclib -undefined suppress -flat_namespace *.o -o libvcfreq.dylib
and the files linked in post #18 (https://forum.doom9.org/showpost.php?p=1838949&postcount=18). vcfreq loads fine, but crashes VapourSynth immediately when I try to preview anything, no matter if I try to use F1Quiver, Sharp etc. It's similar to the problems described in post #5 (https://forum.doom9.org/showpost.php?p=1757689&postcount=5), but I think that Issue was fixed in the Dropbox files? Where any of you able to successfully run it on OSX or am I missing something here?
Any help appreciated!
I'm afraid you're going to have to learn how to debug... the hard way.
I certainly never tested the code outside windows.
It works fine on Linux.
I think this is a miss-compilation issue. These are my flags for reference:
gcc -c -fPIC -shared -std=c++11 -O3 -march=native -pipe -Wl,-O1 -Wl,--as-needed -I. -I/usr/include/vapoursynth -o vcfreq.o vcfreq.cpp
gcc -shared -fPIC -lfftw3f_threads -lfftw3f -Wl,-O1 -Wl,--as-needed -O3 -march=native -pipe -o libvcfreq.so vcfreq.o
As a clear issue I see you didn't link with libfftw3f.
stefanmathiasson
12th May 2020, 14:48
I'm afraid you're going to have to learn how to debug... the hard way.
I certainly never tested the code outside windows.
Thanks! Would love to be able to use vcfreq, so I'll give it a shot.
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.