View Full Version : Help overriding a plugin function
kumi
12th March 2007, 00:02
Hello,
I wish to override MPEG2Source() so all function calls _add_ one parameter. Now, I understand that I can put function MPEG2Source (...){} in an .avsi for auto-loading purposes, and I've also read the AviSynth Wrapper wiki page (http://avisynth.org/index.php?page=Wrapper). But I'm still not sure how to keep all of the original calling arguments.
Specifically, I just want all calls to MPEG2Source() to contain info=3. This script, for example...
LoadPlugin("c:\dgdecode.dll")
MPEG2Source("c:\blah.d2v", idct=7)
...should be processed like this:
LoadPlugin("c:\dgdecode.dll")
MPEG2Source("c:\blah.d2v", idct=7, info=3)
I think someone posted an example of this sort of override recently, but searching yielded nothing. Anyone have a clue?
Terranigma
12th March 2007, 00:04
I'd like to know how too. I was going to ask neuron2 if he could add options to dgmpgdec for ipp, cpu, and the info parameters; so we can set them as default, but never got around to doing it. :rolleyes:
foxyshadis
12th March 2007, 00:48
function MPEG2Source(string file, int idct, etc...) {
info=default(info,3)
MPEG2Source(file,idct,upconv,info,etc....)
}
Then if you really need the original, you can still use dgdecode_mpeg2source().
This might not work with regular plugins, I know you can pass undefined vars to script functions, but I've never tried it with a plugin.
davidhorman
12th March 2007, 01:04
I just gave that a try (mpeg2source within a function called mpeg2source) and, somewhat unsurprisingly, AviSynth died and took VirtualDub with it.
I assumed when I read it that AviSynth would try and recursively call the script function mpeg2source, and never call the plugin. I don't know if that's what's actually happening, but it doesn't like it.
David
kumi
12th March 2007, 01:10
I can't get it to work either. The function isn't being overridden... this script displays the .d2v video, not the ColorBars():
function MPEG2Source(string "d2v", int "idct", int "cpu", bool "iPP", int "moderate_h", int "moderate_v", string "cpu2", int "upConv", bool "iCC", bool "i420", int "info", bool "showQ", bool "fastMC") {
return ColorBars()
}
LoadPlugin("C:\Program Files\dgmpgdec\DGDecode.dll")
MPEG2Source("G:\temp\VTS_01_1.d2v", idct=7)
EDIT: I'm puzzled... according to http://avisynth.org/AviSynthPlugins a UDF always takes top priority:
The order in which function names take precedence is as follows:
1. user-defined function (always have the highest priority)
2. plugin-function (have higher priority than built-in functions - they will override a built-in function)
3. built-in function
Terranigma
12th March 2007, 01:14
d2v = "C:\DGIndex\dmpgdec\video.d2v"
MPEG2Source(d2v, idct, cpu, iPP, moderate_h, moderate_v, cpu2, upConv, iCC, i420, info, showQ, fastMC)
Would this be similar?
foxyshadis
12th March 2007, 02:00
Guess you'll have to settle for recompiling, then. =\
(Oh yeah, and specifying dgdecode_mpeg2source in the function would probably stop it from dying, at least, sorry about that...)
kumi
12th March 2007, 02:28
Well it definetely is possible to override at least some plugin functions. This one overrides ColorMatrix successfully:
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\ColorMatrix\ColorMatrix.dll")
function ColorMatrix (clip, string "mode", int "source", int "dest", int "scaling", bool "interlaced", bool "hints", string "d2v", bool "debug", int "threads", int "thrdmthd", int "opt") {
return ColorBars()
}
ColorMatrix()
But this one...
LoadPlugin("C:\Program Files\dgmpgdec\DGDecode.dll")
function MPEG2Source(string "d2v", int "idct", int "cpu", bool "iPP", int "moderate_h", int "moderate_v", string "cpu2", int "upConv", bool "iCC", bool "i420", int "info", bool "showQ", bool "fastMC") {
return ColorBars()
}
MPEG2Source()
...gives me this: http://img221.imageshack.us/img221/9333/mpeg2sourceerroren3.jpg
:confused:
gzarkadas
12th March 2007, 17:54
This one works:
LoadPlugin("DGDecode.dll")
function MPEG2Source(clip c, string "d2v", int "cpu", int "idct", bool "iPP", \
int "moderate_h", int "moderate_v", bool "showQ", bool "fastMC", string "cpu2", \
int "info", int "upConv", bool "i420", bool "iCC")
{
return ColorBars()
}
return MPEG2Source(BlankClip())
I believe that the reason MPEG2Source override does not work without the additional argument is that all of its arguments are optional (Colormatrix has one mandatory argument). The later, if correct, must have to do with the way Lookup or/and TypeMatch in avisynth.cpp are coded.
kumi
12th March 2007, 18:24
Thanks for the confirmation gzarkadas. I'll just have to make do without MPEG2Source() overriding. :mad:
foxyshadis
12th March 2007, 19:35
I just gave this an actual try, since I'm already in AVSp:
function MPEG2Source(string d2v, int "cpu", int "idct", bool "iPP", \
int "moderate_h", int "moderate_v", bool "showQ", bool "fastMC", string "cpu2", \
int "info", int "upConv", bool "i420", bool "iCC")
{
info=default(info,1)
upconv=default(upconv,2)
return dgdecode_MPEG2Source(d2v,cpu,idct,ipp,moderate_h,moderate_v,showq,fastmc,cpu2,info,upconv,i420,icc)
}
MPEG2source("d:\Sample.demuxed.d2v")
info
This gives me RGB and info as expected, so the overriding is definitely happening. Try again. Maybe it needs 2.5.7, also. It works whether d2v is required or optional (it's required in the plugin itself).
kumi
12th March 2007, 21:43
Hi foxyshadis:
I can't replicate your results. I tried your script with AviSynth 2.56, and no override. I then uninstalled 2.56 completely, installed 2.57, and tried it again. Still no override.
Maybe it has to do with DGDecode.dll; what version are you using? I tried both 1.4.5 and 1.4.7 with no luck.
thanks
EDIT: OK, I see what's happening. If I use LoadPlugin("dgdecode.dll"), the override doesn't happen. If I put DGDecode.dll in my autoloading plugins folder, it does override.
Is there no way to get overriding working without having the .dll in the autoload folder?
EDIT2: In answer to my question, yes there is. If you Import() an .AVS with the function override before the MPEG2Source() call, it works. It does not work, however, if you try and let it autoload as an .AVSI file.
OVERRIDE FAIL:
Import("C:\Program Files\AviSynth 2.5\plugins\dgdecode_ovr.avs")
LoadPlugin("C:\Program Files\dgmpgdec 1.4.5\DGDecode.dll")
MPEG2source("D:\DVDRB WORKING\D2VAVS\V01.D2V")
info
OVERRIDE SUCCESS:
LoadPlugin("C:\Program Files\dgmpgdec 1.4.5\DGDecode.dll")
Import("C:\Program Files\AviSynth 2.5\plugins\dgdecode_ovr.avs")
MPEG2source("D:\DVDRB WORKING\D2VAVS\V01.D2V")
info
OVERRIDE FAIL:
LoadPlugin("C:\Program Files\dgmpgdec 1.4.5\DGDecode.dll")
MPEG2source("D:\DVDRB WORKING\D2VAVS\V01.D2V")
Import("C:\Program Files\AviSynth 2.5\plugins\dgdecode_ovr.avs")
info
OVERRIDE FAIL:
LoadPlugin("C:\Program Files\dgmpgdec 1.4.5\DGDecode.dll")
function MPEG2Source(string d2v, int "cpu", int "idct", bool "iPP", \
int "moderate_h", int "moderate_v", bool "showQ", bool "fastMC", string "cpu2", \
int "info", int "upConv", bool "i420", bool "iCC")
{
info=default(info,1)
upconv=default(upconv,2)
return DGDecode_MPEG2Source(d2v,cpu,idct,ipp,moderate_h,moderate_v,showq,fastmc,cpu2,info,upconv,i420,icc)
}
MPEG2source("D:\DVDRB WORKING\D2VAVS\V01.D2V")
info
So you either have to depend on an autoloaded .DLL and not use loadplugin(), or explicitely Import() an .AVS with the function definition before the MPEG2Source() call.
Unfortunately this is all useless for me, since I wanted to use this with the Filter Editor of DVD Rebuilder. That program inserts everything after the call to MPEG2Source().
Oh well :p
foxyshadis
12th March 2007, 21:54
No, the script is parsed before LoadPlugin() is executed, but Loadplugin also runs before Import. Priority is Builtin->Autoload->Autoload script->user-defined function->manual load plugin->imported function. In other words, put it in a separate avs and Import() it. I haven't tested LoadPlugin in an Imported script, but I'm sure it recursively follows the same path.
I'll see if I can get the docs modified to make that clear.
kumi
12th March 2007, 22:09
Hi foxyshadis:
I just edited my post with my results with Import(). There's nothing I can do if I'm limited to the DVD Rebuilder Filter Editor, right? That only lets you add stuff after the MPEG2Source() call.
foxyshadis
12th March 2007, 22:23
The fun part of parser quirks. Well.... you could add another MPEG2Source after it. I don't think avisynth will complain. :p Especially if they always have the same name, that won't be too bad.
kumi
12th March 2007, 22:34
Hmm OK, I think I'll just give up then. Thanks for helping foxyshadis!
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.