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 28th May 2016, 16:13   #1621  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,173
From what I understand,

MT_NICE_FILTER means there is one class instance and GetFrame gets called several times at once from various threads on the same class. When Pinterf went through my code, he wrote "Say no to globalism!" No global variables unless they are read-only. All working buffers must be created within GetFrame.

MT_MULTI_INSTANCE means that one instance of the class gets created for each thread and each instance is single-threaded. One thread may process frames 1, 4, 7 and 9 while other threads process other frames.

I'm not yet sure what impact MT_SERIALIZED has on the code.

The way to define it is in the Init function

Code:
extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit3(IScriptEnvironment* env, const AVS_Linkage* const vectors) {
	AVS_linkage = vectors;
	env->AddFunction("ConvertToShader", "c[Precision]i[lsb]b", Create_ConvertToShader, 0);
	env->AddFunction("ConvertFromShader", "c[Precision]i[Format]s[lsb]b", Create_ConvertFromShader, 0);
	env->AddFunction("Shader", "c[Path]s[EntryPoint]s[ShaderModel]s[Param0]s[Param1]s[Param2]s[Param3]s[Param4]s[Param5]s[Param6]s[Param7]s[Param8]s[Clip1]i[Clip2]i[Clip3]i[Clip4]i[Clip5]i[Clip6]i[Clip7]i[Clip8]i[Clip9]i[Output]i[Width]i[Height]i", Create_Shader, 0);
	env->AddFunction("ExecuteShader", "c[Clip1]c[Clip2]c[Clip3]c[Clip4]c[Clip5]c[Clip6]c[Clip7]c[Clip8]c[Clip9]c[Clip1Precision]i[Clip2Precision]i[Clip3Precision]i[Clip4Precision]i[Clip5Precision]i[Clip6Precision]i[Clip7Precision]i[Clip8Precision]i[Clip9Precision]i[Precision]i[OutputPrecision]i", Create_ExecuteShader, 0);

	void* is_plus = env->FunctionExists("SetFilterMTMode") ? "true" : nullptr;
	if (is_plus != nullptr) {
		auto env2 = static_cast<IScriptEnvironment2*>(env);
		env2->SetFilterMTMode("ConvertToShader", MT_NICE_FILTER, true);
		env2->SetFilterMTMode("ConvertFromShader", MT_NICE_FILTER, true);
		env2->SetFilterMTMode("Shader", MT_NICE_FILTER, true);
		env2->SetFilterMTMode("ExecuteShader", MT_MULTI_INSTANCE, true);
	}

	return "Shader plugin";
}
MysteryX is offline   Reply With Quote
Old 28th May 2016, 16:59   #1622  |  Link
Chikuzen
typo lover
 
Chikuzen's Avatar
 
Join Date: May 2009
Posts: 597
Quote:
Originally Posted by MysteryX View Post
Code:
	void* is_plus = env->FunctionExists("SetFilterMTMode") ? "true" : nullptr;
	if (is_plus != nullptr) {
		auto env2 = static_cast<IScriptEnvironment2*>(env);
		env2->SetFilterMTMode("ConvertToShader", MT_NICE_FILTER, true);
		env2->SetFilterMTMode("ConvertFromShader", MT_NICE_FILTER, true);
		env2->SetFilterMTMode("Shader", MT_NICE_FILTER, true);
		env2->SetFilterMTMode("ExecuteShader", MT_MULTI_INSTANCE, true);
	}
Why do you convert bool to void* there is no need to do it ?

Code:
	if (env->FunctionExists("SetFilterMTMode")) {
		auto env2 = static_cast<IScriptEnvironment2*>(env);
		env2->SetFilterMTMode("ConvertToShader", MT_NICE_FILTER, true);
		env2->SetFilterMTMode("ConvertFromShader", MT_NICE_FILTER, true);
		env2->SetFilterMTMode("Shader", MT_NICE_FILTER, true);
		env2->SetFilterMTMode("ExecuteShader", MT_MULTI_INSTANCE, true);
	}
I think this is smart and better.
__________________
my repositories
Chikuzen is offline   Reply With Quote
Old 28th May 2016, 18:18   #1623  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,173
I just copied the code from someone else. Monkey see monkey do

I agree it was written in a weird way!
MysteryX is offline   Reply With Quote
Old 28th May 2016, 21:32   #1624  |  Link
Reel.Deel
Registered User
 
Join Date: Mar 2012
Location: Texas
Posts: 1,117
Quote:
Originally Posted by jpsdr View Post
Is there a place/link which explain the differences and impact between all MT status like, MT_SERIALIZED, MT_NICE_FILTER to eventualy add in my filter the report of what they support.
I need the list of all the avaible status, and what they exactly mean for the filter reporting a such status. Where there is such information ?
I don't know if you've seen this already but read this post by ultim: http://forum.doom9.org/showthread.ph...71#post1651071

Last edited by Reel.Deel; 28th May 2016 at 22:46. Reason: fix link
Reel.Deel is offline   Reply With Quote
Old 28th May 2016, 22:31   #1625  |  Link
Groucho2004
Fossil
 
Groucho2004's Avatar
 
Join Date: Mar 2006
Location: A wretched hive of scum and villainy
Posts: 4,505
Quote:
Originally Posted by Reel.Deel View Post
I don't know if you've seen this already but read this post by ultim: http://forum.doom9.org/showthread.ph...11#post1651071
I have seen this here and also on avisynth.nl - when you link to Doom9 forum posts, your links always contain a page reference which of course only works when users have not changed their posts/page forum preference.
Every time I click on one of your links I get transported to some random place since I don't use the default.

I suggest you use the "Link" reference, top right of every post.

Last edited by Groucho2004; 28th May 2016 at 22:39.
Groucho2004 is offline   Reply With Quote
Old 28th May 2016, 22:45   #1626  |  Link
Reel.Deel
Registered User
 
Join Date: Mar 2012
Location: Texas
Posts: 1,117
Quote:
Originally Posted by Groucho2004 View Post
I have seen this here and also on avisynth.nl - when you link to Doom9 forum posts, your links always contain a page reference which of course only works when users have not changed their posts/page forum preference.
Every time I click on one of your links I get transported to some random place since I don't use the default.

I suggest you use the "Link" reference, top right of every post.
Thanks for pointing that out, I'll use the suggested link from now.
The links have always worked for me so I never noticed. I'll try to fix the wiki links as I come across them.
Reel.Deel is offline   Reply With Quote
Old 28th May 2016, 22:49   #1627  |  Link
Groucho2004
Fossil
 
Groucho2004's Avatar
 
Join Date: Mar 2006
Location: A wretched hive of scum and villainy
Posts: 4,505
Quote:
Originally Posted by Reel.Deel View Post
Thanks for pointing that out, I'll use the suggested link from now.
The links have always worked for me so I never noticed. I'll try to fix the wiki links as I come across them.
I think it's only when you link to specific posts, not when you link a whole thread.
Groucho2004 is offline   Reply With Quote
Old 28th May 2016, 23:00   #1628  |  Link
LigH
German doom9/Gleitz SuMo
 
LigH's Avatar
 
Join Date: Oct 2001
Location: Germany, rural Altmark
Posts: 5,983
So for everyone else: reply #204
__________________

New German Gleitz board
MediaFire: x264 | x265 | VPx | AOM | Xvid
LigH is offline   Reply With Quote
Old 28th May 2016, 23:16   #1629  |  Link
Reel.Deel
Registered User
 
Join Date: Mar 2012
Location: Texas
Posts: 1,117
Quote:
Originally Posted by Groucho2004 View Post
I think it's only when you link to specific posts, not when you link a whole thread.
Correct. A while back archive.org had trouble archiving the top right link so I used the alternative link because it worked. I used that style on the wiki just so if it ever gets crawled by archived.org. Just checked and it seems the top-right link also works now.

Sorry to anyone who was directed to a random place. That was not my intent.

Quote:
Originally Posted by LigH View Post
So for everyone else: reply #204
I fixed the link in #1628.
Reel.Deel is offline   Reply With Quote
Old 29th May 2016, 10:42   #1630  |  Link
jpsdr
Registered User
 
Join Date: Oct 2002
Location: France
Posts: 1,775
Ok, i think i understand the differences between the 3.
MT_NICE_FILTER : Not possible if you have to use global internal buffer. Personnaly, i'll never malloc/free on each get frame, and don't want to use MT specific features making the filter working only on MT versions. But on something so simple as brigthness/contrast (for exemple), it will work.
MT_MULTI_INSTANCE : You can use global internal buffer, no several getframe from the same instance, but input frames are "random", so works only if, basicaly, the filter needs only the actual frame. I think it's this case for the actual nnedi3.
MT_SERIALIZED : The filter needs the frames to be entered in the correct order, and probably also have buffer. A simple example would be something like an RII filter (like y[n]=0.5*x[n]+0.25*x[n-1]+0.25*y[n-1]). A such filter is not compatible with the others two modes.

Thanks, things are clear now. I think...

Last edited by jpsdr; 29th May 2016 at 10:45.
jpsdr is offline   Reply With Quote
Old 29th May 2016, 11:23   #1631  |  Link
LigH
German doom9/Gleitz SuMo
 
LigH's Avatar
 
Join Date: Oct 2001
Location: Germany, rural Altmark
Posts: 5,983
I believe even a filter which requires a temporal range of frames can be MT-friendly if the AviSynth(+) core knows about it working on a temporal window and buffering such a range...
__________________

New German Gleitz board
MediaFire: x264 | x265 | VPx | AOM | Xvid
LigH is offline   Reply With Quote
Old 29th May 2016, 20:43   #1632  |  Link
jackoneill
unsigned int
 
jackoneill's Avatar
 
Join Date: Oct 2012
Location: 🇪🇺
Posts: 728
Quote:
Originally Posted by jpsdr View Post
Personnaly, i'll never malloc/free on each get frame,
It's really not that bad. The VapourSynth plugin with work buffers allocated in the getframe function is about as fast as the Avisynth plugin. See http://forum.doom9.org/showthread.ph...99#post1600999 and some posts below.
__________________
Buy me a "coffee" and/or hire me to write code!
jackoneill is offline   Reply With Quote
Old 30th May 2016, 04:35   #1633  |  Link
fAy01
Registered User
 
Join Date: Jun 2010
Posts: 75
The current installer of avs-plus detects avisynth 2.5/2.6. Is there a possibility to have both 32bit and 64bit working without having to overwrite or uninstall the other?
fAy01 is offline   Reply With Quote
Old 30th May 2016, 09:00   #1634  |  Link
LigH
German doom9/Gleitz SuMo
 
LigH's Avatar
 
Join Date: Oct 2001
Location: Germany, rural Altmark
Posts: 5,983
For 32 bit applications, only one DLL can be registered system-wide as AviSynth frameserver, either the "vanilla" AviSynth DLL or the AviSynth+ DLL.

But it is possible to place one of the DLLs next to the application into the same directory, and if the application loads "the next available avisynth.dll", it will probably look first in its own directory before looking into the Windows system directory. This way it may be possible to exchange the AviSynth version used by a specific application independently of the system-wide AviSynth installation, by installing the application in two directories (preferably outside an UAC protected branch, means: not in "Program files") and copying either DLL to either directory.

For 64 bit applications, there is no reliable 64-bit "vanilla" AviSynth build, anyway.
__________________

New German Gleitz board
MediaFire: x264 | x265 | VPx | AOM | Xvid
LigH is offline   Reply With Quote
Old 30th May 2016, 09:54   #1635  |  Link
Groucho2004
Fossil
 
Groucho2004's Avatar
 
Join Date: Mar 2006
Location: A wretched hive of scum and villainy
Posts: 4,505
Quote:
Originally Posted by fAy01 View Post
The current installer of avs-plus detects avisynth 2.5/2.6. Is there a possibility to have both 32bit and 64bit working without having to overwrite or uninstall the other?
Any 32 bit and 64 bit Avisynth versions can live happily together. The 32 bit avisynth.dll/devil.dll are placed in SysWOW64, the 64 bit versions in system32. A client application will (should) automatically load the correct DLL.

However, only Avisynth+ has the option of specifying separate plugin directories which is needed for auto-loading filters.

To answer your question - yes, you can install just 64 bit AVS+ alongside your existing 32 bit Avisynth.

Last edited by Groucho2004; 30th May 2016 at 10:38.
Groucho2004 is offline   Reply With Quote
Old 30th May 2016, 10:09   #1636  |  Link
Groucho2004
Fossil
 
Groucho2004's Avatar
 
Join Date: Mar 2006
Location: A wretched hive of scum and villainy
Posts: 4,505
Quote:
Originally Posted by LigH View Post
For 32 bit applications, only one DLL can be registered system-wide as AviSynth frameserver, either the "vanilla" AviSynth DLL or the AviSynth+ DLL.
Avisynth.dll does not need registration. A client application can load any avisynth.dll.

Quote:
Originally Posted by LigH View Post
For 64 bit applications, there is no reliable 64-bit "vanilla" AviSynth build, anyway.
I find AVS+ r1576 and the latest build from pinterf very usable.
Groucho2004 is offline   Reply With Quote
Old 30th May 2016, 10:17   #1637  |  Link
LigH
German doom9/Gleitz SuMo
 
LigH's Avatar
 
Join Date: Oct 2001
Location: Germany, rural Altmark
Posts: 5,983
Quote:
Originally Posted by Groucho2004 View Post
I find AVS+ r1576 and the latest build from pinterf very usable.
But that's AviSynth+ (plus), not vanilla/legacy/original AviSynth... how should I call it to make it distinct from the "plus" fork?

A 64-bit AviSynth (without "plus") does exist; but it was mainly known as unstable (I guess many of the programming tricks the 32-bit version survived would crash the 64-bit version, and only few plugins were ported before this project was abandoned).
__________________

New German Gleitz board
MediaFire: x264 | x265 | VPx | AOM | Xvid
LigH is offline   Reply With Quote
Old 30th May 2016, 10:37   #1638  |  Link
Groucho2004
Fossil
 
Groucho2004's Avatar
 
Join Date: Mar 2006
Location: A wretched hive of scum and villainy
Posts: 4,505
Quote:
Originally Posted by LigH View Post
But that's AviSynth+ (plus), not vanilla/legacy/original AviSynth... how should I call it to make it distinct from the "plus" fork?

A 64-bit AviSynth (without "plus") does exist; but it was mainly known as unstable (I guess many of the programming tricks the 32-bit version survived would crash the 64-bit version, and only few plugins were ported before this project was abandoned).
I know what you meant and I agree with all of the above.

I just pointed out that there are a couple of very usable 64 bit builds because your statement "there is no reliable 64-bit "vanilla" AviSynth build, anyway" may be misleading for folks not familiar with vanilla flavour in this context.

Last edited by Groucho2004; 30th May 2016 at 13:13.
Groucho2004 is offline   Reply With Quote
Old 30th May 2016, 12:10   #1639  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,173
I posted some time ago about AviSynth+ x64 taking HUGE amounts of memory. The fault is mine. AviSynthShader takes more than twice the memory in x64, trying to figure out why. If I remove that, all the other filters take slightly more memory but perform faster.

From what I tested so far, AviSynthShader may be the only x64 filter that isn't working as expected.
MysteryX is offline   Reply With Quote
Old 30th May 2016, 22:01   #1640  |  Link
fAy01
Registered User
 
Join Date: Jun 2010
Posts: 75
Quote:
Originally Posted by Groucho2004 View Post
Any 32 bit and 64 bit Avisynth versions can live happily together. The 32 bit avisynth.dll/devil.dll are placed in SysWOW64, the 64 bit versions in system32. A client application will (should) automatically load the correct DLL.

However, only Avisynth+ has the option of specifying separate plugin directories which is needed for auto-loading filters.

To answer your question - yes, you can install just 64 bit AVS+ alongside your existing 32 bit Avisynth.


avs-plus suggests otherwise
fAy01 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 14:42.


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