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
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
Old 1st June 2013, 11:13   #1  |  Link
jordanh
Registered User
 
Join Date: Apr 2013
Location: Vienna, Austria
Posts: 55
usage of new avisynth interface version 5 (linker errors on AVS_Linkage)

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
jordanh is offline   Reply With Quote
Old 1st June 2013, 17:29   #2  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Avisynth v2.6 is

Code:
#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.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 1st June 2013, 19:34   #3  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 2,496
I found I had to add:

Code:
#define AVS_LINKAGE_DLLIMPORT
before

Code:
#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...
wonkey_monkey is offline   Reply With Quote
Old 1st June 2013, 23:02   #4  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
This is how I've been compiling 26 plugs

Code:
#include <Windows.h>

#ifdef AVISYNTH_PLUGIN_25
	#include "Avisynth25.h"
#else
	#include "Avisynth26.h"
#endif

Code:
// 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
Code:
	#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

Code:
/*
	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
*/
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 1st June 2013 at 23:05.
StainlessS is offline   Reply With Quote
Old 2nd June 2013, 00:45   #5  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
This is discussed in the thread "Baked code removal - Proposal for AviSynth 2.6 - Post #52". A little further down, Post #59 by Robert Martens, 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 :-
Code:
#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.
Code:
...
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.

Last edited by IanB; 2nd June 2013 at 00:48.
IanB is offline   Reply With Quote
Old 2nd June 2013, 01:42   #6  |  Link
Robert Martens
Registered User
 
Join Date: Feb 2010
Location: New York
Posts: 116
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.
Robert Martens is offline   Reply With Quote
Old 4th June 2013, 02:30   #7  |  Link
jordanh
Registered User
 
Join Date: Apr 2013
Location: Vienna, Austria
Posts: 55
Quote:
Originally Posted by StainlessS View Post
Avisynth v2.6 is

Code:
#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 is offline   Reply With Quote
Old 6th June 2013, 19:14   #8  |  Link
jordanh
Registered User
 
Join Date: Apr 2013
Location: Vienna, Austria
Posts: 55
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.
jordanh is offline   Reply With Quote
Reply


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 03:10.


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