Layer [yuy2][rgb32]

Layer (base_clip, overlay_clip, string "op", int "level", int "x", int "y", int "threshold", bool "use_chroma")

This filter can overlay two clips of different sizes (but with the same color format) using different operation modes.
For pixel-wise transparency information the 4th color channel of RGB32 (A- or alpha-channel) is used as a mask.

Base_clip: the underlying clip which determines the size and all other video and audio properties of the result.
Overlay_clip: the clip which is merged onto clip. This clip can contain an alpha layer.
op: the performed merge operation, which can be: "add", "subtract", "lighten", "darken", "fast", "mul"
level: 0-257, the strength of the performed operation. 0: the base_clip is returned unchanged, 257 (256 for YUY2): the maximal strength is used
x, y: offset position of the overlay_clip
threshold: only implemented for "lighten" and "darken"
use_chroma: use chroma of the overlay_clip, default=true. When false only luma is used.

There are some differences in the behaviour and the allowed parameter depending on the color format and the operation, here are the details:

These operators behave equally for RGB32 or YUY2:

"fast": use_chroma must be TRUE, level and threshold is not used.
        The result is simply the average of base_clip and overlay_clip.

"add":  threshold is not used. The difference between base_clip and
        overlay_clip is multiplied with alpha and added to the base_clip.
          alpha=0 -> only base_clip visible,
          alpha=128 -> base and overlay equally blended,
          alpha=255 -> only overlay visible.
        Formula used :-
          RGB32 :: base += ((overlay-base)*(alpha*level+1)>>8)>>8
          YUY2  :: base += ((overlay-base)*level)>>8

"subtract": the same as add, but the overlay_clip is inverted before.

These operators seem to work correctly only in YUY2:

"mul": threshold is not used. The base_clip is colored
       as overlay_clip, so use_chroma should be TRUE.
       alpha=0 -> only base_clip visible, alpha=255 -> approx.
       the same Luminance as Base but with the colors of Overlay

"lighten": use_chroma must be TRUE. Performs the same operation
           as "add", but only when the result is BRIGHTER than the
           base the new values are used. With a higher threshold
           the operation is more likely, so with threshold=255
           it's the same as "add", with threshold=0 the base_clip
           is more likely passed unchanged, depending on the
           difference between base_clip and overlay_clip.

"darken": the same as "lighten", but it is performed only
          when the result is DARKER than the base.


Also see here for the resulting clip properties.

 

Mask [rgb32]

Mask (clip, mask_clip)

Applies a defined alpha-mask to clip, for use with Layer, by converting mask_clip to greyscale and using that for the mask (the alpha-channel) of RGB32. In this channel "black" means completely transparent, white means completely opaque).

 

ResetMask [rgb32]

ResetMask (clip)

Applies an "all-opaque" (that is white) alpha-mask to clip, for use with Layer.

The alpha-channel of a RGB32-clip is not always well-defined (depending on the source), this filter is the faster way to apply an all white mask:

clip = ResetMask(clip)

 

ColorKeyMask [rgb32]

ColorKeyMask (clip, int color[, int tolB, int tolG, int tolR])

Clears pixels in the alpha-channel by comparing the color (default black). Each pixel with a color differing less than (tolB, tolR, tolG) (default 10) is set to transparent (that is black), otherwise it is left unchanged i.e. It is NOT set to opaque (that it is not set to white, that's why you might need ResetMask before applying this filter), this allows a aggregate mask to be constructed with multiple calls. When tolR or tolG are not set, they use the value from tolB (which reflects the old behaviour). Normally you start with a ResetMask, then chain a few calls to ColorKeyMask to cause transparent holes where each color of interest occurs. See Overlay for examples.

For AviSynth versions older than v2.58, there were no separate tolerance levels for blue, green and red. There was only one tolerance level called tolerance and was used for blue, green and red simultaneously.

$Date: 2008/02/06 16:40:23 $