http://avisynth.nl/api.php?action=feedcontributions&user=Admin&feedformat=atomAvisynth wiki - User contributions [en]2024-03-29T05:39:31ZUser contributionsMediaWiki 1.19.24http://avisynth.nl/index.php/Talk:Mediawiki/FAQ_frameservingTalk:Mediawiki/FAQ frameserving2024-03-01T12:48:51Z<p>Admin: Undo revision 13328 by 154.6.95.135 (talk)</p>
<hr />
<div>[[Category:Talk]]<br />
==== please delete this page ====<br />
I was trying to support old links such as this:<br><br />
http://avisynth.org/mediawiki/FAQ_frameserving <br><br />
...which I encountered here:<br><br />
http://forum.doom9.org/showpost.php?p=1360122&postcount=6<br />
<br />
Sadly it does not work. To support old links like this would require a web-server level [http://httpd.apache.org/docs/2.2/mod/mod_alias.html redirect] in your web root [[wikipedia:.htaccess|<code>.htaccess</code>]] file - something like:<br />
RedirectMatch permanent '/mediawiki/' http://avisynth.nl/index.php/<br />
I believe this would fix all old links like the one above - or at least do no harm. I have done similar redirects for another site, required by a complete site reorganization while not breaking old URLs, and it worked very well.<br><br />
Your web host may prefer you add redirects through the admin control panel, rather than edit <code>.htaccess</code> directly. Either way is good.<br><br />
[[User:Raffriff42|Raffriff42]] 04:38, 5 October 2014 (CEST)</div>Adminhttp://avisynth.nl/index.php/Talk:Main_PageTalk:Main Page2024-03-01T12:48:12Z<p>Admin: </p>
<hr />
<div>[[Category:Talk]]<br />
==== 2.60 alpha ====<br />
<br />
''v.2.6.0 ST, 32-bit at SourceForge (still in alpha stage)''<br />
<br />
Shouldn't a note be put up to encourage people to get this version, something like (in StainlessS's words, [http://forum.doom9.org/showthread.php?p=1690445#post1690445 here]) <blockquote>''v2.6 is much better. If you don't like the alpha status, then just don't use 2.6 additional colorspaces or functions - 2.58 compatible stuff is considerably more stable.''</blockquote> [[User:Raffriff42|Raffriff42]] 05:34, 20 August 2014 (CEST)<br />
(EDIT forgot to add four ~'s for auto-sig)<br />
<br />
-- -- --<br />
<br />
Yeah I've thought about doing something like this. Maybe create a page exclusively for AviSynth 2.6 info and add all possible references in hope of convincing people to use 2.6 over 2.5.8? <br />
<br />
*IanB: http://forum.doom9.org/showthread.php?p=1629125#post1629125 (note: this was written during the alpha4 phase, maybe some of the things mentioned no longer apply to alpha5?)<br />
<blockquote>As a 2.5.8 replacement 2.6.0 should be just as stable. It passes all current the 2.5 regression tests, while 2.5.8 fails a few due to bugs being fixed and test to expose them being added. Most problems show up in new code, so if you use the new 2.6 features, that is where you might expect to find problems. A lot of people are downloading 2.6. And the only 2.5 bug reports I seem to get are for things broken in 2.5.8 as well, the few 2.6 bug reports are to do with things like YV24 overlay and YV411 text painting.<br />
<br />
I have most of the API changes mapped out to cover hooks for expected features for 2.6.1 and 2.6.2 like extra colour spaces and threading so that 2.6 plugins won't need to be recompiled. I have a long standing bug in the cache from 2.5.7 that I am working on at present and I intend to do an Alpha 5 release when I finish and test that fix. If Alpha 5 stands up without any new bugs I will probably promote it to Release Candidate 1, i.e. 1st Beta release.</blockquote><br />
<br />
*Doom9 thread: [http://forum.doom9.org/showthread.php?t=168478 Which Avisynth version are you using?] - A poll which clearly shows that most people are using 2.6.<br />
<br />
I also have my own little rant on this very issue: http://forum.doom9.org/showthread.php?p=1684284#post1684284 - nothing of importance just frustrated that people are still using 2.5.8 and still have the audacity to complain.<br />
<br />
Regarding the wiki I never really did anything about it because I don't know what my limits are? I know it's a wiki but I also don't want to overstep any boundaries (if any). [[User:Reel.Deal|Reel.Deal]] 15:20, 20 August 2014 (CEST)<br />
<br />
:- yeah I know, editing the main page as a normal user requires chutzpah. [[User:Raffriff42|Raffriff42]] 05:34, 20 August 2014 (CEST)<br />
<br />
::Feel free to make changes, i will read and correct them if necessary. If you want to change something but you are not sure about it, just ask. You can also use the talk pages for such proposals [[User:Admin|Admin]] 16:56, 20 August 2014 (CEST)<br />
<br />
:::OK I put something up there. Feel free to edit or roll back completely. [[User:Raffriff42|Raffriff42]] 21:51, 20 August 2014 (CEST)<br />
<br />
<br />
==== "Avisynth Manual" ====<br />
:...links to [[Internal filters]] - wth?? <br />
<blockquote>Interested? On this site, you can read [[more about AviSynth]], search the official [[Internal filters|AviSynth manual]], and browse the [[AviSynth FAQ]]. Or you can jump straight to pages listed below for downloading Avisynth. </blockquote><br />
:"Internal filters" is a nice page and all, but it's not a Manual. I figured somebody made a typo and went to the [http://web.archive.org/ archive] to find where it went wrong. It seems Internal filters has been the link target for a long, long time - I had to go back to 2007 to find an [http://web.archive.org/web/20070704162253/http://avisynth.org/AviSynthManual "AviSynth Manual."] It ain't much; it's mostly a list of filters. <br />
<br />
:Really, these days, the Main Page '''is''' the Manual - so I propose we revise any phrases like "browse the manual" to something more appropriate to the context - or simply delete references to the Manual altogether.<br />
:[[User:Raffriff42|Raffriff42]] 05:53, 21 September 2014 (CEST)<br />
<br />
:...deleted reference to the Manual, also cleaned up the top nav bar. [[User:Raffriff42|Raffriff42]] 17:51, 21 September 2014 (CEST)<br />
<br />
====User pages====<br />
:re ''User pages hosted on this site'', the listing on the main page is intended to be temporary. I have no idea how many user pages there are; they are hard to find unless you stumble across them, or else maybe drill down into the all of the [http://avisynth.nl/index.php?title=Special%3APrefixIndex&prefix=Template%3A&namespace=0 Author templates]. It would be nice to have an Authors category or better yet, a 'thank-you' page somewhere. It sounds like a lot of work though. If anyone has this info in spreadsheet form in would be a big help. [[User:Raffriff42|Raffriff42]] 18:08, 21 September 2014 (CEST)<br />
<br />
::Not sure what you mean but there are only three authors who have a user page: http://avisynth.nl/index.php?title=Special:ListUsers&limit=100 . I don't know how to get a list of all users who edited at least one page. http://avisynth.nl/index.php/Special:ActiveUsers gives only the users who edited something in the last 30 days. Anyway most users are fake (i think but i'm not sure). They should be merged into a spam account. [[User:Admin|Admin]] 18:29, 21 September 2014 (CEST)<br />
<br />
:::I mean Avisynth code or plugin authors, not Wiki authors in this case. If those are the only 3 then there's no need to do anything more. Thanks. [[User:Raffriff42|Raffriff42]] 19:01, 21 September 2014 (CEST)<br />
<br />
====OldWiki====<br />
The [http://avisynth.org/oldwiki/ "Old Wiki" link] on the sidebar is dead; it should use [[:Template:OldWiki]] - or [http://web.archive.org/web/20100616111740/http://avisynth.org/oldwiki this link] directly. --[[User:Raffriff42|Raffriff42]] 13:26, 19 January 2016 (CET)</div>Adminhttp://avisynth.nl/index.php/Talk:Mediawiki/FAQ_frameservingTalk:Mediawiki/FAQ frameserving2024-03-01T12:47:45Z<p>Admin: Reverted edits by 154.6.95.21 (talk) to last revision by 154.6.95.135</p>
<hr />
<div>[[Category:Talk]]<br />
==== please delete this page ====<br />
I was trying to support old links such as this:<br><br />
http://avisynth.org/mediawiki/FAQ_frameserving <br><br />
...which I encountered here:<br><br />
http://forum.doom9.org/showpost.php?p=1360122&postcount=6<br />
<br />
Sadly it does not work. To support old links like this would require a web-server level [http://httpd.apache.org/docs/2.2/mod/mod_alias.html redirect] in your web root [[wikipedia:.htaccess|<code>.htaccess</code>]] file - something like:<br />
RedirectMatch permanent '/mediawiki/' http://avisynth.nl/index.php/<br />
I believe this would fix all old links like the one above - or at least do no harm. I have done similar redirects for another site, required by a complete site reorganization while not breaking old URLs, and it worked very well.<br><br />
Your web host may prefer you add redirects through the admin control panel, rather than edit <code>.htaccess</code> directly. Either way is good.<br><br />
[[User:Raffriff42|Raffriff42]] 04:38, 5 October 2014 (CEST)<br />
<br />
== The conquer CBD products ==<br />
<br />
I gave cbd gummies a try for the treatment of the primary previously, and I'm amazed! They tasted smashing and provided a intelligibility of calmness and relaxation. My lay stress melted away, and I slept less ill too. These gummies are a game-changer for me, and I highly endorse them to anyone seeking spontaneous emphasis liberation and think twice sleep.</div>Adminhttp://avisynth.nl/index.php/Talk:Main_PageTalk:Main Page2024-03-01T12:45:47Z<p>Admin: Reverted edits by 188.130.129.242 (talk) to last revision by 138.199.59.201</p>
<hr />
<div>[[Category:Talk]]<br />
==== 2.60 alpha ====<br />
<br />
''v.2.6.0 ST, 32-bit at SourceForge (still in alpha stage)''<br />
<br />
Shouldn't a note be put up to encourage people to get this version, something like (in StainlessS's words, [http://forum.doom9.org/showthread.php?p=1690445#post1690445 here]) <blockquote>''v2.6 is much better. If you don't like the alpha status, then just don't use 2.6 additional colorspaces or functions - 2.58 compatible stuff is considerably more stable.''</blockquote> [[User:Raffriff42|Raffriff42]] 05:34, 20 August 2014 (CEST)<br />
(EDIT forgot to add four ~'s for auto-sig)<br />
<br />
-- -- --<br />
<br />
Yeah I've thought about doing something like this. Maybe create a page exclusively for AviSynth 2.6 info and add all possible references in hope of convincing people to use 2.6 over 2.5.8? <br />
<br />
*IanB: http://forum.doom9.org/showthread.php?p=1629125#post1629125 (note: this was written during the alpha4 phase, maybe some of the things mentioned no longer apply to alpha5?)<br />
<blockquote>As a 2.5.8 replacement 2.6.0 should be just as stable. It passes all current the 2.5 regression tests, while 2.5.8 fails a few due to bugs being fixed and test to expose them being added. Most problems show up in new code, so if you use the new 2.6 features, that is where you might expect to find problems. A lot of people are downloading 2.6. And the only 2.5 bug reports I seem to get are for things broken in 2.5.8 as well, the few 2.6 bug reports are to do with things like YV24 overlay and YV411 text painting.<br />
<br />
I have most of the API changes mapped out to cover hooks for expected features for 2.6.1 and 2.6.2 like extra colour spaces and threading so that 2.6 plugins won't need to be recompiled. I have a long standing bug in the cache from 2.5.7 that I am working on at present and I intend to do an Alpha 5 release when I finish and test that fix. If Alpha 5 stands up without any new bugs I will probably promote it to Release Candidate 1, i.e. 1st Beta release.</blockquote><br />
<br />
*Doom9 thread: [http://forum.doom9.org/showthread.php?t=168478 Which Avisynth version are you using?] - A poll which clearly shows that most people are using 2.6.<br />
<br />
I also have my own little rant on this very issue: http://forum.doom9.org/showthread.php?p=1684284#post1684284 - nothing of importance just frustrated that people are still using 2.5.8 and still have the audacity to complain.<br />
<br />
Regarding the wiki I never really did anything about it because I don't know what my limits are? I know it's a wiki but I also don't want to overstep any boundaries (if any). [[User:Reel.Deal|Reel.Deal]] 15:20, 20 August 2014 (CEST)<br />
<br />
:- yeah I know, editing the main page as a normal user requires chutzpah. [[User:Raffriff42|Raffriff42]] 05:34, 20 August 2014 (CEST)<br />
<br />
::Feel free to make changes, i will read and correct them if necessary. If you want to change something but you are not sure about it, just ask. You can also use the talk pages for such proposals [[User:Admin|Admin]] 16:56, 20 August 2014 (CEST)<br />
<br />
:::OK I put something up there. Feel free to edit or roll back completely. [[User:Raffriff42|Raffriff42]] 21:51, 20 August 2014 (CEST)<br />
<br />
<br />
==== "Avisynth Manual" ====<br />
:...links to [[Internal filters]] - wth?? <br />
<blockquote>Interested? On this site, you can read [[more about AviSynth]], search the official [[Internal filters|AviSynth manual]], and browse the [[AviSynth FAQ]]. Or you can jump straight to pages listed below for downloading Avisynth. </blockquote><br />
:"Internal filters" is a nice page and all, but it's not a Manual. I figured somebody made a typo and went to the [http://web.archive.org/ archive] to find where it went wrong. It seems Internal filters has been the link target for a long, long time - I had to go back to 2007 to find an [http://web.archive.org/web/20070704162253/http://avisynth.org/AviSynthManual "AviSynth Manual."] It ain't much; it's mostly a list of filters. <br />
<br />
:Really, these days, the Main Page '''is''' the Manual - so I propose we revise any phrases like "browse the manual" to something more appropriate to the context - or simply delete references to the Manual altogether.<br />
:[[User:Raffriff42|Raffriff42]] 05:53, 21 September 2014 (CEST)<br />
<br />
:...deleted reference to the Manual, also cleaned up the top nav bar. [[User:Raffriff42|Raffriff42]] 17:51, 21 September 2014 (CEST)<br />
<br />
====User pages====<br />
:re ''User pages hosted on this site'', the listing on the main page is intended to be temporary. I have no idea how many user pages there are; they are hard to find unless you stumble across them, or else maybe drill down into the all of the [http://avisynth.nl/index.php?title=Special%3APrefixIndex&prefix=Template%3A&namespace=0 Author templates]. It would be nice to have an Authors category or better yet, a 'thank-you' page somewhere. It sounds like a lot of work though. If anyone has this info in spreadsheet form in would be a big help. [[User:Raffriff42|Raffriff42]] 18:08, 21 September 2014 (CEST)<br />
<br />
::Not sure what you mean but there are only three authors who have a user page: http://avisynth.nl/index.php?title=Special:ListUsers&limit=100 . I don't know how to get a list of all users who edited at least one page. http://avisynth.nl/index.php/Special:ActiveUsers gives only the users who edited something in the last 30 days. Anyway most users are fake (i think but i'm not sure). They should be merged into a spam account. [[User:Admin|Admin]] 18:29, 21 September 2014 (CEST)<br />
<br />
:::I mean Avisynth code or plugin authors, not Wiki authors in this case. If those are the only 3 then there's no need to do anything more. Thanks. [[User:Raffriff42|Raffriff42]] 19:01, 21 September 2014 (CEST)<br />
<br />
====OldWiki====<br />
The [http://avisynth.org/oldwiki/ "Old Wiki" link] on the sidebar is dead; it should use [[:Template:OldWiki]] - or [http://web.archive.org/web/20100616111740/http://avisynth.org/oldwiki this link] directly. --[[User:Raffriff42|Raffriff42]] 13:26, 19 January 2016 (CET)<br />
<br />
== thank you very much ==<br />
<br />
interesting for a very long time</div>Adminhttp://avisynth.nl/index.php/ResizeResize2024-02-22T20:53:41Z<p>Admin: Reverted edits by 77.205.22.58 (talk) to last revision by Reel.Deal</p>
<hr />
<div><div style="max-width:62em" ><br />
<br />
<div {{BlueBox2|40|0|3px solid purple}} ><br />
{{AvsPlusFullname}}<br><br />
Up-to-date documentation: [https://avisynthplus.readthedocs.io/en/latest/avisynthdoc/corefilters/resize.html https://avisynthplus.readthedocs.io]<br />
</div><br />
<br />
Scales the input video frames to an arbitrary new resolution, and optionally crops the frame before resizing with sub-pixel precision. <br />
<br />
There are trade-offs to be considered between preservation (or augmentation) of image detail and possible artifacts (i.e., oversharpening).<br />
</div><br />
__TOC__<br />
<br />
== Common Parameters ==<br />
<br />
{{Par2|target_width, target_height|int|}}<br />
:Width and height of the returned clip.<br />
<br />
{{Par2|src_left, src_top|float|0, 0}}<br />
:See [[#Cropping |cropping]] discussion below.<br />
<div {{ListItemContinue|2}} ><br />
Cropping of the {{FuncArg|left}} and {{FuncArg|top}} edges respectively, in pixels, before resizing.<br />
</div><br />
<br />
{{Par2|src_width, src_height|float|(source width, height)}}<br />
:See [[#Cropping |cropping]] discussion below.<br />
<div {{ListItemContinue|2}} ><br />
As with [[Crop]], these arguments have different functionality, depending on their value: <br />
* If &nbsp;&gt; zero, these set the '''width''' and '''height''' of the clip before resizing. <br />
* If &lt;= zero, they set the cropping of the '''right''' and '''bottom''' edges respectively, before resizing.<br />
Note, there are certain limits:<br />
* {{FuncArg|clip}}.[[Clip_properties|Width]] must be &gt;= ({{FuncArg|src_left}} + '''width''')<br />
* {{FuncArg|clip}}.[[Clip_properties|Width]] must be &gt;&nbsp; ({{FuncArg|src_left}} + '''right''')<br />
* {{FuncArg|clip}}.[[Clip_properties|Height]] must be &gt;= ({{FuncArg|src_top}} + '''height''')<br />
* {{FuncArg|clip}}.[[Clip_properties|Height]] must be &gt;&nbsp; ({{FuncArg|src_top}} + '''bottom''')<br />
...otherwise it would enlarge ("un-crop") the clip, or reduce width or height to 0, which is not allowed.<br />
</div><br />
<br />
<br />
== Cropping ==<br />
<div style="max-width:62em" ><br />
* All resizers have an expanded syntax which '''crops''' the frame before resizing: <br />
<div {{BoxWidthIndent|54|3}} ><br />
BilinearResize(100, 150, ''src_left''=10, ''src_top''=10, ''src_width''=200, ''src_height''=300)<br />
</div><br />
<div {{ListItemContinue}} ><br />
...or more succinctly:<br />
</div><br />
<div {{BoxWidthIndent|54|3}} ><br />
BilinearResize(100, 150, 10, 10, 200, 300)<br />
</div><div {{ListItemContinue}} ><br />
The operations are the same as if you put [[Crop]] before the Resize:<br />
</div><br />
<div {{BoxWidthIndent|54|3}} ><br />
Crop(10, 10, 200, 300).BilinearResize(100, 150)<br />
</div><br />
<br />
*Note the cropping parameters are all [[Script_variables|floating point]]. This allows any '''Resize''' filter to be used as a sub-pixel shifter. <sup>[http://forum.doom9.org/showpost.php?p=938102&postcount=2]</sup><br />
<br />
*Note that [[Crop]] gives a hard boundary, whereas the '''Resize''' filters interpolate pixels outside the cropped region &ndash; depending on the resizer kernel &ndash; bilinear, bicubic etc, and not beyond the edge of the image.<br />
<br />
*As a general rule, <br />
** [[Crop]] any hard borders or noise; '''Resize''' cropping may propagate the noise into the output. <br />
** Use '''Resize''' cropping to maintain accurate edge rendering when excising a part of a complete image.<br />
<br />
*Negative cropping is allowed; this results in repeated edge pixels as shown below:<br />
<div {{BoxWidthIndent|54|3}} ><br />
BilinearResize(Width, Height, -64, -64, Width, Height)<br />
</div><br />
:[[File:Sintel_frm6291_Resize_shift.jpg|680px]]<br />
</div><br />
<br />
<br />
== BilinearResize ==<br />
<div style="max-width:62em" ><br />
{{FuncDef<br />
|BilinearResize(clip ''clip'', int ''target_width'', int ''target_height'' [, <br><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float ''src_left'', float ''src_top'', float ''src_width'', float ''src_height'' ] )<br />
}}<br />
<br />
'''BilinearResize''' uses standard [[Wikipedia:Bilinear_filtering|bilinear filtering]] and is a good choice for smoothing overly sharp sources.<br />
</div><br />
<br />
<br />
== BicubicResize ==<br />
<div style="max-width:62em" ><br />
{{FuncDef<br />
|BicubicResize(clip ''clip'', int ''target_width'', int ''target_height'' [, float ''b'', float ''c'', <br><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float ''src_left'', float ''src_top'', float ''src_width'', float ''src_height'' ] )<br />
}}<br />
<br />
'''BicubicResize''' is similar to [[#BilinearResize|BilinearResize]], except that instead of a linear filtering function it uses the [[Wikipedia:Mitchell–Netravali_filters|Mitchell–Netravali]] two-part cubic. The parameters {{FuncArg|b}} and {{FuncArg|c}} can be used to adjust the properties of the cubic; they are sometimes referred to as "blurring" and "ringing" respectively.<br />
<br />
If you are enlarging your video, you will get sharper results with '''BicubicResize''' than with BilinearResize. However, if you are shrinking it, you may prefer [[#BilinearResize|BilinearResize]] as it performs some [[Wikipedia:Spatial_anti-aliasing#Examples|antialiasing]]. <br />
<br />
==== parameters ''b'' and ''c'' ====<br />
{{Par2|b, c|float|1/3}}<br />
:The default for both {{FuncArg|b}} and {{FuncArg|c}} is 1/3, which were recommended by Mitchell and Netravali for having the most visually pleasing results. <br />
<br />
<div {{ListItemContinue|2}} ><br />
Set [{{FuncArg|b}} + 2{{FuncArg|c}} = 1] for the most numerically accurate filter. This gives, for {{FuncArg|b}}=0, the maximum value of 0.5 for {{FuncArg|c}}, which is the [[Wikipedia:Cubic_Hermite_spline#Catmull.E2.80.93Rom_spline|Catmull-Rom spline]] and a good suggestion for sharpness. <br />
<br />
Larger values of {{FuncArg|b}} and {{FuncArg|c}} can produce interesting op-art effects &ndash; for example, try ({{FuncArg|b}}=0, {{FuncArg|c}}= -5.0). <br />
<br />
As {{FuncArg|c}} exceeds 0.6, the filter starts to [[Wikipedia:Ringing_artifacts|"ring"]] or overshoot. You won't get true sharpness &ndash; what you'll get is exaggerated edges.<br />
Negative values for {{FuncArg|b}} (although allowed) give undesirable results, so use {{FuncArg|b}}=0 for values of {{FuncArg|c}} > 0.5.<br />
<br />
With ({{FuncArg|b}}=0, {{FuncArg|c}}=0.75) the filter is the same as [http://www.virtualdub.org/blog/pivot/entry.php?id=95 VirtualDub's "Precise Bicubic"]. <br />
<br />
'''BicubicResize''' may be the most visually pleasing of the '''Resize''' filters for ''downsizing'' to half-size or less.<sup>[http://forum.doom9.org/showthread.php?t=172871&page=2 doom9]</sup><br>Try the default setting, ({{FuncArg|b}}=0, {{FuncArg|c}}=0.75) as above, or ({{FuncArg|b}}= -0.5, {{FuncArg|c}}=0.25).<br />
</div><br />
</div><br />
<br />
== BlackmanResize ==<br />
<div style="max-width:62em" ><br />
{{FuncDef<br />
|BlackmanResize(clip ''clip'', int ''target_width'', int ''target_height'' [, <br><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float ''src_left'', float ''src_top'', float ''src_width'', float ''src_height'', int ''taps'' ] )<br />
}}<br />
<br />
'''BlackmanResize''' is a modification of LanczosResize that has better control of [[Wikipedia:Ringing_artifacts|ringing]] artifacts for high numbers of {{FuncArg|taps}}. <br />
<br />
==== parameter ''taps'' ====<br />
{{Par2|taps|int|4}}<br />
:See [[#lanczos_taps|LanczosResize]] for an explanation of the {{FuncArg|taps}} argument (default 4, range 1-100).<br />
</div><br />
<br />
<br />
== GaussResize ==<br />
<div style="max-width:62em" ><br />
{{FuncDef<br />
|GaussResize(clip ''clip'', int ''target_width'', int ''target_height'' [, <br><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float ''src_left'', float ''src_top'', float ''src_width'', float ''src_height'', float ''p'' ] )<br />
}}<br />
<br />
'''GaussResize''' uses a [[Wikipedia:Gaussian_filter|gaussian]] resizer, which unlike the bicubics, does not overshoot &ndash; but perhaps does not appear as sharp to the eye.<br />
<br />
==== parameter ''p'' ====<br />
{{Par2|p|float|30.0}}<br />
:Sharpness. Range from about 1 to 100, with 1 being very blurry and 100 being very sharp.<br />
</div><br />
<br />
<br />
== LanczosResize ==<br />
<div style="max-width:62em" ><br />
{{FuncDef<br />
|LanczosResize(clip ''clip'', int ''target_width'', int ''target_height'' [, <br><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float ''src_left'', float ''src_top'', float ''src_width'', float ''src_height'', int ''taps'' ] )<br />
}}<br />
<br />
{{FuncDef<br />
|Lanczos4Resize(clip ''clip'', int ''target_width'', int ''target_height'' [, <br><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float ''src_left'', float ''src_top'', float ''src_width'', float ''src_height'' ] )<br />
}}<br />
<br />
'''LanczosResize''' is a sharper alternative to [[#BicubicResize|BicubicResize]]. It is NOT suited for low bitrate video; the various Bicubic flavours are much better for this. <br />
<br />
'''Lanczos4Resize''' is a short hand for <code>LanczosResize(taps=4)</code>. It produces sharper images than LanczosResize with the default {{FuncArg|taps}}=3, especially useful when upsizing a clip.<br />
<br />
<div id="lanczos_taps" style="display:inline;font-size:50%;height:0;line-height:0;overflow:hidden;"></div><br />
==== parameter ''taps'' ====<br />
{{Par2|taps|int|3}}<br />
:Basically, {{FuncArg|taps}} affects sharpness. Default 3, range 1-100. Equal to the number of filter [[Wikipedia:Lanczos_resampling#Lanczos_kernel|''lobes'']] (ignoring mirroring around the origin).<br />
<br />
<div {{ListItemContinue|2}} ><br />
''Note:'' the input argument named {{FuncArg|taps}} should really be called "lobes". When discussing resizers, "taps" has a different meaning, as described below:<br />
<br />
<div {{ListItemContinue|1}} ><br />
{{BoldColor|black|120|“}}So when people talk about Lanczos2, they mean a 2-lobe Lanczos-windowed sinc function. There are actually 4 lobes -- 2 on each side...<br />
<br />
For upsampling (making the image larger), the filter is sized such that the entire equation falls across 4 input samples, making it a 4-tap filter. It doesn't matter how big the output image is going to be - it's still just 4 taps. For downsampling (making the image smaller), the equation is sized so it will fall across 4 *destination* samples, which obviously are spaced at wider intervals than the source samples. So for downsampling by a factor of 2 (making the image half as big), the filter covers 8 input samples, and thus 8 taps. For 3X downsampling, you need 12 taps, and so forth.<br />
<br />
The total number of taps you need for downsampling is the downsampling ratio times the number of lobes, times 2. And practically, one needs to round that up to the next even integer. For upsampling, it's always 4 taps.{{BoldColor|black|120|”}}<br />
<br />
[http://www.avsforum.com/forum/26-home-theater-computers/460922-lanczos-vs-bicubic-comparison-2.html#post4760581 Don Munsil (avsforum post)] | [[lanczos lobs/taps|mirror]].<br />
</div><br />
</div><br />
</div><br />
<br />
<br />
== PointResize ==<br />
<div style="max-width:62em" ><br />
{{FuncDef<br />
|PointResize(clip ''clip'', int ''target_width'', int ''target_height'' [, <br><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float ''src_left'', float ''src_top'', float ''src_width'', float ''src_height'' ] )<br />
}}<br />
<br />
'''PointResize''' is the simplest resizer possible. It uses a Point Sampler or [[Wikipedia:Nearest-neighbor_interpolation|Nearest Neighbour]] algorithm, which usually results in a very "blocky" image. So in general this filter should only be used, if you ''intend'' to have inferior quality, or you need the clear pixel drawings. Useful for magnifying small areas for examination.<br />
</div><br />
<br />
<br />
== Spline based resizers ==<br />
<div style="max-width:62em" ><br />
{{FuncDef<br />
|Spline16Resize(clip ''clip'', int ''target_width'', int ''target_height'' [, <br><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float ''src_left'', float ''src_top'', float ''src_width'', float ''src_height'' ] )<br />
}}<br />
<br />
{{FuncDef<br />
|Spline36Resize(clip ''clip'', int ''target_width'', int ''target_height'' [, <br><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float ''src_left'', float ''src_top'', float ''src_width'', float ''src_height'' ] )<br />
}}<br />
<br />
{{FuncDef<br />
|Spline64Resize(clip ''clip'', int ''target_width'', int ''target_height'' [, <br><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float ''src_left'', float ''src_top'', float ''src_width'', float ''src_height'' ] )<br />
}}<br />
<br />
'''Spline16Resize''', '''Spline36Resize''' and '''Spline64Resize''' are three [[Wikipedia:Spline_interpolation|Spline based]] resizers. They are the (cubic) spline based resizers from [http://sourceforge.net/projects/panotools/ Panorama tools] that fit a spline through the sample points and then derives the filter kernel from the resulting blending polynomials. See [http://forum.doom9.org/showthread.php?t=147117 this thread] for the technical details.<br />
<br />
The rationale for '''Spline''' is to be as sharp as possible with less ringing artifacts than [[#LanczosResize|LanczosResize]] produces. '''Spline16Resize''' uses &radic;16 or 4 sample points, '''Spline36Resize''' uses &radic;36 or 6 sample points, etc ... The more sample points used, the more accurate the resampling. Several resizer comparison pages are given in the [[#External Links|External Links]] section. <br />
<br />
*'''Spline64Resize''' may be the most accurate of the '''Resize''' filters.<sup>[http://web.archive.org/web/20060827184031/http://www.path.unimelb.edu.au/~dersch/interpolator/interpolator.html Dersch]</sup><br />
*'''Spline16Resize''' is sharper and [[Wikipedia:Ringing_artifacts|rings]] just a bit (which may be desirable with soft sources),<br>and looks pleasing to the eye when enlarging or reducing in moderate amounts.<sup>[http://forum.doom9.org/showthread.php?p=1689519#post1689519 doom9]</sup><br />
*'''Spline36Resize''' is somewhere in between the other two.<br />
</div><br />
<br />
<br />
== SincResize ==<br />
<div style="max-width:62em" ><br />
{{FuncDef<br />
|SincResize(clip ''clip'', int ''target_width'', int ''target_height'' [, <br><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float ''src_left'', float ''src_top'', float ''src_width'', float ''src_height'', int ''taps'' ] )<br />
}}<br />
<br />
'''SincResize''' uses the truncated sinc function. It is very sharp, but prone to [[Wikipedia:Ringing_artifacts|ringing]] artifacts.<br />
<br />
==== parameter ''taps'' ====<br />
{{Par2|taps|int|4}}<br />
:See [[#lanczos_taps|LanczosResize]] for an explanation of the {{FuncArg|taps}} argument (default 4, range 1-20).<br />
</div><br />
<br />
<br />
== Examples ==<br />
* Cropping:<br />
<div {{BoxWidthIndent|42|3}} ><br />
Crop(10, 10, 200, 300).BilinearResize(100, 150)<br />
</div><br />
<div {{ListItemContinue}} ><br />
which is nearly the same as:<br />
</div><br />
<div {{BoxWidthIndent|42|3}} ><br />
BilinearResize(100, 150, 10, 10, 200, 300)<br />
</div><br />
<br />
* Load a video file and resize it to 240x180 (from whatever it was before)<br />
<div {{BoxWidthIndent|42|3}} ><br />
AviSource("video.avi").BilinearResize(240,180)<br />
</div><br />
<br />
* Load a 720x480 ([[Wikipedia:Rec._601|Rec. 601]]) video and resize it to 352x240 ([[Wikipedia:Video_CD|VCD]]), preserving the correct aspect ratio<br />
<div {{BoxWidthIndent|42|3}} ><br />
AviSource("dv.avi").BilinearResize(352, 240, 8, 0, 704, 480)<br />
</div> <br />
<div {{ListItemContinue}} ><br />
which is the same as:<br />
</div><br />
<div {{BoxWidthIndent|42|3}} ><br />
AviSource("dv.avi").BilinearResize(352, 240, 8, 0, -8, -0)<br />
</div><br />
<br />
* Extract the upper-right quadrant of a 320x240 video and zoom it to fill the whole frame<br />
<div {{BoxWidthIndent|42|3}} ><br />
BilinearResize(320, 240, 160, 0, 160, 120)<br />
</div><br />
<br />
<br />
== Notes ==<br />
<div style="max-width:62em" ><br />
* AviSynth has completely separate vertical and horizontal resizers. If input is the same as output on one axis, that resizer will be skipped. The resizer with the smallest downscale ratio is called first; this is done to preserve maximum quality, so the second resizer has the best possible picture to work with. [[Filter_SDK/Data_storage|Data storing]] will have an impact on what [[Modulo|mods]] should be used for sizes when resizing and cropping; see [[Crop#Crop restrictions|Crop restrictions]].<br />
</div><br />
<br />
<br />
== External Links ==<br />
* [http://hermidownloads.craqstar.de/videoresizefiltercomparasion/ ''AviSynth resize filter comparison''] (hermidownloads.craqstar.de) | [http://web.archive.org/web/20130815024055/http://hermidownloads.craqstar.de/videoresizefiltercomparasion archived link]<br />
* [http://jeanbruenn.info/2011/10/30/upscaling-in-avisynth-comparison-of-resizers/ ''Upscaling in Avisynth – Comparison of resizers''] (jeanbruenn.info) | [http://web.archive.org/web/20140207171106/http://jeanbruenn.info/2011/10/30/upscaling-in-avisynth-comparison-of-resizers/ archived link]<br />
* [http://web.archive.org/web/20060827184031/http://www.path.unimelb.edu.au/~dersch/interpolator/interpolator.html ''Testing Interpolator Quality''] (Helmut Dersch, Technical University Furtwangen)<br />
* [http://forum.doom9.org/showthread.php?t=172871 ''Discussion of resizers for downsizing''] (doom9.org)<br />
<br />
<br />
== Changelog ==<br />
{| border="1"<br />
|- <br />
| v2.60<br />
| Added SincResize.<br />
|- <br />
| v2.58<br />
| Added BlackmanResize, Spline64Resize.<br />
|- <br />
| v2.56<br />
| Added Spline16Resize, Spline36Resize, GaussResize and taps parameter in LanczosResize; added offsets in Crop part of xxxResize.<br />
|- <br />
| v2.55<br />
| Added Lanczos4Resize.<br />
|}<br />
<br />
[[Category:Internal filters]]<br />
[[Category:Resizers]]</div>Adminhttp://avisynth.nl/index.php/Talk:ImageSourceTalk:ImageSource2024-02-22T20:51:30Z<p>Admin: Reverted edits by 154.6.91.7 (talk) to last revision by Admin</p>
<hr />
<div>If you have trouble loading animated GIFs, see this discussion @ doom9.org:<br />
<br />
Try AviSynth+<br />
Try FFmpegSource<br />
Try LSMASHSource/LWLibavVideoSource <br />
<br />
:Both animated gifs (that are mentioned in that thread) load fine for me. Guess they must be using the old DevIL library or so. Please don't do this without testing it yourself (and file a bug report etc ...).<br />
:Feel free to add alternative ways to import images here: http://avisynth.nl/index.php/Importing_media#How_do_I_load_my_image_into_AviSynth.3F [[User:Admin|Admin]] 23:08, 1 February 2016 (CET)</div>Adminhttp://avisynth.nl/index.php/FeedbackFeedback2024-01-24T22:00:06Z<p>Admin: Reverted edits by 185.54.231.69 (talk) to last revision by Admin</p>
<hr />
<div>{{BlueBox}}'''The Feedback page has been retired.''' <br><br />
To give feedback, report bugs or ask for help, please visit the [http://forum.doom9.org/forumdisplay.php?s=&forumid=33 Doom9 AviSynth Usage Forum]{{End_BlueBox}}<br />
<br />
[[Category:AviSynth_Usage]]<br />
<br />
<div style="display:none"><br />
THIS PAGE IS OBSOLETE<br />
<br />
Please put <nowiki>~~~</nowiki> behind your comments to add your name/date.<br />
<br />
I tried to download avisynth but get a message that I need administrator rights to install it. I have administrator rights and have never had a problem downloading anything before. Any idea what's wrong? Anyone else have this problem?<br />
<br />
:See [http://forum.doom9.org/showthread.php?t=97406]. Apperently you are not the only one with this problem. Uninstalling it first solves the problem. What is the latest AviSynth version which installs without problems? [[User:Wilbert|Wilbert]] 03:39, 31 March 2006 (EST)<br />
<br />
The Resize (tried Bicubic and Spline36) function crashes AviSynth on my Windows Vista 64-bit, 8GB RAM (core2quad). Everything else works fine - including all other functions/filters I tried.<br />
<br />
I would like to port all the plugins documentation (website / readme files) and the plugins themself into this wiki so no data get lost because of canceled webhosting services, removed images, etc. Can i just start or do i have to ask the plugin developer for permission before? What if the developer does not reply at all? Is there a special wiki page naming system i should follow? Does the server behind avisynth.org have enough power to host the whole wiki & files or should i help with my own ded. server? :) Thanks! [[User:An3k|an3k]] 12:58, 21 December 2012 (UTC)<br />
<br />
i would like to buy your website , is it for sale? <br />
<br />
if yes reply me at yonielbb1@gmail.com with the price</div>Adminhttp://avisynth.nl/index.php/FeedbackFeedback2023-11-25T09:29:37Z<p>Admin: Reverted edits by 85.250.12.135 (talk) to last revision by Admin</p>
<hr />
<div>{{BlueBox}}'''The Feedback page has been retired.''' <br><br />
To give feedback, report bugs or ask for help, please visit the [http://forum.doom9.org/forumdisplay.php?s=&forumid=33 Doom9 AviSynth Usage Forum]{{End_BlueBox}}<br />
<br />
[[Category:AviSynth_Usage]]<br />
<br />
<div style="display:none"><br />
THIS PAGE IS OBSOLETE<br />
<br />
Please put <nowiki>~~~</nowiki> behind your comments to add your name/date.<br />
<br />
I tried to download avisynth but get a message that I need administrator rights to install it. I have administrator rights and have never had a problem downloading anything before. Any idea what's wrong? Anyone else have this problem?<br />
<br />
:See [http://forum.doom9.org/showthread.php?t=97406]. Apperently you are not the only one with this problem. Uninstalling it first solves the problem. What is the latest AviSynth version which installs without problems? [[User:Wilbert|Wilbert]] 03:39, 31 March 2006 (EST)<br />
<br />
The Resize (tried Bicubic and Spline36) function crashes AviSynth on my Windows Vista 64-bit, 8GB RAM (core2quad). Everything else works fine - including all other functions/filters I tried.<br />
<br />
I would like to port all the plugins documentation (website / readme files) and the plugins themself into this wiki so no data get lost because of canceled webhosting services, removed images, etc. Can i just start or do i have to ask the plugin developer for permission before? What if the developer does not reply at all? Is there a special wiki page naming system i should follow? Does the server behind avisynth.org have enough power to host the whole wiki & files or should i help with my own ded. server? :) Thanks! [[User:An3k|an3k]] 12:58, 21 December 2012 (UTC)<br />
<br />
i would like to buy your website , is it for sale? <br />
<br />
if yes reply me at yonielbb1@gmail.com with the price</div>Adminhttp://avisynth.nl/index.php/Main_PageMain Page2023-09-24T14:32:11Z<p>Admin: </p>
<hr />
<div>__NOTOC__<br />
<div style="min-width: 700px; max-width: 1400px; margin: auto;"><br />
<p style="clear:both; margin-top:-3px; margin-bottom: 1em; font-variant: small-caps; text-align: center; font-size: 105%;"><br />
<!-- These should be fundamental categories --> <br />
[[AviSynth FAQ]] | <br />
[[Internal filters]] | <br />
[[External filters]] | <br />
[[AviSynth Syntax]] | <br />
[http://sourceforge.net/projects/avisynth2/ Sourceforge] | <br />
[http://forum.doom9.org/forumdisplay.php?s=&forumid=33 Doom9 Forum]<br />
</p><br />
[[File:Avisynth-logo-tray.png|center|280px|AviSynth]] <br />
<br />
{| role="presentation" style="border:0; margin:0;" width="90%" cellspacing="10"<br />
| colspan="2"| <!-- Row 0 --><br />
=== {{ReverseHeading3|What is AviSynth?}} === __NOEDITSECTION__<br />
<p><br />
AviSynth is a powerful tool for video post-production. It provides ways of editing and processing videos. AviSynth works as a [[frameserver]], providing instant editing without the need for temporary files.<br />
<br />
AviSynth itself does not provide a graphical user interface (GUI), but instead relies on a script system that allows advanced [[NLE|non-linear editing]]. While this may at first seem tedious and unintuitive, it is remarkably powerful and is a very good way to manage projects in a precise, consistent, and reproducible manner. Because text-based scripts are human readable, projects are inherently self-documenting. The scripting language is simple yet powerful, and complex filters can be created from basic operations to develop a sophisticated palette of useful and unique effects.<br />
</p><br />
<p><br />
AviSynth is free open-source software, and licensed under the [http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License GPLv2].<br />
</p><br />
<br />
|-<br />
| style="vertical-align: top; width:50%; padding-right:2em; padding-top: 1em;" | <!-- Row 1 Left --><br />
=== {{ReverseHeading3|New to AviSynth – Start Here}} === __NOEDITSECTION__<br />
* '''[[first script|Your first script]]''' – A guide for total newbies.<br />
* '''[[Getting started]]''' – An introductory guide.<br />
* '''[[Grammar]]''' – An introduction to the AviSynth scripting language.<br />
* '''[[Filter introduction]]''' – An introductory guide to most common AviSynth [[Filter|filters]].<br />
* '''[[Script examples]]''' – Putting everything together in the real world.<br />
* '''[[AviSynth FAQ]]''' – Answers to many common problems.<br />
* [[More_about_AviSynth|More information]] ''(How does it work? When is it useful? Why no GUI? What applications work well with AviSynth?)''<br />
* [[Guides]] – Guides explaining the basics, tips on specific conversion types and common tasks.<br />
* [[Troubleshooting]] your scripts and configuration.<br />
<br />
<br />
{|style="border:none;max-width:26em;margin-left:1em"<br />
|style="padding:0.5em"|[[File:Overlay-example-lighten.png|104px|link=Overlay|Overlay: Lighten mode]]<br />
|style="padding:0.5em"|[[File:Layer-example-lite.png|104px|link=Layer|Layer: Lighten mode]]<br />
|style="padding:0.5em"|[[File:Overlay-example-subtract.png|104px|link=Overlay|Overlay: Subtract mode]]<br />
|-<br />
|style="padding:0.5em"|[[File:Overlay-example-add.png|104px|link=Overlay|Overlay: Add mode]]<br />
|style="padding:0.5em"|[[File:Layer-example-mul-rgb.png|104px|link=Layer|Layer: Multiply mode]]<br />
|style="padding:0.5em"|[[File:Layer-base-Lena.png|104px|link=File:Lenna.png|Lenna]]<br />
|}<br />
<br />
|style="vertical-align: top; width:50%; padding-top: 1em;" | <!-- Row 1 Right --><br />
=== {{ReverseHeading3|Download AviSynth}} === __NOEDITSECTION__<br />
*'''Current Builds'''<br />
::{{AvsPlusFullname}}<br />
::New features, backward compatible, native support for Unix-like OSes.<br />
::[[AviSynth%2B|Wiki page]]<br />
::[http://www.avs-plus.net/ Homepage (avs-plus.net)&nbsp;]<br />
::[https://github.com/AviSynth/AviSynthPlus/releases Latest release (GitHub)&nbsp;]<br />
::[https://forum.doom9.org/showthread.php?t=181351 Discussion] at forum.doom9.org<br />
<br />
*''Deprecated Official builds''<br />
::[http://sourceforge.net/projects/avisynth2/ v.2.6.0 ST, 32-bit] at [[SourceForge]]<br />
<br />
*''Deprecated Unofficial builds''<br />
::[http://forum.doom9.org/showthread.php?t=148782 v.2.6.0 MT, 32-bit, author SET] <br>at forum.doom9.org<br />
<br />
*'''Universal Installer'''<br />
::Install&mdash;and quickly switch between&mdash;AviSynth versions:<br />
::* Avisynth 2.5.8, 2.6.0, 2.6.0 MT, 2.6.1 Alpha<br />
::* Avisynth+ 32-bit, 64-bit<br />
::Get it [http://forum.doom9.org/showthread.php?t=172124 here] at forum.doom9.org<br />
<br />
*''Deprecated Multithread Version''<br />
::v.2.5.8 MT, 32-bit, author SET, <br>[http://forum.doom9.org/showthread.php?t=148117 discussion at forum.doom9.org]<br />
::v.2.5.8 MT, 64-bit, author SET, <br>[http://forum.doom9.org/showthread.php?t=152800 compiled by JoshyD at forum.doom9.org] <br />
::[https://github.com/avxsynth/avxsynth AvxSynth] <br>AviSynth 2.5.8 running on Ubuntu 32/64. <br />
<br />
*''Old Bugs and issues''<br />
::[[Known Issues v2.58|Known Issues in v2.58]].<br />
::[[Known Issues|Known Issues in v2.60]].<br />
<br />
|-<br />
|style="vertical-align:top; width:50%; padding-right:2em; padding-top: 1em;" | <!-- Row 2 Left --><br />
=== {{ReverseHeading3|Script Syntax}} === __NOEDITSECTION__<br />
''The official reference documentation.''<br />
* [[AviSynth Syntax|AviSynth Syntax overview]]<br />
** '''[[Script variables]]''' – How to declare and use them in scripts.<br />
** '''[[Operators]]''' – Available operators and relative precedence.<br />
** '''[[Internal functions]]''' – General purpose functions for math, logic etc.<br />
** '''[[Clip properties]]''' – Properties such as Width, Height, Framerate etc.<br />
** '''[[Control structures]]''' – Language constructs for script flow control.<br />
** '''[[User defined script functions]]''' – How to define and use them in scripts.<br />
** '''[[Plugins]]''' – How to load them (AviSynth, VirtualDub, VFAPI and C-plugins); autoloading and name-precedence explained. Most '''[[External filters]]''' are plugins; the rest are regular scripts.<br />
** '''[[Runtime environment]]''' – Scripting on a per-clip frame basis.<br />
** '''[[Function objects]]''' – {{AvsPluscon}}user defined functions as variables, capture external variables, use them in ScriptClip instead of stringified script fragments.<br />
<br />
|style="vertical-align:top; width:50%; padding-top: 1em;" | <!-- Row 2 Right --><br />
=== {{ReverseHeading3|Filters and Utilities}} === __NOEDITSECTION__<br />
* '''[[Internal filters]]''' – Included media [[Filter|filters]], organized by category.<br />
* '''[[External filters]]''' – Hundreds of separately downloadable filters, organized by category.<br />
* User pages hosted on this site:<br />
** [http://www.avisynth.nl/users/warpenterprises/ AviSynth Filter Collection – Warpenterprises]<br />
** [http://www.avisynth.nl/users/fizick/fizick.html Fizick’s AviSynth plugins]<br />
** [http://www.avisynth.nl/users/vcmohan/ vcmohan’s Plugin Filters]<br />
** [http://www.avisynth.nl/users/stickboy/ stickboy’s AviSynth Stuff]<br />
* [[Shared functions]] – Commonly used script functions.<br />
* [[Utilities]] – A list of GUIs, command-line, batch and other AviSynth related utilities.<br />
<br />
|-<br />
|style="vertical-align:top; width:50%; padding-right:2em; padding-top: 1em;" | <!-- Row 3 Left --><br />
=== {{ReverseHeading3|Scripting reference}} === __NOEDITSECTION__<br />
''Beyond scripting basics''<br />
* [[Scripting reference|Scripting reference overview]] <br />
** [[The full AviSynth grammar]] – The AviSynth grammar revisited and explained in detail.<br />
** [[The script execution model]] – The steps behind the scenes from the script to the final video clip output. The filter graph. Scope and lifetime of variables. Evaluation of runtime scripts.<br />
** [[User functions]] – How to effectively write and invoke user defined script functions; common pitfalls to avoid; ways to organise your function collection and create libraries of functions, and many more.<br />
** [[Block statements]] – Techniques and coding idioms for creating blocks of AviSynth script statements.<br />
** [[Arrays]] – Using arrays (and array operators) for manipulating collections of data in a single step.<br />
** [[Scripting at runtime]] – How to unravel the power of runtime filters and create complex runtime scripts that can perform interesting (and memory/speed efficient) editing/processing operations and effects.<br />
<br />
|style="vertical-align:top; width:40%; padding-top: 1em;" | <!-- Row 3 Right --><br />
<br><br><br />
[[File:ChannelMixer_Before%26After.png|center|240px|link=ChannelMixer|ChannelMixer before and after]]<br />
<div style="text-align:center;"><br />
[[File:Maskhs.jpg|100px|link=MaskHS|MaskHS(startHue=105, endHue=138)]] <br />
[[File:Histogram audiolevels.jpg|120px|link=Histogram#Audiolevels_mode|Histogram(mode="audiolevels")]]<br />
<br />
[[File:Histogram-tournesol-color2.png|center|240px|link=Histogram#Color2_mode|Histogram(mode="color2")]]<br />
</div><br />
<br />
|-<br />
|style="vertical-align:top; width:50%; padding-right:2em; padding-top: 1em;" | <!-- Row 4 Left --><br />
=== {{ReverseHeading3|Advanced topics}} === __NOEDITSECTION__<br />
* [[Advanced Scripting Tips]] – Using recursion, weaving 3 clips, and other programming tips.<br />
* [[Advanced topics]] – Chroma Upsampling Error, color conversions, hybrid video, motion compensation, and other advanced subjects.<br />
* [[Aspect ratios|Aspect ratios explained]] – Introduction to aspect ratios (DAR, PAR, SAR), and how to use that for resizing your clip.<br />
* [[High_bit-depth_Support_with_Avisynth|High bit-depth ('''Deep Color''') support with AviSynth]]<br />
{|<br />
|[[File:Downsampling_bilinear.png|center|180px|link=Resampling#Bilinear_resampler|Resampling: Bilinear upsampling]]<br />
|[[File:Blackman.jpg|center|180px|link=Resampling#Blackman_resampler|Resampling: Blackman filter response]]<br />
|}<br />
<br />
|style="vertical-align:top; width:50%; padding-top: 1em;" | <!-- Row 4 Right --><br />
=== {{ReverseHeading3|Development}} === __NOEDITSECTION__<br />
* Want to [[get involved]]?<br />
* The [http://sourceforge.net/projects/avisynth2/ official project].<br />
* Learn how to [[Filter_SDK/Compile AviSynth|install compilers and setup environments]].<br />
* Learn how to [[Filter_SDK/Compile AviSynth|compile AviSynth]], [[Filter_SDK/Compiling_instructions|AviSynth plugins]] and [[Filter_SDK/Compiling_instructions|console applications that access AviSynth]].<br />
* Learn how to debug [[Filter_SDK/Debugging_instructions|AviSynth]], [[Filter_SDK/Debugging_instructions|AviSynth plugins]] and [[Filter_SDK/Debugging_instructions|console applications that access AviSynth]].<br />
* [[Filter SDK]] – AviSynth plugin programming tips.<br />
* [[Avisynth Plugin Development in C]] – A tutorial to write a plugin with&nbsp;C.<br />
* [http://forum.doom9.org/forumdisplay.php?s=&forumid=69 AviSynth Developer Forum]<br />
* The ongoing [[changelist]].<br />
* About the development of [[AviSynth v3]] (which will be platform independent).<br />
* References to [[Image Processing Algorithms|image processing algorithms]].<br />
<br />
|-<br />
| colspan="1" style="vertical-align:top; padding-top: 1em;" | <!-- Row 5 Left --><br />
=== {{ReverseHeading3|About This Website}} === __NOEDITSECTION__<br />
We need your help to build and improve our site! <br />
*'''Editing''' is easy! Please see [http://www.mediawiki.org/wiki/Help:Editing_pages Editing pages] and [http://www.mediawiki.org/wiki/Help:Formatting Formatting].<br />
*To port this site to '''another language''', please see the [http://www.mediawiki.org/wiki/Localisation MediaWiki Localisation Guide.] <br />
*'''Filter and script authors''' – please see [http://forum.doom9.org/showthread.php?t=171356 ''Submit your Documentation''] on doom9.org, and the documentation template [[ExampleFilter]].<br />
<br />
|style="vertical-align:top; font-size:96%; width:50%; padding-top: 1em;" | <!-- Row 5 Right --><br />
=== {{ReverseHeading3|Documentation Copyright}} === __NOEDITSECTION__<br />
AviSynth documentation is [[Avisynth_wiki:Copyrights|Copyright (c) 2002-{{CURRENTYEAR}}]] AviSynth developers and contributors.<br />
<br />
The contents of [http://avisynth.org avisynth.org] and [http://avisynth.nl avisynth.nl] are released under the ''Creative Commons Attribution-ShareAlike 3.0 License'' [http://creativecommons.org/licenses/by-sa/3.0/ (CC BY-SA 3.0)].<br />
<br />
|}<br />
</div><br />
[[Category:AviSynth]]</div>Adminhttp://avisynth.nl/index.php/FeedbackFeedback2023-09-22T19:43:20Z<p>Admin: Reverted edits by 85.65.147.180 (talk) to last revision by 84.32.52.31</p>
<hr />
<div>{{BlueBox}}'''The Feedback page has been retired.''' <br><br />
To give feedback, report bugs or ask for help, please visit the [http://forum.doom9.org/forumdisplay.php?s=&forumid=33 Doom9 AviSynth Usage Forum]{{End_BlueBox}}<br />
<br />
[[Category:AviSynth_Usage]]<br />
<br />
<div style="display:none"><br />
THIS PAGE IS OBSOLETE<br />
<br />
Please put <nowiki>~~~</nowiki> behind your comments to add your name/date.<br />
<br />
I tried to download avisynth but get a message that I need administrator rights to install it. I have administrator rights and have never had a problem downloading anything before. Any idea what's wrong? Anyone else have this problem?<br />
<br />
:See [http://forum.doom9.org/showthread.php?t=97406]. Apperently you are not the only one with this problem. Uninstalling it first solves the problem. What is the latest AviSynth version which installs without problems? [[User:Wilbert|Wilbert]] 03:39, 31 March 2006 (EST)<br />
<br />
The Resize (tried Bicubic and Spline36) function crashes AviSynth on my Windows Vista 64-bit, 8GB RAM (core2quad). Everything else works fine - including all other functions/filters I tried.<br />
<br />
I would like to port all the plugins documentation (website / readme files) and the plugins themself into this wiki so no data get lost because of canceled webhosting services, removed images, etc. Can i just start or do i have to ask the plugin developer for permission before? What if the developer does not reply at all? Is there a special wiki page naming system i should follow? Does the server behind avisynth.org have enough power to host the whole wiki & files or should i help with my own ded. server? :) Thanks! [[User:An3k|an3k]] 12:58, 21 December 2012 (UTC)<br />
<br />
i would like to buy your website , is it for sale? <br />
<br />
if yes reply me at yonielbb1@gmail.com with the price</div>Adminhttp://avisynth.nl/index.php/User:Raffriff42User:Raffriff422023-09-22T19:41:46Z<p>Admin: Reverted edits by 64.44.118.197 (talk) to last revision by Raffriff42</p>
<hr />
<div>[[Category:Talk]]<br />
=== Subpages ===<br />
:[[File:Utils-r41.avsi|'''Utils-r41.avsi''']] (a library of basic utility functions; most require AVS+)<br />
:[[User:Raffriff42/Utils-r41_Quick_Reference|'''Utils-r41_Quick_Reference''']] (a quick reference page for the above)<br />
<br />
:[[User:Raffriff42/Wiki_notes|'''Wiki_notes''']] (useful wikicode snippets)<br />
<br />
:[[User:Raffriff42/sandbox]] (blank)<br />
:[[User:Raffriff42/Main_Page_sandbox]] (blank)<br />
<br />
=== Talk ===<br />
<br />
==== Color Presets, Categories ====<br />
I like what you did with the color presets :) - [[User:Reel.Deal|Reel.Deal]] , August 4th 2014<br />
:Hi again. Please fix the categories when you have time: http://avisynth.nl/index.php/Special:WantedCategories (either create them or remove them if they are doubles). Thanks for your efforts! Btw, the complete list: http://avisynth.nl/index.php/Special:Categories [[User:Admin|Admin]] 00:35, 21 September 2014 (CEST)<br />
:Please also look at http://avisynth.nl/index.php/Special:LonelyPages . These pages are not linked from anywhere. [[User:Admin|Admin]] 00:52, 21 September 2014 (CEST)<br />
::Sure thing, I will look at them soon. <br />
::[[User:Raffriff42|Raffriff42]] 04:54, 21 September 2014 (CEST)<br />
<br />
:::Hi, can you please hold off on doing that for just a bit? A handful of those entries are mine and I would like to revise and edit a few things before it gets finalized. I already started but I need a little bit more time. [[User:Reel.Deal|Reel.Deal]] 12:12, 21 September 2014 (CEST)<br />
<br />
::::You are better qualified to do the Categories anyway, as it is related to the (amazing) work you've been doing lately with External Filters. I'm gonna be busy with the TODO pages for a while, and after that, or maybe before that, a little break time; I'm tired! [[User:Raffriff42|Raffriff42]] 16:12, 21 September 2014 (CEST)<br />
<br />
::Progress report: I have done some work on [[Special:Categories|Categories]], including as many [[Special:WantedCategories|Wanted Categories]] as I could fix - leaving the foreign language ones, and some others that look like Reel.Deal might be working on them. Ditto, [[Special:WantedPages|Wanted Pages]]. There remains one [[Special:WantedFiles|Wanted File]] that I cannot fix, namely [[Frebuild.avsi]]. That file seems to be lost. <br />
::[[User:Raffriff42|Raffriff42]] 03:05, 15 November 2015 (CET)<br />
<br />
<br />
:::Raffriff42, your recent changes to the templates broke some pages, take a look at [[ChromaShiftSP]], [[FTurn]], and probably more. Also the author's section in the abstract table looks off now (look at FTurn). [[User:Reel.Deal|Reel.Deal]] 05:41, 14 December 2015 (CET)<br />
<br />
:::Putting the category without a line break fixes the problem, I'll try to go back and do it to all templates. [[User:Reel.Deal|Reel.Deal]] 05:53, 14 December 2015 (CET)<br />
<br />
::::Ouch, so sorry about that! I should have checked! -- [[User:Raffriff42|Raffriff42]] 06:22, 14 December 2015 (CET)<br />
<br />
"clip.BlankClip does not work reliably here; use BlankClip(clip) instead"<br />
Please explain. Why, when, under what circumstances? [[User:Admin|Admin]] 16:04, 10 February 2018 (CET)<br />
: aaaah sorry, I can't recreate the problem now and can't find the script where I first experienced it. It was probably some error on my part. I'll remove that line right away. [[User:Raffriff42|Raffriff42]] 04:37, 11 February 2018 (CET)</div>Adminhttp://avisynth.nl/index.php/Filter_SDK/C_API/AVS_VideoInfoFilter SDK/C API/AVS VideoInfo2023-04-01T22:04:59Z<p>Admin: </p>
<hr />
<div>The AVS_VideoInfo structure holds global information about a clip (i.e. information that does not depend on the frame number). It's a member of the AVS_FilterInfo structure. Below is a description of it (for AVISYNTH_INTERFACE_VERSION=6).<br />
<br />
== Properties and constants ==<br />
* Colorspace constants, Colorformat constants and Image_type constants:<br />
<br />
:These constants are the same as the ones in the C++ API with a AVS_ prefix. For example, the C++ API constant CS_BGR becomes AVS_CS_BGR.<br />
<br />
:For some reason these constants are not part of the AVS_VideoInfo structure. Why not???<br />
<br />
* Colorspace properties, Image_type properties and General properties:<br />
<br />
:These are the same as in the C++ API.<br />
<br />
* Chroma placement constants (bits 20 -> 23):<br />
<br />
:They are missing in the C API. Todo: add them in the API.<br />
<br />
* Remaining constants (they are not present in the C++ API):<br />
<br />
enum {<br />
AVS_FILTER_TYPE=1,<br />
AVS_FILTER_INPUT_COLORSPACE=2,<br />
AVS_FILTER_OUTPUT_TYPE=9,<br />
AVS_FILTER_NAME=4,<br />
AVS_FILTER_AUTHOR=5,<br />
AVS_FILTER_VERSION=6,<br />
AVS_FILTER_ARGS=7,<br />
AVS_FILTER_ARGS_INFO=8,<br />
AVS_FILTER_ARGS_DESCRIPTION=10,<br />
AVS_FILTER_DESCRIPTION=11<br />
};<br />
<br />
enum { //SUBTYPES<br />
AVS_FILTER_TYPE_AUDIO=1,<br />
AVS_FILTER_TYPE_VIDEO=2,<br />
AVS_FILTER_OUTPUT_TYPE_SAME=3,<br />
AVS_FILTER_OUTPUT_TYPE_DIFFERENT=4<br />
};<br />
<br />
Todo: add description.<br />
<br />
== Functions [need to add examples] ==<br />
<br />
These functions are not members of the AVS_VideoInfo structure, but they take an AVS_VideoInfo structure as input. Unless stated otherwise the functions have the same funcionality as the corresponding ones in the C++ API.<br />
<br />
Note the name of the functions are basically the same as the ones in the C++ API, with a 'avs_' prefix, a AVS_VideoInfo as input, lower case letters and with a underscore between separate words in the name. <br />
<br />
For example, instead of vi.IsYUV(), you would use avs_is_yuv(&fi->vi) where fi is a pointer to AVS_FilterInfo.<br />
<br />
{|class="wikitable"<br />
!text-align:center;"|C++ API<br />
!text-align:center;"|C API<br />
|-<br />
|bool IsRGB() const<br />
|int avs_is_rgb(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsRGB24() const<br />
|int avs_is_rgb24(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsRGB32() const<br />
|int avs_is_rgb32(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYUV() const;<br />
|int avs_is_yuv(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYUY2() const;<br />
|int avs_is_yuy2(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYV24() const;<br />
|int avs_is_yv24(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYV16() const;<br />
|int avs_is_yv16(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYV12() const;<br />
|int avs_is_yv12(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYV411() const;<br />
|int avs_is_yv411(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsY8() const;<br />
|int avs_is_y8(const AVS_VideoInfo * p);<br />
|- border="2"<br />
|bool IsColorSpace(int c_space) const;<br />
|int avs_is_color_space(const AVS_VideoInfo * p, int c_space);<br />
|-<br />
|bool IsSameColorspace(const VideoInfo& vi) const;<br />
|int avs_is_same_colorspace(AVS_VideoInfo * x, AVS_VideoInfo * y)<br />
|-<br />
|bool IsPlanar() const;<br />
|int avs_is_planar(const AVS_VideoInfo * p)<br />
|-<br />
|bool Is(int property) const;<br />
|int avs_is_property(const AVS_VideoInfo * p, int property)<br />
|-<br />
|bool IsFieldBased() const;<br />
|int avs_is_field_based(const AVS_VideoInfo * p)<br />
|-<br />
|bool IsParityKnown() const;<br />
|int avs_is_parity_known(const AVS_VideoInfo * p)<br />
|-<br />
|bool IsBFF() const;<br />
|int avs_is_bff(const AVS_VideoInfo * p)<br />
|-<br />
|bool IsTFF() const;<br />
|int avs_is_tff(const AVS_VideoInfo * p);<br />
|-<br />
|void SetFieldBased(bool isfieldbased);<br />
|void avs_set_field_based(AVS_VideoInfo * p, int isfieldbased);<br />
|-<br />
|void Set(int property);<br />
|void avs_set_property(AVS_VideoInfo * p, int property);<br />
|-<br />
|void Clear(int property);<br />
|void avs_clear_property(AVS_VideoInfo * p, int property);<br />
|-<br />
|int BitsPerPixel() const;<br />
|int avs_bits_per_pixel(const AVS_VideoInfo * p);<br />
|-<br />
|void SetFPS(unsigned numerator, unsigned denominator);<br />
|void avs_set_fps(AVS_VideoInfo * p, unsigned numerator, unsigned denominator)<br />
|-<br />
|void MulDivFPS(unsigned multiplier, unsigned divisor);<br />
|doesn't exist<br />
|-<br />
|int BytesFromPixels(int pixels) const;<br />
|int avs_bytes_from_pixels(const AVS_VideoInfo * p, int pixels);<br />
|-<br />
|int RowSize(int plane=0) const;<br />
|int avs_row_size_p(const AVS_VideoInfo * p, int plane);<br />
|-<br />
|int BMPSize() const;<br />
|int avs_bmp_size(const AVS_VideoInfo * vi);<br />
|-<br />
|int GetPlaneWidthSubsampling(int plane) const;<br />
|int avs_get_plane_width_subsampling(const AVS_VideoInfo * p, int plane);<br />
|-<br />
|int GetPlaneHeightSubsampling(int plane) const;<br />
|int avs_get_plane_height_subsampling(const AVS_VideoInfo * p, int plane);<br />
|-<br />
|bool HasAudio() const;<br />
|int avs_has_audio(const AVS_VideoInfo * p);<br />
|-<br />
|int AudioChannels() const;<br />
|int avs_audio_channels(const AVS_VideoInfo * p);<br />
|-<br />
|int SampleType() const;<br />
|int avs_sample_type(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsSampleType(int testtype) const;<br />
|doesn't exist<br />
|-<br />
|int SamplesPerSecond() const;<br />
|int avs_samples_per_second(const AVS_VideoInfo * p);<br />
|-<br />
|int BytesPerAudioSample() const;<br />
|int avs_bytes_per_audio_sample(const AVS_VideoInfo * p);<br />
|-<br />
|int BytesPerChannelSample() const;<br />
|int avs_bytes_per_channel_sample(const AVS_VideoInfo * p);<br />
|-<br />
|__int64 AudioSamplesFromFrames(int frames) const;<br />
|INT64 avs_audio_samples_from_frames(const AVS_VideoInfo * p, INT64 frames);<br />
|-<br />
|int FramesFromAudioSamples(__int64 samples) const;<br />
|int avs_frames_from_audio_samples(const AVS_VideoInfo * p, INT64 samples);<br />
|-<br />
|__int64 AudioSamplesFromBytes(__int64 bytes) const;<br />
|INT64 avs_audio_samples_from_bytes(const AVS_VideoInfo * p, INT64 bytes);<br />
|-<br />
|__int64 BytesFromAudioSamples(__int64 samples) const;<br />
|INT64 avs_bytes_from_audio_samples(const AVS_VideoInfo * p, INT64 samples);<br />
|}<br />
<br />
[[Category:AviSynth_Development]]</div>Adminhttp://avisynth.nl/index.php/TCPDeliverTCPDeliver2020-06-29T21:06:21Z<p>Admin: fixed link to GitHub</p>
<hr />
<div>{{FilterCat4|External_filters|Plugins|Plugins_x64|Support_filters}}<br />
{{Filter3<br />
|1={{Author/Sh0dan}}, [https://github.com/DJATOM DJATOM]<br />
|2=v0.2<br />
|3=[https://github.com/DJATOM/TCPDeliver/releases TCPDeliver-x86.7z]<br>[https://github.com/DJATOM/TCPDeliver/releases TCPDeliver-x64.7z]<br />
|4=[[:Category:Support_filters|Support filters]]<br />
|5=[http://www.gnu.org/licenses/gpl-2.0.txt GPLv2]<br />
|6=[https://forum.doom9.org/showthread.php?t=72868 Doom9 Forum]<br />
}}<br />
<br><br />
== Description ==<br />
This filter will enable you to send clips over your network. You can connect several clients to the same machine. <br />
<br><br />
<br><br />
== Requirements ==<br />
* [x86]: [[AviSynth+]] or [https://sourceforge.net/projects/avisynth2/ AviSynth 2.6]<br />
* [x64]: [[AviSynth+]]<br />
<br><br />
== [[Script variables|Syntax and Parameters]] ==<br />
<br />
=== Server: ===<br />
<br />
<code>TCPServer</code> (clip, int "port")<br /><br />
<br /><br />
This will spawn a server thread on the current machine running on the specified port. Port default is 22050.<br /><br />
You will get output in the application you open your script in, but the server will only be running as long as the application (vdub for instance) is open.<br /><br />
<br /><br />
Example:<br />
<br />
<pre>Colorbars(512, 256)<br />
TCPServer()</pre><br />
will start a server.<br />
<br><br />
<br><br />
=== Client: ===<br />
<br />
<code>TCPSource</code> (string hostname, int "port", string "compression")<br /><br />
<br /><br />
This will connect to the machine with the given address (IP-number for instance) to a server running on the given port. Port default is also 22050 here.<br />
<br />
Compression enable you to choose the compression used for the video:<br />
<br />
:{|<br />
| '''Compression Type'''<br />
| '''Description'''<br />
|-<br />
| None<br />
| Use no compression. Fastest option - video will not be compressed before being sent over the net.<br />
|-<br />
| LZO<br />
| Use [http://www.oberhumer.com/opensource/lzo/ LZO] dictionary compression. Fairly fast, but only compresses well on artificial sources, like cartoons and anime with very uniform surfaces.<br />
|-<br />
| Huffman<br />
| Uses a fairly slow Huffman routine by [http://bcl.sourceforge.net/ Marcus Geelnard]. Compresses natural video better than LZO.<br />
|-<br />
| GZip<br />
| Uses a [http://www.gzip.org/ Gzip] Huffman only compression. Works much like Huffman setting, but seems faster.<br />
|}<br />
<br />
If no compression is given, GZip is currently used by default. Interlaced material compresses worse than non-interlaced due to downwards deltaencoding. If network speed is a problem you might want to use [[SeparateFields]].<br />
<br />
Example:<br />
<br />
<pre>TCPSource("127.0.0.1")<br />
Info()</pre><br />
This will connect to the local machine, if a server is running.<br />
<br><br />
<br><br />
== Examples ==<br />
<br />
You can use this to run each/some filters on different PC's. For example:<br />
<br />
<pre># Clustermember 1:<br />
AVISource<br />
Deinterlacer<br />
TCPServer<br />
<br />
# Clustermember 2:<br />
TCPSource<br />
Sharpener<br />
TCPServer<br />
<br />
# Clustermember 3:<br />
TCPSource<br />
# client app -> video codec -> final file</pre><br />
<br />
<br />
=== Usability Notes ===<br />
<br />
Once you have added a TCPServer, you cannot add more filters to the chain, or use the output from the filter. The server runs in a separate thread, but since AviSynth isn't completely thread-safe you cannot reliably run multiple servers. This should '''not''' be used:<br />
<br />
<pre><br />
AviSource("avi.avi")<br />
TCPServer(1001)<br />
TCPServer(1002) # This is NOT a good idea<br />
</pre><br />
So the basic rule is '''never more than one TCPServer per script'''.<br />
<br />
Using commands after TCPServer is also a bad idea:<br />
<br />
<pre>AviSource("avi.avi")<br />
TCPServer(1001)<br />
AviSource("avi2.avi") # Do not do this, this will disable the server.</pre><br />
AviSynth detects that the output of TCPServer isn't used, so it kills the Server filter. '''TCPServer should always be the last filter.'''<br />
<br><br />
<br><br />
== Changelog ==<br />
Version Date Changes<br><br />
v0.2 2017/02/13 - TCPDeliver for AviSynth+ version 0.2<br />
- Differences from 0.1:<br />
* support for YUVA/PlanarRGBA colorspaces;<br />
* HBD formats should be handled better if compression is involved;<br />
* dropped old garbage from source code;<br />
* no need in the old VS runtime.<br />
<br><br />
== External Links ==<br />
*[https://github.com/DJATOM/TCPDeliver GitHub] - Source code repository.<br />
<br><br />
<br><br />
-----------------------------------------------<br />
'''Back to [[External_filters#Support_filters|External Filters]] &larr;'''</div>Adminhttp://avisynth.nl/index.php/DGDecNVDGDecNV2020-06-02T19:47:03Z<p>Admin: typo</p>
<hr />
<div>{{FilterCat4|External_filters|Plugins|Plugins_x64|Source_filters}}<br />
{{Filter3<br />
|1={{Author/Donald Graft}}<br />
|2=205x<br />
|3=[http://rationalqm.us/dgdecnv/dgdecnv.html Get License]<br />
|4=Source filters<br />
|5=<br />
|6=[http://rationalqm.us/board/viewforum.php?f=8&sid=7e4371d29402371f0cc19da6e290124c rationalqm.us]}}<br />
<br />
== Description ==<br />
[[DGDecNV]] is a decoder/frameserver for AVC, HEVC, MPEG2, and VC1 streams that runs on the GPU of Nvidia graphics cards that support CUDA video decoding. It works in conjunction with the indexing tool DGIndexNV. See official homepage: http://rationalqm.us/dgdecnv/dgdecnv.html<br />
<br />
<br />
'''DGDecodeNV.dll''' includes the following AviSynth filters:<br />
* <code>DGSource</code>: source filter that delivers decoded video in YV12/i420/YUV420P16 format. (requires AviSynth+ for high-bit-depth work)<br />
* <code>DGDenoise</code>: fast stand-alone CUDA filter that implements [https://en.wikipedia.org/wiki/Non-local_means NLM denoising]. Supports [[YUV420P16]].<br />
* <code>DGSharpen</code>: fast stand-alone CUDA filter that implements limited sharpening like the well-known filter [[LimitedSharpen|LimitedSharpenFaster]](). Supports [[YUV420P16]].<br />
* <code>DGTelecide</code>: fast stand-alone CUDA filter that implements field matching and adaptive deinterlacing.<br />
* <code>DGDecimate</code>: fast stand-alone CUDA filter that implements N-in-M frame decimation.<br />
* <code>DGBob</code>: fast stand-alone CUDA filter that implements the YADIF deinterlacing algorithm (original concept by Michael Niedermayer).<br />
* <code>PVBob</code>: a stand-alone version of the PureVideo deinterlacer. This is the same functionality that you get using the deinterlace parameter of DGSource().<br />
<br><br />
'''DGIndexNV'''<br />
DGIndexNV, part of the DGDecNV package, is primarily designed to create an index of an AVC/HEVC/MPG/VC1 video stream, containing the location of each frame in the input stream, and some additional information about each frame. This index, or project file, is used by the companion Avisynth filter DGDecodeNV to provide frame-accurate serving of the video via an Avisynth script. DGDecNV can also be used with Vapoursynth because Vapoursynth can load and use Avisynth source filters. DGIndexNV can open AVC/HEVC/MPG/VC1 video in elementary streams, and in program, transport, Matroska, and MP4 containers.<br />
<br><br />
<br><br />
== Requirements ==<br />
* [x86]: [[AviSynth+]] or [https://sourceforge.net/projects/avisynth2/ AviSynth 2.6]<br />
* [x64]: [[AviSynth+]]<br />
<br><br />
<br><br />
-----------------------------------------------<br />
'''Back to [[External_filters#Source_Filters|External Filters]] &larr;'''<br />
-----------------------------------------------</div>Adminhttp://avisynth.nl/index.php/Changelist_26Changelist 262019-07-30T18:22:24Z<p>Admin: /* CODE CHANGES */</p>
<hr />
<div>== Changes from 2.6.1 alpha 1 to 2.6.1 cvs ==<br />
<br />
* Pacify VS2015 /W4.<br />
* Fix DV chroma positioning (UV swapped), Assert interlaced options only for YV12.<br />
* VFAPI support for > 2^32 audio samples.<br />
* ColorYUV support Y8.<br />
* Make TemporalSoften reentrant (MT ready).<br />
* Fix Histogram mode color, chroma fill.<br />
* Compare support Y8<br />
<br />
* Add TimeStretch overload with rational pair arguments.<br />
* Update to SoundTouch 1.9.2.<br />
<br />
== Changes from 2.6.0 to 2.6.1 alpha 1 ==<br />
<br />
=== ENVIRONMENT CHANGES and UPDATES ===<br />
* Update to SoundTouch 1.9.0(Wilbert+IanB).<br />
* Update to DevIL 1.7.8<br />
* TCPDeliver update to zlib 1.2.8 and lzo-2.09.<br />
* TCPDeliver complete Klaus's last work for 2.6 API.<br />
* Updated 2.6.1 VC6 build scripts.<br />
* Initial 2.6.1 VC2005 build scripts.<br />
* DirectShowSource add BaseClasses project to Avisynth solution.<br />
* MSVC 2008 Express project and solution files.<br />
* Experiment with 2K8 SSE2 build.<br />
<br />
=== CODE CHANGES ===<br />
* Add offset parameter to conditional functions(Wilbert).<br />
* Replace convert_a.asm for yuy2 to rgb.<br />
* Redo SEH exception handling code.<br />
* VirtualQuery/GetModuleFileName + Trap on Invoke(SEt).<br />
* Use LoadLibraryEx/LOAD_WITH_ALTERED_SEARCH_PATH for plugins.<br />
* Use GetVarDef() extensively.<br />
* Handle exceptions from DevIL.dll now being delay loaded.<br />
* Explicitly catch stray std::bad_alloc and report.<br />
<br />
=== BUGFIXES ===<br />
* Supereq gain arguments can only be int, enforce it.<br />
* Fix handle leak with "Exists"(SEt)<br />
* Fix VDub plugin race on cleanup<br />
* Fix TCPDeliver crash with bad hostnames.<br />
* Fix ShowSMPTE non-integer fps message not being thrown (raffriff42).<br />
* Fix avisynth_c plane=0. Default params are not allowed in plain C.<br />
* Fix MergeLuma allow any Planar test(Wilbert).<br />
* Remove redundant self class spec from definition(Wilbert).<br />
<br />
=== ENHANCEMENTS ===<br />
* Evaluate Invert arguments once in Constructor not every GetFrame, Doh!<br />
* Move matrix decision into Convert constructor, overcome exceed cacheline.<br />
<br />
=== BUILD CHANGES ===<br />
* Remove msvcP*.dll dependencies.<br />
* Add AsFloatF(), compiler sugar!<br />
* Move to /W4 compiler warnings.<br />
* Isolate void BitBlt(...) & long GetGPUFlags() functions.<br />
* Add VDCall as __cdecl to VDub api calls<br />
* Add __cdecl declaration to all api calls(SEt).<br />
* Code cleanup(SEt).<br />
* Improve precompiled header usage.<br />
* Use #pragma comment to control link options.<br />
* Turn off RuntimeTypeInfo for the rest of the solution.<br />
* Patch BaseClasses to avoid ATL/MFC dependance.<br />
* Add build environment tags to various filenames and values.<br />
* Amend template AVS_BUILD strings.<br />
* Link with nothrownew.obj.<br />
* Remove writable system32\avisynth.dll dependency.<br />
* Dodge 2005-2015 compiler bug with nested try/catch.<br />
* Fix missing advapi32.lib for debug builds.<br />
<br />
== Changes from 2.5 series to 2.6.0 ==<br />
<br />
=== Additions ===<br />
* TCPDeliver, 2.6 plugin, support all pixel types. (Wilbert)<br />
* AviSource: added multiple video and audio track support.<br />
* Add IScriptEnvironment::GetVarDef() nothrow version of GetVar().<br />
* Partial 2.6 update of Avisynth_C interface.<br />
* Add current dwAvail{Phys, Virtual} to out of memory error message.<br />
* Add #ifndef KSDATAFORMAT_SUBTYPE_{PCM IEEE_FLOAT} for newer SDK's.<br />
* DirectShowSource support negotiation of non-standard MediaSubTypes "I420", "NV12", "YV24" and "YV16".<br />
* AviSource and DirectShowSource support '+' prefix on pixel_type to handle bad padded planar data.<br />
* Added Eval(clip, string name, string) alias for oop processing of argument.<br />
* DirectShowSource support non-standard pixel types "YV24" and "YV16".<br />
* Info: Audio only clip now creates its own canvas video.<br />
* AviSource: Include packed/padded processing and -ve biHeight logic for compressed input.<br />
* Added Script Functions :- BitLRotate, BitRRotate, BitChange, BitClear, BitSet, BitTest and their asm aliases.<br />
* Added WeaveRows (blit cost) and WeaveColumns (slow) frame combining filters.<br />
* Added AudioDuration() [as float seconds], IsY8(), IsYV411() & PixelType() [as a string] script functions.<br />
* Added Echo and Preroll filters.<br />
* Added IScriptEnvironment::GetAVSLinkage() and DLLExport AVS_linkage for host usage of avisynth.dll.<br />
* DirectShowSource, 2.6 plugin, support pixel types "AYUV" as YV24, "Y41P" and "Y411" as YV411.<br />
* AviSource: Add Full and Auto pseudo pixel_types. Full is all supported. Auto is YV12, YUY2, RGB32, RGB24 & Y8.<br />
* Added "AudioLengthS", "Ord" & "FillStr" script functions.<br />
* Added AudioTrim(clip, float, float) audio priority trimming, args in fractional seconds.<br />
* Added Trim(M, Length=N[, Pad=False]) and Trim(M, End=N[, Pad=False]) function overloads for explicit Trimming. Length=0 means zero frame clip. End=0 means end at frame 0.<br />
* Added SeparateRows (zero cost) and SeparateColumns (slow) frame slashing filters.<br />
* Added Script Functions :- Acos, Asin, Atan, Atan2, Cosh, Sinh, Tanh, Fmod, Log10, BitLShift, BitRShiftS, BitRShiftU and Hex.<br />
* Added "ConditionalSelect","csc+[show]b" runtime filter.<br />
* Added dither option to Levels, RGBAdjust & Tweak.<br />
* Added BitAnd(), BitNot(), BitOr() & BitXor() script functions.<br />
* Added StrCmp() & StrCmpI() script functions.<br />
* Added YV24 support for Limiter show option.<br />
* Added "Global OPT_dwChannelMask={int}"<br />
* Added 0x0063F speaker mask for 7.1 WAVE_FORMAT_EXTENSIBLE.<br />
* Added .dll DelayLoad exception texts to crash message formatter.<br />
* ImageWriter, add support for printf formating of filename string, default is ("%06d.%s", n, ext);<br />
* Added avs_get_error(AVS_ScriptEnvironment*); to avisynth_c interface.<br />
* Catch and save AvisynthError text in more avisynth_c entry points, for kemuri-_9.<br />
* Added ScriptName(), ScriptFile(), ScriptDir() functions (WarpEnterprises).<br />
* Added SkewRows filter.<br />
* Histogram, Levels mode, Improve colour of chroma legends.<br />
* ConditionalFilter, teach about string results.<br />
* Add some more "Add/Remove Software" registry keys to the Installer (XhmikosR).<br />
* AviSource: Support both packed and DWORD padded raw planar input like with DSS.<br />
* Added IScriptEnvironment::ApplyMessage()<br />
* Added ImageSourceAnim (Wilbert)<br />
* Support user upgrade to 178 DevIL.dll (They need to manage CRT dependancies).<br />
* ImageSource: palette and compressed bmp images load correctly now (issue 894702) [need 178 DevIL.dll]<br />
* ImageSource: support for other formats like: gif, exr, jp2, psd, hdr [need 178 DevIL.dll]<br />
* Added YV24 mode to ColorBars.<br />
* Added ColorBarsHD based on arib_std_b28.<br />
* C-api usability enhancements from kemuri9 [Work in progress!]<br />
* Added Undefined(), AudioLengthLo(), AudioLengthHi(), IsYV16() & IsYV24() script functions<br />
* Allow newlines (and hence comments) before '{' -- Gavino<br />
* Added IScriptEnvironment::DeleteScriptEnvironment()<br />
* Added Histogram, population clamp % factor for "Levels" mode,<br />
* Histogram, revert "Stereo" mode to YV12, Add "StereoY8" mode,<br />
* AviSource: Support fourcc "GREY" as Y8<br />
* Added "Global OPT_AVIPadScanlines=True" option for DWORD aligned planar padding<br />
* Added support for argument passing and EAX return value to SoftwireHelper.<br />
* Added "Global OPT_VDubPlanarHack=True" to flip YV24 and YV16 chroma planes for old VDub's.<br />
* Added ContinuedDenominator/ContinuedNumerator(f[]i[limit]i) script functions.<br />
* Tweak: fix MaskPointResizing + put back Dividee ISSE code (use sse=true, can't use all settings in that case).<br />
* Added ChromaInPlacement, ChromaOutPlacement and ChromaResample options to planar colour conversions.<br />
* Added MaskHS.<br />
* Minor tweaks to get ready for VC8.<br />
* Add Y8 for DevIL, planarize EBMP.<br />
* Planar support for many filters.<br />
* Added Info() time indicator on audio length and video (current frame & total). (2.5.8)<br />
* Added UtoY8 and VtoY8.<br />
* Added more info to Info(). (2.5.8)<br />
* ColorYUV: Added all adjustment parameters as conditional variables "coloryuv_SETTING". Enable by setting conditional=true.<br />
* ConditionalReader: Added support for type String.<br />
* ConditionalReader: Added offset keyword to offset all frame numbers after the keyword.<br />
* Added SincResize() with optional taps parameter (default is 4).<br />
* Added Custom band setting to SuperEQ to allow all 16 bands to be set from script. Usage: SuperEQ(clip,band1, band2, band3....) values are dB in float.<br />
* Added fast 0-1-0 kernel for YV24 to ConvertBacktoYUY2().<br />
* Added formats: YV24, YV16, Y8, YV411.<br />
<br />
=== Bugfixes ===<br />
* Fixed missing I420 in DirectShowSource pixel type error message.<br />
* Fixed VideoInfo::Is property to reference image_type (not pixel_type).<br />
* Fixed YV16->YUY2 always ran both mmx and C code.<br />
* Fixed YV12 Blur C code skiping left column.<br />
* Fixed Conditional functions with Y8 referencing non-existant chroma.<br />
* Fixed frame range clamping in ComparePlane (ultim).<br />
* Fixed posible leak with realloc in ConditionalReader (ultim).<br />
* Fixed posible double free in text-overlay (ultim).<br />
* Fixed RGB32 to Y8 pixel right shift from 4th pixel on (Robert Martens).<br />
* Fixed Overlay YV24 Image444 leak.<br />
* Fixed AVISource "AUTO" and "FULL" handling.<br />
* Fixed ImageSource handling of missing ebmp files.<br />
* Fixed DirectShowSource incorrect byte order for unpacking of pixel type "AYUV".<br />
* Fixed HexValue parsing values greater than 7FFFFFFF, now as unsigned hex.<br />
* Fixed ConditionalReader memory overrun parsing bools.<br />
* Fixed ResampleAudio NOP test to compare vi.num_audio_samples, not sample rate.<br />
* Fixed YV24 -> RGB24 overrun cleanup for widths%16 == 5.<br />
* Fixed RGB24 AddBorders with right=0.<br />
* Fixed conditional_functions error message names (Wilbert).<br />
* Fixed Audio cache ac_expected_next regression.<br />
* Fixed ImageSource deal with add 1 to IL_NUM_IMAGES bug (Wilbert)<br />
* Fixed Overlay YV24 V plane conversion.<br />
* Fixed Overlay YV24 mode with shared input clip, needed a MakeWritable.<br />
* Fixed ImageReader upside down TIFF in 178 DevIL. (Wilbert)<br />
* Fixed SaveString 'string+string' bug when total length is 4096*K-1, K is +int.<br />
* Fixed SincResize misuse of "int abs(int)" (Gavino). Fix Lanczos and Blackman sinc use of float == 0.0, use small limit "> 0.000001".<br />
* Fixed Classic mode legend drawing for planar right limit and yuy2 centre line.<br />
* Fixed possible MT race. Use "env->ManageCache(MC_IncVFBRefcount, ...)" in ProtectVFB.<br />
* Fixed SwapYToUV output image size bug for 3 clip case.<br />
* Fixed Crop limit tests for RGB.<br />
* Fixed Overlay yellow tint on rec601 RGB import conversion.<br />
* Fixed YtoUV() output image size bug for 3 clip case.<br />
* Fixed ConvertToPlanar chroma alignment.<br />
* Fixed Levels (RGB) change use of PixelClip(x) to min(max(x, 0), 255).<br />
* Fixed SwapYtoUV yuy2 crash (StainlessS).<br />
* Fixed Overlay saturate UV in add and subtract mode.<br />
* Fixed Info.h range protect display characters (StainlessS).<br />
* Fixed AviSource packed planar import chroma offsets.<br />
* Fixed AviSource NULL GetWritePtr() failure due to premature setting of last_frame.<br />
* Fixed Mask rounding in greyscale calcs (Wilbert), minor refactor.<br />
* Fixed SelectRangeEvery audio snafu (Gavino).<br />
* Fixed LoadPlugin, SaveString of result string.<br />
* Fixed LoadPlugin, use _vsnprintf.<br />
* Fixed LoadVirtualdubPlugin, don't add vdub filter to chain on load failure.<br />
* Fixed rounding in RGB HResize (JoshyD) (affects all resizers)<br />
* Fixed error message name in the filter VerticalReduceBy2<br />
* Fixed SeparateFields() with variable parity input clip (Wilbert)<br />
* Fixed AviSource, cannot cast__int64* to long*, it does not work!<br />
* Fixed ConditionalReader: Don't allow out of range "Range" to overwrite edge values<br />
* Fixed MonoToStereo with stereo sources.<br />
* Fixed MergeChannels with only 1 input clip.<br />
* Fixed support for negative height DIB format AVI's. (Oops still not quite right yet)<br />
* Fixed Audio cache crashes.<br />
* Fixed resize with YV411 missing code.<br />
* Fixed ConditionalReader rounding with integer Interpolation.<br />
* Fixed Softwire SSE2 bugs.<br />
* Fixed SSSE3 CPU detection.<br />
* Fixed SSSE3, SSE4.1 & SSE4.2 detection.<br />
* Fixed Fastwire encoding of instructions that are >2 opcodes (SSSE3+4).<br />
* Fixed _RPT5() macro for debug builds<br />
<br />
=== Optimizations ===<br />
* Cache auto increase span on sparse misses.<br />
* Cache prevent inactive instances returning VFB early and spoiling active instances hit rate (LaTo).<br />
* ConvertToPlanarGeneric explicit add Cache before chroma rescaler.<br />
* Overlay minor refactor YV12 -> 444 chroma<br />
* Speedup ConvertToMono(), minor refactor MixAudio().<br />
* Change StackVertical/Horizontal to interative instead of recursive, 2^N performace increase for 3 and more clips, i.e. 1 blit total instead of blit(blit(blit(...<br />
* RGBtoY8 Dynamic ASM code, suport for RGB24.<br />
* YV24backtoYUY2 Dynamic ASM code.<br />
* UtoY8, VtoY8 abuse subframe, zero cost.<br />
* YV24<->RGB Add SSE2 and SSSE3 code paths, get rid of wide_enough.<br />
* ConvertToYUY2 Add SSE2, MMX restore full speed on platforms with poor ooox.<br />
* ConvertAudio, manage tempbuffer and floatbuffer independently.<br />
* ConvertAudio, prefer SSE2 over 3DNow for super AMD cores.<br />
* Info.h, full refactor, a good example of "Never look down", thx StainlessS<br />
* DoubleWeaveFrames, If A not writable, try to write to B, else make new frame<br />
* Histogram, fix GetFrame/NewVideoFrame call order<br />
* HResizer, interleave code +4% faster<br />
* YtoUV() Abuse Subframe to snatch the Y plane / UV planes, Derestrict destination colorformat autogeneration.<br />
* ImageSource: Improve thread interlock code<br />
* ConditionalReader/WriteFile: Full refactor.<br />
* Replace _strdup with SaveString in AddFunction (Thanks Gavino)<br />
* SuperEQ: Improve channel unpacking/packing code.<br />
* H-Resize: Use SSE4.1 (movntdqa) loads for use once memory access.<br />
* H-Resize: Added SSE2 horizontal unpacker.<br />
* Resize: Use SSE3 (lddqu) loads for unaligned memory access.<br />
* Added ultra fast vertical PointResizer (64 pixel/cycle).<br />
* Added dynamic SSSE3 vertical resizer (16 pixel/cycle) ~ twice as fast as old MMX.<br />
* Added dynamic SSE2 vertical resizer (16 pixel/cycle).<br />
* Added dynamic MMX vertical resizer (8 pixel/cycle).<br />
* Added SSSE3 version for RGB<->YV24 conversions.<br />
* Added dynamic compiled MMX/iSSE for RGB<->YV24 conversions. Speed is approx 200% of C-code.<br />
<br />
=== Changes ===<br />
* New default directory, $PROGRAMFILES\AviSynth. But it will continue to default to the previous intall dir and will use the previously existing plugin dir.<br />
* Do a full unistall and answer YES to clearing the registry to reset to all the new defaults.<br />
* Menu dir is now $SMPROGRAMS\AviSynth. Will rename "AviSynth 2.5" to "AviSynth".<br />
* Cache only uses extended hints if rev 6 and above. Counter bad use in rev 5. [undocumented]<br />
* Bump AVISYNTH_INTERFACE_VERSION to 6.<br />
* Changed recursive include protection #define from __AVISYNTH_H__ to __AVISYNTH_6_H__<br />
* Changed mem size elements from signed int to unsigned size_t.<br />
* Removed CACHE_25_* enums.<br />
* Removed from avisynth.h AlignedPlanar, FillBorder, ConvertAudio. Now in separate include files.<br />
* Change CPUF_SSE4_2 to 0x1000 to match VirtualDub. 0x800 reserved for AVX.<br />
* Removed MIN_INT, MAX_INT.<br />
* BMPSize() use mod 4 rowsize for all formats.<br />
* LoadPlugin errs 0x7e and 0x7f have descriptive text.<br />
* Import: Increase full path buffer to MAX_PATH*4 for multi char code pages like CP932 (Chikuzen).<br />
* Throw error when output number of frames will exceed MAXINT.<br />
* BlankClip: Supply useful defaults for new Audio/Video when using a Video/Audio only template clip.<br />
* BlankClip: Use duration from Audio only template as default length for new clip.<br />
* Define new IClip::SetCacheHints cachehint constants.<br />
* Force int call arguments to user script function float params to be explicit floats.<br />
* Splice pass CacheHints through to both children in + and ++ mode.<br />
* WriteFileStart/End save current_frame and set Last.<br />
* ConditionalReader do not ignore syntax errors in input file.<br />
* ImageSourceAnim Pad/Crop images to match first frame (Wilbert)<br />
* ImageSource Add version to messages (Wilbert)<br />
* Initial 2.6 API entry point linkage.<br />
* Use Invoke for graph tail, enhance non-clip output error reporting.<br />
* PopContext when inner block Asserts/throws (maxxon).<br />
* Remove duplicate definitions (Wilbert)<br />
* Enhance non-clip output error reporting.<br />
* Explicitly specify calling sequence as __cdecl for Avisynth softwire routines, (was the compiler default)<br />
* Use env->Invoke("Cache", ...) everywhere instead of Cache::Create_Cache(), allows for Cache to be overloaded by a plugin.<br />
* ConvertToYUY2 Change from 0-1-1 kernel to 1-2-1 kernel.<br />
* Tweak make Interp same units as minSat and maxSat.<br />
* Check HKEY_CURRENT_USER for PluginDir first. (henktiggelaar)<br />
* Make forced, -ve, planar alignment of chroma planes match subsampling.<br />
* Enforce planar alignment restrictions.<br />
* C-api: Remove func sub-struct from AVS_Library struct<br />
* Add error code to plugin load failure message<br />
* Make default planar AVI output packed.<br />
* WriteFile() now supports unlimited number of unlimited strings. (was 16 by 254 byte strings).<br />
* ConvertToRGB*, make C++ code sample chroma the same as the MMX code i.e. use both pixels.<br />
* ConvertToRGB*, use YV24 path for planar, complain when options are present for YUY2.<br />
* ConvertToYUY2, use YV16 path for planar, complain when options are present for RGB<br />
** see: http://forum.doom9.org/showthread.php?p=1378381#post1378381<br />
* Thread safe code, part 2.<br />
* Correct IClip baked documentation<br />
* Fix at_exit executon order<br />
* Passify compilation error/warnings (XhmikosR)<br />
* for, const, extern and ansi patches for VC2008 (SEt)<br />
* Disable OPT_RELS_LOGGING option<br />
* Change implicit Last parsing for argless, bracketless calls to match bracketed cases. (Gavino) [not documented yet ???]<br />
* DirectShowSource: Support last minute format renegotiation thru IPin::QueryAccept() & Validate the size of the provided directshow buffer.<br />
* Remove non ascii chars from comments.<br />
* Add core stubs for DirectShowSource, TCPServer & TCPSource, report when plugins are missing.<br />
* Add note for original source downloads - SoundTouch<br />
* Add more lineage history to Info()<br />
* Move convertaudio, alignplanar, fillborder & MIN/MAX_INT definitions.<br />
* Run AtExit before dismantling world.<br />
* Change setcachehints definition from void to int. Test IClip version >= 5.<br />
* Move PixelClip definition to avisynth.cpp<br />
* SubTitle, etc, make X & Y options float (0.125 pixel granularity).<br />
* ShowSMPTE() supports all integer FPS and multiplies of drop frame FPS.<br />
* SubTitle, stop overwriting string constants (Gavino).<br />
* SubTitle, improve pixel registration (Gavino).<br />
* Make Info() CPU display hierarchical.<br />
* Thread safe code, part 1.<br />
* ConditionalReader/WriteFile: Full refactor.<br />
* SoftwireHelper: explicit hardware exception handling.<br />
* Resize: Moved GetResampleFunction into Resamplefunction, to allow overrides.<br />
* Resampler: Removed dead stlf code.<br />
* Updated Soundtouch to 1.31 (2.5.8)<br />
* Put dynamic matrix conversion into separate file.<br />
* Moved chroma subsampling to image_type section.<br />
* Added specific error reporting when requesting chromasubsampling with Y8.<br />
* Split up merge and plane Swappers.<br />
* Split up Plane transfers into separate classes.<br />
* Added automatic destination colorspace detection on planar YtoUV.<br />
* Took out greyscale and RGB32<->RGB24 from convert.cpp and placed them in separate files.<br />
* All code assuming UVwidth = Ywidth/2 and similar should be gone.<br />
<br />
[[Category:Changelist]]</div>Adminhttp://avisynth.nl/index.php/Changelist_26Changelist 262019-07-30T18:21:47Z<p>Admin: typo</p>
<hr />
<div>== Changes from 2.6.1 alpha 1 to 2.6.1 cvs ==<br />
<br />
* Pacify VS2015 /W4.<br />
* Fix DV chroma positioning (UV swapped), Assert interlaced options only for YV12.<br />
* VFAPI support for > 2^32 audio samples.<br />
* ColorYUV support Y8.<br />
* Make TemporalSoften reentrant (MT ready).<br />
* Fix Histogram mode color, chroma fill.<br />
* Compare support Y8<br />
<br />
* Add TimeStretch overload with rational pair arguments.<br />
* Update to SoundTouch 1.9.2.<br />
<br />
== Changes from 2.6.0 to 2.6.1 alpha 1 ==<br />
<br />
=== ENVIRONMENT CHANGES and UPDATES ===<br />
* Update to SoundTouch 1.9.0(Wilbert+IanB).<br />
* Update to DevIL 1.7.8<br />
* TCPDeliver update to zlib 1.2.8 and lzo-2.09.<br />
* TCPDeliver complete Klaus's last work for 2.6 API.<br />
* Updated 2.6.1 VC6 build scripts.<br />
* Initial 2.6.1 VC2005 build scripts.<br />
* DirectShowSource add BaseClasses project to Avisynth solution.<br />
* MSVC 2008 Express project and solution files.<br />
* Experiment with 2K8 SSE2 build.<br />
<br />
=== CODE CHANGES ===<br />
* Add offset parameter to conditional functions(Wilbert).<br />
* Replace convert_a.asm for yuy2 to rgb.<br />
* Redo SEH exception handling code.<br />
* VirtualQuery/GetModuleFileName + Trap on Invoke(SEt).<br />
* Use LoadLibraryEx/LOAD_WITH_ALTERED_SEARCH_PATH for plugins.<br />
* Use GetVarDef() extensivly.<br />
* Handle exceptions from DevIL.dll now being delay loaded.<br />
* Explicitly catch stray std::bad_alloc and report.<br />
<br />
=== BUGFIXES ===<br />
* Supereq gain arguments can only be int, enforce it.<br />
* Fix handle leak with "Exists"(SEt)<br />
* Fix VDub plugin race on cleanup<br />
* Fix TCPDeliver crash with bad hostnames.<br />
* Fix ShowSMPTE non-integer fps message not being thrown (raffriff42).<br />
* Fix avisynth_c plane=0. Default params are not allowed in plain C.<br />
* Fix MergeLuma allow any Planar test(Wilbert).<br />
* Remove redundant self class spec from definition(Wilbert).<br />
<br />
=== ENHANCEMENTS ===<br />
* Evaluate Invert arguments once in Constructor not every GetFrame, Doh!<br />
* Move matrix decision into Convert constructor, overcome exceed cacheline.<br />
<br />
=== BUILD CHANGES ===<br />
* Remove msvcP*.dll dependencies.<br />
* Add AsFloatF(), compiler sugar!<br />
* Move to /W4 compiler warnings.<br />
* Isolate void BitBlt(...) & long GetGPUFlags() functions.<br />
* Add VDCall as __cdecl to VDub api calls<br />
* Add __cdecl declaration to all api calls(SEt).<br />
* Code cleanup(SEt).<br />
* Improve precompiled header usage.<br />
* Use #pragma comment to control link options.<br />
* Turn off RuntimeTypeInfo for the rest of the solution.<br />
* Patch BaseClasses to avoid ATL/MFC dependance.<br />
* Add build environment tags to various filenames and values.<br />
* Amend template AVS_BUILD strings.<br />
* Link with nothrownew.obj.<br />
* Remove writable system32\avisynth.dll dependency.<br />
* Dodge 2005-2015 compiler bug with nested try/catch.<br />
* Fix missing advapi32.lib for debug builds.<br />
<br />
== Changes from 2.5 series to 2.6.0 ==<br />
<br />
=== Additions ===<br />
* TCPDeliver, 2.6 plugin, support all pixel types. (Wilbert)<br />
* AviSource: added multiple video and audio track support.<br />
* Add IScriptEnvironment::GetVarDef() nothrow version of GetVar().<br />
* Partial 2.6 update of Avisynth_C interface.<br />
* Add current dwAvail{Phys, Virtual} to out of memory error message.<br />
* Add #ifndef KSDATAFORMAT_SUBTYPE_{PCM IEEE_FLOAT} for newer SDK's.<br />
* DirectShowSource support negotiation of non-standard MediaSubTypes "I420", "NV12", "YV24" and "YV16".<br />
* AviSource and DirectShowSource support '+' prefix on pixel_type to handle bad padded planar data.<br />
* Added Eval(clip, string name, string) alias for oop processing of argument.<br />
* DirectShowSource support non-standard pixel types "YV24" and "YV16".<br />
* Info: Audio only clip now creates its own canvas video.<br />
* AviSource: Include packed/padded processing and -ve biHeight logic for compressed input.<br />
* Added Script Functions :- BitLRotate, BitRRotate, BitChange, BitClear, BitSet, BitTest and their asm aliases.<br />
* Added WeaveRows (blit cost) and WeaveColumns (slow) frame combining filters.<br />
* Added AudioDuration() [as float seconds], IsY8(), IsYV411() & PixelType() [as a string] script functions.<br />
* Added Echo and Preroll filters.<br />
* Added IScriptEnvironment::GetAVSLinkage() and DLLExport AVS_linkage for host usage of avisynth.dll.<br />
* DirectShowSource, 2.6 plugin, support pixel types "AYUV" as YV24, "Y41P" and "Y411" as YV411.<br />
* AviSource: Add Full and Auto pseudo pixel_types. Full is all supported. Auto is YV12, YUY2, RGB32, RGB24 & Y8.<br />
* Added "AudioLengthS", "Ord" & "FillStr" script functions.<br />
* Added AudioTrim(clip, float, float) audio priority trimming, args in fractional seconds.<br />
* Added Trim(M, Length=N[, Pad=False]) and Trim(M, End=N[, Pad=False]) function overloads for explicit Trimming. Length=0 means zero frame clip. End=0 means end at frame 0.<br />
* Added SeparateRows (zero cost) and SeparateColumns (slow) frame slashing filters.<br />
* Added Script Functions :- Acos, Asin, Atan, Atan2, Cosh, Sinh, Tanh, Fmod, Log10, BitLShift, BitRShiftS, BitRShiftU and Hex.<br />
* Added "ConditionalSelect","csc+[show]b" runtime filter.<br />
* Added dither option to Levels, RGBAdjust & Tweak.<br />
* Added BitAnd(), BitNot(), BitOr() & BitXor() script functions.<br />
* Added StrCmp() & StrCmpI() script functions.<br />
* Added YV24 support for Limiter show option.<br />
* Added "Global OPT_dwChannelMask={int}"<br />
* Added 0x0063F speaker mask for 7.1 WAVE_FORMAT_EXTENSIBLE.<br />
* Added .dll DelayLoad exception texts to crash message formatter.<br />
* ImageWriter, add support for printf formating of filename string, default is ("%06d.%s", n, ext);<br />
* Added avs_get_error(AVS_ScriptEnvironment*); to avisynth_c interface.<br />
* Catch and save AvisynthError text in more avisynth_c entry points, for kemuri-_9.<br />
* Added ScriptName(), ScriptFile(), ScriptDir() functions (WarpEnterprises).<br />
* Added SkewRows filter.<br />
* Histogram, Levels mode, Improve colour of chroma legends.<br />
* ConditionalFilter, teach about string results.<br />
* Add some more "Add/Remove Software" registry keys to the Installer (XhmikosR).<br />
* AviSource: Support both packed and DWORD padded raw planar input like with DSS.<br />
* Added IScriptEnvironment::ApplyMessage()<br />
* Added ImageSourceAnim (Wilbert)<br />
* Support user upgrade to 178 DevIL.dll (They need to manage CRT dependancies).<br />
* ImageSource: palette and compressed bmp images load correctly now (issue 894702) [need 178 DevIL.dll]<br />
* ImageSource: support for other formats like: gif, exr, jp2, psd, hdr [need 178 DevIL.dll]<br />
* Added YV24 mode to ColorBars.<br />
* Added ColorBarsHD based on arib_std_b28.<br />
* C-api usability enhancements from kemuri9 [Work in progress!]<br />
* Added Undefined(), AudioLengthLo(), AudioLengthHi(), IsYV16() & IsYV24() script functions<br />
* Allow newlines (and hence comments) before '{' -- Gavino<br />
* Added IScriptEnvironment::DeleteScriptEnvironment()<br />
* Added Histogram, population clamp % factor for "Levels" mode,<br />
* Histogram, revert "Stereo" mode to YV12, Add "StereoY8" mode,<br />
* AviSource: Support fourcc "GREY" as Y8<br />
* Added "Global OPT_AVIPadScanlines=True" option for DWORD aligned planar padding<br />
* Added support for argument passing and EAX return value to SoftwireHelper.<br />
* Added "Global OPT_VDubPlanarHack=True" to flip YV24 and YV16 chroma planes for old VDub's.<br />
* Added ContinuedDenominator/ContinuedNumerator(f[]i[limit]i) script functions.<br />
* Tweak: fix MaskPointResizing + put back Dividee ISSE code (use sse=true, can't use all settings in that case).<br />
* Added ChromaInPlacement, ChromaOutPlacement and ChromaResample options to planar colour conversions.<br />
* Added MaskHS.<br />
* Minor tweaks to get ready for VC8.<br />
* Add Y8 for DevIL, planarize EBMP.<br />
* Planar support for many filters.<br />
* Added Info() time indicator on audio length and video (current frame & total). (2.5.8)<br />
* Added UtoY8 and VtoY8.<br />
* Added more info to Info(). (2.5.8)<br />
* ColorYUV: Added all adjustment parameters as conditional variables "coloryuv_SETTING". Enable by setting conditional=true.<br />
* ConditionalReader: Added support for type String.<br />
* ConditionalReader: Added offset keyword to offset all frame numbers after the keyword.<br />
* Added SincResize() with optional taps parameter (default is 4).<br />
* Added Custom band setting to SuperEQ to allow all 16 bands to be set from script. Usage: SuperEQ(clip,band1, band2, band3....) values are dB in float.<br />
* Added fast 0-1-0 kernel for YV24 to ConvertBacktoYUY2().<br />
* Added formats: YV24, YV16, Y8, YV411.<br />
<br />
=== Bugfixes ===<br />
* Fixed missing I420 in DirectShowSource pixel type error message.<br />
* Fixed VideoInfo::Is property to reference image_type (not pixel_type).<br />
* Fixed YV16->YUY2 always ran both mmx and C code.<br />
* Fixed YV12 Blur C code skiping left column.<br />
* Fixed Conditional functions with Y8 referencing non-existant chroma.<br />
* Fixed frame range clamping in ComparePlane (ultim).<br />
* Fixed posible leak with realloc in ConditionalReader (ultim).<br />
* Fixed posible double free in text-overlay (ultim).<br />
* Fixed RGB32 to Y8 pixel right shift from 4th pixel on (Robert Martens).<br />
* Fixed Overlay YV24 Image444 leak.<br />
* Fixed AVISource "AUTO" and "FULL" handling.<br />
* Fixed ImageSource handling of missing ebmp files.<br />
* Fixed DirectShowSource incorrect byte order for unpacking of pixel type "AYUV".<br />
* Fixed HexValue parsing values greater than 7FFFFFFF, now as unsigned hex.<br />
* Fixed ConditionalReader memory overrun parsing bools.<br />
* Fixed ResampleAudio NOP test to compare vi.num_audio_samples, not sample rate.<br />
* Fixed YV24 -> RGB24 overrun cleanup for widths%16 == 5.<br />
* Fixed RGB24 AddBorders with right=0.<br />
* Fixed conditional_functions error message names (Wilbert).<br />
* Fixed Audio cache ac_expected_next regression.<br />
* Fixed ImageSource deal with add 1 to IL_NUM_IMAGES bug (Wilbert)<br />
* Fixed Overlay YV24 V plane conversion.<br />
* Fixed Overlay YV24 mode with shared input clip, needed a MakeWritable.<br />
* Fixed ImageReader upside down TIFF in 178 DevIL. (Wilbert)<br />
* Fixed SaveString 'string+string' bug when total length is 4096*K-1, K is +int.<br />
* Fixed SincResize misuse of "int abs(int)" (Gavino). Fix Lanczos and Blackman sinc use of float == 0.0, use small limit "> 0.000001".<br />
* Fixed Classic mode legend drawing for planar right limit and yuy2 centre line.<br />
* Fixed possible MT race. Use "env->ManageCache(MC_IncVFBRefcount, ...)" in ProtectVFB.<br />
* Fixed SwapYToUV output image size bug for 3 clip case.<br />
* Fixed Crop limit tests for RGB.<br />
* Fixed Overlay yellow tint on rec601 RGB import conversion.<br />
* Fixed YtoUV() output image size bug for 3 clip case.<br />
* Fixed ConvertToPlanar chroma alignment.<br />
* Fixed Levels (RGB) change use of PixelClip(x) to min(max(x, 0), 255).<br />
* Fixed SwapYtoUV yuy2 crash (StainlessS).<br />
* Fixed Overlay saturate UV in add and subtract mode.<br />
* Fixed Info.h range protect display characters (StainlessS).<br />
* Fixed AviSource packed planar import chroma offsets.<br />
* Fixed AviSource NULL GetWritePtr() failure due to premature setting of last_frame.<br />
* Fixed Mask rounding in greyscale calcs (Wilbert), minor refactor.<br />
* Fixed SelectRangeEvery audio snafu (Gavino).<br />
* Fixed LoadPlugin, SaveString of result string.<br />
* Fixed LoadPlugin, use _vsnprintf.<br />
* Fixed LoadVirtualdubPlugin, don't add vdub filter to chain on load failure.<br />
* Fixed rounding in RGB HResize (JoshyD) (affects all resizers)<br />
* Fixed error message name in the filter VerticalReduceBy2<br />
* Fixed SeparateFields() with variable parity input clip (Wilbert)<br />
* Fixed AviSource, cannot cast__int64* to long*, it does not work!<br />
* Fixed ConditionalReader: Don't allow out of range "Range" to overwrite edge values<br />
* Fixed MonoToStereo with stereo sources.<br />
* Fixed MergeChannels with only 1 input clip.<br />
* Fixed support for negative height DIB format AVI's. (Oops still not quite right yet)<br />
* Fixed Audio cache crashes.<br />
* Fixed resize with YV411 missing code.<br />
* Fixed ConditionalReader rounding with integer Interpolation.<br />
* Fixed Softwire SSE2 bugs.<br />
* Fixed SSSE3 CPU detection.<br />
* Fixed SSSE3, SSE4.1 & SSE4.2 detection.<br />
* Fixed Fastwire encoding of instructions that are >2 opcodes (SSSE3+4).<br />
* Fixed _RPT5() macro for debug builds<br />
<br />
=== Optimizations ===<br />
* Cache auto increase span on sparse misses.<br />
* Cache prevent inactive instances returning VFB early and spoiling active instances hit rate (LaTo).<br />
* ConvertToPlanarGeneric explicit add Cache before chroma rescaler.<br />
* Overlay minor refactor YV12 -> 444 chroma<br />
* Speedup ConvertToMono(), minor refactor MixAudio().<br />
* Change StackVertical/Horizontal to interative instead of recursive, 2^N performace increase for 3 and more clips, i.e. 1 blit total instead of blit(blit(blit(...<br />
* RGBtoY8 Dynamic ASM code, suport for RGB24.<br />
* YV24backtoYUY2 Dynamic ASM code.<br />
* UtoY8, VtoY8 abuse subframe, zero cost.<br />
* YV24<->RGB Add SSE2 and SSSE3 code paths, get rid of wide_enough.<br />
* ConvertToYUY2 Add SSE2, MMX restore full speed on platforms with poor ooox.<br />
* ConvertAudio, manage tempbuffer and floatbuffer independently.<br />
* ConvertAudio, prefer SSE2 over 3DNow for super AMD cores.<br />
* Info.h, full refactor, a good example of "Never look down", thx StainlessS<br />
* DoubleWeaveFrames, If A not writable, try to write to B, else make new frame<br />
* Histogram, fix GetFrame/NewVideoFrame call order<br />
* HResizer, interleave code +4% faster<br />
* YtoUV() Abuse Subframe to snatch the Y plane / UV planes, Derestrict destination colorformat autogeneration.<br />
* ImageSource: Improve thread interlock code<br />
* ConditionalReader/WriteFile: Full refactor.<br />
* Replace _strdup with SaveString in AddFunction (Thanks Gavino)<br />
* SuperEQ: Improve channel unpacking/packing code.<br />
* H-Resize: Use SSE4.1 (movntdqa) loads for use once memory access.<br />
* H-Resize: Added SSE2 horizontal unpacker.<br />
* Resize: Use SSE3 (lddqu) loads for unaligned memory access.<br />
* Added ultra fast vertical PointResizer (64 pixel/cycle).<br />
* Added dynamic SSSE3 vertical resizer (16 pixel/cycle) ~ twice as fast as old MMX.<br />
* Added dynamic SSE2 vertical resizer (16 pixel/cycle).<br />
* Added dynamic MMX vertical resizer (8 pixel/cycle).<br />
* Added SSSE3 version for RGB<->YV24 conversions.<br />
* Added dynamic compiled MMX/iSSE for RGB<->YV24 conversions. Speed is approx 200% of C-code.<br />
<br />
=== Changes ===<br />
* New default directory, $PROGRAMFILES\AviSynth. But it will continue to default to the previous intall dir and will use the previously existing plugin dir.<br />
* Do a full unistall and answer YES to clearing the registry to reset to all the new defaults.<br />
* Menu dir is now $SMPROGRAMS\AviSynth. Will rename "AviSynth 2.5" to "AviSynth".<br />
* Cache only uses extended hints if rev 6 and above. Counter bad use in rev 5. [undocumented]<br />
* Bump AVISYNTH_INTERFACE_VERSION to 6.<br />
* Changed recursive include protection #define from __AVISYNTH_H__ to __AVISYNTH_6_H__<br />
* Changed mem size elements from signed int to unsigned size_t.<br />
* Removed CACHE_25_* enums.<br />
* Removed from avisynth.h AlignedPlanar, FillBorder, ConvertAudio. Now in separate include files.<br />
* Change CPUF_SSE4_2 to 0x1000 to match VirtualDub. 0x800 reserved for AVX.<br />
* Removed MIN_INT, MAX_INT.<br />
* BMPSize() use mod 4 rowsize for all formats.<br />
* LoadPlugin errs 0x7e and 0x7f have descriptive text.<br />
* Import: Increase full path buffer to MAX_PATH*4 for multi char code pages like CP932 (Chikuzen).<br />
* Throw error when output number of frames will exceed MAXINT.<br />
* BlankClip: Supply useful defaults for new Audio/Video when using a Video/Audio only template clip.<br />
* BlankClip: Use duration from Audio only template as default length for new clip.<br />
* Define new IClip::SetCacheHints cachehint constants.<br />
* Force int call arguments to user script function float params to be explicit floats.<br />
* Splice pass CacheHints through to both children in + and ++ mode.<br />
* WriteFileStart/End save current_frame and set Last.<br />
* ConditionalReader do not ignore syntax errors in input file.<br />
* ImageSourceAnim Pad/Crop images to match first frame (Wilbert)<br />
* ImageSource Add version to messages (Wilbert)<br />
* Initial 2.6 API entry point linkage.<br />
* Use Invoke for graph tail, enhance non-clip output error reporting.<br />
* PopContext when inner block Asserts/throws (maxxon).<br />
* Remove duplicate definitions (Wilbert)<br />
* Enhance non-clip output error reporting.<br />
* Explicitly specify calling sequence as __cdecl for Avisynth softwire routines, (was the compiler default)<br />
* Use env->Invoke("Cache", ...) everywhere instead of Cache::Create_Cache(), allows for Cache to be overloaded by a plugin.<br />
* ConvertToYUY2 Change from 0-1-1 kernel to 1-2-1 kernel.<br />
* Tweak make Interp same units as minSat and maxSat.<br />
* Check HKEY_CURRENT_USER for PluginDir first. (henktiggelaar)<br />
* Make forced, -ve, planar alignment of chroma planes match subsampling.<br />
* Enforce planar alignment restrictions.<br />
* C-api: Remove func sub-struct from AVS_Library struct<br />
* Add error code to plugin load failure message<br />
* Make default planar AVI output packed.<br />
* WriteFile() now supports unlimited number of unlimited strings. (was 16 by 254 byte strings).<br />
* ConvertToRGB*, make C++ code sample chroma the same as the MMX code i.e. use both pixels.<br />
* ConvertToRGB*, use YV24 path for planar, complain when options are present for YUY2.<br />
* ConvertToYUY2, use YV16 path for planar, complain when options are present for RGB<br />
** see: http://forum.doom9.org/showthread.php?p=1378381#post1378381<br />
* Thread safe code, part 2.<br />
* Correct IClip baked documentation<br />
* Fix at_exit executon order<br />
* Passify compilation error/warnings (XhmikosR)<br />
* for, const, extern and ansi patches for VC2008 (SEt)<br />
* Disable OPT_RELS_LOGGING option<br />
* Change implicit Last parsing for argless, bracketless calls to match bracketed cases. (Gavino) [not documented yet ???]<br />
* DirectShowSource: Support last minute format renegotiation thru IPin::QueryAccept() & Validate the size of the provided directshow buffer.<br />
* Remove non ascii chars from comments.<br />
* Add core stubs for DirectShowSource, TCPServer & TCPSource, report when plugins are missing.<br />
* Add note for original source downloads - SoundTouch<br />
* Add more lineage history to Info()<br />
* Move convertaudio, alignplanar, fillborder & MIN/MAX_INT definitions.<br />
* Run AtExit before dismantling world.<br />
* Change setcachehints definition from void to int. Test IClip version >= 5.<br />
* Move PixelClip definition to avisynth.cpp<br />
* SubTitle, etc, make X & Y options float (0.125 pixel granularity).<br />
* ShowSMPTE() supports all integer FPS and multiplies of drop frame FPS.<br />
* SubTitle, stop overwriting string constants (Gavino).<br />
* SubTitle, improve pixel registration (Gavino).<br />
* Make Info() CPU display hierarchical.<br />
* Thread safe code, part 1.<br />
* ConditionalReader/WriteFile: Full refactor.<br />
* SoftwireHelper: explicit hardware exception handling.<br />
* Resize: Moved GetResampleFunction into Resamplefunction, to allow overrides.<br />
* Resampler: Removed dead stlf code.<br />
* Updated Soundtouch to 1.31 (2.5.8)<br />
* Put dynamic matrix conversion into separate file.<br />
* Moved chroma subsampling to image_type section.<br />
* Added specific error reporting when requesting chromasubsampling with Y8.<br />
* Split up merge and plane Swappers.<br />
* Split up Plane transfers into separate classes.<br />
* Added automatic destination colorspace detection on planar YtoUV.<br />
* Took out greyscale and RGB32<->RGB24 from convert.cpp and placed them in separate files.<br />
* All code assuming UVwidth = Ywidth/2 and similar should be gone.<br />
<br />
[[Category:Changelist]]</div>Adminhttp://avisynth.nl/index.php/VersionVersion2019-05-16T21:27:26Z<p>Admin: missing bracket</p>
<hr />
<div><div style="max-width:62em" ><br />
{{FuncDef|Version()}}<br />
<br />
Generates a 24[[wikipedia:Frame_rate|fps]], 10-second, [[RGB24]]-format video clip with a version, build time, copyright statement, and homepage information in 24-point, Arial, light yellow ([[Colors|$ECF2BF]]) text on a 25% grey ($404040) background. Width and height are chosen to fit the message, so clip size varies by version. <br />
<br />
<br />
:[[File:avisynth-version-2.6.png]]<br />
<br />
<br />
<br />
If the '''Version''' message is presented by itself (as is the normal case, when simply checking the installed AviSynth version), you don't care about the exact size, frame rate etc; but if you want to [[Splice]] this clip with other video clips, the [[Clip_properties|properties]] must be compatible: you will need more control. The following script implements a variant of the '''Version''' filter with a clip argument {{FuncArg|bg}} which defines the resulting properties, and (if {{FuncArg|showbg}}=true) the audio/video content in the background.<br />
<div {{BoxWidthIndent|48|2}} ><br />
### 'Version' filter with background/template clip <br />
function Version(clip bg, bool "showbg")<br />
{<br />
showbg = [[Internal_functions/Default|Default]](showbg, false)<br />
bg = (showbg) ? bg : [[BlankClip]](bg, color=$404040)<br />
v=Version<br />
m=v.[[ConvertToRGB32]].[[ColorKeyMask]]($404040, 0).[[ShowAlpha]]<br />
[[Overlay]](bg, v, mask=m.[[Blur]](0.2),<br />
\ x=(bg.Width/2-v.Width/2), <br />
\ y=(bg.Height/2-v.Height/2))<br />
return Last<br />
}<br />
</div><br />
<br />
:''Usage with template clip:''<br />
:<code>Version(BlankClip(width=600, height=336, pixel_type="YV24"))</code><br />
:[[File:Avisynth-version-template-2.61.png]]<br />
<br />
<br />
:''Showing the clip under the message:''<br />
:<code>Version([[ColorBarsHD]](width=600, height=336), '''showbg=true'''))</code><br />
:[[File:Avisynth-version-overlay-2.61.png]]<br />
<br />
</div><br />
<br />
<br />
[[Category:Internal filters]]<br />
[[Category:Debugging/Diagnostic filters]]</div>Adminhttp://avisynth.nl/index.php/Filter_SDK/Compiling_instructionsFilter SDK/Compiling instructions2019-01-03T22:41:28Z<p>Admin: /* General settings */</p>
<hr />
<div>== Introduction ==<br />
<br />
The Avisynth API is a C++ API, but that doesn't mean that you can use every C++ compiler to compile your plugin. Unfortunately compilers have different ideas about what the C++ ABI should look like. In practice, this means that if you want things to work 100% as expected, you must compile your plugin with the same compiler that was used to compile AviSynth. That's MSVC 6.0 for official builds. Later versions of MSVC will kinda sorta work, as will ICL (up to ICL10.1), but there are caveats (for example, you must never allow any C++ exceptions to escape your plugin ever - use ThrowError() instead - and you must always make sure memory allocated by AviSynth is freed by AviSynth itself and not by your plugin). So unfortunately it matters what C++ compiler will be used to compile a plugin.<br />
<br />
An application binary interface ([http://en.wikipedia.org/wiki/Application_binary_interface ABI]) specifies how software components should interact with each other at the binary level (in this case AviSynth and a plugin). ABIs cover details such as the sizes, layout, and alignment of data types, the calling convention of functions' arguments that are passed and returned. It standardizes details such as the [http://en.wikipedia.org/wiki/Name_mangling#Name_mangling_in_C.2B.2B C++ name mangling] and exception propagation. The problem is that there are different C++ ABIs.<br />
<br />
Microsoft set their general C++ ABI with their first C++ compilers, and it has had some changes along the years and versions of their compiler suite. Intel and Borland, among others, support the Microsoft ABI, and thus things built with the other generally work, just like with Linux and the ABI used by GCC. Enter MinGW.<br />
<br />
Instead of implementing the Microsoft ABI, the people at GCC and MinGW decided to just use the same C++ ABI on Windows as they use everywhere else. Thus we have two groups of compilers that use a different ABI. It will give issues if you try to load a mingw-built C++ API DLL from a MSVC-built Avisynth. The opposite will not work, either. The C interface was made exactly for this reason, as pretty much by chance the ABI for C is (more or less) set, and thus it is generally OK to mix binaries created by different C compilers.<br />
<br />
This is why the Avisynth C API exists: if you want a portable API, you want a C API. C++ API's are more or less by definition unportable.<br />
<br />
This section explains how to compile Avisynth plugins that are using the C++ API and that are using the C API. For the latter see the MSVC++ 2010 section.<br />
<br />
=== Further reading ===<br />
<br />
If you want extra reading regarding calling conventions and name mangling and such ABI-related things, you can read the following PDF that lists quite a few things of various implementations. Available [http://www.agner.org/optimize/calling_conventions.pdf here]. Basically these things in general are not fixable by a mere header, you would have to patch a compiler for the other calling convention, as well as handle exceptions so that the other side would understand it as well. And so forth, and so forth. (source: Doom9 forum posts: [http://forum.doom9.org/showthread.php?p=1653392#post1653392], [http://forum.doom9.org/showthread.php?p=1653737#post1653737].)<br />
<br />
== Installing necessary software ==<br />
<br />
For installing software and setting up environments have a look at [[Filter_SDK/SDK_necessaries|necessary software]] and [[Filter_SDK/Compile AviSynth|necessary software and setting up environments]].<br />
<br />
== Compiling AviSynth plugins step by step instructions (for MS VC++ 6.0) ==<br />
<br />
Open VC++. Select a new project: Go to the File tab -> New. Select a Win32 Dynamic-Link Library in the Projects tab:<br />
<br />
[[Image:Compiling_plugins.png]]<br />
<br />
Add the location of your project and the Project Name. The location is the project folder where the source of your project will be.<br />
<br />
Select "An empty DLL project":<br />
<br />
[[Image:Compiling_plugins2.png]]<br />
<br />
Copy existing source files (*.cpp), headers (*.h) and avisynth.h in your project folder. If you started from scratch, you only need to copy avisynth.h in your project folder.<br />
<br />
Go to the Project tab -> Add To Project -> Files:<br />
<br />
[[Image:Compiling_plugins3.png]]<br />
<br />
Add the existing source files (*.cpp), headers (*.h) and avisynth.h to your project. If you start from scratch, you need to a new files to your project:<br />
<br />
Go to the Project tab -> Add To project -> New:<br />
<br />
1) Select C++ source file, and give it a name.<br />
2) Select C/C++ header file (if you are going to use one), and give it a name.<br />
<br />
Go to the Build tab -> Set Active Configuration -> select the release build.<br />
<br />
If you go to the Project tab again -> Settings. Then you should see something similar as this:<br />
<br />
[[Image:Compiling_plugins4.png]]<br />
<br />
Save your workspace: File -> Save Workspace.<br />
<br />
Finally, code your source/header files, and compile your plugin. Go to the Build tab -> Build (...)<br />
<br />
[[Image:Compiling_plugins5.png]]<br />
<br />
== Compiling AviSynth plugins step by step instructions (for MS VC++ 2005 Express Edition) ==<br />
<br />
=== How to compile existent (old MS VC 6.0) plugin with MS VC++ 2005 ===<br />
<br />
* Start VC++ 2005, go to folder with old plugin (e.g. [[Filter_SDK/Simple_sample | SimpleSample]]) unpacked zip file with full source codes and project files, and open plugin workspace file SimpleSample.dsw.<br />
<br />
* Agree in dialog to convert and open this project.<br />
<br />
* Go to menu Build -> Configuration Manager, Set active solution configuration to Release (or Debug if you want firsly debug it).<br />
<br />
* Go to Build -> Build Solution (F7) to compile and create SimpleSample.dll<br />
<br />
* If you get fatal error LNK1181: cannot open input file 'odbc32.lib', then go to menu Project -> SimpleSample Properties. Select Configuration Properties -> Linker -> Input -> Additional Dependencies, and remove extra unneeded libraries like odbc32.lib, odbccp32.lib.<br />
<br />
* Also check Linker -> Output File option there and set approriate pathname (or Inherit From Process default).<br />
<br />
* You can make some changes (edit) of source codes if you want.<br />
<br />
* Repeat command Build -> Build Solution (F7) to compile and create SimpleSample.dll<br />
<br />
=== How to create new plugin from scratch with MS VC++ 2005 ===<br />
<br />
* Start VC++2005. <br />
* Menu: fiIe -> Create new project.<br />
* Select Win32 console appication.<br />
* Enter name of your new project and press OK.<br />
* You will in Win32 Appcilation Wizard. Press Application Settings (left panel).<br />
* Select Application Type as DLL (but it may be console too).<br />
* At Additional options select "Empty project" <br />
* Copy files to project folder with Explorer.<br />
* Add header file avisynth.h to the project: Menu Project -> Add existent item. Also add existant (e.g. simplesample.cpp) or create new CPP files by Project -> Add new item.<br />
* Go to menu Build -> Configuration Manager, Set active solution configuration to Release (or Debug if you want firsly debug it). <br />
* Make some changes (edit) of source codes to implement your algorithm. See [[Filter_SDK/Simple_sample | SimpleSample]] or some other open source plugin source code and Avisynth [[Filter SDK]] for details.<br />
* Go to Build -> Build Solution (F7) to compile and create plugin SimpleSample.dll<br />
<br />
== Compiling AviSynth plugins step by step instructions (for MS VC++ 2008 Professional Edition) ==<br />
<br />
* In this guide, we will compile the Example plugin from CPP for C programmers, from http://forum.doom9.org/showthread.php?p=1538557#post1538557 or directly from http://www.mediafire.com/download.php?tc61m9otustmy29<br />
* Start Microsoft Visual Studio 2008<br />
* Upon first start, you are asked to set up your environment. You may choose the typical Visual C++ option<br />
* Choose File->New->Project or click the New Project icon<br />
* On the left pane, under Project Types, expand Visual C++ and select Win32<br />
* On the right pane, choose Win32 Console Application<br />
* Enter a name for your project (in this example we will use Example), click OK<br />
* You may get an error: An error has occurred in this dialog, Error: 54, Unspecified Error. This may be because you installed some windows updates but didn't reboot yet. Click OK.<br />
* You are shown the current project settings. Click Next.<br />
* Under Application Type, click the DLL option. Under Additional options, check the Empty project box.<br />
* A new directory is created, My Documents\Visual Studio 2008\Projects\Example<br />
* You need to extract the files from our example plugin into My Documents\Visual Studio 2008\Projects\Example\Example<br />
* In the default layout, there is a Solution Explorer pane on the left side. Right click Header Files, and select Add->Existing Item, select avisynth.h and click Add<br />
* Continue to add the other files, Info.h and InfoF.h<br />
* Right click Source Files, select Add->Existing Item, and select Example.cpp<br />
* Click Build->Build Solution (this will give errors!)<br />
* There's a lot of errors about OutputDebugStringW. To fix this, select Project->Example Properties<br />
* In the left pane, Expand Configuration Properties, select General<br />
* In the right pane, click Character Set. Use the drop-down to select Use Multi-Byte Character Set. Click OK.<br />
* Click Build->Build Solution (this may give errors!)<br />
* In the version 0.3 of the plugin, there was an error, 'example.cpp(610) : error C4430: missing type specifier - int assumed'. To fix this, double-click that error line to highlight it's location in the example.cpp source file. Change 'const wstep = (vi.IsRGB24()) ? 3 : 4; // 3 bytes for RGB24, & 4 for RGB32.' to 'const int wstep = (vi.IsRGB24()) ? 3 : 4; // 3 bytes for RGB24, & 4 for RGB32.'<br />
* Click Build->Build Solution<br />
* If you get an error 'unresolved external symbol _main referenced in function ___tmainCRTStartup', then you're trying to build an .exe. Use Project->Example Properties, Configuration Properties, General, set Configuration Type to Dynamic Library (.dll)<br />
* By default, a debug version is made. To change this, Build->Configuration Manager, select Release in the left drop-down<br />
* You will have to re-apply the configuration changes: Project->Example Properties, Configuration Properties, General, Configuration Type=Dynamic Library (.dll) and Character Set=Use Multi-Byte Character Set<br />
* The following file should appear: My Documents\Visual Studio 2008\Projects\Example\Release\Example.dll. Note that there is also a directory My Documents\Visual Studio 2008\Projects\Example\Example\Release which contains only tempory files, but not the dll. This is set under Project->Example Properties, General, Output Directory=$(SolutionDir)$(ConfigurationName), Intermediate Directory=$(ConfigurationName). In this case $(SolutionDir)=My Documents\Visual Studio 2008\Projects\Example, $(ConfigurationName)=Release.<br />
* You need to copy Example.dll to your Avisynth plugins directory, and then test it with the Example.avs file.<br />
* If everything worked, you can proceed to modify the example by following the comments, or also using the SimnpleSample included in the Avisynth distribution.<br />
<br />
== Compiling AviSynth plugins or console applications step by step instructions (for MS VC++ 2010 Express and Professional Edition) ==<br />
<br />
These instructions are also valid for the 2008 editions. Be sure to start with the [[Filter_SDK/SDK_necessaries|necessary software]] and [[Filter_SDK/Compile AviSynth|necessary software and setting up environments]].<br />
<br />
=== Creating a new project ===<br />
<br />
Open MSVC++ 2010. Select a new project: <br />
<br />
[[Image:Compiling_plugins_msvc2010_001.jpg|720px]]<br />
<br />
Select a Win32 Console Application. Add the location of your project and the project name. The Location\Name will be the project folder (or Solution Directory as MSVC++ 2010 calls it) where the source of your project will be. If the folder "Name" already exists the 'Create directory for solution' box should be left unchecked, otherwise it will create as a subfolder regardless.<br />
<br />
[[Image:Compiling_plugins_msvc2010_002.jpg|720px]]<br />
<br />
Select application settings. When creating a plugin check the application type 'DLL' and when creating a console application (such as avs2wav.exe for example) check the application type 'Console application'. Also check the additional option 'Empty project' boxes. Click on finish:<br />
<br />
[[Image:Compiling_plugins_msvc2010_003.jpg]]<br />
<br />
=== Adding files to the project ===<br />
<br />
In the Solution Explorer window, the solution has the 'folders' External Dependencies, Header Files, Resource Files and Source Files:<br />
<br />
[[Image:Compiling_plugins_msvc2010_004.jpg]]<br />
<br />
* When creating a plugin using the C++ API, you need to copy the existing source files (*.cpp), headers (*.h) and avisynth.h in your project folder. If you started from scratch, you only need to copy avisynth.h in your project folder.<br />
<br />
* When creating a plugin using the C API, you need to copy the existing source files (*.c), headers (*.h) and avisynth_c.h in your project folder. If you started from scratch, you only need to copy avisynth_c.h in your project folder. Note make sure your source files end with '.c' instead of '.cpp' (that's how for example MSVC++ knows it's C code).<br />
<br />
You can add the source and header files to your project by right-clicking on a 'folder' (say Header Files as in the screenshot below), select Add and Existing Item (or New Item if you start from scratch):<br />
<br />
[[Image:Compiling_plugins_msvc2010_005.jpg]]<br />
<br />
When creating a plugin using the C API, you need to do two additional things:<br />
<br />
* You need to link to avisynth.lib (create the folder InvertNeg/lib and copy the library to it). In the linker add lib\avisynth.lib under 'Additional Dependencies' (both for the release and debug configuration):<br />
:[[Image:Compiling_cplugins_msvc2010_001.jpg]]<br />
<br />
* When compiling with MSVC++ you also need to add a definition file to your project (otherwise LoadCPlugin can't load the library). Create a text file (here named InvertNeg.def), add it to your project (under source files) and add it to the 'Module Definition File' in the linker (both for the release and debug configuration):<br />
:[[Image:Compiling_cplugins_msvc2010_002.jpg]]<br />
<br />
Select the release build, since we are building the release build.<br />
<br />
=== General settings ===<br />
<br />
If it's your first time you use the compiler, you need to select the expert settings to make the build tab visible:<br />
<br />
Tools > Settings > Expert Settings<br />
<br />
[[Image:Compiling_plugins_msvc2010_006.jpg|720px]]<br />
<br />
In the property page you can see (and change) the location of the DLL that will be build:<br />
<br />
Right click on the project name (InvertNeg in our case) > Properties > Configuration Properties > General<br />
<br />
The default location is $(SolutionDir)$(Configuration)\. You have set the 'SolutionDir' when defining the project (D:\AviSynth\Plugins\InvertNeg in our case). 'Configuration' will be the Release or Debug folder depending on which configuration you have selected.<br />
<br />
[[Image:Compiling_plugins_msvc2010_07.jpg|720px]]<br />
<br />
Next you need to be aware of the VC++ Directories and change them if necessary:<br />
<br />
Right click on the project name (InvertNeg in our case) > Properties > Configuration Properties > VC++ Directories<br />
<br />
Here you will find the location of the 'Include Directories' and others. $(VCInstallDir)include points to the include folder of MSVC++ 2010 and $(WindowsSdkDir)include to the include folder of the Microsoft Platform SDK. When including headers (such as windows.h) in your project they will be searched for in the include folders (unless you explicitly add its location when including them). So both of them should point to the correct folders. <br />
<br />
Note that in general windows.h should be included in your project. It is the header file for accessing the Win32 API through C/C++ and it is located in the include folder of the Microsoft Platform SDK.<br />
<br />
[[Image:Compiling_plugins_msvc2010_008.jpg]]<br />
<br />
You can see the values of VCInstallDir and WindowsSdkDir when opening the VS command prompt:<br />
<br />
Tools > Visual Studio > Command Prompt<br />
<br />
The VS command prompt will be loaded. Type set and you will see the variables. They will be set when starting MSVC++ 2010 (by vsvars32.bat which is located in your <VisualStudioInstallDir>\Common7\Tools folder).<br />
<br />
=== Building the plugin or console application ===<br />
<br />
Now you are ready to build you DLL/EXE. Go to<br />
<br />
Build > Build Solution<br />
<br />
And you will find your compiled plugin in the Location\Name\Folder.<br />
<br />
[[Image:Compiling_plugins_msvc2010_009.jpg|720px]]<br />
<br />
[[Category:AviSynth_Development]]<br />
[[Category:FilterSDK]]</div>Adminhttp://avisynth.nl/index.php/Filter_SDK/Compiling_instructionsFilter SDK/Compiling instructions2019-01-03T22:35:04Z<p>Admin: /* Introduction */</p>
<hr />
<div>== Introduction ==<br />
<br />
The Avisynth API is a C++ API, but that doesn't mean that you can use every C++ compiler to compile your plugin. Unfortunately compilers have different ideas about what the C++ ABI should look like. In practice, this means that if you want things to work 100% as expected, you must compile your plugin with the same compiler that was used to compile AviSynth. That's MSVC 6.0 for official builds. Later versions of MSVC will kinda sorta work, as will ICL (up to ICL10.1), but there are caveats (for example, you must never allow any C++ exceptions to escape your plugin ever - use ThrowError() instead - and you must always make sure memory allocated by AviSynth is freed by AviSynth itself and not by your plugin). So unfortunately it matters what C++ compiler will be used to compile a plugin.<br />
<br />
An application binary interface ([http://en.wikipedia.org/wiki/Application_binary_interface ABI]) specifies how software components should interact with each other at the binary level (in this case AviSynth and a plugin). ABIs cover details such as the sizes, layout, and alignment of data types, the calling convention of functions' arguments that are passed and returned. It standardizes details such as the [http://en.wikipedia.org/wiki/Name_mangling#Name_mangling_in_C.2B.2B C++ name mangling] and exception propagation. The problem is that there are different C++ ABIs.<br />
<br />
Microsoft set their general C++ ABI with their first C++ compilers, and it has had some changes along the years and versions of their compiler suite. Intel and Borland, among others, support the Microsoft ABI, and thus things built with the other generally work, just like with Linux and the ABI used by GCC. Enter MinGW.<br />
<br />
Instead of implementing the Microsoft ABI, the people at GCC and MinGW decided to just use the same C++ ABI on Windows as they use everywhere else. Thus we have two groups of compilers that use a different ABI. It will give issues if you try to load a mingw-built C++ API DLL from a MSVC-built Avisynth. The opposite will not work, either. The C interface was made exactly for this reason, as pretty much by chance the ABI for C is (more or less) set, and thus it is generally OK to mix binaries created by different C compilers.<br />
<br />
This is why the Avisynth C API exists: if you want a portable API, you want a C API. C++ API's are more or less by definition unportable.<br />
<br />
This section explains how to compile Avisynth plugins that are using the C++ API and that are using the C API. For the latter see the MSVC++ 2010 section.<br />
<br />
=== Further reading ===<br />
<br />
If you want extra reading regarding calling conventions and name mangling and such ABI-related things, you can read the following PDF that lists quite a few things of various implementations. Available [http://www.agner.org/optimize/calling_conventions.pdf here]. Basically these things in general are not fixable by a mere header, you would have to patch a compiler for the other calling convention, as well as handle exceptions so that the other side would understand it as well. And so forth, and so forth. (source: Doom9 forum posts: [http://forum.doom9.org/showthread.php?p=1653392#post1653392], [http://forum.doom9.org/showthread.php?p=1653737#post1653737].)<br />
<br />
== Installing necessary software ==<br />
<br />
For installing software and setting up environments have a look at [[Filter_SDK/SDK_necessaries|necessary software]] and [[Filter_SDK/Compile AviSynth|necessary software and setting up environments]].<br />
<br />
== Compiling AviSynth plugins step by step instructions (for MS VC++ 6.0) ==<br />
<br />
Open VC++. Select a new project: Go to the File tab -> New. Select a Win32 Dynamic-Link Library in the Projects tab:<br />
<br />
[[Image:Compiling_plugins.png]]<br />
<br />
Add the location of your project and the Project Name. The location is the project folder where the source of your project will be.<br />
<br />
Select "An empty DLL project":<br />
<br />
[[Image:Compiling_plugins2.png]]<br />
<br />
Copy existing source files (*.cpp), headers (*.h) and avisynth.h in your project folder. If you started from scratch, you only need to copy avisynth.h in your project folder.<br />
<br />
Go to the Project tab -> Add To Project -> Files:<br />
<br />
[[Image:Compiling_plugins3.png]]<br />
<br />
Add the existing source files (*.cpp), headers (*.h) and avisynth.h to your project. If you start from scratch, you need to a new files to your project:<br />
<br />
Go to the Project tab -> Add To project -> New:<br />
<br />
1) Select C++ source file, and give it a name.<br />
2) Select C/C++ header file (if you are going to use one), and give it a name.<br />
<br />
Go to the Build tab -> Set Active Configuration -> select the release build.<br />
<br />
If you go to the Project tab again -> Settings. Then you should see something similar as this:<br />
<br />
[[Image:Compiling_plugins4.png]]<br />
<br />
Save your workspace: File -> Save Workspace.<br />
<br />
Finally, code your source/header files, and compile your plugin. Go to the Build tab -> Build (...)<br />
<br />
[[Image:Compiling_plugins5.png]]<br />
<br />
== Compiling AviSynth plugins step by step instructions (for MS VC++ 2005 Express Edition) ==<br />
<br />
=== How to compile existent (old MS VC 6.0) plugin with MS VC++ 2005 ===<br />
<br />
* Start VC++ 2005, go to folder with old plugin (e.g. [[Filter_SDK/Simple_sample | SimpleSample]]) unpacked zip file with full source codes and project files, and open plugin workspace file SimpleSample.dsw.<br />
<br />
* Agree in dialog to convert and open this project.<br />
<br />
* Go to menu Build -> Configuration Manager, Set active solution configuration to Release (or Debug if you want firsly debug it).<br />
<br />
* Go to Build -> Build Solution (F7) to compile and create SimpleSample.dll<br />
<br />
* If you get fatal error LNK1181: cannot open input file 'odbc32.lib', then go to menu Project -> SimpleSample Properties. Select Configuration Properties -> Linker -> Input -> Additional Dependencies, and remove extra unneeded libraries like odbc32.lib, odbccp32.lib.<br />
<br />
* Also check Linker -> Output File option there and set approriate pathname (or Inherit From Process default).<br />
<br />
* You can make some changes (edit) of source codes if you want.<br />
<br />
* Repeat command Build -> Build Solution (F7) to compile and create SimpleSample.dll<br />
<br />
=== How to create new plugin from scratch with MS VC++ 2005 ===<br />
<br />
* Start VC++2005. <br />
* Menu: fiIe -> Create new project.<br />
* Select Win32 console appication.<br />
* Enter name of your new project and press OK.<br />
* You will in Win32 Appcilation Wizard. Press Application Settings (left panel).<br />
* Select Application Type as DLL (but it may be console too).<br />
* At Additional options select "Empty project" <br />
* Copy files to project folder with Explorer.<br />
* Add header file avisynth.h to the project: Menu Project -> Add existent item. Also add existant (e.g. simplesample.cpp) or create new CPP files by Project -> Add new item.<br />
* Go to menu Build -> Configuration Manager, Set active solution configuration to Release (or Debug if you want firsly debug it). <br />
* Make some changes (edit) of source codes to implement your algorithm. See [[Filter_SDK/Simple_sample | SimpleSample]] or some other open source plugin source code and Avisynth [[Filter SDK]] for details.<br />
* Go to Build -> Build Solution (F7) to compile and create plugin SimpleSample.dll<br />
<br />
== Compiling AviSynth plugins step by step instructions (for MS VC++ 2008 Professional Edition) ==<br />
<br />
* In this guide, we will compile the Example plugin from CPP for C programmers, from http://forum.doom9.org/showthread.php?p=1538557#post1538557 or directly from http://www.mediafire.com/download.php?tc61m9otustmy29<br />
* Start Microsoft Visual Studio 2008<br />
* Upon first start, you are asked to set up your environment. You may choose the typical Visual C++ option<br />
* Choose File->New->Project or click the New Project icon<br />
* On the left pane, under Project Types, expand Visual C++ and select Win32<br />
* On the right pane, choose Win32 Console Application<br />
* Enter a name for your project (in this example we will use Example), click OK<br />
* You may get an error: An error has occurred in this dialog, Error: 54, Unspecified Error. This may be because you installed some windows updates but didn't reboot yet. Click OK.<br />
* You are shown the current project settings. Click Next.<br />
* Under Application Type, click the DLL option. Under Additional options, check the Empty project box.<br />
* A new directory is created, My Documents\Visual Studio 2008\Projects\Example<br />
* You need to extract the files from our example plugin into My Documents\Visual Studio 2008\Projects\Example\Example<br />
* In the default layout, there is a Solution Explorer pane on the left side. Right click Header Files, and select Add->Existing Item, select avisynth.h and click Add<br />
* Continue to add the other files, Info.h and InfoF.h<br />
* Right click Source Files, select Add->Existing Item, and select Example.cpp<br />
* Click Build->Build Solution (this will give errors!)<br />
* There's a lot of errors about OutputDebugStringW. To fix this, select Project->Example Properties<br />
* In the left pane, Expand Configuration Properties, select General<br />
* In the right pane, click Character Set. Use the drop-down to select Use Multi-Byte Character Set. Click OK.<br />
* Click Build->Build Solution (this may give errors!)<br />
* In the version 0.3 of the plugin, there was an error, 'example.cpp(610) : error C4430: missing type specifier - int assumed'. To fix this, double-click that error line to highlight it's location in the example.cpp source file. Change 'const wstep = (vi.IsRGB24()) ? 3 : 4; // 3 bytes for RGB24, & 4 for RGB32.' to 'const int wstep = (vi.IsRGB24()) ? 3 : 4; // 3 bytes for RGB24, & 4 for RGB32.'<br />
* Click Build->Build Solution<br />
* If you get an error 'unresolved external symbol _main referenced in function ___tmainCRTStartup', then you're trying to build an .exe. Use Project->Example Properties, Configuration Properties, General, set Configuration Type to Dynamic Library (.dll)<br />
* By default, a debug version is made. To change this, Build->Configuration Manager, select Release in the left drop-down<br />
* You will have to re-apply the configuration changes: Project->Example Properties, Configuration Properties, General, Configuration Type=Dynamic Library (.dll) and Character Set=Use Multi-Byte Character Set<br />
* The following file should appear: My Documents\Visual Studio 2008\Projects\Example\Release\Example.dll. Note that there is also a directory My Documents\Visual Studio 2008\Projects\Example\Example\Release which contains only tempory files, but not the dll. This is set under Project->Example Properties, General, Output Directory=$(SolutionDir)$(ConfigurationName), Intermediate Directory=$(ConfigurationName). In this case $(SolutionDir)=My Documents\Visual Studio 2008\Projects\Example, $(ConfigurationName)=Release.<br />
* You need to copy Example.dll to your Avisynth plugins directory, and then test it with the Example.avs file.<br />
* If everything worked, you can proceed to modify the example by following the comments, or also using the SimnpleSample included in the Avisynth distribution.<br />
<br />
== Compiling AviSynth plugins or console applications step by step instructions (for MS VC++ 2010 Express and Professional Edition) ==<br />
<br />
These instructions are also valid for the 2008 editions. Be sure to start with the [[Filter_SDK/SDK_necessaries|necessary software]] and [[Filter_SDK/Compile AviSynth|necessary software and setting up environments]].<br />
<br />
=== Creating a new project ===<br />
<br />
Open MSVC++ 2010. Select a new project: <br />
<br />
[[Image:Compiling_plugins_msvc2010_001.jpg|720px]]<br />
<br />
Select a Win32 Console Application. Add the location of your project and the project name. The Location\Name will be the project folder (or Solution Directory as MSVC++ 2010 calls it) where the source of your project will be. If the folder "Name" already exists the 'Create directory for solution' box should be left unchecked, otherwise it will create as a subfolder regardless.<br />
<br />
[[Image:Compiling_plugins_msvc2010_002.jpg|720px]]<br />
<br />
Select application settings. When creating a plugin check the application type 'DLL' and when creating a console application (such as avs2wav.exe for example) check the application type 'Console application'. Also check the additional option 'Empty project' boxes. Click on finish:<br />
<br />
[[Image:Compiling_plugins_msvc2010_003.jpg]]<br />
<br />
=== Adding files to the project ===<br />
<br />
In the Solution Explorer window, the solution has the 'folders' External Dependencies, Header Files, Resource Files and Source Files:<br />
<br />
[[Image:Compiling_plugins_msvc2010_004.jpg]]<br />
<br />
* When creating a plugin using the C++ API, you need to copy the existing source files (*.cpp), headers (*.h) and avisynth.h in your project folder. If you started from scratch, you only need to copy avisynth.h in your project folder.<br />
<br />
* When creating a plugin using the C API, you need to copy the existing source files (*.c), headers (*.h) and avisynth_c.h in your project folder. If you started from scratch, you only need to copy avisynth_c.h in your project folder. Note make sure your source files end with '.c' instead of '.cpp' (that's how for example MSVC++ knows it's C code).<br />
<br />
You can add the source and header files to your project by right-clicking on a 'folder' (say Header Files as in the screenshot below), select Add and Existing Item (or New Item if you start from scratch):<br />
<br />
[[Image:Compiling_plugins_msvc2010_005.jpg]]<br />
<br />
When creating a plugin using the C API, you need to do two additional things:<br />
<br />
* You need to link to avisynth.lib (create the folder InvertNeg/lib and copy the library to it). In the linker add lib\avisynth.lib under 'Additional Dependencies' (both for the release and debug configuration):<br />
:[[Image:Compiling_cplugins_msvc2010_001.jpg]]<br />
<br />
* When compiling with MSVC++ you also need to add a definition file to your project (otherwise LoadCPlugin can't load the library). Create a text file (here named InvertNeg.def), add it to your project (under source files) and add it to the 'Module Definition File' in the linker (both for the release and debug configuration):<br />
:[[Image:Compiling_cplugins_msvc2010_002.jpg]]<br />
<br />
Select the release build, since we are building the release build.<br />
<br />
=== General settings ===<br />
<br />
If it's your first time you use the compiler, you need to select the expert settings to make the build tab visible:<br />
<br />
Tools > Settings > Expert Settings<br />
<br />
[[Image:Compiling_plugins_msvc2010_006.jpg|720px]]<br />
<br />
In the property page you can see (and change) the location of the DLL that will be build:<br />
<br />
Right click on the project name (InvertNeg in our case) > Properties > Configuration Properties > General<br />
<br />
The default location is $(SolutionDir)$(Configuration)\. You have set the 'SolutionDir' when defining the project (D:\AviSynth\Plugins|InvertNeg in our case). 'Configuration' will be the Release or Debug folder depending on which configuration you have selected.<br />
<br />
[[Image:Compiling_plugins_msvc2010_07.jpg|720px]]<br />
<br />
Next you need to be aware of the VC++ Directories and change them if necessary:<br />
<br />
Right click on the project name (InvertNeg in our case) > Properties > Configuration Properties > VC++ Directories<br />
<br />
Here you will find the location of the 'Include Directories' and others. $(VCInstallDir)include points to the include folder of MSVC++ 2010 and $(WindowsSdkDir)include to the include folder of the Microsoft Platform SDK. When including headers (such as windows.h) in your project they will be searched for in the include folders (unless you explicitly add its location when including them). So both of them should point to the correct folders. <br />
<br />
Note that in general windows.h should be included in your project. It is the header file for accessing the Win32 API through C/C++ and it is located in the include folder of the Microsoft Platform SDK.<br />
<br />
[[Image:Compiling_plugins_msvc2010_008.jpg]]<br />
<br />
You can see the values of VCInstallDir and WindowsSdkDir when opening the VS command prompt:<br />
<br />
Tools > Visual Studio > Command Prompt<br />
<br />
The VS command prompt will be loaded. Type set and you will see the variables. They will be set when starting MSVC++ 2010 (by vsvars32.bat which is located in your <VisualStudioInstallDir>\Common7\Tools folder).<br />
<br />
=== Building the plugin or console application ===<br />
<br />
Now you are ready to build you DLL/EXE. Go to<br />
<br />
Build > Build Solution<br />
<br />
And you will find your compiled plugin in the Location\Name\Folder.<br />
<br />
[[Image:Compiling_plugins_msvc2010_009.jpg|720px]]<br />
<br />
[[Category:AviSynth_Development]]<br />
[[Category:FilterSDK]]</div>Adminhttp://avisynth.nl/index.php/Category:UsersCategory:Users2018-07-06T12:13:26Z<p>Admin: Created page with "add users in this category Category:AviSynth"</p>
<hr />
<div>add users in this category<br />
<br />
[[Category:AviSynth]]</div>Adminhttp://avisynth.nl/index.php/User:AdminUser:Admin2018-07-06T12:12:26Z<p>Admin: </p>
<hr />
<div>link: http://avisynth.nl/index.php/User:Admin/Filter_SDK<br />
<br />
<nowiki>%%% tables:</nowiki> <br><br />
<nowiki>{| border="1"</nowiki> <br><br />
<nowiki>|- </nowiki> <br>nl<br />
<nowiki>| v2.55</nowiki> <br><br />
<nowiki>| Added fourCC option.</nowiki> <br><br />
<nowiki>|}</nowiki><br />
<br />
<br />
<nowiki>%%% tables - more advanced (three columns with different width):</nowiki> <br><br />
<nowiki>{| border="1" cellpadding="4"</nowiki> <br><br />
<nowiki>!width=25%| Filter</nowiki> <br><br />
<nowiki>!width=50%| Description</nowiki> <br><br />
<nowiki>!width=25%| Color format</nowiki> <br><br />
<nowiki>|-</nowiki> <br><br />
<nowiki>| [[Info]]</nowiki> <br><br />
<nowiki>| Prints out image and sound information.</nowiki> <br><br />
<nowiki>| RGB24, RGB32, YUY2, Y8, YV411, YV12, YV16, YV24</nowiki> <br><br />
<nowiki>|)</nowiki><br />
<br />
<br />
<nowiki>%%% creating and referring to a category:</nowiki> <br><br />
<nowiki>Add the following at the end of a page:</nowiki> <br><br />
<nowiki>[[Category:Internal filters]]</nowiki><br />
<br />
<nowiki>%%% creating and referring to a subcategory:</nowiki> <br><br />
<nowiki>%%% for example a codecs category divided into several subcategories</nowiki> <br><br />
<nowiki>Add the following at the end of a codec description page:</nowiki> <br><br />
<nowiki>[[Category:LosslessCodecs]]</nowiki> <br><br />
<nowiki>[[Category:Codecs]]</nowiki><br />
<br />
when saving it, it will show up like this: <br><br />
<nowiki>[[Category:LosslessCodecs|Codecs]]</nowiki><br />
<br />
Now go to the LosslessCodecs page and add some text followed by <br><br />
<nowiki>[[Category:Codecs]]</nowiki><br />
<br />
Finally go to Codecs page and add some text.<br />
<br />
<nowiki>%%% redirect to other pages:</nowiki> <br><br />
<nowiki>#REDIRECT [[BlankClip]] [[Category:Internal filters]]</nowiki><br />
<br />
<br />
<nowiki>%%% linking to 'Runtime Functions' when clicking on 'blabla':</nowiki> <br><br />
<nowiki><div id="runtime">Runtime Functions</div></nowiki> <br><br />
<nowiki>[[#runtime|blabla]]</nowiki><br />
<br />
<br />
<nowiki>%%% linking - works only for sections:</nowiki> <br><br />
<nowiki>== Runtime Functions ==</nowiki> <br><br />
<nowiki>[[#Runtime_Functions|Runtime Functions]]</nowiki><br />
<br />
<br />
<nowiki>%%% templates</nowiki> <br><br />
<nowiki>{{Template:FuncDef| ...}}</nowiki> <br><br />
... <br><br />
<nowiki>{{Template:Func4Def| ...}}</nowiki> <br><br />
...<br />
<br />
they are defined on this page: ...<br />
<br />
<nowiki>%%% Filters: when adding defaults in the template description use "&#61 ;" (without empty space) and not "=", otherwise the template is not generated:</nowiki> <br><br />
<nowiki>{{Template:FuncDef|AviSource(string filename [, ... ] [, bool audio &#61; true] [, string pixel_type &#61; YV12] [, string fourCC])}}</nowiki><br />
<br />
<br />
%%% forcing table of contents: <br><br />
Add "<nowiki>__FORCETOC__</nowiki>" to force a table of contents. If the number of sections is less than four, the table of contents will not automatically be generated.<br />
<br />
<br />
%%% Link to a category page: <br><br />
<nowiki>Link to the page http://www.avisynth.org/mediawiki/wiki/Category:Internal_filters: [[:Category:Internal_filters]]</nowiki><br />
<br />
<br />
%%% added languages:<br />
The sidebar should be updated: <br><br />
<nowiki>http://avisynth.nl/index.php/MediaWiki:Sidebar</nowiki><br />
<br />
<br />
%%% Formula's using LaTeX (and the "math" tags):<br />
:<math>\eta(\tau) = q^{1/24} \prod_{n=1}^{\infty} (1-q^{n})</math><br />
<br />
{{FilterCat|AviSynth|Users}}</div>Adminhttp://avisynth.nl/index.php/User:AdminUser:Admin2018-07-06T12:11:01Z<p>Admin: </p>
<hr />
<div>link: http://avisynth.nl/index.php/User:Admin/Filter_SDK<br />
<br />
<nowiki>%%% tables:</nowiki> <br><br />
<nowiki>{| border="1"</nowiki> <br><br />
<nowiki>|- </nowiki> <br>nl<br />
<nowiki>| v2.55</nowiki> <br><br />
<nowiki>| Added fourCC option.</nowiki> <br><br />
<nowiki>|}</nowiki><br />
<br />
<br />
<nowiki>%%% tables - more advanced (three columns with different width):</nowiki> <br><br />
<nowiki>{| border="1" cellpadding="4"</nowiki> <br><br />
<nowiki>!width=25%| Filter</nowiki> <br><br />
<nowiki>!width=50%| Description</nowiki> <br><br />
<nowiki>!width=25%| Color format</nowiki> <br><br />
<nowiki>|-</nowiki> <br><br />
<nowiki>| [[Info]]</nowiki> <br><br />
<nowiki>| Prints out image and sound information.</nowiki> <br><br />
<nowiki>| RGB24, RGB32, YUY2, Y8, YV411, YV12, YV16, YV24</nowiki> <br><br />
<nowiki>|)</nowiki><br />
<br />
<br />
<nowiki>%%% creating and referring to a category:</nowiki> <br><br />
<nowiki>Add the following at the end of a page:</nowiki> <br><br />
<nowiki>[[Category:Internal filters]]</nowiki><br />
<br />
<nowiki>%%% creating and referring to a subcategory:</nowiki> <br><br />
<nowiki>%%% for example a codecs category divided into several subcategories</nowiki> <br><br />
<nowiki>Add the following at the end of a codec description page:</nowiki> <br><br />
<nowiki>[[Category:LosslessCodecs]]</nowiki> <br><br />
<nowiki>[[Category:Codecs]]</nowiki><br />
<br />
when saving it, it will show up like this: <br><br />
<nowiki>[[Category:LosslessCodecs|Codecs]]</nowiki><br />
<br />
Now go to the LosslessCodecs page and add some text followed by <br><br />
<nowiki>[[Category:Codecs]]</nowiki><br />
<br />
Finally go to Codecs page and add some text.<br />
<br />
<nowiki>%%% redirect to other pages:</nowiki> <br><br />
<nowiki>#REDIRECT [[BlankClip]] [[Category:Internal filters]]</nowiki><br />
<br />
<br />
<nowiki>%%% linking to 'Runtime Functions' when clicking on 'blabla':</nowiki> <br><br />
<nowiki><div id="runtime">Runtime Functions</div></nowiki> <br><br />
<nowiki>[[#runtime|blabla]]</nowiki><br />
<br />
<br />
<nowiki>%%% linking - works only for sections:</nowiki> <br><br />
<nowiki>== Runtime Functions ==</nowiki> <br><br />
<nowiki>[[#Runtime_Functions|Runtime Functions]]</nowiki><br />
<br />
<br />
<nowiki>%%% templates</nowiki> <br><br />
<nowiki>{{Template:FuncDef| ...}}</nowiki> <br><br />
... <br><br />
<nowiki>{{Template:Func4Def| ...}}</nowiki> <br><br />
...<br />
<br />
they are defined on this page: ...<br />
<br />
<nowiki>%%% Filters: when adding defaults in the template description use "&#61 ;" (without empty space) and not "=", otherwise the template is not generated:</nowiki> <br><br />
<nowiki>{{Template:FuncDef|AviSource(string filename [, ... ] [, bool audio &#61; true] [, string pixel_type &#61; YV12] [, string fourCC])}}</nowiki><br />
<br />
<br />
%%% forcing table of contents: <br><br />
Add "<nowiki>__FORCETOC__</nowiki>" to force a table of contents. If the number of sections is less than four, the table of contents will not automatically be generated.<br />
<br />
<br />
%%% Link to a category page: <br><br />
<nowiki>Link to the page http://www.avisynth.org/mediawiki/wiki/Category:Internal_filters: [[:Category:Internal_filters]]</nowiki><br />
<br />
<br />
%%% added languages:<br />
The sidebar should be updated: <br><br />
<nowiki>http://avisynth.nl/index.php/MediaWiki:Sidebar</nowiki><br />
<br />
<br />
%%% Formula's using LaTeX (and the "math" tags):<br />
:<math>\eta(\tau) = q^{1/24} \prod_{n=1}^{\infty} (1-q^{n})</math><br />
<br />
[[Category:AviSynth|Users]]</div>Adminhttp://avisynth.nl/index.php/User:Raffriff42User:Raffriff422018-02-10T15:04:16Z<p>Admin: added comment</p>
<hr />
<div>[[Category:Talk]]<br />
=== Subpages ===<br />
:[[File:Utils-r41.avsi|'''Utils-r41.avsi''']] (a library of basic utility functions; most require AVS+)<br />
:[[User:Raffriff42/Utils-r41_Quick_Reference|'''Utils-r41_Quick_Reference''']] (a quick reference page for the above)<br />
<br />
:[[User:Raffriff42/Wiki_notes|'''Wiki_notes''']] (useful wikicode snippets)<br />
<br />
:[[User:Raffriff42/sandbox]] (blank)<br />
:[[User:Raffriff42/Main_Page_sandbox]] (blank)<br />
<br />
=== Talk ===<br />
<br />
==== Color Presets, Categories ====<br />
I like what you did with the color presets :) - [[User:Reel.Deal|Reel.Deal]] , August 4th 2014<br />
:Hi again. Please fix the categories when you have time: http://avisynth.nl/index.php/Special:WantedCategories (either create them or remove them if they are doubles). Thanks for your efforts! Btw, the complete list: http://avisynth.nl/index.php/Special:Categories [[User:Admin|Admin]] 00:35, 21 September 2014 (CEST)<br />
:Please also look at http://avisynth.nl/index.php/Special:LonelyPages . These pages are not linked from anywhere. [[User:Admin|Admin]] 00:52, 21 September 2014 (CEST)<br />
::Sure thing, I will look at them soon. <br />
::[[User:Raffriff42|Raffriff42]] 04:54, 21 September 2014 (CEST)<br />
<br />
:::Hi, can you please hold off on doing that for just a bit? A handful of those entries are mine and I would like to revise and edit a few things before it gets finalized. I already started but I need a little bit more time. [[User:Reel.Deal|Reel.Deal]] 12:12, 21 September 2014 (CEST)<br />
<br />
::::You are better qualified to do the Categories anyway, as it is related to the (amazing) work you've been doing lately with External Filters. I'm gonna be busy with the TODO pages for a while, and after that, or maybe before that, a little break time; I'm tired! [[User:Raffriff42|Raffriff42]] 16:12, 21 September 2014 (CEST)<br />
<br />
::Progress report: I have done some work on [[Special:Categories|Categories]], including as many [[Special:WantedCategories|Wanted Categories]] as I could fix - leaving the foreign language ones, and some others that look like Reel.Deal might be working on them. Ditto, [[Special:WantedPages|Wanted Pages]]. There remains one [[Special:WantedFiles|Wanted File]] that I cannot fix, namely [[Frebuild.avsi]]. That file seems to be lost. <br />
::[[User:Raffriff42|Raffriff42]] 03:05, 15 November 2015 (CET)<br />
<br />
<br />
:::Raffriff42, your recent changes to the templates broke some pages, take a look at [[ChromaShiftSP]], [[FTurn]], and probably more. Also the author's section in the abstract table looks off now (look at FTurn). [[User:Reel.Deal|Reel.Deal]] 05:41, 14 December 2015 (CET)<br />
<br />
:::Putting the category without a line break fixes the problem, I'll try to go back and do it to all templates. [[User:Reel.Deal|Reel.Deal]] 05:53, 14 December 2015 (CET)<br />
<br />
::::Ouch, so sorry about that! I should have checked! -- [[User:Raffriff42|Raffriff42]] 06:22, 14 December 2015 (CET)<br />
<br />
"clip.BlankClip does not work reliably here; use BlankClip(clip) instead"<br />
Please explain. Why, when, under what circumstances? [[User:Admin|Admin]] 16:04, 10 February 2018 (CET)</div>Adminhttp://avisynth.nl/index.php/Clip_propertiesClip properties2017-10-29T22:44:20Z<p>Admin: typo</p>
<hr />
<div><div style="max-width:62em" ><br />
You can access a variety of clip properties in AviSynth scripts. For example, if the variable ''clip'' holds a video clip, then ''clip''.{{FuncArg|Height}} is its height in pixels, ''clip''.{{FuncArg|FrameCount}} is its length in frames, and so on. <br />
<br />
Clip properties can be accessed like [[Script_variables|script variables]], except that they are read-only (in [[wikipedia:C_(programming_language)|'''C''']] terminology, they cannot be ''L-values'').<br />
<br />
__TOC__<br />
<br />
The full list of properties:<br />
<br />
==== Content Properties ====<br />
* ''bool'' clip.{{Term|HasAudio}}<br />
: Returns true if the clip has audio, false otherwise.<br />
* ''bool'' clip.{{Term|HasVideo}}<br />
: Returns true if the clip has video, false otherwise.<br />
<br />
==== Video: Resolution ====<br />
* ''int'' clip.{{Term|Width}}<br />
: Returns the width of the clip in pixels.<br />
* ''int'' clip.{{Term|Height}}<br />
: Returns the height of the clip in pixels.<br />
<br />
==== Video: Framerate and Duration ====<br />
* ''int'' clip.{{Term|FrameCount}}<br />
: Returns the total number of video frames contained in the clip. <br />
* ''float'' clip.{{Term|FrameRate}}<br />
: Returns approximate framerate. Video framerate is actually a ratio of two 32-bit integers; <br />
: so for the precise number, use {{Term|FrameRateNumerator}} and {{Term|FrameRateDenominator}}.<br />
* ''int'' clip.{{Term|FrameRateNumerator}}<br />
: Returns the framerate numerator.<br />
* ''int'' clip.{{Term|FrameRateDenominator}}<br />
: Returns the framerate denominator.<br />
<br />
==== Video: Interlacing ====<br />
* ''bool'' clip.{{Term|IsFieldBased}}<br />
: Returns true if the clip is ''field-based''. What this means is explained [[Interlaced_fieldbased|'''here''']].<br />
* ''bool'' clip.{{Term|IsFrameBased}}<br />
: Returns true if the clip is ''frame-based''. What this means is explained [[Interlaced_fieldbased|'''here''']].<br />
* ''bool'' clip.{{Term|GetParity([ int ''f'' ])}}<br />
: Returns true if frame {{Term|''f''}} (default 0) is the top field of a field-based clip, or if it is a full frame with top field first of a frame-based clip.<br />
<br />
==== Video: Color Format ====<br />
* ''bool'' clip.{{Term|IsPlanar}}<br />
: Returns true if the color format is [[Planar]], false otherwise.<br />
* ''bool'' clip.{{Term|IsInterleaved}}<br />
: Returns true if the color format is [[Interleaved]], false otherwise.<br />
* ''bool'' clip.{{Term|IsRGB}}<br />
: Returns true if the color format is [[RGB]], false otherwise.<br />
: (applies to all RGB clips, whether Planar or Interleaved, RGB or RGBA)<br />
* ''bool'' clip.{{Term|IsRGB24}}<br />
: Returns true if the color format is [[RGB24]], false otherwise.<br />
* ''bool'' clip.{{Term|IsRGB32}}<br />
: Returns true if the color format is [[RGB32]], false otherwise.<br />
* ''bool'' clip.{{Term|IsYUV}}<br />
: Returns true if the color format is [[YUV]], false otherwise.<br />
: (note that {{Term|IsYUV}} returns ''false'' for a [[Avisynthplus_color_formats|YUVA]] clip, and vice versa)<br />
* ''bool'' clip.{{Term|IsYUY2}} (clip)<br />
: Returns true if the color format is [[YUY2]], false otherwise.<br />
* ''bool'' clip.{{Term|IsY8}} (from v2.60)<br />
: Returns true if the color format is [[Y8]], false otherwise.<br />
* ''bool'' clip.{{Term|IsYV12}}<br />
: Returns true if the color format is [[YV12]], false otherwise.<br />
* ''bool'' clip.{{Term|IsYV16}} (from v2.60)<br />
: Returns true if the clip color format is [[YV16]], false otherwise.<br />
* ''bool'' clip.{{Term|IsYV24}} (v2.60)<br />
: Returns true if the color format is [[YV24]], false otherwise.<br />
* ''bool'' clip.{{Term|IsYV411}} (from v2.60)<br />
: Returns true if the color format is [[YV411]], false otherwise.<br />
* ''bool'' clip.{{Term|Is420}}<br />
: {{AvsPluscon}} Returns true if the color format is 4:2:0, false otherwise.<br />
* ''bool'' clip.{{Term|Is422}}<br />
: {{AvsPluscon}} Returns true if the color format is 4:2:2, false otherwise.<br />
* ''bool'' clip.{{Term|Is444}}<br />
: {{AvsPluscon}} Returns true if the color format is 4:4:4, false otherwise.<br />
* ''bool'' clip.{{Term|IsY}}<br />
: {{AvsPluscon}} Returns true if the color format is ''Y''-plane only, false otherwise.<br />
* ''bool'' clip.{{Term|IsYUVA}}<br />
: {{AvsPluscon}} Returns true if the color format is [[Avisynthplus_color_formats|YUVA]], false otherwise.<br />
* ''bool'' clip.{{Term|IsRGB48}}<br />
: {{AvsPluscon}} Returns true if the color format is 16-bit RGB ([[Avisynthplus_color_formats|RGB48]]), false otherwise.<br />
* ''bool'' clip.{{Term|IsRGB64}}<br />
: {{AvsPluscon}} Returns true if the color format is 16-bit RBGA ([[Avisynthplus_color_formats|RGB64]]), false otherwise.<br />
<br />
* ''bool'' clip.{{Term|IsPackedRGB}}<br />
: {{AvsPluscon}} Returns true if the color format is [[Interleaved]] RGB (RGB24/32/48/64), false otherwise.<br />
* ''bool'' clip.{{Term|IsPlanarRGB}}<br />
: {{AvsPluscon}} Returns true if the color format is [[Planar]] RGB, false otherwise.<br />
: (note that {{Term|IsPlanarRGB}} returns ''false'' for a Planar RGBA clip, and vice versa)<br />
* ''bool'' clip.{{Term|IsPlanarRGBA}}<br />
: {{AvsPluscon}} Returns true if the color format is [[Planar]] RGBA, false otherwise.<br />
: (note that {{Term|IsPlanarRGBA}} returns ''false'' for a Planar RGB clip, and vice versa)<br />
* ''bool'' clip.{{Term|HasAlpha}}<br />
: {{AvsPluscon}} Returns true if the color format has an alpha channel; (RGBA or YUVA), false otherwise.<br />
<br />
* ''int'' clip.{{Term|ComponentSize}}<br />
: {{AvsPluscon}} Returns '''1''' for 8-bit formats, '''2''' for 10/12/14/16-bit formats, '''4''' for 32-bit float.<br />
* ''int'' clip.{{Term|NumComponents}}<br />
: {{AvsPluscon}} Returns '''1''' for ''Y''-only formats, '''3''' for RGB and YUV, '''4''' for RGBA and YUVA.<br />
* ''int'' clip.{{Term|BitsPerComponent}}<br />
: {{AvsPluscon}} Returns bit depth per channel &ndash; 8, 10, 12, 14, 16 or 32.<br />
<br />
* ''string'' clip.{{Term|PixelType}} (from v2.60)<br />
: Returns the pixel type as a string, ''eg'' "RGB32".<br />
<br />
==== Audio ====<br />
* ''int'' clip.{{Term|AudioRate}}<br />
: Returns the audio sample rate.<br />
* ''int'' clip.{{Term|AudioLength}}<br />
: Returns the total number of audio samples, per audio channel. <br />
: Be aware of possible overflow on extremely long clips (with >= 2<sup>31</sup> audio samples) &ndash; see [[#Examples|Examples]] below.<br />
* ''int'' clip.{{Term|AudioLengthLo([ int ''m'' ])}} (from v2.60)<br />
* ''int'' clip.{{Term|AudioLengthHi([ int ''d'' ])}} (from v2.60)<br />
: clip.{{Term|AudioLengthLo}} returns the total number of audio samples, modulo {{Term|''m''}}, which is 10<sup>9</sup> by default.<br />
: clip.{{Term|AudioLengthHi}} returns the total number of audio samples, divided by {{Term|''d''}}, which is 10<sup>9</sup> by default.<br />
: Therefore, assuming {{Term|''m''}}=={{Term|''d''}}, the (possibly 64-bit) total equals {{Term|AudioLengthHi}} × {{Term|''m''}} + {{Term|AudioLengthLo}}.<br />
: (see [[#Examples|Examples]] below)<br />
* ''float'' clip.{{Term|AudioLengthF}}<br />
: Returns the total number of audio samples as a float-point number. <br />
: No overflow limit, but there is a possible ''precision'' limit &ndash; see [[#Examples|Examples]] below.<br />
* ''string'' clip.{{Term|AudioLengthS}} (from v2.60)<br />
: Returns the total number of audio samples as a string.<br />
* ''float'' clip.{{Term|AudioDuration}} (from v2.60)<br />
: Returns the audio duration in seconds. <br />
* ''int'' clip.{{Term|AudioChannels}}<br />
: Returns the number of audio channels.<br />
* ''int'' clip.{{Term|AudioBits}}<br />
: Returns the audio bit depth, ''eg'', 8, 16, 24 or 32.<br />
* ''bool'' clip.{{Term|IsAudioFloat}}<br />
: Returns true if the audio format is [[Float]].<br />
* ''bool'' clip.{{Term|IsAudioInt}}<br />
: Returns true if the audio format is an integer type.<br />
<br />
<br />
====Examples====<br />
* Clip duration = 10 seconds. All {{Term|AudioLength}} forms agree.<br />
<div {{BoxWidthIndent|46|2}} ><br />
[[ColorBars]](width=440, height=440)<br />
[[Trim]](0, 299)<br />
[[Info]]<br />
[[Levels]](0, 1.0, 255, 64, 255-64, coring=false)<br />
[[Subtitle]](<br />
\ "\nAudioLength = " + [[Internal_functions#String|String]](AudioLength)<br />
\ + "\nAudioLengthS = '" + AudioLengthS + "'"<br />
\ + "\nAudioLengthF = " + String(AudioLengthF)<br />
\ + "\nAudioLengthLo= " + String(AudioLengthLo)<br />
\ + "\nAudioLengthHi= " + String(AudioLengthHi)<br />
\ , font="courier", text_color=$ffffff, size=32, align=4, lsp=0)<br />
</div><br />
:[[File:AudioLength-10s.png]]<br />
<br />
<br />
* Clip duration approximately 24 hours. <br />
<div {{ListItemContinue}} ><br />
Integer {{Term|AudioLength}} overloads (wraps around to a negative number), while the floating-point form has lost several digits of precision.<br />
</div><br />
<div {{BoxWidthIndent|24|2}} ><br />
[[ColorBars]](width=440, height=440)<br />
<span style="color:green">#Trim(0, 299)</span><br />
[[Loop]](24)<br />
Info<br />
...<br />
</div><br />
:[[File:AudioLength-24hr.png]]<br />
<div {{ListItemContinue}} ><br />
Note the {{Term|AudioLengthHi}} / {{Term|AudioLengthLo}} arithmetic:<br />
:total = <tt>4</tt> × <tt>10</tt><sup>9</sup> + <tt>147195848</tt><br />
:total = <tt>4147195848</tt><br />
</div><br />
</div><br />
<br />
<br />
----<br />
Back to [[AviSynth Syntax]].<br />
<br />
[[Category:AviSynth_Syntax]]</div>Adminhttp://avisynth.nl/index.php/Internal_functionsInternal functions2017-07-10T14:29:10Z<p>Admin: /* Global Options */</p>
<hr />
<div><div style="max-width:82em; min-width:42em;" ><br />
<!-- {{AvsStarFilter}} --><br />
<div style="max-width:62em" ><br />
In addition to [[Internal_filters|internal filters]] AviSynth has a fairly large number of other (non-clip) internal functions. <br />
<br />
The input or/and output of these functions are not clips, but some other variables which can be used in a script. <br />
</div><br />
<br />
__TOC__<br />
<br />
<br />
== Boolean functions ==<br />
<div style="max-width:62em" ><br />
: These return true or false, if the condition that they test holds or not, respectively.<br />
<br />
{{ScriptFunctionH5|IsBool||IsBool(var)}}<br />
: Tests if {{FuncArg|var}} is of the bool type. {{FuncArg|var}} can be any expression allowed by the [[AviSynth Syntax]].<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
b = false<br />
IsBool(b) = true<br />
IsBool(1 < 2 && 0 == 1) = true<br />
IsBool(123) = false<br />
</div><br />
<br />
{{ScriptFunctionH5|IsClip||IsClip(var)}}<br />
: Tests if {{FuncArg|var}} is of the clip type. {{FuncArg|var}} can be any expression allowed by the [[AviSynth Syntax]].<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
<br />
c = [[AviSource]](...)<br />
IsClip(c) = true<br />
IsClip("c") = false<br />
</div><br />
<br />
{{ScriptFunctionH5|IsFloat||IsFloat(var)}}<br />
: Tests if {{FuncArg|var}} is of the float type. {{FuncArg|var}} can be any expression allowed by the [[AviSynth Syntax]].<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
f = [[Internal_functions/Numeric_functions|Sqrt]](2)<br />
IsFloat(f) = true<br />
IsFloat(2) = true # ints are considered to be floats by this function<br />
IsFloat(true) = false<br />
</div><br />
<br />
{{ScriptFunctionH5|IsInt||IsInt(var)}}<br />
: Tests if {{FuncArg|var}} is of the int type. {{FuncArg|var}} can be any expression allowed by the [[AviSynth Syntax]].<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
IsInt(2) = true<br />
IsInt(2.1) = false<br />
IsInt(true) = false<br />
</div><br />
<br />
{{ScriptFunctionH5|IsString||IsString(var)}}<br />
: Tests if {{FuncArg|var}} is of the string type. {{FuncArg|var}} can be any expression allowed by the [[AviSynth Syntax]].<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
IsString("test") = true<br />
IsString(2.3) = false<br />
IsString([[Internal_functions/Conversion_functions|String]](2.3)) = true<br />
</div><br />
<br />
{{ScriptFunctionH5|Exist||Exist(filename)}}<br />
: Tests if the file specified by {{FuncArg|filename}} exists.<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
filename = ...<br />
clp = Exist(filename) <br />
\ ? [[AviSource]](filename) <br />
\ : [[Internal_functions/Control_functions|Assert]](false, "file: " + filename + " does not exist")<br />
</div><br />
<br />
{{ScriptFunctionH5|Defined||Defined(var)}}<br />
: Tests if {{FuncArg|var}} is defined. Can be used inside [[Script_functions]] to test if an optional argument has been given an explicit value.<br />
: More formally, the function returns false if its argument (normally a function argument or variable) has the void ('undefined') type, otherwise it returns true.<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
b_arg_supplied = Defined(arg)<br />
myvar = b_arg_supplied ? ... : ...<br />
</div><br />
</div><br />
<br />
<br />
== Control functions ==<br />
<div style="max-width:62em" ><br />
: These facilitate flow of control (loading of scripts, arguments checks, global settings adjustment, etc.).<br />
<br />
{{ScriptFunctionH5|Apply||Apply(string ''func_string'' [, arg1 [, arg2 [, ... [, argn]]]] )}}<br />
: Calls the function or filter {{FuncArg|func_string}} with arguments {{FuncArg|arg1}}, {{FuncArg|arg2}}, ..., {{FuncArg|argn}} (as many as supplied). Thus, it provides a way to call a function or filter '''by name''' providing arguments in the usual way as in a typical function call. <br />
: Consequently, <tt>Apply("f", x)</tt> is equivalent to <tt>f(x)</tt> which in turn is equivalent to <tt>Eval("f(" + String(x) + ")")</tt>.<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
# here the same call to [[Resize|BicubicResize]] as in the Eval() example is shown <br />
Apply("BicubicResize", last, 352, 288)<br />
# Note that the clip argument must be supplied - 'last' is not implicitly assumed<br />
</div><br />
<br />
{{ScriptFunctionH5|Eval||Eval(expression [, string ''name''])}}<br />
: Evaluates an arbitrary {{FuncArg|expression}} as if it was placed inside the script at the point of the call and returns the result of evaluation (either to the [[Script_variables|variable]] that is explicitly assigned to or to the Last special variable.<br />
: You can use '''Eval''' to construct and evaluate expressions dynamically inside your scripts, based on variable input data. Below some specific examples are shown but you get the general idea.<br />
: Argument {{FuncArg|name}} will be shown in the error message besides the script name. Both will be followed with the line number in the script where the is error caused.<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
# calls [[BicubicResize]](last, 352, 288)<br />
settings = "352, 288"<br />
Eval( "BicubicResize(" + settings + ")" )<br />
<br />
# results in Defined(u) == false<br />
u = Eval("#") <br />
<br />
# increments a global based on a variable's value<br />
Eval("global my_counter = my_counter + " + String(increment)) <br />
<br />
# multi-line example with comment and line continuation<br />
Eval("""<br />
[[ColorBars]]<br />
[[BicubicResize]](352, 288)<br />
#FlipVertical<br />
Subtitle(<br />
\ "Width = " + [[Internal_functions#String|String]]([[Clip_properties|Width]]) + "\n"<br />
\ + "Height = " + String(Height)<br />
\ , align=7, lsp=0)<br />
""")<br />
</div><br />
<br />
{{ScriptFunctionH5|Import||Import(filename)}}<br />
: Evaluates the contents of another script and returns that script's return value. Typically it is used to make available to the calling script library functions and the return value is not used. However this is simply a convention; it is not enforced by the [[AviSynth Syntax]]. See also the dedicated [[Import]] page in [[Internal filters]] for other possible uses.<br />
: Possible scenarios (an indicative list) where the return value could be of use is for the library script to:<br />
:* indicate whether it succesfully initialised itself (a bool return value), <br />
:* inform for the number of presets found on disk (an int return value);<br />
: the value then could be tested by the calling script to decide what action to take next.<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
# here we do not care about the value (''mylib.avsi'' contains only functions)<br />
Import("mylib.avsi") <br />
...<br />
# ''mysources.avsi'' loads predetermined file names from a folder into globals<br />
okflag = [[Import]]("mysources.avsi") <br />
source = okflag ? global1 + global2 + global3 : [[BlankClip]]()<br />
</div><br />
<br />
{{ScriptFunctionH5|Select||Select(index, item0 [, item1 [, ...[, itemn]]])}}<br />
: Returns the item selected by the {{FuncArg|index}} argument, which must be of int type (0 returns {{FuncArg|item0}}, 1 returns {{FuncArg|item1}}, ..., etc). Items can be any script [[Script_variables|variable]] or expression of any type and can even be mixed.<br />
<br />
:If {{FuncArg|index}} is out of range, an error is raised.<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
# select a clip-brush from a set of presets<br />
idx = 2<br />
brush = Select(idx, [[AviSource]]("round.avi"), <br />
\ rectangle, diagonal, diagonal.[[FlipHorizontal]])<br />
</div><br />
<br />
Note - all branches are evaluated:<br />
<div {{BoxWidthIndent|56|2}} ><br />
index=1<br />
Select(index, "zero", "one", "two", <br />
\ Assert(false, "Select evaluates all branches")) <br />
## NOTE this code does not run - it throws [[#Assert|Assert]] error<br />
## because Select evaluates all branches<br />
</div><br />
<br />
If this is not desired, use the [[Ternary_operator|conditional execution]] operator: <br />
<div {{BoxWidthIndent|56|2}} ><br />
index=1<br />
x = (index==0) ? "zero"<br />
\ : (index==1) ? "one"<br />
\ : (index==2) ? "two"<br />
\ : Assert(false, "index out of range")<br />
</div><br />
<br />
{{ScriptFunctionH5|Default||Default(x, d)}}<br />
: Returns {{FuncArg|x}} if '''Defined'''(x) is true, {{FuncArg|d}} otherwise. {{FuncArg|x}} must either be a function's argument or an already declared script variable (ie a variable which has been assigned a value) else an error will occur.<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
function myfunc(clip c, ..., int "strength") {<br />
...<br />
strength = Default(strength, 4) # if not supplied make it 4<br />
...<br />
}<br />
</div><br />
<br />
{{ScriptFunctionH5|Assert||Assert(condition [, err_msg])}}<br />
: Does nothing if {{FuncArg|condition}} is true; throws an error, immediately terminating script execution, if {{FuncArg|condition}} is false. In the later case {{FuncArg|err_msg}}, if supplied, is presented to the user through a dialog box; else the standard message "Assert: assertion failed" shows up.<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
function myfunc(clip c, ..., int "strength") {<br />
...<br />
strength = Default(strength, 4) # if not supplied make it 4<br />
Assert(strength > 0, "'strength' must be positive")<br />
...<br />
}<br />
</div><br />
<br />
{{ScriptFunctionH5|NOP||NOP()}}<br />
: This is a no-operation function provided mainly for conditional execution with non-return value items such as [[Import]], when no "else" condition is desired. That is, use it whenever the [[AviSynth Syntax]] requires an operation (such as with the ?: [[Operators#For_Booleans|operator]]) but your script does not need one.<br />
: Return value: 0 (int type).<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
preset = want_presets ? [[AviSource]]("c:\presets\any.avi") : NOP<br />
... <br />
loadlib ? [[Import]]("my_useful_functions.avs") : NOP<br />
</div><br />
<br />
{{ScriptFunctionH5|Undefined|v2.60|Undefined()}}<br />
: Returns the undefined state.<br />
: It's the state for which '''Defined'''() returns false.<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
x = Undefined()<br />
Defined(x) # == false<br />
</div><br />
</div><br />
<br />
<br />
== Global Options ==<br />
<div style="max-width:62em" ><br />
{{ScriptFunctionH5|SetMemoryMax||SetMemoryMax(amount)}}<br />
: Sets the maximum memory that AviSynth uses (in MB) to the value of {{FuncArg|amount}}. Setting to zero just returns the current Memory Max value. In the 2.5 series the default Memory Max value is 25% of the free physical memory, with a minimum of 16MB.<br />
: The default Memory Max is also limited to 512MB.<br />
:{|class="wikitable" <!-- width=50% --><br />
|-<br />
| Free memory<br />
| <64<br />
| 128<br />
| 256<br />
| 512<br />
| 1024<br />
| 2048<br />
| 3072<br />
|-<br />
| Default Max<br />
| 16<br />
| 32<br />
| 64<br />
| 192<br />
| 448<br />
| 512<br />
| 512<br />
|}<br />
: In some versions there is a default setting of 5MB, which is quite low. If you encounter problems (e.g. low speed) try to set this values to at least 32MB. Too high values can result in crashes because of 2GB address space limit.<br />
: Return value: Actual MemoryMax value set.<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
SetMemoryMax(128)<br />
</div><br />
<br />
{{ScriptFunctionH5|SetWorkingDir||SetWorkingDir(path)}}<br />
: Sets the default directory for AviSynth to the {{FuncArg|path}} argument.<br />
: This is primarily for easy loading of source clips, [[Import|importing]] scripts, etc. It does not affect plugins' autoloading. <br />
: Return value is 0 if successful, -1 otherwise.<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
SetWorkingDir("c:\my_presets")<br />
[[AviSource]]("border_mask.avi") # this loads c:\my_presets\border_mask.avi<br />
</div><br />
<br />
{{ScriptFunctionH5|SetPlanarLegacyAlignment||SetPlanarLegacyAlignment(mode)}}<br />
: Set alignment mode for [[planar]] frames. {{FuncArg|mode}} can either be true or false.<br />
: Some older [[External_plugins|plugins]] illegally assume the layout of video frames in memory. This special filter forces the memory layout of planar frames to be compatible with prior versions of AviSynth. The filter works on the [[The_script_execution_model/Evaluation_of_runtime_scripts|GetFrame]]() call stack, so it effects filters '''before''' it in the script.<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Example : Using an older version of Mpeg2Source() (1.10 or older):<br />
<br />
LoadPlugin("...\Mpeg2Decode.dll")<br />
Mpeg2Source("test.d2v") # A plugin that illegally assumes the layout of memory<br />
SetPlanarLegacyAlignment(true) # Set legacy memory alignment for prior statements<br />
[[Convert|ConvertToYUY2]]() # Statements through to the end of the script have<br />
... # advanced memory alignment.<br />
</div><br />
<br />
{{ScriptFunctionH5|OPT_AllowFloatAudio||global OPT_AllowFloatAudio &#61; true ## default false}}<br />
: [[Float]] audio is converted to 16 bit when [[Frameserver|frameserving]] through [[ACM]], unless [[Internal_functions#OPT_AllowFloatAudio|OPT_AllowFloatAudio]] is set to true (this option enables WAVE_FORMAT_IEEE_FLOAT audio output<sup>[http://forum.doom9.org/showthread.php?t=109608]</sup>). In that case the audio is kept as it is. When accessing AviSynth directly (like MeGUI, BeHappy or ffmpeg do for example), there is no automatic conversion.<br />
<br />
:The automatic conversion is done for clients that cannot handle [[Float]] audio (in the old days most of them couldn't). Note conversion takes place ''after'' the script processing is finished. [[Float]] audio is always allowed within the script.<br><br />
<br />
{{ScriptFunctionH5|OPT_UseWaveExtensible||global OPT_UseWaveExtensible &#61; true ## default false}}<br />
: This option enables WAVE_FORMAT_EXTENSIBLE audio output. The default is WAVE_FORMAT_EX.<br />
: '''Note:''' The default DirectShow component for .AVS files, "AVI/WAV File Source", does not correctly implement WAVE_FORMAT_EXTENSIBLE processing, so many application may not be able to detect the audio track. There are third party DirectShow readers that do work correctly. Intermediate work files written using the AVIFile interface for later DirectShow processing will work correctly if they use the DirectShow "File Source (async)" component or equivalent. <br />
<br />
{{ScriptFunctionH5|OPT_dwChannelMask|v2.60|global OPT_dwChannelMask(int v)}}<br />
: This option enables you to set ChannelMask. It overrides WAVEFORMATEXTENSIBLE.dwChannelMask<sup>[[http://wiki.multimedia.cx/index.php?title=WAVEFORMATEXTENSIBLE]</sup> which is set according to this table<br />
<div {{BoxWidthIndent|56|2}} ><br />
0x00004, // 1 -- -- Cf<br />
0x00003, // 2 Lf Rf<br />
0x00007, // 3 Lf Rf Cf<br />
0x00033, // 4 Lf Rf -- -- Lr Rr<br />
0x00037, // 5 Lf Rf Cf -- Lr Rr<br />
0x0003F, // 5.1 Lf Rf Cf Sw Lr Rr<br />
0x0013F, // 6.1 Lf Rf Cf Sw Lr Rr -- -- Cr<br />
0x0063F, // 7.1 Lf Rf Cf Sw Lr Rr -- -- -- Ls Rs<br />
</div><br />
<br />
{{ScriptFunctionH5|OPT_AVIPadScanlines|v2.60|global OPT_AVIPadScanlines &#61; true ## default false}}<br />
: This option enables DWORD aligned planar padding. Default is packed aligned planar padding. See [[AVIFile output emulation|memory alignment used in the AVIFile output emulation]].<br><br />
<br />
{{ScriptFunctionH5|OPT_VDubPlanarHack|v2.60|global OPT_VDubPlanarHack &#61; true ## default false}}<br />
: This option enables flipped YV24 and YV16 chroma planes. This is an hack for early versions of Virtualdub with YV24/YV16 support. <br><br />
<br />
{{ScriptFunctionH5|OPT_Enable_V210|{{AvsPluscon}}|global OPT_Enable_V210 &#61; true ## default false}}<br />
: For 10bit YUV422, [[Frameserver|Frameserve]] interleaved V210 instead of planar P210. (VfW)<br />
<div {{BoxWidthIndent|56|2}} ><br />
{{BoldColor|black|100|§}} ''VfW'' here means [[wikipedia:Video_for_Windows|Video For Windows]] clients such as VirtualDub are affected, but not other clients such as ffmpeg.<br />
</div><br />
<br />
{{ScriptFunctionH5|OPT_Enable_Y3_10_10|{{AvsPluscon}}|global OPT_Enable_Y3_10_10 &#61; true ## default false}}<br />
: For 10bit YUV422, set the [[FourCC]] to Y3[10][10] ('Y', '3', 10, 10) instead of P210 ('P', '2', '1', '0'). (VfW) <br><br />
<br />
{{ScriptFunctionH5|OPT_Enable_Y3_10_16|{{AvsPluscon}}|global OPT_Enable_Y3_10_16 &#61; true ## default false}}<br />
: For 16bit YUV422, use Y3[10][16] instead of P216 (VfW)<br />
:[[TODO]] not working?<br><br />
<br />
{{ScriptFunctionH5|OPT_Enable_b64a|{{AvsPluscon}}|global OPT_Enable_b64a &#61; true ## default false}}<br />
: Use b64a instead of BRA[64] (VfW)<br />
:[[TODO]] not working?<br><br />
<br />
{{ScriptFunctionH5|OPT_Enable_PlanarToPackedRGB|{{AvsPluscon}}|global OPT_Enable_PlanarToPackedRGB &#61; true ## default false}}<br />
: Convert Planar RGB to packed RGB (VfW)<br />
:[[TODO]] not working?<br><br />
</div><br />
<br />
== Conversion functions ==<br />
<div style="max-width:62em" ><br />
: These convert between different types.<br />
<br />
{{ScriptFunctionH5|Value||Value(string)}}<br />
: Converts a decimal string to its associated numeric value.<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Value ("-2.7") = -2.7<br />
</div><br />
<br />
{{ScriptFunctionH5|HexValue||HexValue(string)}}<br />
: Converts a hexadecimal string to its associated numeric value. <br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
HexValue ("FF00") = 65280<br />
</div><br />
<br />
{{ScriptFunctionH5|Hex|v2.60|Hex(int)}}<br />
: Converts a numerical value to its hexadecimal value. See [[Colors]] for more information on specifying colors.<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Hex (10824234) = "A52A2A"<br />
</div><br />
<br />
{{ScriptFunctionH5|String||String(var [, string format_string])}}<br />
: Converts a variable to a string. String arguments are passed along unchanged; booleans are converted to "true" or "false"; numbers (ints or floats) are formatted as described below; all other value types are converted to the empty string. <br />
: If the variable is float or integer, it first converts it to a float and then uses {{FuncArg|format_string}} to convert the float to a string. <br />
:The syntax of format_string is as follows:<br />
: <code>'''%'''[flags][width][.precision]'''f'''</code><br />
:; ''flags'':<br />
:: <tt>- </tt> left align (instead right align)<br />
:: <tt>+ </tt> always print the +/- sign<br />
:: <tt>0 </tt> padding with leading zeros<br />
:: <tt>' '</tt> print a blank instead of a "+"<br />
:: <tt># </tt> always print the decimal point<br />
:; ''width'': the minimum width (the string is never truncated)<br />
:; ''precision'': the number of digits printed<br />
: You can also put arbitrary text around the format_string as defined above, similar to the C-language [http://www.tutorialspoint.com/c_standard_library/c_function_sprintf.htm sprintf] function.<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Subtitle( "Clip height is " + String(last.height) )<br />
<br />
Subtitle( String(1.23, "%f" )) # '1.23'<br />
Subtitle( String(1.23, "%5.1f") ) # ' 1.2'<br />
Subtitle( String(1.23, "%1.3f") ) # '1.230'<br />
Subtitle( String(24, "%05.0f") ) # '00024'<br />
<br />
Subtitle( "PI=" + String(PI, "%0.0f") ) # "PI=3"<br />
Subtitle( "PI=" + String(PI, "%2.0f") ) # "PI= 3"<br />
Subtitle( "PI=" + String(PI, "%3.2f") ) # "PI=3.14"<br />
Subtitle( "PI=" + String(PI, "%0.5f") ) # "PI=3.14159"<br />
Subtitle( "PI=" + String(PI, "%6.3f") ) # "PI= 3.142"<br />
<br />
Subtitle( "'" + String(32, "%0f") + "'" ) # '32.000000'<br />
Subtitle( "'" + String(32, "%0.0f") + "'" ) # '32'<br />
Subtitle( "'" + String(32, "%3.0f") + "'" ) # ' 32'<br />
Subtitle( "'" + String(32, "%8.0f") + "'" ) # ' 32'<br />
<br />
# arbitrary text around format_string:<br />
Subtitle( String(PI(), "PI = %1.5f (more or less)") ))<br />
# another example of arbitrary text:<br />
Subtitle( String(x, "Value of x is %.3f after AR calc") )<br />
# same output as above but using string concatenation:<br />
Subtitle( "Value of x is " + String(x, "%.3f") + " after AR calc") ) <br />
</div><br />
</div><br />
<br />
<br />
== Numeric functions ==<br />
<div style="max-width:62em" ><br />
: These provide common mathematical operations on numeric variables.<br />
<br />
{{ScriptFunctionH5|Max||Max(float, float [, ...])}}<br />
: Returns the maximum value of a set of numbers.<br />
: If all the values are of type Int, the result is an Int. If any of the values are of type Float, the result is a Float.<br />
: This may cause an unexpected result when an Int value greater than 16777216 is mixed with Float values.<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Max (1, 2) = 2<br />
Max (5, 3.0, 2) = 5.0<br />
</div><br />
<br />
{{ScriptFunctionH5|Min||Min(float, float [, ...])}}<br />
: Returns the minimum value of a set of numbers.<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Min (1, 2) = 1<br />
Min (5, 3.0, 2) = 2.0<br />
</div><br />
<br />
{{ScriptFunctionH5|MulDiv||MulDiv(int, int, int)}}<br />
: Multiplies two ints (m, n) and divides the product by a third (d) in a single operation, with 64 bit intermediate result. The actual equation used is <tt> (m * n + d / 2) / d </tt>.<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
MulDiv (1, 1, 2) = 1<br />
MulDiv (2, 3, 2) = 3<br />
</div><br />
<br />
{{ScriptFunctionH5|Floor||Floor(float)}}<br />
: Converts from single-precision, [http://en.wikipedia.org/wiki/Floating_point floating-point] value to int (round down on any fractional amount).<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Floor(1.2) = 1<br />
Floor(1.6) = 1<br />
Floor(-1.2) = -2<br />
Floor(-1.6) = -2<br />
</div><br />
<br />
{{ScriptFunctionH5|Ceil||Ceil(float)}}<br />
: Converts from single-precision, [http://en.wikipedia.org/wiki/Floating_point floating-point] value to int (round up on any fractional amount).<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Ceil(1.2) = 2<br />
Ceil(1.6) = 2<br />
Ceil(-1.2) = -1<br />
Ceil(-1.6) = -1<br />
</div><br />
<br />
{{ScriptFunctionH5|Round||Round(float)}}<br />
: Converts from single-precision, [http://en.wikipedia.org/wiki/Floating_point floating-point] value to int (round off to nearest integer).<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Round(1.2) = 1<br />
Round(1.6) = 2<br />
Round(-1.2) = -1<br />
Round(-1.6) = -2<br />
</div><br />
<br />
{{ScriptFunctionH5|Int||Int(float)}}<br />
: Converts from single-precision, [http://en.wikipedia.org/wiki/Floating_point floating-point] value to int (round towards zero).<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Int(1.2) = 1<br />
Int(1.6) = 1<br />
Int(-1.2) = -1<br />
Int(-1.6) = -1<br />
</div><br />
<br />
{{ScriptFunctionH5|Float||Float(int)}}<br />
: Converts int to single-precision, [http://en.wikipedia.org/wiki/Floating_point floating-point] value. Integer values that require more than 24-bits to be represented will have their lower 8-bits truncated yielding unexpected values.<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Float(4) = 4.0<br />
Float(4) / 3 = 1.333 (while 4 / 3 = 1 , due to integer division)<br />
Float(123456789) = 123456792.0 (error = -3, 0.000002%)<br />
Float(1234567890) = 1234567936.0 (error = -46, 0.000004%)<br />
</div><br />
<br />
{{ScriptFunctionH5|Fmod|v2.60|Fmod(float, float)}}<br />
: Returns the modulo of the argument. Output is float.<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Fmod(3.5, 0.5) = 0 (since 3.5 - 7*0.5 = 0)<br />
Fmod(3.5, 1.0) = 0.5 (since 3.5 - 3*1.0 = 0.5)<br />
</div><br />
<br />
{{ScriptFunctionH5|Pi||Pi()}}<br />
: Returns the value of the {{BoldColor|black|110|π}} constant (the ratio of a circle's circumference to its diameter).<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
d = Pi() # d == 3.141592653<br />
</div><br />
<br />
{{ScriptFunctionH5|Exp||Exp(float)}}<br />
: Returns the natural (base-e) exponent of the argument.<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Exp(1) = 2.7182818<br />
Exp(0) = 1.0<br />
</div><br />
<br />
{{ScriptFunctionH5|Log||Log(float)}}<br />
: Returns the natural (base-e) logarithm of the argument.<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Log(1) = 0.0<br />
Log(10) = 2.30259<br />
Log(Exp(1)) = 1.0<br />
</div><br />
<br />
{{ScriptFunctionH5|Log10|v2.60|Log10(float)}}<br />
: Returns the common logarithm of the argument.<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Log10(1.0) = 0<br />
Log10(10.0) = 1.0<br />
Log10(2.0) = 0.3010299957<br />
</div><br />
<br />
{{ScriptFunctionH5|Pow||Pow(float base, float power)}}<br />
: Returns {{FuncArg|base}} raised to a {{FuncArg|power}}.<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Pow(2, 3) = 8<br />
Pow(3, 2) = 9<br />
Pow(3.45, 1.75) = 8.7334<br />
</div><br />
<br />
{{ScriptFunctionH5|Sqrt||Sqrt(float)}}<br />
: Returns the square root of the argument.<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Sqrt(1) = 1.0<br />
Sqrt(2) = 1.4142<br />
</div><br />
<br />
{{ScriptFunctionH5|Abs||Abs(float or int)}}<br />
: Returns the absolute value of its argument (returns float for float, integer for integer).<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Abs(-3.8) = 3.8<br />
Abs(-4) = 4<br />
</div><br />
<br />
{{ScriptFunctionH5|Sign||Sign(float)}}<br />
: Returns the sign of the value passed as argument (1, 0 or -1).<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Sign(-3.5) = -1<br />
Sign(3.5) = 1<br />
Sign(0) = 0<br />
</div><br />
<br />
{{ScriptFunctionH5|Frac||Frac(float)}}<br />
: Returns the fractional portion of the value provided.<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Frac(3.7) = 0.7<br />
Frac(-1.8) = -0.8<br />
</div><br />
<br />
{{ScriptFunctionH5|Rand||Rand([int max] [, bool scale] [, bool seed])}}<br />
: Returns a random integer value. All parameters are optional. <br />
:;max<br />
::sets the maximum value+1 (default 32768) and can be set negative for negative results. It operates either in scaled or modulus mode (default {{FuncArg|scale}}=true only if [[#Abs|Abs]]({{FuncArg|max}}) > 32768, false otherwise). <br />
:;scale<br />
::When true, ''scales'' the internal random number generator value to the maximum value, while ''modulus mode'' ({{FuncArg|scale}}=false) uses the remainder from an integer divide of the random generator value by the maximum. Modulus mode is recommended for smaller maximums. <br />
:;seed<br />
::When true, seeds the random number generator with the current time. {{FuncArg|seed}} defaults to false and probably isn't necessary, although it's there just in case. <br />
: Typically, this function would be used with the [[#Select|'''Select''']] function for random clips. <br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Select(Rand(5), clip1, clip2, clip3, clip4, clip5)<br />
</div><br />
<br />
{{ScriptFunctionH5|Spline||Spline(float X, x1, y1, x2, y2, .... [, bool cubic])}}<br />
: Interpolates the Y value at point X using the control points {{FuncArg|x1}}/{{FuncArg|y1}}, ... There have to be at least 2 x/y-pairs. The interpolation can be {{FuncArg|cubic}} (the result is a spline) or linear (the result is a polygon). Default is cubic.<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Spline(5, 0, 0, 10, 10, 20, 0, false) = 5<br />
Spline(5, 0, 0, 10, 10, 20, 0, true) = 7<br />
</div><br />
<br />
===== Continued Numerator, Denominator =====<br />
{{ScriptFunctionCode|ContinuedNumerator|v2.60|ContinuedNumerator(float, int limit)}}<br />
{{ScriptFunctionCode|ContinuedNumerator|v2.60|ContinuedNumerator(int, int, int limit)}}<br />
{{ScriptFunctionCode|ContinuedDenominator|v2.60|ContinuedDenominator(float, int limit)}}<br />
{{ScriptFunctionCode|ContinuedDenominator|v2.60|ContinuedDenominator(int, int, int limit)}}<br />
: The rational pair ('''ContinuedNumerator''', '''ContinuedDenominator''') returned has the smallest possible denominator such that the absolute error is less than 1/{{FuncArg|limit}}. More information can be found on [http://en.wikipedia.org/wiki/Continued_fraction wikipedia].<br />
: If {{FuncArg|limit}} is not specified in the Float case the rational pair returned is to the limit of the single precision floating point value. Thus (float)((double)Num/(double)Den) == V.<br />
: In the Int case if {{FuncArg|limit}} is not specified then the normalized original values will be returned, i.e. reduced by the ''GCD'' (greatest common divisor).<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
<br />
ContinuedNumerator(PI(), limit=5000]) = 355<br />
ContinuedDenominator(PI(), limit=5000) = 113<br />
<br />
ContinuedNumerator(PI(), limit=50]) = 22<br />
ContinuedDenominator(PI(), limit=50) = 7<br />
<br />
ContinuedNumerator(355, 113, limit=50]) = 22<br />
ContinuedDenominator(355, 113, limit=50) = 7<br />
</div><br />
</div><br />
<br />
<br />
== Trigonometry functions ==<br />
<div style="max-width:62em" ><br />
: relationships involving lengths and angles of triangles. <br />
<br />
{{ScriptFunctionH5|Sin||Sin(float)}}<br />
: Returns the sine of the argument (assumes it is radians).<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Sin(Pi()/4) = 0.707<br />
Sin(Pi()/2) = 1.0<br />
</div><br />
<br />
{{ScriptFunctionH5|Cos||Cos(float)}}<br />
: Returns the cosine of the argument (assumes it is radians).<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Cos(Pi()/4) = 0.707<br />
Cos(Pi()/2) = 0.0<br />
</div><br />
<br />
{{ScriptFunctionH5|Tan|v2.60|Tan(float)}}<br />
: Returns the tangent of the argument (assumes it is radians).<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Tan(Pi/4) = 1.0<br />
Tan(Pi/2) = not defined<br />
</div><br />
: 32 bit IEEE floats do not have sufficient resolution to exactly represent<br />
: pi/2 so AviSynth returns a large positive number for the value slightly less<br />
: than pi/2 and a large negative value for the next possible value which is<br />
: slightly greater than pi/2.<br />
<br />
{{ScriptFunctionH5|Asin|v2.60|Asin(float)}}<br />
: Returns the inverse of the sine of the argument (output is radians).<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Asin(0.707) = 0.7852471634 (~ Pi/4)<br />
Asin(1.0) = 1.570796327 (~ Pi/2)<br />
</div><br />
<br />
{{ScriptFunctionH5|Acos|v2.60|Acos(float)}}<br />
: Returns the inverse of the cosine of the argument (output is in radians).<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Acos(0.707) = 0.7852471634 (~ Pi/4)<br />
Acos(0.0) = 1.570796327 (~ Pi/2)<br />
</div><br />
<br />
{{ScriptFunctionH5|Atan|v2.60|Atan(float)}}<br />
: Returns the inverse of the tangent of the argument (output is in radians).<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Atan(0.707) = 0.6154085176<br />
Atan(1.0) = 0.7853981634 (~ Pi/4)<br />
</div><br />
<br />
{{ScriptFunctionH5|Atan2|v2.60|Atan2(float, float)}}<br />
: Returns the angle between the positive x-axis of a plane and the point given by the coordinates (x, y) on it. Output is in radians. See [http://en.wikipedia.org/wiki/Atan2 wikipedia] for more information.<br />
: y is the first argument and x is the second argument.<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Atan2(1.0, 0) = 1.570796327 (~ Pi/2)<br />
Atan2(1.0, 1.0) = 0.7852471634 (~ Pi/4)<br />
Atan2(-1.0, -1.0) = -2.356194490 (~ -3Pi/4)<br />
</div><br />
<br />
{{ScriptFunctionH5|Sinh|v2.60|Sinh(float)}}<br />
: Returns the hyperbolic sine of the argument. See [http://en.wikipedia.org/wiki/Hyperbolic_function wikipedia] for more information.<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Sinh(2.0) = 3.626860408<br />
</div><br />
<br />
{{ScriptFunctionH5|Cosh|v2.60|Cosh(float)}}<br />
: Returns the hyperbolic cosine of the argument.<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Cosh(2.0) = 3.762195691<br />
</div><br />
<br />
{{ScriptFunctionH5|Tanh|v2.60|Tanh(float)}}<br />
: Returns the hyperbolic tangent of the argument.<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Tanh(2.0) = 0.9640275801<br />
</div><br />
</div><br />
<br />
<br />
== Bit functions ==<br />
<div style="max-width:62em" ><br />
: The functions are ''bitwise operators''. They manipulate individual bits within integer variables. This means that their arguments (being integers) are converted to binary numbers, the operation is performed on their bits, and the resulting binary number is converted back again.<br />
<br />
{{ScriptFunctionH5|BitAnd|v2.60|BitAnd(int, int)}}<br />
: Returns the bitwise AND (sets bit to 1 if both bits are 1 and sets bit to 0 otherwise).<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
BitAnd(5, 6) = 4 # since 5 = 101, 6 = 110, and 101&110 = 100<br />
</div><br />
<br />
{{ScriptFunctionH5|BitNot|v2.60|BitNot(int)}}<br />
: Returns the bit-inversion (sets bit to 1 if bit is 0 and vice-versa).<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
BitNOT(5) = -6 <br />
# since 5 = 101, <br />
# and ~101 = 1111 1111 1111 1111 1111 1111 1111 1010 = -6<br />
</div><br />
: Note: 1111 1111 1111 1111 1111 1111 1111 1010 <br />
::= (2^32-1)-2^0-2^2 = 2^32-(1+2^0+2^2) <br />
::= (signed) -(1+2^0+2^2) = -6<br />
<br />
{{ScriptFunctionH5|BitOr|v2.60|BitOr(int, int)}}<br />
: Returns the bitwise inclusive OR (sets bit to 1 if one of the bits (or both) is 1 and sets bit to 0 otherwise).<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
BitOr(5, 6) = 7 # since 5 = 101, 6 = 110, and 101|110 = 111<br />
BitOr(4, 2) = 6 # since 4 = 100, 2 = 010, and 100|010 = 110<br />
</div><br />
<br />
{{ScriptFunctionH5|BitXor|v2.60|BitXor(int, int)}}<br />
: Returns the bitwise exclusive OR (sets bit to 1 if exactly one of the bits is 1 and sets bit to 0 otherwise).<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
BitXor(5, 6) = 3 # since 5 = 101, 6 = 110, and 101^110 = 011<br />
BitXor(4, 2) = 6 # since 4 = 100, 2 = 010, and 100^010 = 110<br />
</div><br />
<br />
===== Bit shift left =====<br />
{{ScriptFunctionCode|BitLShift|v2.60|BitLShift(int, int)}}<br />
{{ScriptFunctionCode|BitShl|v2.60|BitShl(int, int)}}<br />
{{ScriptFunctionCode|BitSal|v2.60|BitSal(int, int)}}<br />
: Shift the bits of a number to the left.<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Shifts the bits of the number 5 two bits to the left:<br />
BitLShift(5, 2) = 20 (since 101 << 2 = 10100)<br />
</div><br />
<br />
===== Bit shift right =====<br />
{{ScriptFunctionCode|BitRShiftA|v2.60|BitRShiftA(int, int)}}<br />
{{ScriptFunctionCode|BitRShiftS|v2.60|BitRShiftS(int, int)}}<br />
{{ScriptFunctionCode|BitSar|v2.60|BitSar(int, int)}}<br />
: Shift the bits of an integer to the right. (Arithmetic, Sign bit fill, Right Shift)<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Shifts the bits of the number -42 one bit to the right, treating it as signed:<br />
BitRShiftA(-42, 1) = -21 <br />
# (since 1111 1111 1111 1111 1111 1111 1101 0110 >> 1 <br />
# = 1111 1111 1111 1111 1111 1111 1110 1011)<br />
</div><br />
<br />
===== Bit shift right, unsigned =====<br />
{{ScriptFunctionCode|BitRShiftL|v2.60|BitRShiftL(int, int)}}<br />
{{ScriptFunctionCode|BitRShiftU|v2.60|BitRShiftU(int, int)}}<br />
{{ScriptFunctionCode|BitShr|v2.60|BitShr(int, int)}}<br />
: Shift the bits of an unsigned integer to the right. (Logical, zero fill, Right Shift)<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Shifts the bits of the number -42 one bit to the right, treating it as unsigned:<br />
BitRShiftL(-42, 1) = 2147483627 <br />
# (since 1111 1111 1111 1111 1111 1111 1101 0110 >> 1 <br />
# = 0111 1111 1111 1111 1111 1111 1110 1011)<br />
</div><br />
: Note: -42 = -(1+2^0+2^3+2^5) = (unsigned) (2^32-1)-(2^0+2^3+2^5) = <br />
::1111 1111 1111 1111 1111 1111 1101 0110<br />
<br />
===== Bit rotate left =====<br />
{{ScriptFunctionCode|BitLRotate|v2.60|BitLRotate(int, int)}}<br />
{{ScriptFunctionCode|BitRol|v2.60|BitRol(int, int)}}<br />
: Rotates the bits of an integer to the left by the number of bits specified in the second operand. For each rotation specified, the high order bit that exits from the left of the operand returns at the right to become the new low order bit.<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Rotates the bits of the number -2147483642 one bit to the left:<br />
BitLRotate(-2147483642, 1) = 13 <br />
# (since 10000000000000000000000000000110 ROL 1<br />
# = 00000000000000000000000000001101)<br />
</div><br />
<br />
===== Bit rotate right =====<br />
{{ScriptFunctionCode|BitRRotate|v2.60|BitRRotateL(int, int)}}<br />
{{ScriptFunctionCode|BitRor|v2.60|BitRor(int, int)}}<br />
: Rotates the bits of an integer to the right by the number of bits specified in the second operand. For each rotation specified, the low order bit that exits from the right of the operand returns at the left to become the new high order bit.<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Rotates the bits of the number 13 one bit to the right:<br />
BitRRotate(13, 1) = -2147483642 <br />
# (since 00000000000000000000000000001101 ROR 1 <br />
# = 10000000000000000000000000000110)<br />
</div><br />
<br />
===== Bit test =====<br />
{{ScriptFunctionCode|BitTest|v2.60|BitTest(int, int)}}<br />
{{ScriptFunctionCode|BitTst|v2.60|BitTst(int, int)}}<br />
: Tests a single bit (that is, it returns true if its state is one, else it returns false). The second operand denotes the location of the bit which is specified as an offset from the low order end of the operand (starting at zero).<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Check the state of the fourth bit:<br />
BitTest(3, 4) = False<br />
BitTest(19, 4) = True<br />
<br />
Check the state of the sign bit:<br />
BitTest(-1, 31) = True<br />
BitTest(2147483647, 31) = False<br />
</div><br />
<br />
{{ScriptFunctionH5|BitSet|v2.60|BitSet(int, int)}}<br />
: Sets a single bit to one (so it sets its state to one). The second operand denotes the location of the bit which is specified as an offset from the low order end of the operand (starting at zero).<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Set the state of the fourth bit to one:<br />
BitSet(3, 4) = 19<br />
BitSet(19, 4) = 19<br />
<br />
Set the state of the sign bit to one:<br />
BitSet(-1, 31) = -1<br />
BitSet(2147483647, 31) = -1<br />
</div><br />
<br />
===== Bit clear =====<br />
{{ScriptFunctionCode|BitClear|v2.60|BitClear(int, int)}}<br />
{{ScriptFunctionCode|BitClr|v2.60|BitClr(int, int)}}<br />
: Sets a single bit to zero (so it sets its state to zero). The second operand denotes the location of the bit which is specified as an offset from the low order end of the operand (starting at zero).<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Clear the bits of the number 5<br />
BitClear(5, 0) = 4 (first bit is set to zero)<br />
BitClear(5, 1) = 5 (second bit is already zero)<br />
BitClear(5, 2) = 1 (third bit is set to zero)<br />
BitClear(5, 3) = 5 (fourth bit is already zero)<br />
<br />
Clear the state of the sign bit:<br />
BitClear(-1, 31) = 2147483647<br />
</div><br />
<br />
===== Bit change =====<br />
{{ScriptFunctionCode|BitChange|v2.60|BitChange(int, int)}}<br />
{{ScriptFunctionCode|BitChg|v2.60|BitChg(int, int)}}<br />
: Sets a single bit to its complement (so it changes the state of a single bit; 1 becomes 0 and vice versa). The second operand denotes the location of the bit which is specified as an offset from the low order end of the operand (starting at zero). The sign bit is bit 31.<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Change the state of the a bit of the number 5:<br />
BitChange(5, 0) = 4 (first bit is set to zero)<br />
BitChange(5, 1) = 7 (second bit is set to one)<br />
BitChange(5, 2) = 1 (third bit is set to zero)<br />
BitChange(5, 3) = 13 (fourth bit is set to one)<br />
<br />
Change the state of the sign bit:<br />
BitChange(-1, 31) = 2147483647<br />
</div><br />
</div><br />
<br />
<br />
== Runtime functions ==<br />
<div style="max-width:62em" ><br />
: These are internal functions which are evaluated at every frame. They can be used inside the scripts passed to runtime filters ([[ConditionalFilter]], [[ScriptClip]], [[FrameEvaluate]]) to return information for a frame.<br />
<br />
===== Average ===== <br />
{{ScriptFunctionCode|AverageLuma||AverageLuma(clip [, int offset &#61; 0])}}<br />
{{ScriptFunctionCode|AverageChromaU||AverageChromaU(clip [, int offset &#61; 0])}}<br />
{{ScriptFunctionCode|AverageChromaV||AverageChromaV(clip [, int offset &#61; 0])}}<br />
{{ScriptFunctionCode|AverageB||AverageB(clip [, int offset &#61; 0])}} {{AvsPluscon}}<br />
{{ScriptFunctionCode|AverageG||AverageG(clip [, int offset &#61; 0])}} {{AvsPluscon}}<br />
{{ScriptFunctionCode|AverageR||AverageR(clip [, int offset &#61; 0])}} {{AvsPluscon}}<br />
: This group of functions return a float value with the average pixel value of a plane (Luma, U-chroma and V-chroma, respectively). They require an [[ISSE]] capable cpu. In v2.61 an {{FuncArg|offset}} argument is added which enables you to access other frames than the current one.<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
ScriptClip(Last, """<br />
threshold = 55<br />
luma = AverageLuma ## gives the average luma of the current frame<br />
#luma = AverageLuma(1) ## gives the average luma of the next frame<br />
luma < threshold <br />
\ ? Levels(0, 1.0+0.5*(threshold-luma)/threshold, 255, 10, 255) <br />
\ : last<br />
Subtitle("luma=" + String(luma), align=2)<br />
""")<br />
</div><br />
<br />
===== Difference =====<br />
{{ScriptFunctionCode|LumaDifference||LumaDifference(clip1, clip2)}}<br />
{{ScriptFunctionCode|ChromaUDifference||ChromaUDifference(clip1, clip2)}}<br />
{{ScriptFunctionCode|ChromaVDifference||ChromaVDifference(clip1, clip2)}}<br />
{{ScriptFunctionCode|RGBDifference||RGBDifference(clip1, clip2)}}<br />
{{ScriptFunctionCode|BDifference||BDifference(clip1, clip2)}} {{AvsPluscon}}<br />
{{ScriptFunctionCode|GDifference||GDifference(clip1, clip2)}} {{AvsPluscon}}<br />
{{ScriptFunctionCode|RDifference||RDifference(clip1, clip2)}} {{AvsPluscon}}<br />
: This group of functions return a float value between 0 and 255 of the absolute difference between two planes from two different clips &ndash; either the combined RGB difference or the Luma, U-chroma or V-chroma differences, respectively. They require an [[ISSE]] capable cpu.<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
ovl = [[Overlay]](last, mov_star, x=some_xvalue, y=some_yvalue, mask=mov_mask)<br />
ldif = LumaDifference(ovl) # implicit last for clip1<br />
udif = ChromaUDifference([[Tweak]](hue=24), ovl)<br />
...<br />
</div><br />
<br />
===== Difference from previous =====<br />
{{ScriptFunctionCode|YDifferenceFromPrevious||YDifferenceFromPrevious(clip)}}<br />
{{ScriptFunctionCode|UDifferenceFromPrevious||UDifferenceFromPrevious(clip)}}<br />
{{ScriptFunctionCode|VDifferenceFromPrevious||VDifferenceFromPrevious(clip)}}<br />
{{ScriptFunctionCode|RGBDifferenceFromPrevious||RGBDifferenceFromPrevious(clip)}}<br />
{{ScriptFunctionCode|BDifferenceFromPrevious||BDifferenceFromPrevious(clip)}} {{AvsPluscon}}<br />
{{ScriptFunctionCode|GDifferenceFromPrevious||GDifferenceFromPrevious(clip)}} {{AvsPluscon}}<br />
{{ScriptFunctionCode|RDifferenceFromPrevious||RDifferenceFromPrevious(clip)}} {{AvsPluscon}}<br />
: This group of functions return the absolute difference of pixel value between the current and previous frame of {{FuncArg|clip}} &ndash; either the combined RGB difference or the Luma, U-chroma or V-chroma differences, respectively.<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
scene_change = (YDifferenceFromPrevious) > threshold)<br />
scene_change ? some_filter(...) : another_filter(...)<br />
</div><br />
<br />
===== Difference to next =====<br />
{{ScriptFunctionCode|YDifferenceToNext||YDifferenceToNext(clip [, int offset &#61; 1])}}<br />
{{ScriptFunctionCode|UDifferenceToNext||UDifferenceToNext(clip [, int offset &#61; 1])}}<br />
{{ScriptFunctionCode|VDifferenceToNext||VDifferenceToNext(clip [, int offset &#61; 1])}}<br />
{{ScriptFunctionCode|RGBDifferenceToNext||RGBDifferenceToNext(clip [, int offset &#61; 1])}}<br />
{{ScriptFunctionCode|BDifferenceToNext||BDifferenceToNext(clip [, int offset &#61; 1])}} {{AvsPluscon}}<br />
{{ScriptFunctionCode|GDifferenceToNext||GDifferenceToNext(clip [, int offset &#61; 1])}} {{AvsPluscon}}<br />
{{ScriptFunctionCode|RDifferenceToNext||RDifferenceToNext(clip [, int offset &#61; 1])}} {{AvsPluscon}}<br />
: This group of functions return the absolute difference of pixel value between the current and next frame of {{FuncArg|clip}} &ndash; either the combined RGB difference or the Luma, U-chroma or V-chroma differences, respectively. In v2.61 an {{FuncArg|offset}} argument is added, which enables you to access the difference between the RGB, luma or chroma plane of the current frame and of ''any'' other frame. Note that for example clip.'''RGBDifferenceToNext'''(-1) = clip.'''RGBDifferenceToPrevious''', and clip.'''RGBDifferenceToNext'''(0) = 0.<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
# both th1, th2 are positive thresholds; th1 is larger enough than th2<br />
scene_change = (YDifferenceFromPrevious > th1) && (YDifferenceToNext < th2)<br />
scene_change ? some_filter(...) : another_filter(...)<br />
</div><br />
<br />
===== Color plane median, min, max, range =====<br />
{{ScriptFunctionCode|YPlaneMedian||YPlaneMedian(clip [, int offset &#61; 0])}}<br />
{{ScriptFunctionCode|UPlaneMedian||UPlaneMedian(clip [, int offset &#61; 0])}}<br />
{{ScriptFunctionCode|VPlaneMedian||VPlaneMedian(clip [, int offset &#61; 0])}}<br />
{{ScriptFunctionCode|BPlaneMedian||BPlaneMedian(clip [, int offset &#61; 0])}} {{AvsPluscon}}<br />
{{ScriptFunctionCode|GPlaneMedian||GPlaneMedian(clip [, int offset &#61; 0])}} {{AvsPluscon}}<br />
{{ScriptFunctionCode|RPlaneMedian||RPlaneMedian(clip [, int offset &#61; 0])}} {{AvsPluscon}}<br />
<br />
{{ScriptFunctionCode|YPlaneMin||YPlaneMin(clip [, float threshold &#61; 0, int offset &#61; 0])}}<br />
{{ScriptFunctionCode|UPlaneMin||UPlaneMin(clip [, float threshold &#61; 0, int offset &#61; 0])}}<br />
{{ScriptFunctionCode|VPlaneMin||VPlaneMin(clip [, float threshold &#61; 0, int offset &#61; 0])}}<br />
{{ScriptFunctionCode|BPlaneMin||BPlaneMin(clip [, float threshold &#61; 0, int offset &#61; 0])}} {{AvsPluscon}}<br />
{{ScriptFunctionCode|GPlaneMin||GPlaneMin(clip [, float threshold &#61; 0, int offset &#61; 0])}} {{AvsPluscon}}{{ScriptFunctionCode|RPlaneMin||RPlaneMin(clip [, float threshold &#61; 0, int offset &#61; 0])}} {{AvsPluscon}}<br />
<br />
{{ScriptFunctionCode|YPlaneMax||YPlaneMax(clip [, float threshold &#61; 0, int offset &#61; 0])}}<br />
{{ScriptFunctionCode|UPlaneMax||UPlaneMax(clip [, float threshold &#61; 0, int offset &#61; 0])}}<br />
{{ScriptFunctionCode|VPlaneMax||VPlaneMax(clip [, float threshold &#61; 0, int offset &#61; 0])}}<br />
{{ScriptFunctionCode|BPlaneMax||BPlaneMax(clip [, float threshold &#61; 0, int offset &#61; 0])}} {{AvsPluscon}}<br />
{{ScriptFunctionCode|GPlaneMax||GPlaneMax(clip [, float threshold &#61; 0, int offset &#61; 0])}} {{AvsPluscon}}{{ScriptFunctionCode|RPlaneMax||RPlaneMax(clip [, float threshold &#61; 0, int offset &#61; 0])}} {{AvsPluscon}}<br />
<br />
{{ScriptFunctionCode|YPlaneMinMaxDifference||YPlaneMinMaxDifference(clip [, float threshold, int offset &#61; 0])}}<br />
{{ScriptFunctionCode|UPlaneMinMaxDifference||UPlaneMinMaxDifference(clip [, float threshold, int offset &#61; 0])}}<br />
{{ScriptFunctionCode|VPlaneMinMaxDifference||VPlaneMinMaxDifference(clip [, float threshold, int offset &#61; 0])}}<br />
{{ScriptFunctionCode|BPlaneMinMaxDifference||BPlaneMinMaxDifference(clip [, float threshold, int offset &#61; 0])}} {{AvsPluscon}}<br />
{{ScriptFunctionCode|GPlaneMinMaxDifference||GPlaneMinMaxDifference(clip [, float threshold, int offset &#61; 0])}} {{AvsPluscon}}<br />
{{ScriptFunctionCode|RPlaneMinMaxDifference||RPlaneMinMaxDifference(clip [, float threshold, int offset &#61; 0])}} {{AvsPluscon}}<br />
<br />
: This group of functions return statistics about the distribution of pixel values on a plane (Luma, U-chroma and V-chroma, respectively). The statistics are, in order of presentation: maximum, minimum, median and range (maximum - minimum difference). <br />
: {{FuncArg|threshold}} is a percentage, stating how many percent of the pixels are allowed above or below minimum. The threshold is optional and defaults to 0. In v2.61 an {{FuncArg|offset}} argument is added, which enables you to access the statistics of other frames than the current one.<br />
<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
# median and average are close only on even distributions; <br />
# this can be a useful diagnostic<br />
have_intense_brights = YPlaneMedian() - AverageLuma() < threshold<br />
...<br />
# a simple per-frame normalizer to [16..235], CCIR, range<br />
[[Levels]](YPlaneMin(), 1.0, YPlaneMax(), 16, 235)<br />
</div><br />
</div><br />
<br />
<br />
== Script functions ==<br />
<div style="max-width:62em" ><br />
: These provide AviSynth script information.<br />
<br />
{{ScriptFunctionH5|ScriptName|v2.60|ScriptName()}}<br />
: Returns the path and filename of the loaded script as a string.<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
name = ScriptName() # name = "F:\ProjectXYZ\video.avs"<br />
</div><br />
<br />
{{ScriptFunctionH5|ScriptFile|v2.60|ScriptFile()}}<br />
: Returns the filename of the loaded script as a string.<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
file = ScriptFile() # file = "video.avs"<br />
</div><br />
<br />
{{ScriptFunctionH5|ScriptDir|v2.60|ScriptDir()}}<br />
: Returns the path of the loaded script as a string.<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
folder = ScriptDir() # folder = "F:\ProjectXYZ"<br />
</div><br />
</div><br />
<br />
<br />
== String functions ==<br />
<div style="max-width:62em" ><br />
: These provide common operations on string variables.<br />
<br />
{{ScriptFunctionH5|LCase||LCase(string)}}<br />
: Returns lower case of {{FuncArg|string}}.<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
LCase("AviSynth") = "avisynth"<br />
</div><br />
<br />
{{ScriptFunctionH5|UCase||UCase(string)}}<br />
: Returns upper case of {{FuncArg|string}}.<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
UCase("AviSynth") = "AVISYNTH"<br />
</div><br />
<br />
{{ScriptFunctionH5|StrLen||StrLen(string)}}<br />
: Returns length of {{FuncArg|string}}.<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
StrLen("AviSynth") = 8<br />
</div><br />
<br />
{{ScriptFunctionH5|RevStr||RevStr(string)}}<br />
: Returns {{FuncArg|string}} backwards.<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
RevStr("AviSynth") = "htnySivA"<br />
</div><br />
<br />
{{ScriptFunctionH5|LeftStr||LeftStr(string, int)}}<br />
: Returns first {{FuncArg|int}} count of characters.<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
LeftStr("AviSynth", 3) = "Avi"<br />
</div><br />
<br />
{{ScriptFunctionH5|RightStr||RightStr(string, int)}}<br />
: Returns last {{FuncArg|int}} count of characters.<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
RightStr("AviSynth", 5) = "Synth"<br />
</div><br />
<br />
{{ScriptFunctionH5|MidStr||MidStr(string, int pos [, int length])}}<br />
: Returns substring starting at {{FuncArg|pos}} for optional {{FuncArg|length}} or to end. {{FuncArg|pos}}=1 specifies start.<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
MidStr("AviSynth", 3, 2) = "iS"<br />
</div><br />
<br />
{{ScriptFunctionH5|FindStr||FindStr(string, substring)}}<br />
: Returns position of {{FuncArg|string}} within {{FuncArg|string}} (note this function is case-sensitive). Returns 0 if {{FuncArg|string}} is not found.<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Findstr("AviSynth", "Syn") = 4<br />
</div><br />
<br />
{{ScriptFunctionH5|FillStr|v2.60|FillStr(int [, string])}}<br />
: Fills a string. When {{FuncArg|int}}>1 it concatenates the {{FuncArg|string}} {{FuncArg|int}} times. {{FuncArg|string}} is "<tt> </tt>" (space) by default.<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
FillStr(1, "AviSynth") = "AviSynth"<br />
FillStr(2, "AviSynth") = "AviSynthAviSynth"<br />
</div><br />
<br />
{{ScriptFunctionH5|StrCmp|v2.60|StrCmp(string, string)}}<br />
: Compares two character strings. The comparison is case-sensitive. If the first string is less than the second string, the return value is negative. If it's greater, the return value is positive. If they are equal, the return value is zero. (The actual value seems to be language dependent so it can't be relied upon.)<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
StrCmp("AviSynth", "AviSynth") = 0 # strings are equal.<br />
StrCmp("AviSynth", "Avisynth") != 0 # strings are not equal.<br />
</div><br />
<br />
{{ScriptFunctionH5|StrCmpi|v2.60|StrCmpi(string, string)}}<br />
: Compares two character strings. The comparison is not case-sensitive. If the first string is less than the second string, the return value is negative. If it's greater, the return value is positive. If they are equal, the return value is zero. (The actual value seems to be language dependent so it can't be relied upon.)<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
StrCmpi("AviSynth", "AviSynth") = 0 # strings are equal.<br />
StrCmpi("AviSynth", "Avisynth") = 0 # strings are equal.<br />
StrCmpi("abcz", "abcdefg") != 0 <br />
# returns the difference betweeen "z" and "d" (which is positive).<br />
</div><br />
<br />
{{ScriptFunctionH5|Chr||Chr(int)}}<br />
: Returns the ASCII character. <br />
: Note that characters above the ASCII character set (ie above 127) are code page dependent and may render different (visual) results in different systems. This has an importance only for user-supplied localised text messages.<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Chr(34) returns the quote character<br />
Chr(9) returns the tab character<br />
</div><br />
<br />
{{ScriptFunctionH5|Ord|v2.60|Ord(string)}}<br />
: Gives the ordinal number (character code) of the first character of {{FuncArg|string}} (works like php [http://php.net/manual/en/function.ord.php ord] or Basic [http://msdn.microsoft.com/en-us/library/xfw01fx4%28v=vs.84%29.aspx Asc])<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
Ord("a") = 97<br />
Ord("AviSynth") = Ord("A") = 65<br />
Ord("§") = 167<br />
</div><br />
<br />
{{ScriptFunctionH5|Time||Time(string)}}<br />
: Returns a string with the current system time formatted as defined by {{FuncArg|string}}.<br />
<br />
: The string may contain any of the codes for output formatting presented below:<br />
:{| class="wikitable"<br />
|-<br />
! style="width:9em" | Code<br />
! style="width:38em" | Description<br />
|-<br />
|%a<br />
%A <br />
| Abbreviated weekday name<br />
Full weekday name<br />
|-<br />
|%b<br />
%B <br />
| Abbreviated month name<br />
Full month name<br />
|-<br />
|%c <br />
| Date and time representation appropriate for locale<br />
|-<br />
|%d <br />
| Day of month as decimal number (01 - 31)<br />
|-<br />
|%H<br />
%I <br />
| Hour in 24-hour format (00 - 23)<br />
Hour in 12-hour format (01 - 12)<br />
|-<br />
|%j <br />
| Day of year as decimal number (001 - 366)<br />
|-<br />
|%m <br />
| Month as decimal number (01 - 12)<br />
|-<br />
|%M <br />
| Minute as decimal number (00 - 59)<br />
|-<br />
|%p <br />
| Current locale's A.M./P.M. indicator for 12-hour clock<br />
|-<br />
|%S <br />
| Second as decimal number (00 - 59)<br />
|-<br />
|%U <br />
| Week of year as decimal number, with Sunday as first day of week (00 - 53)<br />
|-<br />
|%w <br />
| Weekday as decimal number (0 - 6; Sunday is 0)<br />
|-<br />
|%W <br />
| Week of year as decimal number, with Monday as first day of week (00 - 53)<br />
|-<br />
|%x <br />
| Date representation for current locale<br />
|-<br />
|%X <br />
| Time representation for current locale<br />
|-<br />
|%y<br />
%Y <br />
| Year without century, as decimal number (00 - 99)<br />
Year ''with'' century, as decimal number<br />
|-<br />
|%z, %Z <br />
| Time-zone name or abbreviation; no characters if time zone is unknown<br />
|-<br />
|%% <br />
| Percent sign <br />
|}<br />
<br />
: The '#' flag may prefix any formatting code. In that case, the meaning of the format code is changed as follows:<br />
:{| class="wikitable"<br />
|-<br />
! style="width:9em" |Code with '#' flag<br />
! style="width:38em" |Change in meaning<br />
|-<br />
|%#'''a''', %#'''A''', %#'''b''', <br />
%#'''B''', %#'''p''', %#'''X''', <br />
%#'''z''', %#'''Z''', %#'''%'''<br />
| No change; flag is ignored. <br />
|-<br />
|%#'''c''' <br />
| Long date and time representation, appropriate for current locale. <br />
For example, ''"Tuesday, March 14, 1995, 12:41:29"'' <br />
|-<br />
|%#'''x''' <br />
| Long date representation, appropriate to current locale. <br />
For example, ''"Tuesday, March 14, 1995"''<br />
|-<br />
|%#'''d''', %#'''H''', %#'''I''', <br />
%#'''j''', %#'''m''', %#'''M''', <br />
%#'''S''', %#'''U''', %#'''w''', <br />
%#'''W''', %#'''y''', %#'''Y''' <br />
| Remove leading zeros (if any).<br />
|}<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
v = Time("%Y-%m-%d") # "2010-03-01"<br />
v = Time("%d-%b-%Y") # "01-Mar-2010"<br />
v = Time("%#d/%#m/%y") # "1/3/10"<br />
v = Time("%I:%M:%S %p, %z") # "08:04:42 PM, GMT Standard Time"<br />
v = Time("%H:%M:%S %z") # "20:04:42 GMT Standard Time"<br />
</div><br />
<br />
== Version functions ==<br />
<div style="max-width:62em" ><br />
: These provide AviSynth version information.<br />
<br />
{{ScriptFunctionH5|VersionNumber||VersionNumber()}}<br />
: Returns AviSynth version number as a float.<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
v = VersionNumber() # 2.60<br />
</div><br />
<br />
{{ScriptFunctionH5|VersionString||VersionString()}}<br />
: Returns AviSynth version info as a string (first line used in [[Version]]() command).<br />
''Examples:''<br />
<div {{BoxWidthIndent|56|2}} ><br />
v = VersionString() # "AviSynth 2.60, build:Mar 31 2015 [16:38:54]"<br />
</div><br />
</div><br />
<br />
<br />
----<br />
Back to [[AviSynth Syntax]].<br />
</div><br />
<br />
[[Category:Internal_functions]]<br />
[[Category:AviSynth_Syntax]]<br />
[[Category:Scripting_Basics]]</div>Adminhttp://avisynth.nl/index.php/Internal_filtersInternal filters2017-07-10T14:24:12Z<p>Admin: /* Audio processing filters */</p>
<hr />
<div><div style="max-width:76em; min-width:48em"><br />
The available (internal) filters are listed here and divided into categories. A short description is added, including the supported [[Color_spaces|color formats]] (and sample types for the audio filters). There are some functions which combine two or more clips in different ways. How the video content is calculated is described for each function, but [[filters_with_multiple_input_clips|here is a summary which explains which properties that the resulting clip will have]].<br />
<br />
An alphabetical listing of the internal filters can be found [[:Category:Internal_filters|here]].<br />
<br />
=== Source filters ===<br />
<br />
These filters can read media files and return an AviSynth clip. See [[#Debug_filters|debug filters]] for non-file source filters.<br />
<br />
{| style="height:100px; width:95%" border="1" cellpadding="4" class="wikitable"<br />
!width=25%| Filter<br />
!width=50%| Description<br />
!width=15%| Color format<br />
|- <br />
| [[AviSource]] / [[AviFileSource]] / [[OpenDMLSource]]<br />
| Opens an AVI file.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[DirectShowSource]]<br />
| Opens a filename using [[DirectShow]].<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[ImageReader]] / [[ImageSource]] / [[ImageSourceAnim]]<br />
| Reads in still or animated images. See [[#Export_filters|ImageWriter]].<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[Import]]<br />
| Imports an AviSynth script into the current script.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[SegmentedAviSource]] / [[SegmentedDirectShowSource]]<br />
| Loads up to 100 avi files per argument.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[WavSource]]<br />
| Opens a WAV file or the audio of an AVI file.<br />
| [[#Color_formats|All]]<br />
|}<br />
<br />
=== Color conversion and adjustment filters ===<br />
<br />
These filters can be used to change the color format or adjust the colors of a clip.<br />
<br />
{| style="height:100px; width:95%" border="1" cellpadding="4" class="wikitable"<br />
!width=25%| Filter<br />
!width=50%| Description<br />
!width=15%| Color format<br />
|- <br />
| [[ColorYUV]]<br />
| Adjusts colors and luma independently.<br />
| [[#Color_formats|YUV]]<br />
|-<br />
| [[ConvertBackToYUY2]]<br />
| Converts a RGB clip back to YUY2.<br />
| [[#Color_formats|RGB]]<br />
|-<br />
| [[ConvertToRGB]]<br />
| Converts to RGB32 unless clip is RGB24.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[ConvertToRGB24]] / [[ConvertToRGB32]] / [[ConvertToYUY2]] / [[ConvertToY8]] / [[ConvertToYV411]] / [[ConvertToYV12]] / [[ConvertToYV16]] / [[ConvertToYV24]]<br />
| Converts to RGB24 / RGB32 / YUY2 / Y8 / YV411 / YV12 / YV16 (planar version of YUY2) / YV24 (full YUV).<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[FixLuminance]]<br />
| Correct shifting vertical luma offset.<br />
| YUY2<br />
|-<br />
| [[Greyscale]]/[[Grayscale]]<br />
| Converts a video to greyscale (no color)<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[Invert]]<br />
| Inverts selected color channels of a video.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[Levels]]<br />
| Scales and clamps the black and white levels, and adjusts the gamma.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[Limiter]]<br />
| Clips levels to within CCIR-601 range, and optionally highlights pixels outside that range.<br />
| [[#Color_formats|YUV]]<br />
|-<br />
| [[MergeARGB]] / [[MergeRGB]]<br />
| Select and combine a color channel from each of the input video clips.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[MergeChroma]] / [[MergeLuma]]<br />
| Merge (blend) chroma or luma from one video clip into another. There is an optional weighting, so a percentage between the two clips can be specified.<br />
| [[#Color_formats|YUV]]<br />
|-<br />
| [[RGBAdjust]]<br />
| Adjusts each color channel separately.<br />
| [[#Color_formats|RGB]]<br />
|-<br />
| [[ShowAlpha]] / [[ShowRed]] / [[ShowGreen]] / [[ShowBlue]]<br />
| Shows the selected channel of an (A)RGB clip.<br />
| [[#Color_formats|RGB]]<br />
|-<br />
| [[SwapUV]]<br />
| Swaps chroma channels.<br />
| [[#Color_formats|YUV]]<br />
|-<br />
| [[Tweak]]<br />
| Adjusts the hue, saturation, brightness, and contrast.<br />
| [[#Color_formats|YUV]]<br />
|-<br />
| [[UToY]] / [[UToY8]] / [[VToY]] / [[VToY8]]<br />
| Copies U or V chroma plane to the Y luma plane.<br />
| [[#Color_formats|YUV]], except [[Y8]]<br />
|-<br />
| [[YToUV]]<br />
| Puts the luma channels of two clips as U and V channels. Luma is now 50% grey.<br />
| [[#Color_formats|YUV]]<br />
|}<br />
<br />
=== Overlay and Mask filters ===<br />
<br />
These filters can be used to layer clips with or without using masks and to create masks.<br />
<br />
{| style="height:100px; width:95%" border="1" cellpadding="4" class="wikitable"<br />
!width=25%| Filter<br />
!width=50%| Description<br />
!width=15%| Color format<br />
|-<br />
| [[ColorKeyMask]]<br />
| Sets the alpha-channel (similar as Mask does) but generates it by comparing the color.<br />
| RGB32<br />
|-<br />
| [[Layer]]<br />
| Puts one clip on top of another using different layer (blend) modes and variable opacity. Supports alpha-channel transparency.<br />
| RGB32, YUY2<br />
|-<br />
| [[Mask]]<br />
| Applies an alpha-mask to a clip.<br />
| RGB32<br />
|-<br />
| [[MaskHS]]<br />
| This filter returns a mask (as Y8) of clip using a given hue and saturation range.<br />
| [[#Color_formats|YUV]]<br />
|-<br />
| [[Merge]]<br />
| Merge (blend) one video clip into another. There is an optional weighting, so a percentage between the two clips can be specified.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[Overlay]]<br />
| Puts one clip on top of another with optional XY displacement of the overlaying image, using different overlay (blend) modes and variable opacity. Uses a separate ''mask'' clip for transparency information.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[ResetMask]]<br />
| Applies an "all-opaque" alpha-mask to clip.<br />
| RGB32<br />
|-<br />
| [[Subtract]]<br />
| Shows the difference between the corresponding pixels of two clips.<br />
| [[#Color_formats|All]]<br />
|}<br />
<br />
=== Geometric deformation filters ===<br />
<br />
These filters can be used to change image size, process borders or make other deformations of a clip.<br />
<br />
{| style="height:100px; width:95%" border="1" cellpadding="4" class="wikitable"<br />
!width=25%| Filter<br />
!width=50%| Description<br />
!width=15%| Color format<br />
|- <br />
| [[AddBorders]]<br />
| Adds black or colored borders around the image.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[Crop]]<br />
| Crops excess pixels from each frame.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[CropBottom]]<br />
| Crops excess pixels from the bottom of each frame.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[FlipHorizontal]] / [[FlipVertical]]<br />
| Flips the video from left to right/upside-down.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[Letterbox]]<br />
| Blackens out (or colors out) the top and bottom (and optionally left and right) of each frame. <br />
| [[#Color_formats|All]]<br />
|-<br />
| [[HorizontalReduceBy2]] / [[VerticalReduceBy2]] / [[ReduceBy2]]<br />
| Reduces the size of each frame by half horizontally, vertically or in both directions.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[BicubicResize]] / [[BilinearResize]] / [[BlackmanResize]] / [[GaussResize]] / [[LanczosResize]] / [[Lanczos4Resize]] / [[PointResize]] / [[SincResize]] / [[Spline16Resize]] / [[Spline36Resize]] / [[Spline64Resize]]<br />
| Rescale the input video frames to an arbitrary new resolution, using different sampling algorithms.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[SkewRows]]<br />
| Skews (or deskews) the rows of a clip.<br />
| RGB24, RGB32, YUY2, Y8<br />
|-<br />
| [[TurnLeft]] / [[TurnRight]] / [[Turn180]]<br />
| Rotates the clip 90 degrees counter-clockwise / 90 degrees clockwise.<br />
| [[#Color_formats|All]]<br />
|}<br />
<br />
=== Pixel restoration filters ===<br />
<br />
These filters can be used for image detail (pixel) restoration (like denoising, sharpening) of a clip.<br />
<br />
{| style="height:100px; width:95%" border="1" cellpadding="4" class="wikitable"<br />
!width=25%| Filter<br />
!width=50%| Description<br />
!width=15%| Color format<br />
|- <br />
| [[Blur]] / [[Sharpen]]<br />
| Simple 3x3-kernel blurring/sharpening filter.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[GeneralConvolution]]<br />
| General 3x3 or 5x5 convolution matrix.<br />
| RGB32<br />
|-<br />
| [[SpatialSoften]] / [[TemporalSoften]]<br />
| Removes noise from a video clip by selectively blending pixels spatially/temporally.<br />
| YUY2 (SpatialSoften), [[#Color_formats|YUV Planar]]<br />
|-<br />
| [[FixBrokenChromaUpsampling]]<br />
| The free Canopus DV Codec v1.00 upsamples the chroma channels incorrectly (although newer non-free versions appear to work fine). This filter compensates for it.<br />
| YUY2<br />
|}<br />
<br />
=== Timeline editing filters ===<br />
<br />
These filters can be used to arrange frames in time (clip cutting, splicing and other editing).<br />
<br />
{| style="height:100px; width:95%" border="1" cellpadding="4" class="wikitable"<br />
!width=25%| Filter<br />
!width=50%| Description<br />
!width=15%| Color format<br />
|-<br />
| [[AlignedSplice]] / [[UnalignedSplice]]<br />
| Joins two or more video clips end to end.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[AssumeFPS]] / [[AssumeScaledFPS]] / [[ChangeFPS]] / [[ConvertFPS]]<br />
| Changes framerate and/or video speed in different ways.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[DeleteFrame]]<br />
| Deletes a single frame, given as an argument.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[Dissolve]]<br />
| Like [[AlignedSplice]], except that the clips are combined with some overlap.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[DuplicateFrame]]<br />
| Duplicates a single frame given as an argument.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[FadeIn0]] / [[FadeIn]] / [[FadeIn2]] / [[FadeOut0]] / [[FadeOut]] / [[FadeOut2]] / [[FadeIO0]] / [[FadeIO]] / [[FadeIO2]]<br />
| Causes the video stream to fade linearly to black at the start or end.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[FreezeFrame]]<br />
| Replaces all the frames between ''first-frame'' and ''last-frame'' with a selected frame.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[Interleave]]<br />
| Interleaves frames from several clips on a frame-by-frame basis.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[Loop]]<br />
| Loops the segment from ''start_frame'' to ''end_frame'' a given number of times.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[Reverse]]<br />
| Makes a clip play in reverse.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[SelectEven]] / [[SelectOdd]]<br />
| Makes an output video stream using only the even- or odd-numbered frames.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[SelectEvery]]<br />
| Selects frames with a fixed period; a generalization of [[SelectEven]] and [[SelectOdd]].<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[SelectRangeEvery]]<br />
| Selects a range of frames with a fixed period.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[Trim]]<br />
| Trims a video clip so that it includes only the frames ''first_frame'' through ''last_frame''.<br />
| [[#Color_formats|All]]<br />
|}<br />
<br />
=== Interlace filters ===<br />
<br />
These filters can be used for creating and processing field-based material (which is frame-based material separated into fields). AviSynth is capable of dealing with both progressive and interlaced material. The main problem is, that it often doesn't know what it receives from source filters. This is the reason that the field-based flag exists and can be used when dealing with interlaced material. More information about field-based video can be found [[Interlaced_fieldbased|here]].<br />
<br />
{| style="height:100px; width:95%" border="1" cellpadding="4" class="wikitable"<br />
!width=25%| Filter<br />
!width=50%| Description<br />
!width=15%| Color format<br />
|-<br />
| [[AssumeFrameBased]] / [[AssumeFieldBased]]<br />
| Forces frame-based or field-based material.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[AssumeBFF]] / [[AssumeTFF]]<br />
| Forces field order.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[Bob]]<br />
| Takes a clip and [[Wikipedia:Deinterlacing#Field_extension_deinterlacing|bob-deinterlaces]] it.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[ComplementParity]]<br />
| Changes top fields to bottom fields and vice-versa.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[DoubleWeave]]<br />
| Operates like [[Weave]], except that it produces double the number of frames by combining both the odd and even pairs of fields.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[PeculiarBlend]]<br />
| Blends each frame with the following frame in a peculiar way.<br />
| YUY2<br />
|-<br />
| [[Pulldown]]<br />
| Selects two out of every five frames of the source video.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[SeparateColumns]] / [[SeparateRows]]<br />
| Separates the columns or rows of each frame into new frames.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[SeparateFields]]<br />
| Splits each frame into its component top and bottom fields.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[SwapFields]]<br />
| Swaps the two fields in an interlaced frame.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[Weave]]<br />
| Combines fields together to produce interlaced frames.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[WeaveColumns]] / [[WeaveRows]]<br />
| Takes a clip and weaves sets of columns or rows together to produce composite frames.<br />
| [[#Color_formats|All]]<br />
|}<br />
<br />
=== Audio processing filters ===<br />
<br />
These filters process audio. Audio samples will be automatically converted if any filters requires a special type of sample. This means that if a filter doesn't support the type of sample it is given, it will automatically convert the samples to something it supports. The internal formats supported in each filter is listed in the sample type column. A specific sample type can be forced by using the [[ConvertAudio]] functions.<br />
<br />
{{AvsPluscon}} automatic conversion is ''not'' performed. The new behavior is to raise an error when a sample type is not compatible. It is your responsibility to use [[ConvertAudio]] where needed.<br />
<br />
[[Float]] audio is converted to 16 bit when [[Frameserver|frameserving]] through [[ACM]], unless [[Internal_functions#OPT_AllowFloatAudio|OPT_AllowFloatAudio]] is set to true. In that case the audio is kept as it is. When accessing AviSynth directly (like MeGUI, BeHappy or ffmpeg do for example), there is no automatic conversion.<br />
<br />
The automatic conversion is done for clients that cannot handle [[Float]] audio (in the old days most of them couldn't). Note conversion takes place ''after'' the script processing is finished. [[Float]] audio is always allowed within the script.<br />
<br />
{| style="height:100px; width:95%" border="1" cellpadding="4" class="wikitable"<br />
!width=25%| Filter<br />
!width=50%| Description<br />
!width=15%| Sample type<br />
|-<br />
| [[Amplify]] / [[AmplifydB]]<br />
| Amplify multiply audio samples by amount.<br />
| 16 bit, Float<br />
|-<br />
| [[AssumeSampleRate]]<br />
| Adjusts the playback speed of the audio.<br />
| All<br />
|-<br />
| [[AudioDub]] / [[AudioDubEx]]<br />
| ''AudioDub'' takes the video stream from the first argument and the audio stream from the second argument and combines them. ''AudioDubEx'' is similar, but it doesn't throw an exception if both clips don't have a video or audio stream.<br />
| All<br />
|-<br />
| [[AudioTrim]]<br />
| Trims an audio clip so that it includes only the ''start_time'' through ''end_time''.<br />
| All<br />
|-<br />
| [[ConvertAudioTo8bit]] / [[ConvertAudioTo16bit]] / [[ConvertAudioTo24bit]] / [[ConvertAudioTo32bit]] / [[ConvertAudioToFloat]]<br />
| Converts audio samples to 8/16/24/32/Float bits.<br />
| All<br />
|-<br />
| [[ConvertToMono]]<br />
| Merges all audio channels.<br />
| 16 bit, Float<br />
|-<br />
| [[DelayAudio]]<br />
| Delays the audio track by second seconds.<br />
| All<br />
|-<br />
| [[EnsureVBRMP3Sync]]<br />
| Corrects out-of-sync MP3-AVI's, when seeking or trimming.<br />
| All<br />
|-<br />
| [[GetChannel]] / [[GetLeftChannel]] / [[GetRightChannel]]<br />
| Returns an audio channel from a clip.<br />
| All<br />
|-<br />
| [[KillAudio]] / [[KillVideo]]<br />
| Removes the audio or video from a clip completely.<br />
| All<br />
|-<br />
| [[MergeChannels]]<br />
| Merges channels of two audio clips.<br />
| All<br />
|-<br />
| [[MixAudio]]<br />
| Mixes audio from two clips.<br />
| 16 bit, Float<br />
|-<br />
| [[MonoToStereo]]<br />
| Converts two mono signals to one stereo signal.<br />
| 16 bit, Float<br />
|-<br />
| [[Normalize]]<br />
| Amplifies the entire waveform as much as possible, without clipping.<br />
| 16 bit, Float<br />
|-<br />
| [[ResampleAudio]]<br />
| Performs a high-quality change of audio sample rate.<br />
| 16 bit, Float<br />
|-<br />
| [[SuperEQ]]<br />
| High quality 18 band sound equalizer.<br />
| Float<br />
|-<br />
| [[SSRC]]<br />
| Very high quality sample rate conversion.<br />
| Float<br />
|-<br />
| [[TimeStretch]]<br />
| Change speed of a sound without changing the pitch, and change pitch without changing duration.<br />
| Float<br />
|}<br />
<br />
=== Conditional and other meta filters ===<br />
<br />
''Meta'' filters can be used to control other filters' execution. The basic characteristic of conditional filters is that their scripts are evaluated (executed) at every frame instead of when the clip is loaded. This allows for complex video processing that would be difficult or impossible to be performed by a normal AviSynth script. <br />
<br />
{| style="height:100px; width:95%" border="1" cellpadding="4" class="wikitable"<br />
!width=25%| Filter<br />
!width=50%| Description<br />
!width=15%| Color format<br />
|-<br />
| [[ConditionalFilter]] / [[FrameEvaluate]] / [[ScriptClip]] / [[ConditionalSelect]]<br />
| ''ConditionalFilter'' returns source1 if some condition is met, otherwise it returns source2. ''ScriptClip/FrameEvaluate'' returns the clip which is returned by the function evaluated on every frame. ''ConditionalSelect'' returns one frame from several sources based on an integer evaluator.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[ConditionalReader]]<br />
| Import information from a text file, with different values for each frame - or a range of frames.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[WriteFile]] / [[WriteFileIf]] / [[WriteFileStart]] / [[WriteFileEnd]]<br />
| These filters evaluate expressions and output the results to a text-file.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[Animate]] / [[ApplyRange]]<br />
| ''Animate'' is a meta-filter which evaluates another filter with continuously varying arguments.<br />
''ApplyRange'' 'is a special case of ''Animate'' where ''start_args'' = ''end_args''.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[TCPServer]] / [[TCPSource]]<br />
| Send clips over your network. You can connect several clients to the same machine.<br />
| [[#Color_formats|All]]<br />
|}<br />
<br />
=== Export filters ===<br />
<br />
These filters can write directly to media files. <br />
<br />
{| style="height:100px; width:95%" border="1" cellpadding="4" class="wikitable"<br />
!width=25%| Filter<br />
!width=50%| Description<br />
!width=15%| Color format<br />
|-<br />
| [[ImageWriter]]<br />
| Writes frames as images to your hard disk. See [[#Source_filters|ImageReader]].<br />
| [[#Color_formats|All]]<br />
|}<br />
<br />
=== Debug filters ===<br />
<br />
{| style="height:100px; width:95%" border="1" cellpadding="4" class="wikitable"<br />
!width=25%| Filter<br />
!width=50%| Description<br />
!width=15%| Color format<br />
|-<br />
| [[BlankClip]] / [[Blackness]]<br />
| Produces a solid color, silent video clip of the specified length (in frames).<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[ColorBars]] / [[ColorBarsHD]]<br />
| Produce a video clip containing SMPTE colorbars scaled to any image size.<br />
| RGB32, YUY2, YV12, YV24<br />
|-<br />
| [[Compare]]<br />
| Compares two clips and prints out information about the differences.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[Echo]]<br />
| Forces internal <tt>GetFrame</tt> calls to all input clips. Returns only first clip result.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[Histogram]]<br />
| A multipurpose audio/video analysis tool.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[Info]]<br />
| Prints out image and sound information.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[MessageClip]]<br />
| Produces a clip containing a text message.<br />
| RGB32<br />
|-<br />
| [[Preroll]]<br />
| Preroll the audio or video on non-linear access.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[ShowFiveVersions]]<br />
| Takes five video clips and combines them in a staggered arrangement from left to right.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[ShowFrameNumber]] / [[ShowSMPTE]] / [[ShowTime]]<br />
| Draws text on every frame indicating what number AviSynth thinks it is.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[StackHorizontal]] / [[StackVertical]]<br />
| Takes two or more video clips and displays them together in left-to-right/up-to-down order.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[Subtitle]]<br />
| Adds anti-aliased text to a range of frames.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[Tone]]<br />
| Generates a sound.<br />
| Float<br />
|-<br />
| [[Version]]<br />
| Generates a video clip with a short AviSynth version and copyright statement.<br />
| RGB24<br />
|}<br />
<br />
<br />
{{HiddenAnchor|Color_formats}}<br />
=== Footnote: Color Formats ===<br />
<br />
''The above filters work with the following named color formats.''<br />
{| style="height:100px" border="1" cellpadding="4" class="wikitable"<br />
|-<br />
!Name<br />
!Formats<br />
|-<br />
| All<br />
| RGB, YUV<br />
|-<br />
| [[RGB]]<br />
| [[RGB24]], [[RGB32]]<br />
|-<br />
| [[YUV]]<br />
| [[YUY2]], YUV Planar <br />
|-<br />
| YUV [[Planar]]&nbsp;<br />
| [[YV24]]&diams;, [[YV16]]&diams;, [[YV12]], [[YV411]]&diams;, [[Y8]]&diams;&nbsp;<br />
|}<br />
(&diams; = not supported in AviSynth version 2.58 or below)<br />
<br />
</div><br />
<br />
<br />
[[Category:AviSynth_Usage]]<br />
[[Category:AviSynth_Syntax]]</div>Adminhttp://avisynth.nl/index.php/Internal_filtersInternal filters2017-07-10T14:23:32Z<p>Admin: /* Audio processing filters */</p>
<hr />
<div><div style="max-width:76em; min-width:48em"><br />
The available (internal) filters are listed here and divided into categories. A short description is added, including the supported [[Color_spaces|color formats]] (and sample types for the audio filters). There are some functions which combine two or more clips in different ways. How the video content is calculated is described for each function, but [[filters_with_multiple_input_clips|here is a summary which explains which properties that the resulting clip will have]].<br />
<br />
An alphabetical listing of the internal filters can be found [[:Category:Internal_filters|here]].<br />
<br />
=== Source filters ===<br />
<br />
These filters can read media files and return an AviSynth clip. See [[#Debug_filters|debug filters]] for non-file source filters.<br />
<br />
{| style="height:100px; width:95%" border="1" cellpadding="4" class="wikitable"<br />
!width=25%| Filter<br />
!width=50%| Description<br />
!width=15%| Color format<br />
|- <br />
| [[AviSource]] / [[AviFileSource]] / [[OpenDMLSource]]<br />
| Opens an AVI file.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[DirectShowSource]]<br />
| Opens a filename using [[DirectShow]].<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[ImageReader]] / [[ImageSource]] / [[ImageSourceAnim]]<br />
| Reads in still or animated images. See [[#Export_filters|ImageWriter]].<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[Import]]<br />
| Imports an AviSynth script into the current script.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[SegmentedAviSource]] / [[SegmentedDirectShowSource]]<br />
| Loads up to 100 avi files per argument.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[WavSource]]<br />
| Opens a WAV file or the audio of an AVI file.<br />
| [[#Color_formats|All]]<br />
|}<br />
<br />
=== Color conversion and adjustment filters ===<br />
<br />
These filters can be used to change the color format or adjust the colors of a clip.<br />
<br />
{| style="height:100px; width:95%" border="1" cellpadding="4" class="wikitable"<br />
!width=25%| Filter<br />
!width=50%| Description<br />
!width=15%| Color format<br />
|- <br />
| [[ColorYUV]]<br />
| Adjusts colors and luma independently.<br />
| [[#Color_formats|YUV]]<br />
|-<br />
| [[ConvertBackToYUY2]]<br />
| Converts a RGB clip back to YUY2.<br />
| [[#Color_formats|RGB]]<br />
|-<br />
| [[ConvertToRGB]]<br />
| Converts to RGB32 unless clip is RGB24.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[ConvertToRGB24]] / [[ConvertToRGB32]] / [[ConvertToYUY2]] / [[ConvertToY8]] / [[ConvertToYV411]] / [[ConvertToYV12]] / [[ConvertToYV16]] / [[ConvertToYV24]]<br />
| Converts to RGB24 / RGB32 / YUY2 / Y8 / YV411 / YV12 / YV16 (planar version of YUY2) / YV24 (full YUV).<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[FixLuminance]]<br />
| Correct shifting vertical luma offset.<br />
| YUY2<br />
|-<br />
| [[Greyscale]]/[[Grayscale]]<br />
| Converts a video to greyscale (no color)<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[Invert]]<br />
| Inverts selected color channels of a video.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[Levels]]<br />
| Scales and clamps the black and white levels, and adjusts the gamma.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[Limiter]]<br />
| Clips levels to within CCIR-601 range, and optionally highlights pixels outside that range.<br />
| [[#Color_formats|YUV]]<br />
|-<br />
| [[MergeARGB]] / [[MergeRGB]]<br />
| Select and combine a color channel from each of the input video clips.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[MergeChroma]] / [[MergeLuma]]<br />
| Merge (blend) chroma or luma from one video clip into another. There is an optional weighting, so a percentage between the two clips can be specified.<br />
| [[#Color_formats|YUV]]<br />
|-<br />
| [[RGBAdjust]]<br />
| Adjusts each color channel separately.<br />
| [[#Color_formats|RGB]]<br />
|-<br />
| [[ShowAlpha]] / [[ShowRed]] / [[ShowGreen]] / [[ShowBlue]]<br />
| Shows the selected channel of an (A)RGB clip.<br />
| [[#Color_formats|RGB]]<br />
|-<br />
| [[SwapUV]]<br />
| Swaps chroma channels.<br />
| [[#Color_formats|YUV]]<br />
|-<br />
| [[Tweak]]<br />
| Adjusts the hue, saturation, brightness, and contrast.<br />
| [[#Color_formats|YUV]]<br />
|-<br />
| [[UToY]] / [[UToY8]] / [[VToY]] / [[VToY8]]<br />
| Copies U or V chroma plane to the Y luma plane.<br />
| [[#Color_formats|YUV]], except [[Y8]]<br />
|-<br />
| [[YToUV]]<br />
| Puts the luma channels of two clips as U and V channels. Luma is now 50% grey.<br />
| [[#Color_formats|YUV]]<br />
|}<br />
<br />
=== Overlay and Mask filters ===<br />
<br />
These filters can be used to layer clips with or without using masks and to create masks.<br />
<br />
{| style="height:100px; width:95%" border="1" cellpadding="4" class="wikitable"<br />
!width=25%| Filter<br />
!width=50%| Description<br />
!width=15%| Color format<br />
|-<br />
| [[ColorKeyMask]]<br />
| Sets the alpha-channel (similar as Mask does) but generates it by comparing the color.<br />
| RGB32<br />
|-<br />
| [[Layer]]<br />
| Puts one clip on top of another using different layer (blend) modes and variable opacity. Supports alpha-channel transparency.<br />
| RGB32, YUY2<br />
|-<br />
| [[Mask]]<br />
| Applies an alpha-mask to a clip.<br />
| RGB32<br />
|-<br />
| [[MaskHS]]<br />
| This filter returns a mask (as Y8) of clip using a given hue and saturation range.<br />
| [[#Color_formats|YUV]]<br />
|-<br />
| [[Merge]]<br />
| Merge (blend) one video clip into another. There is an optional weighting, so a percentage between the two clips can be specified.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[Overlay]]<br />
| Puts one clip on top of another with optional XY displacement of the overlaying image, using different overlay (blend) modes and variable opacity. Uses a separate ''mask'' clip for transparency information.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[ResetMask]]<br />
| Applies an "all-opaque" alpha-mask to clip.<br />
| RGB32<br />
|-<br />
| [[Subtract]]<br />
| Shows the difference between the corresponding pixels of two clips.<br />
| [[#Color_formats|All]]<br />
|}<br />
<br />
=== Geometric deformation filters ===<br />
<br />
These filters can be used to change image size, process borders or make other deformations of a clip.<br />
<br />
{| style="height:100px; width:95%" border="1" cellpadding="4" class="wikitable"<br />
!width=25%| Filter<br />
!width=50%| Description<br />
!width=15%| Color format<br />
|- <br />
| [[AddBorders]]<br />
| Adds black or colored borders around the image.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[Crop]]<br />
| Crops excess pixels from each frame.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[CropBottom]]<br />
| Crops excess pixels from the bottom of each frame.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[FlipHorizontal]] / [[FlipVertical]]<br />
| Flips the video from left to right/upside-down.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[Letterbox]]<br />
| Blackens out (or colors out) the top and bottom (and optionally left and right) of each frame. <br />
| [[#Color_formats|All]]<br />
|-<br />
| [[HorizontalReduceBy2]] / [[VerticalReduceBy2]] / [[ReduceBy2]]<br />
| Reduces the size of each frame by half horizontally, vertically or in both directions.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[BicubicResize]] / [[BilinearResize]] / [[BlackmanResize]] / [[GaussResize]] / [[LanczosResize]] / [[Lanczos4Resize]] / [[PointResize]] / [[SincResize]] / [[Spline16Resize]] / [[Spline36Resize]] / [[Spline64Resize]]<br />
| Rescale the input video frames to an arbitrary new resolution, using different sampling algorithms.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[SkewRows]]<br />
| Skews (or deskews) the rows of a clip.<br />
| RGB24, RGB32, YUY2, Y8<br />
|-<br />
| [[TurnLeft]] / [[TurnRight]] / [[Turn180]]<br />
| Rotates the clip 90 degrees counter-clockwise / 90 degrees clockwise.<br />
| [[#Color_formats|All]]<br />
|}<br />
<br />
=== Pixel restoration filters ===<br />
<br />
These filters can be used for image detail (pixel) restoration (like denoising, sharpening) of a clip.<br />
<br />
{| style="height:100px; width:95%" border="1" cellpadding="4" class="wikitable"<br />
!width=25%| Filter<br />
!width=50%| Description<br />
!width=15%| Color format<br />
|- <br />
| [[Blur]] / [[Sharpen]]<br />
| Simple 3x3-kernel blurring/sharpening filter.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[GeneralConvolution]]<br />
| General 3x3 or 5x5 convolution matrix.<br />
| RGB32<br />
|-<br />
| [[SpatialSoften]] / [[TemporalSoften]]<br />
| Removes noise from a video clip by selectively blending pixels spatially/temporally.<br />
| YUY2 (SpatialSoften), [[#Color_formats|YUV Planar]]<br />
|-<br />
| [[FixBrokenChromaUpsampling]]<br />
| The free Canopus DV Codec v1.00 upsamples the chroma channels incorrectly (although newer non-free versions appear to work fine). This filter compensates for it.<br />
| YUY2<br />
|}<br />
<br />
=== Timeline editing filters ===<br />
<br />
These filters can be used to arrange frames in time (clip cutting, splicing and other editing).<br />
<br />
{| style="height:100px; width:95%" border="1" cellpadding="4" class="wikitable"<br />
!width=25%| Filter<br />
!width=50%| Description<br />
!width=15%| Color format<br />
|-<br />
| [[AlignedSplice]] / [[UnalignedSplice]]<br />
| Joins two or more video clips end to end.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[AssumeFPS]] / [[AssumeScaledFPS]] / [[ChangeFPS]] / [[ConvertFPS]]<br />
| Changes framerate and/or video speed in different ways.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[DeleteFrame]]<br />
| Deletes a single frame, given as an argument.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[Dissolve]]<br />
| Like [[AlignedSplice]], except that the clips are combined with some overlap.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[DuplicateFrame]]<br />
| Duplicates a single frame given as an argument.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[FadeIn0]] / [[FadeIn]] / [[FadeIn2]] / [[FadeOut0]] / [[FadeOut]] / [[FadeOut2]] / [[FadeIO0]] / [[FadeIO]] / [[FadeIO2]]<br />
| Causes the video stream to fade linearly to black at the start or end.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[FreezeFrame]]<br />
| Replaces all the frames between ''first-frame'' and ''last-frame'' with a selected frame.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[Interleave]]<br />
| Interleaves frames from several clips on a frame-by-frame basis.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[Loop]]<br />
| Loops the segment from ''start_frame'' to ''end_frame'' a given number of times.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[Reverse]]<br />
| Makes a clip play in reverse.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[SelectEven]] / [[SelectOdd]]<br />
| Makes an output video stream using only the even- or odd-numbered frames.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[SelectEvery]]<br />
| Selects frames with a fixed period; a generalization of [[SelectEven]] and [[SelectOdd]].<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[SelectRangeEvery]]<br />
| Selects a range of frames with a fixed period.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[Trim]]<br />
| Trims a video clip so that it includes only the frames ''first_frame'' through ''last_frame''.<br />
| [[#Color_formats|All]]<br />
|}<br />
<br />
=== Interlace filters ===<br />
<br />
These filters can be used for creating and processing field-based material (which is frame-based material separated into fields). AviSynth is capable of dealing with both progressive and interlaced material. The main problem is, that it often doesn't know what it receives from source filters. This is the reason that the field-based flag exists and can be used when dealing with interlaced material. More information about field-based video can be found [[Interlaced_fieldbased|here]].<br />
<br />
{| style="height:100px; width:95%" border="1" cellpadding="4" class="wikitable"<br />
!width=25%| Filter<br />
!width=50%| Description<br />
!width=15%| Color format<br />
|-<br />
| [[AssumeFrameBased]] / [[AssumeFieldBased]]<br />
| Forces frame-based or field-based material.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[AssumeBFF]] / [[AssumeTFF]]<br />
| Forces field order.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[Bob]]<br />
| Takes a clip and [[Wikipedia:Deinterlacing#Field_extension_deinterlacing|bob-deinterlaces]] it.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[ComplementParity]]<br />
| Changes top fields to bottom fields and vice-versa.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[DoubleWeave]]<br />
| Operates like [[Weave]], except that it produces double the number of frames by combining both the odd and even pairs of fields.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[PeculiarBlend]]<br />
| Blends each frame with the following frame in a peculiar way.<br />
| YUY2<br />
|-<br />
| [[Pulldown]]<br />
| Selects two out of every five frames of the source video.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[SeparateColumns]] / [[SeparateRows]]<br />
| Separates the columns or rows of each frame into new frames.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[SeparateFields]]<br />
| Splits each frame into its component top and bottom fields.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[SwapFields]]<br />
| Swaps the two fields in an interlaced frame.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[Weave]]<br />
| Combines fields together to produce interlaced frames.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[WeaveColumns]] / [[WeaveRows]]<br />
| Takes a clip and weaves sets of columns or rows together to produce composite frames.<br />
| [[#Color_formats|All]]<br />
|}<br />
<br />
=== Audio processing filters ===<br />
<br />
These filters process audio. Audio samples will be automatically converted if any filters requires a special type of sample. This means that if a filter doesn't support the type of sample it is given, it will automatically convert the samples to something it supports. The internal formats supported in each filter is listed in the sample type column. A specific sample type can be forced by using the [[ConvertAudio]] functions.<br />
<br />
{{AvsPluscon}} automatic conversion is ''not'' performed. The new behavior is to raise an error when a sample type is not compatible. It is your responsibility to use [[ConvertAudio]] where needed.<br />
<br />
[[Float]] audio is converted to 16 bit when [[Frameserver|frameserving]] through [[ACM]], unless [[Internal_functions#OPT_AllowFloatAudio|OPT_AllowFloatAudio]] is set to true. In that case the audio is kept as it is. When accessing AviSynth directly (like MeGUI, BeHappy or ffmpeg do for example), there is no automatic conversion.<br />
<br />
The automatic conversion is done for clients that cannot handle [[Float]] audio (in the old days, most of them didn't). Note conversion takes place ''after'' the script processing is finished. [[Float]] audio is always allowed within the script.<br />
<br />
{| style="height:100px; width:95%" border="1" cellpadding="4" class="wikitable"<br />
!width=25%| Filter<br />
!width=50%| Description<br />
!width=15%| Sample type<br />
|-<br />
| [[Amplify]] / [[AmplifydB]]<br />
| Amplify multiply audio samples by amount.<br />
| 16 bit, Float<br />
|-<br />
| [[AssumeSampleRate]]<br />
| Adjusts the playback speed of the audio.<br />
| All<br />
|-<br />
| [[AudioDub]] / [[AudioDubEx]]<br />
| ''AudioDub'' takes the video stream from the first argument and the audio stream from the second argument and combines them. ''AudioDubEx'' is similar, but it doesn't throw an exception if both clips don't have a video or audio stream.<br />
| All<br />
|-<br />
| [[AudioTrim]]<br />
| Trims an audio clip so that it includes only the ''start_time'' through ''end_time''.<br />
| All<br />
|-<br />
| [[ConvertAudioTo8bit]] / [[ConvertAudioTo16bit]] / [[ConvertAudioTo24bit]] / [[ConvertAudioTo32bit]] / [[ConvertAudioToFloat]]<br />
| Converts audio samples to 8/16/24/32/Float bits.<br />
| All<br />
|-<br />
| [[ConvertToMono]]<br />
| Merges all audio channels.<br />
| 16 bit, Float<br />
|-<br />
| [[DelayAudio]]<br />
| Delays the audio track by second seconds.<br />
| All<br />
|-<br />
| [[EnsureVBRMP3Sync]]<br />
| Corrects out-of-sync MP3-AVI's, when seeking or trimming.<br />
| All<br />
|-<br />
| [[GetChannel]] / [[GetLeftChannel]] / [[GetRightChannel]]<br />
| Returns an audio channel from a clip.<br />
| All<br />
|-<br />
| [[KillAudio]] / [[KillVideo]]<br />
| Removes the audio or video from a clip completely.<br />
| All<br />
|-<br />
| [[MergeChannels]]<br />
| Merges channels of two audio clips.<br />
| All<br />
|-<br />
| [[MixAudio]]<br />
| Mixes audio from two clips.<br />
| 16 bit, Float<br />
|-<br />
| [[MonoToStereo]]<br />
| Converts two mono signals to one stereo signal.<br />
| 16 bit, Float<br />
|-<br />
| [[Normalize]]<br />
| Amplifies the entire waveform as much as possible, without clipping.<br />
| 16 bit, Float<br />
|-<br />
| [[ResampleAudio]]<br />
| Performs a high-quality change of audio sample rate.<br />
| 16 bit, Float<br />
|-<br />
| [[SuperEQ]]<br />
| High quality 18 band sound equalizer.<br />
| Float<br />
|-<br />
| [[SSRC]]<br />
| Very high quality sample rate conversion.<br />
| Float<br />
|-<br />
| [[TimeStretch]]<br />
| Change speed of a sound without changing the pitch, and change pitch without changing duration.<br />
| Float<br />
|}<br />
<br />
=== Conditional and other meta filters ===<br />
<br />
''Meta'' filters can be used to control other filters' execution. The basic characteristic of conditional filters is that their scripts are evaluated (executed) at every frame instead of when the clip is loaded. This allows for complex video processing that would be difficult or impossible to be performed by a normal AviSynth script. <br />
<br />
{| style="height:100px; width:95%" border="1" cellpadding="4" class="wikitable"<br />
!width=25%| Filter<br />
!width=50%| Description<br />
!width=15%| Color format<br />
|-<br />
| [[ConditionalFilter]] / [[FrameEvaluate]] / [[ScriptClip]] / [[ConditionalSelect]]<br />
| ''ConditionalFilter'' returns source1 if some condition is met, otherwise it returns source2. ''ScriptClip/FrameEvaluate'' returns the clip which is returned by the function evaluated on every frame. ''ConditionalSelect'' returns one frame from several sources based on an integer evaluator.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[ConditionalReader]]<br />
| Import information from a text file, with different values for each frame - or a range of frames.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[WriteFile]] / [[WriteFileIf]] / [[WriteFileStart]] / [[WriteFileEnd]]<br />
| These filters evaluate expressions and output the results to a text-file.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[Animate]] / [[ApplyRange]]<br />
| ''Animate'' is a meta-filter which evaluates another filter with continuously varying arguments.<br />
''ApplyRange'' 'is a special case of ''Animate'' where ''start_args'' = ''end_args''.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[TCPServer]] / [[TCPSource]]<br />
| Send clips over your network. You can connect several clients to the same machine.<br />
| [[#Color_formats|All]]<br />
|}<br />
<br />
=== Export filters ===<br />
<br />
These filters can write directly to media files. <br />
<br />
{| style="height:100px; width:95%" border="1" cellpadding="4" class="wikitable"<br />
!width=25%| Filter<br />
!width=50%| Description<br />
!width=15%| Color format<br />
|-<br />
| [[ImageWriter]]<br />
| Writes frames as images to your hard disk. See [[#Source_filters|ImageReader]].<br />
| [[#Color_formats|All]]<br />
|}<br />
<br />
=== Debug filters ===<br />
<br />
{| style="height:100px; width:95%" border="1" cellpadding="4" class="wikitable"<br />
!width=25%| Filter<br />
!width=50%| Description<br />
!width=15%| Color format<br />
|-<br />
| [[BlankClip]] / [[Blackness]]<br />
| Produces a solid color, silent video clip of the specified length (in frames).<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[ColorBars]] / [[ColorBarsHD]]<br />
| Produce a video clip containing SMPTE colorbars scaled to any image size.<br />
| RGB32, YUY2, YV12, YV24<br />
|-<br />
| [[Compare]]<br />
| Compares two clips and prints out information about the differences.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[Echo]]<br />
| Forces internal <tt>GetFrame</tt> calls to all input clips. Returns only first clip result.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[Histogram]]<br />
| A multipurpose audio/video analysis tool.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[Info]]<br />
| Prints out image and sound information.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[MessageClip]]<br />
| Produces a clip containing a text message.<br />
| RGB32<br />
|-<br />
| [[Preroll]]<br />
| Preroll the audio or video on non-linear access.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[ShowFiveVersions]]<br />
| Takes five video clips and combines them in a staggered arrangement from left to right.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[ShowFrameNumber]] / [[ShowSMPTE]] / [[ShowTime]]<br />
| Draws text on every frame indicating what number AviSynth thinks it is.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[StackHorizontal]] / [[StackVertical]]<br />
| Takes two or more video clips and displays them together in left-to-right/up-to-down order.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[Subtitle]]<br />
| Adds anti-aliased text to a range of frames.<br />
| [[#Color_formats|All]]<br />
|-<br />
| [[Tone]]<br />
| Generates a sound.<br />
| Float<br />
|-<br />
| [[Version]]<br />
| Generates a video clip with a short AviSynth version and copyright statement.<br />
| RGB24<br />
|}<br />
<br />
<br />
{{HiddenAnchor|Color_formats}}<br />
=== Footnote: Color Formats ===<br />
<br />
''The above filters work with the following named color formats.''<br />
{| style="height:100px" border="1" cellpadding="4" class="wikitable"<br />
|-<br />
!Name<br />
!Formats<br />
|-<br />
| All<br />
| RGB, YUV<br />
|-<br />
| [[RGB]]<br />
| [[RGB24]], [[RGB32]]<br />
|-<br />
| [[YUV]]<br />
| [[YUY2]], YUV Planar <br />
|-<br />
| YUV [[Planar]]&nbsp;<br />
| [[YV24]]&diams;, [[YV16]]&diams;, [[YV12]], [[YV411]]&diams;, [[Y8]]&diams;&nbsp;<br />
|}<br />
(&diams; = not supported in AviSynth version 2.58 or below)<br />
<br />
</div><br />
<br />
<br />
[[Category:AviSynth_Usage]]<br />
[[Category:AviSynth_Syntax]]</div>Adminhttp://avisynth.nl/index.php/ACMACM2017-07-10T14:17:07Z<p>Admin: Created page with "https://en.wikipedia.org/wiki/Windows_legacy_audio_components#Audio_Compression_Manager Category:Glossary"</p>
<hr />
<div>https://en.wikipedia.org/wiki/Windows_legacy_audio_components#Audio_Compression_Manager<br />
<br />
[[Category:Glossary]]</div>Adminhttp://avisynth.nl/index.php/Filter_SDK/CInvertNegFilter SDK/CInvertNeg2017-01-13T22:43:53Z<p>Admin: </p>
<hr />
<div>I'll start off with a complete, working Avisynth C plugin. It's called "InvertNeg", and it produces a photo-negative of the input clip.<br />
<br />
Here's InvertNeg.c:<br />
<br />
#include "avisynth_c.h"<br />
<br />
AVS_VideoFrame* AVSC_CC InvertNeg_get_frame(AVS_FilterInfo* fi, int n)<br />
{<br />
AVS_VideoFrame* src;<br />
AVS_VideoFrame* dst;<br />
int row_size, height, src_pitch, dst_pitch;<br />
const BYTE* srcp;<br />
BYTE* dstp;<br />
int x, y, p;<br />
<br />
int planes[] = {AVS_PLANAR_Y, AVS_PLANAR_V, AVS_PLANAR_U};<br />
<br />
src = avs_get_frame(fi->child, n);<br />
dst = avs_new_video_frame(fi->env, &fi->vi);<br />
<br />
for (p=0; p<3; p++) {<br />
srcp = avs_get_read_ptr_p(src, planes[p]);<br />
dstp = avs_get_write_ptr_p(dst, planes[p]);<br />
src_pitch = avs_get_pitch_p(src, planes[p]);<br />
dst_pitch = avs_get_pitch_p(dst, planes[p]);<br />
row_size = avs_get_row_size_p(dst, planes[p]);<br />
height = avs_get_height_p(dst, planes[p]);<br />
<br />
for (y = 0; y < height; y++) {<br />
for (x = 0; x < row_size; x++) {<br />
dstp[x] = srcp[x] ^ 255;<br />
}<br />
srcp += src_pitch;<br />
dstp += dst_pitch;<br />
}<br />
}<br />
<br />
avs_release_video_frame(src);<br />
return dst;<br />
}<br />
<br />
AVS_Value AVSC_CC Create_InvertNeg(AVS_ScriptEnvironment* env, AVS_Value args, void* user_data)<br />
{<br />
AVS_Value v;<br />
AVS_FilterInfo* fi;<br />
AVS_Clip* new_clip = avs_new_c_filter(env, &fi, avs_array_elt(args, 0), 1);<br />
<br />
if (!avs_is_planar(&fi->vi) || !avs_is_yuv(&fi->vi)) {<br />
return avs_new_value_error("InvertNeg: planar YUV data only!");<br />
}<br />
<br />
fi->get_frame = InvertNeg_get_frame;<br />
<br />
v = avs_new_value_clip(new_clip);<br />
<br />
avs_release_clip(new_clip);<br />
return v;<br />
}<br />
<br />
const char* AVSC_CC avisynth_c_plugin_init(AVS_ScriptEnvironment * env)<br />
{<br />
avs_add_function(env, "InvertNeg", "c", Create_InvertNeg, 0);<br />
return "InvertNeg sample c-plugin";<br />
}<br />
<br />
Link to avisynth.lib and when using the MSVC++ compiler add the definition file. Compile this file into a DLL named InvertNeg.dll. See [[Filter_SDK/Compiling_instructions|compiling instructions]]. Now create an Avisynth script which looks something like this:<br />
<br />
LoadCPlugin("d:\path\InvertNeg.dll")<br />
clip = BlankClip().ConvertToYV12()<br />
return clip.InvertNeg()<br />
<br />
=== Line by line breakdown ===<br />
<br />
Here's a line-by-line breakdown of InvertNeg.c:<br />
<br />
#include "avisynth_c.h"<br />
<br />
This header declares all the classes and miscellaneous constants that you might need when writing a plugin. All external plugins should #include it.<br />
<br />
External plugins do not link with avisynth.dll, so they can't directly access functions that are defined in the main Avisynth source code. Therefore, every important function in avisynth_c.h is either defined inline or (???).<br />
<br />
AVS_VideoFrame* AVSC_CC InvertNeg_get_frame(AVS_FilterInfo* fi, int n)<br />
<br />
This function is the main callback functions for our filter. When called it should return frame n. It returns this frame as a pointer to AVS_VideoFrame.<br />
<br />
AVSC_CC stands for Avisynth calling convention. Right now it is stdcall (it used to be cdecl when the C interface was exposes through seperate plugin). By using AVSC_CC you should be able to maintain source code compatibility when the calling convention changes. <br />
<br />
AVS_VideoFrame* src;<br />
AVS_VideoFrame* dst;<br />
int row_size, height, src_pitch, dst_pitch;<br />
const BYTE* srcp;<br />
BYTE* dstp;<br />
int x, y, p;<br />
<br />
Declaring all of the variables we will need '''must be done up front''' (for the C++ plugin this is not necessary). Doing it in between the code will get you strange compile errors.<br />
<br />
int planes[] = {AVS_PLANAR_Y, AVS_PLANAR_V, AVS_PLANAR_U};<br />
<br />
The plugin requires planar YUV data, so we need to process the planes. Note the constants (such as AVS_PLANAR_Y) are the same as the ones in the C++ inteface, except for the 'AVS_' in front of it.<br />
<br />
src = avs_get_frame(fi->child, n);<br />
<br />
"child" is a member of AVS_FilterInfo, of type AVS_Clip. It generally contains the clip that was passed into the filter. For our filter to produce frame n we need the corresponding frame of the input clip. If you need a different frame from the input, all you have to do is pass a different frame number get_frame.<br />
<br />
Note the functions (such as avs_get_frame) are similar as the ones in the C++ inteface, except for the 'avs_' in front of it.<br />
<br />
get_frame calls are usually intercepted by Avisynth's internal caching code, so the frame request may never actually reach the child filter (meaning ???). <br />
<br />
dst = avs_new_video_frame(fi->env, &fi->vi);<br />
<br />
The avs_new_video_frame function allocates space for a video frame of the supplied size. (In this case it will hold our filter's output.) The frame buffer is uninitialized raw memory.<br />
<br />
"env" is a member of AVS_FilterInfo which is a pointer to AVS_ScriptEnvironment. One instance of AVS_ScriptEnvironment is created for each AVS script.<br />
<br />
"vi" is another member of AVS_FilterInfo. It is a structure of type AVS_VideoInfo, which contains information about the clip (like frame size, frame rate, pixel format, audio sample rate, etc.). avs_new_video_frame uses the information in this structure to return a frame buffer of the appropriate size.<br />
<br />
Frame buffers are reused once all references to them go away. So usually memory won't need to be allocated from the heap. <br />
<br />
for (p=0; p<3; p++) {<br />
<br />
Loop over all planes.<br />
<br />
srcp = avs_get_read_ptr_p(src, planes[p]);<br />
dstp = avs_get_write_ptr_p(dst, planes[p]);<br />
<br />
All frame buffers are readable, but not all are writable.<br />
<br />
The rule about writability is this: A buffer is writable if and only if its reference count is one. In other words, you can only write to a buffer if no one else might be reading it. This rule guarantees that as long as you hold on to a video frame and don't write to it yourself, that frame will remain unchanged. Any buffer you get from avs_new_video_frame is guaranteed to be writable. However, frames you get from other clips via get_frame may not be writable, in which case avs_get_write_ptr will return a null pointer.<br />
<br />
There is an is_writable method which you can call to find out if a buffer is writable or not, and there's a avs_make_writable method (described below) to ensure that it is. <br />
<br />
src_pitch = avs_get_pitch_p(src, planes[p]);<br />
dst_pitch = avs_get_pitch_p(dst, planes[p]);<br />
<br />
The "pitch" of a frame buffer is the offset (in bytes) from the beginning of one scan line to the beginning of the next. The source and destination buffers won't necessarily have the same pitch.<br />
<br />
Buffers created by avs_new_video_frame are always double word (16-byte) aligned and always have a pitch that is a multiple of 16. <br />
<br />
row_size = avs_get_row_size_p(dst, planes[p]);<br />
<br />
The row size is the length of each row in bytes (not pixels). It's usually equal to the pitch or slightly less, but it may be significantly less if the frame in question has been through Crop.<br />
<br />
Since our source and destination frames have the same width and pixel format, they will always have the same row size. Thus I only need one row_size variable, and I could just as well have used dest instead of src. <br />
<br />
height = avs_get_height_p(dst, planes[p]);<br />
<br />
The height is the height in pixels. Again, for our filter this is the same for the source and the destination.<br />
<br />
for (y = 0; y < height; y++) {<br />
for (x = 0; x < row_size; x++) {<br />
dstp[x] = srcp[x] ^ 255;<br />
}<br />
srcp += src_pitch;<br />
dstp += dst_pitch;<br />
}<br />
}<br />
<br />
This is the code that does the actual work. The "srcp += src_pitch; dstp += dest_pitch;" idiom is a useful way of dealing with potentially differing pitches without too much grief.<br />
<br />
avs_release_video_frame(src);<br />
<br />
Once we are done with a video frame it needs to be released. Releasing a video frame does not actually delete it but decrements the reference count.<br />
<br />
return dst;<br />
<br />
GetFrame returns the newly-created frame.<br />
<br />
AVS_Value AVSC_CC Create_InvertNeg(AVS_ScriptEnvironment* env, AVS_Value args, void* user_data)<br />
<br />
In order to use our new filter, we need a scripting-language function which creates an instance of it. This is that function.<br />
<br />
Script functions written in C take three arguments. env contains the same ScriptEnvironment pointer that will later be passed to GetFrame. args contais all the arguments passed to the function by the script. user_data contains the void pointer which you passed to AddFunction (see below). Usually you won't need this.<br />
<br />
AVS_Value is a variant type which can hold any one of the following: a boolean value (true/false); an integer; a floating-point number; a string; a video clip; an array of AVS_Values; or nothing ("undefined"). You can test which one it is with the methods avs_is_bool, avs_is_int, avs_is_float, avs_is_string, avs_is_clip, avs_is_array, and avs_defined (which returns true if the AVS_Value is not "undefined"). You can get the value with avs_as_bool, avs_as_int, etc. for arrays, you can use the avs_array_size method to get the number of elements, and avs_array_elt get the elements themselves. For convenience, avs_is_float and avs_as_float will work with integers also. But boolean values are not treated as numeric (unlike C).<br />
<br />
The name "Create_InvertNeg" is arbitrary. This function will actually be known as "InvertNeg" in scripts, because that's the name we pass to avs_add_function below. <br />
<br />
AVS_Value v;<br />
<br />
v will serve as the return value.<br />
<br />
AVS_FilterInfo* fi;<br />
AVS_Clip* new_clip = avs_new_c_filter(env, &fi, avs_array_elt(args, 0), 1);<br />
<br />
"avs_new_c_filter" creates a new filter. AVS_Clip is an abstract type representing a filter. In this case it will represent our new filter. "env" is the current script environment. "fi" will be set to point to our filter AVS_FilterInfo which is the concrete representation of a C filter. We will modify this structure later. "avs_array_elt(args, 0)" is accessing the first value of args, which is generally the parent clip. The last parameter, is a boolean value "store_child". It should generally always be set to true.<br />
<br />
if (!avs_is_planar(&fi->vi) || !avs_is_yuv(&fi->vi)) {<br />
return avs_new_value_error("InvertNeg: planar YUV data only!");<br />
}<br />
<br />
Our filter will not work unless the video is stored as YUV planar. If this is not the case than an error is returned.<br />
<br />
fi->get_frame = InvertNeg_get_frame;<br />
<br />
Here we are setting the get_frame callback. There are other callbacks (like get_audio, set_cache_hints and get_parity), but since "store_child" was set to true we do not have to worry about implementing all of them. Just the ones we need.<br />
<br />
v = avs_new_value_clip(new_clip);<br />
<br />
The return value is then set to the new clip returned by avs_new_c_filter. avs_new_value_clip stores the clip in an AVS_Value which will be returned by our Create_InvertNeg. It also creates a new reference to the clip.<br />
<br />
avs_release_clip(new_clip);<br />
<br />
We must now release the clip returned by avs_new_c_filter. In the case of an error the clip is no longer needed. Otherwise a new reference is created to the clip with avs_new_value_clip so we must release the original reference.<br />
<br />
return v;<br />
<br />
Finally we return our new clip. We could also have returned an error instead (instead of returning an error right away).<br />
<br />
const char* AVSC_CC avisynth_c_plugin_init(AVS_ScriptEnvironment * env)<br />
<br />
This is the only function which gets exported from the DLL. It is called by the script function LoadCPlugin the first time this plugin in loaded in a particular script. If several scripts are open at once and more than one of them loads this plugin, avisynth_c_plugin_init may be called more than once with different ScriptEnvironments. Therefore:<br />
<br />
* You should not save the env parameter in a global variable.<br />
* If you need to initialize any static data, you should do it in DLLMain, not in this function. <br />
<br />
The main purpose of the avisynth_c_plugin_init function is to call avs_add_function.<br />
<br />
avs_add_function(env, "InvertNeg", "c", Create_InvertNeg, 0);<br />
<br />
As promised, we now call add_function to let Avisynth know of the existence of our filter. This function takes four arguments: the name of the new script function; the parameter-type string; the C function implementing the script function; and the user_data cookie.<br />
<br />
The parameter type string specifies the paramaters for the function. The return value is untyped. It consists of a series of letters specinging the parameter types with 'c' for clip, 'i' for integer, 's' for string, 'b' for boolean, and 'f' for float. In addition:<br />
<br />
* Any type can be followed with a '*' or '+' to indicate "zero or more" or "one or more" respectively. In this case all the matching arguments will be gathered into a sub-array. For example, if your type string is "is+f", then the integer argument will be args[0], the string arguments will be args[1][0], args[1][1], etc. (and there will be avs_array_size(args[1]) of them), and the float argument will be args[2].<br />
* '.' matches a single argument of any type. To match multiple arguments of any type, use ".*" or ".+".<br />
* Named arguments can be specified in [brackets] before the type. Named arguments are also optional arguments; if the user omits them, they will be of the undefined type instead of the type you specify. <br />
<br />
return "InvertNeg sample c-plugin";<br />
<br />
The return value of avisynth_c_plugin_init is a string which can contain any message you like, such as a notice identifying the version and author of the plugin. This string becomes the return value of LoadCPlugin, and will almost always be ignored. You can also just return 0 if you prefer.<br />
<br />
== As an in-place filter ==<br />
<br />
The InvertNeg filter could easily do its work in a single buffer, rather than copying from one buffer to another. Here's a new implementation of get_frame that does this:<br />
<br />
#include "avisynth_c.h"<br />
<br />
AVS_VideoFrame* AVSC_CC InvertNeg_get_frame(AVS_FilterInfo* fi, int n)<br />
{<br />
AVS_VideoFrame* src;<br />
int row_size, height, src_pitch;<br />
BYTE* srcp;<br />
int x, y, p;<br />
<br />
int planes[] = {AVS_PLANAR_Y, AVS_PLANAR_V, AVS_PLANAR_U};<br />
<br />
src = avs_get_frame(fi->child, n);<br />
avs_make_writable(fi->env, &src);<br />
<br />
for (p=0; p<3; p++) {<br />
srcp = avs_get_write_ptr_p(src, planes[p]);<br />
src_pitch = avs_get_pitch_p(src, planes[p]);<br />
row_size = avs_get_row_size_p(src, planes[p]);<br />
height = avs_get_height_p(src, planes[p]);<br />
<br />
for (y = 0; y < height; y++) {<br />
for (x = 0; x < row_size; x++) {<br />
srcp[x] = srcp[x] ^ 255; // or srcp[x] =^ 255;<br />
}<br />
srcp += src_pitch;<br />
}<br />
}<br />
<br />
return src;<br />
}<br />
<br />
AVS_Value AVSC_CC Create_InvertNeg(AVS_ScriptEnvironment* env, AVS_Value args, void* user_data)<br />
{<br />
AVS_Value v;<br />
AVS_FilterInfo* fi;<br />
AVS_Clip* new_clip = avs_new_c_filter(env, &fi, avs_array_elt(args, 0), 1);<br />
<br />
if (!avs_is_planar(&fi->vi) || !avs_is_yuv(&fi->vi)) {<br />
v = avs_new_value_error("InvertNeg: planar YUV data only!");<br />
} else {<br />
fi->get_frame = InvertNeg_get_frame;<br />
v = avs_new_value_clip(new_clip);<br />
}<br />
<br />
avs_release_clip(new_clip);<br />
return v;<br />
}<br />
<br />
const char* AVSC_CC avisynth_c_plugin_init(AVS_ScriptEnvironment * env)<br />
{<br />
avs_add_function(env, "InvertNeg", "c", Create_InvertNeg, 0);<br />
return "InvertNeg sample c-plugin";<br />
}<br />
<br />
The key difference between this version of the function and the original version is the presence of the avs_make_writable callback. This is necessary because this time "we don't know where that source frame has been." Someone else in the filter chain may be holding a reference to it, in which case we won't be allowed to write to it.<br />
<br />
== Old versions ==<br />
<br />
[http://www.kevina.org/avisynth_c/example.html Kevin's AviSynth C API Docs] is the documentation written for the deprecated avisynth_c.dll by Kevin Atkinson, in its original form.<br />
<br />
[[Category:C API]]</div>Adminhttp://avisynth.nl/index.php/Filter_SDK/CInvertNegFilter SDK/CInvertNeg2017-01-13T22:30:28Z<p>Admin: /* Line by line breakdown */</p>
<hr />
<div>I'll start off with a complete, working Avisynth C plugin. It's called "InvertNeg", and it produces a photo-negative of the input clip.<br />
<br />
Here's InvertNeg.c:<br />
<br />
#include "avisynth_c.h"<br />
<br />
AVS_VideoFrame* AVSC_CC InvertNeg_get_frame(AVS_FilterInfo* fi, int n)<br />
{<br />
AVS_VideoFrame* src;<br />
AVS_VideoFrame* dst;<br />
int row_size, height, src_pitch, dst_pitch;<br />
const BYTE* srcp;<br />
BYTE* dstp;<br />
int x, y, p;<br />
<br />
int planes[] = {AVS_PLANAR_Y, AVS_PLANAR_V, AVS_PLANAR_U};<br />
<br />
src = avs_get_frame(fi->child, n);<br />
dst = avs_new_video_frame(fi->env, &fi->vi);<br />
<br />
for (p=0; p<3; p++) {<br />
srcp = avs_get_read_ptr_p(src, planes[p]);<br />
dstp = avs_get_write_ptr_p(dst, planes[p]);<br />
src_pitch = avs_get_pitch_p(src, planes[p]);<br />
dst_pitch = avs_get_pitch_p(dst, planes[p]);<br />
row_size = avs_get_row_size_p(dst, planes[p]);<br />
height = avs_get_height_p(dst, planes[p]);<br />
<br />
for (y = 0; y < height; y++) {<br />
for (x = 0; x < row_size; x++) {<br />
dstp[x] = srcp[x] ^ 255;<br />
}<br />
srcp += src_pitch;<br />
dstp += dst_pitch;<br />
}<br />
}<br />
<br />
avs_release_video_frame(src);<br />
return dst;<br />
}<br />
<br />
AVS_Value AVSC_CC Create_InvertNeg(AVS_ScriptEnvironment* env, AVS_Value args, void* user_data)<br />
{<br />
AVS_Value v;<br />
AVS_FilterInfo* fi;<br />
AVS_Clip* new_clip = avs_new_c_filter(env, &fi, avs_array_elt(args, 0), 1);<br />
<br />
if (!avs_is_planar(&fi->vi) || !avs_is_yuv(&fi->vi)) {<br />
return avs_new_value_error("InvertNeg: planar YUV data only!");<br />
}<br />
<br />
fi->get_frame = InvertNeg_get_frame;<br />
<br />
v = avs_new_value_clip(new_clip);<br />
<br />
avs_release_clip(new_clip);<br />
return v;<br />
}<br />
<br />
const char* AVSC_CC avisynth_c_plugin_init(AVS_ScriptEnvironment * env)<br />
{<br />
avs_add_function(env, "InvertNeg", "c", Create_InvertNeg, 0);<br />
return "InvertNeg sample c-plugin";<br />
}<br />
<br />
Link to avisynth.lib and when using the MSVC++ compiler add the definition file. Compile this file into a DLL named InvertNeg.dll. See [[Filter_SDK/Compiling_instructions|compiling instructions]]. Now create an Avisynth script which looks something like this:<br />
<br />
LoadCPlugin("d:\path\InvertNeg.dll")<br />
clip = BlankClip().ConvertToYV12()<br />
return clip.InvertNeg()<br />
<br />
=== Line by line breakdown ===<br />
<br />
Here's a line-by-line breakdown of InvertNeg.c:<br />
<br />
#include "avisynth_c.h"<br />
<br />
This header declares all the classes and miscellaneous constants that you might need when writing a plugin. All external plugins should #include it.<br />
<br />
External plugins do not link with avisynth.dll, so they can't directly access functions that are defined in the main Avisynth source code. Therefore, every important function in avisynth_c.h is either defined inline or (???).<br />
<br />
AVS_VideoFrame* AVSC_CC InvertNeg_get_frame(AVS_FilterInfo* fi, int n)<br />
<br />
This function is the main callback functions for our filter. When called it should return frame n. It returns this frame as a pointer to AVS_VideoFrame.<br />
<br />
AVSC_CC stands for Avisynth calling convention. Right now it is stdcall (it used to be cdecl when the C interface was exposes through seperate plugin). By using AVSC_CC you should be able to maintain source code compatibility when the calling convention changes. <br />
<br />
AVS_VideoFrame* src;<br />
AVS_VideoFrame* dst;<br />
int row_size, height, src_pitch, dst_pitch;<br />
const BYTE* srcp;<br />
BYTE* dstp;<br />
int x, y, p;<br />
<br />
Declaring all of the variables we will need '''must be done up front''' (for the C++ plugin this is not necessary). Doing it in between the code will get you strange compile errors.<br />
<br />
int planes[] = {AVS_PLANAR_Y, AVS_PLANAR_V, AVS_PLANAR_U};<br />
<br />
The plugin requires planar YUV data, so we need to process the planes. Note the constants (such as AVS_PLANAR_Y) are the same as the ones in the C++ inteface, except for the 'AVS_' in front of it.<br />
<br />
src = avs_get_frame(fi->child, n);<br />
<br />
"child" is a member of AVS_FilterInfo, of type AVS_Clip. It generally contains the clip that was passed into the filter. For our filter to produce frame n we need the corresponding frame of the input clip. If you need a different frame from the input, all you have to do is pass a different frame number get_frame.<br />
<br />
Note the functions (such as avs_get_frame) are similar as the ones in the C++ inteface, except for the 'avs_' in front of it.<br />
<br />
get_frame calls are usually intercepted by Avisynth's internal caching code, so the frame request may never actually reach the child filter (meaning ???). <br />
<br />
dst = avs_new_video_frame(fi->env, &fi->vi);<br />
<br />
The avs_new_video_frame function allocates space for a video frame of the supplied size. (In this case it will hold our filter's output.) The frame buffer is uninitialized raw memory.<br />
<br />
"env" is a member of AVS_FilterInfo which is a pointer to AVS_ScriptEnvironment. One instance of AVS_ScriptEnvironment is created for each AVS script.<br />
<br />
"vi" is another member of AVS_FilterInfo. It is a structure of type AVS_VideoInfo, which contains information about the clip (like frame size, frame rate, pixel format, audio sample rate, etc.). avs_new_video_frame uses the information in this structure to return a frame buffer of the appropriate size.<br />
<br />
Frame buffers are reused once all references to them go away. So usually memory won't need to be allocated from the heap. <br />
<br />
for (p=0; p<3; p++) {<br />
<br />
Loop over all planes.<br />
<br />
srcp = avs_get_read_ptr_p(src, planes[p]);<br />
dstp = avs_get_write_ptr_p(dst, planes[p]);<br />
<br />
All frame buffers are readable, but not all are writable.<br />
<br />
The rule about writability is this: A buffer is writable if and only if its reference count is one. In other words, you can only write to a buffer if no one else might be reading it. This rule guarantees that as long as you hold on to a video frame and don't write to it yourself, that frame will remain unchanged. Any buffer you get from avs_new_video_frame is guaranteed to be writable. However, frames you get from other clips via get_frame may not be writable, in which case avs_get_write_ptr will return a null pointer.<br />
<br />
There is an is_writable method which you can call to find out if a buffer is writable or not, and there's a avs_make_writable method (described below) to ensure that it is. <br />
<br />
src_pitch = avs_get_pitch_p(src, planes[p]);<br />
dst_pitch = avs_get_pitch_p(dst, planes[p]);<br />
<br />
The "pitch" of a frame buffer is the offset (in bytes) from the beginning of one scan line to the beginning of the next. The source and destination buffers won't necessarily have the same pitch.<br />
<br />
Buffers created by avs_new_video_frame are always double word (16-byte) aligned and always have a pitch that is a multiple of 16. <br />
<br />
row_size = avs_get_row_size_p(dst, planes[p]);<br />
<br />
The row size is the length of each row in bytes (not pixels). It's usually equal to the pitch or slightly less, but it may be significantly less if the frame in question has been through Crop.<br />
<br />
Since our source and destination frames have the same width and pixel format, they will always have the same row size. Thus I only need one row_size variable, and I could just as well have used dest instead of src. <br />
<br />
height = avs_get_height_p(dst, planes[p]);<br />
<br />
The height is the height in pixels. Again, for our filter this is the same for the source and the destination.<br />
<br />
for (y = 0; y < height; y++) {<br />
for (x = 0; x < row_size; x++) {<br />
dstp[x] = srcp[x] ^ 255;<br />
}<br />
srcp += src_pitch;<br />
dstp += dst_pitch;<br />
}<br />
}<br />
<br />
This is the code that does the actual work. The "srcp += src_pitch; dstp += dest_pitch;" idiom is a useful way of dealing with potentially differing pitches without too much grief.<br />
<br />
avs_release_video_frame(src);<br />
<br />
Once we are done with a video frame it needs to be released. Releasing a video frame does not actually delete it but decrements the reference count.<br />
<br />
return dst;<br />
<br />
GetFrame returns the newly-created frame.<br />
<br />
AVS_Value AVSC_CC Create_InvertNeg(AVS_ScriptEnvironment* env, AVS_Value args, void* user_data)<br />
<br />
In order to use our new filter, we need a scripting-language function which creates an instance of it. This is that function.<br />
<br />
Script functions written in C take three arguments. env contains the same ScriptEnvironment pointer that will later be passed to GetFrame. args contais all the arguments passed to the function by the script. user_data contains the void pointer which you passed to AddFunction (see below). Usually you won't need this.<br />
<br />
AVS_Value is a variant type which can hold any one of the following: a boolean value (true/false); an integer; a floating-point number; a string; a video clip; an array of AVS_Values; or nothing ("undefined"). You can test which one it is with the methods avs_is_bool, avs_is_int, avs_is_float, avs_is_string, avs_is_clip, avs_is_array, and avs_defined (which returns true if the AVS_Value is not "undefined"). You can get the value with avs_as_bool, avs_as_int, etc. for arrays, you can use the avs_array_size method to get the number of elements, and avs_array_elt get the elements themselves. For convenience, avs_is_float and avs_as_float will work with integers also. But boolean values are not treated as numeric (unlike C).<br />
<br />
The name "Create_InvertNeg" is arbitrary. This function will actually be known as "InvertNeg" in scripts, because that's the name we pass to avs_add_function below. <br />
<br />
AVS_Value v;<br />
<br />
v will serve as the return value.<br />
<br />
AVS_FilterInfo* fi;<br />
AVS_Clip* new_clip = avs_new_c_filter(env, &fi, avs_array_elt(args, 0), 1);<br />
<br />
"avs_new_c_filter" creates a new filter. AVS_Clip is an abstract type representing a filter. In this case it will represent our new filter. "env" is the current script environment. "fi" will be set to point to our filter AVS_FilterInfo which is the concrete representation of a C filter. We will modify this structure later. "avs_array_elt(args, 0)" is accessing the first value of args, which is generally the parent clip. The last parameter, is a boolean value "store_child". It should generally always be set to true.<br />
<br />
if (!avs_is_planar(&fi->vi) || !avs_is_yuv(&fi->vi)) {<br />
return avs_new_value_error("InvertNeg: planar YUV data only!");<br />
}<br />
<br />
Our filter will not work unless the video is stored as YUV planar. If this is not the case than an error is returned.<br />
<br />
fi->get_frame = InvertNeg_get_frame;<br />
<br />
Here we are setting the get_frame callback. There are other callbacks (like get_audio, set_cache_hints and get_parity), but since "store_child" was set to true we do not have to worry about implementing all of them. Just the ones we need.<br />
<br />
v = avs_new_value_clip(new_clip);<br />
<br />
The return value is then set to the new clip returned by avs_new_c_filter. avs_new_value_clip stores the clip in an AVS_Value which will be returned by our Create_InvertNeg. It also creates a new reference to the clip.<br />
<br />
avs_release_clip(new_clip);<br />
<br />
We must now release the clip returned by avs_new_c_filter. In the case of an error the clip is no longer needed. Otherwise a new reference is created to the clip with avs_new_value_clip so we must release the original reference.<br />
<br />
return v;<br />
<br />
Finally we return. "v" is either an error or the new clip.<br />
<br />
const char* AVSC_CC avisynth_c_plugin_init(AVS_ScriptEnvironment * env)<br />
<br />
This is the only function which gets exported from the DLL. It is called by the script function LoadCPlugin the first time this plugin in loaded in a particular script. If several scripts are open at once and more than one of them loads this plugin, avisynth_c_plugin_init may be called more than once with different ScriptEnvironments. Therefore:<br />
<br />
* You should not save the env parameter in a global variable.<br />
* If you need to initialize any static data, you should do it in DLLMain, not in this function. <br />
<br />
The main purpose of the avisynth_c_plugin_init function is to call avs_add_function.<br />
<br />
avs_add_function(env, "InvertNeg", "c", Create_InvertNeg, 0);<br />
<br />
As promised, we now call add_function to let Avisynth know of the existence of our filter. This function takes four arguments: the name of the new script function; the parameter-type string; the C function implementing the script function; and the user_data cookie.<br />
<br />
The parameter type string specifies the paramaters for the function. The return value is untyped. It consists of a series of letters specinging the parameter types with 'c' for clip, 'i' for integer, 's' for string, 'b' for boolean, and 'f' for float. In addition:<br />
<br />
* Any type can be followed with a '*' or '+' to indicate "zero or more" or "one or more" respectively. In this case all the matching arguments will be gathered into a sub-array. For example, if your type string is "is+f", then the integer argument will be args[0], the string arguments will be args[1][0], args[1][1], etc. (and there will be avs_array_size(args[1]) of them), and the float argument will be args[2].<br />
* '.' matches a single argument of any type. To match multiple arguments of any type, use ".*" or ".+".<br />
* Named arguments can be specified in [brackets] before the type. Named arguments are also optional arguments; if the user omits them, they will be of the undefined type instead of the type you specify. <br />
<br />
return "InvertNeg sample c-plugin";<br />
<br />
The return value of avisynth_c_plugin_init is a string which can contain any message you like, such as a notice identifying the version and author of the plugin. This string becomes the return value of LoadCPlugin, and will almost always be ignored. You can also just return 0 if you prefer.<br />
<br />
== As an in-place filter ==<br />
<br />
The InvertNeg filter could easily do its work in a single buffer, rather than copying from one buffer to another. Here's a new implementation of get_frame that does this:<br />
<br />
#include "avisynth_c.h"<br />
<br />
AVS_VideoFrame* AVSC_CC InvertNeg_get_frame(AVS_FilterInfo* fi, int n)<br />
{<br />
AVS_VideoFrame* src;<br />
int row_size, height, src_pitch;<br />
BYTE* srcp;<br />
int x, y, p;<br />
<br />
int planes[] = {AVS_PLANAR_Y, AVS_PLANAR_V, AVS_PLANAR_U};<br />
<br />
src = avs_get_frame(fi->child, n);<br />
avs_make_writable(fi->env, &src);<br />
<br />
for (p=0; p<3; p++) {<br />
srcp = avs_get_write_ptr_p(src, planes[p]);<br />
src_pitch = avs_get_pitch_p(src, planes[p]);<br />
row_size = avs_get_row_size_p(src, planes[p]);<br />
height = avs_get_height_p(src, planes[p]);<br />
<br />
for (y = 0; y < height; y++) {<br />
for (x = 0; x < row_size; x++) {<br />
srcp[x] = srcp[x] ^ 255; // or srcp[x] =^ 255;<br />
}<br />
srcp += src_pitch;<br />
}<br />
}<br />
<br />
return src;<br />
}<br />
<br />
AVS_Value AVSC_CC Create_InvertNeg(AVS_ScriptEnvironment* env, AVS_Value args, void* user_data)<br />
{<br />
AVS_Value v;<br />
AVS_FilterInfo* fi;<br />
AVS_Clip* new_clip = avs_new_c_filter(env, &fi, avs_array_elt(args, 0), 1);<br />
<br />
if (!avs_is_planar(&fi->vi) || !avs_is_yuv(&fi->vi)) {<br />
v = avs_new_value_error("InvertNeg: planar YUV data only!");<br />
} else {<br />
fi->get_frame = InvertNeg_get_frame;<br />
v = avs_new_value_clip(new_clip);<br />
}<br />
<br />
avs_release_clip(new_clip);<br />
return v;<br />
}<br />
<br />
const char* AVSC_CC avisynth_c_plugin_init(AVS_ScriptEnvironment * env)<br />
{<br />
avs_add_function(env, "InvertNeg", "c", Create_InvertNeg, 0);<br />
return "InvertNeg sample c-plugin";<br />
}<br />
<br />
The key difference between this version of the function and the original version is the presence of the avs_make_writable callback. This is necessary because this time "we don't know where that source frame has been." Someone else in the filter chain may be holding a reference to it, in which case we won't be allowed to write to it.<br />
<br />
== Old versions ==<br />
<br />
[http://www.kevina.org/avisynth_c/example.html Kevin's AviSynth C API Docs] is the documentation written for the deprecated avisynth_c.dll by Kevin Atkinson, in its original form.<br />
<br />
[[Category:C API]]</div>Adminhttp://avisynth.nl/index.php/Filter_SDK/CInvertNegFilter SDK/CInvertNeg2017-01-13T22:28:07Z<p>Admin: </p>
<hr />
<div>I'll start off with a complete, working Avisynth C plugin. It's called "InvertNeg", and it produces a photo-negative of the input clip.<br />
<br />
Here's InvertNeg.c:<br />
<br />
#include "avisynth_c.h"<br />
<br />
AVS_VideoFrame* AVSC_CC InvertNeg_get_frame(AVS_FilterInfo* fi, int n)<br />
{<br />
AVS_VideoFrame* src;<br />
AVS_VideoFrame* dst;<br />
int row_size, height, src_pitch, dst_pitch;<br />
const BYTE* srcp;<br />
BYTE* dstp;<br />
int x, y, p;<br />
<br />
int planes[] = {AVS_PLANAR_Y, AVS_PLANAR_V, AVS_PLANAR_U};<br />
<br />
src = avs_get_frame(fi->child, n);<br />
dst = avs_new_video_frame(fi->env, &fi->vi);<br />
<br />
for (p=0; p<3; p++) {<br />
srcp = avs_get_read_ptr_p(src, planes[p]);<br />
dstp = avs_get_write_ptr_p(dst, planes[p]);<br />
src_pitch = avs_get_pitch_p(src, planes[p]);<br />
dst_pitch = avs_get_pitch_p(dst, planes[p]);<br />
row_size = avs_get_row_size_p(dst, planes[p]);<br />
height = avs_get_height_p(dst, planes[p]);<br />
<br />
for (y = 0; y < height; y++) {<br />
for (x = 0; x < row_size; x++) {<br />
dstp[x] = srcp[x] ^ 255;<br />
}<br />
srcp += src_pitch;<br />
dstp += dst_pitch;<br />
}<br />
}<br />
<br />
avs_release_video_frame(src);<br />
return dst;<br />
}<br />
<br />
AVS_Value AVSC_CC Create_InvertNeg(AVS_ScriptEnvironment* env, AVS_Value args, void* user_data)<br />
{<br />
AVS_Value v;<br />
AVS_FilterInfo* fi;<br />
AVS_Clip* new_clip = avs_new_c_filter(env, &fi, avs_array_elt(args, 0), 1);<br />
<br />
if (!avs_is_planar(&fi->vi) || !avs_is_yuv(&fi->vi)) {<br />
return avs_new_value_error("InvertNeg: planar YUV data only!");<br />
}<br />
<br />
fi->get_frame = InvertNeg_get_frame;<br />
<br />
v = avs_new_value_clip(new_clip);<br />
<br />
avs_release_clip(new_clip);<br />
return v;<br />
}<br />
<br />
const char* AVSC_CC avisynth_c_plugin_init(AVS_ScriptEnvironment * env)<br />
{<br />
avs_add_function(env, "InvertNeg", "c", Create_InvertNeg, 0);<br />
return "InvertNeg sample c-plugin";<br />
}<br />
<br />
Link to avisynth.lib and when using the MSVC++ compiler add the definition file. Compile this file into a DLL named InvertNeg.dll. See [[Filter_SDK/Compiling_instructions|compiling instructions]]. Now create an Avisynth script which looks something like this:<br />
<br />
LoadCPlugin("d:\path\InvertNeg.dll")<br />
clip = BlankClip().ConvertToYV12()<br />
return clip.InvertNeg()<br />
<br />
=== Line by line breakdown ===<br />
<br />
Here's a line-by-line breakdown of InvertNeg.c:<br />
<br />
#include "avisynth_c.h"<br />
<br />
This header declares all the classes and miscellaneous constants that you might need when writing a plugin. All external plugins should #include it.<br />
<br />
External plugins do not link with avisynth.dll, so they can't directly access functions that are defined in the main Avisynth source code. Therefore, every important function in avisynth_c.h is either defined inline or declared as virtual (???). The virtual functions act as callbacks for external DLLs. <br />
<br />
AVS_VideoFrame* AVSC_CC InvertNeg_get_frame(AVS_FilterInfo* fi, int n)<br />
<br />
This function is the main callback functions for our filter. When called it should return frame n. It returns this frame as a pointer to AVS_VideoFrame.<br />
<br />
AVSC_CC stands for Avisynth calling convention. Right now it is stdcall (it used to be cdecl when the C interface was exposes through seperate plugin). By using AVSC_CC you should be able to maintain source code compatibility when the calling convention changes. <br />
<br />
AVS_VideoFrame* src;<br />
AVS_VideoFrame* dst;<br />
int row_size, height, src_pitch, dst_pitch;<br />
const BYTE* srcp;<br />
BYTE* dstp;<br />
int x, y, p;<br />
<br />
Declaring all of the variables we will need '''must be done up front''' (for the C++ plugin this is not necessary). Doing it in between the code will get you strange compile errors.<br />
<br />
int planes[] = {AVS_PLANAR_Y, AVS_PLANAR_V, AVS_PLANAR_U};<br />
<br />
The plugin requires planar YUV data, so we need to process the planes. Note the constants (such as AVS_PLANAR_Y) are the same as the ones in the C++ inteface, except for the 'AVS_' in front of it.<br />
<br />
src = avs_get_frame(fi->child, n);<br />
<br />
"child" is a member of AVS_FilterInfo, of type AVS_Clip. It generally contains the clip that was passed into the filter. For our filter to produce frame n we need the corresponding frame of the input clip. If you need a different frame from the input, all you have to do is pass a different frame number get_frame.<br />
<br />
Note the functions (such as avs_get_frame) are similar as the ones in the C++ inteface, except for the 'avs_' in front of it.<br />
<br />
get_frame calls are usually intercepted by Avisynth's internal caching code, so the frame request may never actually reach the child filter (meaning ???). <br />
<br />
dst = avs_new_video_frame(fi->env, &fi->vi);<br />
<br />
The avs_new_video_frame function allocates space for a video frame of the supplied size. (In this case it will hold our filter's output.) The frame buffer is uninitialized raw memory.<br />
<br />
"env" is a member of AVS_FilterInfo which is a pointer to AVS_ScriptEnvironment. One instance of AVS_ScriptEnvironment is created for each AVS script.<br />
<br />
"vi" is another member of AVS_FilterInfo. It is a structure of type AVS_VideoInfo, which contains information about the clip (like frame size, frame rate, pixel format, audio sample rate, etc.). avs_new_video_frame uses the information in this structure to return a frame buffer of the appropriate size.<br />
<br />
Frame buffers are reused once all references to them go away. So usually memory won't need to be allocated from the heap. <br />
<br />
for (p=0; p<3; p++) {<br />
<br />
Loop over all planes.<br />
<br />
srcp = avs_get_read_ptr_p(src, planes[p]);<br />
dstp = avs_get_write_ptr_p(dst, planes[p]);<br />
<br />
All frame buffers are readable, but not all are writable.<br />
<br />
The rule about writability is this: A buffer is writable if and only if its reference count is one. In other words, you can only write to a buffer if no one else might be reading it. This rule guarantees that as long as you hold on to a video frame and don't write to it yourself, that frame will remain unchanged. Any buffer you get from avs_new_video_frame is guaranteed to be writable. However, frames you get from other clips via get_frame may not be writable, in which case avs_get_write_ptr will return a null pointer.<br />
<br />
There is an is_writable method which you can call to find out if a buffer is writable or not, and there's a avs_make_writable method (described below) to ensure that it is. <br />
<br />
src_pitch = avs_get_pitch_p(src, planes[p]);<br />
dst_pitch = avs_get_pitch_p(dst, planes[p]);<br />
<br />
The "pitch" of a frame buffer is the offset (in bytes) from the beginning of one scan line to the beginning of the next. The source and destination buffers won't necessarily have the same pitch.<br />
<br />
Buffers created by avs_new_video_frame are always double word (16-byte) aligned and always have a pitch that is a multiple of 16. <br />
<br />
row_size = avs_get_row_size_p(dst, planes[p]);<br />
<br />
The row size is the length of each row in bytes (not pixels). It's usually equal to the pitch or slightly less, but it may be significantly less if the frame in question has been through Crop.<br />
<br />
Since our source and destination frames have the same width and pixel format, they will always have the same row size. Thus I only need one row_size variable, and I could just as well have used dest instead of src. <br />
<br />
height = avs_get_height_p(dst, planes[p]);<br />
<br />
The height is the height in pixels. Again, for our filter this is the same for the source and the destination.<br />
<br />
for (y = 0; y < height; y++) {<br />
for (x = 0; x < row_size; x++) {<br />
dstp[x] = srcp[x] ^ 255;<br />
}<br />
srcp += src_pitch;<br />
dstp += dst_pitch;<br />
}<br />
}<br />
<br />
This is the code that does the actual work. The "srcp += src_pitch; dstp += dest_pitch;" idiom is a useful way of dealing with potentially differing pitches without too much grief.<br />
<br />
avs_release_video_frame(src);<br />
<br />
Once we are done with a video frame it needs to be released. Releasing a video frame does not actually delete it but decrements the reference count.<br />
<br />
return dst;<br />
<br />
GetFrame returns the newly-created frame.<br />
<br />
AVS_Value AVSC_CC Create_InvertNeg(AVS_ScriptEnvironment* env, AVS_Value args, void* user_data)<br />
<br />
In order to use our new filter, we need a scripting-language function which creates an instance of it. This is that function.<br />
<br />
Script functions written in C take three arguments. env contains the same ScriptEnvironment pointer that will later be passed to GetFrame. args contais all the arguments passed to the function by the script. user_data contains the void pointer which you passed to AddFunction (see below). Usually you won't need this.<br />
<br />
AVS_Value is a variant type which can hold any one of the following: a boolean value (true/false); an integer; a floating-point number; a string; a video clip; an array of AVS_Values; or nothing ("undefined"). You can test which one it is with the methods avs_is_bool, avs_is_int, avs_is_float, avs_is_string, avs_is_clip, avs_is_array, and avs_defined (which returns true if the AVS_Value is not "undefined"). You can get the value with avs_as_bool, avs_as_int, etc. for arrays, you can use the avs_array_size method to get the number of elements, and avs_array_elt get the elements themselves. For convenience, avs_is_float and avs_as_float will work with integers also. But boolean values are not treated as numeric (unlike C).<br />
<br />
The name "Create_InvertNeg" is arbitrary. This function will actually be known as "InvertNeg" in scripts, because that's the name we pass to avs_add_function below. <br />
<br />
AVS_Value v;<br />
<br />
v will serve as the return value.<br />
<br />
AVS_FilterInfo* fi;<br />
AVS_Clip* new_clip = avs_new_c_filter(env, &fi, avs_array_elt(args, 0), 1);<br />
<br />
"avs_new_c_filter" creates a new filter. AVS_Clip is an abstract type representing a filter. In this case it will represent our new filter. "env" is the current script environment. "fi" will be set to point to our filter AVS_FilterInfo which is the concrete representation of a C filter. We will modify this structure later. "avs_array_elt(args, 0)" is accessing the first value of args, which is generally the parent clip. The last parameter, is a boolean value "store_child". It should generally always be set to true.<br />
<br />
if (!avs_is_planar(&fi->vi) || !avs_is_yuv(&fi->vi)) {<br />
return avs_new_value_error("InvertNeg: planar YUV data only!");<br />
}<br />
<br />
Our filter will not work unless the video is stored as YUV planar. If this is not the case than an error is returned.<br />
<br />
fi->get_frame = InvertNeg_get_frame;<br />
<br />
Here we are setting the get_frame callback. There are other callbacks (like get_audio, set_cache_hints and get_parity), but since "store_child" was set to true we do not have to worry about implementing all of them. Just the ones we need.<br />
<br />
v = avs_new_value_clip(new_clip);<br />
<br />
The return value is then set to the new clip returned by avs_new_c_filter. avs_new_value_clip stores the clip in an AVS_Value which will be returned by our Create_InvertNeg. It also creates a new reference to the clip.<br />
<br />
avs_release_clip(new_clip);<br />
<br />
We must now release the clip returned by avs_new_c_filter. In the case of an error the clip is no longer needed. Otherwise a new reference is created to the clip with avs_new_value_clip so we must release the original reference.<br />
<br />
return v;<br />
<br />
Finally we return. "v" is either an error or the new clip.<br />
<br />
const char* AVSC_CC avisynth_c_plugin_init(AVS_ScriptEnvironment * env)<br />
<br />
This is the only function which gets exported from the DLL. It is called by the script function LoadCPlugin the first time this plugin in loaded in a particular script. If several scripts are open at once and more than one of them loads this plugin, avisynth_c_plugin_init may be called more than once with different ScriptEnvironments. Therefore:<br />
<br />
* You should not save the env parameter in a global variable.<br />
* If you need to initialize any static data, you should do it in DLLMain, not in this function. <br />
<br />
The main purpose of the avisynth_c_plugin_init function is to call avs_add_function.<br />
<br />
avs_add_function(env, "InvertNeg", "c", Create_InvertNeg, 0);<br />
<br />
As promised, we now call add_function to let Avisynth know of the existence of our filter. This function takes four arguments: the name of the new script function; the parameter-type string; the C function implementing the script function; and the user_data cookie.<br />
<br />
The parameter type string specifies the paramaters for the function. The return value is untyped. It consists of a series of letters specinging the parameter types with 'c' for clip, 'i' for integer, 's' for string, 'b' for boolean, and 'f' for float. In addition:<br />
<br />
* Any type can be followed with a '*' or '+' to indicate "zero or more" or "one or more" respectively. In this case all the matching arguments will be gathered into a sub-array. For example, if your type string is "is+f", then the integer argument will be args[0], the string arguments will be args[1][0], args[1][1], etc. (and there will be avs_array_size(args[1]) of them), and the float argument will be args[2].<br />
* '.' matches a single argument of any type. To match multiple arguments of any type, use ".*" or ".+".<br />
* Named arguments can be specified in [brackets] before the type. Named arguments are also optional arguments; if the user omits them, they will be of the undefined type instead of the type you specify. <br />
<br />
return "InvertNeg sample c-plugin";<br />
<br />
The return value of avisynth_c_plugin_init is a string which can contain any message you like, such as a notice identifying the version and author of the plugin. This string becomes the return value of LoadCPlugin, and will almost always be ignored. You can also just return 0 if you prefer.<br />
<br />
== As an in-place filter ==<br />
<br />
The InvertNeg filter could easily do its work in a single buffer, rather than copying from one buffer to another. Here's a new implementation of get_frame that does this:<br />
<br />
#include "avisynth_c.h"<br />
<br />
AVS_VideoFrame* AVSC_CC InvertNeg_get_frame(AVS_FilterInfo* fi, int n)<br />
{<br />
AVS_VideoFrame* src;<br />
int row_size, height, src_pitch;<br />
BYTE* srcp;<br />
int x, y, p;<br />
<br />
int planes[] = {AVS_PLANAR_Y, AVS_PLANAR_V, AVS_PLANAR_U};<br />
<br />
src = avs_get_frame(fi->child, n);<br />
avs_make_writable(fi->env, &src);<br />
<br />
for (p=0; p<3; p++) {<br />
srcp = avs_get_write_ptr_p(src, planes[p]);<br />
src_pitch = avs_get_pitch_p(src, planes[p]);<br />
row_size = avs_get_row_size_p(src, planes[p]);<br />
height = avs_get_height_p(src, planes[p]);<br />
<br />
for (y = 0; y < height; y++) {<br />
for (x = 0; x < row_size; x++) {<br />
srcp[x] = srcp[x] ^ 255; // or srcp[x] =^ 255;<br />
}<br />
srcp += src_pitch;<br />
}<br />
}<br />
<br />
return src;<br />
}<br />
<br />
AVS_Value AVSC_CC Create_InvertNeg(AVS_ScriptEnvironment* env, AVS_Value args, void* user_data)<br />
{<br />
AVS_Value v;<br />
AVS_FilterInfo* fi;<br />
AVS_Clip* new_clip = avs_new_c_filter(env, &fi, avs_array_elt(args, 0), 1);<br />
<br />
if (!avs_is_planar(&fi->vi) || !avs_is_yuv(&fi->vi)) {<br />
v = avs_new_value_error("InvertNeg: planar YUV data only!");<br />
} else {<br />
fi->get_frame = InvertNeg_get_frame;<br />
v = avs_new_value_clip(new_clip);<br />
}<br />
<br />
avs_release_clip(new_clip);<br />
return v;<br />
}<br />
<br />
const char* AVSC_CC avisynth_c_plugin_init(AVS_ScriptEnvironment * env)<br />
{<br />
avs_add_function(env, "InvertNeg", "c", Create_InvertNeg, 0);<br />
return "InvertNeg sample c-plugin";<br />
}<br />
<br />
The key difference between this version of the function and the original version is the presence of the avs_make_writable callback. This is necessary because this time "we don't know where that source frame has been." Someone else in the filter chain may be holding a reference to it, in which case we won't be allowed to write to it.<br />
<br />
== Old versions ==<br />
<br />
[http://www.kevina.org/avisynth_c/example.html Kevin's AviSynth C API Docs] is the documentation written for the deprecated avisynth_c.dll by Kevin Atkinson, in its original form.<br />
<br />
[[Category:C API]]</div>Adminhttp://avisynth.nl/index.php/Filter_SDK/CMergeFilter SDK/CMerge2017-01-13T22:17:29Z<p>Admin: </p>
<hr />
<div>Here is another working Avisynth C plugin. It's called "Merge", and it merges two clips according to a weight.<br />
<br />
Here's Merge.c:<br />
<br />
#include <stdlib.h><br />
#include "avisynth_c.h"<br />
<br />
typedef struct Merge {<br />
AVS_Clip* clip2;<br />
double weight;<br />
} Merge;<br />
<br />
AVS_VideoFrame* AVSC_CC Merge_get_frame(AVS_FilterInfo* fi, int n)<br />
{<br />
Merge* params = (Merge*) fi->user_data;<br />
<br />
AVS_VideoFrame* src = avs_get_frame(fi->child, n);<br />
const BYTE* srcp = avs_get_read_ptr(src);<br />
int src_pitch = avs_get_pitch(src);<br />
<br />
AVS_VideoFrame* src2 = avs_get_frame(params->clip2, n);<br />
const BYTE* srcp2 = avs_get_read_ptr(src2);<br />
int src2_pitch = avs_get_pitch(src2);<br />
<br />
AVS_VideoFrame* dst = avs_new_video_frame(fi->env, &fi->vi);<br />
BYTE* dstp = avs_get_write_ptr(dst);<br />
int dst_pitch = avs_get_pitch(dst);<br />
int dst_rowsize = avs_get_row_size(dst); // in bytes!<br />
int dst_height = avs_get_height(dst);<br />
<br />
int x, y, ch_tot;<br />
double w;<br />
<br />
if (avs_is_rgb32(&fi->vi))<br />
ch_tot = 4;<br />
else // rgb24<br />
ch_tot = 3;<br />
<br />
w = params->weight;<br />
<br />
for (y=0; y<dst_height; ++y) {<br />
for (x=0; x<dst_rowsize; x+=ch_tot) {<br />
dstp[x] = (int)((1-w)*srcp[x] + w*srcp2[x]+0.5); // B<br />
dstp[x+1] = (int)((1-w)*srcp[x+1] + w*srcp2[x+1]+0.5); // G<br />
dstp[x+2] = (int)((1-w)*srcp[x+2] + w*srcp2[x+2]+0.5); // R<br />
}<br />
srcp += src_pitch;<br />
srcp2 += src2_pitch;<br />
dstp += dst_pitch;<br />
}<br />
<br />
avs_release_frame(src);<br />
avs_release_frame(src2);<br />
<br />
return dst;<br />
}<br />
<br />
void AVSC_CC free_Merge(AVS_FilterInfo* fi)<br />
{<br />
Merge* params = (Merge*) fi->user_data;<br />
avs_release_clip(params->clip2);<br />
free(params);<br />
}<br />
<br />
AVS_Value AVSC_CC create_Merge(AVS_ScriptEnvironment* env, AVS_Value args, void* user_data)<br />
{<br />
AVS_Value v;<br />
AVS_Value tmp;<br />
AVS_FilterInfo* fi;<br />
const AVS_VideoInfo* vi2;<br />
<br />
AVS_Clip* new_clip = avs_new_c_filter(env, &fi, avs_array_elt(args, 0), 1);<br />
<br />
Merge *params = (Merge*)malloc(sizeof(Merge));<br />
if (!params)<br />
return avs_void;<br />
<br />
if (!avs_is_rgb(&fi->vi)) {<br />
return avs_new_value_error("Input video must be in RGB format!");<br />
}<br />
<br />
tmp = avs_array_elt(args, 1);<br />
if (avs_defined(tmp)) {<br />
params->clip2 = avs_take_clip(tmp, env);<br />
vi2 = avs_get_video_info(params->clip2);<br />
if (!avs_has_video(vi2)) {<br />
return avs_new_value_error("Second clip must be a video clip!");<br />
} <br />
else if (!avs_is_color_space(vi2, fi->vi.pixel_type))<br />
{<br />
return avs_new_value_error("Second video must have the same pixel-type as the first clip!");<br />
} <br />
else if (vi2->width != fi->vi.width || vi2->height != fi->vi.height)<br />
{<br />
return avs_new_value_error("Input and second clip sizes must match!");<br />
}<br />
} else {<br />
return avs_new_value_error("Second clip is missing!");<br />
}<br />
<br />
tmp = avs_array_elt(args, 2);<br />
if (avs_defined(tmp)) {<br />
params->weight = avs_as_float(tmp);<br />
if ((params->weight<0.0f) || (params->weight>1.0f)) {<br />
return avs_new_value_error("Make sure that '0.0 <= weight <= 1.0'!");<br />
}<br />
} else {<br />
params->weight = 0.5f; // default value<br />
}<br />
<br />
fi->user_data = (void*) params;<br />
fi->get_frame = Merge_get_frame;<br />
fi->free_filter = free_Merge;<br />
<br />
v = avs_new_value_clip(new_clip);<br />
<br />
avs_release_clip(new_clip);<br />
return v;<br />
}<br />
<br />
const char* AVSC_CC avisynth_c_plugin_init(AVS_ScriptEnvironment* env)<br />
{<br />
avs_add_function(env, "Merge", "cc[weight]f", create_Merge, 0);<br />
return "Merge sample C plugin";<br />
}<br />
<br />
== Line by line breakdown ==<br />
<br />
Here's a line-by-line breakdown of Merge.c. I won't repeat the comments in the previous example InvertNeg.c, so read that first if needed. The declaration of the class is as follows <br />
<br />
#include <stdlib.h> // free, malloc<br />
<br />
This header defines free and malloc which we will need later on.<br />
<br />
Note one could also include windows.h instead. However this gives a 'warning C4005: 'EXTERN_C' : macro redefinition' when compiling with MSVC++. I guess this needs to be fixed avisynth_c.h.<br />
<br />
typedef struct Merge {<br />
AVS_Clip* clip2;<br />
double weight;<br />
} Merge; // this name (ie Merge) is an alias for 'struct Merge'<br />
<br />
In C we don't have classes. We will use a structure to declare our parameter variables (clip2 and weight in this example). The members of a structure are public by default (C++ plugins: recall that in a C++ class they are private by default).<br />
<br />
typedef allows you to declare instances of a structure without using keyword "struct", since the second 'Merge' is an alias for 'struct Merge'. For more information have a look [http://stackoverflow.com/questions/1675351/typedef-struct-vs-struct-definitions here] and [http://www.cs.usfca.edu/~wolber/SoftwareDev/C/CStructs.htm here].<br />
<br />
AVS_VideoFrame* AVSC_CC Merge_get_frame(AVS_FilterInfo* fi, int n)<br />
<br />
This method is called to make our filter produce frame n of its output.<br />
<br />
Merge* params = (Merge*) fi->user_data;<br />
<br />
This fetches instance parameters.<br />
<br />
AVS_VideoFrame* src = avs_get_frame(fi->child, n);<br />
const BYTE* srcp = avs_get_read_ptr(src);<br />
int src_pitch = avs_get_pitch(src);<br />
<br />
AVS_VideoFrame* src2 = avs_get_frame(params->clip2, n);<br />
const BYTE* srcp2 = avs_get_read_ptr(src2);<br />
int src2_pitch = avs_get_pitch(src2);<br />
<br />
Gives read pointers to both our input clips.<br />
<br />
AVS_VideoFrame* dst = avs_new_video_frame(fi->env, &fi->vi);<br />
<br />
Creates a new frame according to what we set up in create_Merge.<br />
<br />
BYTE* dstp = avs_get_write_ptr(dst);<br />
int dst_pitch = avs_get_pitch(dst);<br />
int dst_rowsize = avs_get_row_size(dst); // in bytes!<br />
int dst_height = avs_get_height(dst);<br />
<br />
Gives a write pointer to our output clips.<br />
<br />
if (avs_is_rgb32(&fi->vi))<br />
ch_tot = 4;<br />
else // rgb24<br />
ch_tot = 3;<br />
<br />
This filter requires RGB24 or RGB32. ch_tot is the number of channels.<br />
<br />
w = params->weight;<br />
<br />
The variable w is the input parameter weight. We will use that for better readability.<br />
<br />
for (y=0; y<dst_height; ++y) {<br />
for (x=0; x<dst_rowsize; x+=ch_tot) {<br />
dstp[x] = (int)((1-w)*srcp[x] + w*srcp2[x]+0.5); // B<br />
dstp[x+1] = (int)((1-w)*srcp[x+1] + w*srcp2[x+1]+0.5); // G<br />
dstp[x+2] = (int)((1-w)*srcp[x+2] + w*srcp2[x+2]+0.5); // R<br />
}<br />
srcp += src_pitch;<br />
srcp2 += src2_pitch;<br />
dstp += dst_pitch;<br />
}<br />
<br />
This code does the actual work. It blends the red, green and blue channels together.<br />
<br />
avs_release_frame(src);<br />
avs_release_frame(src2);<br />
<br />
Once we are done with the video frames of both clips they need to be released. Releasing a video frame does not actually delete it but decrements the reference count. (C++ plugins: recall this happens automatically when returning the destination frame.)<br />
<br />
return dst;<br />
<br />
GetFrame returns the newly-created frame.<br />
<br />
void AVSC_CC free_Merge(AVS_FilterInfo* fi)<br />
{<br />
Merge* params = (Merge*) fi->user_data;<br />
avs_release_clip(params->clip2);<br />
free(params);<br />
}<br />
<br />
There are no constructors and deconstructors in C, but we need something to release memory. This is done by the function free_Merge which is defined above.<br />
<br />
AVS_Value AVSC_CC create_Merge(AVS_ScriptEnvironment* env, AVS_Value args, void* user_data)<br />
<br />
In order to use our new filter, we need a scripting-language function which creates an instance of it. This is that function. <br />
<br />
AVS_Clip* new_clip = avs_new_c_filter(env, &fi, avs_array_elt(args, 0), 1);<br />
<br />
The new clip parameters are initialized from the input clip. fi is filled in according to the parent clip's parameters. You may modify fi afterwards to change the returned clip's parameters.<br />
<br />
Merge *params = (Merge*)malloc(sizeof(Merge));<br />
<br />
Allocates memory and create a new instance of params.<br />
<br />
if (!params)<br />
return avs_void;<br />
<br />
When failed to allocate memory, return avs_void.<br />
<br />
if (!avs_is_rgb(&fi->vi)) {<br />
return avs_new_value_error("Input video must be in RGB format!");<br />
}<br />
<br />
As stated above there are no constructors and deconstructors in C, so the necessary checks on the input parameters must be done here. This is before setting the get_frame callback.<br />
<br />
tmp = avs_array_elt(args, 1);<br />
if (avs_defined(tmp)) {<br />
params->clip2 = avs_take_clip(tmp, env);<br />
<br />
The second input parameter should be the second clip. It is actually an AVS_Value, and avs_take_clip converts it to a clip. The parser will check that tmp contains a clip (as specified in avs_add_function), so we know it contains a clip at this stage. Below we will check the clip contains video.<br />
<br />
vi2 = avs_get_video_info(params->clip2);<br />
if (!avs_has_video(vi2)) {<br />
return avs_new_value_error("Second clip must be a video clip!");<br />
}<br />
<br />
If it has no video, an error is returned.<br />
<br />
else if (!avs_is_color_space(vi2, fi->vi.pixel_type))<br />
{<br />
return avs_new_value_error("Second video must have the same pixel-type as the first clip!");<br />
}<br />
<br />
If it has video, but the colorspace (that is the pixeltype) of the second clip is not the same as the one of the first clip, an error is returned.<br />
<br />
else if (vi2->width != fi->vi.width || vi2->height != fi->vi.height)<br />
{<br />
return avs_new_value_error("Input and second clip sizes must match!");<br />
}<br />
<br />
If the colorspace is the same, but the dimensions of both clips are different, an error is returned.<br />
<br />
} else {<br />
return avs_new_value_error("Second clip is missing!");<br />
}<br />
<br />
If the second clip is missing, an error is returned. Although strictly not necessary as explained above, since this check is done by the parser.<br />
<br />
tmp = avs_array_elt(args, 2);<br />
if (avs_defined(tmp)) {<br />
params->weight = avs_as_float(tmp);<br />
<br />
The third input parameter should be the weight. It is actually an AVS_Value,<br />
<br />
if ((params->weight<0.0f) || (params->weight>1.0f)) {<br />
return avs_new_value_error("Make sure that '0.0 <= weight <= 1.0'!");<br />
}<br />
<br />
The weight should be in [0,1], if not an error is returned.<br />
<br />
} else {<br />
params->weight = 0.5; // default value<br />
}<br />
<br />
There are no default values in the C API, so they are set explicitly. Here the weight is set to 0.5 by default.<br />
<br />
fi->user_data = (void*) params;<br />
<br />
Store updated params (members of our structure Merge).<br />
<br />
fi->get_frame = Merge_get_frame;<br />
<br />
Here we set up FilterInfo:<br />
* For audio-only filters you need to implement get_audio. The remaining two members that can be implemented are set_cache_hints and get_parity.<br />
* For source filters, avs_new_c_filter should be called as avs_new_c_filter(env, &fi, avs_void, 0). Thus with the last parameter, store_child, set to false. In this case all four members (get_frame, get_audio, set_cache_hints and get_parity) should be implemented.<br />
<br />
fi->free_filter = free_Merge;<br />
<br />
Clean up everything.<br />
<br />
v = avs_new_value_clip(new_clip);<br />
<br />
The return <br />
value is then set to the new clip returned by avs_new_c_filter.<br />
<br />
avs_release_clip(new_clip);<br />
<br />
We must now release the clip returned by avs_new_c_filter. In the case of an error the clip is no longer needed. Otherwise a new reference is created to the clip with avs_new_value_clip so we must release the original reference.<br />
<br />
return v;<br />
<br />
Finally we return the new clip.<br />
<br />
[[Category:C API]]</div>Adminhttp://avisynth.nl/index.php/User:KyalUser:Kyal2017-01-13T17:51:09Z<p>Admin: added comment</p>
<hr />
<div>I removed your edit. PANADV (Panasonic DV codec) is the worst dv codec out there. It can only output RGB24. Use Cedocida codec instead, it's way more flexible. [[User:Admin|Admin]] 18:51, 13 January 2017 (CET)</div>Adminhttp://avisynth.nl/index.php/FAQ_common_errorsFAQ common errors2017-01-13T17:49:09Z<p>Admin: Reverted edits by Kyal (talk) to last revision by Admin</p>
<hr />
<div>|[[AviSynth_FAQ | Main Page]] | [[FAQ_general_info | General Info]] | [[FAQ_loading_clips | Loading Clips]] | [[FAQ_frameserving | Loading Scripts]] | '''Common Error Messages''' | [[FAQ_different_types_content | Processing Different Content]] | [[FAQ_YV12 | Dealing with YV12]] | [[FAQ_using_virtualdub_plugins | Processing with Virtualdub Plugins]] |<br />
<br />
<br />
=== I got the message "LoadPlugin: unable to load "xxx" is not an AviSynth 1.0/AviSynth 2.0 plugin"? ===<br />
<br />
You are using a plugin which is not compatiable with that version of AviSynth. As explained [[FAQ_general_info#avs_comp|here]], plugins compiled for AviSynth v2.5 are not compatible with AviSynth v1.0x/v2.0x and vice versa.<br />
<br />
<br />
=== When frameserving I got the following message: "Script error, there is no function named "xxx (some filter)""? ===<br />
<br />
You probably installed/registered a version of AviSynth which doesn't contain that specific filter. Make sure that there are no other versions floating around on your hard disk (there's a possibility that a version will be registered while it is not in your system directory). Make sure that the latest stable version is registered, see also [[FAQ_general_info#avs_version_nr|here]].<br />
<br />
There is also the possibility that you are missing the filter's dll, such as "Script error, there is not function named "TDecimate"". In order to solve this, just make sure that you have the TIVTC.dll in your plugins folder.<br />
<br />
<br />
=== I installed AviSynth and got the following error message: "Couldn't locate decompressor for format 'YV12' (unknown)."? ===<br />
<br />
Install a codec which supports YV12. DivX5 or one of the recent [http://www.xvid.org/ XviD builds of Koepi] or [http://forum.doom9.org/showthread.php?s=&threadid=56972 Helix YUV codec] or some other (ffvfw, ffdshow). If that still doesn't work, modify your registry as explained in the next question.<br />
<br />
<br />
=== When encoding I got the following error "ACM failed to suggest a compatible PCM format"? ===<br />
<br />
This error means that you are using AviSource to open your AVI file, but you don't have an ACM codec to decode the audio stream. The most common problem is that your audio is an AC3 or a MP3 stream, but you don't have the corresponding ACM codec installed. It can also happen that your audio is a "crippled" (that is, with an incorrect header) MP3 [http://forums.virtualdub.org/index.php?act=ST&f=4&t=802&hl=0055] [http://forums.virtualdub.org/index.php?act=ST&f=3&t=10931&hl=unknown%20tag%200055&st=15] [http://forum.doom9.org/showthread.php?t=94760].<br />
<br />
There are several solutions for this problem:<br />
<br />
* Get the proper ACM codec. You can use [http://www.headbands.com/gspot/ GSpot] to find out which audio stream you are dealing with. The needed ACM codecs can be found [[Importing_media|here]].<br />
* Demux your audio with an application like [http://www.alexander-noe.com/video/amg/ AVI-Mux GUI] or [[VirtualDub]], and import your audio with a specific plugin. See also [[FAQ_loading_clips|here]].<br />
* Use [[DirectShowSource]] to open the audio. Install [http://avisynth.org/mediawiki/Ffdshow ffdshow] and enable the specific audio format in the "Audio Decoder Properties" tab. Create the following script:<br />
<br />
Vid = AviSource("Blah.avi", audio=false)<br />
Aud = DirectShowSource("Blah.avi", video=false)<br />
AudioDub(Vid, Aud)<br />
<br />
<br />
=== When encoding I got the following error: "framesize xyz x 56 not supported"? ===<br />
<br />
This usually is an indicator of a script error, where the input is actually the error message being displayed. Here, xyz is the length of the error message text and 56 is the height (xyz will vary depending on the error message whilst the height will always be 56 pixels). Your encoder is seeing the error message as an RGB32 input source and hence the error. Opening the script with WMP or VirtualDub should display the error message. Fix the error in the script and retry to encode.<br />
<br />
<br />
=== When frameserving I got the following message: "AVISource: couldn't locate a decompressor for fourcc (...)"? ===<br />
<br />
Usually, this error message shows up if you don't have the right VfW codec installed for decoding your video. Get [http://www.headbands.com/gspot/ Gspot] to find out which codec you need. Get, for example, [[Xvid]] for your MPEG-4 ASP clips and [http://forum.doom9.org/showthread.php?t=94458 Cedocida codec] for your DV clips. If you have problems finding the right one, ask around on the video forums.<br />
<br />
But it can also show up if you call [[AviSource]] too many times. The dll for the decompression codec is loaded separately for every [[AviSource]] call. Eventually an OS-imposed limit is reached, the codec can't be loaded and you get that error message. More discussion can be found [http://forum.doom9.org/showthread.php?t=131687 here]. A good solution is to use a number of scripts (keeping each below the problematic limit of avi calls) and encode them separately, and join them afterwards in some application.<br />
<br />
<br />
=== When frameserving I got the following message: "DirectShowSource: Could not open as video or audio <br> Video Returned: "DirectShowSource: the filter graph manager won't talk to me""? ===<br />
<br />
This is a common error that occurs when DirectShow isn't able to deliver any format that is readable to AviSynth. Try creating a filter graph manually. See if you are able to construct a filter graph that delivers any output that AviSynth can open. If not, you might need to download additional DirectShow filters that can deliver correct material. If you can play the graph in [[GraphEdit]], make sure to remove the video and audio renderers, before saving the graph and opening it in AviSynth. Some examples can be found [[Importing_media#graph|here]].<br />
<br />
<br />
=== I am trying to load a script that has a path name with a mix of japanese characters and ASCII test. I got an import error and the path that is displayed has some strange characters (not the japanese characters)?===<br />
<br />
AviSynth has problems with non-ANSI chars on filenames. It only supports [http://en.wikipedia.org/wiki/ASCII 8 bit character ANSI text]. Some discussion about this: [http://forum.doom9.org/showthread.php?t=110467] and [http://forum.doom9.org/showthread.php?t=131419].<br />
<br />
<br />
=== When frameserving I got the following message: "CAVIStreamSynth: System exception - Access Violation at 0x0, reading from 0x0"? ===<br />
<br />
Access Violation at 0x0, reading from 0x0 is usually caused by running out of memory (memory leak ???). It can be caused by a plugin which is leaking memory, but apparently it can also be caused by other things (codecs, applications ???) [http://forum.doom9.org/showthread.php?t=123195] [http://forum.doom9.org/showthread.php?t=128403]. Add SetMemoryMax(...) at the beginning of the script. If that doesn't help, report the issue in the doom9 forums, and we will try to help finding the cause of it.<br />
<br />
<br />
=== When frameserving I got a message similar to: "Avisynth open failure: Script error: Invalid arguments to function "xxx (some filter)" (I:\Video.avs, line 5)"? ===<br />
<br />
It means you are passing incorrect arguments (that is of the correct type) to your script, filter or plugin. For example:<br />
<br />
# passing a float (2.0), while Loop expects an int:<br />
Loop(clip, 2.0)<br />
<br />
# passing three clips to Overlay instead of two:<br />
AviSource("anime_raw.avi")<br />
karaoke = AviSource("karaoke.avi")<br />
Trim(0,999) + Trim(1000,1030).Overlay(last, karaoke, mask=sign.ShowAlpha()) + Trim(1031,0)<br />
# last should be omitted as argument to Overlay<br />
<br />
# implicit 'last' not defined<br />
v = AviSource("myvid.avi")<br />
Trim(100, 199)<br />
# need to use v.Trim(...) here<br />
<br />
So make sure the passed arguments are of the correct type and read the corresponding documentation if necessary.<br />
<br />
<br />
=== I got the message 'Avisynth open failure avisource autodetect: couldn't open file "xxx (some file)" error code 2' ===<br />
<br />
Error code 2 means ERROR_FILE_NOT_FOUND (thus the filename and or path is not correct). Check the filename and path.<br />
<br />
<br />
=== I got the message 'AVI Import Filter error' when running any script ===<br />
<br />
This means there went something wrong with the installation. De-install and install AviSynth again. Read the corresponding readme and check whether you need to install something in addition.<br />
When you installed AviSynth manually (copied it over an old version for example), it might be that you don't have the correct Microsoft Visual C++ Redistributable package installed.<br />
<br />
<br />
|[[AviSynth_FAQ | Main Page]] | [[FAQ_general_info | General Info]] | [[FAQ_loading_clips | Loading clips]] | [[FAQ_frameserving | Loading Scripts]] | '''Common Error Messages''' | [[FAQ_different_types_content | Processing Different Content]] | [[FAQ_YV12 | Dealing with YV12]] | [[FAQ_using_virtualdub_plugins | Processing with Virtualdub Plugins]] |<br />
<br />
[[Category:AviSynth FAQ]]</div>Adminhttp://avisynth.nl/index.php/Filter_SDK/CInvertNegFilter SDK/CInvertNeg2017-01-12T22:31:26Z<p>Admin: </p>
<hr />
<div>I'll start off with a complete, working Avisynth C plugin. It's called "InvertNeg", and it produces a photo-negative of the input clip.<br />
<br />
Here's InvertNeg.c:<br />
<br />
#include "avisynth_c.h"<br />
<br />
AVS_VideoFrame* AVSC_CC InvertNeg_get_frame(AVS_FilterInfo* fi, int n)<br />
{<br />
AVS_VideoFrame* src;<br />
AVS_VideoFrame* dst;<br />
int row_size, height, src_pitch, dst_pitch;<br />
const BYTE* srcp;<br />
BYTE* dstp;<br />
int x, y, p;<br />
<br />
int planes[] = {AVS_PLANAR_Y, AVS_PLANAR_V, AVS_PLANAR_U};<br />
<br />
src = avs_get_frame(fi->child, n);<br />
dst = avs_new_video_frame(fi->env, &fi->vi);<br />
<br />
for (p=0; p<3; p++) {<br />
srcp = avs_get_read_ptr_p(src, planes[p]);<br />
dstp = avs_get_write_ptr_p(dst, planes[p]);<br />
src_pitch = avs_get_pitch_p(src, planes[p]);<br />
dst_pitch = avs_get_pitch_p(dst, planes[p]);<br />
row_size = avs_get_row_size_p(dst, planes[p]);<br />
height = avs_get_height_p(dst, planes[p]);<br />
<br />
for (y = 0; y < height; y++) {<br />
for (x = 0; x < row_size; x++) {<br />
dstp[x] = srcp[x] ^ 255;<br />
}<br />
srcp += src_pitch;<br />
dstp += dst_pitch;<br />
}<br />
}<br />
<br />
avs_release_video_frame(src);<br />
return dst;<br />
}<br />
<br />
AVS_Value AVSC_CC Create_InvertNeg(AVS_ScriptEnvironment* env, AVS_Value args, void* user_data)<br />
{<br />
AVS_Value v;<br />
AVS_FilterInfo* fi;<br />
AVS_Clip* new_clip = avs_new_c_filter(env, &fi, avs_array_elt(args, 0), 1);<br />
<br />
if (!avs_is_planar(&fi->vi) || !avs_is_yuv(&fi->vi)) {<br />
v = avs_new_value_error("InvertNeg: planar YUV data only!");<br />
} else {<br />
fi->get_frame = InvertNeg_get_frame;<br />
v = avs_new_value_clip(new_clip);<br />
}<br />
<br />
avs_release_clip(new_clip);<br />
return v;<br />
}<br />
<br />
const char* AVSC_CC avisynth_c_plugin_init(AVS_ScriptEnvironment * env)<br />
{<br />
avs_add_function(env, "InvertNeg", "c", Create_InvertNeg, 0);<br />
return "InvertNeg sample c-plugin";<br />
}<br />
<br />
Link to avisynth.lib and when using the MSVC++ compiler add the definition file. Compile this file into a DLL named InvertNeg.dll. See [[Filter_SDK/Compiling_instructions|compiling instructions]]. Now create an Avisynth script which looks something like this:<br />
<br />
LoadCPlugin("d:\path\InvertNeg.dll")<br />
clip = BlankClip().ConvertToYV12()<br />
return clip.InvertNeg()<br />
<br />
=== Line by line breakdown ===<br />
<br />
Here's a line-by-line breakdown of InvertNeg.c:<br />
<br />
#include "avisynth_c.h"<br />
<br />
This header declares all the classes and miscellaneous constants that you might need when writing a plugin. All external plugins should #include it.<br />
<br />
External plugins do not link with avisynth.dll, so they can't directly access functions that are defined in the main Avisynth source code. Therefore, every important function in avisynth_c.h is either defined inline or declared as virtual (???). The virtual functions act as callbacks for external DLLs. <br />
<br />
AVS_VideoFrame* AVSC_CC InvertNeg_get_frame(AVS_FilterInfo* fi, int n)<br />
<br />
This function is the main callback functions for our filter. When called it should return frame n. It returns this frame as a pointer to AVS_VideoFrame.<br />
<br />
AVSC_CC stands for Avisynth calling convention. Right now it is stdcall (it used to be cdecl when the C interface was exposes through seperate plugin). By using AVSC_CC you should be able to maintain source code compatibility when the calling convention changes. <br />
<br />
AVS_VideoFrame* src;<br />
AVS_VideoFrame* dst;<br />
int row_size, height, src_pitch, dst_pitch;<br />
const BYTE* srcp;<br />
BYTE* dstp;<br />
int x, y, p;<br />
<br />
Declaring all of the variables we will need '''must be done up front''' (for the C++ plugin this is not necessary). Doing it in between the code will get you strange compile errors.<br />
<br />
int planes[] = {AVS_PLANAR_Y, AVS_PLANAR_V, AVS_PLANAR_U};<br />
<br />
The plugin requires planar YUV data, so we need to process the planes. Note the constants (such as AVS_PLANAR_Y) are the same as the ones in the C++ inteface, except for the 'AVS_' in front of it.<br />
<br />
src = avs_get_frame(fi->child, n);<br />
<br />
"child" is a member of AVS_FilterInfo, of type AVS_Clip. It generally contains the clip that was passed into the filter. For our filter to produce frame n we need the corresponding frame of the input clip. If you need a different frame from the input, all you have to do is pass a different frame number get_frame.<br />
<br />
Note the functions (such as avs_get_frame) are similar as the ones in the C++ inteface, except for the 'avs_' in front of it.<br />
<br />
get_frame calls are usually intercepted by Avisynth's internal caching code, so the frame request may never actually reach the child filter (meaning ???). <br />
<br />
dst = avs_new_video_frame(fi->env, &fi->vi);<br />
<br />
The avs_new_video_frame function allocates space for a video frame of the supplied size. (In this case it will hold our filter's output.) The frame buffer is uninitialized raw memory.<br />
<br />
"env" is a member of AVS_FilterInfo which is a pointer to AVS_ScriptEnvironment. One instance of AVS_ScriptEnvironment is created for each AVS script.<br />
<br />
"vi" is another member of AVS_FilterInfo. It is a structure of type AVS_VideoInfo, which contains information about the clip (like frame size, frame rate, pixel format, audio sample rate, etc.). avs_new_video_frame uses the information in this structure to return a frame buffer of the appropriate size.<br />
<br />
Frame buffers are reused once all references to them go away. So usually memory won't need to be allocated from the heap. <br />
<br />
for (p=0; p<3; p++) {<br />
<br />
Loop over all planes.<br />
<br />
srcp = avs_get_read_ptr_p(src, planes[p]);<br />
dstp = avs_get_write_ptr_p(dst, planes[p]);<br />
<br />
All frame buffers are readable, but not all are writable.<br />
<br />
The rule about writability is this: A buffer is writable if and only if its reference count is one. In other words, you can only write to a buffer if no one else might be reading it. This rule guarantees that as long as you hold on to a video frame and don't write to it yourself, that frame will remain unchanged. Any buffer you get from avs_new_video_frame is guaranteed to be writable. However, frames you get from other clips via get_frame may not be writable, in which case avs_get_write_ptr will return a null pointer.<br />
<br />
There is an is_writable method which you can call to find out if a buffer is writable or not, and there's a avs_make_writable method (described below) to ensure that it is. <br />
<br />
src_pitch = avs_get_pitch_p(src, planes[p]);<br />
dst_pitch = avs_get_pitch_p(dst, planes[p]);<br />
<br />
The "pitch" of a frame buffer is the offset (in bytes) from the beginning of one scan line to the beginning of the next. The source and destination buffers won't necessarily have the same pitch.<br />
<br />
Buffers created by avs_new_video_frame are always double word (16-byte) aligned and always have a pitch that is a multiple of 16. <br />
<br />
row_size = avs_get_row_size_p(dst, planes[p]);<br />
<br />
The row size is the length of each row in bytes (not pixels). It's usually equal to the pitch or slightly less, but it may be significantly less if the frame in question has been through Crop.<br />
<br />
Since our source and destination frames have the same width and pixel format, they will always have the same row size. Thus I only need one row_size variable, and I could just as well have used dest instead of src. <br />
<br />
height = avs_get_height_p(dst, planes[p]);<br />
<br />
The height is the height in pixels. Again, for our filter this is the same for the source and the destination.<br />
<br />
for (y = 0; y < height; y++) {<br />
for (x = 0; x < row_size; x++) {<br />
dstp[x] = srcp[x] ^ 255;<br />
}<br />
srcp += src_pitch;<br />
dstp += dst_pitch;<br />
}<br />
}<br />
<br />
This is the code that does the actual work. The "srcp += src_pitch; dstp += dest_pitch;" idiom is a useful way of dealing with potentially differing pitches without too much grief.<br />
<br />
avs_release_video_frame(src);<br />
<br />
Once we are done with a video frame it needs to be released. Releasing a video frame does not actually delete it but decrements the reference count.<br />
<br />
return dst;<br />
<br />
GetFrame returns the newly-created frame.<br />
<br />
AVS_Value AVSC_CC Create_InvertNeg(AVS_ScriptEnvironment* env, AVS_Value args, void* user_data)<br />
<br />
In order to use our new filter, we need a scripting-language function which creates an instance of it. This is that function.<br />
<br />
Script functions written in C take three arguments. env contains the same ScriptEnvironment pointer that will later be passed to GetFrame. args contais all the arguments passed to the function by the script. user_data contains the void pointer which you passed to AddFunction (see below). Usually you won't need this.<br />
<br />
AVS_Value is a variant type which can hold any one of the following: a boolean value (true/false); an integer; a floating-point number; a string; a video clip; an array of AVS_Values; or nothing ("undefined"). You can test which one it is with the methods avs_is_bool, avs_is_int, avs_is_float, avs_is_string, avs_is_clip, avs_is_array, and avs_defined (which returns true if the AVS_Value is not "undefined"). You can get the value with avs_as_bool, avs_as_int, etc. for arrays, you can use the avs_array_size method to get the number of elements, and avs_array_elt get the elements themselves. For convenience, avs_is_float and avs_as_float will work with integers also. But boolean values are not treated as numeric (unlike C).<br />
<br />
The name "Create_InvertNeg" is arbitrary. This function will actually be known as "InvertNeg" in scripts, because that's the name we pass to avs_add_function below. <br />
<br />
AVS_Value v;<br />
<br />
v will serve as the return value.<br />
<br />
AVS_FilterInfo* fi;<br />
AVS_Clip* new_clip = avs_new_c_filter(env, &fi, avs_array_elt(args, 0), 1);<br />
<br />
"avs_new_c_filter" creates a new filter. AVS_Clip is an abstract type representing a filter. In this case it will represent our new filter. "env" is the current script environment. "fi" will be set to point to our filter AVS_FilterInfo which is the concrete representation of a C filter. We will modify this structure later. "avs_array_elt(args, 0)" is accessing the first value of args, which is generally the parent clip. The last parameter, is a boolean value "store_child". It should generally always be set to true.<br />
<br />
if (!avs_is_planar(&fi->vi) || !avs_is_yuv(&fi->vi)) {<br />
v = avs_new_value_error("InvertNeg: planar YUV data only!");<br />
} else {<br />
<br />
Our filter will not work unless the video is stored as YUV planar. If this is not the case than an error is returned. This is done be setting the return value to an error condition.<br />
<br />
fi->get_frame = InvertNeg_get_frame;<br />
<br />
Here we are setting the get_frame callback. There are other callbacks but since "store_child" was set we do not have to worry about implementing all of them.<br />
<br />
v = avs_new_value_clip(new_clip);<br />
<br />
The return value is then set to the new clip returned by avs_new_c_filter. avs_new_value_clip converts the clip info an AVS_Value (???). It also creates a new reference to the clip.<br />
<br />
avs_release_clip(new_clip);<br />
<br />
We must now release the clip returned by avs_new_c_filter. In the case of an error the clip is no longer needed. Otherwise a new reference is created to the clip with avs_new_value_clip so we must release the original reference.<br />
<br />
return v;<br />
<br />
Finally we return. "v" is either an error or the new clip.<br />
<br />
const char* AVSC_CC avisynth_c_plugin_init(AVS_ScriptEnvironment * env)<br />
<br />
This is the only function which gets exported from the DLL. It is called by the script function LoadCPlugin the first time this plugin in loaded in a particular script. If several scripts are open at once and more than one of them loads this plugin, avisynth_c_plugin_init may be called more than once with different ScriptEnvironments. Therefore:<br />
<br />
* You should not save the env parameter in a global variable.<br />
* If you need to initialize any static data, you should do it in DLLMain, not in this function. <br />
<br />
The main purpose of the avisynth_c_plugin_init function is to call avs_add_function.<br />
<br />
avs_add_function(env, "InvertNeg", "c", Create_InvertNeg, 0);<br />
<br />
As promised, we now call add_function to let Avisynth know of the existence of our filter. This function takes four arguments: the name of the new script function; the parameter-type string; the C function implementing the script function; and the user_data cookie.<br />
<br />
The parameter type string specifies the paramaters for the function. The return value is untyped. It consists of a series of letters specinging the parameter types with 'c' for clip, 'i' for integer, 's' for string, 'b' for boolean, and 'f' for float. In addition:<br />
<br />
* Any type can be followed with a '*' or '+' to indicate "zero or more" or "one or more" respectively. In this case all the matching arguments will be gathered into a sub-array. For example, if your type string is "is+f", then the integer argument will be args[0], the string arguments will be args[1][0], args[1][1], etc. (and there will be avs_array_size(args[1]) of them), and the float argument will be args[2].<br />
* '.' matches a single argument of any type. To match multiple arguments of any type, use ".*" or ".+".<br />
* Named arguments can be specified in [brackets] before the type. Named arguments are also optional arguments; if the user omits them, they will be of the undefined type instead of the type you specify. <br />
<br />
return "InvertNeg sample c-plugin";<br />
<br />
The return value of avisynth_c_plugin_init is a string which can contain any message you like, such as a notice identifying the version and author of the plugin. This string becomes the return value of LoadCPlugin, and will almost always be ignored. You can also just return 0 if you prefer.<br />
<br />
== As an in-place filter ==<br />
<br />
The InvertNeg filter could easily do its work in a single buffer, rather than copying from one buffer to another. Here's a new implementation of get_frame that does this:<br />
<br />
#include "avisynth_c.h"<br />
<br />
AVS_VideoFrame* AVSC_CC InvertNeg_get_frame(AVS_FilterInfo* fi, int n)<br />
{<br />
AVS_VideoFrame* src;<br />
int row_size, height, src_pitch;<br />
BYTE* srcp;<br />
int x, y, p;<br />
<br />
int planes[] = {AVS_PLANAR_Y, AVS_PLANAR_V, AVS_PLANAR_U};<br />
<br />
src = avs_get_frame(fi->child, n);<br />
avs_make_writable(fi->env, &src);<br />
<br />
for (p=0; p<3; p++) {<br />
srcp = avs_get_write_ptr_p(src, planes[p]);<br />
src_pitch = avs_get_pitch_p(src, planes[p]);<br />
row_size = avs_get_row_size_p(src, planes[p]);<br />
height = avs_get_height_p(src, planes[p]);<br />
<br />
for (y = 0; y < height; y++) {<br />
for (x = 0; x < row_size; x++) {<br />
srcp[x] = srcp[x] ^ 255; // or srcp[x] =^ 255;<br />
}<br />
srcp += src_pitch;<br />
}<br />
}<br />
<br />
return src;<br />
}<br />
<br />
AVS_Value AVSC_CC Create_InvertNeg(AVS_ScriptEnvironment* env, AVS_Value args, void* user_data)<br />
{<br />
AVS_Value v;<br />
AVS_FilterInfo* fi;<br />
AVS_Clip* new_clip = avs_new_c_filter(env, &fi, avs_array_elt(args, 0), 1);<br />
<br />
if (!avs_is_planar(&fi->vi) || !avs_is_yuv(&fi->vi)) {<br />
v = avs_new_value_error("InvertNeg: planar YUV data only!");<br />
} else {<br />
fi->get_frame = InvertNeg_get_frame;<br />
v = avs_new_value_clip(new_clip);<br />
}<br />
<br />
avs_release_clip(new_clip);<br />
return v;<br />
}<br />
<br />
const char* AVSC_CC avisynth_c_plugin_init(AVS_ScriptEnvironment * env)<br />
{<br />
avs_add_function(env, "InvertNeg", "c", Create_InvertNeg, 0);<br />
return "InvertNeg sample c-plugin";<br />
}<br />
<br />
The key difference between this version of the function and the original version is the presence of the avs_make_writable callback. This is necessary because this time "we don't know where that source frame has been." Someone else in the filter chain may be holding a reference to it, in which case we won't be allowed to write to it.<br />
<br />
== Old versions ==<br />
<br />
[http://www.kevina.org/avisynth_c/example.html Kevin's AviSynth C API Docs] is the documentation written for the deprecated avisynth_c.dll by Kevin Atkinson, in its original form.<br />
<br />
[[Category:C API]]</div>Adminhttp://avisynth.nl/index.php/Filter_SDK/CMergeFilter SDK/CMerge2017-01-12T22:30:11Z<p>Admin: </p>
<hr />
<div>Here is another working Avisynth C plugin. It's called "Merge", and it merges two clips according to a weight.<br />
<br />
Here's Merge.c:<br />
<br />
#include <stdlib.h><br />
#include "avisynth_c.h"<br />
<br />
typedef struct Merge {<br />
AVS_Clip* clip2;<br />
double weight;<br />
} Merge;<br />
<br />
AVS_VideoFrame* AVSC_CC Merge_get_frame(AVS_FilterInfo* fi, int n)<br />
{<br />
Merge* params = (Merge*) fi->user_data;<br />
<br />
AVS_VideoFrame* src = avs_get_frame(fi->child, n);<br />
const BYTE* srcp = avs_get_read_ptr(src);<br />
int src_pitch = avs_get_pitch(src);<br />
<br />
AVS_VideoFrame* src2 = avs_get_frame(params->clip2, n);<br />
const BYTE* srcp2 = avs_get_read_ptr(src2);<br />
int src2_pitch = avs_get_pitch(src2);<br />
<br />
AVS_VideoFrame* dst = avs_new_video_frame(fi->env, &fi->vi);<br />
BYTE* dstp = avs_get_write_ptr(dst);<br />
int dst_pitch = avs_get_pitch(dst);<br />
int dst_rowsize = avs_get_row_size(dst); // in bytes!<br />
int dst_height = avs_get_height(dst);<br />
<br />
int x, y, ch_tot;<br />
double w;<br />
<br />
if (avs_is_rgb32(&fi->vi))<br />
ch_tot = 4;<br />
else // rgb24<br />
ch_tot = 3;<br />
<br />
w = params->weight;<br />
<br />
for (y=0; y<dst_height; ++y) {<br />
for (x=0; x<dst_rowsize; x+=ch_tot) {<br />
dstp[x] = (int)((1-w)*srcp[x] + w*srcp2[x]+0.5); // B<br />
dstp[x+1] = (int)((1-w)*srcp[x+1] + w*srcp2[x+1]+0.5); // G<br />
dstp[x+2] = (int)((1-w)*srcp[x+2] + w*srcp2[x+2]+0.5); // R<br />
}<br />
srcp += src_pitch;<br />
srcp2 += src2_pitch;<br />
dstp += dst_pitch;<br />
}<br />
<br />
avs_release_frame(src);<br />
avs_release_frame(src2);<br />
<br />
return dst;<br />
}<br />
<br />
void AVSC_CC free_Merge(AVS_FilterInfo* fi)<br />
{<br />
Merge* params = (Merge*) fi->user_data;<br />
avs_release_clip(params->clip2);<br />
free(params);<br />
}<br />
<br />
AVS_Value AVSC_CC create_Merge(AVS_ScriptEnvironment* env, AVS_Value args, void* user_data)<br />
{<br />
AVS_Value v;<br />
AVS_Value tmp;<br />
AVS_FilterInfo* fi;<br />
const AVS_VideoInfo* vi2;<br />
<br />
AVS_Clip* new_clip = avs_new_c_filter(env, &fi, avs_array_elt(args, 0), 1);<br />
<br />
Merge *params = (Merge*)malloc(sizeof(Merge));<br />
if (!params)<br />
return avs_void;<br />
<br />
if (!avs_is_rgb(&fi->vi)) {<br />
return avs_new_value_error("Input video must be in RGB format!");<br />
}<br />
<br />
tmp = avs_array_elt(args, 1);<br />
if (avs_defined(tmp)) {<br />
params->clip2 = avs_take_clip(tmp, env);<br />
vi2 = avs_get_video_info(params->clip2);<br />
if (!avs_has_video(vi2)) {<br />
return avs_new_value_error("Second clip must be a video clip!");<br />
} <br />
else if (!avs_is_color_space(vi2, fi->vi.pixel_type))<br />
{<br />
return avs_new_value_error("Second video must have the same pixel-type as the first clip!");<br />
} <br />
else if (vi2->width != fi->vi.width || vi2->height != fi->vi.height)<br />
{<br />
return avs_new_value_error("Input and second clip sizes must match!");<br />
}<br />
} else {<br />
return avs_new_value_error("Second clip is missing!");<br />
}<br />
<br />
tmp = avs_array_elt(args, 2);<br />
if (avs_defined(tmp)) {<br />
params->weight = avs_as_float(tmp);<br />
if ((params->weight<0.0f) || (params->weight>1.0f)) {<br />
return avs_new_value_error("Make sure that '0.0 <= weight <= 1.0'!");<br />
}<br />
} else {<br />
params->weight = 0.5f; // default value<br />
}<br />
<br />
fi->user_data = (void*) params;<br />
fi->get_frame = Merge_get_frame;<br />
fi->free_filter = free_Merge;<br />
<br />
v = avs_new_value_clip(new_clip);<br />
<br />
avs_release_clip(new_clip);<br />
return v;<br />
}<br />
<br />
const char* AVSC_CC avisynth_c_plugin_init(AVS_ScriptEnvironment* env)<br />
{<br />
avs_add_function(env, "Merge", "cc[weight]f", create_Merge, 0);<br />
return "Merge sample C plugin";<br />
}<br />
<br />
== Line by line breakdown ==<br />
<br />
Here's a line-by-line breakdown of Merge.c. I won't repeat the comments in the previous example InvertNeg.c, so read that first if needed. The declaration of the class is as follows <br />
<br />
#include <stdlib.h> // free, malloc<br />
<br />
This header defines free and malloc which we will need later on.<br />
<br />
Note one could also include windows.h instead. However this gives a 'warning C4005: 'EXTERN_C' : macro redefinition' when compiling with MSVC++. I guess this needs to be fixed avisynth_c.h.<br />
<br />
typedef struct Merge {<br />
AVS_Clip* clip2;<br />
double weight;<br />
} Merge; // this name (ie Merge) is an alias for 'struct Merge'<br />
<br />
In C we don't have classes. We will use a structure to declare our parameter variables (clip2 and weight in this example). The members of a structure are public by default (C++ plugins: recall that in a C++ class they are private by default).<br />
<br />
typedef allows you to declare instances of a structure without using keyword "struct", since the second 'Merge' is an alias for 'struct Merge'. For more information have a look [http://stackoverflow.com/questions/1675351/typedef-struct-vs-struct-definitions here] and [http://www.cs.usfca.edu/~wolber/SoftwareDev/C/CStructs.htm here].<br />
<br />
AVS_VideoFrame* AVSC_CC Merge_get_frame(AVS_FilterInfo* fi, int n)<br />
<br />
This method is called to make our filter produce frame n of its output.<br />
<br />
Merge* params = (Merge*) fi->user_data;<br />
<br />
This fetches instance parameters.<br />
<br />
AVS_VideoFrame* src = avs_get_frame(fi->child, n);<br />
const BYTE* srcp = avs_get_read_ptr(src);<br />
int src_pitch = avs_get_pitch(src);<br />
<br />
AVS_VideoFrame* src2 = avs_get_frame(params->clip2, n);<br />
const BYTE* srcp2 = avs_get_read_ptr(src2);<br />
int src2_pitch = avs_get_pitch(src2);<br />
<br />
Gives read pointers to both our input clips.<br />
<br />
AVS_VideoFrame* dst = avs_new_video_frame(fi->env, &fi->vi);<br />
<br />
Creates a new frame according to what we set up in create_Merge.<br />
<br />
BYTE* dstp = avs_get_write_ptr(dst);<br />
int dst_pitch = avs_get_pitch(dst);<br />
int dst_rowsize = avs_get_row_size(dst); // in bytes!<br />
int dst_height = avs_get_height(dst);<br />
<br />
Gives a write pointer to our output clips.<br />
<br />
if (avs_is_rgb32(&fi->vi))<br />
ch_tot = 4;<br />
else // rgb24<br />
ch_tot = 3;<br />
<br />
This filter requires RGB24 or RGB32. ch_tot is the number of channels.<br />
<br />
w = params->weight;<br />
<br />
The variable w is the input parameter weight. We will use that for better readability.<br />
<br />
for (y=0; y<dst_height; ++y) {<br />
for (x=0; x<dst_rowsize; x+=ch_tot) {<br />
dstp[x] = (int)((1-w)*srcp[x] + w*srcp2[x]+0.5); // B<br />
dstp[x+1] = (int)((1-w)*srcp[x+1] + w*srcp2[x+1]+0.5); // G<br />
dstp[x+2] = (int)((1-w)*srcp[x+2] + w*srcp2[x+2]+0.5); // R<br />
}<br />
srcp += src_pitch;<br />
srcp2 += src2_pitch;<br />
dstp += dst_pitch;<br />
}<br />
<br />
This code does the actual work. It blends the red, green and blue channels together.<br />
<br />
avs_release_frame(src);<br />
avs_release_frame(src2);<br />
<br />
Once we are done with the video frames of both clips they need to be released. Releasing a video frame does not actually delete it but decrements the reference count. (C++ plugins: recall this happens automatically when returning the destination frame.)<br />
<br />
return dst;<br />
<br />
GetFrame returns the newly-created frame.<br />
<br />
void AVSC_CC free_Merge(AVS_FilterInfo* fi)<br />
{<br />
Merge* params = (Merge*) fi->user_data;<br />
avs_release_clip(params->clip2);<br />
free(params);<br />
}<br />
<br />
There are no constructors and deconstructors in C, but we need something to release memory. This is done by the function free_Merge which is defined above.<br />
<br />
AVS_Value AVSC_CC create_Merge(AVS_ScriptEnvironment* env, AVS_Value args, void* user_data)<br />
<br />
In order to use our new filter, we need a scripting-language function which creates an instance of it. This is that function. <br />
<br />
AVS_Clip* new_clip = avs_new_c_filter(env, &fi, avs_array_elt(args, 0), 1);<br />
<br />
The new clip parameters are initialized from the input clip. fi is filled in according to the parent clip's parameters. You may modify fi afterwards to change the returned clip's parameters.<br />
<br />
Merge *params = (Merge*)malloc(sizeof(Merge));<br />
<br />
Allocates memory and create a new instance of params.<br />
<br />
if (!params)<br />
return avs_void;<br />
<br />
When failed to allocate memory, return avs_void.<br />
<br />
if (!avs_is_rgb(&fi->vi)) {<br />
return avs_new_value_error("Input video must be in RGB format!");<br />
}<br />
<br />
As stated above there are no constructors and deconstructors in C, so the necessary checks on the input parameters must be done here. This is before setting the get_frame callback.<br />
<br />
tmp = avs_array_elt(args, 1);<br />
if (avs_defined(tmp)) {<br />
params->clip2 = avs_take_clip(tmp, env);<br />
<br />
The second input parameter should be the second clip. It is actually an AVS_Value, and avs_take_clip converts it to a clip. The parser will check that tmp contains a clip (as specified in avs_add_function), so we know it contains a clip at this stage. Below we will check the clip contains video.<br />
<br />
vi2 = avs_get_video_info(params->clip2);<br />
if (!avs_has_video(vi2)) {<br />
return avs_new_value_error("Second clip must be a video clip!");<br />
}<br />
<br />
If it has no video, an error is returned.<br />
<br />
else if (!avs_is_color_space(vi2, fi->vi.pixel_type))<br />
{<br />
return avs_new_value_error("Second video must have the same pixel-type as the first clip!");<br />
}<br />
<br />
If it has video, but the colorspace (that is the pixeltype) of the second clip is not the same as the one of the first clip, an error is returned.<br />
<br />
else if (vi2->width != fi->vi.width || vi2->height != fi->vi.height)<br />
{<br />
return avs_new_value_error("Input and second clip sizes must match!");<br />
}<br />
<br />
If the colorspace is the same, but the dimensions of both clips are different, an error is returned.<br />
<br />
} else {<br />
return avs_new_value_error("Second clip is missing!");<br />
}<br />
<br />
If the second clip is missing, an error is returned. Although strictly not necessary as explained above, since this check is done by the parser.<br />
<br />
tmp = avs_array_elt(args, 2);<br />
if (avs_defined(tmp)) {<br />
params->weight = avs_as_float(tmp);<br />
<br />
The third input parameter should be the weight. It is actually an AVS_Value,<br />
<br />
if ((params->weight<0.0f) || (params->weight>1.0f)) {<br />
return avs_new_value_error("Make sure that '0.0 <= weight <= 1.0'!");<br />
}<br />
<br />
The weight should be in [0,1], if not an error is returned.<br />
<br />
} else {<br />
params->weight = 0.5; // default value<br />
}<br />
<br />
There are no default values in the C API, so they are set explicitly. Here the weight is set to 0.5 by default.<br />
<br />
fi->user_data = (void*) params;<br />
fi->get_frame = Merge_get_frame;<br />
fi->free_filter = free_Merge;<br />
<br />
Here we set up FilterInfo:<br />
* For audio-only filters you need to implement get_audio. Other members that can be implemented are set_cache_hints and get_parity. * For source filters, avs_new_c_filter should be called as avs_new_c_filter(env, &fi, avs_void, 0). Thus the last parameter, store_child, is set to false. In this case all four members (get_frame, get_audio, set_cache_hints and get_parity) should be implemented.<br />
* user_data ...<br />
* free_filter ...<br />
<br />
v = avs_new_value_clip(new_clip);<br />
<br />
The return value is then set to the new clip returned by avs_new_c_filter.<br />
<br />
avs_release_clip(new_clip);<br />
<br />
We must now release the clip returned by avs_new_c_filter. In the case of an error the clip is no longer needed. Otherwise a new reference is created to the clip with avs_new_value_clip so we must release the original reference.<br />
<br />
return v;<br />
<br />
Finally we return. "v" is either an error or the new clip.<br />
<br />
[[Category:C API]]</div>Adminhttp://avisynth.nl/index.php/Category:C_APICategory:C API2017-01-12T21:48:48Z<p>Admin: Created page with "Category:FilterSDK"</p>
<hr />
<div>[[Category:FilterSDK]]</div>Adminhttp://avisynth.nl/index.php/Filter_SDK/CInvertNegFilter SDK/CInvertNeg2017-01-12T21:48:35Z<p>Admin: </p>
<hr />
<div>I'll start off with a complete, working Avisynth C plugin. It's called "InvertNeg", and it produces a photo-negative of the input clip.<br />
<br />
Here's InvertNeg.c:<br />
<br />
#include "avisynth_c.h"<br />
<br />
AVS_VideoFrame* AVSC_CC InvertNeg_get_frame(AVS_FilterInfo* fi, int n)<br />
{<br />
AVS_VideoFrame* src;<br />
AVS_VideoFrame* dst;<br />
int row_size, height, src_pitch, dst_pitch;<br />
const BYTE* srcp;<br />
BYTE* dstp;<br />
int x, y, p;<br />
<br />
int planes[] = {AVS_PLANAR_Y, AVS_PLANAR_V, AVS_PLANAR_U};<br />
<br />
src = avs_get_frame(fi->child, n);<br />
dst = avs_new_video_frame(fi->env, &fi->vi);<br />
<br />
for (p=0; p<3; p++) {<br />
srcp = avs_get_read_ptr_p(src, planes[p]);<br />
dstp = avs_get_write_ptr_p(dst, planes[p]);<br />
src_pitch = avs_get_pitch_p(src, planes[p]);<br />
dst_pitch = avs_get_pitch_p(dst, planes[p]);<br />
row_size = avs_get_row_size_p(dst, planes[p]);<br />
height = avs_get_height_p(dst, planes[p]);<br />
<br />
for (y = 0; y < height; y++) {<br />
for (x = 0; x < row_size; x++) {<br />
dstp[x] = srcp[x] ^ 255;<br />
}<br />
srcp += src_pitch;<br />
dstp += dst_pitch;<br />
}<br />
}<br />
<br />
avs_release_video_frame(src);<br />
return dst;<br />
}<br />
<br />
AVS_Value AVSC_CC Create_InvertNeg(AVS_ScriptEnvironment* env, AVS_Value args, void* user_data)<br />
{<br />
AVS_Value v;<br />
AVS_FilterInfo* fi;<br />
AVS_Clip* new_clip = avs_new_c_filter(env, &fi, avs_array_elt(args, 0), 1);<br />
<br />
if (!avs_is_planar(&fi->vi) || !avs_is_yuv(&fi->vi)) {<br />
v = avs_new_value_error("InvertNeg: planar YUV data only!");<br />
} else {<br />
fi->get_frame = InvertNeg_get_frame;<br />
v = avs_new_value_clip(new_clip);<br />
}<br />
<br />
avs_release_clip(new_clip);<br />
return v;<br />
}<br />
<br />
const char* AVSC_CC avisynth_c_plugin_init(AVS_ScriptEnvironment * env)<br />
{<br />
avs_add_function(env, "InvertNeg", "c", Create_InvertNeg, 0);<br />
return "InvertNeg sample c-plugin";<br />
}<br />
<br />
Link to avisynth.lib and when using the MSVC++ compiler add the definition file. Compile this file into a DLL named InvertNeg.dll. See [[Filter_SDK/Compiling_instructions|compiling instructions]]. Now create an Avisynth script which looks something like this:<br />
<br />
LoadCPlugin("d:\path\InvertNeg.dll")<br />
clip = BlankClip().ConvertToYV12()<br />
return clip.InvertNeg()<br />
<br />
=== Line by line breakdown ===<br />
<br />
Here's a line-by-line breakdown of InvertNeg.c:<br />
<br />
#include "avisynth_c.h"<br />
<br />
This header declares all the classes and miscellaneous constants that you might need when writing a plugin. All external plugins should #include it.<br />
<br />
External plugins do not link with avisynth.dll, so they can't directly access functions that are defined in the main Avisynth source code. Therefore, every important function in avisynth_c.h is either defined inline or declared as virtual (???). The virtual functions act as callbacks for external DLLs. <br />
<br />
AVS_VideoFrame* AVSC_CC InvertNeg_get_frame(AVS_FilterInfo* fi, int n)<br />
<br />
This function is the main callback functions for our filter. When called it should return frame n. It returns this frame as a pointer to AVS_VideoFrame.<br />
<br />
AVSC_CC stands for Avisynth calling convention. Right now it is stdcall (it used to be cdecl when the C interface was exposes through seperate plugin). By using AVSC_CC you should be able to maintain source code compatibility when the calling convention changes. <br />
<br />
AVS_VideoFrame* src;<br />
AVS_VideoFrame* dst;<br />
int row_size, height, src_pitch, dst_pitch;<br />
const BYTE* srcp;<br />
BYTE* dstp;<br />
int x, y, p;<br />
<br />
Declaring all of the variables we will need '''must be done up front''' (for the C++ plugin this is not necessary). Doing it in between the code will get you strange compile errors.<br />
<br />
int planes[] = {AVS_PLANAR_Y, AVS_PLANAR_V, AVS_PLANAR_U};<br />
<br />
The plugin requires planar YUV data, so we need to process the planes. Note the constants (such as AVS_PLANAR_Y) are the same as the ones in the C++ inteface, except for the 'AVS_' in front of it.<br />
<br />
src = avs_get_frame(fi->child, n);<br />
<br />
"child" is a member of AVS_FilterInfo, of type AVS_Clip. It generally contains the clip that was passed into the filter. For our filter to produce frame n we need the corresponding frame of the input clip. If you need a different frame from the input, all you have to do is pass a different frame number get_frame.<br />
<br />
Note the functions (such as avs_get_frame) are similar as the ones in the C++ inteface, except for the 'avs_' in front of it.<br />
<br />
get_frame calls are usually intercepted by Avisynth's internal caching code, so the frame request may never actually reach the child filter (meaning ???). <br />
<br />
dst = avs_new_video_frame(fi->env, &fi->vi);<br />
<br />
The avs_new_video_frame function allocates space for a video frame of the supplied size. (In this case it will hold our filter's output.) The frame buffer is uninitialized raw memory.<br />
<br />
"env" is a member of AVS_FilterInfo which is a pointer to AVS_ScriptEnvironment. One instance of AVS_ScriptEnvironment is created for each AVS script.<br />
<br />
"vi" is another member of AVS_FilterInfo. It is a structure of type AVS_VideoInfo, which contains information about the clip (like frame size, frame rate, pixel format, audio sample rate, etc.). avs_new_video_frame uses the information in this structure to return a frame buffer of the appropriate size.<br />
<br />
Frame buffers are reused once all references to them go away. So usually memory won't need to be allocated from the heap. <br />
<br />
for (p=0; p<3; p++) {<br />
<br />
Loop over all planes.<br />
<br />
srcp = avs_get_read_ptr_p(src, planes[p]);<br />
dstp = avs_get_write_ptr_p(dst, planes[p]);<br />
<br />
All frame buffers are readable, but not all are writable.<br />
<br />
The rule about writability is this: A buffer is writable if and only if its reference count is one. In other words, you can only write to a buffer if no one else might be reading it. This rule guarantees that as long as you hold on to a video frame and don't write to it yourself, that frame will remain unchanged. Any buffer you get from avs_new_video_frame is guaranteed to be writable. However, frames you get from other clips via get_frame may not be writable, in which case avs_get_write_ptr will return a null pointer.<br />
<br />
There is an is_writable method which you can call to find out if a buffer is writable or not, and there's a avs_make_writable method (described below) to ensure that it is. <br />
<br />
src_pitch = avs_get_pitch_p(src, planes[p]);<br />
dst_pitch = avs_get_pitch_p(dst, planes[p]);<br />
<br />
The "pitch" of a frame buffer is the offset (in bytes) from the beginning of one scan line to the beginning of the next. The source and destination buffers won't necessarily have the same pitch.<br />
<br />
Buffers created by avs_new_video_frame are always double word (16-byte) aligned and always have a pitch that is a multiple of 16. <br />
<br />
row_size = avs_get_row_size_p(dst, planes[p]);<br />
<br />
The row size is the length of each row in bytes (not pixels). It's usually equal to the pitch or slightly less, but it may be significantly less if the frame in question has been through Crop.<br />
<br />
Since our source and destination frames have the same width and pixel format, they will always have the same row size. Thus I only need one row_size variable, and I could just as well have used dest instead of src. <br />
<br />
height = avs_get_height_p(dst, planes[p]);<br />
<br />
The height is the height in pixels. Again, for our filter this is the same for the source and the destination.<br />
<br />
for (y = 0; y < height; y++) {<br />
for (x = 0; x < row_size; x++) {<br />
dstp[x] = srcp[x] ^ 255;<br />
}<br />
srcp += src_pitch;<br />
dstp += dst_pitch;<br />
}<br />
}<br />
<br />
This is the code that does the actual work. The "srcp += src_pitch; dstp += dest_pitch;" idiom is a useful way of dealing with potentially differing pitches without too much grief.<br />
<br />
avs_release_video_frame(src);<br />
<br />
Once we are done with a video frame it needs to be released. Releasing a video frame does not actually delete it but decrements the reference count.<br />
<br />
return dst;<br />
<br />
GetFrame returns the newly-created frame.<br />
<br />
AVS_Value AVSC_CC Create_InvertNeg(AVS_ScriptEnvironment* env, AVS_Value args, void* user_data)<br />
<br />
In order to use our new filter, we need a scripting-language function which creates an instance of it. This is that function.<br />
<br />
Script functions written in C take three arguments. env contains the same ScriptEnvironment pointer that will later be passed to GetFrame. args contais all the arguments passed to the function by the script. user_data contains the void pointer which you passed to AddFunction (see below). Usually you won't need this.<br />
<br />
AVS_Value is a variant type which can hold any one of the following: a boolean value (true/false); an integer; a floating-point number; a string; a video clip; an array of AVS_Values; or nothing ("undefined"). You can test which one it is with the methods avs_is_bool, avs_is_int, avs_is_float, avs_is_string, avs_is_clip, avs_is_array, and avs_defined (which returns true if the AVS_Value is not "undefined"). You can get the value with avs_as_bool, avs_as_int, etc. for arrays, you can use the avs_array_size method to get the number of elements, and avs_array_elt get the elements themselves. For convenience, avs_is_float and avs_as_float will work with integers also. But boolean values are not treated as numeric (unlike C).<br />
<br />
The name "Create_InvertNeg" is arbitrary. This function will actually be known as "InvertNeg" in scripts, because that's the name we pass to avs_add_function below. <br />
<br />
AVS_Value v;<br />
<br />
v will serve as the return value.<br />
<br />
AVS_FilterInfo* fi;<br />
AVS_Clip* new_clip = avs_new_c_filter(env, &fi, avs_array_elt(args, 0), 1);<br />
<br />
"avs_new_c_filter" creates a new filter. AVS_Clip is an abstract type representing a filter. In this case it will represent our new filter. "env" is the current script environment. "fi" will be set to point to our filter AVS_FilterInfo which is the concrete representation of a C filter. We will modify this structure later. "avs_array_elt(args, 0)" is accessing the first value of args, which is generally the parent clip. The last parameter, is a boolean value "store_child". It should generally always be set to true.<br />
<br />
if (!avs_is_planar(&fi->vi) || !avs_is_yuv(&fi->vi)) {<br />
v = avs_new_value_error("InvertNeg: planar YUV data only!");<br />
} else {<br />
<br />
Our filter will not work unless the video is stored as YUV planar. If this is not the case than an error is returned. This is done be setting the return value to an error condition.<br />
<br />
fi->get_frame = InvertNeg_get_frame;<br />
<br />
Here we are setting the get_frame callback. There are other callbacks but since "store_child" was set we do not have to worry about implementing all of them.<br />
<br />
v = avs_new_value_clip(new_clip);<br />
<br />
The return value is then set to the new clip returned by avs_new_c_filter. avs_new_value_clip converts the clip info an AVS_Value (???). It also creates a new reference to the clip.<br />
<br />
avs_release_clip(new_clip);<br />
<br />
We must now release the clip returned by avs_new_c_filter. In the case of an error the clip is no longer needed. Otherwise a new reference is created to the clip with avs_new_value_clip so we must release the orignal reference.<br />
<br />
return v;<br />
<br />
Finally we return. "v" is either an error or the new clip.<br />
<br />
const char* AVSC_CC avisynth_c_plugin_init(AVS_ScriptEnvironment * env)<br />
<br />
This is the only function which gets exported from the DLL. It is called by the script function LoadCPlugin the first time this plugin in loaded in a particular script. If several scripts are open at once and more than one of them loads this plugin, avisynth_c_plugin_init may be called more than once with different ScriptEnvironments. Therefore:<br />
<br />
* You should not save the env parameter in a global variable.<br />
* If you need to initialize any static data, you should do it in DLLMain, not in this function. <br />
<br />
The main purpose of the avisynth_c_plugin_init function is to call avs_add_function.<br />
<br />
avs_add_function(env, "InvertNeg", "c", Create_InvertNeg, 0);<br />
<br />
As promised, we now call add_function to let Avisynth know of the existence of our filter. This function takes four arguments: the name of the new script function; the parameter-type string; the C function implementing the script function; and the user_data cookie.<br />
<br />
The parameter type string specifies the paramaters for the function. The return value is untyped. It consists of a series of letters specinging the parameter types with 'c' for clip, 'i' for integer, 's' for string, 'b' for boolean, and 'f' for float. In addition:<br />
<br />
* Any type can be followed with a '*' or '+' to indicate "zero or more" or "one or more" respectively. In this case all the matching arguments will be gathered into a sub-array. For example, if your type string is "is+f", then the integer argument will be args[0], the string arguments will be args[1][0], args[1][1], etc. (and there will be avs_array_size(args[1]) of them), and the float argument will be args[2].<br />
* '.' matches a single argument of any type. To match multiple arguments of any type, use ".*" or ".+".<br />
* Named arguments can be specified in [brackets] before the type. Named arguments are also optional arguments; if the user omits them, they will be of the undefined type instead of the type you specify. <br />
<br />
return "InvertNeg sample c-plugin";<br />
<br />
The return value of avisynth_c_plugin_init is a string which can contain any message you like, such as a notice identifying the version and author of the plugin. This string becomes the return value of LoadCPlugin, and will almost always be ignored. You can also just return 0 if you prefer.<br />
<br />
== As an in-place filter ==<br />
<br />
The InvertNeg filter could easily do its work in a single buffer, rather than copying from one buffer to another. Here's a new implementation of get_frame that does this:<br />
<br />
#include "avisynth_c.h"<br />
<br />
AVS_VideoFrame* AVSC_CC InvertNeg_get_frame(AVS_FilterInfo* fi, int n)<br />
{<br />
AVS_VideoFrame* src;<br />
int row_size, height, src_pitch;<br />
BYTE* srcp;<br />
int x, y, p;<br />
<br />
int planes[] = {AVS_PLANAR_Y, AVS_PLANAR_V, AVS_PLANAR_U};<br />
<br />
src = avs_get_frame(fi->child, n);<br />
avs_make_writable(fi->env, &src);<br />
<br />
for (p=0; p<3; p++) {<br />
srcp = avs_get_write_ptr_p(src, planes[p]);<br />
src_pitch = avs_get_pitch_p(src, planes[p]);<br />
row_size = avs_get_row_size_p(src, planes[p]);<br />
height = avs_get_height_p(src, planes[p]);<br />
<br />
for (y = 0; y < height; y++) {<br />
for (x = 0; x < row_size; x++) {<br />
srcp[x] = srcp[x] ^ 255; // or srcp[x] =^ 255;<br />
}<br />
srcp += src_pitch;<br />
}<br />
}<br />
<br />
return src;<br />
}<br />
<br />
AVS_Value AVSC_CC Create_InvertNeg(AVS_ScriptEnvironment* env, AVS_Value args, void* user_data)<br />
{<br />
AVS_Value v;<br />
AVS_FilterInfo* fi;<br />
AVS_Clip* new_clip = avs_new_c_filter(env, &fi, avs_array_elt(args, 0), 1);<br />
<br />
if (!avs_is_planar(&fi->vi) || !avs_is_yuv(&fi->vi)) {<br />
v = avs_new_value_error("InvertNeg: planar YUV data only!");<br />
} else {<br />
fi->get_frame = InvertNeg_get_frame;<br />
v = avs_new_value_clip(new_clip);<br />
}<br />
<br />
avs_release_clip(new_clip);<br />
return v;<br />
}<br />
<br />
const char* AVSC_CC avisynth_c_plugin_init(AVS_ScriptEnvironment * env)<br />
{<br />
avs_add_function(env, "InvertNeg", "c", Create_InvertNeg, 0);<br />
return "InvertNeg sample c-plugin";<br />
}<br />
<br />
The key difference between this version of the function and the original version is the presence of the avs_make_writable callback. This is necessary because this time "we don't know where that source frame has been." Someone else in the filter chain may be holding a reference to it, in which case we won't be allowed to write to it.<br />
<br />
== Old versions ==<br />
<br />
[http://www.kevina.org/avisynth_c/example.html Kevin's AviSynth C API Docs] is the documentation written for the deprecated avisynth_c.dll by Kevin Atkinson, in its original form.<br />
<br />
[[Category:C API]]</div>Adminhttp://avisynth.nl/index.php/Filter_SDK/CInvertNegFilter SDK/CInvertNeg2017-01-12T21:48:01Z<p>Admin: </p>
<hr />
<div>I'll start off with a complete, working Avisynth C plugin. It's called "InvertNeg", and it produces a photo-negative of the input clip.<br />
<br />
Here's InvertNeg.c:<br />
<br />
#include "avisynth_c.h"<br />
<br />
AVS_VideoFrame* AVSC_CC InvertNeg_get_frame(AVS_FilterInfo* fi, int n)<br />
{<br />
AVS_VideoFrame* src;<br />
AVS_VideoFrame* dst;<br />
int row_size, height, src_pitch, dst_pitch;<br />
const BYTE* srcp;<br />
BYTE* dstp;<br />
int x, y, p;<br />
<br />
int planes[] = {AVS_PLANAR_Y, AVS_PLANAR_V, AVS_PLANAR_U};<br />
<br />
src = avs_get_frame(fi->child, n);<br />
dst = avs_new_video_frame(fi->env, &fi->vi);<br />
<br />
for (p=0; p<3; p++) {<br />
srcp = avs_get_read_ptr_p(src, planes[p]);<br />
dstp = avs_get_write_ptr_p(dst, planes[p]);<br />
src_pitch = avs_get_pitch_p(src, planes[p]);<br />
dst_pitch = avs_get_pitch_p(dst, planes[p]);<br />
row_size = avs_get_row_size_p(dst, planes[p]);<br />
height = avs_get_height_p(dst, planes[p]);<br />
<br />
for (y = 0; y < height; y++) {<br />
for (x = 0; x < row_size; x++) {<br />
dstp[x] = srcp[x] ^ 255;<br />
}<br />
srcp += src_pitch;<br />
dstp += dst_pitch;<br />
}<br />
}<br />
<br />
avs_release_video_frame(src);<br />
return dst;<br />
}<br />
<br />
AVS_Value AVSC_CC Create_InvertNeg(AVS_ScriptEnvironment* env, AVS_Value args, void* user_data)<br />
{<br />
AVS_Value v;<br />
AVS_FilterInfo* fi;<br />
AVS_Clip* new_clip = avs_new_c_filter(env, &fi, avs_array_elt(args, 0), 1);<br />
<br />
if (!avs_is_planar(&fi->vi) || !avs_is_yuv(&fi->vi)) {<br />
v = avs_new_value_error("InvertNeg: planar YUV data only!");<br />
} else {<br />
fi->get_frame = InvertNeg_get_frame;<br />
v = avs_new_value_clip(new_clip);<br />
}<br />
<br />
avs_release_clip(new_clip);<br />
return v;<br />
}<br />
<br />
const char* AVSC_CC avisynth_c_plugin_init(AVS_ScriptEnvironment * env)<br />
{<br />
avs_add_function(env, "InvertNeg", "c", Create_InvertNeg, 0);<br />
return "InvertNeg sample c-plugin";<br />
}<br />
<br />
Link to avisynth.lib and when using the MSVC++ compiler add the definition file. Compile this file into a DLL named InvertNeg.dll. See [[Filter_SDK/Compiling_instructions|compiling instructions]]. Now create an Avisynth script which looks something like this:<br />
<br />
LoadCPlugin("d:\path\InvertNeg.dll")<br />
clip = BlankClip().ConvertToYV12()<br />
return clip.InvertNeg()<br />
<br />
=== Line by line breakdown ===<br />
<br />
Here's a line-by-line breakdown of InvertNeg.c:<br />
<br />
#include "avisynth_c.h"<br />
<br />
This header declares all the classes and miscellaneous constants that you might need when writing a plugin. All external plugins should #include it.<br />
<br />
External plugins do not link with avisynth.dll, so they can't directly access functions that are defined in the main Avisynth source code. Therefore, every important function in avisynth_c.h is either defined inline or declared as virtual (???). The virtual functions act as callbacks for external DLLs. <br />
<br />
AVS_VideoFrame* AVSC_CC InvertNeg_get_frame(AVS_FilterInfo* fi, int n)<br />
<br />
This function is the main callback functions for our filter. When called it should return frame n. It returns this frame as a pointer to AVS_VideoFrame.<br />
<br />
AVSC_CC stands for Avisynth calling convention. Right now it is stdcall (it used to be cdecl when the C interface was exposes through seperate plugin). By using AVSC_CC you should be able to maintain source code compatibility when the calling convention changes. <br />
<br />
AVS_VideoFrame* src;<br />
AVS_VideoFrame* dst;<br />
int row_size, height, src_pitch, dst_pitch;<br />
const BYTE* srcp;<br />
BYTE* dstp;<br />
int x, y, p;<br />
<br />
Declaring all of the variables we will need '''must be done up front''' (for the C++ plugin this is not necessary). Doing it in between the code will get you strange compile errors.<br />
<br />
int planes[] = {AVS_PLANAR_Y, AVS_PLANAR_V, AVS_PLANAR_U};<br />
<br />
The plugin requires planar YUV data, so we need to process the planes. Note the constants (such as AVS_PLANAR_Y) are the same as the ones in the C++ inteface, except for the 'AVS_' in front of it.<br />
<br />
src = avs_get_frame(fi->child, n);<br />
<br />
"child" is a member of AVS_FilterInfo, of type AVS_Clip. It generally contains the clip that was passed into the filter. For our filter to produce frame n we need the corresponding frame of the input clip. If you need a different frame from the input, all you have to do is pass a different frame number get_frame.<br />
<br />
Note the functions (such as avs_get_frame) are similar as the ones in the C++ inteface, except for the 'avs_' in front of it.<br />
<br />
get_frame calls are usually intercepted by Avisynth's internal caching code, so the frame request may never actually reach the child filter (meaning ???). <br />
<br />
dst = avs_new_video_frame(fi->env, &fi->vi);<br />
<br />
The avs_new_video_frame function allocates space for a video frame of the supplied size. (In this case it will hold our filter's output.) The frame buffer is uninitialized raw memory.<br />
<br />
"env" is a member of AVS_FilterInfo which is a pointer to AVS_ScriptEnvironment. One instance of AVS_ScriptEnvironment is created for each AVS script.<br />
<br />
"vi" is another member of AVS_FilterInfo. It is a structure of type AVS_VideoInfo, which contains information about the clip (like frame size, frame rate, pixel format, audio sample rate, etc.). avs_new_video_frame uses the information in this structure to return a frame buffer of the appropriate size.<br />
<br />
Frame buffers are reused once all references to them go away. So usually memory won't need to be allocated from the heap. <br />
<br />
for (p=0; p<3; p++) {<br />
<br />
Loop over all planes.<br />
<br />
srcp = avs_get_read_ptr_p(src, planes[p]);<br />
dstp = avs_get_write_ptr_p(dst, planes[p]);<br />
<br />
All frame buffers are readable, but not all are writable.<br />
<br />
The rule about writability is this: A buffer is writable if and only if its reference count is one. In other words, you can only write to a buffer if no one else might be reading it. This rule guarantees that as long as you hold on to a video frame and don't write to it yourself, that frame will remain unchanged. Any buffer you get from avs_new_video_frame is guaranteed to be writable. However, frames you get from other clips via get_frame may not be writable, in which case avs_get_write_ptr will return a null pointer.<br />
<br />
There is an is_writable method which you can call to find out if a buffer is writable or not, and there's a avs_make_writable method (described below) to ensure that it is. <br />
<br />
src_pitch = avs_get_pitch_p(src, planes[p]);<br />
dst_pitch = avs_get_pitch_p(dst, planes[p]);<br />
<br />
The "pitch" of a frame buffer is the offset (in bytes) from the beginning of one scan line to the beginning of the next. The source and destination buffers won't necessarily have the same pitch.<br />
<br />
Buffers created by avs_new_video_frame are always double word (16-byte) aligned and always have a pitch that is a multiple of 16. <br />
<br />
row_size = avs_get_row_size_p(dst, planes[p]);<br />
<br />
The row size is the length of each row in bytes (not pixels). It's usually equal to the pitch or slightly less, but it may be significantly less if the frame in question has been through Crop.<br />
<br />
Since our source and destination frames have the same width and pixel format, they will always have the same row size. Thus I only need one row_size variable, and I could just as well have used dest instead of src. <br />
<br />
height = avs_get_height_p(dst, planes[p]);<br />
<br />
The height is the height in pixels. Again, for our filter this is the same for the source and the destination.<br />
<br />
for (y = 0; y < height; y++) {<br />
for (x = 0; x < row_size; x++) {<br />
dstp[x] = srcp[x] ^ 255;<br />
}<br />
srcp += src_pitch;<br />
dstp += dst_pitch;<br />
}<br />
}<br />
<br />
This is the code that does the actual work. The "srcp += src_pitch; dstp += dest_pitch;" idiom is a useful way of dealing with potentially differing pitches without too much grief.<br />
<br />
avs_release_video_frame(src);<br />
<br />
Once we are done with a video frame it needs to be released. Releasing a video frame does not actually delete it but decrements the reference count.<br />
<br />
return dst;<br />
<br />
GetFrame returns the newly-created frame.<br />
<br />
AVS_Value AVSC_CC Create_InvertNeg(AVS_ScriptEnvironment* env, AVS_Value args, void* user_data)<br />
<br />
In order to use our new filter, we need a scripting-language function which creates an instance of it. This is that function.<br />
<br />
Script functions written in C take three arguments. env contains the same ScriptEnvironment pointer that will later be passed to GetFrame. args contais all the arguments passed to the function by the script. user_data contains the void pointer which you passed to AddFunction (see below). Usually you won't need this.<br />
<br />
AVS_Value is a variant type which can hold any one of the following: a boolean value (true/false); an integer; a floating-point number; a string; a video clip; an array of AVS_Values; or nothing ("undefined"). You can test which one it is with the methods avs_is_bool, avs_is_int, avs_is_float, avs_is_string, avs_is_clip, avs_is_array, and avs_defined (which returns true if the AVS_Value is not "undefined"). You can get the value with avs_as_bool, avs_as_int, etc. for arrays, you can use the avs_array_size method to get the number of elements, and avs_array_elt get the elements themselves. For convenience, avs_is_float and avs_as_float will work with integers also. But boolean values are not treated as numeric (unlike C).<br />
<br />
The name "Create_InvertNeg" is arbitrary. This function will actually be known as "InvertNeg" in scripts, because that's the name we pass to avs_add_function below. <br />
<br />
AVS_Value v;<br />
<br />
v will serve as the return value.<br />
<br />
AVS_FilterInfo* fi;<br />
AVS_Clip* new_clip = avs_new_c_filter(env, &fi, avs_array_elt(args, 0), 1);<br />
<br />
"avs_new_c_filter" creates a new filter. AVS_Clip is an abstract type representing a filter. In this case it will represent our new filter. "env" is the current script environment. "fi" will be set to point to our filter AVS_FilterInfo which is the concrete representation of a C filter. We will modify this structure later. "avs_array_elt(args, 0)" is accessing the first value of args, which is generally the parent clip. The last parameter, is a boolean value "store_child". It should generally always be set to true.<br />
<br />
if (!avs_is_planar(&fi->vi) || !avs_is_yuv(&fi->vi)) {<br />
v = avs_new_value_error("InvertNeg: planar YUV data only!");<br />
} else {<br />
<br />
Our filter will not work unless the video is stored as YUV planar. If this is not the case than an error is returned. This is done be setting the return value to an error condition.<br />
<br />
fi->get_frame = InvertNeg_get_frame;<br />
<br />
Here we are setting the get_frame callback. There are other callbacks but since "store_child" was set we do not have to worry about implementing all of them.<br />
<br />
v = avs_new_value_clip(new_clip);<br />
<br />
The return value is then set to the new clip returned by avs_new_c_filter. avs_new_value_clip converts the clip info an AVS_Value (???). It also creates a new reference to the clip.<br />
<br />
avs_release_clip(new_clip);<br />
<br />
We must now release the clip returned by avs_new_c_filter. In the case of an error the clip is no longer needed. Otherwise a new reference is created to the clip with avs_new_value_clip so we must release the orignal reference.<br />
<br />
return v;<br />
<br />
Finally we return. "v" is either an error or the new clip.<br />
<br />
const char* AVSC_CC avisynth_c_plugin_init(AVS_ScriptEnvironment * env)<br />
<br />
This is the only function which gets exported from the DLL. It is called by the script function LoadCPlugin the first time this plugin in loaded in a particular script. If several scripts are open at once and more than one of them loads this plugin, avisynth_c_plugin_init may be called more than once with different ScriptEnvironments. Therefore:<br />
<br />
* You should not save the env parameter in a global variable.<br />
* If you need to initialize any static data, you should do it in DLLMain, not in this function. <br />
<br />
The main purpose of the avisynth_c_plugin_init function is to call avs_add_function.<br />
<br />
avs_add_function(env, "InvertNeg", "c", Create_InvertNeg, 0);<br />
<br />
As promised, we now call add_function to let Avisynth know of the existence of our filter. This function takes four arguments: the name of the new script function; the parameter-type string; the C function implementing the script function; and the user_data cookie.<br />
<br />
The parameter type string specifies the paramaters for the function. The return value is untyped. It consists of a series of letters specinging the parameter types with 'c' for clip, 'i' for integer, 's' for string, 'b' for boolean, and 'f' for float. In addition:<br />
<br />
* Any type can be followed with a '*' or '+' to indicate "zero or more" or "one or more" respectively. In this case all the matching arguments will be gathered into a sub-array. For example, if your type string is "is+f", then the integer argument will be args[0], the string arguments will be args[1][0], args[1][1], etc. (and there will be avs_array_size(args[1]) of them), and the float argument will be args[2].<br />
* '.' matches a single argument of any type. To match multiple arguments of any type, use ".*" or ".+".<br />
* Named arguments can be specified in [brackets] before the type. Named arguments are also optional arguments; if the user omits them, they will be of the undefined type instead of the type you specify. <br />
<br />
return "InvertNeg sample c-plugin";<br />
<br />
The return value of avisynth_c_plugin_init is a string which can contain any message you like, such as a notice identifying the version and author of the plugin. This string becomes the return value of LoadCPlugin, and will almost always be ignored. You can also just return 0 if you prefer.<br />
<br />
== As an in-place filter ==<br />
<br />
The InvertNeg filter could easily do its work in a single buffer, rather than copying from one buffer to another. Here's a new implementation of get_frame that does this:<br />
<br />
#include "avisynth_c.h"<br />
<br />
AVS_VideoFrame* AVSC_CC InvertNeg_get_frame(AVS_FilterInfo* fi, int n)<br />
{<br />
AVS_VideoFrame* src;<br />
int row_size, height, src_pitch;<br />
BYTE* srcp;<br />
int x, y, p;<br />
<br />
int planes[] = {AVS_PLANAR_Y, AVS_PLANAR_V, AVS_PLANAR_U};<br />
<br />
src = avs_get_frame(fi->child, n);<br />
avs_make_writable(fi->env, &src);<br />
<br />
for (p=0; p<3; p++) {<br />
srcp = avs_get_write_ptr_p(src, planes[p]);<br />
src_pitch = avs_get_pitch_p(src, planes[p]);<br />
row_size = avs_get_row_size_p(src, planes[p]);<br />
height = avs_get_height_p(src, planes[p]);<br />
<br />
for (y = 0; y < height; y++) {<br />
for (x = 0; x < row_size; x++) {<br />
srcp[x] = srcp[x] ^ 255; // or srcp[x] =^ 255;<br />
}<br />
srcp += src_pitch;<br />
}<br />
}<br />
<br />
return src;<br />
}<br />
<br />
AVS_Value AVSC_CC Create_InvertNeg(AVS_ScriptEnvironment* env, AVS_Value args, void* user_data)<br />
{<br />
AVS_Value v;<br />
AVS_FilterInfo* fi;<br />
AVS_Clip* new_clip = avs_new_c_filter(env, &fi, avs_array_elt(args, 0), 1);<br />
<br />
if (!avs_is_planar(&fi->vi) || !avs_is_yuv(&fi->vi)) {<br />
v = avs_new_value_error("InvertNeg: planar YUV data only!");<br />
} else {<br />
fi->get_frame = InvertNeg_get_frame;<br />
v = avs_new_value_clip(new_clip);<br />
}<br />
<br />
avs_release_clip(new_clip);<br />
return v;<br />
}<br />
<br />
const char* AVSC_CC avisynth_c_plugin_init(AVS_ScriptEnvironment * env)<br />
{<br />
avs_add_function(env, "InvertNeg", "c", Create_InvertNeg, 0);<br />
return "InvertNeg sample c-plugin";<br />
}<br />
<br />
The key difference between this version of the function and the original version is the presence of the avs_make_writable callback. This is necessary because this time "we don't know where that source frame has been." Someone else in the filter chain may be holding a reference to it, in which case we won't be allowed to write to it.<br />
<br />
== Old versions ==<br />
<br />
[http://www.kevina.org/avisynth_c/example.html Kevin's AviSynth C API Docs] is the documentation written for the deprecated avisynth_c.dll by Kevin Atkinson, in its original form.<br />
<br />
[[Category:FilterSDK]]<br />
[[Category:C API]]</div>Adminhttp://avisynth.nl/index.php/Filter_SDK/C_APIFilter SDK/C API2017-01-07T23:17:08Z<p>Admin: </p>
<hr />
<div>The header, avisynth_c.h, declares all the structures and miscellaneous constants that you might need when writing a plugin. All external plugins should #include it:<br />
<br />
#include "avisynth_c.h"<br />
<br />
----<br />
<br />
== differences C and C++ ==<br />
<br />
put somewhere else.<br />
<br />
=== CreateScriptEnvironment ===<br />
<br />
=== Structures ===<br />
<br />
See C++ API for descriptions. If there is no C++ API equivalent, the description is given here.<br />
<br />
{|class="wikitable"<br />
!text-align:center;"|C++ API<br />
!text-align:center;"|C API<br />
|-<br />
|AvisynthError<br />
|?<br />
|-<br />
|doesn't exist<br />
|AVS_FilterInfo<br />
|-<br />
|VideoFrameBuffer<br />
|AVS_VideoFrameBuffer<br />
|-<br />
|VideoFrame<br />
|AVS_VideoFrame<br />
|-<br />
|AlignPlanar<br />
|doesn't exist<br />
|-<br />
|FillBorder<br />
|doesn't exist<br />
|-<br />
|ConvertAudio<br />
|doesn't exist<br />
|-<br />
|IScriptEnvironment<br />
|AVS_ScriptEnvironment<br />
|-<br />
|IClip<br />
|AVS_Clip<br />
|-<br />
|AVSValue<br />
|AVS_Value<br />
|}<br />
<br />
AVS_FilterInfo is a structure with members (the first three are structures too): <br />
* AVS_Clip (no members)<br />
* AVS_ScriptEnvironment (no members)<br />
* AVS_VideoFrame <br />
* get_parity<br />
* get_audio<br />
* set_cache_hints<br />
* free_filter<br />
* error<br />
* user_data<br />
<br />
AVS_VideoFrame is a structure with members:<br />
* offset, pitch, row_size, height, offsetU, offsetV, pitchUV<br />
* row_sizeUV, heightUV<br />
<br />
AVS_VideoInfo is a structure with members:<br />
* width, height<br />
* fps_numerator, fps_denominator<br />
* num_frames<br />
* pixel_type<br />
* audio_samples_per_second<br />
* sample_type<br />
* num_audio_samples<br />
* nchannels<br />
* image_type<br />
<br />
<br />
AVS_Value is a structure with members:<br />
* type // 'a'rray, 'c'lip, 'b'ool, 'i'nt, 'f'loat, 's'tring, 'v'oid, or 'l'ong<br />
// for some function e'rror<br />
* array_size;<br />
union {<br />
void * clip; // do not use directly, use avs_take_clip<br />
char boolean;<br />
int integer;<br />
float floating_pt;<br />
const char * string;<br />
const AVS_Value * array;<br />
} d;<br />
<br />
<br />
<br />
=== Structures ===<br />
<br />
=== Constants ===<br />
<br />
The available constants are the sames ones as in the C++ API.<br />
<br />
Note contrary to the C++ API, float audio is '''not''' typedef'd to SFLOAT.<br />
<br />
<br />
<br />
<br />
<br />
----<br />
<br />
source: http://forum.doom9.org/showthread.php?p=1464911#post1464911<br />
<br />
compiling plugins: http://forum.doom9.org/showthread.php?p=1092380#post1092380<br />
<br />
example: http://forum.doom9.org/showthread.php?p=1001260#post1001260<br />
<br />
For now the api is described here: http://www.kevina.org/avisynth_c/api.html . An example is given here: http://www.kevina.org/avisynth_c/example.html .<br />
<br />
[[Category:AviSynth_Development]]</div>Adminhttp://avisynth.nl/index.php/Filter_SDK/C_APIFilter SDK/C API2017-01-07T16:19:55Z<p>Admin: </p>
<hr />
<div>The header, avisynth_c.h, declares all the structures and miscellaneous constants that you might need when writing a plugin. All external plugins should #include it:<br />
<br />
#include "avisynth_c.h"<br />
<br />
----<br />
<br />
== differences C and C++ ==<br />
<br />
put somewhere else.<br />
<br />
=== CreateScriptEnvironment ===<br />
<br />
=== Classes ===<br />
<br />
See C++ API for descriptions. If there is no C++ API equivalent, the description is given here.<br />
<br />
{|class="wikitable"<br />
!text-align:center;"|C++ API<br />
!text-align:center;"|C API<br />
|-<br />
|AvisynthError<br />
|?<br />
|-<br />
|doesn't exist<br />
|AVS_FilterInfo<br />
|-<br />
|VideoFrameBuffer<br />
|AVS_VideoFrameBuffer<br />
|-<br />
|VideoFrame<br />
|AVS_VideoFrame<br />
|-<br />
|AlignPlanar<br />
|doesn't exist<br />
|-<br />
|FillBorder<br />
|doesn't exist<br />
|-<br />
|ConvertAudio<br />
|doesn't exist<br />
|-<br />
|IScriptEnvironment<br />
|AVS_ScriptEnvironment<br />
|-<br />
|IClip<br />
|AVS_Clip<br />
|-<br />
|AVSValue<br />
|AVS_Value<br />
|}<br />
<br />
AVS_FilterInfo is a structure with members (the first three are structures too): <br />
* AVS_Clip (no members)<br />
* AVS_ScriptEnvironment (no members)<br />
* AVS_VideoFrame <br />
* get_parity<br />
* get_audio<br />
* set_cache_hints<br />
* free_filter<br />
* error<br />
* user_data<br />
<br />
AVS_VideoFrame is a structure with members:<br />
* offset, pitch, row_size, height, offsetU, offsetV, pitchUV<br />
* row_sizeUV, heightUV<br />
<br />
AVS_VideoInfo is a structure with members:<br />
* width, height<br />
* fps_numerator, fps_denominator<br />
* num_frames<br />
* pixel_type<br />
* audio_samples_per_second<br />
* sample_type<br />
* num_audio_samples<br />
* nchannels<br />
* image_type<br />
<br />
<br />
AVS_Value is a structure with members:<br />
* type // 'a'rray, 'c'lip, 'b'ool, 'i'nt, 'f'loat, 's'tring, 'v'oid, or 'l'ong<br />
// for some function e'rror<br />
* array_size;<br />
union {<br />
void * clip; // do not use directly, use avs_take_clip<br />
char boolean;<br />
int integer;<br />
float floating_pt;<br />
const char * string;<br />
const AVS_Value * array;<br />
} d;<br />
<br />
<br />
<br />
=== Structures ===<br />
<br />
=== Constants ===<br />
<br />
The available constants are the sames ones as in the C++ API.<br />
<br />
Note contrary to the C++ API, float audio is '''not''' typedef'd to SFLOAT.<br />
<br />
<br />
<br />
<br />
<br />
----<br />
<br />
source: http://forum.doom9.org/showthread.php?p=1464911#post1464911<br />
<br />
compiling plugins: http://forum.doom9.org/showthread.php?p=1092380#post1092380<br />
<br />
example: http://forum.doom9.org/showthread.php?p=1001260#post1001260<br />
<br />
For now the api is described here: http://www.kevina.org/avisynth_c/api.html . An example is given here: http://www.kevina.org/avisynth_c/example.html .<br />
<br />
[[Category:AviSynth_Development]]</div>Adminhttp://avisynth.nl/index.php/Filter_SDK/C_API/AVS_VideoInfoFilter SDK/C API/AVS VideoInfo2017-01-07T15:45:53Z<p>Admin: /* Functions [need to add examples] */</p>
<hr />
<div>The AVS_VideoInfo structure holds global information about a clip (i.e. information that does not depend on the frame number). It's a member of the AVS_FilterInfo structure. Below is a description of it (for AVISYNTH_INTERFACE_VERSION=6).<br />
<br />
== Properties and constants ==<br />
* Colorspace constants, Colorformat constants and Image_type constants:<br />
<br />
:These constants are the same as the ones in the C++ API with a AVS_ prefix. For example, the C++ API constant CS_BGR becomes AVS_CS_BGR.<br />
<br />
:For some reason these constants are not part of the AVS_VideoInfo structure. Why not???<br />
<br />
* Colorspace properties, Image_type properties and General properties:<br />
<br />
:These are the same as in the C++ API.<br />
<br />
* Chroma placement constants (bits 20 -> 23):<br />
<br />
:They are missing in the C API. Todo: add them in the API.<br />
<br />
* Remaining constants (they are not present in the C++ API):<br />
<br />
enum {<br />
AVS_FILTER_TYPE=1,<br />
AVS_FILTER_INPUT_COLORSPACE=2,<br />
AVS_FILTER_OUTPUT_TYPE=9,<br />
AVS_FILTER_NAME=4,<br />
AVS_FILTER_AUTHOR=5,<br />
AVS_FILTER_VERSION=6,<br />
AVS_FILTER_ARGS=7,<br />
AVS_FILTER_ARGS_INFO=8,<br />
AVS_FILTER_ARGS_DESCRIPTION=10,<br />
AVS_FILTER_DESCRIPTION=11<br />
};<br />
<br />
enum { //SUBTYPES<br />
AVS_FILTER_TYPE_AUDIO=1,<br />
AVS_FILTER_TYPE_VIDEO=2,<br />
AVS_FILTER_OUTPUT_TYPE_SAME=3,<br />
AVS_FILTER_OUTPUT_TYPE_DIFFERENT=4<br />
};<br />
<br />
Todo: add description.<br />
<br />
== Functions [need to add examples] ==<br />
<br />
These functions are not members of the AVS_VideoInfo structure, but they take an AVS_VideoInfo structure as input. Unless stated otherwise the functions have the same funcionality as the corresponding ones in the C++ API.<br />
<br />
Note the name of the functions are basically the same as the ones in the C++ API, with a 'avs_' prefix, a AVS_VideoInfo as input, lower case letters and with a underscore between separate words in the name. <br />
<br />
For example, instead of vi.IsYUV(), you would use avs_is_yuv(&fi->vi) where fi is a pointer to AVS_FilterInfo.<br />
<br />
{|class="wikitable"<br />
!text-align:center;"|C++ API<br />
!text-align:center;"|C API<br />
|-<br />
|bool IsRGB() const<br />
|int avs_is_rgb(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsRGB24() const<br />
|int avs_is_rgb24(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsRGB32() const<br />
|int avs_is_rgb32(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYUV() const;<br />
|int avs_is_yuv(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYUY2() const;<br />
|int avs_is_yuy2(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYV24() const;<br />
|int avs_is_yv24(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYV16() const;<br />
|int avs_is_yv16(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYV12() const;<br />
|int avs_is_yv12(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYV411() const;<br />
|int avs_is_yv411(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsY8() const;<br />
|int avs_is_y8(const AVS_VideoInfo * p);<br />
|- border="2"<br />
|bool IsColorSpace(int c_space) const;<br />
|int avs_is_color_space(const AVS_VideoInfo * p, int c_space);<br />
|-<br />
|bool IsSameColorspace(const VideoInfo& vi) const;<br />
|int avs_is_same_colorspace(AVS_VideoInfo * x, AVS_VideoInfo * y)<br />
|-<br />
|bool IsPlanar() const;<br />
|int avs_is_planar(const AVS_VideoInfo * p)<br />
|-<br />
|bool Is(int property) const;<br />
|int avs_is_property(const AVS_VideoInfo * p, int property)<br />
|-<br />
|bool IsFieldBased() const;<br />
|int avs_is_field_based(const AVS_VideoInfo * p)<br />
|-<br />
|bool IsParityKnown() const;<br />
|int avs_is_parity_known(const AVS_VideoInfo * p)<br />
|-<br />
|bool IsBFF() const;<br />
|int avs_is_bff(const AVS_VideoInfo * p)<br />
|-<br />
|bool IsTFF() const;<br />
|int avs_is_tff(const AVS_VideoInfo * p);<br />
|-<br />
|void SetFieldBased(bool isfieldbased);<br />
|void avs_set_field_based(AVS_VideoInfo * p, int isfieldbased);<br />
|-<br />
|void Set(int property);<br />
|void avs_set_property(AVS_VideoInfo * p, int property);<br />
|-<br />
|void Clear(int property);<br />
|void avs_clear_property(AVS_VideoInfo * p, int property);<br />
|-<br />
|int BitsPerPixel() const;<br />
|int avs_bits_per_pixel(const AVS_VideoInfo * p);<br />
|-<br />
|void SetFPS(unsigned numerator, unsigned denominator);<br />
|void avs_set_fps(AVS_VideoInfo * p, unsigned numerator, unsigned denominator)<br />
|-<br />
|void MulDivFPS(unsigned multiplier, unsigned divisor);<br />
|doesn't exist<br />
|-<br />
|int BytesFromPixels(int pixels) const;<br />
|int avs_bytes_from_pixels(const AVS_VideoInfo * p, int pixels);<br />
|-<br />
|int RowSize(int plane=0) const;<br />
|int avs_row_size_p(const AVS_VideoInfo * p, int plane);<br />
|-<br />
|int BMPSize() const;<br />
|int avs_bmp_size(const AVS_VideoInfo * vi);<br />
|-<br />
|int GetPlaneWidthSubsampling(int plane) const;<br />
|int avs_get_plane_width_subsampling(const AVS_VideoInfo * p, int plane);<br />
|-<br />
|int GetPlaneHeightSubsampling(int plane) const;<br />
|int avs_get_plane_height_subsampling(const AVS_VideoInfo * p, int plane);<br />
|-<br />
|bool HasAudio() const;<br />
|int avs_has_audio(const AVS_VideoInfo * p);<br />
|-<br />
|int AudioChannels() const;<br />
|int avs_audio_channels(const AVS_VideoInfo * p);<br />
|-<br />
|int SampleType() const;<br />
|int avs_sample_type(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsSampleType(int testtype) const;<br />
|doesn't exist<br />
|-<br />
|int SamplesPerSecond() const;<br />
|int avs_samples_per_second(const AVS_VideoInfo * p);<br />
|-<br />
|int BytesPerAudioSample() const;<br />
|int avs_bytes_per_audio_sample(const AVS_VideoInfo * p);<br />
|-<br />
|int BytesPerChannelSample() const;<br />
|int avs_bytes_per_channel_sample(const AVS_VideoInfo * p);<br />
|-<br />
|__int64 AudioSamplesFromFrames(int frames) const;<br />
|INT64 avs_audio_samples_from_frames(const AVS_VideoInfo * p, INT64 frames);<br />
|-<br />
|int FramesFromAudioSamples(__int64 samples) const;<br />
|int avs_frames_from_audio_samples(const AVS_VideoInfo * p, INT64 samples);<br />
|-<br />
|__int64 AudioSamplesFromBytes(__int64 bytes) const;<br />
|INT64 avs_audio_samples_from_bytes(const AVS_VideoInfo * p, INT64 bytes);<br />
|-<br />
|__int64 BytesFromAudioSamples(__int64 samples) const;<br />
|INT64 avs_bytes_from_audio_samples(const AVS_VideoInfo * p, INT64 samples);<br />
|}</div>Adminhttp://avisynth.nl/index.php/Filter_SDK/C_API/AVS_VideoInfoFilter SDK/C API/AVS VideoInfo2017-01-07T15:45:12Z<p>Admin: /* Functions [need to add examples] */</p>
<hr />
<div>The AVS_VideoInfo structure holds global information about a clip (i.e. information that does not depend on the frame number). It's a member of the AVS_FilterInfo structure. Below is a description of it (for AVISYNTH_INTERFACE_VERSION=6).<br />
<br />
== Properties and constants ==<br />
* Colorspace constants, Colorformat constants and Image_type constants:<br />
<br />
:These constants are the same as the ones in the C++ API with a AVS_ prefix. For example, the C++ API constant CS_BGR becomes AVS_CS_BGR.<br />
<br />
:For some reason these constants are not part of the AVS_VideoInfo structure. Why not???<br />
<br />
* Colorspace properties, Image_type properties and General properties:<br />
<br />
:These are the same as in the C++ API.<br />
<br />
* Chroma placement constants (bits 20 -> 23):<br />
<br />
:They are missing in the C API. Todo: add them in the API.<br />
<br />
* Remaining constants (they are not present in the C++ API):<br />
<br />
enum {<br />
AVS_FILTER_TYPE=1,<br />
AVS_FILTER_INPUT_COLORSPACE=2,<br />
AVS_FILTER_OUTPUT_TYPE=9,<br />
AVS_FILTER_NAME=4,<br />
AVS_FILTER_AUTHOR=5,<br />
AVS_FILTER_VERSION=6,<br />
AVS_FILTER_ARGS=7,<br />
AVS_FILTER_ARGS_INFO=8,<br />
AVS_FILTER_ARGS_DESCRIPTION=10,<br />
AVS_FILTER_DESCRIPTION=11<br />
};<br />
<br />
enum { //SUBTYPES<br />
AVS_FILTER_TYPE_AUDIO=1,<br />
AVS_FILTER_TYPE_VIDEO=2,<br />
AVS_FILTER_OUTPUT_TYPE_SAME=3,<br />
AVS_FILTER_OUTPUT_TYPE_DIFFERENT=4<br />
};<br />
<br />
Todo: add description.<br />
<br />
== Functions [need to add examples] ==<br />
<br />
These functions are not members of the AVS_VideoInfo structure, but they take an AVS_VideoInfo structure as input. Unless stated otherwise the functions have the same funcionality as the corresponding ones in the C++ API.<br />
<br />
Note the name of the functions are basically the same as the ones in the C++ API, with a 'avs_' prefix, a AVS_VideoInfo as input, lower case letters and with a '_' between separate words in the name. <br />
<br />
For example, instead of vi.IsYUV(), you would use avs_is_yuv(&fi->vi) where fi is a pointer to AVS_FilterInfo.<br />
<br />
{|class="wikitable"<br />
!text-align:center;"|C++ API<br />
!text-align:center;"|C API<br />
|-<br />
|bool IsRGB() const<br />
|int avs_is_rgb(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsRGB24() const<br />
|int avs_is_rgb24(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsRGB32() const<br />
|int avs_is_rgb32(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYUV() const;<br />
|int avs_is_yuv(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYUY2() const;<br />
|int avs_is_yuy2(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYV24() const;<br />
|int avs_is_yv24(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYV16() const;<br />
|int avs_is_yv16(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYV12() const;<br />
|int avs_is_yv12(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYV411() const;<br />
|int avs_is_yv411(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsY8() const;<br />
|int avs_is_y8(const AVS_VideoInfo * p);<br />
|- border="2"<br />
|bool IsColorSpace(int c_space) const;<br />
|int avs_is_color_space(const AVS_VideoInfo * p, int c_space);<br />
|-<br />
|bool IsSameColorspace(const VideoInfo& vi) const;<br />
|int avs_is_same_colorspace(AVS_VideoInfo * x, AVS_VideoInfo * y)<br />
|-<br />
|bool IsPlanar() const;<br />
|int avs_is_planar(const AVS_VideoInfo * p)<br />
|-<br />
|bool Is(int property) const;<br />
|int avs_is_property(const AVS_VideoInfo * p, int property)<br />
|-<br />
|bool IsFieldBased() const;<br />
|int avs_is_field_based(const AVS_VideoInfo * p)<br />
|-<br />
|bool IsParityKnown() const;<br />
|int avs_is_parity_known(const AVS_VideoInfo * p)<br />
|-<br />
|bool IsBFF() const;<br />
|int avs_is_bff(const AVS_VideoInfo * p)<br />
|-<br />
|bool IsTFF() const;<br />
|int avs_is_tff(const AVS_VideoInfo * p);<br />
|-<br />
|void SetFieldBased(bool isfieldbased);<br />
|void avs_set_field_based(AVS_VideoInfo * p, int isfieldbased);<br />
|-<br />
|void Set(int property);<br />
|void avs_set_property(AVS_VideoInfo * p, int property);<br />
|-<br />
|void Clear(int property);<br />
|void avs_clear_property(AVS_VideoInfo * p, int property);<br />
|-<br />
|int BitsPerPixel() const;<br />
|int avs_bits_per_pixel(const AVS_VideoInfo * p);<br />
|-<br />
|void SetFPS(unsigned numerator, unsigned denominator);<br />
|void avs_set_fps(AVS_VideoInfo * p, unsigned numerator, unsigned denominator)<br />
|-<br />
|void MulDivFPS(unsigned multiplier, unsigned divisor);<br />
|doesn't exist<br />
|-<br />
|int BytesFromPixels(int pixels) const;<br />
|int avs_bytes_from_pixels(const AVS_VideoInfo * p, int pixels);<br />
|-<br />
|int RowSize(int plane=0) const;<br />
|int avs_row_size_p(const AVS_VideoInfo * p, int plane);<br />
|-<br />
|int BMPSize() const;<br />
|int avs_bmp_size(const AVS_VideoInfo * vi);<br />
|-<br />
|int GetPlaneWidthSubsampling(int plane) const;<br />
|int avs_get_plane_width_subsampling(const AVS_VideoInfo * p, int plane);<br />
|-<br />
|int GetPlaneHeightSubsampling(int plane) const;<br />
|int avs_get_plane_height_subsampling(const AVS_VideoInfo * p, int plane);<br />
|-<br />
|bool HasAudio() const;<br />
|int avs_has_audio(const AVS_VideoInfo * p);<br />
|-<br />
|int AudioChannels() const;<br />
|int avs_audio_channels(const AVS_VideoInfo * p);<br />
|-<br />
|int SampleType() const;<br />
|int avs_sample_type(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsSampleType(int testtype) const;<br />
|doesn't exist<br />
|-<br />
|int SamplesPerSecond() const;<br />
|int avs_samples_per_second(const AVS_VideoInfo * p);<br />
|-<br />
|int BytesPerAudioSample() const;<br />
|int avs_bytes_per_audio_sample(const AVS_VideoInfo * p);<br />
|-<br />
|int BytesPerChannelSample() const;<br />
|int avs_bytes_per_channel_sample(const AVS_VideoInfo * p);<br />
|-<br />
|__int64 AudioSamplesFromFrames(int frames) const;<br />
|INT64 avs_audio_samples_from_frames(const AVS_VideoInfo * p, INT64 frames);<br />
|-<br />
|int FramesFromAudioSamples(__int64 samples) const;<br />
|int avs_frames_from_audio_samples(const AVS_VideoInfo * p, INT64 samples);<br />
|-<br />
|__int64 AudioSamplesFromBytes(__int64 bytes) const;<br />
|INT64 avs_audio_samples_from_bytes(const AVS_VideoInfo * p, INT64 bytes);<br />
|-<br />
|__int64 BytesFromAudioSamples(__int64 samples) const;<br />
|INT64 avs_bytes_from_audio_samples(const AVS_VideoInfo * p, INT64 samples);<br />
|}</div>Adminhttp://avisynth.nl/index.php/Filter_SDK/C_API/AVS_VideoInfoFilter SDK/C API/AVS VideoInfo2017-01-07T15:24:44Z<p>Admin: /* Functions [need to add examples] */</p>
<hr />
<div>The AVS_VideoInfo structure holds global information about a clip (i.e. information that does not depend on the frame number). It's a member of the AVS_FilterInfo structure. Below is a description of it (for AVISYNTH_INTERFACE_VERSION=6).<br />
<br />
== Properties and constants ==<br />
* Colorspace constants, Colorformat constants and Image_type constants:<br />
<br />
:These constants are the same as the ones in the C++ API with a AVS_ prefix. For example, the C++ API constant CS_BGR becomes AVS_CS_BGR.<br />
<br />
:For some reason these constants are not part of the AVS_VideoInfo structure. Why not???<br />
<br />
* Colorspace properties, Image_type properties and General properties:<br />
<br />
:These are the same as in the C++ API.<br />
<br />
* Chroma placement constants (bits 20 -> 23):<br />
<br />
:They are missing in the C API. Todo: add them in the API.<br />
<br />
* Remaining constants (they are not present in the C++ API):<br />
<br />
enum {<br />
AVS_FILTER_TYPE=1,<br />
AVS_FILTER_INPUT_COLORSPACE=2,<br />
AVS_FILTER_OUTPUT_TYPE=9,<br />
AVS_FILTER_NAME=4,<br />
AVS_FILTER_AUTHOR=5,<br />
AVS_FILTER_VERSION=6,<br />
AVS_FILTER_ARGS=7,<br />
AVS_FILTER_ARGS_INFO=8,<br />
AVS_FILTER_ARGS_DESCRIPTION=10,<br />
AVS_FILTER_DESCRIPTION=11<br />
};<br />
<br />
enum { //SUBTYPES<br />
AVS_FILTER_TYPE_AUDIO=1,<br />
AVS_FILTER_TYPE_VIDEO=2,<br />
AVS_FILTER_OUTPUT_TYPE_SAME=3,<br />
AVS_FILTER_OUTPUT_TYPE_DIFFERENT=4<br />
};<br />
<br />
Todo: add description.<br />
<br />
== Functions [need to add examples] ==<br />
<br />
These functions are not members of the AVS_VideoInfo structure, but they take an AVS_VideoInfo structure as input. Unless stated otherwise the functions have the same funcionality as the corresponding ones in the C++ API.<br />
<br />
Note the name of the functions are basically the same as the ones in the C++ API, with a 'avs_' prefix, a AVS_VideoInfo as input, lower case letters and with a '_' between separate words in the name. <br />
<br />
todo: example<br />
<br />
{|class="wikitable"<br />
!text-align:center;"|C++ API<br />
!text-align:center;"|C API<br />
|-<br />
|bool IsRGB() const<br />
|int avs_is_rgb(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsRGB24() const<br />
|int avs_is_rgb24(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsRGB32() const<br />
|int avs_is_rgb32(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYUV() const;<br />
|int avs_is_yuv(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYUY2() const;<br />
|int avs_is_yuy2(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYV24() const;<br />
|int avs_is_yv24(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYV16() const;<br />
|int avs_is_yv16(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYV12() const;<br />
|int avs_is_yv12(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYV411() const;<br />
|int avs_is_yv411(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsY8() const;<br />
|int avs_is_y8(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsColorSpace(int c_space) const;<br />
|int avs_is_color_space(const AVS_VideoInfo * p, int c_space);<br />
|-<br />
|bool IsSameColorspace(const VideoInfo& vi) const;<br />
|int avs_is_same_colorspace(AVS_VideoInfo * x, AVS_VideoInfo * y)<br />
|-<br />
|bool IsPlanar() const;<br />
|int avs_is_planar(const AVS_VideoInfo * p)<br />
|-<br />
|bool Is(int property) const;<br />
|int avs_is_property(const AVS_VideoInfo * p, int property)<br />
|-<br />
|bool IsFieldBased() const;<br />
|int avs_is_field_based(const AVS_VideoInfo * p)<br />
|-<br />
|bool IsParityKnown() const;<br />
|int avs_is_parity_known(const AVS_VideoInfo * p)<br />
|-<br />
|bool IsBFF() const;<br />
|int avs_is_bff(const AVS_VideoInfo * p)<br />
|-<br />
|bool IsTFF() const;<br />
|int avs_is_tff(const AVS_VideoInfo * p);<br />
|-<br />
|void SetFieldBased(bool isfieldbased);<br />
|void avs_set_field_based(AVS_VideoInfo * p, int isfieldbased);<br />
|-<br />
|void Set(int property);<br />
|void avs_set_property(AVS_VideoInfo * p, int property);<br />
|-<br />
|void Clear(int property);<br />
|void avs_clear_property(AVS_VideoInfo * p, int property);<br />
|-<br />
|int BitsPerPixel() const;<br />
|int avs_bits_per_pixel(const AVS_VideoInfo * p);<br />
|-<br />
|void SetFPS(unsigned numerator, unsigned denominator);<br />
|void avs_set_fps(AVS_VideoInfo * p, unsigned numerator, unsigned denominator)<br />
|-<br />
|void MulDivFPS(unsigned multiplier, unsigned divisor);<br />
|doesn't exist<br />
|-<br />
|int BytesFromPixels(int pixels) const;<br />
|int avs_bytes_from_pixels(const AVS_VideoInfo * p, int pixels);<br />
|-<br />
|int RowSize(int plane=0) const;<br />
|int avs_row_size_p(const AVS_VideoInfo * p, int plane);<br />
|-<br />
|int BMPSize() const;<br />
|int avs_bmp_size(const AVS_VideoInfo * vi);<br />
|-<br />
|int GetPlaneWidthSubsampling(int plane) const;<br />
|int avs_get_plane_width_subsampling(const AVS_VideoInfo * p, int plane);<br />
|-<br />
|int GetPlaneHeightSubsampling(int plane) const;<br />
|int avs_get_plane_height_subsampling(const AVS_VideoInfo * p, int plane);<br />
|-<br />
|bool HasAudio() const;<br />
|int avs_has_audio(const AVS_VideoInfo * p);<br />
|-<br />
|int AudioChannels() const;<br />
|int avs_audio_channels(const AVS_VideoInfo * p);<br />
|-<br />
|int SampleType() const;<br />
|int avs_sample_type(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsSampleType(int testtype) const;<br />
|doesn't exist<br />
|-<br />
|int SamplesPerSecond() const;<br />
|int avs_samples_per_second(const AVS_VideoInfo * p);<br />
|-<br />
|int BytesPerAudioSample() const;<br />
|int avs_bytes_per_audio_sample(const AVS_VideoInfo * p);<br />
|-<br />
|int BytesPerChannelSample() const;<br />
|int avs_bytes_per_channel_sample(const AVS_VideoInfo * p);<br />
|-<br />
|__int64 AudioSamplesFromFrames(int frames) const;<br />
|INT64 avs_audio_samples_from_frames(const AVS_VideoInfo * p, INT64 frames);<br />
|-<br />
|int FramesFromAudioSamples(__int64 samples) const;<br />
|int avs_frames_from_audio_samples(const AVS_VideoInfo * p, INT64 samples);<br />
|-<br />
|__int64 AudioSamplesFromBytes(__int64 bytes) const;<br />
|INT64 avs_audio_samples_from_bytes(const AVS_VideoInfo * p, INT64 bytes);<br />
|-<br />
|__int64 BytesFromAudioSamples(__int64 samples) const;<br />
|INT64 avs_bytes_from_audio_samples(const AVS_VideoInfo * p, INT64 samples);<br />
|-<br />
|x<br />
|y<br />
|-<br />
|x<br />
|y<br />
|-<br />
|x<br />
|y<br />
|}</div>Adminhttp://avisynth.nl/index.php/Filter_SDK/C_API/AVS_VideoInfoFilter SDK/C API/AVS VideoInfo2017-01-07T15:24:32Z<p>Admin: /* Functions [need to add examples] */</p>
<hr />
<div>The AVS_VideoInfo structure holds global information about a clip (i.e. information that does not depend on the frame number). It's a member of the AVS_FilterInfo structure. Below is a description of it (for AVISYNTH_INTERFACE_VERSION=6).<br />
<br />
== Properties and constants ==<br />
* Colorspace constants, Colorformat constants and Image_type constants:<br />
<br />
:These constants are the same as the ones in the C++ API with a AVS_ prefix. For example, the C++ API constant CS_BGR becomes AVS_CS_BGR.<br />
<br />
:For some reason these constants are not part of the AVS_VideoInfo structure. Why not???<br />
<br />
* Colorspace properties, Image_type properties and General properties:<br />
<br />
:These are the same as in the C++ API.<br />
<br />
* Chroma placement constants (bits 20 -> 23):<br />
<br />
:They are missing in the C API. Todo: add them in the API.<br />
<br />
* Remaining constants (they are not present in the C++ API):<br />
<br />
enum {<br />
AVS_FILTER_TYPE=1,<br />
AVS_FILTER_INPUT_COLORSPACE=2,<br />
AVS_FILTER_OUTPUT_TYPE=9,<br />
AVS_FILTER_NAME=4,<br />
AVS_FILTER_AUTHOR=5,<br />
AVS_FILTER_VERSION=6,<br />
AVS_FILTER_ARGS=7,<br />
AVS_FILTER_ARGS_INFO=8,<br />
AVS_FILTER_ARGS_DESCRIPTION=10,<br />
AVS_FILTER_DESCRIPTION=11<br />
};<br />
<br />
enum { //SUBTYPES<br />
AVS_FILTER_TYPE_AUDIO=1,<br />
AVS_FILTER_TYPE_VIDEO=2,<br />
AVS_FILTER_OUTPUT_TYPE_SAME=3,<br />
AVS_FILTER_OUTPUT_TYPE_DIFFERENT=4<br />
};<br />
<br />
Todo: add description.<br />
<br />
== Functions [need to add examples] ==<br />
<br />
These functions are not members of the AVS_VideoInfo structure, but they take an AVS_VideoInfo structure as input. Unless stated otherwise the functions have the same funcionality as the corresponding ones in the C++ API.<br />
<br />
Note the name of the functions are basically the same as the ones in the C++ API, with a 'avs_' prefix, as AVS_VideoInfo as input, lower case letters and with a '_' between separate words in the name. <br />
<br />
todo: example<br />
<br />
{|class="wikitable"<br />
!text-align:center;"|C++ API<br />
!text-align:center;"|C API<br />
|-<br />
|bool IsRGB() const<br />
|int avs_is_rgb(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsRGB24() const<br />
|int avs_is_rgb24(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsRGB32() const<br />
|int avs_is_rgb32(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYUV() const;<br />
|int avs_is_yuv(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYUY2() const;<br />
|int avs_is_yuy2(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYV24() const;<br />
|int avs_is_yv24(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYV16() const;<br />
|int avs_is_yv16(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYV12() const;<br />
|int avs_is_yv12(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYV411() const;<br />
|int avs_is_yv411(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsY8() const;<br />
|int avs_is_y8(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsColorSpace(int c_space) const;<br />
|int avs_is_color_space(const AVS_VideoInfo * p, int c_space);<br />
|-<br />
|bool IsSameColorspace(const VideoInfo& vi) const;<br />
|int avs_is_same_colorspace(AVS_VideoInfo * x, AVS_VideoInfo * y)<br />
|-<br />
|bool IsPlanar() const;<br />
|int avs_is_planar(const AVS_VideoInfo * p)<br />
|-<br />
|bool Is(int property) const;<br />
|int avs_is_property(const AVS_VideoInfo * p, int property)<br />
|-<br />
|bool IsFieldBased() const;<br />
|int avs_is_field_based(const AVS_VideoInfo * p)<br />
|-<br />
|bool IsParityKnown() const;<br />
|int avs_is_parity_known(const AVS_VideoInfo * p)<br />
|-<br />
|bool IsBFF() const;<br />
|int avs_is_bff(const AVS_VideoInfo * p)<br />
|-<br />
|bool IsTFF() const;<br />
|int avs_is_tff(const AVS_VideoInfo * p);<br />
|-<br />
|void SetFieldBased(bool isfieldbased);<br />
|void avs_set_field_based(AVS_VideoInfo * p, int isfieldbased);<br />
|-<br />
|void Set(int property);<br />
|void avs_set_property(AVS_VideoInfo * p, int property);<br />
|-<br />
|void Clear(int property);<br />
|void avs_clear_property(AVS_VideoInfo * p, int property);<br />
|-<br />
|int BitsPerPixel() const;<br />
|int avs_bits_per_pixel(const AVS_VideoInfo * p);<br />
|-<br />
|void SetFPS(unsigned numerator, unsigned denominator);<br />
|void avs_set_fps(AVS_VideoInfo * p, unsigned numerator, unsigned denominator)<br />
|-<br />
|void MulDivFPS(unsigned multiplier, unsigned divisor);<br />
|doesn't exist<br />
|-<br />
|int BytesFromPixels(int pixels) const;<br />
|int avs_bytes_from_pixels(const AVS_VideoInfo * p, int pixels);<br />
|-<br />
|int RowSize(int plane=0) const;<br />
|int avs_row_size_p(const AVS_VideoInfo * p, int plane);<br />
|-<br />
|int BMPSize() const;<br />
|int avs_bmp_size(const AVS_VideoInfo * vi);<br />
|-<br />
|int GetPlaneWidthSubsampling(int plane) const;<br />
|int avs_get_plane_width_subsampling(const AVS_VideoInfo * p, int plane);<br />
|-<br />
|int GetPlaneHeightSubsampling(int plane) const;<br />
|int avs_get_plane_height_subsampling(const AVS_VideoInfo * p, int plane);<br />
|-<br />
|bool HasAudio() const;<br />
|int avs_has_audio(const AVS_VideoInfo * p);<br />
|-<br />
|int AudioChannels() const;<br />
|int avs_audio_channels(const AVS_VideoInfo * p);<br />
|-<br />
|int SampleType() const;<br />
|int avs_sample_type(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsSampleType(int testtype) const;<br />
|doesn't exist<br />
|-<br />
|int SamplesPerSecond() const;<br />
|int avs_samples_per_second(const AVS_VideoInfo * p);<br />
|-<br />
|int BytesPerAudioSample() const;<br />
|int avs_bytes_per_audio_sample(const AVS_VideoInfo * p);<br />
|-<br />
|int BytesPerChannelSample() const;<br />
|int avs_bytes_per_channel_sample(const AVS_VideoInfo * p);<br />
|-<br />
|__int64 AudioSamplesFromFrames(int frames) const;<br />
|INT64 avs_audio_samples_from_frames(const AVS_VideoInfo * p, INT64 frames);<br />
|-<br />
|int FramesFromAudioSamples(__int64 samples) const;<br />
|int avs_frames_from_audio_samples(const AVS_VideoInfo * p, INT64 samples);<br />
|-<br />
|__int64 AudioSamplesFromBytes(__int64 bytes) const;<br />
|INT64 avs_audio_samples_from_bytes(const AVS_VideoInfo * p, INT64 bytes);<br />
|-<br />
|__int64 BytesFromAudioSamples(__int64 samples) const;<br />
|INT64 avs_bytes_from_audio_samples(const AVS_VideoInfo * p, INT64 samples);<br />
|-<br />
|x<br />
|y<br />
|-<br />
|x<br />
|y<br />
|-<br />
|x<br />
|y<br />
|}</div>Adminhttp://avisynth.nl/index.php/Filter_SDK/C_API/AVS_VideoInfoFilter SDK/C API/AVS VideoInfo2017-01-07T15:23:58Z<p>Admin: </p>
<hr />
<div>The AVS_VideoInfo structure holds global information about a clip (i.e. information that does not depend on the frame number). It's a member of the AVS_FilterInfo structure. Below is a description of it (for AVISYNTH_INTERFACE_VERSION=6).<br />
<br />
== Properties and constants ==<br />
* Colorspace constants, Colorformat constants and Image_type constants:<br />
<br />
:These constants are the same as the ones in the C++ API with a AVS_ prefix. For example, the C++ API constant CS_BGR becomes AVS_CS_BGR.<br />
<br />
:For some reason these constants are not part of the AVS_VideoInfo structure. Why not???<br />
<br />
* Colorspace properties, Image_type properties and General properties:<br />
<br />
:These are the same as in the C++ API.<br />
<br />
* Chroma placement constants (bits 20 -> 23):<br />
<br />
:They are missing in the C API. Todo: add them in the API.<br />
<br />
* Remaining constants (they are not present in the C++ API):<br />
<br />
enum {<br />
AVS_FILTER_TYPE=1,<br />
AVS_FILTER_INPUT_COLORSPACE=2,<br />
AVS_FILTER_OUTPUT_TYPE=9,<br />
AVS_FILTER_NAME=4,<br />
AVS_FILTER_AUTHOR=5,<br />
AVS_FILTER_VERSION=6,<br />
AVS_FILTER_ARGS=7,<br />
AVS_FILTER_ARGS_INFO=8,<br />
AVS_FILTER_ARGS_DESCRIPTION=10,<br />
AVS_FILTER_DESCRIPTION=11<br />
};<br />
<br />
enum { //SUBTYPES<br />
AVS_FILTER_TYPE_AUDIO=1,<br />
AVS_FILTER_TYPE_VIDEO=2,<br />
AVS_FILTER_OUTPUT_TYPE_SAME=3,<br />
AVS_FILTER_OUTPUT_TYPE_DIFFERENT=4<br />
};<br />
<br />
Todo: add description.<br />
<br />
== Functions [need to add examples] ==<br />
<br />
These functions are not members of the AVS_VideoInfo structure, but they take an AVS_VideoInfo structure as input. Unless stated otherwise the functions have the same funcionality as the corresponding ones in the C++ API.<br />
<br />
Note the name of the functions are basically the same as the ones in the C++ API, with a 'avs_' prefix, lower case letters and with a '_' between separate words in the name. <br />
<br />
todo: example<br />
<br />
{|class="wikitable"<br />
!text-align:center;"|C++ API<br />
!text-align:center;"|C API<br />
|-<br />
|bool IsRGB() const<br />
|int avs_is_rgb(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsRGB24() const<br />
|int avs_is_rgb24(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsRGB32() const<br />
|int avs_is_rgb32(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYUV() const;<br />
|int avs_is_yuv(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYUY2() const;<br />
|int avs_is_yuy2(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYV24() const;<br />
|int avs_is_yv24(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYV16() const;<br />
|int avs_is_yv16(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYV12() const;<br />
|int avs_is_yv12(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYV411() const;<br />
|int avs_is_yv411(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsY8() const;<br />
|int avs_is_y8(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsColorSpace(int c_space) const;<br />
|int avs_is_color_space(const AVS_VideoInfo * p, int c_space);<br />
|-<br />
|bool IsSameColorspace(const VideoInfo& vi) const;<br />
|int avs_is_same_colorspace(AVS_VideoInfo * x, AVS_VideoInfo * y)<br />
|-<br />
|bool IsPlanar() const;<br />
|int avs_is_planar(const AVS_VideoInfo * p)<br />
|-<br />
|bool Is(int property) const;<br />
|int avs_is_property(const AVS_VideoInfo * p, int property)<br />
|-<br />
|bool IsFieldBased() const;<br />
|int avs_is_field_based(const AVS_VideoInfo * p)<br />
|-<br />
|bool IsParityKnown() const;<br />
|int avs_is_parity_known(const AVS_VideoInfo * p)<br />
|-<br />
|bool IsBFF() const;<br />
|int avs_is_bff(const AVS_VideoInfo * p)<br />
|-<br />
|bool IsTFF() const;<br />
|int avs_is_tff(const AVS_VideoInfo * p);<br />
|-<br />
|void SetFieldBased(bool isfieldbased);<br />
|void avs_set_field_based(AVS_VideoInfo * p, int isfieldbased);<br />
|-<br />
|void Set(int property);<br />
|void avs_set_property(AVS_VideoInfo * p, int property);<br />
|-<br />
|void Clear(int property);<br />
|void avs_clear_property(AVS_VideoInfo * p, int property);<br />
|-<br />
|int BitsPerPixel() const;<br />
|int avs_bits_per_pixel(const AVS_VideoInfo * p);<br />
|-<br />
|void SetFPS(unsigned numerator, unsigned denominator);<br />
|void avs_set_fps(AVS_VideoInfo * p, unsigned numerator, unsigned denominator)<br />
|-<br />
|void MulDivFPS(unsigned multiplier, unsigned divisor);<br />
|doesn't exist<br />
|-<br />
|int BytesFromPixels(int pixels) const;<br />
|int avs_bytes_from_pixels(const AVS_VideoInfo * p, int pixels);<br />
|-<br />
|int RowSize(int plane=0) const;<br />
|int avs_row_size_p(const AVS_VideoInfo * p, int plane);<br />
|-<br />
|int BMPSize() const;<br />
|int avs_bmp_size(const AVS_VideoInfo * vi);<br />
|-<br />
|int GetPlaneWidthSubsampling(int plane) const;<br />
|int avs_get_plane_width_subsampling(const AVS_VideoInfo * p, int plane);<br />
|-<br />
|int GetPlaneHeightSubsampling(int plane) const;<br />
|int avs_get_plane_height_subsampling(const AVS_VideoInfo * p, int plane);<br />
|-<br />
|bool HasAudio() const;<br />
|int avs_has_audio(const AVS_VideoInfo * p);<br />
|-<br />
|int AudioChannels() const;<br />
|int avs_audio_channels(const AVS_VideoInfo * p);<br />
|-<br />
|int SampleType() const;<br />
|int avs_sample_type(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsSampleType(int testtype) const;<br />
|doesn't exist<br />
|-<br />
|int SamplesPerSecond() const;<br />
|int avs_samples_per_second(const AVS_VideoInfo * p);<br />
|-<br />
|int BytesPerAudioSample() const;<br />
|int avs_bytes_per_audio_sample(const AVS_VideoInfo * p);<br />
|-<br />
|int BytesPerChannelSample() const;<br />
|int avs_bytes_per_channel_sample(const AVS_VideoInfo * p);<br />
|-<br />
|__int64 AudioSamplesFromFrames(int frames) const;<br />
|INT64 avs_audio_samples_from_frames(const AVS_VideoInfo * p, INT64 frames);<br />
|-<br />
|int FramesFromAudioSamples(__int64 samples) const;<br />
|int avs_frames_from_audio_samples(const AVS_VideoInfo * p, INT64 samples);<br />
|-<br />
|__int64 AudioSamplesFromBytes(__int64 bytes) const;<br />
|INT64 avs_audio_samples_from_bytes(const AVS_VideoInfo * p, INT64 bytes);<br />
|-<br />
|__int64 BytesFromAudioSamples(__int64 samples) const;<br />
|INT64 avs_bytes_from_audio_samples(const AVS_VideoInfo * p, INT64 samples);<br />
|-<br />
|x<br />
|y<br />
|-<br />
|x<br />
|y<br />
|-<br />
|x<br />
|y<br />
|}</div>Adminhttp://avisynth.nl/index.php/Filter_SDK/C_API/AVS_VideoInfoFilter SDK/C API/AVS VideoInfo2017-01-07T15:22:02Z<p>Admin: </p>
<hr />
<div>The AVS_VideoInfo structure holds global information about a clip (i.e. information that does not depend on the frame number). It's a member of the AVS_FilterInfo structure. Below is a description of it (for AVISYNTH_INTERFACE_VERSION=6).<br />
<br />
== Properties and constants ==<br />
* Colorspace constants, Colorformat constants and Image_type constants:<br />
<br />
:These constants are the same as the ones in the C++ API with a AVS_ prefix. For example, the C++ API constant CS_BGR becomes AVS_CS_BGR.<br />
<br />
:For some reason these constants are not part of the AVS_VideoInfo structure. Why not???<br />
<br />
* Colorspace properties, Image_type properties and General properties:<br />
<br />
:These are the same as in the C++ API.<br />
<br />
* Chroma placement constants (bits 20 -> 23):<br />
<br />
:They are missing in the C API. Todo: add them in the API.<br />
<br />
* Remaining constants (they are not present in the C++ API):<br />
<br />
enum {<br />
AVS_FILTER_TYPE=1,<br />
AVS_FILTER_INPUT_COLORSPACE=2,<br />
AVS_FILTER_OUTPUT_TYPE=9,<br />
AVS_FILTER_NAME=4,<br />
AVS_FILTER_AUTHOR=5,<br />
AVS_FILTER_VERSION=6,<br />
AVS_FILTER_ARGS=7,<br />
AVS_FILTER_ARGS_INFO=8,<br />
AVS_FILTER_ARGS_DESCRIPTION=10,<br />
AVS_FILTER_DESCRIPTION=11<br />
};<br />
<br />
enum { //SUBTYPES<br />
AVS_FILTER_TYPE_AUDIO=1,<br />
AVS_FILTER_TYPE_VIDEO=2,<br />
AVS_FILTER_OUTPUT_TYPE_SAME=3,<br />
AVS_FILTER_OUTPUT_TYPE_DIFFERENT=4<br />
};<br />
<br />
Todo: add description.<br />
<br />
== Functions [need to add examples] ==<br />
<br />
These functions are not members of the AVS_VideoInfo structure, but they take an AVS_VideoInfo structure as input. Unless stated otherwise the functions have the same funcionality as the corresponding ones in the C++ API.<br />
<br />
Note the name of the functions are basically the same as the ones in the C++ API, with a 'avs_' prefix, lower case letters and with a '_' between separate words in the name. <br />
<br />
todo: example<br />
<br />
{|class="wikitable"<br />
!style="width:5em; text-align:center;"|C++ API<br />
!style="width:5em; text-align:center;"|C API<br />
|-<br />
|bool IsRGB() const<br />
|int avs_is_rgb(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsRGB24() const<br />
|int avs_is_rgb24(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsRGB32() const<br />
|int avs_is_rgb32(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYUV() const;<br />
|int avs_is_yuv(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYUY2() const;<br />
|int avs_is_yuy2(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYV24() const;<br />
|int avs_is_yv24(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYV16() const;<br />
|int avs_is_yv16(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYV12() const;<br />
|int avs_is_yv12(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsYV411() const;<br />
|int avs_is_yv411(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsY8() const;<br />
|int avs_is_y8(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsColorSpace(int c_space) const;<br />
|int avs_is_color_space(const AVS_VideoInfo * p, int c_space);<br />
|-<br />
|bool IsSameColorspace(const VideoInfo& vi) const;<br />
|int avs_is_same_colorspace(AVS_VideoInfo * x, AVS_VideoInfo * y)<br />
|-<br />
|bool IsPlanar() const;<br />
|int avs_is_planar(const AVS_VideoInfo * p)<br />
|-<br />
|bool Is(int property) const;<br />
|int avs_is_property(const AVS_VideoInfo * p, int property)<br />
|-<br />
|bool IsFieldBased() const;<br />
|int avs_is_field_based(const AVS_VideoInfo * p)<br />
|-<br />
|bool IsParityKnown() const;<br />
|int avs_is_parity_known(const AVS_VideoInfo * p)<br />
|-<br />
|bool IsBFF() const;<br />
|int avs_is_bff(const AVS_VideoInfo * p)<br />
|-<br />
|bool IsTFF() const;<br />
|int avs_is_tff(const AVS_VideoInfo * p);<br />
|-<br />
|void SetFieldBased(bool isfieldbased);<br />
|void avs_set_field_based(AVS_VideoInfo * p, int isfieldbased);<br />
|-<br />
|void Set(int property);<br />
|void avs_set_property(AVS_VideoInfo * p, int property);<br />
|-<br />
|void Clear(int property);<br />
|void avs_clear_property(AVS_VideoInfo * p, int property);<br />
|-<br />
|int BitsPerPixel() const;<br />
|int avs_bits_per_pixel(const AVS_VideoInfo * p);<br />
|-<br />
|void SetFPS(unsigned numerator, unsigned denominator);<br />
|void avs_set_fps(AVS_VideoInfo * p, unsigned numerator, unsigned denominator)<br />
|-<br />
|void MulDivFPS(unsigned multiplier, unsigned divisor);<br />
|doesn't exist<br />
|-<br />
|int BytesFromPixels(int pixels) const;<br />
|int avs_bytes_from_pixels(const AVS_VideoInfo * p, int pixels);<br />
|-<br />
|int RowSize(int plane=0) const;<br />
|int avs_row_size_p(const AVS_VideoInfo * p, int plane);<br />
|-<br />
|int BMPSize() const;<br />
|int avs_bmp_size(const AVS_VideoInfo * vi);<br />
|-<br />
|int GetPlaneWidthSubsampling(int plane) const;<br />
|int avs_get_plane_width_subsampling(const AVS_VideoInfo * p, int plane);<br />
|-<br />
|int GetPlaneHeightSubsampling(int plane) const;<br />
|int avs_get_plane_height_subsampling(const AVS_VideoInfo * p, int plane);<br />
|-<br />
|bool HasAudio() const;<br />
|int avs_has_audio(const AVS_VideoInfo * p);<br />
|-<br />
|int AudioChannels() const;<br />
|int avs_audio_channels(const AVS_VideoInfo * p);<br />
|-<br />
|int SampleType() const;<br />
|int avs_sample_type(const AVS_VideoInfo * p);<br />
|-<br />
|bool IsSampleType(int testtype) const;<br />
|doesn't exist<br />
|-<br />
|int SamplesPerSecond() const;<br />
|int avs_samples_per_second(const AVS_VideoInfo * p);<br />
|-<br />
|int BytesPerAudioSample() const;<br />
|int avs_bytes_per_audio_sample(const AVS_VideoInfo * p);<br />
|-<br />
|int BytesPerChannelSample() const;<br />
|int avs_bytes_per_channel_sample(const AVS_VideoInfo * p);<br />
|-<br />
|__int64 AudioSamplesFromFrames(int frames) const;<br />
|INT64 avs_audio_samples_from_frames(const AVS_VideoInfo * p, INT64 frames);<br />
|-<br />
|int FramesFromAudioSamples(__int64 samples) const;<br />
|int avs_frames_from_audio_samples(const AVS_VideoInfo * p, INT64 samples);<br />
|-<br />
|__int64 AudioSamplesFromBytes(__int64 bytes) const;<br />
|INT64 avs_audio_samples_from_bytes(const AVS_VideoInfo * p, INT64 bytes);<br />
|-<br />
|__int64 BytesFromAudioSamples(__int64 samples) const;<br />
|INT64 avs_bytes_from_audio_samples(const AVS_VideoInfo * p, INT64 samples);<br />
|-<br />
|x<br />
|y<br />
|-<br />
|x<br />
|y<br />
|-<br />
|x<br />
|y<br />
|}</div>Adminhttp://avisynth.nl/index.php/Filter_SDK/Cplusplus_API/VideoInfoFilter SDK/Cplusplus API/VideoInfo2017-01-07T15:08:45Z<p>Admin: /* IsColorSpace / IsSameColorspace / IsPlanar */</p>
<hr />
<div>The VideoInfo structure holds global information about a clip (i.e. information that does not depend on the frame number). The GetVideoInfo method in IClip returns this structure. Below is a description of it (for AVISYNTH_INTERFACE_VERSION=6).<br />
<br />
== Properties and constants ==<br />
<br />
// General properties:<br />
int width, height; // width=0 means no video<br />
unsigned fps_numerator, fps_denominator;<br />
int num_frames; // max. num_frames = 2,147,483,647 (signed int32)<br />
int audio_samples_per_second; // audio_samples_per_second=0 means no audio<br />
int sample_type; // samples types are defined in avisynth.h<br />
__int64 num_audio_samples;<br />
int nchannels;<br />
<br />
// Colorspace properties and constants:<br />
int pixel_type; <br />
<br />
enum {<br />
CS_BGR = 1<<28,<br />
CS_YUV = 1<<29,<br />
CS_INTERLEAVED = 1<<30,<br />
CS_PLANAR = 1<<31,<br />
<br />
// added in v5<br />
CS_Shift_Sub_Width = 0,<br />
CS_Shift_Sub_Height = 8,<br />
CS_Shift_Sample_Bits = 16,<br />
<br />
CS_Sub_Width_Mask = 7 << CS_Shift_Sub_Width,<br />
CS_Sub_Width_1 = 3 << CS_Shift_Sub_Width, // YV24<br />
CS_Sub_Width_2 = 0 << CS_Shift_Sub_Width, // YV12, I420, YV16<br />
CS_Sub_Width_4 = 1 << CS_Shift_Sub_Width, // YUV9, YV411<br />
<br />
CS_VPlaneFirst = 1 << 3, // YV12, YV16, YV24, YV411, YUV9<br />
CS_UPlaneFirst = 1 << 4, // I420<br />
<br />
CS_Sub_Height_Mask = 7 << CS_Shift_Sub_Height,<br />
CS_Sub_Height_1 = 3 << CS_Shift_Sub_Height, // YV16, YV24, YV411<br />
CS_Sub_Height_2 = 0 << CS_Shift_Sub_Height, // YV12, I420<br />
CS_Sub_Height_4 = 1 << CS_Shift_Sub_Height, // YUV9<br />
<br />
CS_Sample_Bits_Mask = 7 << CS_Shift_Sample_Bits,<br />
CS_Sample_Bits_8 = 0 << CS_Shift_Sample_Bits,<br />
CS_Sample_Bits_16 = 1 << CS_Shift_Sample_Bits,<br />
CS_Sample_Bits_32 = 2 << CS_Shift_Sample_Bits,<br />
<br />
CS_PLANAR_MASK = CS_PLANAR | CS_INTERLEAVED | CS_YUV | CS_BGR | CS_Sample_Bits_Mask | CS_Sub_Height_Mask | CS_Sub_Width_Mask,<br />
CS_PLANAR_FILTER = ~( CS_VPlaneFirst | CS_UPlaneFirst ),<br />
};<br />
<br />
// Colorformat constants:<br />
<br />
enum {<br />
CS_UNKNOWN = 0,<br />
CS_BGR24 = 1<<0 | CS_BGR | CS_INTERLEAVED,<br />
CS_BGR32 = 1<<1 | CS_BGR | CS_INTERLEAVED,<br />
CS_YUY2 = 1<<2 | CS_YUV | CS_INTERLEAVED,<br />
CS_YV12 = 1<<3 | CS_YUV | CS_PLANAR, // y-v-u, 4:2:0 planar // only in v3<br />
CS_I420 = 1<<4 | CS_YUV | CS_PLANAR, // y-u-v, 4:2:0 planar // only in v3<br />
CS_IYUV = 1<<4 | CS_YUV | CS_PLANAR, // same as above // only in v3<br />
<br />
// added in v5<br />
CS_RAW32 = 1<<5 | CS_INTERLEAVED,<br />
CS_YV24 = CS_PLANAR | CS_YUV | CS_Sample_Bits_8 | CS_VPlaneFirst | CS_Sub_Height_1 | CS_Sub_Width_1, // YUV 4:4:4 planar<br />
CS_YV16 = CS_PLANAR | CS_YUV | CS_Sample_Bits_8 | CS_VPlaneFirst | CS_Sub_Height_1 | CS_Sub_Width_2, // YUV 4:2:2 planar<br />
CS_YV12 = CS_PLANAR | CS_YUV | CS_Sample_Bits_8 | CS_VPlaneFirst | CS_Sub_Height_2 | CS_Sub_Width_2, // y-v-u, 4:2:0 planar<br />
CS_I420 = CS_PLANAR | CS_YUV | CS_Sample_Bits_8 | CS_UPlaneFirst | CS_Sub_Height_2 | CS_Sub_Width_2, // y-u-v, 4:2:0 planar<br />
CS_IYUV = CS_I420,<br />
CS_YUV9 = CS_PLANAR | CS_YUV | CS_Sample_Bits_8 | CS_VPlaneFirst | CS_Sub_Height_4 | CS_Sub_Width_4, // YUV 4:1:0 planar<br />
CS_YV411 = CS_PLANAR | CS_YUV | CS_Sample_Bits_8 | CS_VPlaneFirst | CS_Sub_Height_1 | CS_Sub_Width_4, // YUV 4:1:1 planar<br />
<br />
CS_Y8 = CS_PLANAR | CS_INTERLEAVED | CS_YUV | CS_Sample_Bits_8, // Y 4:0:0 planar<br />
};<br />
<br />
// Image_type properties and constants:<br />
int image_type;<br />
<br />
enum {<br />
IT_BFF = 1<<0,<br />
IT_TFF = 1<<1,<br />
IT_FIELDBASED = 1<<2<br />
};<br />
<br />
// Chroma placement constants (bits 20 -> 23):<br />
<br />
enum { // added in v5<br />
CS_UNKNOWN_CHROMA_PLACEMENT = 0 << 20,<br />
CS_MPEG1_CHROMA_PLACEMENT = 1 << 20,<br />
CS_MPEG2_CHROMA_PLACEMENT = 2 << 20,<br />
CS_YUY2_CHROMA_PLACEMENT = 3 << 20,<br />
CS_TOPLEFT_CHROMA_PLACEMENT = 4 << 20<br />
};<br />
<br />
== Functions [need to add examples] ==<br />
<br />
=== HasVideo ===<br />
<br />
bool HasVideo() const;<br />
<br />
This will return true if there is any video in the given clip.<br />
<br />
=== IsRGB / IsRGB24 / IsRGB32 ===<br />
<br />
bool IsRGB() const;<br />
bool IsRGB24() const;<br />
bool IsRGB32() const;<br />
<br />
All of them will return true if the colorspace is [[RGB]] (in any way). The last two return true if the clip has the specific RGB colorspace ([[RGB24]] and [[RGB32]]).<br />
<br />
=== IsYUV / IsYUY2 / IsYV24 / IsYV16 / IsYV12 / IsYV411 / IsY8 ===<br />
<br />
bool IsYUV() const;<br />
bool IsYUY2() const;<br />
bool IsYV24() const; // v5<br />
bool IsYV16() const; // v5<br />
bool IsYV12() const;<br />
bool IsYV411() const; // v5<br />
bool IsY8() const; // v5<br />
<br />
All of them will return true if the colorspace is [[YUV]] (in any way). The last six return true if the clip has the specific YUV colorspace ([[YUY2]], [[YV24]], [[YV16]], [[YV12]], [[YV411]] and [[Y8]]).<br />
<br />
=== IsColorSpace / IsSameColorspace / IsPlanar ===<br />
<br />
bool IsColorSpace(int c_space) const;<br />
<br />
This will return true if the colorspace (VideoInfo.pixel_type) is the same as the given c_space (or more general it checks for a [[Colorspace property]]).<br />
<br />
bool IsSameColorspace(const VideoInfo& vi) const;<br />
<br />
This function will compare two VideoInfos, and check if the colorspace (pixel_type) is the same. Note: It does not check imagesize or similar properties.<br />
<br />
bool IsPlanar() const;<br />
<br />
This will return true if the video is planar. See the [[Planar]] image format.<br />
<br />
=== Is / IsFieldBased / IsParityKnown / IsBFF / IsTFF ===<br />
<br />
bool Is(int property) const;<br />
<br />
From v6 this will return true if the image type (VideoInfo.image_type) is the same as the given property (being IT_BFF, IT_TFF or IT_FIELDBASED).<br />
<br />
bool IsFieldBased() const;<br />
<br />
This will return true if the video is field-based. Thus if has been through a [[SeparateFields]] or [[AssumeFieldBased]]. Otherwise it will return false.<br />
<br />
bool IsParityKnown() const;<br />
<br />
This will return true if the video parity is known (thus if it is TFF or BFF).<br />
<br />
bool IsBFF() const;<br />
bool IsTFF() const;<br />
<br />
This will return true if the video is bottom-field-first or top-field-first respectively.<br />
<br />
=== SetFieldBased / Set / Clear ===<br />
<br />
void SetFieldBased(bool isfieldbased);<br />
<br />
This will set the field-based property to true (respectively false) if isfieldbased=true (respectively false).<br />
<br />
void Set(int property);<br />
void Clear(int property);<br />
<br />
This sets respectively clears an image_type property like: IT_BFF, IT_TFF or IT_FIELDBASED. See field.h for examples.<br />
<br />
=== BitsPerPixel ===<br />
<br />
int BitsPerPixel() const;<br />
<br />
This will return the number of bits per pixel. This can be:<br />
<br />
{| border="1" cellpadding="4"<br />
!width=50%| pixel_type<br />
!width=50%| nr of bits<br />
|-<br />
| CS_BGR32<br />
| 32<br />
|-<br />
| CS_BGR24, CS_YV24<br />
| 24<br />
|-<br />
| CS_YUY2, CS_YV16<br />
| 16<br />
|-<br />
| CS_YV12, CS_I420<br />
| 12<br />
|-<br />
| CS_Y8<br />
| 8<br />
|-<br />
| CS_YV411<br />
| 6<br />
|}<br />
<br />
=== SetFPS / MulDivFPS ===<br />
<br />
void SetFPS(unsigned numerator, unsigned denominator);<br />
<br />
This will set the framerate.<br />
<br />
void MulDivFPS(unsigned multiplier, unsigned divisor);<br />
<br />
This will multiply the denominator by ''multiplier'' and scale the numerator and modified denominator.<br />
<br />
=== BytesFromPixels ===<br />
<br />
int BytesFromPixels(int pixels) const;<br />
<br />
For interleaved formats it will return the number of bytes from the specified number of pixels. For planar formats it will do the same except it operates on the first plane.<br />
<br />
=== RowSize / BMPSize ===<br />
<br />
int RowSize(int plane=0) const;<br />
<br />
For interleaved formats it will return the width of the frame in bytes. For planar formats it will return the width of the specified plane in bytes.<br />
<br />
examples:<br />
<br />
640x480 RGB24: RowSize() = 3*640 = 1920<br />
<br />
640x480 YV12: RowSize() = 640 <br><br />
640x480 YV12: RowSize(1) = 320<br />
<br />
int BMPSize() const;<br />
<br />
For interleaved formats it will return the size of the frame in bytes where the width is rounded up to a multiple of 4 bytes. For planar formats it will do the same but only for the first plane. So, it's the number of bytes of a frame as it was a [http://en.wikipedia.org/wiki/BMP_file_format BMP frame].<br />
<br />
examples:<br />
<br />
640x480 RGB24: BMPSize() = 480 * 3*640 = 921600 <br><br />
643x480 RGB24: BMPSize() = 480 * 3*644 = 927360<br />
<br />
640x480 YV24: BMPSize() = 480 * 640 = 307200 <br><br />
643x480 YV24: BMPSize() = 480 * 644 = 309120<br />
<br />
Since v5 the behavior for planar formats is the same as for interleaved formats.<br />
<br />
=== GetPlaneWidthSubsampling / GetPlaneHeightSubsampling ===<br />
<br />
int GetPlaneWidthSubsampling(int plane) const; // v5<br />
<br />
This will return the subsampling of the width in bitshifts.<br />
<br />
examples:<br />
<br />
YV24: GetPlaneWidthSubsampling(PLANAR_U) = 0 // since there is no horizontal subsampling on a chroma plane <br><br />
YV16: GetPlaneWidthSubsampling(PLANAR_U) = 0 // since there is no horizontal subsampling on a chroma plane<br />
<br />
int GetPlaneHeightSubsampling(int plane) const; // v5<br />
<br />
This will return the subsampling of the height in bitshifts.<br />
<br />
examples:<br />
<br />
YV24: GetPlaneHeightSubsampling(PLANAR_U) = 0 // since there is no vertical subsampling on a chroma plane <br><br />
YV16: GetPlaneHeightSubsampling(PLANAR_U) = 1 // since vertically there are two times less samples on a chroma plane compared to a plane which is not subsampled<br />
<br />
{| border="1"<br />
|- <br />
| color format<br />
| GetPlaneWidthSubsampling(PLANAR_U)<br />
| GetPlaneHeightSubsampling(PLANAR_U)<br />
|- <br />
| YV24<br />
| 0<br />
| 0<br />
|- <br />
| YV16<br />
| 1<br />
| 0<br />
|- <br />
| YV12<br />
| 1<br />
| 1<br />
|- <br />
| YV411<br />
| 2<br />
| 1<br />
|- <br />
| Y8<br />
| 0 ?<br />
| 0 ?<br />
|}<br />
<br />
=== HasAudio ===<br />
<br />
bool HasAudio() const;<br />
<br />
This will return true if there is any audio in the given clip.<br />
<br />
=== AudioChannels / SampleType ===<br />
<br />
int AudioChannels() const;<br />
<br />
This will return the number of audio channels.<br />
<br />
int SampleType() const;<br />
<br />
This will return the sample type. See [[Filter_SDK/Cplusplus_API#Constants|constants]] for the available sample types.<br />
<br />
=== IsSampleType ===<br />
<br />
bool IsSampleType(int testtype) const;<br />
<br />
This will return true if the sampletype (VideoInfo.sample_type) is the same as testtype.<br />
<br />
=== SamplesPerSecond / BytesPerAudioSample / BytesPerChannelSample ===<br />
<br />
int SamplesPerSecond() const;<br />
<br />
This will return the number of samples per second.<br />
<br />
int BytesPerAudioSample() const;<br />
<br />
This will return the number of bytes per sample.<br />
<br />
int BytesPerChannelSample() const;<br />
<br />
This will return the number of bytes per channel-sample. This can be:<br />
<br />
{| border="1" cellpadding="4"<br />
!width=50%| sample<br />
!width=50%| nr of bytes<br />
|-<br />
| SAMPLE_INT8<br />
| sizeof(signed char)<br />
|-<br />
| SAMPLE_INT16<br />
| sizeof(signed short)<br />
|-<br />
| SAMPLE_INT24<br />
| 3<br />
|-<br />
| SAMPLE_INT32<br />
| sizeof(signed int)<br />
|-<br />
| SAMPLE_FLOAT<br />
| sizeof(SFLOAT)<br />
|}<br />
<br />
=== AudioSamplesFromFrames / FramesFromAudioSamples / AudioSamplesFromBytes / BytesFromAudioSamples ===<br />
<br />
__int64 AudioSamplesFromFrames(int frames) const;<br />
<br />
This returns the number of audiosamples from the first ''frames'' frames.<br />
<br />
int FramesFromAudioSamples(__int64 samples) const;<br />
<br />
This returns the number of frames from the first ''samples'' audiosamples.<br />
<br />
__int64 AudioSamplesFromBytes(__int64 bytes) const;<br />
<br />
This returns the number of audiosamples from the specified number of bytes.<br />
<br />
__int64 BytesFromAudioSamples(__int64 samples) const;<br />
<br />
This returns the number of bytes from the first ''samples'' audiosamples.<br />
<br />
[[Category:AviSynth_Development]]</div>Adminhttp://avisynth.nl/index.php/Filter_SDK/Cplusplus_API/VideoInfoFilter SDK/Cplusplus API/VideoInfo2017-01-07T15:08:13Z<p>Admin: /* IsColorSpace / IsSameColorspace / IsPlanar */</p>
<hr />
<div>The VideoInfo structure holds global information about a clip (i.e. information that does not depend on the frame number). The GetVideoInfo method in IClip returns this structure. Below is a description of it (for AVISYNTH_INTERFACE_VERSION=6).<br />
<br />
== Properties and constants ==<br />
<br />
// General properties:<br />
int width, height; // width=0 means no video<br />
unsigned fps_numerator, fps_denominator;<br />
int num_frames; // max. num_frames = 2,147,483,647 (signed int32)<br />
int audio_samples_per_second; // audio_samples_per_second=0 means no audio<br />
int sample_type; // samples types are defined in avisynth.h<br />
__int64 num_audio_samples;<br />
int nchannels;<br />
<br />
// Colorspace properties and constants:<br />
int pixel_type; <br />
<br />
enum {<br />
CS_BGR = 1<<28,<br />
CS_YUV = 1<<29,<br />
CS_INTERLEAVED = 1<<30,<br />
CS_PLANAR = 1<<31,<br />
<br />
// added in v5<br />
CS_Shift_Sub_Width = 0,<br />
CS_Shift_Sub_Height = 8,<br />
CS_Shift_Sample_Bits = 16,<br />
<br />
CS_Sub_Width_Mask = 7 << CS_Shift_Sub_Width,<br />
CS_Sub_Width_1 = 3 << CS_Shift_Sub_Width, // YV24<br />
CS_Sub_Width_2 = 0 << CS_Shift_Sub_Width, // YV12, I420, YV16<br />
CS_Sub_Width_4 = 1 << CS_Shift_Sub_Width, // YUV9, YV411<br />
<br />
CS_VPlaneFirst = 1 << 3, // YV12, YV16, YV24, YV411, YUV9<br />
CS_UPlaneFirst = 1 << 4, // I420<br />
<br />
CS_Sub_Height_Mask = 7 << CS_Shift_Sub_Height,<br />
CS_Sub_Height_1 = 3 << CS_Shift_Sub_Height, // YV16, YV24, YV411<br />
CS_Sub_Height_2 = 0 << CS_Shift_Sub_Height, // YV12, I420<br />
CS_Sub_Height_4 = 1 << CS_Shift_Sub_Height, // YUV9<br />
<br />
CS_Sample_Bits_Mask = 7 << CS_Shift_Sample_Bits,<br />
CS_Sample_Bits_8 = 0 << CS_Shift_Sample_Bits,<br />
CS_Sample_Bits_16 = 1 << CS_Shift_Sample_Bits,<br />
CS_Sample_Bits_32 = 2 << CS_Shift_Sample_Bits,<br />
<br />
CS_PLANAR_MASK = CS_PLANAR | CS_INTERLEAVED | CS_YUV | CS_BGR | CS_Sample_Bits_Mask | CS_Sub_Height_Mask | CS_Sub_Width_Mask,<br />
CS_PLANAR_FILTER = ~( CS_VPlaneFirst | CS_UPlaneFirst ),<br />
};<br />
<br />
// Colorformat constants:<br />
<br />
enum {<br />
CS_UNKNOWN = 0,<br />
CS_BGR24 = 1<<0 | CS_BGR | CS_INTERLEAVED,<br />
CS_BGR32 = 1<<1 | CS_BGR | CS_INTERLEAVED,<br />
CS_YUY2 = 1<<2 | CS_YUV | CS_INTERLEAVED,<br />
CS_YV12 = 1<<3 | CS_YUV | CS_PLANAR, // y-v-u, 4:2:0 planar // only in v3<br />
CS_I420 = 1<<4 | CS_YUV | CS_PLANAR, // y-u-v, 4:2:0 planar // only in v3<br />
CS_IYUV = 1<<4 | CS_YUV | CS_PLANAR, // same as above // only in v3<br />
<br />
// added in v5<br />
CS_RAW32 = 1<<5 | CS_INTERLEAVED,<br />
CS_YV24 = CS_PLANAR | CS_YUV | CS_Sample_Bits_8 | CS_VPlaneFirst | CS_Sub_Height_1 | CS_Sub_Width_1, // YUV 4:4:4 planar<br />
CS_YV16 = CS_PLANAR | CS_YUV | CS_Sample_Bits_8 | CS_VPlaneFirst | CS_Sub_Height_1 | CS_Sub_Width_2, // YUV 4:2:2 planar<br />
CS_YV12 = CS_PLANAR | CS_YUV | CS_Sample_Bits_8 | CS_VPlaneFirst | CS_Sub_Height_2 | CS_Sub_Width_2, // y-v-u, 4:2:0 planar<br />
CS_I420 = CS_PLANAR | CS_YUV | CS_Sample_Bits_8 | CS_UPlaneFirst | CS_Sub_Height_2 | CS_Sub_Width_2, // y-u-v, 4:2:0 planar<br />
CS_IYUV = CS_I420,<br />
CS_YUV9 = CS_PLANAR | CS_YUV | CS_Sample_Bits_8 | CS_VPlaneFirst | CS_Sub_Height_4 | CS_Sub_Width_4, // YUV 4:1:0 planar<br />
CS_YV411 = CS_PLANAR | CS_YUV | CS_Sample_Bits_8 | CS_VPlaneFirst | CS_Sub_Height_1 | CS_Sub_Width_4, // YUV 4:1:1 planar<br />
<br />
CS_Y8 = CS_PLANAR | CS_INTERLEAVED | CS_YUV | CS_Sample_Bits_8, // Y 4:0:0 planar<br />
};<br />
<br />
// Image_type properties and constants:<br />
int image_type;<br />
<br />
enum {<br />
IT_BFF = 1<<0,<br />
IT_TFF = 1<<1,<br />
IT_FIELDBASED = 1<<2<br />
};<br />
<br />
// Chroma placement constants (bits 20 -> 23):<br />
<br />
enum { // added in v5<br />
CS_UNKNOWN_CHROMA_PLACEMENT = 0 << 20,<br />
CS_MPEG1_CHROMA_PLACEMENT = 1 << 20,<br />
CS_MPEG2_CHROMA_PLACEMENT = 2 << 20,<br />
CS_YUY2_CHROMA_PLACEMENT = 3 << 20,<br />
CS_TOPLEFT_CHROMA_PLACEMENT = 4 << 20<br />
};<br />
<br />
== Functions [need to add examples] ==<br />
<br />
=== HasVideo ===<br />
<br />
bool HasVideo() const;<br />
<br />
This will return true if there is any video in the given clip.<br />
<br />
=== IsRGB / IsRGB24 / IsRGB32 ===<br />
<br />
bool IsRGB() const;<br />
bool IsRGB24() const;<br />
bool IsRGB32() const;<br />
<br />
All of them will return true if the colorspace is [[RGB]] (in any way). The last two return true if the clip has the specific RGB colorspace ([[RGB24]] and [[RGB32]]).<br />
<br />
=== IsYUV / IsYUY2 / IsYV24 / IsYV16 / IsYV12 / IsYV411 / IsY8 ===<br />
<br />
bool IsYUV() const;<br />
bool IsYUY2() const;<br />
bool IsYV24() const; // v5<br />
bool IsYV16() const; // v5<br />
bool IsYV12() const;<br />
bool IsYV411() const; // v5<br />
bool IsY8() const; // v5<br />
<br />
All of them will return true if the colorspace is [[YUV]] (in any way). The last six return true if the clip has the specific YUV colorspace ([[YUY2]], [[YV24]], [[YV16]], [[YV12]], [[YV411]] and [[Y8]]).<br />
<br />
=== IsColorSpace / IsSameColorspace / IsPlanar ===<br />
<br />
bool IsColorSpace(int c_space) const;<br />
<br />
This will return true if the colorspace (VideoInfo.pixel_type) is the same as the given c_space (or more general it checks for a [[Colorspace property]]).<br />
<br />
bool IsSameColorspace(const VideoInfo& vi) const;<br />
<br />
This function will compare two VideoInfos (pixel_types), and check if the colorspace is the same. Note: It does not check imagesize or similar properties.<br />
<br />
bool IsPlanar() const;<br />
<br />
This will return true if the video is planar. See the [[Planar]] image format.<br />
<br />
=== Is / IsFieldBased / IsParityKnown / IsBFF / IsTFF ===<br />
<br />
bool Is(int property) const;<br />
<br />
From v6 this will return true if the image type (VideoInfo.image_type) is the same as the given property (being IT_BFF, IT_TFF or IT_FIELDBASED).<br />
<br />
bool IsFieldBased() const;<br />
<br />
This will return true if the video is field-based. Thus if has been through a [[SeparateFields]] or [[AssumeFieldBased]]. Otherwise it will return false.<br />
<br />
bool IsParityKnown() const;<br />
<br />
This will return true if the video parity is known (thus if it is TFF or BFF).<br />
<br />
bool IsBFF() const;<br />
bool IsTFF() const;<br />
<br />
This will return true if the video is bottom-field-first or top-field-first respectively.<br />
<br />
=== SetFieldBased / Set / Clear ===<br />
<br />
void SetFieldBased(bool isfieldbased);<br />
<br />
This will set the field-based property to true (respectively false) if isfieldbased=true (respectively false).<br />
<br />
void Set(int property);<br />
void Clear(int property);<br />
<br />
This sets respectively clears an image_type property like: IT_BFF, IT_TFF or IT_FIELDBASED. See field.h for examples.<br />
<br />
=== BitsPerPixel ===<br />
<br />
int BitsPerPixel() const;<br />
<br />
This will return the number of bits per pixel. This can be:<br />
<br />
{| border="1" cellpadding="4"<br />
!width=50%| pixel_type<br />
!width=50%| nr of bits<br />
|-<br />
| CS_BGR32<br />
| 32<br />
|-<br />
| CS_BGR24, CS_YV24<br />
| 24<br />
|-<br />
| CS_YUY2, CS_YV16<br />
| 16<br />
|-<br />
| CS_YV12, CS_I420<br />
| 12<br />
|-<br />
| CS_Y8<br />
| 8<br />
|-<br />
| CS_YV411<br />
| 6<br />
|}<br />
<br />
=== SetFPS / MulDivFPS ===<br />
<br />
void SetFPS(unsigned numerator, unsigned denominator);<br />
<br />
This will set the framerate.<br />
<br />
void MulDivFPS(unsigned multiplier, unsigned divisor);<br />
<br />
This will multiply the denominator by ''multiplier'' and scale the numerator and modified denominator.<br />
<br />
=== BytesFromPixels ===<br />
<br />
int BytesFromPixels(int pixels) const;<br />
<br />
For interleaved formats it will return the number of bytes from the specified number of pixels. For planar formats it will do the same except it operates on the first plane.<br />
<br />
=== RowSize / BMPSize ===<br />
<br />
int RowSize(int plane=0) const;<br />
<br />
For interleaved formats it will return the width of the frame in bytes. For planar formats it will return the width of the specified plane in bytes.<br />
<br />
examples:<br />
<br />
640x480 RGB24: RowSize() = 3*640 = 1920<br />
<br />
640x480 YV12: RowSize() = 640 <br><br />
640x480 YV12: RowSize(1) = 320<br />
<br />
int BMPSize() const;<br />
<br />
For interleaved formats it will return the size of the frame in bytes where the width is rounded up to a multiple of 4 bytes. For planar formats it will do the same but only for the first plane. So, it's the number of bytes of a frame as it was a [http://en.wikipedia.org/wiki/BMP_file_format BMP frame].<br />
<br />
examples:<br />
<br />
640x480 RGB24: BMPSize() = 480 * 3*640 = 921600 <br><br />
643x480 RGB24: BMPSize() = 480 * 3*644 = 927360<br />
<br />
640x480 YV24: BMPSize() = 480 * 640 = 307200 <br><br />
643x480 YV24: BMPSize() = 480 * 644 = 309120<br />
<br />
Since v5 the behavior for planar formats is the same as for interleaved formats.<br />
<br />
=== GetPlaneWidthSubsampling / GetPlaneHeightSubsampling ===<br />
<br />
int GetPlaneWidthSubsampling(int plane) const; // v5<br />
<br />
This will return the subsampling of the width in bitshifts.<br />
<br />
examples:<br />
<br />
YV24: GetPlaneWidthSubsampling(PLANAR_U) = 0 // since there is no horizontal subsampling on a chroma plane <br><br />
YV16: GetPlaneWidthSubsampling(PLANAR_U) = 0 // since there is no horizontal subsampling on a chroma plane<br />
<br />
int GetPlaneHeightSubsampling(int plane) const; // v5<br />
<br />
This will return the subsampling of the height in bitshifts.<br />
<br />
examples:<br />
<br />
YV24: GetPlaneHeightSubsampling(PLANAR_U) = 0 // since there is no vertical subsampling on a chroma plane <br><br />
YV16: GetPlaneHeightSubsampling(PLANAR_U) = 1 // since vertically there are two times less samples on a chroma plane compared to a plane which is not subsampled<br />
<br />
{| border="1"<br />
|- <br />
| color format<br />
| GetPlaneWidthSubsampling(PLANAR_U)<br />
| GetPlaneHeightSubsampling(PLANAR_U)<br />
|- <br />
| YV24<br />
| 0<br />
| 0<br />
|- <br />
| YV16<br />
| 1<br />
| 0<br />
|- <br />
| YV12<br />
| 1<br />
| 1<br />
|- <br />
| YV411<br />
| 2<br />
| 1<br />
|- <br />
| Y8<br />
| 0 ?<br />
| 0 ?<br />
|}<br />
<br />
=== HasAudio ===<br />
<br />
bool HasAudio() const;<br />
<br />
This will return true if there is any audio in the given clip.<br />
<br />
=== AudioChannels / SampleType ===<br />
<br />
int AudioChannels() const;<br />
<br />
This will return the number of audio channels.<br />
<br />
int SampleType() const;<br />
<br />
This will return the sample type. See [[Filter_SDK/Cplusplus_API#Constants|constants]] for the available sample types.<br />
<br />
=== IsSampleType ===<br />
<br />
bool IsSampleType(int testtype) const;<br />
<br />
This will return true if the sampletype (VideoInfo.sample_type) is the same as testtype.<br />
<br />
=== SamplesPerSecond / BytesPerAudioSample / BytesPerChannelSample ===<br />
<br />
int SamplesPerSecond() const;<br />
<br />
This will return the number of samples per second.<br />
<br />
int BytesPerAudioSample() const;<br />
<br />
This will return the number of bytes per sample.<br />
<br />
int BytesPerChannelSample() const;<br />
<br />
This will return the number of bytes per channel-sample. This can be:<br />
<br />
{| border="1" cellpadding="4"<br />
!width=50%| sample<br />
!width=50%| nr of bytes<br />
|-<br />
| SAMPLE_INT8<br />
| sizeof(signed char)<br />
|-<br />
| SAMPLE_INT16<br />
| sizeof(signed short)<br />
|-<br />
| SAMPLE_INT24<br />
| 3<br />
|-<br />
| SAMPLE_INT32<br />
| sizeof(signed int)<br />
|-<br />
| SAMPLE_FLOAT<br />
| sizeof(SFLOAT)<br />
|}<br />
<br />
=== AudioSamplesFromFrames / FramesFromAudioSamples / AudioSamplesFromBytes / BytesFromAudioSamples ===<br />
<br />
__int64 AudioSamplesFromFrames(int frames) const;<br />
<br />
This returns the number of audiosamples from the first ''frames'' frames.<br />
<br />
int FramesFromAudioSamples(__int64 samples) const;<br />
<br />
This returns the number of frames from the first ''samples'' audiosamples.<br />
<br />
__int64 AudioSamplesFromBytes(__int64 bytes) const;<br />
<br />
This returns the number of audiosamples from the specified number of bytes.<br />
<br />
__int64 BytesFromAudioSamples(__int64 samples) const;<br />
<br />
This returns the number of bytes from the first ''samples'' audiosamples.<br />
<br />
[[Category:AviSynth_Development]]</div>Adminhttp://avisynth.nl/index.php/Filter_SDK/Cplusplus_API/VideoInfoFilter SDK/Cplusplus API/VideoInfo2017-01-07T14:50:42Z<p>Admin: /* SetFieldBased / Set / Clear */</p>
<hr />
<div>The VideoInfo structure holds global information about a clip (i.e. information that does not depend on the frame number). The GetVideoInfo method in IClip returns this structure. Below is a description of it (for AVISYNTH_INTERFACE_VERSION=6).<br />
<br />
== Properties and constants ==<br />
<br />
// General properties:<br />
int width, height; // width=0 means no video<br />
unsigned fps_numerator, fps_denominator;<br />
int num_frames; // max. num_frames = 2,147,483,647 (signed int32)<br />
int audio_samples_per_second; // audio_samples_per_second=0 means no audio<br />
int sample_type; // samples types are defined in avisynth.h<br />
__int64 num_audio_samples;<br />
int nchannels;<br />
<br />
// Colorspace properties and constants:<br />
int pixel_type; <br />
<br />
enum {<br />
CS_BGR = 1<<28,<br />
CS_YUV = 1<<29,<br />
CS_INTERLEAVED = 1<<30,<br />
CS_PLANAR = 1<<31,<br />
<br />
// added in v5<br />
CS_Shift_Sub_Width = 0,<br />
CS_Shift_Sub_Height = 8,<br />
CS_Shift_Sample_Bits = 16,<br />
<br />
CS_Sub_Width_Mask = 7 << CS_Shift_Sub_Width,<br />
CS_Sub_Width_1 = 3 << CS_Shift_Sub_Width, // YV24<br />
CS_Sub_Width_2 = 0 << CS_Shift_Sub_Width, // YV12, I420, YV16<br />
CS_Sub_Width_4 = 1 << CS_Shift_Sub_Width, // YUV9, YV411<br />
<br />
CS_VPlaneFirst = 1 << 3, // YV12, YV16, YV24, YV411, YUV9<br />
CS_UPlaneFirst = 1 << 4, // I420<br />
<br />
CS_Sub_Height_Mask = 7 << CS_Shift_Sub_Height,<br />
CS_Sub_Height_1 = 3 << CS_Shift_Sub_Height, // YV16, YV24, YV411<br />
CS_Sub_Height_2 = 0 << CS_Shift_Sub_Height, // YV12, I420<br />
CS_Sub_Height_4 = 1 << CS_Shift_Sub_Height, // YUV9<br />
<br />
CS_Sample_Bits_Mask = 7 << CS_Shift_Sample_Bits,<br />
CS_Sample_Bits_8 = 0 << CS_Shift_Sample_Bits,<br />
CS_Sample_Bits_16 = 1 << CS_Shift_Sample_Bits,<br />
CS_Sample_Bits_32 = 2 << CS_Shift_Sample_Bits,<br />
<br />
CS_PLANAR_MASK = CS_PLANAR | CS_INTERLEAVED | CS_YUV | CS_BGR | CS_Sample_Bits_Mask | CS_Sub_Height_Mask | CS_Sub_Width_Mask,<br />
CS_PLANAR_FILTER = ~( CS_VPlaneFirst | CS_UPlaneFirst ),<br />
};<br />
<br />
// Colorformat constants:<br />
<br />
enum {<br />
CS_UNKNOWN = 0,<br />
CS_BGR24 = 1<<0 | CS_BGR | CS_INTERLEAVED,<br />
CS_BGR32 = 1<<1 | CS_BGR | CS_INTERLEAVED,<br />
CS_YUY2 = 1<<2 | CS_YUV | CS_INTERLEAVED,<br />
CS_YV12 = 1<<3 | CS_YUV | CS_PLANAR, // y-v-u, 4:2:0 planar // only in v3<br />
CS_I420 = 1<<4 | CS_YUV | CS_PLANAR, // y-u-v, 4:2:0 planar // only in v3<br />
CS_IYUV = 1<<4 | CS_YUV | CS_PLANAR, // same as above // only in v3<br />
<br />
// added in v5<br />
CS_RAW32 = 1<<5 | CS_INTERLEAVED,<br />
CS_YV24 = CS_PLANAR | CS_YUV | CS_Sample_Bits_8 | CS_VPlaneFirst | CS_Sub_Height_1 | CS_Sub_Width_1, // YUV 4:4:4 planar<br />
CS_YV16 = CS_PLANAR | CS_YUV | CS_Sample_Bits_8 | CS_VPlaneFirst | CS_Sub_Height_1 | CS_Sub_Width_2, // YUV 4:2:2 planar<br />
CS_YV12 = CS_PLANAR | CS_YUV | CS_Sample_Bits_8 | CS_VPlaneFirst | CS_Sub_Height_2 | CS_Sub_Width_2, // y-v-u, 4:2:0 planar<br />
CS_I420 = CS_PLANAR | CS_YUV | CS_Sample_Bits_8 | CS_UPlaneFirst | CS_Sub_Height_2 | CS_Sub_Width_2, // y-u-v, 4:2:0 planar<br />
CS_IYUV = CS_I420,<br />
CS_YUV9 = CS_PLANAR | CS_YUV | CS_Sample_Bits_8 | CS_VPlaneFirst | CS_Sub_Height_4 | CS_Sub_Width_4, // YUV 4:1:0 planar<br />
CS_YV411 = CS_PLANAR | CS_YUV | CS_Sample_Bits_8 | CS_VPlaneFirst | CS_Sub_Height_1 | CS_Sub_Width_4, // YUV 4:1:1 planar<br />
<br />
CS_Y8 = CS_PLANAR | CS_INTERLEAVED | CS_YUV | CS_Sample_Bits_8, // Y 4:0:0 planar<br />
};<br />
<br />
// Image_type properties and constants:<br />
int image_type;<br />
<br />
enum {<br />
IT_BFF = 1<<0,<br />
IT_TFF = 1<<1,<br />
IT_FIELDBASED = 1<<2<br />
};<br />
<br />
// Chroma placement constants (bits 20 -> 23):<br />
<br />
enum { // added in v5<br />
CS_UNKNOWN_CHROMA_PLACEMENT = 0 << 20,<br />
CS_MPEG1_CHROMA_PLACEMENT = 1 << 20,<br />
CS_MPEG2_CHROMA_PLACEMENT = 2 << 20,<br />
CS_YUY2_CHROMA_PLACEMENT = 3 << 20,<br />
CS_TOPLEFT_CHROMA_PLACEMENT = 4 << 20<br />
};<br />
<br />
== Functions [need to add examples] ==<br />
<br />
=== HasVideo ===<br />
<br />
bool HasVideo() const;<br />
<br />
This will return true if there is any video in the given clip.<br />
<br />
=== IsRGB / IsRGB24 / IsRGB32 ===<br />
<br />
bool IsRGB() const;<br />
bool IsRGB24() const;<br />
bool IsRGB32() const;<br />
<br />
All of them will return true if the colorspace is [[RGB]] (in any way). The last two return true if the clip has the specific RGB colorspace ([[RGB24]] and [[RGB32]]).<br />
<br />
=== IsYUV / IsYUY2 / IsYV24 / IsYV16 / IsYV12 / IsYV411 / IsY8 ===<br />
<br />
bool IsYUV() const;<br />
bool IsYUY2() const;<br />
bool IsYV24() const; // v5<br />
bool IsYV16() const; // v5<br />
bool IsYV12() const;<br />
bool IsYV411() const; // v5<br />
bool IsY8() const; // v5<br />
<br />
All of them will return true if the colorspace is [[YUV]] (in any way). The last six return true if the clip has the specific YUV colorspace ([[YUY2]], [[YV24]], [[YV16]], [[YV12]], [[YV411]] and [[Y8]]).<br />
<br />
=== IsColorSpace / IsSameColorspace / IsPlanar ===<br />
<br />
bool IsColorSpace(int c_space) const;<br />
<br />
This will return true if the colorspace (VideoInfo.pixel_type) is the same as the given c_space (or more general it checks for a [[Colorspace property]]).<br />
<br />
bool IsSameColorspace(const VideoInfo& vi) const;<br />
<br />
This function will compare two VideoInfos, and check if the colorspace is the same. Note: It does not check imagesize or similar properties.<br />
<br />
bool IsPlanar() const;<br />
<br />
This will return true if the video is planar. See the [[Planar]] image format.<br />
<br />
=== Is / IsFieldBased / IsParityKnown / IsBFF / IsTFF ===<br />
<br />
bool Is(int property) const;<br />
<br />
From v6 this will return true if the image type (VideoInfo.image_type) is the same as the given property (being IT_BFF, IT_TFF or IT_FIELDBASED).<br />
<br />
bool IsFieldBased() const;<br />
<br />
This will return true if the video is field-based. Thus if has been through a [[SeparateFields]] or [[AssumeFieldBased]]. Otherwise it will return false.<br />
<br />
bool IsParityKnown() const;<br />
<br />
This will return true if the video parity is known (thus if it is TFF or BFF).<br />
<br />
bool IsBFF() const;<br />
bool IsTFF() const;<br />
<br />
This will return true if the video is bottom-field-first or top-field-first respectively.<br />
<br />
=== SetFieldBased / Set / Clear ===<br />
<br />
void SetFieldBased(bool isfieldbased);<br />
<br />
This will set the field-based property to true (respectively false) if isfieldbased=true (respectively false).<br />
<br />
void Set(int property);<br />
void Clear(int property);<br />
<br />
This sets respectively clears an image_type property like: IT_BFF, IT_TFF or IT_FIELDBASED. See field.h for examples.<br />
<br />
=== BitsPerPixel ===<br />
<br />
int BitsPerPixel() const;<br />
<br />
This will return the number of bits per pixel. This can be:<br />
<br />
{| border="1" cellpadding="4"<br />
!width=50%| pixel_type<br />
!width=50%| nr of bits<br />
|-<br />
| CS_BGR32<br />
| 32<br />
|-<br />
| CS_BGR24, CS_YV24<br />
| 24<br />
|-<br />
| CS_YUY2, CS_YV16<br />
| 16<br />
|-<br />
| CS_YV12, CS_I420<br />
| 12<br />
|-<br />
| CS_Y8<br />
| 8<br />
|-<br />
| CS_YV411<br />
| 6<br />
|}<br />
<br />
=== SetFPS / MulDivFPS ===<br />
<br />
void SetFPS(unsigned numerator, unsigned denominator);<br />
<br />
This will set the framerate.<br />
<br />
void MulDivFPS(unsigned multiplier, unsigned divisor);<br />
<br />
This will multiply the denominator by ''multiplier'' and scale the numerator and modified denominator.<br />
<br />
=== BytesFromPixels ===<br />
<br />
int BytesFromPixels(int pixels) const;<br />
<br />
For interleaved formats it will return the number of bytes from the specified number of pixels. For planar formats it will do the same except it operates on the first plane.<br />
<br />
=== RowSize / BMPSize ===<br />
<br />
int RowSize(int plane=0) const;<br />
<br />
For interleaved formats it will return the width of the frame in bytes. For planar formats it will return the width of the specified plane in bytes.<br />
<br />
examples:<br />
<br />
640x480 RGB24: RowSize() = 3*640 = 1920<br />
<br />
640x480 YV12: RowSize() = 640 <br><br />
640x480 YV12: RowSize(1) = 320<br />
<br />
int BMPSize() const;<br />
<br />
For interleaved formats it will return the size of the frame in bytes where the width is rounded up to a multiple of 4 bytes. For planar formats it will do the same but only for the first plane. So, it's the number of bytes of a frame as it was a [http://en.wikipedia.org/wiki/BMP_file_format BMP frame].<br />
<br />
examples:<br />
<br />
640x480 RGB24: BMPSize() = 480 * 3*640 = 921600 <br><br />
643x480 RGB24: BMPSize() = 480 * 3*644 = 927360<br />
<br />
640x480 YV24: BMPSize() = 480 * 640 = 307200 <br><br />
643x480 YV24: BMPSize() = 480 * 644 = 309120<br />
<br />
Since v5 the behavior for planar formats is the same as for interleaved formats.<br />
<br />
=== GetPlaneWidthSubsampling / GetPlaneHeightSubsampling ===<br />
<br />
int GetPlaneWidthSubsampling(int plane) const; // v5<br />
<br />
This will return the subsampling of the width in bitshifts.<br />
<br />
examples:<br />
<br />
YV24: GetPlaneWidthSubsampling(PLANAR_U) = 0 // since there is no horizontal subsampling on a chroma plane <br><br />
YV16: GetPlaneWidthSubsampling(PLANAR_U) = 0 // since there is no horizontal subsampling on a chroma plane<br />
<br />
int GetPlaneHeightSubsampling(int plane) const; // v5<br />
<br />
This will return the subsampling of the height in bitshifts.<br />
<br />
examples:<br />
<br />
YV24: GetPlaneHeightSubsampling(PLANAR_U) = 0 // since there is no vertical subsampling on a chroma plane <br><br />
YV16: GetPlaneHeightSubsampling(PLANAR_U) = 1 // since vertically there are two times less samples on a chroma plane compared to a plane which is not subsampled<br />
<br />
{| border="1"<br />
|- <br />
| color format<br />
| GetPlaneWidthSubsampling(PLANAR_U)<br />
| GetPlaneHeightSubsampling(PLANAR_U)<br />
|- <br />
| YV24<br />
| 0<br />
| 0<br />
|- <br />
| YV16<br />
| 1<br />
| 0<br />
|- <br />
| YV12<br />
| 1<br />
| 1<br />
|- <br />
| YV411<br />
| 2<br />
| 1<br />
|- <br />
| Y8<br />
| 0 ?<br />
| 0 ?<br />
|}<br />
<br />
=== HasAudio ===<br />
<br />
bool HasAudio() const;<br />
<br />
This will return true if there is any audio in the given clip.<br />
<br />
=== AudioChannels / SampleType ===<br />
<br />
int AudioChannels() const;<br />
<br />
This will return the number of audio channels.<br />
<br />
int SampleType() const;<br />
<br />
This will return the sample type. See [[Filter_SDK/Cplusplus_API#Constants|constants]] for the available sample types.<br />
<br />
=== IsSampleType ===<br />
<br />
bool IsSampleType(int testtype) const;<br />
<br />
This will return true if the sampletype (VideoInfo.sample_type) is the same as testtype.<br />
<br />
=== SamplesPerSecond / BytesPerAudioSample / BytesPerChannelSample ===<br />
<br />
int SamplesPerSecond() const;<br />
<br />
This will return the number of samples per second.<br />
<br />
int BytesPerAudioSample() const;<br />
<br />
This will return the number of bytes per sample.<br />
<br />
int BytesPerChannelSample() const;<br />
<br />
This will return the number of bytes per channel-sample. This can be:<br />
<br />
{| border="1" cellpadding="4"<br />
!width=50%| sample<br />
!width=50%| nr of bytes<br />
|-<br />
| SAMPLE_INT8<br />
| sizeof(signed char)<br />
|-<br />
| SAMPLE_INT16<br />
| sizeof(signed short)<br />
|-<br />
| SAMPLE_INT24<br />
| 3<br />
|-<br />
| SAMPLE_INT32<br />
| sizeof(signed int)<br />
|-<br />
| SAMPLE_FLOAT<br />
| sizeof(SFLOAT)<br />
|}<br />
<br />
=== AudioSamplesFromFrames / FramesFromAudioSamples / AudioSamplesFromBytes / BytesFromAudioSamples ===<br />
<br />
__int64 AudioSamplesFromFrames(int frames) const;<br />
<br />
This returns the number of audiosamples from the first ''frames'' frames.<br />
<br />
int FramesFromAudioSamples(__int64 samples) const;<br />
<br />
This returns the number of frames from the first ''samples'' audiosamples.<br />
<br />
__int64 AudioSamplesFromBytes(__int64 bytes) const;<br />
<br />
This returns the number of audiosamples from the specified number of bytes.<br />
<br />
__int64 BytesFromAudioSamples(__int64 samples) const;<br />
<br />
This returns the number of bytes from the first ''samples'' audiosamples.<br />
<br />
[[Category:AviSynth_Development]]</div>Adminhttp://avisynth.nl/index.php/Filter_SDK/C_API/AVS_VideoInfoFilter SDK/C API/AVS VideoInfo2017-01-05T22:05:13Z<p>Admin: /* Properties and constants */</p>
<hr />
<div>The AVS_VideoInfo structure holds global information about a clip (i.e. information that does not depend on the frame number). It's a member of the AVS_FilterInfo structure. Below is a description of it (for AVISYNTH_INTERFACE_VERSION=6).<br />
<br />
== Properties and constants ==<br />
* Colorspace constants, Colorformat constants and Image_type constants:<br />
<br />
:These constants are the same as the ones in the C++ API with a AVS_ prefix. For example, the C++ API constant CS_BGR becomes AVS_CS_BGR.<br />
<br />
:For some reason these constants are not part of the AVS_VideoInfo structure. Why not???<br />
<br />
* Colorspace properties, Image_type properties and General properties:<br />
<br />
:These are the same as in the C++ API.<br />
<br />
* Chroma placement constants (bits 20 -> 23):<br />
<br />
:They are missing in the C API. Todo: add them in the API.<br />
<br />
* Remaining constants (they are not present in the C++ API):<br />
<br />
enum {<br />
AVS_FILTER_TYPE=1,<br />
AVS_FILTER_INPUT_COLORSPACE=2,<br />
AVS_FILTER_OUTPUT_TYPE=9,<br />
AVS_FILTER_NAME=4,<br />
AVS_FILTER_AUTHOR=5,<br />
AVS_FILTER_VERSION=6,<br />
AVS_FILTER_ARGS=7,<br />
AVS_FILTER_ARGS_INFO=8,<br />
AVS_FILTER_ARGS_DESCRIPTION=10,<br />
AVS_FILTER_DESCRIPTION=11<br />
};<br />
<br />
enum { //SUBTYPES<br />
AVS_FILTER_TYPE_AUDIO=1,<br />
AVS_FILTER_TYPE_VIDEO=2,<br />
AVS_FILTER_OUTPUT_TYPE_SAME=3,<br />
AVS_FILTER_OUTPUT_TYPE_DIFFERENT=4<br />
};<br />
<br />
Todo: add description.</div>Admin