lvsfunc.deblock

Deblocking functions and wrappers.

lvsfunc.deblock.vsdpir(clip[, strength, ...])

A simple vs-mlrt DPIR wrapper for convenience.

lvsfunc.deblock.autodb_dpir(clip[, ...])

A rewrite of fvsfunc.AutoDeblock that uses vspdir instead of dfttest to deblock.

class lvsfunc.deblock.vsdpir(clip, strength=25, mode='deblock', matrix=None, tiles=None, cuda=True, i444=False, kernel=<lvsfunc.kernels.Catrom object>, zones=None, **dpir_args)

Bases:

A simple vs-mlrt DPIR wrapper for convenience.

You must install vs-mlrt. For more information, see the following links:

Converts to RGB -> runs DPIR -> converts back to original format, and with no subsampling if i444=True. For more information, see the original DPIR repository.

Dependencies:

  • vs-mlrt

Parameters
  • clip (VideoNode) – Input clip

  • strength (Union[SupportsFloat, VideoNode, None]) – DPIR strength. Sane values lie between 1–20 for mode='deblock', and 1–3 for mode='denoise'

  • mode (str) – DPIR mode. Valid modes are ‘deblock’ and ‘denoise’.

  • matrix (Union[Matrix, int, None]) – Enum for the matrix of the input clip. See types.Matrix for more info. If not specified, gets matrix from the “_Matrix” prop of the clip unless it’s an RGB clip, in which case it stays as None.

  • cuda (Union[bool, Literal[‘trt’]]) – Use CUDA backend if True, else CPU backend

  • i444 (bool) – Forces the returned clip to be YUV444PS instead of the input clip’s format

  • zones (Optional[List[Tuple[Union[int, None, Tuple[Optional[int], Optional[int]], List[Union[int, None, Tuple[Optional[int], Optional[int]]]]], Union[SupportsFloat, VideoNode, None]]]]) – A mapping to zone the DPIR strength so you don’t have to call it multiple times. The key should be a float / VideoNode (a normalised mask, for example) or None to pass the input clip. The values should be a range that will be passed to replace_ranges

  • dpir_args (Any) – Additional args to pass to vs-mlrt. Note: strength, tiles, and model cannot be overridden!

Return type

VideoNode

Returns

Deblocked or denoised clip in either the given clip’s format or YUV444PS

lvsfunc.deblock.autodb_dpir(clip, edgevalue=24, strs=[30, 50, 75], thrs=[(1.5, 2.0, 2.0), (3.0, 4.5, 4.5), (5.5, 7.0, 7.0)], matrix=None, cuda=True, write_props=False, **vsdpir_args)

A rewrite of fvsfunc.AutoDeblock that uses vspdir instead of dfttest to deblock.

This function checks for differences between a frame and an edgemask with some processing done on it, and for differences between the current frame and the next frame. For frames where both thresholds are exceeded, it will perform deblocking at a specified strength. This will ideally be frames that show big temporal and spatial inconsistencies.

Thresholds and calculations are added to the frameprops to use as reference when setting the thresholds.

Keep in mind that vsdpir is not perfect; it may cause weird, black dots to appear sometimes. If that happens, you can perform a denoise on the original clip (maybe even using vsdpir’s denoising mode) and grab the brightest pixels from your two clips. That should return a perfectly fine clip.

Thanks Vardë, louis, setsugen_no_ao!

Dependencies:

  • vs-dpir

Parameters
  • clip (VideoNode) – Input clip

  • edgevalue (int) – Remove edges from the edgemask that exceed this threshold (higher means more edges removed)

  • strs (Sequence[float]) – A list of DPIR strength values (higher means stronger deblocking). You can pass any arbitrary number of values here. Sane deblocking strengths lie between 1–20 for most regular deblocking. Going higher than 50 is not recommended outside of very extreme cases. The amount of values in strs and thrs need to be equal.

  • thrs (Sequence[Tuple[float, float, float]]) – A list of thresholds, written as [(EdgeValRef, NextFrameDiff, PrevFrameDiff)]. You can pass any arbitrary number of values here. The amount of values in strs and thrs need to be equal.

  • matrix (Union[Matrix, int, None]) – Enum for the matrix of the input clip. See types.Matrix for more info. If None, gets matrix from the “_Matrix” prop of the clip unless it’s an RGB clip, in which case it stays as None.

  • cuda (bool) – Use CUDA backend if True, else CPU backend

  • write_props (bool) – Will write verbose props

  • vsdpir_args (Any) – Additional args to pass to vsdpir

Return type

VideoNode

Returns

Deblocked clip