Skip to content

colors

Classes:

Colorspace

Bases: CustomIntEnum

Methods:

Attributes:

GRAY class-attribute instance-attribute

GRAY = 0

OPP class-attribute instance-attribute

OPP = 5

OPP_BM3D class-attribute instance-attribute

OPP_BM3D = 7

OPP_BM3DS class-attribute instance-attribute

OPP_BM3DS = 8

OPP_LCC class-attribute instance-attribute

OPP_LCC = 6

RGB class-attribute instance-attribute

RGB = 2

YCgCo class-attribute instance-attribute

YCgCo = 3

YCgCoR class-attribute instance-attribute

YCgCoR = 4

YUV class-attribute instance-attribute

YUV = 1

is_opp property

is_opp: bool

is_rgb property

is_rgb: bool

is_yuv property

is_yuv: bool

resampler property

resampler: type[ResampleUtil]

to property

to

__call__

__call__(clip: VideoNode, **kwargs: Any) -> VideoNode
Source code
462
463
464
465
def __call__(self, clip: vs.VideoNode, **kwargs: Any) -> vs.VideoNode:
    assert check_variable_format(clip, self.from_clip)

    return self.resampler.clip2csp(clip, **kwargs)

from_clip

from_clip(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
467
468
469
470
471
472
473
474
def from_clip(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    func = func or self.from_clip

    assert check_variable_format(clip, func)

    return self.resampler.clip2csp(clip, fp32, func, **kwargs)

to_rgb

to_rgb(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    props: VideoNode | None = None,
    **kwargs: Any
) -> VideoNode
Source code
476
477
478
479
480
481
482
483
484
485
486
487
def to_rgb(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None,
    props: vs.VideoNode | None = None, **kwargs: Any
) -> vs.VideoNode:
    func = func or self.to_rgb

    assert check_variable_format(clip, func)

    if props:
        kwargs = self._kw_from_props(clip, props, func, **kwargs)

    return self.resampler.csp2rgb(clip, fp32, func, **kwargs)

to_yuv

to_yuv(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    props: VideoNode | None = None,
    **kwargs: Any
) -> VideoNode
Source code
489
490
491
492
493
494
495
496
497
498
499
500
def to_yuv(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None,
    props: vs.VideoNode | None = None, **kwargs: Any
) -> vs.VideoNode:
    func = func or self.to_yuv

    assert check_variable_format(clip, func)

    if props:
        kwargs = self._kw_from_props(clip, props, func, **kwargs)

    return self.resampler.csp2yuv(clip, fp32, func, **kwargs)

ResampleGRAY

Bases: ResampleYUV

Methods:

clip2csp

clip2csp(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode

Convert any clip to the implemented colorspace.

Parameters:

  • clip

    (VideoNode) –

    Clip to be processed.

  • fp32

    (bool | None, default: None ) –

    Whether to process in original bitdepth (None) or in int16 (False) or float32 (True).

  • func

    (FuncExceptT | None, default: None ) –

    Function returned for custom error handling. This should only be set by VS package developers.

Returns:

  • VideoNode

    Converted clip.

Source code
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
@inject_self
def clip2csp(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    """
    Convert any clip to the implemented colorspace.

    :param clip:    Clip to be processed.
    :param fp32:    Whether to process in original bitdepth (None) or in int16 (False) or float32 (True).
    :param func:    Function returned for custom error handling.
                    This should only be set by VS package developers.

    :return:        Converted clip.
    """

    func = func or self.clip2csp

    assert check_variable_format(clip, func)

    if clip.format.color_family is vs.RGB:
        return self.rgb2csp(clip, fp32, func, **kwargs)

    return self.yuv2csp(clip, fp32, func, **kwargs)

csp2rgb

csp2rgb(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
139
140
141
142
143
144
145
146
147
148
149
@inject_self
def csp2rgb(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_format(clip, (func := func or self.csp2yuv))

    yuv = self.csp2yuv(clip, fp32, func)

    conv_args = video_resample_heuristics(yuv, kwargs, color_family=vs.RGB, subsampling_w=0, subsampling_h=0)

    return yuv.resize.Bicubic(**_norm_props_enums(conv_args))

csp2yuv

csp2yuv(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
222
223
224
225
226
@inject_self
def csp2yuv(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    return clip if fp32 is None else depth(clip, 32 if fp32 else 16)

rgb2csp

rgb2csp(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
129
130
131
132
133
134
135
136
137
@inject_self
def rgb2csp(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_format(clip, (func := func or self.rgb2csp))

    conv_args = video_resample_heuristics(clip, kwargs, color_family=vs.YUV)

    return self.yuv2csp(clip.resize.Bicubic(**_norm_props_enums(conv_args)), fp32, func)

yuv2csp

yuv2csp(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
210
211
212
213
214
215
216
217
218
219
220
@inject_self
def yuv2csp(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:

    assert clip.format

    if fp32 is None or (32 if fp32 else 16) == clip.format.bits_per_sample:
        return plane(clip, 0)

    return clip.resize.Point(format=vs.GRAYS if fp32 else vs.GRAY16)

ResampleOPP

Bases: ResampleRGBMatrixUtil

Methods:

Attributes:

matrix_csp2rgb class-attribute instance-attribute

matrix_csp2rgb = [
    1,
    0,
    -sqrt(2),
    1,
    sqrt(3 / 2),
    1 / sqrt(2),
    1,
    -sqrt(3 / 2),
    1 / sqrt(2),
]

matrix_rgb2csp class-attribute instance-attribute

matrix_rgb2csp = [
    1 / 3,
    1 / 3,
    1 / 3,
    0,
    1 / sqrt(6),
    -1 / sqrt(6),
    -sqrt(2) / 3,
    1 / 3 * sqrt(2),
    1 / 3 * sqrt(2),
]

clip2csp

clip2csp(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode

Convert any clip to the implemented colorspace.

Parameters:

  • clip

    (VideoNode) –

    Clip to be processed.

  • fp32

    (bool | None, default: None ) –

    Whether to process in original bitdepth (None) or in int16 (False) or float32 (True).

  • func

    (FuncExceptT | None, default: None ) –

    Function returned for custom error handling. This should only be set by VS package developers.

Returns:

  • VideoNode

    Converted clip.

Source code
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
@inject_self
def clip2csp(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    """
    Convert any clip to the implemented colorspace.

    :param clip:    Clip to be processed.
    :param fp32:    Whether to process in original bitdepth (None) or in int16 (False) or float32 (True).
    :param func:    Function returned for custom error handling.
                    This should only be set by VS package developers.

    :return:        Converted clip.
    """

    func = func or self.clip2csp

    assert check_variable_format(clip, func)

    if clip.format.color_family is vs.RGB:
        return self.rgb2csp(clip, fp32, func, **kwargs)

    return self.yuv2csp(clip, fp32, func, **kwargs)

csp2rgb

csp2rgb(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
168
169
170
171
172
173
174
175
176
177
178
@inject_self
def csp2rgb(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_format(clip, (func := func or self.csp2rgb))

    clip = clip.fmtc.matrix(
        fulls=True, fulld=True, col_fam=vs.RGB, coef=list(interleave_arr(self.matrix_csp2rgb, [0, 0, 0], 3))
    )

    return clip if fp32 is None else depth(clip, 32 if fp32 else 16)

csp2yuv

csp2yuv(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
115
116
117
118
119
120
121
122
123
124
125
@inject_self
def csp2yuv(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_format(clip, (func := func or self.csp2yuv))

    rgb = self.csp2rgb(clip, fp32, func)

    conv_args = video_resample_heuristics(rgb, kwargs, color_family=vs.YUV)

    return rgb.resize.Bicubic(**_norm_props_enums(conv_args))

rgb2csp

rgb2csp(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
156
157
158
159
160
161
162
163
164
165
166
@inject_self
def rgb2csp(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_format(clip, (func := func or self.rgb2csp))

    clip = clip.fmtc.matrix(
        fulls=True, fulld=True, col_fam=vs.YUV, coef=list(interleave_arr(self.matrix_rgb2csp, [0, 0, 0], 3))
    )

    return clip if fp32 is None else depth(clip, 32 if fp32 else 16)

yuv2csp

yuv2csp(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
105
106
107
108
109
110
111
112
113
@inject_self
def yuv2csp(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_format(clip, (func := func or self.yuv2csp))

    conv_args = video_resample_heuristics(clip, kwargs, color_family=vs.RGB, subsampling_w=0, subsampling_h=0)

    return self.rgb2csp(clip.resize.Bicubic(**_norm_props_enums(conv_args)), fp32, func)

ResampleOPPBM3D

Bases: ResampleRGBMatrixUtil

Methods:

Attributes:

matrix_csp2rgb class-attribute instance-attribute

matrix_csp2rgb = [1, 1, 2 / 3, 1, 0, -4 / 3, 1, -1, 2 / 3]

matrix_rgb2csp class-attribute instance-attribute

matrix_rgb2csp = [1 / 3, 1 / 3, 1 / 3, 1 / 2, 0, -1 / 2, 1 / 4, -1 / 2, 1 / 4]

clip2csp

clip2csp(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode

Convert any clip to the implemented colorspace.

Parameters:

  • clip

    (VideoNode) –

    Clip to be processed.

  • fp32

    (bool | None, default: None ) –

    Whether to process in original bitdepth (None) or in int16 (False) or float32 (True).

  • func

    (FuncExceptT | None, default: None ) –

    Function returned for custom error handling. This should only be set by VS package developers.

Returns:

  • VideoNode

    Converted clip.

Source code
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
@inject_self
def clip2csp(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    """
    Convert any clip to the implemented colorspace.

    :param clip:    Clip to be processed.
    :param fp32:    Whether to process in original bitdepth (None) or in int16 (False) or float32 (True).
    :param func:    Function returned for custom error handling.
                    This should only be set by VS package developers.

    :return:        Converted clip.
    """

    func = func or self.clip2csp

    assert check_variable_format(clip, func)

    if clip.format.color_family is vs.RGB:
        return self.rgb2csp(clip, fp32, func, **kwargs)

    return self.yuv2csp(clip, fp32, func, **kwargs)

csp2rgb

csp2rgb(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
168
169
170
171
172
173
174
175
176
177
178
@inject_self
def csp2rgb(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_format(clip, (func := func or self.csp2rgb))

    clip = clip.fmtc.matrix(
        fulls=True, fulld=True, col_fam=vs.RGB, coef=list(interleave_arr(self.matrix_csp2rgb, [0, 0, 0], 3))
    )

    return clip if fp32 is None else depth(clip, 32 if fp32 else 16)

csp2yuv

csp2yuv(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
115
116
117
118
119
120
121
122
123
124
125
@inject_self
def csp2yuv(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_format(clip, (func := func or self.csp2yuv))

    rgb = self.csp2rgb(clip, fp32, func)

    conv_args = video_resample_heuristics(rgb, kwargs, color_family=vs.YUV)

    return rgb.resize.Bicubic(**_norm_props_enums(conv_args))

rgb2csp

rgb2csp(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
156
157
158
159
160
161
162
163
164
165
166
@inject_self
def rgb2csp(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_format(clip, (func := func or self.rgb2csp))

    clip = clip.fmtc.matrix(
        fulls=True, fulld=True, col_fam=vs.YUV, coef=list(interleave_arr(self.matrix_rgb2csp, [0, 0, 0], 3))
    )

    return clip if fp32 is None else depth(clip, 32 if fp32 else 16)

yuv2csp

yuv2csp(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
105
106
107
108
109
110
111
112
113
@inject_self
def yuv2csp(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_format(clip, (func := func or self.yuv2csp))

    conv_args = video_resample_heuristics(clip, kwargs, color_family=vs.RGB, subsampling_w=0, subsampling_h=0)

    return self.rgb2csp(clip.resize.Bicubic(**_norm_props_enums(conv_args)), fp32, func)

ResampleOPPBM3DS

Bases: ResampleRGBMatrixUtil

Methods:

Attributes:

matrix_csp2rgb class-attribute instance-attribute

matrix_csp2rgb = [1, 0, -4 / 3, 1, 1, 2 / 3, 1, -1, 2 / 3]

matrix_rgb2csp class-attribute instance-attribute

matrix_rgb2csp = [1 / 3, 1 / 3, 1 / 3, 0, 1 / 2, -1 / 2, -1 / 2, 1 / 4, 1 / 4]

clip2csp

clip2csp(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode

Convert any clip to the implemented colorspace.

Parameters:

  • clip

    (VideoNode) –

    Clip to be processed.

  • fp32

    (bool | None, default: None ) –

    Whether to process in original bitdepth (None) or in int16 (False) or float32 (True).

  • func

    (FuncExceptT | None, default: None ) –

    Function returned for custom error handling. This should only be set by VS package developers.

Returns:

  • VideoNode

    Converted clip.

Source code
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
@inject_self
def clip2csp(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    """
    Convert any clip to the implemented colorspace.

    :param clip:    Clip to be processed.
    :param fp32:    Whether to process in original bitdepth (None) or in int16 (False) or float32 (True).
    :param func:    Function returned for custom error handling.
                    This should only be set by VS package developers.

    :return:        Converted clip.
    """

    func = func or self.clip2csp

    assert check_variable_format(clip, func)

    if clip.format.color_family is vs.RGB:
        return self.rgb2csp(clip, fp32, func, **kwargs)

    return self.yuv2csp(clip, fp32, func, **kwargs)

csp2rgb

csp2rgb(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
168
169
170
171
172
173
174
175
176
177
178
@inject_self
def csp2rgb(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_format(clip, (func := func or self.csp2rgb))

    clip = clip.fmtc.matrix(
        fulls=True, fulld=True, col_fam=vs.RGB, coef=list(interleave_arr(self.matrix_csp2rgb, [0, 0, 0], 3))
    )

    return clip if fp32 is None else depth(clip, 32 if fp32 else 16)

csp2yuv

csp2yuv(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
115
116
117
118
119
120
121
122
123
124
125
@inject_self
def csp2yuv(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_format(clip, (func := func or self.csp2yuv))

    rgb = self.csp2rgb(clip, fp32, func)

    conv_args = video_resample_heuristics(rgb, kwargs, color_family=vs.YUV)

    return rgb.resize.Bicubic(**_norm_props_enums(conv_args))

rgb2csp

rgb2csp(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
156
157
158
159
160
161
162
163
164
165
166
@inject_self
def rgb2csp(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_format(clip, (func := func or self.rgb2csp))

    clip = clip.fmtc.matrix(
        fulls=True, fulld=True, col_fam=vs.YUV, coef=list(interleave_arr(self.matrix_rgb2csp, [0, 0, 0], 3))
    )

    return clip if fp32 is None else depth(clip, 32 if fp32 else 16)

yuv2csp

yuv2csp(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
105
106
107
108
109
110
111
112
113
@inject_self
def yuv2csp(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_format(clip, (func := func or self.yuv2csp))

    conv_args = video_resample_heuristics(clip, kwargs, color_family=vs.RGB, subsampling_w=0, subsampling_h=0)

    return self.rgb2csp(clip.resize.Bicubic(**_norm_props_enums(conv_args)), fp32, func)

ResampleOPPLCC

Bases: ResampleRGBMatrixUtil

Methods:

Attributes:

matrix_csp2rgb class-attribute instance-attribute

matrix_csp2rgb = [
    1,
    sqrt(3 / 2),
    1 / sqrt(2),
    1,
    0,
    -sqrt(2),
    1,
    -sqrt(3 / 2),
    1 / sqrt(2),
]

matrix_rgb2csp class-attribute instance-attribute

matrix_rgb2csp = [
    1 / 3,
    1 / 3,
    1 / 3,
    1 / sqrt(6),
    0,
    -1 / sqrt(6),
    1 / 3 * sqrt(2),
    sqrt(2) / -3,
    1 / 3 * sqrt(2),
]

clip2csp

clip2csp(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode

Convert any clip to the implemented colorspace.

Parameters:

  • clip

    (VideoNode) –

    Clip to be processed.

  • fp32

    (bool | None, default: None ) –

    Whether to process in original bitdepth (None) or in int16 (False) or float32 (True).

  • func

    (FuncExceptT | None, default: None ) –

    Function returned for custom error handling. This should only be set by VS package developers.

Returns:

  • VideoNode

    Converted clip.

Source code
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
@inject_self
def clip2csp(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    """
    Convert any clip to the implemented colorspace.

    :param clip:    Clip to be processed.
    :param fp32:    Whether to process in original bitdepth (None) or in int16 (False) or float32 (True).
    :param func:    Function returned for custom error handling.
                    This should only be set by VS package developers.

    :return:        Converted clip.
    """

    func = func or self.clip2csp

    assert check_variable_format(clip, func)

    if clip.format.color_family is vs.RGB:
        return self.rgb2csp(clip, fp32, func, **kwargs)

    return self.yuv2csp(clip, fp32, func, **kwargs)

csp2rgb

csp2rgb(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
168
169
170
171
172
173
174
175
176
177
178
@inject_self
def csp2rgb(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_format(clip, (func := func or self.csp2rgb))

    clip = clip.fmtc.matrix(
        fulls=True, fulld=True, col_fam=vs.RGB, coef=list(interleave_arr(self.matrix_csp2rgb, [0, 0, 0], 3))
    )

    return clip if fp32 is None else depth(clip, 32 if fp32 else 16)

csp2yuv

csp2yuv(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
115
116
117
118
119
120
121
122
123
124
125
@inject_self
def csp2yuv(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_format(clip, (func := func or self.csp2yuv))

    rgb = self.csp2rgb(clip, fp32, func)

    conv_args = video_resample_heuristics(rgb, kwargs, color_family=vs.YUV)

    return rgb.resize.Bicubic(**_norm_props_enums(conv_args))

rgb2csp

rgb2csp(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
156
157
158
159
160
161
162
163
164
165
166
@inject_self
def rgb2csp(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_format(clip, (func := func or self.rgb2csp))

    clip = clip.fmtc.matrix(
        fulls=True, fulld=True, col_fam=vs.YUV, coef=list(interleave_arr(self.matrix_rgb2csp, [0, 0, 0], 3))
    )

    return clip if fp32 is None else depth(clip, 32 if fp32 else 16)

yuv2csp

yuv2csp(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
105
106
107
108
109
110
111
112
113
@inject_self
def yuv2csp(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_format(clip, (func := func or self.yuv2csp))

    conv_args = video_resample_heuristics(clip, kwargs, color_family=vs.RGB, subsampling_w=0, subsampling_h=0)

    return self.rgb2csp(clip.resize.Bicubic(**_norm_props_enums(conv_args)), fp32, func)

ResampleRGB

Bases: ResampleRGBUtil

Methods:

clip2csp

clip2csp(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode

Convert any clip to the implemented colorspace.

Parameters:

  • clip

    (VideoNode) –

    Clip to be processed.

  • fp32

    (bool | None, default: None ) –

    Whether to process in original bitdepth (None) or in int16 (False) or float32 (True).

  • func

    (FuncExceptT | None, default: None ) –

    Function returned for custom error handling. This should only be set by VS package developers.

Returns:

  • VideoNode

    Converted clip.

Source code
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
@inject_self
def clip2csp(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    """
    Convert any clip to the implemented colorspace.

    :param clip:    Clip to be processed.
    :param fp32:    Whether to process in original bitdepth (None) or in int16 (False) or float32 (True).
    :param func:    Function returned for custom error handling.
                    This should only be set by VS package developers.

    :return:        Converted clip.
    """

    func = func or self.clip2csp

    assert check_variable_format(clip, func)

    if clip.format.color_family is vs.RGB:
        return self.rgb2csp(clip, fp32, func, **kwargs)

    return self.yuv2csp(clip, fp32, func, **kwargs)

csp2rgb

csp2rgb(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
188
189
190
191
192
@inject_self
def csp2rgb(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    return clip if fp32 is None else depth(clip, 32 if fp32 else 16)

csp2yuv

csp2yuv(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
115
116
117
118
119
120
121
122
123
124
125
@inject_self
def csp2yuv(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_format(clip, (func := func or self.csp2yuv))

    rgb = self.csp2rgb(clip, fp32, func)

    conv_args = video_resample_heuristics(rgb, kwargs, color_family=vs.YUV)

    return rgb.resize.Bicubic(**_norm_props_enums(conv_args))

rgb2csp

rgb2csp(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
182
183
184
185
186
@inject_self
def rgb2csp(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    return clip if fp32 is None else depth(clip, 32 if fp32 else 16)

yuv2csp

yuv2csp(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
105
106
107
108
109
110
111
112
113
@inject_self
def yuv2csp(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_format(clip, (func := func or self.yuv2csp))

    conv_args = video_resample_heuristics(clip, kwargs, color_family=vs.RGB, subsampling_w=0, subsampling_h=0)

    return self.rgb2csp(clip.resize.Bicubic(**_norm_props_enums(conv_args)), fp32, func)

ResampleRGBMatrixUtil

Bases: ResampleRGBUtil

Methods:

Attributes:

matrix_csp2rgb class-attribute

matrix_csp2rgb: list[float]

matrix_rgb2csp class-attribute

matrix_rgb2csp: list[float]

clip2csp

clip2csp(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode

Convert any clip to the implemented colorspace.

Parameters:

  • clip

    (VideoNode) –

    Clip to be processed.

  • fp32

    (bool | None, default: None ) –

    Whether to process in original bitdepth (None) or in int16 (False) or float32 (True).

  • func

    (FuncExceptT | None, default: None ) –

    Function returned for custom error handling. This should only be set by VS package developers.

Returns:

  • VideoNode

    Converted clip.

Source code
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
@inject_self
def clip2csp(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    """
    Convert any clip to the implemented colorspace.

    :param clip:    Clip to be processed.
    :param fp32:    Whether to process in original bitdepth (None) or in int16 (False) or float32 (True).
    :param func:    Function returned for custom error handling.
                    This should only be set by VS package developers.

    :return:        Converted clip.
    """

    func = func or self.clip2csp

    assert check_variable_format(clip, func)

    if clip.format.color_family is vs.RGB:
        return self.rgb2csp(clip, fp32, func, **kwargs)

    return self.yuv2csp(clip, fp32, func, **kwargs)

csp2rgb

csp2rgb(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
168
169
170
171
172
173
174
175
176
177
178
@inject_self
def csp2rgb(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_format(clip, (func := func or self.csp2rgb))

    clip = clip.fmtc.matrix(
        fulls=True, fulld=True, col_fam=vs.RGB, coef=list(interleave_arr(self.matrix_csp2rgb, [0, 0, 0], 3))
    )

    return clip if fp32 is None else depth(clip, 32 if fp32 else 16)

csp2yuv

csp2yuv(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
115
116
117
118
119
120
121
122
123
124
125
@inject_self
def csp2yuv(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_format(clip, (func := func or self.csp2yuv))

    rgb = self.csp2rgb(clip, fp32, func)

    conv_args = video_resample_heuristics(rgb, kwargs, color_family=vs.YUV)

    return rgb.resize.Bicubic(**_norm_props_enums(conv_args))

rgb2csp

rgb2csp(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
156
157
158
159
160
161
162
163
164
165
166
@inject_self
def rgb2csp(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_format(clip, (func := func or self.rgb2csp))

    clip = clip.fmtc.matrix(
        fulls=True, fulld=True, col_fam=vs.YUV, coef=list(interleave_arr(self.matrix_rgb2csp, [0, 0, 0], 3))
    )

    return clip if fp32 is None else depth(clip, 32 if fp32 else 16)

yuv2csp

yuv2csp(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
105
106
107
108
109
110
111
112
113
@inject_self
def yuv2csp(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_format(clip, (func := func or self.yuv2csp))

    conv_args = video_resample_heuristics(clip, kwargs, color_family=vs.RGB, subsampling_w=0, subsampling_h=0)

    return self.rgb2csp(clip.resize.Bicubic(**_norm_props_enums(conv_args)), fp32, func)

ResampleRGBUtil

Bases: ResampleUtil

Methods:

clip2csp

clip2csp(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode

Convert any clip to the implemented colorspace.

Parameters:

  • clip

    (VideoNode) –

    Clip to be processed.

  • fp32

    (bool | None, default: None ) –

    Whether to process in original bitdepth (None) or in int16 (False) or float32 (True).

  • func

    (FuncExceptT | None, default: None ) –

    Function returned for custom error handling. This should only be set by VS package developers.

Returns:

  • VideoNode

    Converted clip.

Source code
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
@inject_self
def clip2csp(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    """
    Convert any clip to the implemented colorspace.

    :param clip:    Clip to be processed.
    :param fp32:    Whether to process in original bitdepth (None) or in int16 (False) or float32 (True).
    :param func:    Function returned for custom error handling.
                    This should only be set by VS package developers.

    :return:        Converted clip.
    """

    func = func or self.clip2csp

    assert check_variable_format(clip, func)

    if clip.format.color_family is vs.RGB:
        return self.rgb2csp(clip, fp32, func, **kwargs)

    return self.yuv2csp(clip, fp32, func, **kwargs)

csp2rgb abstractmethod

csp2rgb(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
89
90
91
92
93
94
@inject_self
@abstractmethod
def csp2rgb(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    ...

csp2yuv

csp2yuv(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
115
116
117
118
119
120
121
122
123
124
125
@inject_self
def csp2yuv(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_format(clip, (func := func or self.csp2yuv))

    rgb = self.csp2rgb(clip, fp32, func)

    conv_args = video_resample_heuristics(rgb, kwargs, color_family=vs.YUV)

    return rgb.resize.Bicubic(**_norm_props_enums(conv_args))

rgb2csp abstractmethod

rgb2csp(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode

Convert an RGB clip to the implemented colorspace.

Parameters:

  • clip

    (VideoNode) –

    RGB clip to be processed.

  • fp32

    (bool | None, default: None ) –

    Whether to process in original bitdepth (None) or in int16 (False) or float32 (True).

  • func

    (FuncExceptT | None, default: None ) –

    Function returned for custom error handling. This should only be set by VS package developers.

Returns:

  • VideoNode

    Converted clip.

Source code
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
@inject_self
@abstractmethod
def rgb2csp(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    """
    Convert an RGB clip to the implemented colorspace.

    :param clip:    RGB clip to be processed.
    :param fp32:    Whether to process in original bitdepth (None) or in int16 (False) or float32 (True).
    :param func:    Function returned for custom error handling.
                    This should only be set by VS package developers.

    :return:        Converted clip.
    """

yuv2csp

yuv2csp(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
105
106
107
108
109
110
111
112
113
@inject_self
def yuv2csp(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_format(clip, (func := func or self.yuv2csp))

    conv_args = video_resample_heuristics(clip, kwargs, color_family=vs.RGB, subsampling_w=0, subsampling_h=0)

    return self.rgb2csp(clip.resize.Bicubic(**_norm_props_enums(conv_args)), fp32, func)

ResampleUtil

Methods:

  • clip2csp

    Convert any clip to the implemented colorspace.

  • csp2rgb
  • csp2yuv
  • rgb2csp

    Convert an RGB clip to the implemented colorspace.

  • yuv2csp

    Convert a YUV clip to the implemented colorspace.

clip2csp

clip2csp(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode

Convert any clip to the implemented colorspace.

Parameters:

  • clip

    (VideoNode) –

    Clip to be processed.

  • fp32

    (bool | None, default: None ) –

    Whether to process in original bitdepth (None) or in int16 (False) or float32 (True).

  • func

    (FuncExceptT | None, default: None ) –

    Function returned for custom error handling. This should only be set by VS package developers.

Returns:

  • VideoNode

    Converted clip.

Source code
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
@inject_self
def clip2csp(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    """
    Convert any clip to the implemented colorspace.

    :param clip:    Clip to be processed.
    :param fp32:    Whether to process in original bitdepth (None) or in int16 (False) or float32 (True).
    :param func:    Function returned for custom error handling.
                    This should only be set by VS package developers.

    :return:        Converted clip.
    """

    func = func or self.clip2csp

    assert check_variable_format(clip, func)

    if clip.format.color_family is vs.RGB:
        return self.rgb2csp(clip, fp32, func, **kwargs)

    return self.yuv2csp(clip, fp32, func, **kwargs)

csp2rgb abstractmethod

csp2rgb(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
89
90
91
92
93
94
@inject_self
@abstractmethod
def csp2rgb(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    ...

csp2yuv abstractmethod

csp2yuv(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
 96
 97
 98
 99
100
101
@inject_self
@abstractmethod
def csp2yuv(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    ...

rgb2csp abstractmethod

rgb2csp(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode

Convert an RGB clip to the implemented colorspace.

Parameters:

  • clip

    (VideoNode) –

    RGB clip to be processed.

  • fp32

    (bool | None, default: None ) –

    Whether to process in original bitdepth (None) or in int16 (False) or float32 (True).

  • func

    (FuncExceptT | None, default: None ) –

    Function returned for custom error handling. This should only be set by VS package developers.

Returns:

  • VideoNode

    Converted clip.

Source code
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
@inject_self
@abstractmethod
def rgb2csp(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    """
    Convert an RGB clip to the implemented colorspace.

    :param clip:    RGB clip to be processed.
    :param fp32:    Whether to process in original bitdepth (None) or in int16 (False) or float32 (True).
    :param func:    Function returned for custom error handling.
                    This should only be set by VS package developers.

    :return:        Converted clip.
    """

yuv2csp abstractmethod

yuv2csp(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode

Convert a YUV clip to the implemented colorspace.

Parameters:

  • clip

    (VideoNode) –

    YUV clip to be processed.

  • fp32

    (bool | None, default: None ) –

    Whether to process in original bitdepth (None) or in int16 (False) or float32 (True).

  • func

    (FuncExceptT | None, default: None ) –

    Function returned for custom error handling. This should only be set by VS package developers.

Returns:

  • VideoNode

    Converted clip.

Source code
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
@inject_self
@abstractmethod
def yuv2csp(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    """
    Convert a YUV clip to the implemented colorspace.

    :param clip:    YUV clip to be processed.
    :param fp32:    Whether to process in original bitdepth (None) or in int16 (False) or float32 (True).
    :param func:    Function returned for custom error handling.
                    This should only be set by VS package developers.

    :return:        Converted clip.
    """

ResampleYCgCo

Bases: ResampleRGBMatrixUtil

Methods:

Attributes:

matrix_csp2rgb class-attribute instance-attribute

matrix_csp2rgb = [1, 1, -1, 1, 0, 1, 1, -1, -1]

matrix_rgb2csp class-attribute instance-attribute

matrix_rgb2csp = [1 / 4, 1 / 2, 1 / 4, 1 / 2, 0, -1 / 2, -1 / 4, 1 / 2, -1 / 4]

clip2csp

clip2csp(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode

Convert any clip to the implemented colorspace.

Parameters:

  • clip

    (VideoNode) –

    Clip to be processed.

  • fp32

    (bool | None, default: None ) –

    Whether to process in original bitdepth (None) or in int16 (False) or float32 (True).

  • func

    (FuncExceptT | None, default: None ) –

    Function returned for custom error handling. This should only be set by VS package developers.

Returns:

  • VideoNode

    Converted clip.

Source code
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
@inject_self
def clip2csp(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    """
    Convert any clip to the implemented colorspace.

    :param clip:    Clip to be processed.
    :param fp32:    Whether to process in original bitdepth (None) or in int16 (False) or float32 (True).
    :param func:    Function returned for custom error handling.
                    This should only be set by VS package developers.

    :return:        Converted clip.
    """

    func = func or self.clip2csp

    assert check_variable_format(clip, func)

    if clip.format.color_family is vs.RGB:
        return self.rgb2csp(clip, fp32, func, **kwargs)

    return self.yuv2csp(clip, fp32, func, **kwargs)

csp2rgb

csp2rgb(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
168
169
170
171
172
173
174
175
176
177
178
@inject_self
def csp2rgb(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_format(clip, (func := func or self.csp2rgb))

    clip = clip.fmtc.matrix(
        fulls=True, fulld=True, col_fam=vs.RGB, coef=list(interleave_arr(self.matrix_csp2rgb, [0, 0, 0], 3))
    )

    return clip if fp32 is None else depth(clip, 32 if fp32 else 16)

csp2yuv

csp2yuv(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
115
116
117
118
119
120
121
122
123
124
125
@inject_self
def csp2yuv(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_format(clip, (func := func or self.csp2yuv))

    rgb = self.csp2rgb(clip, fp32, func)

    conv_args = video_resample_heuristics(rgb, kwargs, color_family=vs.YUV)

    return rgb.resize.Bicubic(**_norm_props_enums(conv_args))

rgb2csp

rgb2csp(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
156
157
158
159
160
161
162
163
164
165
166
@inject_self
def rgb2csp(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_format(clip, (func := func or self.rgb2csp))

    clip = clip.fmtc.matrix(
        fulls=True, fulld=True, col_fam=vs.YUV, coef=list(interleave_arr(self.matrix_rgb2csp, [0, 0, 0], 3))
    )

    return clip if fp32 is None else depth(clip, 32 if fp32 else 16)

yuv2csp

yuv2csp(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
105
106
107
108
109
110
111
112
113
@inject_self
def yuv2csp(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_format(clip, (func := func or self.yuv2csp))

    conv_args = video_resample_heuristics(clip, kwargs, color_family=vs.RGB, subsampling_w=0, subsampling_h=0)

    return self.rgb2csp(clip.resize.Bicubic(**_norm_props_enums(conv_args)), fp32, func)

ResampleYCgCoR

Bases: ResampleRGBMatrixUtil

Methods:

Attributes:

matrix_csp2rgb class-attribute instance-attribute

matrix_csp2rgb = [1, 1 / 2, -1 / 2, 1, 0, 1 / 2, 1, -1 / 2, -1 / 2]

matrix_rgb2csp class-attribute instance-attribute

matrix_rgb2csp = [1 / 4, 1 / 2, 1 / 4, 1, 0, -1, -1 / 2, 1, -1 / 2]

clip2csp

clip2csp(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode

Convert any clip to the implemented colorspace.

Parameters:

  • clip

    (VideoNode) –

    Clip to be processed.

  • fp32

    (bool | None, default: None ) –

    Whether to process in original bitdepth (None) or in int16 (False) or float32 (True).

  • func

    (FuncExceptT | None, default: None ) –

    Function returned for custom error handling. This should only be set by VS package developers.

Returns:

  • VideoNode

    Converted clip.

Source code
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
@inject_self
def clip2csp(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    """
    Convert any clip to the implemented colorspace.

    :param clip:    Clip to be processed.
    :param fp32:    Whether to process in original bitdepth (None) or in int16 (False) or float32 (True).
    :param func:    Function returned for custom error handling.
                    This should only be set by VS package developers.

    :return:        Converted clip.
    """

    func = func or self.clip2csp

    assert check_variable_format(clip, func)

    if clip.format.color_family is vs.RGB:
        return self.rgb2csp(clip, fp32, func, **kwargs)

    return self.yuv2csp(clip, fp32, func, **kwargs)

csp2rgb

csp2rgb(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
168
169
170
171
172
173
174
175
176
177
178
@inject_self
def csp2rgb(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_format(clip, (func := func or self.csp2rgb))

    clip = clip.fmtc.matrix(
        fulls=True, fulld=True, col_fam=vs.RGB, coef=list(interleave_arr(self.matrix_csp2rgb, [0, 0, 0], 3))
    )

    return clip if fp32 is None else depth(clip, 32 if fp32 else 16)

csp2yuv

csp2yuv(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
115
116
117
118
119
120
121
122
123
124
125
@inject_self
def csp2yuv(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_format(clip, (func := func or self.csp2yuv))

    rgb = self.csp2rgb(clip, fp32, func)

    conv_args = video_resample_heuristics(rgb, kwargs, color_family=vs.YUV)

    return rgb.resize.Bicubic(**_norm_props_enums(conv_args))

rgb2csp

rgb2csp(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
156
157
158
159
160
161
162
163
164
165
166
@inject_self
def rgb2csp(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_format(clip, (func := func or self.rgb2csp))

    clip = clip.fmtc.matrix(
        fulls=True, fulld=True, col_fam=vs.YUV, coef=list(interleave_arr(self.matrix_rgb2csp, [0, 0, 0], 3))
    )

    return clip if fp32 is None else depth(clip, 32 if fp32 else 16)

yuv2csp

yuv2csp(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
105
106
107
108
109
110
111
112
113
@inject_self
def yuv2csp(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_format(clip, (func := func or self.yuv2csp))

    conv_args = video_resample_heuristics(clip, kwargs, color_family=vs.RGB, subsampling_w=0, subsampling_h=0)

    return self.rgb2csp(clip.resize.Bicubic(**_norm_props_enums(conv_args)), fp32, func)

ResampleYUV

Bases: ResampleYUVUtil

Methods:

clip2csp

clip2csp(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode

Convert any clip to the implemented colorspace.

Parameters:

  • clip

    (VideoNode) –

    Clip to be processed.

  • fp32

    (bool | None, default: None ) –

    Whether to process in original bitdepth (None) or in int16 (False) or float32 (True).

  • func

    (FuncExceptT | None, default: None ) –

    Function returned for custom error handling. This should only be set by VS package developers.

Returns:

  • VideoNode

    Converted clip.

Source code
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
@inject_self
def clip2csp(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    """
    Convert any clip to the implemented colorspace.

    :param clip:    Clip to be processed.
    :param fp32:    Whether to process in original bitdepth (None) or in int16 (False) or float32 (True).
    :param func:    Function returned for custom error handling.
                    This should only be set by VS package developers.

    :return:        Converted clip.
    """

    func = func or self.clip2csp

    assert check_variable_format(clip, func)

    if clip.format.color_family is vs.RGB:
        return self.rgb2csp(clip, fp32, func, **kwargs)

    return self.yuv2csp(clip, fp32, func, **kwargs)

csp2rgb

csp2rgb(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
139
140
141
142
143
144
145
146
147
148
149
@inject_self
def csp2rgb(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_format(clip, (func := func or self.csp2yuv))

    yuv = self.csp2yuv(clip, fp32, func)

    conv_args = video_resample_heuristics(yuv, kwargs, color_family=vs.RGB, subsampling_w=0, subsampling_h=0)

    return yuv.resize.Bicubic(**_norm_props_enums(conv_args))

csp2yuv

csp2yuv(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
202
203
204
205
206
@inject_self
def csp2yuv(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    return clip if fp32 is None else depth(clip, 32 if fp32 else 16)

rgb2csp

rgb2csp(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
129
130
131
132
133
134
135
136
137
@inject_self
def rgb2csp(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_format(clip, (func := func or self.rgb2csp))

    conv_args = video_resample_heuristics(clip, kwargs, color_family=vs.YUV)

    return self.yuv2csp(clip.resize.Bicubic(**_norm_props_enums(conv_args)), fp32, func)

yuv2csp

yuv2csp(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
196
197
198
199
200
@inject_self
def yuv2csp(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    return clip if fp32 is None else depth(clip, 32 if fp32 else 16)

ResampleYUVUtil

Bases: ResampleUtil

Methods:

clip2csp

clip2csp(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode

Convert any clip to the implemented colorspace.

Parameters:

  • clip

    (VideoNode) –

    Clip to be processed.

  • fp32

    (bool | None, default: None ) –

    Whether to process in original bitdepth (None) or in int16 (False) or float32 (True).

  • func

    (FuncExceptT | None, default: None ) –

    Function returned for custom error handling. This should only be set by VS package developers.

Returns:

  • VideoNode

    Converted clip.

Source code
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
@inject_self
def clip2csp(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    """
    Convert any clip to the implemented colorspace.

    :param clip:    Clip to be processed.
    :param fp32:    Whether to process in original bitdepth (None) or in int16 (False) or float32 (True).
    :param func:    Function returned for custom error handling.
                    This should only be set by VS package developers.

    :return:        Converted clip.
    """

    func = func or self.clip2csp

    assert check_variable_format(clip, func)

    if clip.format.color_family is vs.RGB:
        return self.rgb2csp(clip, fp32, func, **kwargs)

    return self.yuv2csp(clip, fp32, func, **kwargs)

csp2rgb

csp2rgb(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
139
140
141
142
143
144
145
146
147
148
149
@inject_self
def csp2rgb(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_format(clip, (func := func or self.csp2yuv))

    yuv = self.csp2yuv(clip, fp32, func)

    conv_args = video_resample_heuristics(yuv, kwargs, color_family=vs.RGB, subsampling_w=0, subsampling_h=0)

    return yuv.resize.Bicubic(**_norm_props_enums(conv_args))

csp2yuv abstractmethod

csp2yuv(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
 96
 97
 98
 99
100
101
@inject_self
@abstractmethod
def csp2yuv(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    ...

rgb2csp

rgb2csp(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode
Source code
129
130
131
132
133
134
135
136
137
@inject_self
def rgb2csp(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    assert check_variable_format(clip, (func := func or self.rgb2csp))

    conv_args = video_resample_heuristics(clip, kwargs, color_family=vs.YUV)

    return self.yuv2csp(clip.resize.Bicubic(**_norm_props_enums(conv_args)), fp32, func)

yuv2csp abstractmethod

yuv2csp(
    clip: VideoNode,
    fp32: bool | None = None,
    func: FuncExceptT | None = None,
    **kwargs: Any
) -> VideoNode

Convert a YUV clip to the implemented colorspace.

Parameters:

  • clip

    (VideoNode) –

    YUV clip to be processed.

  • fp32

    (bool | None, default: None ) –

    Whether to process in original bitdepth (None) or in int16 (False) or float32 (True).

  • func

    (FuncExceptT | None, default: None ) –

    Function returned for custom error handling. This should only be set by VS package developers.

Returns:

  • VideoNode

    Converted clip.

Source code
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
@inject_self
@abstractmethod
def yuv2csp(
    self, clip: vs.VideoNode, fp32: bool | None = None, func: FuncExceptT | None = None, **kwargs: Any
) -> vs.VideoNode:
    """
    Convert a YUV clip to the implemented colorspace.

    :param clip:    YUV clip to be processed.
    :param fp32:    Whether to process in original bitdepth (None) or in int16 (False) or float32 (True).
    :param func:    Function returned for custom error handling.
                    This should only be set by VS package developers.

    :return:        Converted clip.
    """