Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
13th November 2005, 18:22 | #1 | Link |
Errant Knight
Join Date: Oct 2004
Location: St Louis, M0 US
Posts: 364
|
Help with (“$Plugin!Functionname!Param$“)
Hello,
I could use some more help, please. Trying to collect the data returned by the statement. Code:
AVSValue myobject = env->GetVar(“$Plugin!Functionname!Param$“) Using “myobject.AsString()” crashes. The other “AsString(const char* def)” is beyond me, I do not understand what argument should be passed to AsString(???). Can some one please explain or provide an example. I have a alpha demo of FilmCutter with an external function pick list you can find here:http://forum.doom9.org/showthread.ph...073#post737073 Thanks a lot in advance. Eobtron http://members.aol.com/avsfilmcutter |
14th November 2005, 17:12 | #3 | Link | |
AviSynth plugger
Join Date: Nov 2003
Location: Russia
Posts: 2,183
|
My question about this:
http://forum.doom9.org/showthread.ph...098#post729098 Quote:
|
|
14th November 2005, 20:05 | #4 | Link |
AviSynth plugger
Join Date: Nov 2003
Location: Russia
Posts: 2,183
|
I found the bug in avisynth.cpp. Here is part of the code.
I commented old code and adde new. Code:
char temp[1024] = "$Plugin!"; strcat(temp, name); strcat(temp, "!Param$"); // env->SetGlobalVar(env->SaveString(temp, 8+strlen(name)+7+1), AVSValue(params)); // it does not work (null param) env->SetGlobalVar(env->SaveString(temp, 8+strlen(name)+7+1), AVSValue(f->param_types)); // Fizick if (alt_name) { strcpy(temp, "$Plugin!"); strcat(temp, alt_name); strcat(temp, "!Param$"); env->SetGlobalVar(env->SaveString(temp, 8+strlen(alt_name)+7+1), AVSValue(f->param_types)); } http://www.avisynth.org/fizick/temp/avisynth.dll IanB, please put the fix to 2.5.7 alpha (after checking my code) I am still afraid put anything to CVS. |
14th November 2005, 21:13 | #5 | Link |
Errant Knight
Join Date: Oct 2004
Location: St Louis, M0 US
Posts: 364
|
Hi all,
Fizick, You fixed it, ( $Plugin!Functionname!Param$ ) returns Function params for both internal and external functions. See here:http://members.aol.com/avsfilmcutter...on_Params.html Above link broken @Fizick, what is up with all the caps? Did I miss 2.5.6 going final I have been very busy. Fantastic Fizick, great catch. Now I can work on params helper, for externals too. Ebobtron http://members.aol.com/avsfilmcutter Last edited by Ebobtron; 10th October 2006 at 05:27. |
14th November 2005, 21:46 | #6 | Link |
AviSynth plugger
Join Date: Nov 2003
Location: Russia
Posts: 2,183
|
Ebobtron,
Go ahead, Internal functions are work in 2.5.6 release right now, I hope my bugfix will be in 2.5.7 for external plugins too. I see in your list, that my functions params are longest, but Peach is not short too. |
14th November 2005, 22:02 | #8 | Link | ||
Errant Knight
Join Date: Oct 2004
Location: St Louis, M0 US
Posts: 364
|
Quote:
Quote:
ebt http://members.aol.com/avsfilmcutter |
||
17th April 2010, 01:00 | #11 | Link |
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,431
|
I know this thread is several years old, but it holds the key to a mysterious problem affecting AvsP (and potentially other applications too).
It turns out Fizick's code in post #4 above (incorporated in FunctionTable::AddFunction) has a subtle error. When writing a plugin function's parameter types to the corresponding AVS variable, a copy of the string pointer in f->param_types is saved. However, the string addressed by this pointer is freed the first time a function in the plugin is called (when FunctionTable::Lookup calls RemovePlugin after reloading the plugin), so the value of the AVS variable is likely to be corrupted soon afterwards. If an application processes the string after this point, it will see garbage. With AvsP, this can occur if a function from an auto-loaded plugin is called from an auto-loaded .avsi file, eg global AviSynthPluginsDir = GetWorkingDir() It shows up as AvsP producing an error message "Error parsing <xxx> plugin parameters: unknown character <x>". The symptoms have been reported several times in the past (eg here, here, and just recently here), but never properly understood till now. The solution (as usual!) is to use SaveString when writing the parameter string to the AVS variable, ie Code:
env->SetGlobalVar(env->SaveString(temp, 8+strlen(name)+7+1), AVSValue(f->param_types)); // Fizick Code:
env->SetGlobalVar(env->SaveString(temp, 8+strlen(name)+7+1), AVSValue(env->SaveString(f->param_types))); // Gavino ;) Incidentally, it seems to me that this entire scheme has a basic flaw in it. Avisynth allows overloaded function names (two or more functions with the same name, but different parameters). However, the $Plugin!name!Param$ string can only store one set of parameters, the last one processed for a given function name overwrites any previous one. Is this intended? (Another puzzling thing during auto-loading is that LoadPluginsMatching("*.vdf") is called, but this only ever calls LoadPlugin, not LoadVirtualdubPlugin. ) Last edited by Gavino; 17th April 2010 at 01:34. Reason: Formatting |
17th April 2010, 03:26 | #12 | Link |
Avisynth Developer
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
|
Well spotted. I got rid of all the _strdups/frees so all the names and arglists are now SaveString'd.
Yes function list and args exporting is pretty gross. Maybe we can define a new better one. The LoadPluginsMatching("*.vdf") is probably a leftover from someone's misguided attempt to autoload VDub plugins. Maybe I should remove it. When loading VFAPI and VDub plugins you need to provide a function name. Doh! |
17th April 2010, 09:55 | #13 | Link |
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,431
|
Another oddity is that, as well as saving plugin function names in $PluginFunctions$, internal function names are saved in $InternalFunctions$, but their parameter types are saved in $Plugin!name!Param$, contradicting post#3 above.
|
|
|