Skip to content

y5gfunc.filter.aa

aa

Functions:

Name Description
double_aa

Apply light anti-aliasing to input video clip. Suitable for recent non-descalable anime.

double_aa

double_aa(clip: VideoNode, mask: Optional[VideoNode] = None, doubler: Callable[[VideoNode], VideoNode] = nn2x) -> VideoNode

Apply light anti-aliasing to input video clip. Suitable for recent non-descalable anime.

The function first doubles the resolution of the input clip with doubler, then downscales back with SSIM_downsample. Chroma planes are not touched.

Parameters:

Name Type Description Default

clip

VideoNode

Input video clip.

required

mask

Optional[VideoNode]

If provided, will be used as mask to merge anti-aliased clip and source clip. Otherwise, Prewitt mask is used.

None

doubler

Callable[[VideoNode], VideoNode]

Function to double the clip.

nn2x

Returns: Anti-aliased input video clip.

Source code in y5gfunc/filter/aa.py
def double_aa(
    clip: vs.VideoNode,
    mask: Optional[vs.VideoNode] = None,
    doubler: Callable[[vs.VideoNode], vs.VideoNode] = nn2x,
) -> vs.VideoNode:
    """
    Apply light anti-aliasing to input video clip. Suitable for recent non-descalable anime.

    The function first doubles the resolution of the input clip with `doubler`, then downscales back with SSIM_downsample.
    Chroma planes are not touched.

    Args:
        clip: Input video clip.
        mask: If provided, will be used as mask to merge anti-aliased clip and source clip. Otherwise, Prewitt mask is used.
        doubler: Function to double the clip.
    Returns:
        Anti-aliased input video clip.
    """

    return core.std.MaskedMerge(
        clip,
        join(
            depth(
                SSIM_downsample(
                    doubler(get_y(clip)),
                    width=clip.width,
                    height=clip.height,
                    src_left=-0.5,
                    src_top=-0.5,
                ),
                clip,
            ),
            clip,
        ),
        mask or maximum(prewitt(clip)),
        first_plane=True,
    )