pub trait FilterFunction: Send + Sync {
    fn name(&self) -> &str;
    fn args(&self) -> &str;
    fn create<'core>(
        &self,
        api: API,
        core: CoreRef<'core>,
        args: &Map<'core>
    ) -> Result<Option<Box<dyn Filter<'core> + 'core>>, Error>; }
Expand description

A filter function interface.

See the make_filter_function! macro that generates types implementing this automatically.

Required Methods

Returns the name of the function.

The characters allowed are letters, numbers, and the underscore. The first character must be a letter. In other words: ^[a-zA-Z][a-zA-Z0-9_]*$.

For example, Invert.

Returns the argument string.

Arguments are separated by a semicolon. Each argument is made of several fields separated by a colon. Don’t insert additional whitespace characters, or VapourSynth will die.

Fields:

  • The argument name. The same characters are allowed as for the filter’s name. Argument names should be all lowercase and use only letters and the underscore.

  • The type. One of int, float, data, clip, frame, func. They correspond to the Map::get_*() functions (clip is get_node()). It’s possible to declare an array by appending [] to the type.

  • opt if the parameter is optional.

  • empty if the array is allowed to be empty.

The following example declares the arguments “blah”, “moo”, and “asdf”: blah:clip;moo:int[]:opt;asdf:float:opt;

The callback for this filter function.

In most cases this is where you should create a new instance of the filter and return it. However, a filter function like AviSynth compat’s LoadPlugin() which isn’t actually a filter, can return None.

args contains the filter arguments, as specified by the argument string from FilterFunction::args(). Their presence and types are validated by VapourSynth so it’s safe to unwrap().

In this function you should take all input nodes for your filter and store them somewhere so that you can request their frames in get_frame_initial().

Implementors