Skip to main content

VapourSynth expr plugin built on top of Cranelift.

Project description

cranexpr

cranexpr is like std.Expr but built on top of Cranelift. It's a VapourSynth plugin that allows one to evaluate an expression per pixel.

Examples

Median of 3 clips:

core.cranexpr.Expr([x, y, z], "x y min x y max z min max")

Flip a clip horizontally:

core.cranexpr.Expr([x], "width X - 1 - Y x[]")

3x3 box blur:

core.cranexpr.Expr([x], "x[-1,-1] x[0,-1] x[1,-1] x[-1,0] x x[1,0] x[-1,1] x[0,1] x[1,1] + + + + + + + + 9 /")

Features

  • Arithmetic: +, -, *, /, %, pow, exp, log, sqrt.
  • Trigonometry: sin, cos, tan, atan2.
  • Comparison: >, <, =.
  • Bitwise: bitand, bitor, bitxor, bitnot.
  • Clamping: min, max, clip (alias: clamp).
  • Rounding: floor, round.
  • Ternary (if/else): ?.
  • sgn: Returns the sign of a value (-1 if negative, 1 if positive, 0 if zero).
  • Constants:
    • width: Width of the plane.
    • height: Height of the plane.
    • N: Current frame number.
    • pi: π.
  • Stack manipulation:
    • dropN, drop: drops the top N values from the stack. drop is equivalent to drop1.
    • dupN, dup: allows a value N steps up in the stack to be duplicated. The top value of the stack has index 0 meaning that dup is equivalent to dup0.
    • swapN, swap: allows a value N steps up in the stack to be swapped. The top value of the stack has index 0 meaning that swap is equivalent to swap1. This is because swapN always swaps with the topmost value at index 0.
  • Variables:
    • var!: Pops the top value from the stack and stores it in a variable named var.
    • var@: Pushes the value of the variable var onto the stack.
  • Frame property access: clip.PropertyName.
    • Accesses a numeric frame property from the given clip.
    • If the property is missing, its value will be NaN.
    • If the property is not a numeric frame property, its value will be the first byte.
  • Relative pixel access: clip[relX, relY]:[mode].
    • Accesses a pixel relative to the current coordinate (X, Y). relX and relY must be integer constants.
    • If no suffix is provided, the edge behavior is determined by the filter's boundary parameter.
      • :c: Forces clamped boundary.
      • :m: Forces mirrored boundary.
  • Absolute pixel access: absX absY clip[]:[mode].
    • Accesses a pixel at an absolute coordinate. It pops absY then absX from the stack. These coordinates can be computed by expressions.
    • If the coordinates are not integers, they will be rounded half to even.
    • Example: X 2 / Y x[] reads the pixel at half the current X coordinate from the first clip, using the default clamp mode.
    • Boundary Suffixes:
      • :c: Forces clamped boundary.
      • :m: Forces mirrored boundary.
  • Supports any number of input clips. srcN may be used to access the N-th input clip. Shorthand aliases x, y, z, a, b, c, etc. map to src0, src1, src2, src3, src4, src5, etc., up to w being src25. Beyond that, use srcN.

API

cranexpr.Expr(
  clips: Sequence[vs.VideoNode],
  expr: str | list[str],
  format: int | None = None,
  boundary: Literal[0, 1] = 0,
) -> vs.VideoNode
  • clips — Input video nodes.
  • expr — Reverse Polish Notation (RPN) expression(s) for each plane. The expression given for the previous plane is used if the list contains fewer expressions than the input clip has planes. This means that a single expression will be applied to all planes by default.
  • format — By default the output format is the same as the first input clip's format. This can be overridden by setting this parameter.
  • boundary — Boundary mode. 0 for clamping, 1 for mirroring.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vapoursynth_cranexpr-0.3.0.tar.gz (47.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

vapoursynth_cranexpr-0.3.0-py3-none-win_amd64.whl (4.5 MB view details)

Uploaded Python 3Windows x86-64

vapoursynth_cranexpr-0.3.0-py3-none-win32.whl (4.5 MB view details)

Uploaded Python 3Windows x86

vapoursynth_cranexpr-0.3.0-py3-none-manylinux_2_28_x86_64.whl (4.9 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

vapoursynth_cranexpr-0.3.0-py3-none-manylinux_2_28_aarch64.whl (1.1 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

vapoursynth_cranexpr-0.3.0-py3-none-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

Details for the file vapoursynth_cranexpr-0.3.0.tar.gz.

File metadata

  • Download URL: vapoursynth_cranexpr-0.3.0.tar.gz
  • Upload date:
  • Size: 47.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for vapoursynth_cranexpr-0.3.0.tar.gz
Algorithm Hash digest
SHA256 21ddf44fae5044add27265d69a2fae93af85c17db71c4603186b7f6d6652b281
MD5 86bdb1772514534c06adc8cf92be7a41
BLAKE2b-256 7b4074b5b9a59c06a57630e3bf424b071e0b5307298cc7e9f98aa70a85f635c7

See more details on using hashes here.

Provenance

The following attestation bundles were made for vapoursynth_cranexpr-0.3.0.tar.gz:

Publisher: publish.yml on sgt0/cranexpr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vapoursynth_cranexpr-0.3.0-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for vapoursynth_cranexpr-0.3.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 8a46fc20050db7ab3dce6eae3cf719c5def6fc3d9d7374419fc94fcdf7cfc441
MD5 da4823667f92eb840987710d88b96af5
BLAKE2b-256 de824e56d87235109ed63812e2afccd241aacf6d1c8e49c227b677e6993639ad

See more details on using hashes here.

Provenance

The following attestation bundles were made for vapoursynth_cranexpr-0.3.0-py3-none-win_amd64.whl:

Publisher: publish.yml on sgt0/cranexpr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vapoursynth_cranexpr-0.3.0-py3-none-win32.whl.

File metadata

File hashes

Hashes for vapoursynth_cranexpr-0.3.0-py3-none-win32.whl
Algorithm Hash digest
SHA256 ea82769c87728aa1f6d5123772e58d31928221bc6601521581a74d54cff4cc20
MD5 c765b59a6da2253dc0ffd83771a18a07
BLAKE2b-256 0ad71f35a4255254dd49f401a0d39ff5c6c7f0f9dab7d46d83a4150aaae9ce16

See more details on using hashes here.

Provenance

The following attestation bundles were made for vapoursynth_cranexpr-0.3.0-py3-none-win32.whl:

Publisher: publish.yml on sgt0/cranexpr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vapoursynth_cranexpr-0.3.0-py3-none-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for vapoursynth_cranexpr-0.3.0-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a1a64f8bea31681d9716fc848e942b2c022e3ebc3066d3e9d5205b02362a0c63
MD5 d8c3782747a47aafe778d8c66607337a
BLAKE2b-256 5f50468d2e0769202608aa9ef4f45c5f5533cd377471b85a8820bcf363d3fd36

See more details on using hashes here.

Provenance

The following attestation bundles were made for vapoursynth_cranexpr-0.3.0-py3-none-manylinux_2_28_x86_64.whl:

Publisher: publish.yml on sgt0/cranexpr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vapoursynth_cranexpr-0.3.0-py3-none-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for vapoursynth_cranexpr-0.3.0-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 67e70bb8ff4d470d74aad9c4bc6dd66f1b5fc61c0dd5898878ff3f30bedc9f38
MD5 728fc418aae451549937762c1e1f0f34
BLAKE2b-256 4a071db6d78efa4269d800a8a1e774587b3a77b38944600c0386fa1678d5a204

See more details on using hashes here.

Provenance

The following attestation bundles were made for vapoursynth_cranexpr-0.3.0-py3-none-manylinux_2_28_aarch64.whl:

Publisher: publish.yml on sgt0/cranexpr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vapoursynth_cranexpr-0.3.0-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for vapoursynth_cranexpr-0.3.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c5914a21d0fbf22fcb1fbcc0edacebb137f587ecd981c8e79e621104f4dad741
MD5 0b04b2f869608b9e320653d6f8594b60
BLAKE2b-256 8e94d241c6e52debc6f66c7c65c494481ecf942118956f67e3433ee5bc6472ea

See more details on using hashes here.

Provenance

The following attestation bundles were made for vapoursynth_cranexpr-0.3.0-py3-none-macosx_11_0_arm64.whl:

Publisher: publish.yml on sgt0/cranexpr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page