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.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 13th November 2005, 18:22   #1  |  Link
Ebobtron
Errant Knight
 
Ebobtron's Avatar
 
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$“)
So far, for each "!Functionname!" I use, “IsDefined()” and “IsString()” return TRUE;

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
Ebobtron is offline   Reply With Quote
Old 14th November 2005, 00:07   #2  |  Link
Fizick
AviSynth plugger
 
Fizick's Avatar
 
Join Date: Nov 2003
Location: Russia
Posts: 2,183
It seems,
this works for internal functions only.

const char * myobject = env->GetVar("$Plugin!ConverttoYV12!Param$").AsString()
env->ThrowError(myobject);
Fizick is offline   Reply With Quote
Old 14th November 2005, 17:12   #3  |  Link
Fizick
AviSynth plugger
 
Fizick's Avatar
 
Join Date: Nov 2003
Location: Russia
Posts: 2,183
My question about this:

http://forum.doom9.org/showthread.ph...098#post729098

Quote:
Originally Posted by sh0dan
Internal and external (plugin) functions are exported as AviSynth Variables.

$InternalFunctions$ Should contain function names of all internal functions.
$InternalFunctions!Functionname!Param$ Should contain all parameters for each internal function.
$PluginFunctions$ Should contain all plugins.
$Plugin!Functionname!Param$ Should contain all parameters.

Use env->GetVar() to access them.
Can somebody fixed this bug in Avisynth 2.5.7 ?
Fizick is offline   Reply With Quote
Old 14th November 2005, 20:05   #4  |  Link
Fizick
AviSynth plugger
 
Fizick's Avatar
 
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));
    }
Here is fixed avisyth.dll (temporary). Ebobtron, try it.
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.
Fizick is offline   Reply With Quote
Old 14th November 2005, 21:13   #5  |  Link
Ebobtron
Errant Knight
 
Ebobtron's Avatar
 
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.
Ebobtron is offline   Reply With Quote
Old 14th November 2005, 21:46   #6  |  Link
Fizick
AviSynth plugger
 
Fizick's Avatar
 
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.
Fizick is offline   Reply With Quote
Old 14th November 2005, 21:50   #7  |  Link
Fizick
AviSynth plugger
 
Fizick's Avatar
 
Join Date: Nov 2003
Location: Russia
Posts: 2,183
And please remember alternative function names,
such as "defreq_DeFreq"
Fizick is offline   Reply With Quote
Old 14th November 2005, 22:02   #8  |  Link
Ebobtron
Errant Knight
 
Ebobtron's Avatar
 
Join Date: Oct 2004
Location: St Louis, M0 US
Posts: 364
Quote:
Originally Posted by Fizick
Ebobtron,
I see in your list, that my functions params are longest, but Peach is not short too.
Would not be so long if they where smaller.

Quote:
And please remember alternative function names,
such as "defreq_DeFreq"
Da.

ebt
http://members.aol.com/avsfilmcutter
Ebobtron is offline   Reply With Quote
Old 14th November 2005, 22:12   #9  |  Link
Fizick
AviSynth plugger
 
Fizick's Avatar
 
Join Date: Nov 2003
Location: Russia
Posts: 2,183
Uppercase names is not important, you may use lowcase instead.
avisynth is not case-sensetive.
Fizick is offline   Reply With Quote
Old 15th November 2005, 05:56   #10  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,168
@Fizick,

Nice one, I will upload the fix in my next batch to CVS
IanB is offline   Reply With Quote
Old 17th April 2010, 01:00   #11  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,380
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
should be
Code:
  env->SetGlobalVar(env->SaveString(temp, 8+strlen(name)+7+1),
                    AVSValue(env->SaveString(f->param_types))); // Gavino ;)
and similarly for f2->param_types.

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
Gavino is offline   Reply With Quote
Old 17th April 2010, 03:26   #12  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,168
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!
IanB is offline   Reply With Quote
Old 17th April 2010, 09:55   #13  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,380
Quote:
Originally Posted by IanB View Post
Yes function list and args exporting is pretty gross.
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.
Gavino is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:02.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.