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 17th September 2011, 15:49   #1  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,332
Documenting AviSynth api

As is well known the AviSynth api is poorly documented. The part which is documented is scattered among the wiki and this forum. Some of it can be found here http://avisynth.org/mediawiki/Filter_SDK .

A while ago I started to collect, rewrite and complete all the documentation and I can use some help. The idea is that the content in the above wiki link will be replaced by something which is well structured, complete and contains a lot of examples.

What I have done so far:

http://avisynth.org/mediawiki/User:Wilbert/Filter_SDK
http://avisynth.org/mediawiki/Cplusplus_API
http://avisynth.org/mediawiki/Cplusplus_API/VideoInfo
http://avisynth.org/mediawiki/C_API

As you can see a lot is still missing. I need people who are willing to correct and proof-read the stuff about the C++ api. I also need people who are willing to document the C api and create a c-version of the example plugins: Simple Sample 1.6 and Simple Sample 1.7. Any volunteers who are willing to help?

I also would like to hear your ideas about what I have done so far. Is it better than what existed, should it be organized in a different way, do other things need to be added, other relevant things which you can think off ???
Wilbert is offline   Reply With Quote
Old 18th September 2011, 03:03   #2  |  Link
kemuri-_9
Compiling Encoder
 
kemuri-_9's Avatar
 
Join Date: Jan 2007
Posts: 1,348
I have a fair bit of experience in the C interface so I may be able to help there, granted I can find time to do so in my schedule.

If I were to write simple sample 1.6 and 1.7 in the C interface, how should it be provided to you?
__________________
custom x264 builds & patches | F@H | My Specs
kemuri-_9 is offline   Reply With Quote
Old 18th September 2011, 12:21   #3  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,332
Quote:
I have a fair bit of experience in the C interface so I may be able to help there, granted I can find time to do so in my schedule.
That would be great!

Quote:
If I were to write simple sample 1.6 and 1.7 in the C interface, how should it be provided to you?
If you provide it in html or doc format would be fine. Adding it to the wiki is fine too if you prefer that.
Wilbert is offline   Reply With Quote
Old 29th April 2012, 22:02   #4  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,332
Some questions for those who know the internals better than i do:

1) SetCacheHints(CACHE_RANGE, frame_range)

Does frame_range denote the diameter or radius of frames to be cached? Is it the diameter prior to v2.56? The cache code is too complicated for me to follow.

2) PushContext / PopContext / PopContextGlobal

What's the difference between those and when is each used?

3) What's the difference between SetVar and SetGlobalVar?

4) What's the difference between CACHE_AUDIO_AUTO and CACHE_AUDIO?
Wilbert is offline   Reply With Quote
Old 1st May 2012, 13:14   #5  |  Link
TheFluff
Excessively jovial fellow
 
Join Date: Jun 2004
Location: rude
Posts: 1,069
3: the first one sets a local variable and the second sets a global. That is, the first one is equivalent to a simple "foo = bar", while the second is equivalent to "global foo = bar".

Last edited by TheFluff; 1st May 2012 at 13:17.
TheFluff is offline   Reply With Quote
Old 6th October 2012, 20:07   #6  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 6,746
Quote:
Originally Posted by Wilbert View Post
Some questions for those who know the internals better than i do:
3) What's the difference between SetVar and SetGlobalVar?
Not the question (already answered by TheFluff) BUT ,
The return value from SetVar/SetGlobalVar denotes whether the variable already exists (false) or newly created (true), not denoting error situation as in API docs Cplusplus_API (from my reading of source script.cpp a week or so ago).

Question:
When do you use env->SaveString() for SetVar/SetGlobalVar, only when the variable name does not already exist ?

When do you use env->SaveString() for SetVar/SetGlobalVar, with the value, always for strings ?

EDIT: Would be nice if Wilberts questions could be answered too.

EDIT: Nice work in the docs Wilbert.
__________________
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; 6th October 2012 at 22:38.
StainlessS is offline   Reply With Quote
Old 12th October 2012, 12:43   #7  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,380
Quote:
Originally Posted by StainlessS View Post
When do you use env->SaveString() for SetVar/SetGlobalVar, only when the variable name does not already exist ?

When do you use env->SaveString() for SetVar/SetGlobalVar, with the value, always for strings ?
The principles are the same as for other uses of SaveString.

Since Set[Global]Var does not copy the contents of the variable name (only a pointer to it), you need to use SaveString if the memory holding the name string will be deallocated before the current script environment (eg a local variable) [unless you know (in advance) that the name already exists].

Similarly, if the value is a string, use SaveString if the string contents are stored in memory that will not survive long enough.
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 13th October 2012, 10:47   #8  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 6,746
I did read about 3 pages (search) of posts for SetVar and about 1 for SetGlobalVar (or other way around)
and was no wiser afterwards. Some people always used, some never and one fellow fixed a bug by using SaveString.
I implemented ShowChannels latest beta as you describe so thats OK, I'm always uncomfortable if I dont know the
specifics and dont like guessing.
Thank you maestro.
__________________
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 14th October 2012, 02:05   #9  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,171
Sorry, I intended to answer this post, but I got distracted and subsequently forgot about it
Quote:
Originally Posted by Wilbert View Post
Some questions for those who know the internals better than i do:

1) SetCacheHints(CACHE_RANGE, frame_range)

Does frame_range denote the diameter or radius of frames to be cached? Is it the diameter prior to v2.56? The cache code is too complicated for me to follow.
CACHE_RANGE currently provides a hard cache of up to frame_range buffers. When a new frame is buffered any buffers containing frames outside the radius frame_range are released. With normal sequential access only frame_range buffers are ever protected.
E.g. for frame_range=3 and frame 10 is the next frame being generated. Frames 8, 9, 10, 11 & 12 become eligible for protection, any frames <= 7 and >= 13 will be marked unprotected. From the previous iteration, frames 7, 8 & 9 will be cached and protected, 10, 11 & 12 have never been requested so will not exist. As frame 10 is being added frame 7 will become marked unprotected, frames 8 & 9 will remain protected and new frame 10 will become protected, frames 11 and 12 still do not exist.

Note! Subsequently accessing frame 8 will make frames 6, 7, 8, 9 & 10 eligible but will not cause them to become explicitly protected. So frames 6 & 7 will be left alone and will remain marked unprotected, if they even still exist, frame 8 will be explicitly marked as protected (a nop) and frames 9 & 10 will be left alone and remain marked as protected.

I believe that CACHE_RANGE has always worked fundamentally as described above, but there has been much confusion about the frame_range values to be used. Earlier cache.cpp versions maintained a table frame_range*2+1 in size but frames outside the radius frame_range were always evicted as new frames were added so the table was only ever half full.
E.g. With frames 7, 8 & 9 in the table, adding frame 11 would make frames 9, 10, 11, 12 & 13 eligible. This will evict frames 7 & 8. Frame 9 will remain, frame 11 will be added and frames 10, 12 & 13 will not exist yet.

CACHE_RANGE is being renamed to CACHE_WINDOW in 2.6 This will require plugin authors using CACHE_RANGE to re-evaluate the caching needs of their filters in consideration of a hopefully less ambiguous definition of the cache api.

Quote:
2) PushContext / PopContext / PopContextGlobal

What's the difference between those and when is each used?
PushContext() and PopContext() are used to implement local script function name space contexts. A plugin could use these to create a new local name space before Invok'ing or Eval'ing script expressions in order to avoid clashes with similarly named variables in the calling script.

PushContext() and PopContext() should always be used in matched pairs, and the code region of interest be try/catch protected with a PopContext() in the catch case.

PopContextGlobal() will release the global script namespace. It is used as part of the ~IScriptEnvironment cleanup, calling this function outside of this function is usually pretty fatal. It is currently of no use in user plugins. My guess is BenRG had some thought about having a matching PushContextGlobal() but it was apparently not needed and was never implemented. Likewise PushContext(Level) always ignores the level argument, my guess is BenRG had some thought about having nestable local namespaces like in nested Pascal functions but it was apparently not needed and was never implemented.

Quote:
3) What's the difference between SetVar and SetGlobalVar?
SetVar and SetGlobalVar implement script variables. Filters can use the IScriptEnvironment callbacks together with GetVar to interact with the calling scripts variables.

SetVar manipulates variables in the current local script function context. See PushContext.

SetGlobalVar manipulates global script variables declared with the GLOBAL qualifier.

The variable core only maintains the pointers to the name strings passed in, so the memory containing the names must remain constant and current for the duration of context maintaining the variables. Using env->SaveString is a convenient way to allocate pseudo static memory for the script duration. You could equally use strdup but then you need to eventually free the buffer when the context is no longer current to avoid a memory leak.

Quote:
4) What's the difference between CACHE_AUDIO_AUTO and CACHE_AUDIO?
CACHE_AUDIO is to explicitly cache audio with an initial X byte cache. Auto mode can increase the size if required, but will never disable or decrease the cache.

CACHE_AUDIO_AUTO is used internally to turn the Audio cache on in auto mode.

CACHE_AUDIO_NONE is the default and starts with the Audio cache off but in auto mode.

Auto mode monitors the input request pattern for forwards and backwards accesses. When it detects sufficient backwards accesses it switches to CACHE_AUDIO_AUTO mode. When it detects only forwards accesses with no further backwards accesses it switches back to CACHE_AUDIO_NONE mode and waits for any further sufficient backwards accesses.

Auto mode also monitors the success and failure of the cache when enabled and will increase the cache size when required. A future edition could also decrease the cache size if indicated, the current version only reverts to CACHE_AUDIO_NONE mode.

CACHE_AUDIO_NOTHING is new in 2.6 and is to explicitly not cache audio and disables auto mode scanning.
IanB is offline   Reply With Quote
Old 7th November 2013, 12:07   #10  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 6,746
Wilbert, links in opening post are broken.

EDIT: Perhaps these are correct.

http://www.avisynth.nl/index.php/Filter_SDK
http://www.avisynth.nl/index.php/Cplusplus_API
http://www.avisynth.nl/index.php/Cpl..._API/VideoInfo
http://www.avisynth.nl/index.php/C_API

Not sure about the "User:Wilbert/Filter_SDK" link.
__________________
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; 7th November 2013 at 12:47.
StainlessS is offline   Reply With Quote
Old 3rd December 2013, 17:41   #11  |  Link
martin53
Registered User
 
Join Date: Mar 2007
Posts: 405
Wilbert,
highly appreciate your effort to improve documentation!
There's also a Wiki page about how to set up a build environment - and currently there's a small discussion about that in the RT_Stats thread. I think me and others would also be very grateful if the mentioned page was updated and important hints were added - e.g. to avoid conflicting other compilers with a higher %PATH% priority, who needs Visual C++ Toolkit 2003 and who doesn't, etc etc.

I am about to set up a plugin IDE, but I'm really afraid about what I learn about all the things to observe - and I only notice it by chance as some off topic remarks here, there and there. I think I haven't got the time to go through all possible shallows of bad IDE configurations.
Maybe VS 2010, that seems to compile for XP ... W7 (W8?), x86+x64, I don't ask for more than one reasonable suggestion.
martin53 is offline   Reply With Quote
Old 3rd December 2013, 18:40   #12  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,332
Quote:
There's also a Wiki page about how to set up a build environment - and currently there's a small discussion about that in the RT_Stats thread. I think me and others would also be very grateful if the mentioned page was updated and important hints were added - e.g. to avoid conflicting other compilers with a higher %PATH% priority, who needs Visual C++ Toolkit 2003 and who doesn't, etc etc.
Could you give links to the relevants posts here? That thread is long Then i will include when i have some time ...

Guess you mean http://forum.doom9.org/showthread.ph...25#post1654825 + next couple of pages.

Last edited by Wilbert; 3rd December 2013 at 18:45.
Wilbert is offline   Reply With Quote
Old 3rd December 2013, 21:07   #13  |  Link
martin53
Registered User
 
Join Date: Mar 2007
Posts: 405
Quote:
Originally Posted by Wilbert View Post
Guess you mean http://forum.doom9.org/showthread.ph...25#post1654825 + next couple of pages.
Yep. Thank you for your time!
martin53 is offline   Reply With Quote
Old 3rd December 2013, 21:20   #14  |  Link
Groucho2004
 
Groucho2004's Avatar
 
Join Date: Mar 2006
Location: A wretched hive of scum and villainy
Posts: 4,218
Quote:
Originally Posted by martin53 View Post
There's also a Wiki page about how to set up a build environment - and currently there's a small discussion about that in the RT_Stats thread. I think me and others would also be very grateful if the mentioned page was updated and important hints were added - e.g. to avoid conflicting other compilers with a higher %PATH% priority, who needs Visual C++ Toolkit 2003 and who doesn't, etc etc.

I am about to set up a plugin IDE, but I'm really afraid about what I learn about all the things to observe - and I only notice it by chance as some off topic remarks here, there and there. I think I haven't got the time to go through all possible shallows of bad IDE configurations.
Maybe VS 2010, that seems to compile for XP ... W7 (W8?), x86+x64, I don't ask for more than one reasonable suggestion.
There is already a guide on Avisynth.nl that describes how to build plugins with various Visual Studio versions and as far as I can see, it's sufficient. The guide for VS2008 on that page should provide enough info make it also work with VS2010 and 2012.
Groucho2004 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 04:49.


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