View Full Version : Filter returning float
mg262
31st January 2005, 12:32
Is there any way to create a filter returning a float (or any other type that isn't a clip)? In some sense I'm not really talking about a filter in that it wouldn't return a stream; I just mean something that would compute a property of a clip, like FrameCount().
I can't see anything in AviSynth.h but maybe I'm being blind (wouldn't be the first time!)... if there isn't a way, can anyone think of a workaround more sensible than a dummy filter that dumps the relevant value to a file?
M.
stickboy
31st January 2005, 12:59
All filters return an AVSValue. Usually this AVSValue represents a clip, but it also can be a bool, int, float, or string.
mg262
31st January 2005, 13:47
I'm sorry - I meant plugin, not script filter.
stickboy
31st January 2005, 20:28
Originally posted by mg262
I'm sorry - I meant plugin, not script filter. And I'm talking about plug-ins. You don't use AVSValue structs directly in user-level scripts!AVSValue __cdecl foo(AVSValue args, void* userDataP,
IScriptEnvironment* envP)
{
return AVSValue(1.0); // Return a floating-point value.
}
mg262
31st January 2005, 20:58
Sorry, yes - just found this:
AVSValue __cdecl Create_BlendWeight(AVSValue args, void* user_data, IScriptEnvironment* env) {
return new BlendWeight(
args[0].AsClip(),
args[1].AsInt(0),
env);
}
extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit2(IScriptEnvironment* env) {
env->AddFunction("BlendWeight", "ci", Create_BlendWeight, 0);
Edit: Just missed your edit - anyway, thankyou! Got misled by looking too hard at GenericVideoFilter...
sh0dan
31st January 2005, 22:04
All conditional functions (Averageluma, etc) return ints and floats. This allows them to be used within the conditional filters. Have a look at conditional_functions.cpp (http://cvs.sourceforge.net/viewcvs.py/avisynth2/avisynth/src/filters/conditional/conditional_functions.cpp?rev=1.4&view=auto).
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.