helpers ¶
Type Aliases:
-
ExprVarLike
–Type alias representing any expression-compatible variable or literal.
Classes:
-
ClipVar
–Expression variable that wraps a VideoNode and provides symbolic and numeric access.
-
ComputedVar
–Represents a fully built RPN expression as a sequence of operations with per-plane operations support.
-
ExprVar
–Base interface for variables used in RPN expression
-
LiteralVar
–Literal value wrapper for use in RPN expressions.
-
Operators
–A singleton class that defines the expression operators used in inline_expr.
-
Tokens
–A singleton class that defines the expression tokens used in inline_expr.
ExprVarLike ¶
Type alias representing any expression-compatible variable or literal.
ClipVar ¶
Bases: ExprVar
, VSObjectABC
Expression variable that wraps a VideoNode and provides symbolic and numeric access.
Initializes a new ClipVar instance.
Parameters:
-
char
¶str
) –A short symbolic name representing this clip in the RPN expression.
-
node
¶VideoNode
) –The actual VapourSynth VideoNode.
Methods:
-
as_var
–Converts the expression variable to a ComputedVar.
-
to_str
–Returns the string representation of the expression variable.
Attributes:
-
MaskMax
(Final[ComputedVar]
) –Maximum value in mask clips.
-
Neutral
(Final[ComputedVar]
) –Neutral value (e.g. 128 for 8-bit limited, 0 for float).
-
PlaneMax
(Final[ComputedVar]
) –Maximum value in the clip's range (chroma-aware).
-
PlaneMin
(Final[ComputedVar]
) –Minimum value in the clip's range (chroma-aware).
-
RangeMax
(Final[ComputedVar]
) –Maximum value in full range (chroma-aware).
-
RangeMin
(Final[ComputedVar]
) –Minimum value in full range (chroma-aware).
-
RangeSize
(Final[ComputedVar]
) –Size of the full range (e.g. 256 for 8-bit, 65536 for 16-bit).
-
char
(str
) –A short symbolic name representing this clip in the RPN expression.
-
node
(VideoNode
) –The actual VapourSynth VideoNode.
-
props
(ClipVarProps
) –A helper to access frame properties.
Source code in vsexprtools/inline/helpers.py
729 730 731 732 733 734 735 736 737 738 |
|
MaskMax class-attribute
instance-attribute
¶
MaskMax: Final[ComputedVar] = cast(ComputedVar, ...)
Maximum value in mask clips.
Neutral class-attribute
instance-attribute
¶
Neutral: Final[ComputedVar] = cast(ComputedVar, ...)
Neutral value (e.g. 128 for 8-bit limited, 0 for float).
PlaneMax class-attribute
instance-attribute
¶
PlaneMax: Final[ComputedVar] = cast(ComputedVar, ...)
Maximum value in the clip's range (chroma-aware).
PlaneMin class-attribute
instance-attribute
¶
PlaneMin: Final[ComputedVar] = cast(ComputedVar, ...)
Minimum value in the clip's range (chroma-aware).
RangeMax class-attribute
instance-attribute
¶
RangeMax: Final[ComputedVar] = cast(ComputedVar, ...)
Maximum value in full range (chroma-aware).
RangeMin class-attribute
instance-attribute
¶
RangeMin: Final[ComputedVar] = cast(ComputedVar, ...)
Minimum value in full range (chroma-aware).
RangeSize class-attribute
instance-attribute
¶
RangeSize: Final[ComputedVar] = cast(ComputedVar, ...)
Size of the full range (e.g. 256 for 8-bit, 65536 for 16-bit).
as_var ¶
as_var() -> ComputedVar
Converts the expression variable to a ComputedVar.
Returns:
-
ComputedVar
–A ComputedVar.
Source code in vsexprtools/inline/helpers.py
466 467 468 469 470 471 472 473 474 475 |
|
to_str ¶
Returns the string representation of the expression variable.
Parameters:
Returns:
-
str
–The string representation of the expression variable.
Source code in vsexprtools/inline/helpers.py
442 443 444 445 446 447 448 449 450 451 452 |
|
ClipVarProps ¶
ClipVarProps(var: ClipVar)
Helper class exposing common frame properties of a ClipVar.
Attributes:
Source code in vsexprtools/inline/helpers.py
690 691 |
|
ComputedVar ¶
ComputedVar(operations: ExprVarLike | Iterable[ExprVarLike])
Bases: ExprVar
Represents a fully built RPN expression as a sequence of operations with per-plane operations support.
Initializes a new ComputedVar.
Parameters:
-
operations
¶ExprVarLike | Iterable[ExprVarLike]
) –An iterable of operators and/or expression variables that define the computation.
Methods:
-
as_var
–Converts the expression variable to a ComputedVar.
-
to_str
–Returns a string representation of the expression in RPN format for the selected plane.
-
to_str_per_plane
–Returns string representations of the expression in RPN format for each plane.
Attributes:
-
b
(Self
) –Returns the B (blue) plane expression.
-
g
(Self
) –Returns the G (green) plane expression.
-
r
(Self
) –Returns the R (red) plane expression.
-
u
(Self
) –Returns the U (chroma) plane expression.
-
uv
(tuple[Self, Self]
) –Returns the U and V (chroma) planes expression.
-
v
(Self
) –Returns the V (chroma) plane expression.
-
y
(Self
) –Returns the Y (luma) plane expression.
Source code in vsexprtools/inline/helpers.py
503 504 505 506 507 508 509 510 511 512 |
|
uv deletable
property
writable
¶
Returns the U and V (chroma) planes expression.
as_var ¶
as_var() -> ComputedVar
Converts the expression variable to a ComputedVar.
Returns:
-
ComputedVar
–A ComputedVar.
Source code in vsexprtools/inline/helpers.py
466 467 468 469 470 471 472 473 474 475 |
|
to_str ¶
Returns a string representation of the expression in RPN format for the selected plane.
Parameters:
-
plane
¶int
, default:0
) –Optional plane index to select which expression to stringify.
-
**kwargs
¶Any
, default:{}
) –Additional keyword arguments passed to each expression's to_str method.
Returns:
-
str
–String representation of the expression in RPN format for the selected plane.
Source code in vsexprtools/inline/helpers.py
667 668 669 670 671 672 673 674 675 676 677 678 679 |
|
to_str_per_plane ¶
to_str_per_plane(num_planes: int = 3) -> list[str]
Returns string representations of the expression in RPN format for each plane.
Parameters:
Returns:
Source code in vsexprtools/inline/helpers.py
655 656 657 658 659 660 661 662 663 664 665 |
|
ExprVar ¶
Bases: ABC
Base interface for variables used in RPN expression
Methods:
-
as_var
–Converts the expression variable to a ComputedVar.
-
to_str
–Returns the string representation of the expression variable.
as_var ¶
as_var() -> ComputedVar
Converts the expression variable to a ComputedVar.
Returns:
-
ComputedVar
–A ComputedVar.
Source code in vsexprtools/inline/helpers.py
466 467 468 469 470 471 472 473 474 475 |
|
to_str ¶
Returns the string representation of the expression variable.
Parameters:
Returns:
-
str
–The string representation of the expression variable.
Source code in vsexprtools/inline/helpers.py
442 443 444 445 446 447 448 449 450 451 452 |
|
LiteralVar ¶
LiteralVar(value: ExprVarLike)
Bases: ExprVar
Literal value wrapper for use in RPN expressions.
Initializes a new LiteralVar.
Parameters:
-
value
¶ExprVarLike
) –An integer, float, string, or ExprVar to wrap.
Methods:
-
as_var
–Converts the expression variable to a ComputedVar.
-
to_str
–Returns the string representation of the expression variable.
Attributes:
-
value
–
Source code in vsexprtools/inline/helpers.py
485 486 487 488 489 490 491 492 |
|
as_var ¶
as_var() -> ComputedVar
Converts the expression variable to a ComputedVar.
Returns:
-
ComputedVar
–A ComputedVar.
Source code in vsexprtools/inline/helpers.py
466 467 468 469 470 471 472 473 474 475 |
|
to_str ¶
Returns the string representation of the expression variable.
Parameters:
Returns:
-
str
–The string representation of the expression variable.
Source code in vsexprtools/inline/helpers.py
442 443 444 445 446 447 448 449 450 451 452 |
|
Operators ¶
A singleton class that defines the expression operators used in inline_expr.
Methods:
-
__call__
–Returns itself.
-
abs
–Absolute value of x.
-
abs_pix
–Absolute pixel access.
-
acos
–Arccosine (inverse cosine) of x.
-
add
–Performs addition of two elements (x + y).
-
and_
–Performs a logical AND.
-
asin
–Arcsine (inverse sine) of x.
-
atan
–Arctangent of x
-
bitand
–Performs a bitwise AND.
-
bitnot
–Performs a bitwise NOT.
-
bitor
–Performs a bitwise OR.
-
bitxor
–Performs a bitwise XOR.
-
ceil
–Round up x to nearest integer.
-
clamp
–Clamps a value between a min and a max.
-
convolution
–Convenience method wrapping ExprOp.convolution.
-
cos
–Cosine (radians) of x.
-
div
–Performs division of two elements (x / y).
-
eq
–Performs x == y.
-
exp
–Exponential function (e^x).
-
floor
–Round down x to nearest integer.
-
gt
–Performs x > y.
-
gte
–Performs x >= y.
-
lerp
–Performs a linear interpolation of t between x and y.
-
log
–Natural logarithm of x.
-
lt
–Performs x < y.
-
lte
–Performs x <= y.
-
matrix
–Convenience method wrapping ExprOp.matrix.
-
max
–Calculates the maximum of x and y.
-
min
–Calculates the minimum of x and y.
-
mod
–Performs x % y.
-
mul
–Performs multiplication of two elements (x * y).
-
neg
–Negation (multiply by -1) of x.
-
not_
–Logical NOT of x.
-
or_
–Performs a logical OR.
-
polyval
–Evaluates a polynomial at x using Horner's method.
-
pow
–Performs x to the power of y (x ** y).
-
rel_pix
–Relative pixel access.
-
round
–Round x to nearest integer.
-
sgn
–Sign function (-1, 0, or 1) of x.
-
sin
–Sine (radians) of x.
-
sqrt
–Square root of x.
-
sub
–Performs subtraction of two elements (x - y).
-
tan
–Tangent (radians) of x.
-
tern
–Ternary operator (if cond then if_true else if_false).
-
trunc
–Truncate x to integer (toward zero).
-
xor
–Performs a logical XOR.
Attributes:
__call__ ¶
__call__() -> Self
Returns itself.
Returns:
-
Self
–Returns itself.
Source code in vsexprtools/inline/helpers.py
215 216 217 218 219 220 221 222 |
|
abs ¶
abs(x: ExprVarLike) -> ComputedVar
Absolute value of x.
Source code in vsexprtools/inline/helpers.py
72 73 74 |
|
abs_pix ¶
abs_pix(char: SupportsString, x: int, y: int) -> ComputedVar
Absolute pixel access.
Source code in vsexprtools/inline/helpers.py
211 212 213 |
|
acos ¶
acos(x: ExprVarLike) -> ComputedVar
Arccosine (inverse cosine) of x.
Source code in vsexprtools/inline/helpers.py
60 61 62 |
|
add ¶
add(x: ExprVarLike, y: ExprVarLike) -> ComputedVar
Performs addition of two elements (x + y).
Source code in vsexprtools/inline/helpers.py
117 118 119 |
|
and_ ¶
and_(x: ExprVarLike, y: ExprVarLike) -> ComputedVar
Performs a logical AND.
Source code in vsexprtools/inline/helpers.py
157 158 159 |
|
asin ¶
asin(x: ExprVarLike) -> ComputedVar
Arcsine (inverse sine) of x.
Source code in vsexprtools/inline/helpers.py
52 53 54 |
|
atan ¶
atan(x: ExprVarLike) -> ComputedVar
Arctangent of x
Source code in vsexprtools/inline/helpers.py
68 69 70 |
|
bitand ¶
bitand(x: ExprVarLike, y: ExprVarLike) -> ComputedVar
Performs a bitwise AND.
Source code in vsexprtools/inline/helpers.py
173 174 175 |
|
bitnot ¶
bitnot(x: ExprVarLike) -> ComputedVar
Performs a bitwise NOT.
Source code in vsexprtools/inline/helpers.py
96 97 98 |
|
bitor ¶
bitor(x: ExprVarLike, y: ExprVarLike) -> ComputedVar
Performs a bitwise OR.
Source code in vsexprtools/inline/helpers.py
177 178 179 |
|
bitxor ¶
bitxor(x: ExprVarLike, y: ExprVarLike) -> ComputedVar
Performs a bitwise XOR.
Source code in vsexprtools/inline/helpers.py
181 182 183 |
|
ceil ¶
ceil(x: ExprVarLike) -> ComputedVar
Round up x to nearest integer.
Source code in vsexprtools/inline/helpers.py
92 93 94 |
|
clamp ¶
clamp(x: ExprVarLike, min: ExprVarLike, max: ExprVarLike) -> ComputedVar
Clamps a value between a min and a max.
Source code in vsexprtools/inline/helpers.py
193 194 195 |
|
convolution ¶
convolution(
var: SupportsString | Collection[SupportsString],
matrix: Iterable[ExprVarLike] | Iterable[Iterable[ExprVarLike]],
bias: ExprVarLike | None = None,
divisor: ExprVarLike | bool = True,
saturate: bool = True,
mode: OnePassConvMode = SQUARE,
premultiply: ExprVarLike | None = None,
multiply: ExprVarLike | None = None,
clamp: bool = False,
) -> ComputedVar
Convenience method wrapping ExprOp.convolution.
Parameters:
-
var
¶SupportsString | Collection[SupportsString]
) –The variable used as the central value or elements proportional to the radius if mode is
Literal[ConvMode.TEMPORAL]
. -
matrix
¶Iterable[ExprVarLike] | Iterable[Iterable[ExprVarLike]]
) –A flat or 2D iterable representing the convolution weights.
-
bias
¶ExprVarLike | None
, default:None
) –A constant value to add to the result after convolution (default: None).
-
divisor
¶ExprVarLike | bool
, default:True
) –If True, normalizes by the sum of weights; if False, skips division; Otherwise, divides by this value.
-
saturate
¶bool
, default:True
) –If False, applies
abs()
to avoid negatives. -
mode
¶OnePassConvMode
, default:SQUARE
) –The convolution shape.
-
premultiply
¶ExprVarLike | None
, default:None
) –Optional scalar to multiply the result before normalization.
-
multiply
¶ExprVarLike | None
, default:None
) –Optional scalar to multiply the result at the end.
-
clamp
¶bool
, default:False
) –If True, clamps the final result to [RangeMin, RangeMax].
Returns:
-
ComputedVar
–A
ComputedVar
representing the expression-based convolution.
Source code in vsexprtools/inline/helpers.py
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
|
cos ¶
cos(x: ExprVarLike) -> ComputedVar
Cosine (radians) of x.
Source code in vsexprtools/inline/helpers.py
56 57 58 |
|
div ¶
div(x: ExprVarLike, y: ExprVarLike) -> ComputedVar
Performs division of two elements (x / y).
Source code in vsexprtools/inline/helpers.py
129 130 131 |
|
eq ¶
eq(x: ExprVarLike, y: ExprVarLike) -> ComputedVar
Performs x == y.
Source code in vsexprtools/inline/helpers.py
145 146 147 |
|
exp ¶
exp(x: ExprVarLike) -> ComputedVar
Exponential function (e^x).
Source code in vsexprtools/inline/helpers.py
36 37 38 |
|
floor ¶
floor(x: ExprVarLike) -> ComputedVar
Round down x to nearest integer.
Source code in vsexprtools/inline/helpers.py
88 89 90 |
|
gt ¶
gt(x: ExprVarLike, y: ExprVarLike) -> ComputedVar
Performs x > y.
Source code in vsexprtools/inline/helpers.py
137 138 139 |
|
gte ¶
gte(x: ExprVarLike, y: ExprVarLike) -> ComputedVar
Performs x >= y.
Source code in vsexprtools/inline/helpers.py
149 150 151 |
|
lerp ¶
lerp(x: ExprVarLike, y: ExprVarLike, t: ExprVarLike) -> ComputedVar
Performs a linear interpolation of t between x and y.
Source code in vsexprtools/inline/helpers.py
197 198 199 |
|
log ¶
log(x: ExprVarLike) -> ComputedVar
Natural logarithm of x.
Source code in vsexprtools/inline/helpers.py
40 41 42 |
|
lt ¶
lt(x: ExprVarLike, y: ExprVarLike) -> ComputedVar
Performs x < y.
Source code in vsexprtools/inline/helpers.py
141 142 143 |
|
lte ¶
lte(x: ExprVarLike, y: ExprVarLike) -> ComputedVar
Performs x <= y.
Source code in vsexprtools/inline/helpers.py
153 154 155 |
|
matrix ¶
matrix(
char: SupportsString | Collection[SupportsString],
radius: int,
mode: Literal[SQUARE, HORIZONTAL, VERTICAL, TEMPORAL],
exclude: Iterable[tuple[int, int]] | None = None,
include: Iterable[tuple[int, int]] | None = None,
) -> list[LiteralVar]
Convenience method wrapping ExprOp.matrix.
Parameters:
-
char
¶SupportsString | Collection[SupportsString]
) –The variable representing the central pixel(s).
-
radius
¶int
) –The radius of the kernel in pixels (e.g., 1 for 3x3).
-
mode
¶Literal[SQUARE, HORIZONTAL, VERTICAL, TEMPORAL]
) –The convolution mode.
HV
is not supported. -
exclude
¶Iterable[tuple[int, int]] | None
, default:None
) –Optional set of (x, y) coordinates to exclude from the matrix.
-
include
¶Iterable[tuple[int, int]] | None
, default:None
) –Optional set of (x, y) coordinates to include in the matrix.
Returns:
-
list[LiteralVar]
–A list of LiteralVar instances
-
list[LiteralVar]
–representing the matrix of expressions.
Source code in vsexprtools/inline/helpers.py
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
|
max ¶
max(x: ExprVarLike, y: ExprVarLike) -> ComputedVar
Calculates the maximum of x and y.
Source code in vsexprtools/inline/helpers.py
109 110 111 |
|
min ¶
min(x: ExprVarLike, y: ExprVarLike) -> ComputedVar
Calculates the minimum of x and y.
Source code in vsexprtools/inline/helpers.py
113 114 115 |
|
mod ¶
mod(x: ExprVarLike, y: ExprVarLike) -> ComputedVar
Performs x % y.
Source code in vsexprtools/inline/helpers.py
169 170 171 |
|
mul ¶
mul(x: ExprVarLike, y: ExprVarLike) -> ComputedVar
Performs multiplication of two elements (x * y).
Source code in vsexprtools/inline/helpers.py
125 126 127 |
|
neg ¶
neg(x: ExprVarLike) -> ComputedVar
Negation (multiply by -1) of x.
Source code in vsexprtools/inline/helpers.py
104 105 106 |
|
not_ ¶
not_(x: ExprVarLike) -> ComputedVar
Logical NOT of x.
Source code in vsexprtools/inline/helpers.py
76 77 78 |
|
or_ ¶
or_(x: ExprVarLike, y: ExprVarLike) -> ComputedVar
Performs a logical OR.
Source code in vsexprtools/inline/helpers.py
161 162 163 |
|
polyval ¶
polyval(x: ExprVarLike, *coeffs: ExprVarLike) -> ComputedVar
Evaluates a polynomial at x using Horner's method.
Source code in vsexprtools/inline/helpers.py
202 203 204 |
|
pow ¶
pow(x: ExprVarLike, y: ExprVarLike) -> ComputedVar
Performs x to the power of y (x ** y).
Source code in vsexprtools/inline/helpers.py
133 134 135 |
|
rel_pix ¶
rel_pix(char: SupportsString, x: int, y: int) -> ComputedVar
Relative pixel access.
Source code in vsexprtools/inline/helpers.py
207 208 209 |
|
round ¶
round(x: ExprVarLike) -> ComputedVar
Round x to nearest integer.
Source code in vsexprtools/inline/helpers.py
84 85 86 |
|
sgn ¶
sgn(x: ExprVarLike) -> ComputedVar
Sign function (-1, 0, or 1) of x.
Source code in vsexprtools/inline/helpers.py
100 101 102 |
|
sin ¶
sin(x: ExprVarLike) -> ComputedVar
Sine (radians) of x.
Source code in vsexprtools/inline/helpers.py
48 49 50 |
|
sqrt ¶
sqrt(x: ExprVarLike) -> ComputedVar
Square root of x.
Source code in vsexprtools/inline/helpers.py
44 45 46 |
|
sub ¶
sub(x: ExprVarLike, y: ExprVarLike) -> ComputedVar
Performs subtraction of two elements (x - y).
Source code in vsexprtools/inline/helpers.py
121 122 123 |
|
tan ¶
tan(x: ExprVarLike) -> ComputedVar
Tangent (radians) of x.
Source code in vsexprtools/inline/helpers.py
64 65 66 |
|
tern ¶
tern(
cond: ExprVarLike, if_true: ExprVarLike, if_false: ExprVarLike
) -> ComputedVar
Ternary operator (if cond then if_true else if_false).
Source code in vsexprtools/inline/helpers.py
186 187 188 |
|
trunc ¶
trunc(x: ExprVarLike) -> ComputedVar
Truncate x to integer (toward zero).
Source code in vsexprtools/inline/helpers.py
80 81 82 |
|
xor ¶
xor(x: ExprVarLike, y: ExprVarLike) -> ComputedVar
Performs a logical XOR.
Source code in vsexprtools/inline/helpers.py
165 166 167 |
|
Token ¶
Token(expr_token: ExprToken)
Bases: LiteralVar
An expression token wrapping ExprToken.
Initializes a new Token instance.
Parameters:
Methods:
-
__call__
–Returns a version of the token specific to a clip variable.
-
as_var
–Converts the expression variable to a ComputedVar.
-
to_str
–Returns the string representation of the expression variable.
Attributes:
-
value
–
Source code in vsexprtools/inline/helpers.py
785 786 787 788 789 790 791 792 |
|
__call__ ¶
__call__(var: ClipVar) -> ComputedVar
Returns a version of the token specific to a clip variable.
Parameters:
Returns:
-
ComputedVar
–A ComputedVar with a var suffix for use in inline expressions.
Source code in vsexprtools/inline/helpers.py
794 795 796 797 798 799 800 801 802 803 804 |
|
as_var ¶
as_var() -> ComputedVar
Converts the expression variable to a ComputedVar.
Returns:
-
ComputedVar
–A ComputedVar.
Source code in vsexprtools/inline/helpers.py
466 467 468 469 470 471 472 473 474 475 |
|
to_str ¶
Returns the string representation of the expression variable.
Parameters:
Returns:
-
str
–The string representation of the expression variable.
Source code in vsexprtools/inline/helpers.py
442 443 444 445 446 447 448 449 450 451 452 |
|
Tokens ¶
A singleton class that defines the expression tokens used in inline_expr.
Attributes:
-
MaskMax
(Final[Token]
) –Maximum value in mask clips.
-
Neutral
(Final[Token]
) –Neutral value (e.g. 128 for 8-bit limited, 0 for float).
-
PlaneMax
(Final[Token]
) –Maximum value in the clip's range (chroma-aware).
-
PlaneMin
(Final[Token]
) –Minimum value in the clip's range (chroma-aware).
-
RangeMax
(Final[Token]
) –Maximum value in full range (chroma-aware).
-
RangeMin
(Final[Token]
) –Minimum value in full range (chroma-aware).
-
RangeSize
(Final[Token]
) –Size of the full range (e.g. 256 for 8-bit, 65536 for 16-bit).
MaskMax class-attribute
instance-attribute
¶
Maximum value in mask clips.
Neutral class-attribute
instance-attribute
¶
Neutral value (e.g. 128 for 8-bit limited, 0 for float).
PlaneMax class-attribute
instance-attribute
¶
Maximum value in the clip's range (chroma-aware).
PlaneMin class-attribute
instance-attribute
¶
Minimum value in the clip's range (chroma-aware).
RangeMax class-attribute
instance-attribute
¶
Maximum value in full range (chroma-aware).
RangeMin class-attribute
instance-attribute
¶
Minimum value in full range (chroma-aware).