Skip to main content

Module filter

Module filter 

Source
Expand description

Video filters — per-frame transforms applied to decoded frames before per-rung scaling and encoding.

§Layout

The canonical representation is a list of VideoFilter values. This mod.rs owns the cross-cutting pieces — the enum, the textual / structured parsers, the apply dispatch, the FilterChain, and the shared plane helpers — while each filter’s implementation lives in its own file: [crop], [pad], [hflip], [vflip], [rotate], [grayscale], [overlay], [invert], [brightness], [contrast], [saturation], and the [denoise] family (one file per algorithm under denoise/).

Two kinds of filter:

  • Stateless (apply runs them directly): crop, pad, hflip, vflip, rotate, grayscale (geometry, any bit depth); invert, brightness, contrast, saturation (colour, 8-bit); and denoise (selectable algorithm, 8-bit).
  • Resource filters need one-time setup — overlay loads its PNG and converts it to YUV + alpha. Build a FilterChain with FilterChain::prepare (loads overlays once) and call FilterChain::apply per frame.

Two interchangeable serializations (they round-trip: parse_chain(&chain_to_string(c)) == c):

  • Structured objects (serde feature) — a YAML/JSON DSL writes a chain as a list of objects: [{crop: {w,h}}, hflip, {overlay: {image: "logo.png"}}].
  • Textual ffmpeg--vf style — parse_chain / [Display]: crop=1280:720,hflip,overlay=logo.png:24:24.

Structs§

FilterChain
A filter chain with its resources prepared (overlay PNGs loaded + converted). Build once with prepare, then apply per frame.

Enums§

DenoiseMethod
Which spatial denoise algorithm super::VideoFilter::Denoise runs. Each suits a different kind of noise; strength then blends the result with the source. (Temporal denoisers — hqdn3d / NLM-temporal — need frame history and don’t fit this stateless per-frame filter; a future extension.)
VideoFilter
One video-filter step. The canonical, code-interpreted representation.

Functions§

apply
Apply one stateless filter, dispatching to its module. (Overlay errors here — use FilterChain.)
apply_chain
Apply a whole stateless chain to a frame, in order. Returns an error if the chain contains an overlay (use FilterChain for that).
chain_to_string
A whole chain as a comma-separated textual string (the inverse of parse_chain).
parse_chain
Parse an ffmpeg--vf-style chain, e.g. "crop=1280:720,hflip".