Internal functions/Runtime functions

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
m (1 revision)
(make redirect)
 
Line 1: Line 1:
== Runtime functions ==
+
#REDIRECT [[Internal_functions#Runtime_functions]]
  
These are the 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 (usually the current one). When using these functions there is an implicit '''<tt>last</tt>''' clip (the one that is passed to the runtime filter). Thus, first parameter doesn't have to be specified; it is replaced by the <tt>last</tt> clip.
 
 
 
* {{ScriptFunction|AverageLuma|v2.x|AverageLuma(clip)}}
 
* {{ScriptFunction|AverageChromaU|v2.x|AverageChromaU(clip)}}
 
* {{ScriptFunction|AverageChromaV|v2.x|AverageChromaV(clip)}}
 
: 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 that <tt>clip</tt> is in [[YV12]] [[Color_spaces|colorspace]] and [[ISSE]].
 
: ''Examples:''
 
threshold = 55
 
luma = AverageLuma()
 
luma < threshold ? [[Levels]](0, 1.0 + 0.5*(threshold - luma)/threshold, 255, 10, 255) : last
 
 
* {{ScriptFunction|RGBDifference|v2.x|RGBDifference(clip1, clip2)}}
 
* {{ScriptFunction|LumaDifference|v2.x|LumaDifference(clip1, clip2)}}
 
* {{ScriptFunction|ChromaUDifference|v2.x|ChromaUDifference(clip1, clip2)}}
 
* {{ScriptFunction|ChromaVDifference|v2.x|ChromaVDifference(clip1, clip2)}}
 
: This group of functions return a float value between 0 and 255 of the absolute difference between two planes (that is two frames from two different clips). Either the combined RGB difference or the Luma, U-chroma or V-chroma differences, respectively. They require that <tt>clip</tt> is in [[YV12]] [[Color_spaces|colorspace]] and [[ISSE]].
 
: ''Examples:''
 
ovl = [[Overlay]](last, mov_star, x=some_xvalue, y=some_yvalue, mask=mov_mask)
 
ldif = LumaDifference(ovl) # implicit last for clip1
 
udif = ChromaUDifference([[Tweak]](hue=24), ovl)
 
...
 
 
 
The next two groups of functions should be quite handy for detecting scene change transitions:
 
 
* {{ScriptFunction|RGBDifferenceFromPrevious|v2.x|RGBDifferenceFromPrevious(clip)}}
 
* {{ScriptFunction|YDifferenceFromPrevious|v2.x|YDifferenceFromPrevious(clip)}}
 
* {{ScriptFunction|UDifferenceFromPrevious|v2.x|UDifferenceFromPrevious(clip)}}
 
* {{ScriptFunction|VDifferenceFromPrevious|v2.x|VDifferenceFromPrevious(clip)}}
 
: This group of functions return the absolute difference of pixel value between the current and previous frame of <tt>clip</tt>. Either the combined RGB difference or the Luma, U-chroma or V-chroma differences, respectively.
 
: ''Examples:''
 
scene_change = YDifferenceFromPrevious() > threshold ? true : false
 
scene_change ? some_filter(...) : another_filter(...)
 
 
* {{ScriptFunction|RGBDifferenceToNext|v2.x|RGBDifferenceToNext(clip)}}
 
* {{ScriptFunction|YDifferenceToNext|v2.x|YDifferenceToNext(clip)}}
 
* {{ScriptFunction|UDifferenceToNext|v2.x|UDifferenceToNext(clip)}}
 
* {{ScriptFunction|VDifferenceToNext|v2.x|VDifferenceToNext(clip)}}
 
: This group of functions return the absolute difference of pixel value between the current and next frame of <tt>clip</tt>. Either the combined RGB difference or the Luma, U-chroma or V-chroma differences, respectively.
 
: ''Examples:''
 
# both th1, th2 are positive thresholds; th1 is larger enough than th2
 
scene_change = YDifferenceFromPrevious() > th1 && YDifferenceToNext() < th2
 
scene_change ? some_filter(...) : another_filter(...)
 
 
* {{ScriptFunction|YPlaneMax|v2.x|YPlaneMax(clip, float threshold)}}
 
* {{ScriptFunction|UPlaneMax|v2.x|UPlaneMax(clip, float threshold)}}
 
* {{ScriptFunction|VPlaneMax|v2.x|VPlaneMax(clip, float threshold)}}
 
* {{ScriptFunction|YPlaneMin|v2.x|YPlaneMin(clip, float threshold)}}
 
* {{ScriptFunction|UPlaneMin|v2.x|UPlaneMin(clip, float threshold)}}
 
* {{ScriptFunction|VPlaneMin|v2.x|VPlaneMin(clip, float threshold)}}
 
* {{ScriptFunction|YPlaneMedian|v2.x|YPlaneMedian(clip)}}
 
* {{ScriptFunction|UPlaneMedian|v2.x|UPlaneMedian(clip)}}
 
* {{ScriptFunction|VPlaneMedian|v2.x|VPlaneMedian(clip)}}
 
* {{ScriptFunction|YPlaneMinMaxDifference|v2.x|YPlaneMinMaxDifference(clip, float threshold)}}
 
* {{ScriptFunction|UPlaneMinMaxDifference|v2.x|UPlaneMinMaxDifference(clip, float threshold)}}
 
* {{ScriptFunction|VPlaneMinMaxDifference|v2.x|VPlaneMinMaxDifference(clip, float threshold)}}
 
: 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).
 
: <tt>threshold</tt> is a percentage, stating how many percent of the pixels are allowed above or below minimum. The threshold is optional and defaults to 0.
 
: ''Examples:''
 
# median and average are close only on even distributions; this can be a useful diagnostic
 
have_intense_brights = YPlaneMedian() - AverageLuma() < threshold
 
...
 
# a simple per-frame normalizer to [16..235], CCIR, range
 
[[Levels]](YPlaneMin(), 1.0, YPlaneMax(), 16, 235)
 
 
----
 
Back to [[Internal functions]].
 
  
 
[[Category:AviSynth_Syntax]]
 
[[Category:AviSynth_Syntax]]
 
[[Category:Scripting_Basics]]
 
[[Category:Scripting_Basics]]

Latest revision as of 03:56, 17 September 2014

  1. REDIRECT Internal_functions#Runtime_functions
Personal tools