User:Raffriff42/sandbox
From Avisynth wiki
< User:Raffriff42(Difference between revisions)
Raffriff42 (Talk | contribs) |
Raffriff42 (Talk | contribs) m |
||
Line 4: | Line 4: | ||
: They return true or false, if the condition that they test holds or not, respectively. | : They return true or false, if the condition that they test holds or not, respectively. | ||
− | + | {{ScriptFunctionH5|IsBool|v1|IsBool(var)}} | |
: Tests if ''var'' is of the bool type. ''var'' can be any expression allowed by the [[AviSynth Syntax]]. | : Tests if ''var'' is of the bool type. ''var'' can be any expression allowed by the [[AviSynth Syntax]]. | ||
: ''Examples:'' | : ''Examples:'' | ||
Line 12: | Line 12: | ||
IsBool(123) = false | IsBool(123) = false | ||
− | + | {{ScriptFunctionH5|IsClip||IsClip(var)}} | |
: Tests if ''var'' is of the clip type. ''var'' can be any expression allowed by the [[AviSynth Syntax]]. | : Tests if ''var'' is of the clip type. ''var'' can be any expression allowed by the [[AviSynth Syntax]]. | ||
: ''Examples:'' | : ''Examples:'' | ||
Line 19: | Line 19: | ||
IsClip("c") = false | IsClip("c") = false | ||
− | + | {{ScriptFunctionH5|IsFloat||IsFloat(var)}} | |
: Tests if ''var'' is of the float type. ''var'' can be any expression allowed by the [[AviSynth Syntax]]. | : Tests if ''var'' is of the float type. ''var'' can be any expression allowed by the [[AviSynth Syntax]]. | ||
: ''Examples:'' | : ''Examples:'' | ||
Line 27: | Line 27: | ||
IsFloat(true) = false | IsFloat(true) = false | ||
− | + | {{ScriptFunctionH5|IsInt||IsInt(var)}} | |
: Tests if ''var'' is of the int type. ''var'' can be any expression allowed by the [[AviSynth Syntax]]. | : Tests if ''var'' is of the int type. ''var'' can be any expression allowed by the [[AviSynth Syntax]]. | ||
: ''Examples:'' | : ''Examples:'' | ||
Line 34: | Line 34: | ||
IsInt(true) = false | IsInt(true) = false | ||
− | + | {{ScriptFunctionH5|IsString||IsString(var)}} | |
: Tests if ''var'' is of the string type. ''var'' can be any expression allowed by the [[AviSynth Syntax]]. | : Tests if ''var'' is of the string type. ''var'' can be any expression allowed by the [[AviSynth Syntax]]. | ||
: ''Examples:'' | : ''Examples:'' | ||
Line 41: | Line 41: | ||
IsString([[Internal_functions/Conversion_functions|String]](2.3)) = true | IsString([[Internal_functions/Conversion_functions|String]](2.3)) = true | ||
− | + | {{ScriptFunctionH5|Exist|v2.07|Exist(filename)}} | |
: Tests if the file specified by ''filename'' exists. | : Tests if the file specified by ''filename'' exists. | ||
: ''Examples:'' | : ''Examples:'' | ||
Line 47: | Line 47: | ||
clp = Exist(filename) ? [[AviSource]](filename) : [[Internal_functions/Control_functions|Assert]](false, "file: " + filename + " does not exist") | clp = Exist(filename) ? [[AviSource]](filename) : [[Internal_functions/Control_functions|Assert]](false, "file: " + filename + " does not exist") | ||
− | + | {{ScriptFunctionH5|Defined||Defined(var)}} | |
: Tests if ''var'' is defined. Can be used inside [[Script_functions]] to test if an optional argument has been given an explicit value. | : Tests if ''var'' is defined. Can be used inside [[Script_functions]] to test if an optional argument has been given an explicit value. | ||
: More formally, the function returns false if its argument (normally a function argument or variable) has the void ('undefined') type, otherwise it returns true. | : More formally, the function returns false if its argument (normally a function argument or variable) has the void ('undefined') type, otherwise it returns true. | ||
Line 57: | Line 57: | ||
: These facilitate flow of control (loading of scripts, arguments checks, global settings adjustment, etc.). | : These facilitate flow of control (loading of scripts, arguments checks, global settings adjustment, etc.). | ||
− | + | {{ScriptFunctionH5|Apply||Apply(string ''func_string'' [, arg1 [, arg2 [, ... [, argn]]]] )}} | |
: Calls the function or filter ''func_string'' with arguments ''arg1'', ''arg2'', ..., ''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. | : Calls the function or filter ''func_string'' with arguments ''arg1'', ''arg2'', ..., ''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. | ||
: 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>. | : 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>. | ||
Line 65: | Line 65: | ||
# Note that the clip argument must be supplied - 'last' is not implicitly assumed | # Note that the clip argument must be supplied - 'last' is not implicitly assumed | ||
− | + | {{ScriptFunctionH5|Eval||Eval(expression [, string ''name''])}} | |
: Eval evaluates an arbitrary ''expression'' as if it was placed inside the script at the point of the call to Eval and returns the result of evaluation (either to the [[Script_variables|variable]] that is explicitly assigned to or to the last special variable. | : Eval evaluates an arbitrary ''expression'' as if it was placed inside the script at the point of the call to Eval and returns the result of evaluation (either to the [[Script_variables|variable]] that is explicitly assigned to or to the last special variable. | ||
: 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. | : 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. | ||
Line 80: | Line 80: | ||
dummy = Eval("global my_counter = my_counter + " + String(increment)) | dummy = Eval("global my_counter = my_counter + " + String(increment)) | ||
− | + | {{ScriptFunctionH5|Import||Import(filename)}} | |
: Import evaluates the contents of another AviSynth script and returns the imported 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. | : Import evaluates the contents of another AviSynth script and returns the imported 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. | ||
: Possible scenarios (an indicative list) where the return value could be of use is for the library script to: | : Possible scenarios (an indicative list) where the return value could be of use is for the library script to: | ||
Line 92: | Line 92: | ||
source = okflag ? global1 + global2 + global3 : [[BlankClip]]() | source = okflag ? global1 + global2 + global3 : [[BlankClip]]() | ||
− | + | {{ScriptFunctionH5|Select||Select(index, item0 [, item1 [, ...[, itemn]]])}} | |
: Returns the item selected by the ''index'' argument, which must be of int type (0 returns ''item0'', 1 returns ''item1'', ..., etc). Items can be any script [[Script_variables|variable]] or expression of any type and can even be mixed. | : Returns the item selected by the ''index'' argument, which must be of int type (0 returns ''item0'', 1 returns ''item1'', ..., etc). Items can be any script [[Script_variables|variable]] or expression of any type and can even be mixed. | ||
: ''Examples:'' | : ''Examples:'' | ||
Line 99: | Line 99: | ||
brush = Select(idx, [[AviSource]]("round.avi"), rectangle, diagonal, diagonal.[[FlipHorizontal]]) | brush = Select(idx, [[AviSource]]("round.avi"), rectangle, diagonal, diagonal.[[FlipHorizontal]]) | ||
− | + | {{ScriptFunctionH5|Default||Default(x, d)}} | |
: Returns ''x'' if Defined(x) is true, ''d'' otherwise. ''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. | : Returns ''x'' if Defined(x) is true, ''d'' otherwise. ''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. | ||
: ''Examples:'' | : ''Examples:'' | ||
Line 108: | Line 108: | ||
} | } | ||
− | + | {{ScriptFunctionH5|Assert||Assert(condition [, err_msg])}} | |
: Does nothing if ''condition'' is true; throws an error, immediately terminating script execution, if ''condition'' is false. In the later case ''err_msg'', if supplied, is presented to the user through a dialog box; else the standard message "Assert: assertion failed". shows up. | : Does nothing if ''condition'' is true; throws an error, immediately terminating script execution, if ''condition'' is false. In the later case ''err_msg'', if supplied, is presented to the user through a dialog box; else the standard message "Assert: assertion failed". shows up. | ||
: ''Examples:'' | : ''Examples:'' | ||
Line 118: | Line 118: | ||
} | } | ||
− | + | {{ScriptFunctionH5|NOP||NOP()}} | |
: 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 ?: operator) but your script does not need one. | : 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 ?: operator) but your script does not need one. | ||
: Return value: 0 (int type). | : Return value: 0 (int type). | ||
Line 126: | Line 126: | ||
loadlib ? [[Import]]("my_useful_functions.avs") : NOP | loadlib ? [[Import]]("my_useful_functions.avs") : NOP | ||
− | + | {{ScriptFunctionH5|UnDefined|v2.60|UnDefined()}} | |
− | + | ||
: Returns the undefined state. | : Returns the undefined state. | ||
: It's the state for which Defined() returns false. | : It's the state for which Defined() returns false. | ||
Line 136: | Line 135: | ||
== Global Options == | == Global Options == | ||
− | + | {{ScriptFunctionH5|SetMemoryMax|v2|SetMemoryMax(amount)}} | |
− | + | ||
: Sets the maximum memory that AviSynth uses (in MB) to the value of ''amount''. Setting to zero just returns the current Memory Max value. v2, (=0) v2.58. In the 2.5 series the default Memory Max value is 25% of the free physical memory, with a minimum of 16MB. | : Sets the maximum memory that AviSynth uses (in MB) to the value of ''amount''. Setting to zero just returns the current Memory Max value. v2, (=0) v2.58. In the 2.5 series the default Memory Max value is 25% of the free physical memory, with a minimum of 16MB. | ||
: From v2.58, the default Memory Max is also limited to 512MB. | : From v2.58, the default Memory Max is also limited to 512MB. | ||
Line 174: | Line 172: | ||
SetMemoryMax(128) | SetMemoryMax(128) | ||
− | + | {{ScriptFunctionH5|SetWorkingDir|v2|SetWorkingDir(path)}} | |
− | + | ||
: Sets the default directory for AviSynth to the ''path'' argument. | : Sets the default directory for AviSynth to the ''path'' argument. | ||
: This is primarily for easy loading of source clips, [[Import|importing]] scripts, etc. It does not affect plugins' autoloading. | : This is primarily for easy loading of source clips, [[Import|importing]] scripts, etc. It does not affect plugins' autoloading. | ||
Line 183: | Line 180: | ||
[[AviSource]]("border_mask.avi") # this loads c:\my_presets\border_mask.avi | [[AviSource]]("border_mask.avi") # this loads c:\my_presets\border_mask.avi | ||
− | + | {{ScriptFunctionH5|SetPlanarLegacyAlignment|v2.56|SetPlanarLegacyAlignment(mode)}} | |
− | + | ||
: Set alignment mode for [[planar]] frames. ''mode'' can either be true or false. | : Set alignment mode for [[planar]] frames. ''mode'' can either be true or false. | ||
: 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 GetFrame() call stack, so it effects filters '''before''' it in the script. | : 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 GetFrame() call stack, so it effects filters '''before''' it in the script. | ||
Line 196: | Line 192: | ||
... # advanced memory alignment. | ... # advanced memory alignment. | ||
− | + | {{ScriptFunctionH5|OPT_AllowFloatAudio|v2.57|global OPT_AllowFloatAudio = True}} | |
− | + | ||
: This option enables WAVE_FORMAT_IEEE_FLOAT audio output. The default is to autoconvert Float audio to 16 bit. <br> | : This option enables WAVE_FORMAT_IEEE_FLOAT audio output. The default is to autoconvert Float audio to 16 bit. <br> | ||
− | + | {{ScriptFunctionH5|OPT_UseWaveExtensible|v2.58|global OPT_UseWaveExtensible = True}} | |
− | + | ||
: This option enables WAVE_FORMAT_EXTENSIBLE audio output. The default is WAVE_FORMAT_EX. | : This option enables WAVE_FORMAT_EXTENSIBLE audio output. The default is WAVE_FORMAT_EX. | ||
: '''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. | : '''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. | ||
− | + | {{ScriptFunctionH5|OPT_VDubPlanarHack|v2.60|global OPT_VDubPlanarHack = True}} | |
− | + | ||
: This option enables flipped YV24 and YV16 chroma planes. This is an hack for early versions of Virtualdub with YV24/YV16 support. <br> | : This option enables flipped YV24 and YV16 chroma planes. This is an hack for early versions of Virtualdub with YV24/YV16 support. <br> | ||
− | + | {{ScriptFunctionH5|OPT_dwChannelMask|v2.60|global OPT_dwChannelMask(int v)}} | |
− | + | ||
: This option enables you to set ChannelMask. It overrides WAVEFORMATEXTENSIBLE.dwChannelMask which is set according to this table | : This option enables you to set ChannelMask. It overrides WAVEFORMATEXTENSIBLE.dwChannelMask which is set according to this table | ||
0x00004, // 1 -- -- Cf | 0x00004, // 1 -- -- Cf | ||
Line 221: | Line 213: | ||
0x0063F, // 7.1 Lf Rf Cf Sw Lr Rr -- -- -- Ls Rs <br> | 0x0063F, // 7.1 Lf Rf Cf Sw Lr Rr -- -- -- Ls Rs <br> | ||
− | + | {{ScriptFunctionH5|OPT_AVIPadScanlines|v2.60|global OPT_AVIPadScanlines = True}} | |
− | + | ||
: 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> | : 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> | ||
Line 228: | Line 219: | ||
: These convert between different types. | : These convert between different types. | ||
− | + | {{ScriptFunctionH5|Value|v2.07|Value(string)}} | |
− | + | ||
: Converts a decimal string to its associated numeric value. | : Converts a decimal string to its associated numeric value. | ||
: ''Examples:'' | : ''Examples:'' | ||
Value ("-2.7") = -2.7 | Value ("-2.7") = -2.7 | ||
− | + | {{ScriptFunctionH5|HexValue|v2.07|HexValue(string)}} | |
− | + | ||
: Converts a hexadecimal string to its associated numeric value. | : Converts a hexadecimal string to its associated numeric value. | ||
: ''Examples:'' | : ''Examples:'' | ||
HexValue ("FF00") = 65280 | HexValue ("FF00") = 65280 | ||
− | + | {{ScriptFunctionH5|Hex|v2.60|Hex(int)}} | |
− | + | ||
: Converts a numerical value to its hexadecimal value. See [[Colors]] for more information on specifying colors. | : Converts a numerical value to its hexadecimal value. See [[Colors]] for more information on specifying colors. | ||
: ''Examples:'' | : ''Examples:'' | ||
Hex (10824234) = "A52A2A" | Hex (10824234) = "A52A2A" | ||
− | + | {{ScriptFunctionH5|String|v2.07|String(float / int [, string format_string])}} | |
− | + | ||
: 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. | : 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. | ||
: If the variable is float or integer, it first converts it to a float and then uses format_string to convert the float to a string. The syntax of format_string is as follows: | : If the variable is float or integer, it first converts it to a float and then uses format_string to convert the float to a string. The syntax of format_string is as follows: | ||
Line 284: | Line 271: | ||
: They provide common mathematical operations on numeric variables. | : They provide common mathematical operations on numeric variables. | ||
− | + | {{ScriptFunctionH5|Max|v2.58|Max(float, float [, ...])}} | |
− | + | ||
: Returns the maximum value of a set of numbers. | : Returns the maximum value of a set of numbers. | ||
: 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. | : 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. | ||
Line 293: | Line 279: | ||
Max (5, 3.0, 2) = 5.0 | Max (5, 3.0, 2) = 5.0 | ||
− | + | {{ScriptFunctionH5|Min|v2.58|Min(float, float [, ...])}} | |
− | + | ||
: Returns the minimum value of a set of numbers. | : Returns the minimum value of a set of numbers. | ||
: ''Examples:'' | : ''Examples:'' | ||
Line 300: | Line 285: | ||
Min (5, 3.0, 2) = 2.0 | Min (5, 3.0, 2) = 2.0 | ||
− | + | {{ScriptFunctionH5|MulDiv|v2.56|MulDiv(int, int, int)}} | |
− | + | ||
: 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>. | : 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>. | ||
: ''Examples:'' | : ''Examples:'' | ||
Line 307: | Line 291: | ||
MulDiv (2, 3, 2) = 3 | MulDiv (2, 3, 2) = 3 | ||
− | + | {{ScriptFunctionH5|Floor||Floor(float)}} | |
: Converts from single-precision, [http://en.wikipedia.org/wiki/Floating_point floating-point] value to int (round down on any fractional amount). | : Converts from single-precision, [http://en.wikipedia.org/wiki/Floating_point floating-point] value to int (round down on any fractional amount). | ||
: ''Examples:'' | : ''Examples:'' | ||
Line 315: | Line 299: | ||
Floor(-1.6) = -2 | Floor(-1.6) = -2 | ||
− | + | {{ScriptFunctionH5|Ceil||Ceil(float)}} | |
: Converts from single-precision, [http://en.wikipedia.org/wiki/Floating_point floating-point] value to int (round up on any fractional amount). | : Converts from single-precision, [http://en.wikipedia.org/wiki/Floating_point floating-point] value to int (round up on any fractional amount). | ||
: ''Examples:'' | : ''Examples:'' | ||
Line 323: | Line 307: | ||
Ceil(-1.6) = -1 | Ceil(-1.6) = -1 | ||
− | + | {{ScriptFunctionH5|Round||Round(float)}} | |
: Converts from single-precision, [http://en.wikipedia.org/wiki/Floating_point floating-point] value to int (round off to nearest integer). | : Converts from single-precision, [http://en.wikipedia.org/wiki/Floating_point floating-point] value to int (round off to nearest integer). | ||
: ''Examples:'' | : ''Examples:'' | ||
Line 331: | Line 315: | ||
Round(-1.6) = -2 | Round(-1.6) = -2 | ||
− | + | {{ScriptFunctionH5|Int|v2.07|Int(float)}} | |
− | + | ||
: Converts from single-precision, [http://en.wikipedia.org/wiki/Floating_point floating-point] value to int (round towards zero). | : Converts from single-precision, [http://en.wikipedia.org/wiki/Floating_point floating-point] value to int (round towards zero). | ||
: ''Examples:'' | : ''Examples:'' | ||
Line 340: | Line 323: | ||
Int(-1.6) = -1 | Int(-1.6) = -1 | ||
− | + | {{ScriptFunctionH5|Float|v2.07|Float(int)}} | |
− | + | ||
: 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. | : 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. | ||
: ''Examples:'' | : ''Examples:'' | ||
Line 347: | Line 329: | ||
Float(4) / 3 = 1.333 (while 4 / 3 = 1 , due to integer division) | Float(4) / 3 = 1.333 (while 4 / 3 = 1 , due to integer division) | ||
− | + | {{ScriptFunctionH5|Sin|v2|Sin(float)}} | |
− | + | ||
: Returns the sine of the argument (assumes it is radians). | : Returns the sine of the argument (assumes it is radians). | ||
: ''Examples:'' | : ''Examples:'' | ||
Line 354: | Line 335: | ||
Sin(Pi()/2) = 1.0 | Sin(Pi()/2) = 1.0 | ||
− | + | {{ScriptFunctionH5|Cos|v2|Cos(float)}} | |
− | + | ||
: Returns the cosine of the argument (assumes it is radians). | : Returns the cosine of the argument (assumes it is radians). | ||
: ''Examples:'' | : ''Examples:'' | ||
Line 361: | Line 341: | ||
Cos(Pi()/2) = 0.0 | Cos(Pi()/2) = 0.0 | ||
− | + | {{ScriptFunctionH5|Tan|v2.60|Tan(float)}} | |
− | + | ||
: Returns the tangent of the argument (assumes it is radians). | : Returns the tangent of the argument (assumes it is radians). | ||
: ''Examples:'' | : ''Examples:'' | ||
Line 372: | Line 351: | ||
: slightly greater than pi/2. | : slightly greater than pi/2. | ||
− | + | {{ScriptFunctionH5|Asin|v2.60|Asin(float)}} | |
− | + | ||
: Returns the inverse of the sine of the argument (output is radians). | : Returns the inverse of the sine of the argument (output is radians). | ||
: ''Examples:'' | : ''Examples:'' | ||
Line 379: | Line 357: | ||
Asin(1.0) = 1.570796327 (~ Pi/2) | Asin(1.0) = 1.570796327 (~ Pi/2) | ||
− | + | {{ScriptFunctionH5|Acos|v2.60|Acos(float)}} | |
− | + | ||
: Returns the inverse of the cosine of the argument (output is in radians). | : Returns the inverse of the cosine of the argument (output is in radians). | ||
: ''Examples:'' | : ''Examples:'' | ||
Line 386: | Line 363: | ||
Acos(0.0) = 1.570796327 (~ Pi/2) | Acos(0.0) = 1.570796327 (~ Pi/2) | ||
− | + | {{ScriptFunctionH5|Atan|v2.60|Atan(float)}} | |
− | + | ||
: Returns the inverse of the tangent of the argument (output is in radians). | : Returns the inverse of the tangent of the argument (output is in radians). | ||
: ''Examples:'' | : ''Examples:'' | ||
Line 393: | Line 369: | ||
Atan(1.0) = 0.7853981634 (~ Pi/4) | Atan(1.0) = 0.7853981634 (~ Pi/4) | ||
− | + | {{ScriptFunctionH5|Atan2|v2.60|Atan2(float, float)}} | |
− | + | ||
: 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. | : 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. | ||
: y is the first argument and x is the second argument. | : y is the first argument and x is the second argument. | ||
Line 402: | Line 377: | ||
Atan2(-1.0, -1.0) = -2.356194490 (~ -3Pi/4) | Atan2(-1.0, -1.0) = -2.356194490 (~ -3Pi/4) | ||
− | + | {{ScriptFunctionH5|Sinh|v2.60|Sinh(float)}} | |
− | + | ||
: Returns the hyperbolic sine of the argument. See [http://en.wikipedia.org/wiki/Hyperbolic_function wikipedia] for more information. | : Returns the hyperbolic sine of the argument. See [http://en.wikipedia.org/wiki/Hyperbolic_function wikipedia] for more information. | ||
: ''Examples:'' | : ''Examples:'' | ||
Sinh(2.0) = 3.626860408 | Sinh(2.0) = 3.626860408 | ||
− | + | {{ScriptFunctionH5|Cosh|v2.60|Cosh(float)}} | |
− | + | ||
: Returns the hyperbolic cosine of the argument. | : Returns the hyperbolic cosine of the argument. | ||
: ''Examples:'' | : ''Examples:'' | ||
Cosh(2.0) = 3.762195691 | Cosh(2.0) = 3.762195691 | ||
− | + | {{ScriptFunctionH5|Tanh|v2.60|Tanh(float)}} | |
− | + | ||
: Returns the hyperbolic tangent of the argument. | : Returns the hyperbolic tangent of the argument. | ||
: ''Examples:'' | : ''Examples:'' | ||
Tanh(2.0) = 0.9640275801 | Tanh(2.0) = 0.9640275801 | ||
− | + | {{ScriptFunctionH5|Fmod|v2.60|Fmod(float, float)}} | |
− | + | ||
: Returns the modulo of the argument. Output is float. | : Returns the modulo of the argument. Output is float. | ||
: ''Examples:'' | : ''Examples:'' | ||
Line 427: | Line 398: | ||
Fmod(3.5, 1.0) = 0.5 (since 3.5 - 3*1.0 = 0.5) | Fmod(3.5, 1.0) = 0.5 (since 3.5 - 3*1.0 = 0.5) | ||
− | + | {{ScriptFunctionH5|Pi|v2|Pi()}} | |
− | + | ||
: Returns the value of the "pi" constant (the ratio of a circle's circumference to its diameter). | : Returns the value of the "pi" constant (the ratio of a circle's circumference to its diameter). | ||
: ''Examples:'' | : ''Examples:'' | ||
d = Pi() # d == 3.141592653 | d = Pi() # d == 3.141592653 | ||
− | + | {{ScriptFunctionH5|Exp|v2|Exp(float)}} | |
: @since v2 | : @since v2 | ||
: Returns the natural (base-e) exponent of the argument. | : Returns the natural (base-e) exponent of the argument. | ||
Line 440: | Line 410: | ||
Exp(0) = 1.0 | Exp(0) = 1.0 | ||
− | + | {{ScriptFunctionH5|Log|v2|Log(float)}} | |
− | + | ||
: Returns the natural (base-e) logarithm of the argument. | : Returns the natural (base-e) logarithm of the argument. | ||
: ''Examples:'' | : ''Examples:'' | ||
Line 448: | Line 417: | ||
Log(Exp(1)) = 1.0 | Log(Exp(1)) = 1.0 | ||
− | + | {{ScriptFunctionH5|Log10|v2.60|Log10(float)}} | |
− | + | ||
: Returns the common logarithm of the argument. | : Returns the common logarithm of the argument. | ||
: ''Examples:'' | : ''Examples:'' | ||
Line 456: | Line 424: | ||
Log10(2.0) = 0.3010299957 | Log10(2.0) = 0.3010299957 | ||
− | + | {{ScriptFunctionH5|Pow|v2|Pow(float base, float power)}} | |
− | + | ||
: Returns "base" raised to the power indicated by the second argument. | : Returns "base" raised to the power indicated by the second argument. | ||
: ''Examples:'' | : ''Examples:'' | ||
Line 464: | Line 431: | ||
Pow(3.45, 1.75) = 8.7334 | Pow(3.45, 1.75) = 8.7334 | ||
− | + | {{ScriptFunctionH5|Sqrt|v2|Sqrt(float)}} | |
− | + | ||
: Returns the square root of the argument. | : Returns the square root of the argument. | ||
: ''Examples:'' | : ''Examples:'' | ||
Line 471: | Line 437: | ||
Sqrt(2) = 1.4142 | Sqrt(2) = 1.4142 | ||
− | + | {{ScriptFunctionH5|Abs|v2.07|Abs(float or int)}} | |
− | + | ||
: Returns the absolute value of its argument (returns float for float, integer for integer). | : Returns the absolute value of its argument (returns float for float, integer for integer). | ||
: ''Examples:'' | : ''Examples:'' | ||
Line 478: | Line 443: | ||
Abs(-4) = 4 | Abs(-4) = 4 | ||
− | + | {{ScriptFunctionH5|Sign|v2.07|Sign(float)}} | |
− | + | ||
: Returns the sign of the value passed as argument (1, 0 or -1). | : Returns the sign of the value passed as argument (1, 0 or -1). | ||
: ''Examples:'' | : ''Examples:'' | ||
Line 486: | Line 450: | ||
Sign(0) = 0 | Sign(0) = 0 | ||
− | + | {{ScriptFunctionH5|Frac|v2.07|Frac(float)}} | |
− | + | ||
: Returns the fractional portion of the value provided. | : Returns the fractional portion of the value provided. | ||
: ''Examples:'' | : ''Examples:'' | ||
Line 493: | Line 456: | ||
Frac(-1.8) = -0.8 | Frac(-1.8) = -0.8 | ||
− | + | {{ScriptFunctionH5|Rand|v2.07|Rand([int max] [, bool scale] [, bool seed])}} | |
− | + | ||
: Returns a random integer value. All parameters are optional. | : Returns a random integer value. All parameters are optional. | ||
− | : | + | :;max |
− | : | + | ::sets the maximum value+1 (default 32768) and can be set negative for negative results. It operates either in scaled or modulus mode (default ''scale''=true only if abs(max) > 32768, false otherwise). |
− | : | + | :;scale |
− | : Typically, this function would be used with the Select function for random clips. | + | ::When true, ''scales'' the internal random number generator value to the maximum value, while ''modulus mode'' (scale=false) uses the remainder from an integer divide of the random generator value by the maximum. Modulus mode is recommended for smaller maximums. |
+ | :;seed | ||
+ | ::When true, seeds the random number generator with the current time. ''seed'' defaults to false and probably isn't necessary, although it's there just in case. | ||
+ | : Typically, this function would be used with the [[#Select]] function for random clips. | ||
: ''Examples:'' | : ''Examples:'' | ||
Select(Rand(5), clip1, clip2, clip3, clip4, clip5) | Select(Rand(5), clip1, clip2, clip3, clip4, clip5) | ||
− | + | {{ScriptFunctionH5|Spline|v2.51|Spline(float X, x1, y1, x2, y2, .... [, bool cubic])}} | |
− | + | ||
: Interpolates the Y value at point X using the control points x1/y1, ... There have to be at least 2 x/y-pairs. The interpolation can be cubic (the result is a spline) or linear (the result is a polygon). Default is cubic. | : Interpolates the Y value at point X using the control points x1/y1, ... There have to be at least 2 x/y-pairs. The interpolation can be cubic (the result is a spline) or linear (the result is a polygon). Default is cubic. | ||
: ''Examples:'' | : ''Examples:'' | ||
Line 511: | Line 475: | ||
===== ContinuedNumerator ===== | ===== ContinuedNumerator ===== | ||
− | + | {{ScriptFunctionCode|ContinuedNumerator|v2.60|ContinuedNumerator(float, int limit)}} | |
− | + | {{ScriptFunctionCode|ContinuedNumerator|v2.60|ContinuedNumerator(int, int, int limit)}} | |
− | + | {{ScriptFunctionCode|ContinuedDenominator|v2.60|ContinuedDenominator(float, int limit)}} | |
− | + | {{ScriptFunctionCode|ContinuedDenominator|v2.60|ContinuedDenominator(int, int, int limit)}} | |
− | + | ||
− | + | ||
: The rational pair (ContinuedNumerator, ContinuedDenominator) returned has the smallest possible denominator such that the absolute error is less than 1/limit. More information can be found on [http://en.wikipedia.org/wiki/Continued_fraction wikipedia]. | : The rational pair (ContinuedNumerator, ContinuedDenominator) returned has the smallest possible denominator such that the absolute error is less than 1/limit. More information can be found on [http://en.wikipedia.org/wiki/Continued_fraction wikipedia]. | ||
: If ''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. | : If ''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. | ||
Line 530: | Line 492: | ||
ContinuedDenominator(355, 113, limit=50) = 7 | ContinuedDenominator(355, 113, limit=50) = 7 | ||
− | + | {{ScriptFunctionH5|BitAnd|v2.60|BitAnd(int, int)}} | |
− | + | ||
: The functions: BitAnd, BitNot, BitOr and BitXor, etc, are bitwise operators. 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. | : The functions: BitAnd, BitNot, BitOr and BitXor, etc, are bitwise operators. 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. | ||
: BitAnd returns the bitwise AND (sets bit to 1 if both bits are 1 and sets bit to 0 otherwise). | : BitAnd returns the bitwise AND (sets bit to 1 if both bits are 1 and sets bit to 0 otherwise). | ||
Line 537: | Line 498: | ||
BitAnd(5, 6) = 4 # since 5 = 101, 6 = 110, and 101&110 = 100 | BitAnd(5, 6) = 4 # since 5 = 101, 6 = 110, and 101&110 = 100 | ||
− | + | {{ScriptFunctionH5|BitNot|v2.60|BitNot(int)}} | |
− | + | ||
: Returns the bit-inversion (sets bit to 1 if bit is 0 and vice-versa). | : Returns the bit-inversion (sets bit to 1 if bit is 0 and vice-versa). | ||
: ''Examples:'' | : ''Examples:'' | ||
Line 544: | Line 504: | ||
: Note: 1111 1111 1111 1111 1111 1111 1111 1010 = (2^32-1)-2^0-2^2 = 2^32-(1+2^0+2^2) =(signed) -(1+2^0+2^2) = -6 | : Note: 1111 1111 1111 1111 1111 1111 1111 1010 = (2^32-1)-2^0-2^2 = 2^32-(1+2^0+2^2) =(signed) -(1+2^0+2^2) = -6 | ||
− | + | {{ScriptFunctionH5|BitOr|v2.60|BitOr(int, int)}} | |
− | + | ||
: Returns the bitwise inclusive OR (sets bit to 1 if one of the bits (or both) is 1 and sets bit to 0 otherwise). | : Returns the bitwise inclusive OR (sets bit to 1 if one of the bits (or both) is 1 and sets bit to 0 otherwise). | ||
: ''Examples:'' | : ''Examples:'' | ||
Line 551: | Line 510: | ||
BitOr(4, 2) = 6 # since 4 = 100, 2 = 010, and 100|010 = 110 | BitOr(4, 2) = 6 # since 4 = 100, 2 = 010, and 100|010 = 110 | ||
− | + | {{ScriptFunctionH5|BitXor|v2.60|BitXor(int, int)}} | |
− | + | ||
: Returns the bitwise exclusive OR (sets bit to 1 if exactly one of the bits is 1 and sets bit to 0 otherwise). | : Returns the bitwise exclusive OR (sets bit to 1 if exactly one of the bits is 1 and sets bit to 0 otherwise). | ||
: ''Examples:'' | : ''Examples:'' | ||
Line 558: | Line 516: | ||
BitXor(4, 2) = 6 # since 4 = 100, 2 = 010, and 100^010 = 110 | BitXor(4, 2) = 6 # since 4 = 100, 2 = 010, and 100^010 = 110 | ||
− | ===== BitLShift | + | ===== Bit shift left ===== |
− | + | * {{ScriptFunctionCode|BitLShift|v2.60|BitLShift(int, int)}} | |
+ | * {{ScriptFunctionCode|BitShl|v2.60|BitShl(int, int)}} | ||
+ | * {{ScriptFunctionCode|BitSal|v2.60|BitSal(int, int)}} | ||
: Shift the bits of a number to the left. | : Shift the bits of a number to the left. | ||
: ''Examples:'' | : ''Examples:'' | ||
Line 565: | Line 525: | ||
BitLShift(5, 2) = 20 (since 101 << 2 = 10100) | BitLShift(5, 2) = 20 (since 101 << 2 = 10100) | ||
− | ===== | + | ===== Bit shift right ===== |
− | + | {{ScriptFunctionCode|BitRShiftA|v2.60|BitRShiftA(int, int)}} | |
+ | {{ScriptFunctionCode|BitRShiftS|v2.60|BitRShiftS(int, int)}} | ||
+ | {{ScriptFunctionCode|BitSar|v2.60|BitSar(int, int)}} | ||
+ | : Shift the bits of an integer to the right. (Arithmetic, Sign bit fill, Right Shift) | ||
+ | : Examples: | ||
+ | Shifts the bits of the number -42 one bit to the right, treating it as signed: | ||
+ | BitRShiftA(-42, 1) = -21 (since 1111 1111 1111 1111 1111 1111 1101 0110 >> 1 = 1111 1111 1111 1111 1111 1111 1110 1011) | ||
+ | |||
+ | ===== Bit shift right, unsigned ===== | ||
+ | {{ScriptFunctionCode|BitRShiftL|v2.60|BitRShiftL(int, int)}} | ||
+ | {{ScriptFunctionCode|BitRShiftU|v2.60|BitRShiftU(int, int)}} | ||
+ | {{ScriptFunctionCode|BitShr|v2.60|BitShr(int, int)}} | ||
: Shift the bits of an unsigned integer to the right. (Logical, zero fill, Right Shift) | : Shift the bits of an unsigned integer to the right. (Logical, zero fill, Right Shift) | ||
: ''Examples:'' | : ''Examples:'' | ||
Line 573: | Line 544: | ||
: Note: -42 = -(1+2^0+2^3+2^5) = (unsigned) (2^32-1)-(2^0+2^3+2^5) = 1111 1111 1111 1111 1111 1111 1101 0110 | : Note: -42 = -(1+2^0+2^3+2^5) = (unsigned) (2^32-1)-(2^0+2^3+2^5) = 1111 1111 1111 1111 1111 1111 1101 0110 | ||
− | ===== | + | ===== Bit rotate left ===== |
− | + | {{ScriptFunctionCode|BitLRotate|v2.60|BitLRotate(int, int)}} | |
− | + | {{ScriptFunctionCode|BitRol|v2.60|BitRol(int, int)}} | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
: 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. | : 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. | ||
: Examples: | : Examples: | ||
Line 587: | Line 552: | ||
BitLRotate(-2147483642, 1) = 13 (since 10000000000000000000000000000110 ROL 1 = 00000000000000000000000000001101) | BitLRotate(-2147483642, 1) = 13 (since 10000000000000000000000000000110 ROL 1 = 00000000000000000000000000001101) | ||
− | ===== BitRRotateL | + | ===== Bit rotate right ===== |
− | + | {{ScriptFunctionCode|BitRRotate|v2.60|BitRRotateL(int, int)}} | |
+ | {{ScriptFunctionCode|BitRor|v2.60|BitRor(int, int)}} | ||
: 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. | : 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. | ||
: Examples: | : Examples: | ||
Line 594: | Line 560: | ||
BitRRotate(13, 1) = -2147483642 (since 00000000000000000000000000001101 ROR 1 = 10000000000000000000000000000110) | BitRRotate(13, 1) = -2147483642 (since 00000000000000000000000000001101 ROR 1 = 10000000000000000000000000000110) | ||
− | ===== BitTest | + | ===== Bit test ===== |
− | + | {{ScriptFunctionCode|BitTest|v2.60|BitTest(int, int)}} | |
+ | {{ScriptFunctionCode|BitTst|v2.60|BitTst(int, int)}} | ||
: 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). | : 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). | ||
: Examples: | : Examples: | ||
Line 606: | Line 573: | ||
BitTest(2147483647, 31) = False | BitTest(2147483647, 31) = False | ||
− | + | {{ScriptFunctionH5|BitSet|v2.60|BitSet(int, int)}} | |
− | + | ||
: 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). | : 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). | ||
: Examples: | : Examples: | ||
Line 618: | Line 584: | ||
BitSet(2147483647, 31) = -1 | BitSet(2147483647, 31) = -1 | ||
− | ===== BitClear | + | ===== Bit clear ===== |
− | + | {{ScriptFunctionCode|BitClear|v2.60|BitClear(int, int)}} | |
+ | {{ScriptFunctionCode|BitClr|v2.60|BitClr(int, int)}} | ||
: 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). | : 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). | ||
: Examples: | : Examples: | ||
Line 631: | Line 598: | ||
BitClear(-1, 31) = 2147483647 | BitClear(-1, 31) = 2147483647 | ||
− | ===== BitChange | + | ===== Bit change ===== |
− | + | {{ScriptFunctionCode|BitChange|v2.60|BitChange(int, int)}} | |
+ | {{ScriptFunctionCode|BitChg|v2.60|BitChg(int, int)}} | ||
: 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. | : 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. | ||
: Examples: | : Examples: | ||
Line 647: | Line 615: | ||
: 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. | : 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. | ||
− | ===== | + | ===== Average luma ===== |
− | + | {{ScriptFunctionCode|AverageLuma|v2.x|AverageLuma(clip)}} | |
+ | {{ScriptFunctionCode|AverageChromaU|v2.x|AverageChromaU(clip)}} | ||
+ | {{ScriptFunctionCode|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]]. | : 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:'' | : ''Examples:'' | ||
Line 655: | Line 625: | ||
luma < threshold ? [[Levels]](0, 1.0 + 0.5*(threshold - luma)/threshold, 255, 10, 255) : last | luma < threshold ? [[Levels]](0, 1.0 + 0.5*(threshold - luma)/threshold, 255, 10, 255) : last | ||
− | ===== RGBDifference, LumaDifference, ChromaUDifference | + | ===== Difference ===== |
− | + | {{ScriptFunctionCode|RGBDifference|v2.x|RGBDifference(clip1, clip2)}} | |
+ | {{ScriptFunctionCode|LumaDifference|v2.x|LumaDifference(clip1, clip2)}} | ||
+ | {{ScriptFunctionCode|ChromaUDifference|v2.x|ChromaUDifference(clip1, clip2)}} | ||
+ | {{ScriptFunctionCode|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]]. | : 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:'' | : ''Examples:'' | ||
Line 664: | Line 637: | ||
... | ... | ||
− | ===== RGBDifferenceFromPrevious | + | ===== Difference from previous ===== |
− | + | {{ScriptFunctionCode|RGBDifferenceFromPrevious|v2.x|RGBDifferenceFromPrevious(clip)}} | |
+ | {{ScriptFunctionCode|YDifferenceFromPrevious|v2.x|YDifferenceFromPrevious(clip)}} | ||
+ | {{ScriptFunctionCode|UDifferenceFromPrevious|v2.x|UDifferenceFromPrevious(clip)}} | ||
+ | {{ScriptFunctionCode|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. | : 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:'' | : ''Examples:'' | ||
Line 671: | Line 647: | ||
scene_change ? some_filter(...) : another_filter(...) | scene_change ? some_filter(...) : another_filter(...) | ||
− | ===== RGBDifferenceToNext | + | ===== Difference to next ===== |
− | + | {{ScriptFunctionCode|RGBDifferenceToNext|v2.x|RGBDifferenceToNext(clip)}} | |
+ | {{ScriptFunctionCode|YDifferenceToNext|v2.x|YDifferenceToNext(clip)}} | ||
+ | {{ScriptFunctionCode|UDifferenceToNext|v2.x|UDifferenceToNext(clip)}} | ||
+ | {{ScriptFunctionCode|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. | : 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:'' | : ''Examples:'' | ||
Line 679: | Line 658: | ||
scene_change ? some_filter(...) : another_filter(...) | scene_change ? some_filter(...) : another_filter(...) | ||
− | ===== | + | ===== Color plane median, min, max, range ===== |
− | + | {{ScriptFunctionCode|YPlaneMedian|v2.x|YPlaneMedian(clip)}} | |
− | + | {{ScriptFunctionCode|UPlaneMedian|v2.x|UPlaneMedian(clip)}} | |
− | + | {{ScriptFunctionCode|VPlaneMedian|v2.x|VPlaneMedian(clip)}} | |
− | + | {{ScriptFunctionCode|YPlaneMin|v2.x|YPlaneMin(clip, float threshold)}} | |
− | + | {{ScriptFunctionCode|UPlaneMin|v2.x|UPlaneMin(clip, float threshold)}} | |
− | + | {{ScriptFunctionCode|VPlaneMin|v2.x|VPlaneMin(clip, float threshold)}} | |
− | + | {{ScriptFunctionCode|YPlaneMax|v2.x|YPlaneMax(clip, float threshold)}} | |
− | + | {{ScriptFunctionCode|UPlaneMax|v2.x|UPlaneMax(clip, float threshold)}} | |
+ | {{ScriptFunctionCode|VPlaneMax|v2.x|VPlaneMax(clip, float threshold)}} | ||
+ | {{ScriptFunctionCode|YPlaneMinMaxDifference|v2.x|YPlaneMinMaxDifference(clip, float threshold)}} | ||
+ | {{ScriptFunctionCode|UPlaneMinMaxDifference|v2.x|UPlaneMinMaxDifference(clip, float threshold)}} | ||
+ | {{ScriptFunctionCode|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). | : 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. | : <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. |
Revision as of 01:45, 17 September 2014
(Non-clip_functions work in progress)
Boolean functions
- They return true or false, if the condition that they test holds or not, respectively.
IsBool
- IsBool(var) v1
- Tests if var is of the bool type. var can be any expression allowed by the AviSynth Syntax.
- Examples:
b = false IsBool(b) = true IsBool(1 < 2 && 0 == 1) = true IsBool(123) = false
IsClip
- IsClip(var)
- Tests if var is of the clip type. var can be any expression allowed by the AviSynth Syntax.
- Examples:
c = AviSource(...) IsClip(c) = true IsClip("c") = false
IsFloat
- IsFloat(var)
- Tests if var is of the float type. var can be any expression allowed by the AviSynth Syntax.
- Examples:
f = Sqrt(2) IsFloat(f) = true IsFloat(2) = true # ints are considered to be floats by this function IsFloat(true) = false
IsInt
- IsInt(var)
- Tests if var is of the int type. var can be any expression allowed by the AviSynth Syntax.
- Examples:
IsInt(2) = true IsInt(2.1) = false IsInt(true) = false
IsString
- IsString(var)
- Tests if var is of the string type. var can be any expression allowed by the AviSynth Syntax.
- Examples:
IsString("test") = true IsString(2.3) = false IsString(String(2.3)) = true
Exist
- Exist(filename) v2.07
- Tests if the file specified by filename exists.
- Examples:
filename = ... clp = Exist(filename) ? AviSource(filename) : Assert(false, "file: " + filename + " does not exist")
Defined
- Defined(var)
- Tests if var is defined. Can be used inside Script_functions to test if an optional argument has been given an explicit value.
- More formally, the function returns false if its argument (normally a function argument or variable) has the void ('undefined') type, otherwise it returns true.
- Examples:
b_arg_supplied = Defined(arg) myvar = b_arg_supplied ? ... : ...
Control functions
- These facilitate flow of control (loading of scripts, arguments checks, global settings adjustment, etc.).
Apply
- Apply(string func_string [, arg1 [, arg2 [, ... [, argn]]]] )
- Calls the function or filter func_string with arguments arg1, arg2, ..., 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.
- Consequently, Apply("f", x) is equivalent to f(x) which in turn is equivalent to Eval("f(" + String(x) + ")").
- Examples:
# here the same call to BicubicResize as in the Eval() example is shown Apply("BicubicResize", last, 352, 288) # Note that the clip argument must be supplied - 'last' is not implicitly assumed
Eval
- Eval(expression [, string name])
- Eval evaluates an arbitrary expression as if it was placed inside the script at the point of the call to Eval and returns the result of evaluation (either to the variable that is explicitly assigned to or to the last special variable.
- 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.
- Argument 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.
- Examples:
# this calls BicubicResize(last, 352, 288) settings = "352, 288" Eval( "BicubicResize(" + settings + ")" ) ... # this will result in Defined(u) == false u = Eval("#") ... # this increments a global based on a variable's value dummy = Eval("global my_counter = my_counter + " + String(increment))
Import
- Import(filename)
- Import evaluates the contents of another AviSynth script and returns the imported 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.
- Possible scenarios (an indicative list) where the return value could be of use is for the library script to:
- indicate whether it succesfully initialised itself (a bool return value),
- inform for the number of presets found on disk (an int return value);
- the value then could be tested by the calling script to decide what action to take next.
- Examples:
Import("mylib.avsi") # here we do not care about the value (mylib.avsi contains only functions) ... okflag = Import("mysources.avsi") # mysources loads predetermined filenames from a folder into globals source = okflag ? global1 + global2 + global3 : BlankClip()
Select
- Select(index, item0 [, item1 [, ...[, itemn]]])
- Returns the item selected by the index argument, which must be of int type (0 returns item0, 1 returns item1, ..., etc). Items can be any script variable or expression of any type and can even be mixed.
- Examples:
# select a clip-brush from a set of presets idx = 2 brush = Select(idx, AviSource("round.avi"), rectangle, diagonal, diagonal.FlipHorizontal)
Default
- Default(x, d)
- Returns x if Defined(x) is true, d otherwise. 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.
- Examples:
function myfunc(clip c, ..., int "strength") { ... strength = Default(strength, 4) # if not supplied make it 4 ... }
Assert
- Assert(condition [, err_msg])
- Does nothing if condition is true; throws an error, immediately terminating script execution, if condition is false. In the later case err_msg, if supplied, is presented to the user through a dialog box; else the standard message "Assert: assertion failed". shows up.
- Examples:
function myfunc(clip c, ..., int "strength") { ... strength = Default(strength, 4) # if not supplied make it 4 Assert(strength > 0, "'strength' must be positive") ... }
NOP
- NOP()
- 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 ?: operator) but your script does not need one.
- Return value: 0 (int type).
- Examples:
preset = want_presets ? AviSource("c:\presets\any.avi") : NOP ... loadlib ? Import("my_useful_functions.avs") : NOP
UnDefined
- UnDefined() v2.60
- Returns the undefined state.
- It's the state for which Defined() returns false.
- Examples:
x = Undefined() Defined(x) # = true
Global Options
SetMemoryMax
- SetMemoryMax(amount) v2
- Sets the maximum memory that AviSynth uses (in MB) to the value of amount. Setting to zero just returns the current Memory Max value. v2, (=0) v2.58. In the 2.5 series the default Memory Max value is 25% of the free physical memory, with a minimum of 16MB.
- From v2.58, the default Memory Max is also limited to 512MB.
Free memory <64 128 256 512 1024 2048 3072 Max v2.57 and older 16 32 64 128 256 512 768 Default Max since v2.58 16 32 64 192 448 512 512
- 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.
- Return value: Actual MemoryMax value set.
- Examples:
SetMemoryMax(128)
SetWorkingDir
- SetWorkingDir(path) v2
- Sets the default directory for AviSynth to the path argument.
- This is primarily for easy loading of source clips, importing scripts, etc. It does not affect plugins' autoloading.
- Return value is 0 if successful, -1 otherwise.
- Examples:
SetWorkingDir("c:\my_presets") AviSource("border_mask.avi") # this loads c:\my_presets\border_mask.avi
SetPlanarLegacyAlignment
- SetPlanarLegacyAlignment(mode) v2.56
- Set alignment mode for planar frames. mode can either be true or false.
- Some older 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 GetFrame() call stack, so it effects filters before it in the script.
- Examples:
Example : Using an older version of Mpeg2Source() (1.10 or older): LoadPlugin("...\Mpeg2Decode.dll") Mpeg2Source("test.d2v") # A plugin that illegally assumes the layout of memory SetPlanarLegacyAlignment(true) # Set legacy memory alignment for prior statements ConvertToYUY2() # Statements through to the end of the script have ... # advanced memory alignment.
OPT_AllowFloatAudio
- global OPT_AllowFloatAudio = True v2.57
- This option enables WAVE_FORMAT_IEEE_FLOAT audio output. The default is to autoconvert Float audio to 16 bit.
OPT_UseWaveExtensible
- global OPT_UseWaveExtensible = True v2.58
- This option enables WAVE_FORMAT_EXTENSIBLE audio output. The default is WAVE_FORMAT_EX.
- 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.
OPT_VDubPlanarHack
- global OPT_VDubPlanarHack = True v2.60
- This option enables flipped YV24 and YV16 chroma planes. This is an hack for early versions of Virtualdub with YV24/YV16 support.
OPT_dwChannelMask
- global OPT_dwChannelMask(int v) v2.60
- This option enables you to set ChannelMask. It overrides WAVEFORMATEXTENSIBLE.dwChannelMask which is set according to this table
0x00004, // 1 -- -- Cf 0x00003, // 2 Lf Rf 0x00007, // 3 Lf Rf Cf 0x00033, // 4 Lf Rf -- -- Lr Rr 0x00037, // 5 Lf Rf Cf -- Lr Rr 0x0003F, // 5.1 Lf Rf Cf Sw Lr Rr 0x0013F, // 6.1 Lf Rf Cf Sw Lr Rr -- -- Cr 0x0063F, // 7.1 Lf Rf Cf Sw Lr Rr -- -- -- Ls Rs
OPT_AVIPadScanlines
- global OPT_AVIPadScanlines = True v2.60
- This option enables DWORD aligned planar padding. Default is packed aligned planar padding. See memory alignment used in the AVIFile output emulation.
Conversion functions
- These convert between different types.
Value
- Value(string) v2.07
- Converts a decimal string to its associated numeric value.
- Examples:
Value ("-2.7") = -2.7
HexValue
- HexValue(string) v2.07
- Converts a hexadecimal string to its associated numeric value.
- Examples:
HexValue ("FF00") = 65280
Hex
- Hex(int) v2.60
- Converts a numerical value to its hexadecimal value. See Colors for more information on specifying colors.
- Examples:
Hex (10824234) = "A52A2A"
String
- String(float / int [, string format_string]) v2.07
- 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.
- If the variable is float or integer, it first converts it to a float and then uses format_string to convert the float to a string. The syntax of format_string is as follows:
- %[flags][width][.precision]f
- flags
- - left align (instead right align)
- + always print the +/- sign
- 0 padding with leading zeros
- ' ' print a blank instead of a "+"
- # always print the decimal point
- width
- the minimum width (the string is never truncated)
- precision
- the number of digits printed
- You can also put arbitrary text around the format_string as defined above, similar to the C-language sprintf function.
- Examples:
Subtitle( "Clip height is " + String(last.height) ) Subtitle( String(x, "Value of x is %.3f after AR calc") ) Subtitle( "Value of x is " + String(x, "%.3f") + " after AR calc") ) # same as above Subtitle( String(1.23, "%f" )) # '1.23' Subtitle( String(1.23, "%5.1f") ) # ' 1.2' Subtitle( String(1.23, "%1.3f") ) # '1.230' Subtitle( String(24, "%05.0f") ) # '00024' Subtitle( "PI=" + String(PI, "%0.0f") ) # "PI=3" Subtitle( "PI=" + String(PI, "%2.0f") ) # "PI= 3" Subtitle( "PI=" + String(PI, "%3.2f") ) # "PI=3.14" Subtitle( "PI=" + String(PI, "%0.5f") ) # "PI=3.14159" Subtitle( "PI=" + String(PI, "%6.3f") ) # "PI= 3.142" Subtitle( "'" + String(32, "%0f") + "'" ) # '32.000000' Subtitle( "'" + String(32, "%0.0f") + "'" ) # '32' Subtitle( "'" + String(32, "%3.0f") + "'" ) # ' 32' Subtitle( "'" + String(32, "%8.0f") + "'" ) # ' 32'
Numeric functions
- They provide common mathematical operations on numeric variables.
Max
- Max(float, float [, ...]) v2.58
- Returns the maximum value of a set of numbers.
- 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.
- This may cause an unexpected result when an Int value greater than 16777216 is mixed with Float values.
- Examples:
Max (1, 2) = 2 Max (5, 3.0, 2) = 5.0
Min
- Min(float, float [, ...]) v2.58
- Returns the minimum value of a set of numbers.
- Examples:
Min (1, 2) = 1 Min (5, 3.0, 2) = 2.0
MulDiv
- MulDiv(int, int, int) v2.56
- 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 (m * n + d / 2) / d .
- Examples:
MulDiv (1, 1, 2) = 1 MulDiv (2, 3, 2) = 3
Floor
- Floor(float)
- Converts from single-precision, floating-point value to int (round down on any fractional amount).
- Examples:
Floor(1.2) = 1 Floor(1.6) = 1 Floor(-1.2) = -2 Floor(-1.6) = -2
Ceil
- Ceil(float)
- Converts from single-precision, floating-point value to int (round up on any fractional amount).
- Examples:
Ceil(1.2) = 2 Ceil(1.6) = 2 Ceil(-1.2) = -1 Ceil(-1.6) = -1
Round
- Round(float)
- Converts from single-precision, floating-point value to int (round off to nearest integer).
- Examples:
Round(1.2) = 1 Round(1.6) = 2 Round(-1.2) = -1 Round(-1.6) = -2
Int
- Int(float) v2.07
- Converts from single-precision, floating-point value to int (round towards zero).
- Examples:
Int(1.2) = 1 Int(1.6) = 1 Int(-1.2) = -1 Int(-1.6) = -1
Float
- Float(int) v2.07
- Converts int to single-precision, floating-point value. Integer values that require more than 24-bits to be represented will have their lower 8-bits truncated yielding unexpected values.
- Examples:
Float(4) = 4.0 Float(4) / 3 = 1.333 (while 4 / 3 = 1 , due to integer division)
Sin
- Sin(float) v2
- Returns the sine of the argument (assumes it is radians).
- Examples:
Sin(Pi()/4) = 0.707 Sin(Pi()/2) = 1.0
Cos
- Cos(float) v2
- Returns the cosine of the argument (assumes it is radians).
- Examples:
Cos(Pi()/4) = 0.707 Cos(Pi()/2) = 0.0
Tan
- Tan(float) v2.60
- Returns the tangent of the argument (assumes it is radians).
- Examples:
Tan(Pi()/4) = 1.0 Tan(Pi()/2) = not defined
- 32 bit ieee floats do not have sufficient resolution to exactly represent
- pi/2 so AviSynth returns a large positive number for the value slightly less
- than pi/2 and a large negative value for the next possible value which is
- slightly greater than pi/2.
Asin
- Asin(float) v2.60
- Returns the inverse of the sine of the argument (output is radians).
- Examples:
Asin(0.707) = 0.7852471634 (~ Pi/4) Asin(1.0) = 1.570796327 (~ Pi/2)
Acos
- Acos(float) v2.60
- Returns the inverse of the cosine of the argument (output is in radians).
- Examples:
Acos(0.707) = 0.7852471634 (~ Pi/4) Acos(0.0) = 1.570796327 (~ Pi/2)
Atan
- Atan(float) v2.60
- Returns the inverse of the tangent of the argument (output is in radians).
- Examples:
Atan(0.707) = 0.6154085176 Atan(1.0) = 0.7853981634 (~ Pi/4)
Atan2
- Atan2(float, float) v2.60
- 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 wikipedia for more information.
- y is the first argument and x is the second argument.
- Examples:
Atan2(1.0, 0) = 1.570796327 (~ Pi/2) Atan2(1.0, 1.0) = 0.7852471634 (~ Pi/4) Atan2(-1.0, -1.0) = -2.356194490 (~ -3Pi/4)
Sinh
- Sinh(float) v2.60
- Returns the hyperbolic sine of the argument. See wikipedia for more information.
- Examples:
Sinh(2.0) = 3.626860408
Cosh
- Cosh(float) v2.60
- Returns the hyperbolic cosine of the argument.
- Examples:
Cosh(2.0) = 3.762195691
Tanh
- Tanh(float) v2.60
- Returns the hyperbolic tangent of the argument.
- Examples:
Tanh(2.0) = 0.9640275801
Fmod
- Fmod(float, float) v2.60
- Returns the modulo of the argument. Output is float.
- Examples:
Fmod(3.5, 0.5) = 0 (since 3.5 - 7*0.5 = 0) Fmod(3.5, 1.0) = 0.5 (since 3.5 - 3*1.0 = 0.5)
Pi
- Pi() v2
- Returns the value of the "pi" constant (the ratio of a circle's circumference to its diameter).
- Examples:
d = Pi() # d == 3.141592653
Exp
- Exp(float) v2
- @since v2
- Returns the natural (base-e) exponent of the argument.
- Examples:
Exp(1) = 2.7182818 Exp(0) = 1.0
Log
- Log(float) v2
- Returns the natural (base-e) logarithm of the argument.
- Examples:
Log(1) = 0.0 Log(10) = 2.30259 Log(Exp(1)) = 1.0
Log10
- Log10(float) v2.60
- Returns the common logarithm of the argument.
- Examples:
Log10(1.0) = 0 Log10(10.0) = 1.0 Log10(2.0) = 0.3010299957
Pow
- Pow(float base, float power) v2
- Returns "base" raised to the power indicated by the second argument.
- Examples:
Pow(2, 3) = 8 Pow(3, 2) = 9 Pow(3.45, 1.75) = 8.7334
Sqrt
- Sqrt(float) v2
- Returns the square root of the argument.
- Examples:
Sqrt(1) = 1.0 Sqrt(2) = 1.4142
Abs
- Abs(float or int) v2.07
- Returns the absolute value of its argument (returns float for float, integer for integer).
- Examples:
Abs(-3.8) = 3.8 Abs(-4) = 4
Sign
- Sign(float) v2.07
- Returns the sign of the value passed as argument (1, 0 or -1).
- Examples:
Sign(-3.5) = -1 Sign(3.5) = 1 Sign(0) = 0
Frac
- Frac(float) v2.07
- Returns the fractional portion of the value provided.
- Examples:
Frac(3.7) = 0.7 Frac(-1.8) = -0.8
Rand
- Rand([int max] [, bool scale] [, bool seed]) v2.07
- Returns a random integer value. All parameters are optional.
- max
- sets the maximum value+1 (default 32768) and can be set negative for negative results. It operates either in scaled or modulus mode (default scale=true only if abs(max) > 32768, false otherwise).
- scale
- When true, scales the internal random number generator value to the maximum value, while modulus mode (scale=false) uses the remainder from an integer divide of the random generator value by the maximum. Modulus mode is recommended for smaller maximums.
- seed
- When true, seeds the random number generator with the current time. seed defaults to false and probably isn't necessary, although it's there just in case.
- Typically, this function would be used with the #Select function for random clips.
- Examples:
Select(Rand(5), clip1, clip2, clip3, clip4, clip5)
Spline
- Spline(float X, x1, y1, x2, y2, .... [, bool cubic]) v2.51
- Interpolates the Y value at point X using the control points x1/y1, ... There have to be at least 2 x/y-pairs. The interpolation can be cubic (the result is a spline) or linear (the result is a polygon). Default is cubic.
- Examples:
Spline(5, 0, 0, 10, 10, 20, 0, false) = 5 Spline(5, 0, 0, 10, 10, 20, 0, true) = 7
ContinuedNumerator
- ContinuedNumerator(float, int limit) v2.60
- ContinuedNumerator(int, int, int limit) v2.60
- ContinuedDenominator(float, int limit) v2.60
- ContinuedDenominator(int, int, int limit) v2.60
- The rational pair (ContinuedNumerator, ContinuedDenominator) returned has the smallest possible denominator such that the absolute error is less than 1/limit. More information can be found on wikipedia.
- If 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.
- In the Int case if limit is not specified then the normalized original values will be returned, i.e. reduced by the GCD.
- Examples:
ContinuedNumerator(PI(), limit=5000]) = 355 ContinuedDenominator(PI(), limit=5000) = 113 ContinuedNumerator(PI(), limit=50]) = 22 ContinuedDenominator(PI(), limit=50) = 7 ContinuedNumerator(355, 113, limit=50]) = 22 ContinuedDenominator(355, 113, limit=50) = 7
BitAnd
- BitAnd(int, int) v2.60
- The functions: BitAnd, BitNot, BitOr and BitXor, etc, are bitwise operators. 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.
- BitAnd returns the bitwise AND (sets bit to 1 if both bits are 1 and sets bit to 0 otherwise).
- Examples:
BitAnd(5, 6) = 4 # since 5 = 101, 6 = 110, and 101&110 = 100
BitNot
- BitNot(int) v2.60
- Returns the bit-inversion (sets bit to 1 if bit is 0 and vice-versa).
- Examples:
BitNOT(5) = -6 # since 5 = 101, and ~101 = 1111 1111 1111 1111 1111 1111 1111 1010 = -6
- Note: 1111 1111 1111 1111 1111 1111 1111 1010 = (2^32-1)-2^0-2^2 = 2^32-(1+2^0+2^2) =(signed) -(1+2^0+2^2) = -6
BitOr
- BitOr(int, int) v2.60
- Returns the bitwise inclusive OR (sets bit to 1 if one of the bits (or both) is 1 and sets bit to 0 otherwise).
- Examples:
BitOr(5, 6) = 7 # since 5 = 101, 6 = 110, and 101|110 = 111 BitOr(4, 2) = 6 # since 4 = 100, 2 = 010, and 100|010 = 110
BitXor
- BitXor(int, int) v2.60
- Returns the bitwise exclusive OR (sets bit to 1 if exactly one of the bits is 1 and sets bit to 0 otherwise).
- Examples:
BitXor(5, 6) = 3 # since 5 = 101, 6 = 110, and 101^110 = 011 BitXor(4, 2) = 6 # since 4 = 100, 2 = 010, and 100^010 = 110
Bit shift left
- BitLShift(int, int) v2.60
- BitShl(int, int) v2.60
- BitSal(int, int) v2.60
- Shift the bits of a number to the left.
- Examples:
Shifts the bits of the number 5 two bits to the left: BitLShift(5, 2) = 20 (since 101 << 2 = 10100)
Bit shift right
- BitRShiftA(int, int) v2.60
- BitRShiftS(int, int) v2.60
- BitSar(int, int) v2.60
- Shift the bits of an integer to the right. (Arithmetic, Sign bit fill, Right Shift)
- Examples:
Shifts the bits of the number -42 one bit to the right, treating it as signed: BitRShiftA(-42, 1) = -21 (since 1111 1111 1111 1111 1111 1111 1101 0110 >> 1 = 1111 1111 1111 1111 1111 1111 1110 1011)
Bit shift right, unsigned
- BitRShiftL(int, int) v2.60
- BitRShiftU(int, int) v2.60
- BitShr(int, int) v2.60
- Shift the bits of an unsigned integer to the right. (Logical, zero fill, Right Shift)
- Examples:
Shifts the bits of the number -42 one bit to the right, treating it as unsigned: BitRShiftL(-42, 1) = 2147483627 (since 1111 1111 1111 1111 1111 1111 1101 0110 >> 1 = 0111 1111 1111 1111 1111 1111 1110 1011)
- Note: -42 = -(1+2^0+2^3+2^5) = (unsigned) (2^32-1)-(2^0+2^3+2^5) = 1111 1111 1111 1111 1111 1111 1101 0110
Bit rotate left
- BitLRotate(int, int) v2.60
- BitRol(int, int) v2.60
- 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.
- Examples:
Rotates the bits of the number -2147483642 one bit to the left: BitLRotate(-2147483642, 1) = 13 (since 10000000000000000000000000000110 ROL 1 = 00000000000000000000000000001101)
Bit rotate right
- BitRRotateL(int, int) v2.60
- BitRor(int, int) v2.60
- 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.
- Examples:
Rotates the bits of the number 13 one bit to the right: BitRRotate(13, 1) = -2147483642 (since 00000000000000000000000000001101 ROR 1 = 10000000000000000000000000000110)
Bit test
- BitTest(int, int) v2.60
- BitTst(int, int) v2.60
- 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).
- Examples:
Check the state of the fourth bit: BitTest(3, 4) = False BitTest(19, 4) = True Check the state of the sign bit: BitTest(-1, 31) = True BitTest(2147483647, 31) = False
BitSet
- BitSet(int, int) v2.60
- 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).
- Examples:
Set the state of the fourth bit to one: BitSet(3, 4) = 19 BitSet(19, 4) = 19
Set the state of the sign bit to one: BitSet(-1, 31) = -1 BitSet(2147483647, 31) = -1
Bit clear
- BitClear(int, int) v2.60
- BitClr(int, int) v2.60
- 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).
- Examples:
Clear the bits of the number 5 BitClear(5, 0) = 4 (first bit is set to zero) BitClear(5, 1) = 5 (second bit is already zero) BitClear(5, 2) = 1 (third bit is set to zero) BitClear(5, 3) = 5 (fourth bit is already zero) Clear the state of the sign bit: BitClear(-1, 31) = 2147483647
Bit change
- BitChange(int, int) v2.60
- BitChg(int, int) v2.60
- 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.
- Examples:
Change the state of the a bit of the number 5: BitChange(5, 0) = 4 (first bit is set to zero) BitChange(5, 1) = 7 (second bit is set to one) BitChange(5, 2) = 1 (third bit is set to zero) BitChange(5, 3) = 13 (fourth bit is set to one) Change the state of the sign bit: BitChange(-1, 31) = 2147483647
Runtime functions
- 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.
Average luma
- AverageLuma(clip) v2.x
- AverageChromaU(clip) v2.x
- AverageChromaV(clip) v2.x
- 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 clip is in YV12 colorspace and ISSE.
- Examples:
threshold = 55 luma = AverageLuma() luma < threshold ? Levels(0, 1.0 + 0.5*(threshold - luma)/threshold, 255, 10, 255) : last
Difference
- RGBDifference(clip1, clip2) v2.x
- LumaDifference(clip1, clip2) v2.x
- ChromaUDifference(clip1, clip2) v2.x
- ChromaVDifference(clip1, clip2) v2.x
- 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 clip is in YV12 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) ...
Difference from previous
- RGBDifferenceFromPrevious(clip) v2.x
- YDifferenceFromPrevious(clip) v2.x
- UDifferenceFromPrevious(clip) v2.x
- VDifferenceFromPrevious(clip) v2.x
- This group of functions return the absolute difference of pixel value between the current and previous frame of clip. 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(...)
Difference to next
- RGBDifferenceToNext(clip) v2.x
- YDifferenceToNext(clip) v2.x
- UDifferenceToNext(clip) v2.x
- VDifferenceToNext(clip) v2.x
- This group of functions return the absolute difference of pixel value between the current and next frame of clip. 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(...)
Color plane median, min, max, range
- YPlaneMedian(clip) v2.x
- UPlaneMedian(clip) v2.x
- VPlaneMedian(clip) v2.x
- YPlaneMin(clip, float threshold) v2.x
- UPlaneMin(clip, float threshold) v2.x
- VPlaneMin(clip, float threshold) v2.x
- YPlaneMax(clip, float threshold) v2.x
- UPlaneMax(clip, float threshold) v2.x
- VPlaneMax(clip, float threshold) v2.x
- YPlaneMinMaxDifference(clip, float threshold) v2.x
- UPlaneMinMaxDifference(clip, float threshold) v2.x
- VPlaneMinMaxDifference(clip, float threshold) v2.x
- 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).
- 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.
- 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)
Script functions
- They provide AviSynth script information.
String functions
- They provide common operations on string variables.
Version functions
- They provide AviSynth version information.
Back to AviSynth Syntax.