View Full Version : Implement not filter, but function
dum
22nd November 2007, 00:38
Guys, tell me please, is it possible (using C++) implement not filter, but just a function, which will return not a clip, but something different: string or integer?
If it is - please tell me how: just point me, how to approach this.
foxyshadis
22nd November 2007, 04:25
Return an AVSValue from the constructor instead of a PClip. A lot of conditional filters are like that, or you can look at, say, the filters in script.cpp in the avisynth source.
Fizick
22nd November 2007, 06:00
there is no plugin example. So, dum, please tell to us when you finish :)
dum
23rd November 2007, 03:43
Return an AVSValue from the constructor instead of a PClip. A lot of conditional filters are like that, or you can look at, say, the filters in script.cpp in the avisynth source.
What dp ypu mean as "return from the constructor"? I do not have a lot of variants, what yo return :) Or you mean creation function like AVSValue __cdecl Create_Filter(AVSValue args, void* user_data, IScriptEnvironment* env)? Where to return then?
And how "script.cpp" can help me? Can you, please, show the exact place to me?
Thank you beforehand.
foxyshadis
23rd November 2007, 06:35
Here's a sample from script.cpp, edited for external use:
AVSValue Sin(AVSValue args, void* user_data, IScriptEnvironment* env) { return sin(args[0].AsFloat()); }
extern "C" __declspec(dllexport) const char* __stdcall
AvisynthPluginInit2(IScriptEnvironment* env) {
env->AddFunction("sin", "f", Sin, 0);
return "sin";
}
You don't even need a class/constructor, come to think of it. Include avisynth.h and that could be a whole plugin right there. (If not a terribly useful one.)
dum
23rd November 2007, 16:11
Thank you.
And for each instance of AviSynth each own instance of plugin will be loaded?
The reason of this question is following - if I have to return string I need to allocate it somewhere else, except the local variable. Now I'm acting like this:
char p[200];
AVSValue Filter(AVSValue args, void* user_data, IScriptEnvironment* env)
{
...
strcpy(p,...);
return p;
}
What will be the most correct solution of such problem, which will keep me away from all probles with multiple instances etc?
dum
23rd November 2007, 17:09
I'm sorry: and there is completely no documentation (I mean, full description or something) for developers, except some commented samples?
tsp
23rd November 2007, 18:48
http://avisynth.org/mediawiki/Filter_SDK
dum
23rd November 2007, 19:31
Thanks, I got, concerning strings, but, nevertheless is it true that for each instance of AviSynth each own instance of plugin will be loaded? So can I leave data in the variable and rely that it will save it till next call?
IanB
23rd November 2007, 22:24
return env->SaveString(p);
See also Start->Programs->"Avisynth 2.5"->"FilterSDK Information" (it's an optional install with Avisynth).
stickboy
25th November 2007, 04:57
http://forum.doom9.org/showthread.php?t=130383
Anyway, a number of my plug-ins have functions that don't return clips, so you can use them as examples.
Fizick
25th November 2007, 12:22
I made several attempts to write non-clip plugin function without success. :( So, I created tutorial how to write non-clip function and placed it to FilterSDK.
http://avisynth.org/mediawiki/Filter_SDK/Non-clip_sample
He who can, does. He who cannot, teaches. :)
George Bernard Shaw, Man and Superman (1903) "Maxims for Revolutionists" http://www.quotationspage.com/quote/290.html
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.