Log in

View Full Version : Multiple calls of same LoadPlugin()?


kypec
13th July 2010, 21:53
Can anybody tell me if it is alright to include same plugin more than once in a script?
I'm asking this because currently I'm trying to split my rather long chains of processing (in one big AVS) into separate smaller AVS files which would be Imported into main script (individual user functions in each AVS)
Example:
script A contains LoadPlugin("DePan.dll")
function funcA() {some code that needs DePan.dll}
script B contains LoadPlugin("DePan.dll")
function funcB() {other code that needs DePan.dll}
main script using both functionsImport("scriptA.avs")
Import("scriptB.avs")
funcA()
funcB()
Will Avisynth automatically recognize that same plugin has already been loaded and thus ignores the following loads? Or will it hog the memory with another copy of DLL?

Another problem I encounter is when using different versions of a plugin which use same functions.
Example:
script A contains LoadPlugin("RepairSSE2.dll")
function funcA() {some code that calls Repair function}
script B contains LoadPlugin("RepairSSE3.dll")
function funcB() {other code that calls identically named Repair function}
Which version of Repair function would be called in latter script? The one from SSE2 or the other from SSE3?

IanB
13th July 2010, 23:28
Yes Avisynth tracks the HMODULE values returned from the LoadLibrary() calls, so loading the same .dll multiple times is okay.

When overloading functions the most recent has priority. Previous versions of the function are available by their alternate name, DllName_FunctionName().

So RepairSSE2_Repair() and RepairSSE3_Repair() remain distinct but Repair() will be overloaded to be the same as RepairSSE3_Repair()

kypec
14th July 2010, 22:20
Thanks for exhaustive explanation IanB, perfectly understandable and expected from programmer's point of view.