Log in

View Full Version : Example plugins for Vapoursynth


thewebchat
19th October 2012, 15:08
Download link. (https://github.com/sekrit-twc/VSExamples)

Here are some simple plugin examples for vapoursynth. Included are:

vsmatrix -- do arbitrary affine transformations on RGB/YUV triplets
vsrandom -- generate normally distributed random numbers

These examples show one way of supporting extended colorspaces in VapourSynth without duplicating large blocks of code. More practically, vsmatrix may be used to convert between Rec.601 and Rec.709 matrix coefficients, as documented in matrix_conversions.txt.

Both plugins support all sample types allowed by VapourSynth. Performance is quite reasonable as well, at 16 ms/frame for vsmatrix and 45 ms/frame for vsrand at 1920x1080x8bpp.

Note that I've never written a line of code in my life before this, so please excuse any errors (but feel free to note them).

SassBot
19th October 2012, 15:53
What's the license on the code? Also, the vsmatrix is nice although am I reading your code correctly in that it requires you to pass in the coefficients manually? I'm considering now to just take your code and extend it a bit and just make that the new ColorMatrix base and throw away the other code completely.

thewebchat
19th October 2012, 16:54
The filter is derived from invert_example.cpp from Vapoursynth, so therefore it has the same license as Vapoursynth.

thewebchat
15th November 2012, 20:29
Updated examples for Vapoursynth R15 API.

Mug Funky
16th November 2012, 02:23
what do i need to make these compile in MSYS?

i'm getting piles of errors about _malloc type stuff.


$ make
g++ -std=c++11 -Wall -Wextra -Wno-unused-parameter -O3 -shared -g vsmatrix.cpp -o vsmatrix.dylib
In file included from vsmatrix.cpp:3:0:
VapourSynth/VSHelper.h: In function 'T* vs_aligned_malloc(size_t, size_t)':
VapourSynth/VSHelper.h:48:44: error: there are no arguments to '_aligned_malloc' that depend on a template parameter, so a declaration of '_aligned_malloc' must be available [-fpermissive]
VapourSynth/VSHelper.h:48:44: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
VapourSynth/VSHelper.h: In function 'void vs_aligned_free(void*)':
VapourSynth/VSHelper.h:58:2: error: '_aligned_free' was not declared in this scope
make: *** [vsmatrix.dylib] Error 1

Chikuzen
16th November 2012, 02:37
g++ -o vsmatrix.dll -shared -std=c++11 -Wall -Wextra -Wno-unused-parameter -O3 -g0 -Wl,--dll,--add-stdcall-alias vsmatrix.cpp

maybe, this is OK.

EDIT:
hmm, VSHelper.h does not consider about mingw.


@@ -32,6 +32,11 @@
#define inline _inline
#endif

+#ifdef __MINGW32__
+#define __MSVCRT_VERSION__ 0x0700
+#include <malloc.h>
+#endif
+
#ifdef _WIN32
#define VS_ALIGNED_MALLOC(pptr, size, alignment) *(pptr) = _aligned_malloc((size), (alignment))
#define VS_ALIGNED_FREE(ptr) _aligned_free((ptr))


you need this patch for VSHelper.h

Mug Funky
16th November 2012, 04:11
that's done the trick! thanks muchly!

Myrsloik
16th November 2012, 16:21
g++ -o vsmatrix.dll -shared -std=c++11 -Wall -Wextra -Wno-unused-parameter -O3 -g0 -Wl,--dll,--add-stdcall-alias vsmatrix.cpp

maybe, this is OK.

EDIT:
hmm, VSHelper.h does not consider about mingw.


@@ -32,6 +32,11 @@
#define inline _inline
#endif

+#ifdef __MINGW32__
+#define __MSVCRT_VERSION__ 0x0700
+#include <malloc.h>
+#endif
+
#ifdef _WIN32
#define VS_ALIGNED_MALLOC(pptr, size, alignment) *(pptr) = _aligned_malloc((size), (alignment))
#define VS_ALIGNED_FREE(ptr) _aligned_free((ptr))


you need this patch for VSHelper.h

Partially applied since malloc.h should be included for all windows compilation. The mingw specific crt version to target is something probably best defined on the command line when compiling and won't be added.

thewebchat
11th December 2012, 02:16
Added a (slow) method of directly computing random numbers instead of looking it up in a giant LUT. If someone is actually interested in using this, I may consider adding functionality to actually put noise on a frame.

sl1pkn07
18th October 2013, 22:49
the link is dead

greetings

Reel.Deel
18th October 2013, 23:32
the link is dead

Here (https://www.dropbox.com/s/updihf3gipg8uhj/VSExamples_r3.tar.gz) you go.

If someone is actually interested in using this, I may consider adding functionality to actually put noise on a frame.

Hmmm, must of missed this.
Would be nice to have an AddGrain (http://forum.doom9.org/showthread.php?t=111849) equivalent for VS.

sl1pkn07
18th October 2013, 23:36
tnx man!

greetings