View Full Version : usage of new avisynth interface version 5 (linker errors on AVS_Linkage)
jordanh
1st June 2013, 11:13
Hey there!
I just posted the question how to free the memory in 2.5.x..
Well, one of the options is obviously to port to 2.6 or interface version 6.
Unfortunately i didnt find any filter or similar where i can look how to use 2.6...
The first problem is that the compiler complains about non linked stuff:
error LNK2001: non resolved symbol ""struct AVS_Linkage const * const AVS_linkage" (?AVS_linkage@@3PBUAVS_Linkage@@B)".
I already pointed in the project properties to the avisynth.lib... Now, do i also need to do something with the avisynth.map file?
It feels like not being able to see the forest because of too much trees ;-)
cheers,
Harry
StainlessS
1st June 2013, 17:29
Avisynth v2.6 is
#ifndef __AVISYNTH_H__
#define __AVISYNTH_H__
enum { AVISYNTH_INTERFACE_VERSION = 5 };
for v2.58 is version 3
Not sure, I think version 2 is 2.57
I too would like to find a good v2.6 interface demo plugin.
wonkey_monkey
1st June 2013, 19:34
I found I had to add:
#define AVS_LINKAGE_DLLIMPORT
before
#include <avisynth.h>
after which my old plugins compiled fine for 2.6. No idea if that's really the right way to do it, though...
StainlessS
1st June 2013, 23:02
This is how I've been compiling 26 plugs
#include <Windows.h>
#ifdef AVISYNTH_PLUGIN_25
#include "Avisynth25.h"
#else
#include "Avisynth26.h"
#endif
// The following function is the function that actually registers the filter in AviSynth
// It is called automatically, when the plugin is loaded to see which functions this filter contains.
#ifdef AVISYNTH_PLUGIN_25
extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit2(IScriptEnvironment* env) {
#else
/* New 2.6 requirement!!! */
// Declare and initialise server pointers static storage.
const AVS_Linkage *AVS_linkage = 0;
/* New 2.6 requirement!!! */
// DLL entry point called from LoadPlugin() to setup a user plugin.
extern "C" __declspec(dllexport) const char* __stdcall
AvisynthPluginInit3(IScriptEnvironment* env, const AVS_Linkage* const vectors) {
/* New 2.6 requirment!!! */
// Save the server pointers.
AVS_linkage = vectors;
#endif
env->AddFunction("DDigitTest", "c[arg]i",Create_DDigitTest, 0);
// The AddFunction has the following paramters:
// AddFunction(Filtername , Arguments, Function to call,0);
// Arguments is a string that defines the types and optional names of the arguments for you filter.
// c - Video Clip
// i - Integer number
// f - Float number
// s - String
// b - boolean
return "`DDigitTest' DDigitTest plugin";
// A freeform name of the plugin.
}
I also use this
#ifdef AVISYNTH_PLUGIN_25
// Plugin v2.5 and Avisynth v2.6
AVSValue args[1]; // 1 undefined arg
AVSValue res=env->Invoke("VersionNumber", AVSValue(args, 0));
double ver=res.AsFloat(); // v2.6 double comes out as 2.5999999046329
if(ver > 2.58 && vi.IsPlanar()) {
if( vi.pixel_type!=0xA0000008 && // YV12
vi.pixel_type!=0xE0000000 // Y8
) {
env->ThrowError("DDigitTest: ColorSpace unsupported in DDigitTest v2.5\n");
}
}
# endif
in constructor where a v2.5 plugin can deal successfully with Y8 (it is mainly chroma that is a problem).
EDIT: I also include this bit of text into my plugs
/*
Compiling for both Avisynth v2.58 & v2.6 ProjectName under VS6, where ProjectName is the base name of the plugin.
Create an additional project ProjectName26 and copy the
project files into ProjectName folder. Add headers and source files to v2.6 project.
You should have "avisynth25.h" in the ProjectName Header Files and
"avisynth26.h" in the ProjectName26 Header Files.
For the v2.58 project, add preprocessor definition to :-
Menu/Project/Settings/All Configuration/C/C++, AVISYNTH_PLUGIN_25
*/
This is discussed in the thread "Baked code removal - Proposal for AviSynth 2.6 - Post #52 (http://forum.doom9.org/showthread.php?p=1567792#post1567792)". A little further down, Post #59 by Robert Martens, (http://forum.doom9.org/showthread.php?p=1575270#post1575270) starts discussion about using avisynth.dll in an application and how to get the AVS_Linkage pointer. The rest of the thread is the long boring history of how we got to that point.
To use static linkage to avisynth.dll do this :-#define AVS_LINKAGE_DLLIMPORT
#include "avisynth.h"Static linkage is a pita when used in other .dll's. They won't load with that useless 0x7e error code if all the static dependencies cannot be found. It is a source of constant annoyance that we chose to statically link DevIL.dll into avisynth.dll.
I think dynamic linkage is preferred for plugins and add-ons because you at least get to print useful messages about what is missing....
const AVS_Linkage *AVS_linkage = 0;
...
IScriptEnvironment *env;
...
env = CreateScriptEnvironment();
AVS_linkage = env->GetAVSLinkage();
...
An example of how to change to a 2.6 plugin can be seen in this Diff of directshow_source.cpp line 2463 onwards (http://avisynth2.cvs.sourceforge.net/viewvc/avisynth2/avisynth/src/plugins/DirectShowSource/directshow_source.cpp?r1=1.33&r2=1.34#l2463).
Robert Martens
2nd June 2013, 01:42
For another example of 2.6 API usage from a plugin's point of view, you can check the source of the project I was referring to in the thread IanB linked: https://github.com/ItEndsWithTens/TurnsTile Namely the bottom of interface.cpp, but of course the rest of the code proceeds to do a handful of things with 2.6-specific methods.
The testing code I was working on, where I load Avisynth as a library, hasn't been brought up to snuff and added to the repository just yet, but it's on my todo list, so one of these days the project will be able to demonstrate both sides of the equation.
jordanh
4th June 2013, 02:30
Avisynth v2.6 is
#ifndef __AVISYNTH_H__
#define __AVISYNTH_H__
enum { AVISYNTH_INTERFACE_VERSION = 5 };
for v2.58 is version 3
Not sure, I think version 2 is 2.57
I too would like to find a good v2.6 interface demo plugin.
This did the trick. But IanB is of course right about the static linkage stuff...
In short time i'll post the carbonsource() plugin here thats then another example for this ;-)
Thank you all!!
jordanh
6th June 2013, 19:14
Sorry, i need to correct myself, it was the above
#define AVS_LINKAGE_DLLIMPORT
that did the trick. Still need to get out how i can use dll_linkage.
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.