Log in

View Full Version : AsClip() problems


kassandro
11th February 2004, 10:06
In a forthcoming filter I have severe problems with the AsClip() function. Firstly one cannot specify a default value AsClip(defaultclip), where defaultclip is a PClip lvalue.
Secondly AsClip() does not work with named variables, i.e. I would like to use it as follows: myfilter(clip1, secondclip=clip2). If secondclip is not specified, then the filter should take clip1 as default value. There is no way to implement this kind functionality. I simply cannot understand, why AsClip() is designed so differently from AsBool, AsInt, AsString etc.. This deficiency simply forces me to disable an important feature of my filter.

WarpEnterprises
11th February 2004, 22:10
Did you try to let the variables unasserted and test the array members with IsClip()?

sh0dan
11th February 2004, 22:30
Use IsDefined() before getting the clip as PClip. This will allow you to skip the AsClip() if it is an optional parameter.

Something like this:

PClip c1 = args[0].AsClip()
PClip c2 = args[1].IsDefined() ? args[1].AsClip() : c1;

kassandro
11th February 2004, 23:38
In a much simplified form the situation was as follows:

DLL initialisation:
env->AddFunction("myfilter", "c[secondclip]c", creat_myfilter, 0);

in the function "creat_myfilter" I had the following lines:
PClip clip1 = args[0].AsClip();
PClip clip2 = arg2[1].AsClip(clip1);

These lines were rejected by the compiler, because AsClip() unlike AsInt() dosen't accept any argument. But, sh0dan, your suggestion doesn't work either, because the compiler rejects args[1].IsDefined() and "IsDefined" can't be found anywhere in avisynth.h.

kassandro
11th February 2004, 23:51
Ok, instead of IsDefined() you have to take Defined().
It now works! Thank you!
Nevertheless, to have a uniform design, AsClip() should accept a argument.