How to use the vapoursynth.RGB function in VapourSynth

To help you get started, we’ve selected a few VapourSynth examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Endilll / vapoursynth-preview / vspreview / core / media.py View on Github external
'chromaloc_in_s': settings.VS_OUTPUT_CHROMALOC,
            'prefer_props'  : settings.VS_OUTPUT_PREFER_PROPS,
        }

        if not alpha:
            vs_output = vs_core.std.FlipVertical(vs_output)

        if vs_output.format == COMPATBGR32:  # type: ignore
            return vs_output

        is_subsampled = (vs_output.format.subsampling_w != 0
                         or vs_output.format.subsampling_h != 0)
        if not is_subsampled:
            resizer = self.Resizer.Point

        if vs_output.format.color_family == RGB:
            del resizer_kwargs['matrix_in_s']

        if alpha:
            if vs_output.format == GRAY8:  # type: ignore
                return vs_output
            resizer_kwargs['format'] = GRAY8

        vs_output = resizer(vs_output, **resizer_kwargs,
                            **settings.VS_OUTPUT_RESIZER_KWARGS)

        return vs_output
github Endilll / vapoursynth-preview / vspreview / toolbars / pipette.py View on Github external
def on_current_output_changed(self, index: int, prev_index: int) -> None:
        from math import ceil, log

        super().on_current_output_changed(index, prev_index)

        fmt = self.main.current_output.format
        src_label_text = ''
        if fmt.color_family == vs.RGB:
            src_label_text = 'Raw (RGB{}):'
        elif fmt.color_family == vs.YUV:
            src_label_text = 'Raw (YUV{}):'
        elif fmt.color_family == vs.GRAY:
            src_label_text = 'Raw (Gray{}):'
        elif fmt.color_family == vs.YCOCG:
            src_label_text = 'Raw (YCoCg{}):'
        elif fmt.id == vs.COMPATBGR32.value:
            src_label_text = 'Raw (RGB{}):'
        elif fmt.id == vs.COMPATYUY2.value:
            src_label_text = 'Raw (YUV{}):'

        has_alpha = self.main.current_output.has_alpha
        if not has_alpha:
            self.src_label.setText(src_label_text.format(''))
        else:
github Endilll / vapoursynth-preview / vspreview / core / types.py View on Github external
'chromaloc_in_s': self.main.VS_OUTPUT_CHROMALOC,
            'prefer_props'  : self.main.VS_OUTPUT_PREFER_PROPS,
        }

        if not alpha:
            vs_output = vs.core.std.FlipVertical(vs_output)

        if vs_output.format == vs.COMPATBGR32:  # type: ignore
            return vs_output

        is_subsampled = (vs_output.format.subsampling_w != 0
                         or vs_output.format.subsampling_h != 0)
        if not is_subsampled:
            resizer = self.Resizer.Point

        if vs_output.format.color_family == vs.RGB:
            del resizer_kwargs['matrix_in_s']

        if alpha:
            if vs_output.format == vs.GRAY8:  # type: ignore
                return vs_output
            resizer_kwargs['format'] = vs.GRAY8

        vs_output = resizer(vs_output, **resizer_kwargs,
                            **self.main.VS_OUTPUT_RESIZER_KWARGS)

        return vs_output
github darealshinji / vapoursynth-plugins / scripts / resamplehq.py View on Github external
range_in = 'limited'

    orig_format = clip.format.id

    if precision == 1:
        tmp_format = vs.RGBS
    else:
        tmp_format = vs.RGBH

    to_tmp_format_opts = dict(format=tmp_format, transfer_in_s=transfer, transfer_s='linear',
                              range_in_s=range_in, range_s='full')

    to_orig_format_opts = dict(format=orig_format, transfer_in_s='linear', transfer_s=transfer,
                               range_in_s='full', range_s=range_in)

    if clip.format.color_family != vs.RGB:
        to_tmp_format_opts.update(matrix_in_s=matrix)
        to_orig_format_opts.update(matrix_s=matrix)

    # Do stuff

    clip = core.resize.Bicubic(clip, **to_tmp_format_opts)

    clip = scaler(clip, **scaler_opts)

    clip = core.resize.Bicubic(clip, **to_orig_format_opts)

    return clip
github Irrational-Encoding-Wizardry / yuuno / yuuno / vs / clip.py View on Github external
def _to_compat_rgb32(self, clip: VideoNode):
        if clip.format.color_family == vs.YUV:
            clip = self.extension.resize_filter(clip, format=vs.RGB24, matrix_in_s=self.extension.yuv_matrix)

        if clip.format.color_family != vs.RGB or clip.format.bits_per_sample != 8:
            clip = self.extension.resize_filter(clip, format=vs.RGB24)

        return self.extension.resize_filter(clip, format=vs.COMPATBGR32)
github darealshinji / vapoursynth-plugins / scripts / mvsfunc.py View on Github external
if a1 is None and a2 is None:
            a1 = 0
            a2 = 0.5
    elif not isinstance(kernel, str):
        raise TypeError(funcName + ': \"kernel\" must be a str!')
    
    # Conversion
    if sIsRGB:
        # Skip matrix conversion for RGB input
        # Apply depth conversion for output clip
        clip = Depth(clip, dbitPS, dSType, fulls, fulld, dither, useZ, ampo, ampn, dyn, staticnoise)
    elif sIsGRAY:
        # Apply depth conversion for output clip
        clip = Depth(clip, dbitPS, dSType, fulls, fulld, dither, useZ, ampo, ampn, dyn, staticnoise)
        # Shuffle planes for Gray input
        clip = core.std.ShufflePlanes([clip,clip,clip], [0,0,0], vs.RGB)
    else:
        # Apply depth conversion for processed clip
        clip = Depth(clip, pbitPS, pSType, fulls, fulls, dither, useZ, ampo, ampn, dyn, staticnoise)
        # Apply chroma up-sampling if needed
        if sHSubS != 1 or sVSubS != 1:
            clip = core.fmtc.resample(clip, kernel=kernel, taps=taps, a1=a1, a2=a2, css="444", planes=[2,3,3], fulls=fulls, fulld=fulls, cplace=cplace)
        # Apply matrix conversion for YUV or YCoCg input
        if matrix == "OPP":
            clip = core.fmtc.matrix(clip, fulls=fulls, fulld=fulld, coef=[1,1,2/3,0, 1,0,-4/3,0, 1,-1,2/3,0], col_fam=vs.RGB)
            clip = SetColorSpace(clip, Matrix=0)
        elif matrix == "2020cl":
            clip = core.fmtc.matrix2020cl(clip, full=fulls)
        else:
            clip = core.fmtc.matrix(clip, mat=matrix, fulls=fulls, fulld=fulld, col_fam=vs.RGB)
        # Apply depth conversion for output clip
        clip = Depth(clip, dbitPS, dSType, fulld, fulld, dither, useZ, ampo, ampn, dyn, staticnoise)
github darealshinji / vapoursynth-plugins / scripts / mvsfunc.py View on Github external
# Set VS core and function name
    core = vs.get_core()
    funcName = 'ToRGB'
    clip = input
    
    if not isinstance(input, vs.VideoNode):
        raise TypeError(funcName + ': \"input\" must be a clip!')
    
    # Get string format parameter "matrix"
    matrix = GetMatrix(input, matrix, True)
    
    # Get properties of input clip
    sFormat = input.format
    
    sColorFamily = sFormat.color_family
    sIsRGB = sColorFamily == vs.RGB
    sIsYUV = sColorFamily == vs.YUV
    sIsGRAY = sColorFamily == vs.GRAY
    sIsYCOCG = sColorFamily == vs.YCOCG
    if sColorFamily == vs.COMPAT:
        raise ValueError(funcName + ': Color family *COMPAT* is not supported!')
    
    sbitPS = sFormat.bits_per_sample
    sSType = sFormat.sample_type
    
    sHSubS = 1 << sFormat.subsampling_w
    sVSubS = 1 << sFormat.subsampling_h
    
    if full is None:
        # If not set, assume limited range for YUV and Gray input
        # Assume full range for YCgCo and OPP input
        if (sIsGRAY or sIsYUV or sIsYCOCG) and (matrix == "RGB" or matrix == "YCgCo" or matrix == "OPP"):
github Irrational-Encoding-Wizardry / fvsfunc / fvsfunc.py View on Github external
if start >= end:
        raise ValueError('InsertSign: "start" must be smaller than or equal to "end"!')
    if matrix == '601':
        matrix = '470bg'
    clip_cf = clip.format.color_family
    overlay_cf = overlay[0].format.color_family

    before = clip[:start] if start != 0 else None
    middle = clip[start:end]
    after = clip[end:] if end != clip.num_frames else None

    matrix_s = None
    matrix_in_s = None
    if clip_cf == vs.YUV and overlay_cf == vs.RGB:
        matrix_s = matrix
    if overlay_cf == vs.YUV and clip_cf == vs.RGB:
        matrix_in_s = matrix
    sign = core.resize.Spline36(overlay[0], clip.width, clip.height, format=clip.format.id,
                                matrix_s=matrix_s, matrix_in_s=matrix_in_s,
                                dither_type='error_diffusion')

    if overlay[1] is None:
        overlay[1] = core.std.BlankClip(sign, format=vs.GRAY8, color=255)
    mask = core.resize.Bicubic(overlay[1], clip.width, clip.height)
    mask = Depth(mask, bits=clip.format.bits_per_sample, range='full', range_in='full')

    middle = core.std.MaskedMerge(middle, sign, mask)

    out = middle
    if before is not None:
        out = before + out
    if after is not None:
github darealshinji / vapoursynth-plugins / scripts / mvsfunc.py View on Github external
# Apply depth conversion for output clip
        clip = Depth(clip, dbitPS, dSType, fulls, fulld, dither, useZ, ampo, ampn, dyn, staticnoise)
    elif sIsGRAY:
        # Apply depth conversion for output clip
        clip = Depth(clip, dbitPS, dSType, fulls, fulld, dither, useZ, ampo, ampn, dyn, staticnoise)
        # Shuffle planes for Gray input
        clip = core.std.ShufflePlanes([clip,clip,clip], [0,0,0], vs.RGB)
    else:
        # Apply depth conversion for processed clip
        clip = Depth(clip, pbitPS, pSType, fulls, fulls, dither, useZ, ampo, ampn, dyn, staticnoise)
        # Apply chroma up-sampling if needed
        if sHSubS != 1 or sVSubS != 1:
            clip = core.fmtc.resample(clip, kernel=kernel, taps=taps, a1=a1, a2=a2, css="444", planes=[2,3,3], fulls=fulls, fulld=fulls, cplace=cplace)
        # Apply matrix conversion for YUV or YCoCg input
        if matrix == "OPP":
            clip = core.fmtc.matrix(clip, fulls=fulls, fulld=fulld, coef=[1,1,2/3,0, 1,0,-4/3,0, 1,-1,2/3,0], col_fam=vs.RGB)
            clip = SetColorSpace(clip, Matrix=0)
        elif matrix == "2020cl":
            clip = core.fmtc.matrix2020cl(clip, full=fulls)
        else:
            clip = core.fmtc.matrix(clip, mat=matrix, fulls=fulls, fulld=fulld, col_fam=vs.RGB)
        # Apply depth conversion for output clip
        clip = Depth(clip, dbitPS, dSType, fulld, fulld, dither, useZ, ampo, ampn, dyn, staticnoise)
    
    # Output
    return clip
################################################################################################################################
github Infiziert90 / getnative / fvsfunc_getnative.py View on Github external
def descale_getnative(src, width, height, kernel='bilinear', b=1/3, c=1/3, taps=3, yuv444=False, gray=False, chromaloc=None):
    src_f = src.format
    src_cf = src_f.color_family
    src_st = src_f.sample_type
    src_bits = src_f.bits_per_sample
    src_sw = src_f.subsampling_w
    src_sh = src_f.subsampling_h

    descale_getnative_filter = get_descale_getnative_filter(b, c, taps, kernel)

    if src_cf == vs.RGB and not gray:
        rgb = descale_getnative_filter(to_rgbs(src), width, height)
        return rgb.resize.Point(format=src_f.id)

    y = descale_getnative_filter(to_grays(src), width, height)
    y_f = core.register_format(vs.GRAY, src_st, src_bits, 0, 0)
    y = y.resize.Point(format=y_f.id)

    if src_cf == vs.GRAY or gray:
        return y

    if not yuv444 and ((width % 2 and src_sw) or (height % 2 and src_sh)):
        raise ValueError('descale_getnative: The output dimension and the subsampling are incompatible.')

    uv_f = core.register_format(src_cf, src_st, src_bits, 0 if yuv444 else src_sw, 0 if yuv444 else src_sh)
    uv = src.resize.Spline36(width, height, format=uv_f.id, chromaloc_s=chromaloc)