Skip to content

qtgmc

Classes:

  • QTempGaussMC

    Q Temporal Gaussian Motion Compensated (QTGMC)

QTGMCArgs

Namespace containing helper TypedDict definitions for various argument groups.

Classes:

Blur

Bases: TypedDict

Arguments available when passing to MVTools.flow_blur.

Attributes:

prec instance-attribute

prec: int | None

Compensate

Bases: TypedDict

Arguments available when passing to MVTools.compensate.

Attributes:

scbehavior instance-attribute

scbehavior: bool | None

thsad instance-attribute

thsad: int | None

time instance-attribute

time: float | None

Degrain

Bases: TypedDict

Arguments available when passing to the internal binomial_degrain method, calling MVTools.degrain through QTempGaussMC.basic and QTempGaussMC.source_match or directly calling MVTools.degrain through QTempGaussMC.final

Attributes:

limit instance-attribute

limit: float | tuple[float | None, float | None] | None

planes instance-attribute

planes: Planes

Mask

Bases: TypedDict

Arguments available when passing to MVTools.mask.

Attributes:

delta instance-attribute

delta: int

gamma instance-attribute

gamma: float | None

ml instance-attribute

ml: float | None

time instance-attribute

time: float | None

ysc instance-attribute

ysc: int | None

MaskShimmer

Bases: TypedDict

Arguments available when passing to the internal _mask_shimmer method through QTempGaussMC.prefilter, QTempGaussMC.basic and QTempGaussMC.final.

Attributes:

erosion_distance instance-attribute

erosion_distance: int

How much to deflate then reflate to remove thin areas.

over_dilation instance-attribute

over_dilation: int

Extra inflation to ensure areas to restore back are fully caught.

PrefilterToFullRange

Bases: TypedDict

Arguments available when passing to prefilter_to_full_range.

Attributes:

slope instance-attribute

slope: float

smooth instance-attribute

smooth: float

QTempGaussMC

QTempGaussMC(
    clip: VideoNode,
    input_type: InputType = INTERLACE,
    tff: FieldBasedLike | bool | None = None,
    **kwargs: Any
)

Bases: VSObject

Q Temporal Gaussian Motion Compensated (QTGMC)

A very high quality deinterlacer with a range of features for both quality and convenience. These include extensive noise processing capabilities, support for repair of progressive material, precision source matching, shutter speed simulation, etc.

Originally based on TempGaussMC by Didée.

Basic usage
deinterlace = QTempGaussMC(clip).deinterlace()

Refer to the AviSynth QTGMC documentation and the havsfunc implementation for detailed explanations of the underlying algorithm.

These resources remain relevant, as the core algorithm used here is largely similar.

Note that parameter names differ in this implementation due to a complete rewrite. A mapping between vsjetpack and havsfunc parameters is available here.

Examples:

  • ...
  • Passing a progressive input to reduce shimmering (equivalent to InputType=2, ProgSADMask=12):
    clip = (
        QTempGaussMC(clip, QTempGaussMC.InputType.REPAIR)
        .basic(mask_args={"ml": 12})
        .deinterlace()
    )
    
    Or:
    clip = QTempGaussMC(clip, QTempGaussMC.InputType.REPAIR, basic_mask_args={"ml": 12}).deinterlace()
    

Parameters:

  • clip

    (VideoNode) –

    Clip to process.

  • input_type

    (InputType, default: INTERLACE ) –

    Indicates processing routine.

  • tff

    (FieldBasedLike | bool | None, default: None ) –

    Field order of the clip.

  • **kwargs

    (Any, default: {} ) –

    Additional arguments to be passed to the parameter stage methods. Use the method's name as prefix to pass an argument to the respective method.

    Example for passing tr=1 to the prefilter stage: prefilter_tr=1.

Classes:

  • BackBlendMode

    When to back blend (blurred) difference between pre & post sharpened clip.

  • InputType

    Processing routine to use for the input.

  • LosslessMode

    When to put exact source fields into result & clean any artifacts.

  • NoiseDeintMode

    When noise is taken from interlaced source, how to 'deinterlace' it before restoring.

  • NoiseProcessMode

    How to handle processing noise in the source.

  • SearchPostProcess

    Prefiltering to apply in order to assist with motion search.

  • SharpenLimitMode

    How to limit and when to apply re-sharpening of the clip.

  • SharpenMode

    How to re-sharpen the clip after temporally blurring.

  • SourceMatchMode

    Creates higher fidelity output with extra processing.

Methods:

  • analyze

    Configure parameters for the motion analysis stage.

  • back_blend

    Configure parameters for the back_blend stage.

  • basic

    Configure parameters for the basic stage.

  • deinterlace

    Start the deinterlacing process.

  • denoise

    Configure parameters for the denoise stage.

  • final

    Configure parameters for the final stage.

  • lossless

    Configure parameter for the lossless stage.

  • motion_blur

    Configure parameters for the motion blur stage.

  • prefilter

    Configure parameters for the prefilter stage.

  • sharpen

    Configure parameters for the sharpen stage.

  • sharpen_limit

    Configure parameters for the sharpen_limit stage.

  • source_match

    Configure parameters for the source_match stage.

Attributes:

Source code in vsdeinterlace/qtgmc.py
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
def __init__(
    self,
    clip: vs.VideoNode,
    input_type: InputType = InputType.INTERLACE,
    tff: FieldBasedLike | bool | None = None,
    **kwargs: Any,
) -> None:
    """
    Args:
        clip: Clip to process.
        input_type: Indicates processing routine.
        tff: Field order of the clip.
        **kwargs: Additional arguments to be passed to the parameter stage methods.
            Use the method's name as prefix to pass an argument to the respective method.

            Example for passing tr=1 to the prefilter stage: `prefilter_tr=1`.
    """
    clip_fieldbased = FieldBased.from_param_or_video(tff, clip, True, self.__class__)

    self.clip = clip
    self.input_type = input_type

    if self.input_type == self.InputType.PROGRESSIVE and clip_fieldbased.is_inter():
        raise UnsupportedFieldBasedError(f"{self.input_type} incompatible with interlaced video!", self.__class__)
    elif self.input_type in (self.InputType.INTERLACE, self.InputType.REPAIR) and not clip_fieldbased.is_inter():
        raise UnsupportedFieldBasedError(f"{self.input_type} incompatible with progressive video!", self.__class__)

    self.tff = None if self.input_type == self.InputType.PROGRESSIVE else clip_fieldbased.is_tff()
    self.double_rate = self.input_type != self.InputType.REPAIR

    # Set default parameters for all the stages in this exact order
    self._settings_methods = (
        self.prefilter,
        self.analyze,
        self.denoise,
        self.basic,
        self.source_match,
        self.lossless,
        self.sharpen,
        self.back_blend,
        self.sharpen_limit,
        self.final,
        self.motion_blur,
    )

    for method in self._settings_methods:
        prefix = f"{method.__name__}_"

        method(**{k.removeprefix(prefix): kwargs.pop(k) for k in tuple(kwargs) if k.startswith(prefix)})

    if kwargs:
        raise CustomValueError("Unknown arguments were passed", self.__class__, kwargs)

basic_output instance-attribute

basic_output: VideoNode

Output of the basic stage.

bobbed instance-attribute

bobbed: VideoNode

High quality bobbed clip, initial spatial interpolation.

clip instance-attribute

clip: VideoNode = clip

Clip to process.

denoise_output instance-attribute

denoise_output: VideoNode

Output of the denoise stage.

double_rate instance-attribute

double_rate = input_type != REPAIR

draft instance-attribute

draft: VideoNode

Draft processed clip, used as a base for prefiltering & denoising.

final_output instance-attribute

final_output: VideoNode

Output of the final stage.

input_type instance-attribute

input_type = input_type

motion_blur_output instance-attribute

motion_blur_output: VideoNode

Output of the motion blur stage.

noise instance-attribute

noise: VideoNode

Extracted noise when noise processing is enabled.

prefilter_output instance-attribute

prefilter_output: VideoNode

Output of the prefilter stage.

sharpen_limit_radius property writable

sharpen_limit_radius: int

sharpen_mode property writable

sharpen_mode: SharpenMode

sharpen_strength property writable

sharpen_strength: float

source_match_bobber property writable

source_match_bobber: Bobber

tff instance-attribute

tff = None if input_type == PROGRESSIVE else is_tff()

BackBlendMode

Bases: CustomIntEnum

When to back blend (blurred) difference between pre & post sharpened clip.

Attributes:

  • BOTH

    Perform back-blending both before and after sharpness limiting.

  • POSTLIMIT

    Perform back-blending after sharpness limiting.

  • PRELIMIT

    Perform back-blending prior to sharpness limiting.

BOTH class-attribute instance-attribute

BOTH = 2

Perform back-blending both before and after sharpness limiting.

POSTLIMIT class-attribute instance-attribute

POSTLIMIT = 1

Perform back-blending after sharpness limiting.

PRELIMIT class-attribute instance-attribute

PRELIMIT = 0

Perform back-blending prior to sharpness limiting.

InputType

Bases: CustomIntEnum

Processing routine to use for the input.

Attributes:

  • INTERLACE

    Deinterlace interlaced input.

  • PROGRESSIVE

    Deshimmer general progressive material that contains less severe problems.

  • REPAIR

    Repair badly deinterlaced material with considerable horizontal artifacts.

INTERLACE class-attribute instance-attribute

INTERLACE = 0

Deinterlace interlaced input.

PROGRESSIVE class-attribute instance-attribute

PROGRESSIVE = 1

Deshimmer general progressive material that contains less severe problems.

REPAIR class-attribute instance-attribute

REPAIR = 2

Repair badly deinterlaced material with considerable horizontal artifacts.

LosslessMode

Bases: CustomIntEnum

When to put exact source fields into result & clean any artifacts.

Attributes:

  • NONE

    Do not restore source fields.

  • POSTSMOOTH

    Restore source fields after final temporal smooth. True lossless but less stable.

  • PRESHARPEN

    Restore source fields prior to re-sharpening. Not exactly lossless.

NONE class-attribute instance-attribute

NONE = 0

Do not restore source fields.

POSTSMOOTH class-attribute instance-attribute

POSTSMOOTH = 2

Restore source fields after final temporal smooth. True lossless but less stable.

PRESHARPEN class-attribute instance-attribute

PRESHARPEN = 1

Restore source fields prior to re-sharpening. Not exactly lossless.

NoiseDeintMode

Bases: CustomIntEnum

When noise is taken from interlaced source, how to 'deinterlace' it before restoring.

Attributes:

  • BOB

    Bob source noise, results in coarse noise.

  • GENERATE

    Generates fresh noise lines.

  • WEAVE

    Double weave source noise, lags behind by one frame.

BOB class-attribute instance-attribute

BOB = 1

Bob source noise, results in coarse noise.

GENERATE class-attribute instance-attribute

GENERATE = 2

Generates fresh noise lines.

WEAVE class-attribute instance-attribute

WEAVE = 0

Double weave source noise, lags behind by one frame.

NoiseProcessMode

Bases: CustomIntEnum

How to handle processing noise in the source.

Attributes:

  • DENOISE

    Denoise source & optionally restore some noise back at the end of basic or final stages.

  • IDENTIFY

    Identify noise only & optionally restore some noise back at the end of basic or final stages.

DENOISE class-attribute instance-attribute

DENOISE = 1

Denoise source & optionally restore some noise back at the end of basic or final stages.

IDENTIFY class-attribute instance-attribute

IDENTIFY = 0

Identify noise only & optionally restore some noise back at the end of basic or final stages.

SearchPostProcess

Bases: CustomIntEnum

Prefiltering to apply in order to assist with motion search.

Attributes:

GAUSSBLUR class-attribute instance-attribute

GAUSSBLUR = 0

Gaussian blur.

GAUSSBLUR_EDGESOFTEN class-attribute instance-attribute

GAUSSBLUR_EDGESOFTEN = 1

Gaussian blur & edge softening.

SharpenLimitMode

Bases: CustomIntEnum

How to limit and when to apply re-sharpening of the clip.

Attributes:

SPATIAL_POSTSMOOTH class-attribute instance-attribute

SPATIAL_POSTSMOOTH = 2

Spatial sharpness limiting after the final stage.

SPATIAL_PRESMOOTH class-attribute instance-attribute

SPATIAL_PRESMOOTH = 0

Spatial sharpness limiting prior to final stage.

TEMPORAL_POSTSMOOTH class-attribute instance-attribute

TEMPORAL_POSTSMOOTH = 3

Temporal sharpness limiting after the final stage.

TEMPORAL_PRESMOOTH class-attribute instance-attribute

TEMPORAL_PRESMOOTH = 1

Temporal sharpness limiting prior to final stage.

SharpenMode

Bases: CustomIntEnum

How to re-sharpen the clip after temporally blurring.

Attributes:

  • UNSHARP

    Re-sharpening using unsharpening.

  • UNSHARP_MINMAX

    Re-sharpening using unsharpening clamped to the local 3x3 min/max average.

UNSHARP class-attribute instance-attribute

UNSHARP = 0

Re-sharpening using unsharpening.

UNSHARP_MINMAX class-attribute instance-attribute

UNSHARP_MINMAX = 1

Re-sharpening using unsharpening clamped to the local 3x3 min/max average.

SourceMatchMode

Bases: CustomIntEnum

Creates higher fidelity output with extra processing. Will capture more source detail and reduce oversharpening / haloing.

Attributes:

  • BASIC

    Conservative halfway stage that rarely introduces artifacts.

  • NONE

    No source match processing.

  • REFINED

    Restores almost exact source detail but is sensitive to noise & can introduce occasional aliasing.

  • TWICE_REFINED

    Restores almost exact source detail.

BASIC class-attribute instance-attribute

BASIC = 1

Conservative halfway stage that rarely introduces artifacts.

NONE class-attribute instance-attribute

NONE = 0

No source match processing.

REFINED class-attribute instance-attribute

REFINED = 2

Restores almost exact source detail but is sensitive to noise & can introduce occasional aliasing.

TWICE_REFINED class-attribute instance-attribute

TWICE_REFINED = 3

Restores almost exact source detail.

analyze

analyze(
    *,
    force_tr: int = 0,
    preset: Mapping[str, Any] = HQ_SAD,
    blksize: int | tuple[int, int] = 16,
    overlap: int | tuple[int, int] = 2,
    refine: int = 1,
    thsad_recalc: int | None = None,
    thscd: int | tuple[int | None, float | None] | None = (180, 38.5)
) -> Self

Configure parameters for the motion analysis stage.

Parameters:

  • force_tr

    (int, default: 0 ) –

    Always analyze motion to at least this, even if otherwise unnecessary.

  • preset

    (Mapping[str, Any], default: HQ_SAD ) –

    MVTools preset defining base values for the MVTools object.

  • blksize

    (int | tuple[int, int], default: 16 ) –

    Size of a block. Larger blocks are less sensitive to noise, are faster, but also less accurate.

  • overlap

    (int | tuple[int, int], default: 2 ) –

    The blksize divisor for block overlap. Larger overlapping reduces blocking artifacts.

  • refine

    (int, default: 1 ) –

    Number of times to recalculate motion vectors with halved block size.

  • thsad_recalc

    (int | None, default: None ) –

    Only bad quality new vectors with a SAD above this will be re-estimated by search. thsad value is scaled to 8x8 block size.

  • thscd

    (int | tuple[int | None, float | None] | None, default: (180, 38.5) ) –

    Scene change detection thresholds:

    • First value: SAD threshold for considering a block changed between frames.
    • Second value: Percentage of changed blocks needed to trigger a scene change.
Source code in vsdeinterlace/qtgmc.py
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
def analyze(
    self,
    *,
    force_tr: int = 0,
    preset: Mapping[str, Any] = MVToolsPreset.HQ_SAD,
    blksize: int | tuple[int, int] = 16,
    overlap: int | tuple[int, int] = 2,
    refine: int = 1,
    thsad_recalc: int | None = None,
    thscd: int | tuple[int | None, float | None] | None = (180, 38.5),
) -> Self:
    """
    Configure parameters for the motion analysis stage.

    Args:
        force_tr: Always analyze motion to at least this, even if otherwise unnecessary.
        preset: MVTools preset defining base values for the MVTools object.
        blksize: Size of a block. Larger blocks are less sensitive to noise, are faster, but also less accurate.
        overlap: The blksize divisor for block overlap. Larger overlapping reduces blocking artifacts.
        refine: Number of times to recalculate motion vectors with halved block size.
        thsad_recalc: Only bad quality new vectors with a SAD above this will be re-estimated by search. thsad value
            is scaled to 8x8 block size.
        thscd: Scene change detection thresholds:

               - First value: SAD threshold for considering a block changed between frames.
               - Second value: Percentage of changed blocks needed to trigger a scene change.
    """

    self.analyze_force_tr = force_tr
    self.analyze_preset = preset
    self.analyze_blksize = blksize
    self.analyze_overlap = overlap
    self.analyze_refine = refine
    self.analyze_thsad_recalc = thsad_recalc
    self.analyze_thscd = thscd

    return self

back_blend

back_blend(*, mode: BackBlendMode = PRELIMIT, sigma: float = 1.4) -> Self

Configure parameters for the back_blend stage.

Parameters:

  • mode

    (BackBlendMode, default: PRELIMIT ) –

    Specifies at which stage to perform back-blending.

  • sigma

    (float, default: 1.4 ) –

    Gaussian blur sigma.

Source code in vsdeinterlace/qtgmc.py
669
670
671
672
673
674
675
676
677
678
679
680
681
def back_blend(self, *, mode: BackBlendMode = BackBlendMode.PRELIMIT, sigma: float = 1.4) -> Self:
    """
    Configure parameters for the back_blend stage.

    Args:
        mode: Specifies at which stage to perform back-blending.
        sigma: Gaussian blur sigma.
    """

    self.backblend_mode = mode
    self.backblend_sigma = sigma

    return self

basic

basic(
    *,
    tr: int = 2,
    thsad: int | tuple[int, int] = 640,
    bobber: BobberLike = NNEDI3(nsize=1),
    noise_restore: float = 0,
    degrain_args: Degrain | None = None,
    mask_args: Mask | None = {"ml": 10},
    mask_shimmer_args: MaskShimmer | None = {"erosion_distance": 0}
) -> Self

Configure parameters for the basic stage.

Parameters:

  • tr

    (int, default: 2 ) –

    Temporal radius of the motion compensated binomial smooth.

  • thsad

    (int | tuple[int, int], default: 640 ) –

    Thsad of the motion compensated binomial smooth.

  • bobber

    (BobberLike, default: NNEDI3(nsize=1) ) –

    Bobber to use for initial spatial interpolation.

  • noise_restore

    (float, default: 0 ) –

    How much noise to restore after this stage.

  • degrain_args

    (Degrain | None, default: None ) –

    Arguments passed to the binomial_degrain call.

  • mask_args

    (Mask | None, default: {'ml': 10} ) –

    Arguments passed to MVTools.mask for InputType.REPAIR.

  • mask_shimmer_args

    (MaskShimmer | None, default: {'erosion_distance': 0} ) –

    Arguments passed to the mask_shimmer call.

Source code in vsdeinterlace/qtgmc.py
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
def basic(
    self,
    *,
    tr: int = 2,
    thsad: int | tuple[int, int] = 640,
    bobber: BobberLike = NNEDI3(nsize=1),
    noise_restore: float = 0,
    degrain_args: QTGMCArgs.Degrain | None = None,
    mask_args: QTGMCArgs.Mask | None = {"ml": 10},
    mask_shimmer_args: QTGMCArgs.MaskShimmer | None = {"erosion_distance": 0},
) -> Self:
    """
    Configure parameters for the basic stage.

    Args:
        tr: Temporal radius of the motion compensated binomial smooth.
        thsad: Thsad of the motion compensated binomial smooth.
        bobber: Bobber to use for initial spatial interpolation.
        noise_restore: How much noise to restore after this stage.
        degrain_args: Arguments passed to the binomial_degrain call.
        mask_args: Arguments passed to [MVTools.mask][vsdenoise.mvtools.mvtools.MVTools.mask] for
            [InputType.REPAIR][vsdeinterlace.qtgmc.QTempGaussMC.InputType.REPAIR].
        mask_shimmer_args: Arguments passed to the mask_shimmer call.
    """

    self.basic_tr = tr
    self.basic_thsad = thsad
    self.basic_bobber = (
        deepcopy(bobber) if isinstance(bobber, Bobber) else Bobber.ensure_obj(bobber, self.__class__)
    )
    self.basic_noise_restore = noise_restore
    self.basic_degrain_args = fallback(degrain_args, QTGMCArgs.Degrain())
    self.basic_mask_args = fallback(mask_args, QTGMCArgs.Mask())
    self.basic_mask_shimmer_args = fallback(mask_shimmer_args, QTGMCArgs.MaskShimmer())

    return self

deinterlace

deinterlace() -> VideoNode

Start the deinterlacing process.

Returns:

  • VideoNode

    Deinterlaced clip.

Source code in vsdeinterlace/qtgmc.py
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
def deinterlace(self) -> vs.VideoNode:
    """
    Start the deinterlacing process.

    Returns:
        Deinterlaced clip.
    """

    self._apply_prefilter()
    self._apply_analyze()
    self._apply_denoise()
    self._apply_basic()
    self._apply_final()
    self._apply_motion_blur()

    return self.motion_blur_output

denoise

denoise(
    *,
    tr: int = 1,
    func: DFTTest | _DenoiseFuncTr = DFTTest(sigma=8),
    mode: NoiseProcessMode = IDENTIFY,
    deint: NoiseDeintMode = GENERATE,
    mc_denoise: bool = True,
    stabilize: tuple[float, float] | Literal[False] = (0.6, 0.2),
    func_comp_args: Compensate | None = None,
    stabilize_comp_args: Compensate | None = None
) -> Self

Configure parameters for the denoise stage.

Parameters:

  • tr

    (int, default: 1 ) –

    Temporal radius of the denoising function & it's motion compensation.

  • func

    (DFTTest | _DenoiseFuncTr, default: DFTTest(sigma=8) ) –

    Denoising function to use.

  • mode

    (NoiseProcessMode, default: IDENTIFY ) –

    Noise handling method to use.

  • deint

    (NoiseDeintMode, default: GENERATE ) –

    Noise deinterlacing method to use.

  • mc_denoise

    (bool, default: True ) –

    Whether to perform motion-compensated denoising.

  • stabilize

    (tuple[float, float] | Literal[False], default: (0.6, 0.2) ) –

    Weights to use when blending source noise with compensated noise.

  • func_comp_args

    (Compensate | None, default: None ) –

    Arguments passed to MVTools.compensate for denoising.

  • stabilize_comp_args

    (Compensate | None, default: None ) –

    Arguments passed to MVTools.compensate for stabilization.

Source code in vsdeinterlace/qtgmc.py
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
def denoise(
    self,
    *,
    tr: int = 1,
    func: DFTTest | _DenoiseFuncTr = DFTTest(sigma=8),
    mode: NoiseProcessMode = NoiseProcessMode.IDENTIFY,
    deint: NoiseDeintMode = NoiseDeintMode.GENERATE,
    mc_denoise: bool = True,
    stabilize: tuple[float, float] | Literal[False] = (0.6, 0.2),
    func_comp_args: QTGMCArgs.Compensate | None = None,
    stabilize_comp_args: QTGMCArgs.Compensate | None = None,
) -> Self:
    """
    Configure parameters for the denoise stage.

    Args:
        tr: Temporal radius of the denoising function & it's motion compensation.
        func: Denoising function to use.
        mode: Noise handling method to use.
        deint: Noise deinterlacing method to use.
        mc_denoise: Whether to perform motion-compensated denoising.
        stabilize: Weights to use when blending source noise with compensated noise.
        func_comp_args: Arguments passed to [MVTools.compensate][vsdenoise.mvtools.mvtools.MVTools.compensate] for
            denoising.
        stabilize_comp_args: Arguments passed to [MVTools.compensate][vsdenoise.mvtools.mvtools.MVTools.compensate]
            for stabilization.
    """

    self.denoise_tr = tr
    self.denoise_func = func.denoise if isinstance(func, DFTTest) else func
    self.denoise_mode = mode
    self.denoise_deint = deint
    self.denoise_mc_denoise = mc_denoise
    self.denoise_stabilize: tuple[float, float] | Literal[False] = stabilize
    self.denoise_func_comp_args = fallback(func_comp_args, QTGMCArgs.Compensate())
    self.denoise_stabilize_comp_args = fallback(stabilize_comp_args, QTGMCArgs.Compensate())

    return self

final

final(
    *,
    tr: int = 1,
    thsad: int | tuple[int, int] = 256,
    noise_restore: float = 0,
    degrain_args: Degrain | None = None,
    mask_shimmer_args: MaskShimmer | None = None
) -> Self

Configure parameters for the final stage.

Parameters:

  • tr

    (int, default: 1 ) –

    Temporal radius of the motion compensated smooth.

  • thsad

    (int | tuple[int, int], default: 256 ) –

    Thsad of the motion compensated smooth.

  • noise_restore

    (float, default: 0 ) –

    How much noise to restore after this stage.

  • degrain_args

    (Degrain | None, default: None ) –

    Arguments passed to MVTools.degrain.

  • mask_shimmer_args

    (MaskShimmer | None, default: None ) –

    Arguments passed to the mask_shimmer call.

Source code in vsdeinterlace/qtgmc.py
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
def final(
    self,
    *,
    tr: int = 1,
    thsad: int | tuple[int, int] = 256,
    noise_restore: float = 0,
    degrain_args: QTGMCArgs.Degrain | None = None,
    mask_shimmer_args: QTGMCArgs.MaskShimmer | None = None,
) -> Self:
    """
    Configure parameters for the final stage.

    Args:
        tr: Temporal radius of the motion compensated smooth.
        thsad: Thsad of the motion compensated smooth.
        noise_restore: How much noise to restore after this stage.
        degrain_args: Arguments passed to [MVTools.degrain][vsdenoise.mvtools.mvtools.MVTools.degrain].
        mask_shimmer_args: Arguments passed to the mask_shimmer call.
    """

    self.final_tr = tr
    self.final_thsad = thsad
    self.final_noise_restore = noise_restore
    self.final_degrain_args = fallback(degrain_args, QTGMCArgs.Degrain())
    self.final_mask_shimmer_args = fallback(mask_shimmer_args, QTGMCArgs.MaskShimmer())

    return self

lossless

lossless(*, mode: LosslessMode = NONE, anti_comb: bool = True) -> Self

Configure parameter for the lossless stage.

Parameters:

  • mode

    (LosslessMode, default: NONE ) –

    Specifies at which stage to re-weave the original fields.

  • anti_comb

    (bool, default: True ) –

    Whether to apply combing reduction post-processing.

Source code in vsdeinterlace/qtgmc.py
603
604
605
606
607
608
609
610
611
612
613
614
615
def lossless(self, *, mode: LosslessMode = LosslessMode.NONE, anti_comb: bool = True) -> Self:
    """
    Configure parameter for the lossless stage.

    Args:
        mode: Specifies at which stage to re-weave the original fields.
        anti_comb: Whether to apply combing reduction post-processing.
    """

    self.lossless_mode = mode
    self.lossless_anti_comb = anti_comb

    return self

motion_blur

motion_blur(
    *,
    shutter_angle: tuple[float, float] = (180, 180),
    fps_divisor: int = 1,
    blur_args: Blur | None = None,
    mask_args: Mask | None = {"ml": 4}
) -> Self

Configure parameters for the motion blur stage.

Parameters:

  • shutter_angle

    (tuple[float, float], default: (180, 180) ) –

    Tuple containing the source and output shutter angle. Will apply motion blur if they do not match.

  • fps_divisor

    (int, default: 1 ) –

    Factor by which to reduce framerate.

  • blur_args

    (Blur | None, default: None ) –

    Arguments passed to MVTools.flow_blur.

  • mask_args

    (Mask | None, default: {'ml': 4} ) –

    Arguments passed to MVTools.mask.

Source code in vsdeinterlace/qtgmc.py
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
def motion_blur(
    self,
    *,
    shutter_angle: tuple[float, float] = (180, 180),
    fps_divisor: int = 1,
    blur_args: QTGMCArgs.Blur | None = None,
    mask_args: QTGMCArgs.Mask | None = {"ml": 4},
) -> Self:
    """
    Configure parameters for the motion blur stage.

    Args:
        shutter_angle: Tuple containing the source and output shutter angle. Will apply motion blur if they do not
            match.
        fps_divisor: Factor by which to reduce framerate.
        blur_args: Arguments passed to [MVTools.flow_blur][vsdenoise.mvtools.mvtools.MVTools.flow_blur].
        mask_args: Arguments passed to [MVTools.mask][vsdenoise.mvtools.mvtools.MVTools.mask].
    """

    self.motion_blur_shutter_angle = shutter_angle
    self.motion_blur_fps_divisor = fps_divisor
    self.motion_blur_blur_args = fallback(blur_args, QTGMCArgs.Blur())
    self.motion_blur_mask_args = fallback(mask_args, QTGMCArgs.Mask())

    return self

prefilter

prefilter(
    *,
    tr: int = 2,
    sc_threshold: float = 0.1,
    postprocess: SearchPostProcess = GAUSSBLUR_EDGESOFTEN,
    strength: tuple[float, float] | Literal[False] = (1.9, 0.1),
    limit: tuple[float, float, float] = (3, 7, 2),
    range_expansion_args: PrefilterToFullRange | None = None,
    mask_shimmer_args: MaskShimmer | None = None
) -> Self

Configure parameters for the prefilter stage.

Parameters:

  • tr

    (int, default: 2 ) –

    Radius of the initial temporal binomial smooth.

  • sc_threshold

    (float, default: 0.1 ) –

    Threshold for scene changes, disables sc detection if False.

  • postprocess

    (SearchPostProcess, default: GAUSSBLUR_EDGESOFTEN ) –

    Post-processing routine to use.

  • strength

    (tuple[float, float] | Literal[False], default: (1.9, 0.1) ) –

    Tuple containing gaussian blur sigma & blend weight of the blur.

  • limit

    (tuple[float, float, float], default: (3, 7, 2) ) –

    3-step limiting (8-bits) thresholds for the gaussian blur post-processing.

  • range_expansion_args

    (PrefilterToFullRange | None, default: None ) –

    Arguments passed to prefilter_to_full_range.

  • mask_shimmer_args

    (MaskShimmer | None, default: None ) –

    mask_shimmer_args: Arguments passed to the mask_shimmer call.

Source code in vsdeinterlace/qtgmc.py
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
def prefilter(
    self,
    *,
    tr: int = 2,
    sc_threshold: float = 0.1,
    postprocess: SearchPostProcess = SearchPostProcess.GAUSSBLUR_EDGESOFTEN,
    strength: tuple[float, float] | Literal[False] = (1.9, 0.1),
    limit: tuple[float, float, float] = (3, 7, 2),
    range_expansion_args: QTGMCArgs.PrefilterToFullRange | None = None,
    mask_shimmer_args: QTGMCArgs.MaskShimmer | None = None,
) -> Self:
    """
    Configure parameters for the prefilter stage.

    Args:
        tr: Radius of the initial temporal binomial smooth.
        sc_threshold: Threshold for scene changes, disables sc detection if False.
        postprocess: Post-processing routine to use.
        strength: Tuple containing gaussian blur sigma & blend weight of the blur.
        limit: 3-step limiting (8-bits) thresholds for the gaussian blur post-processing.
        range_expansion_args: Arguments passed to
            [prefilter_to_full_range][vsdenoise.prefilters.prefilter_to_full_range].
        mask_shimmer_args: mask_shimmer_args: Arguments passed to the mask_shimmer call.
    """

    self.prefilter_tr = tr
    self.prefilter_sc_threshold = sc_threshold
    self.prefilter_postprocess = postprocess
    self.prefilter_strength: tuple[float, float] | Literal[False] = strength
    self.prefilter_limit = limit
    self.prefilter_range_expansion_args = fallback(range_expansion_args, QTGMCArgs.PrefilterToFullRange())
    self.prefilter_mask_shimmer_args = fallback(mask_shimmer_args, QTGMCArgs.MaskShimmer())

    return self

sharpen

sharpen(
    *,
    mode: SharpenMode | None = None,
    strength: float | None = None,
    clamp: float | tuple[float, float] = 1,
    thin: float = 0
) -> Self

Configure parameters for the sharpen stage.

Parameters:

  • mode

    (SharpenMode | None, default: None ) –

    Specifies the type of sharpening to use. Defaults to [SharpMode.UNSHARP][vsdeinterlace.qtgmc.QTempGaussMC.SharpMode.UNSHARP] for InputType.PROGRESSIVE or [SharpMode.UNSHARP_MINMAX][vsdeinterlace.qtgmc.QTempGaussMC.SharpMode.UNSHARP_MINMAX] otherwise.

  • strength

    (float | None, default: None ) –

    Sharpening strength. Defaults to 1 for SourceMatchMode.NONE or 0 otherwise.

  • clamp

    (float | tuple[float, float], default: 1 ) –

    Clamp the sharpening strength of [SharpMode.UNSHARP_MINMAX][vsdeinterlace.qtgmc.QTempGaussMC.SharpMode.UNSHARP_MINMAX] to the min/max average plus/minus this.

  • thin

    (float, default: 0 ) –

    How much to vertically thin edges.

Source code in vsdeinterlace/qtgmc.py
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
def sharpen(
    self,
    *,
    mode: SharpenMode | None = None,
    strength: float | None = None,
    clamp: float | tuple[float, float] = 1,
    thin: float = 0,
) -> Self:
    """
    Configure parameters for the sharpen stage.

    Args:
        mode: Specifies the type of sharpening to use.
            Defaults to [SharpMode.UNSHARP][vsdeinterlace.qtgmc.QTempGaussMC.SharpMode.UNSHARP] for
                [InputType.PROGRESSIVE][vsdeinterlace.qtgmc.QTempGaussMC.InputType.PROGRESSIVE] or
                [SharpMode.UNSHARP_MINMAX][vsdeinterlace.qtgmc.QTempGaussMC.SharpMode.UNSHARP_MINMAX] otherwise.
        strength: Sharpening strength. Defaults to 1 for
            [SourceMatchMode.NONE][vsdeinterlace.qtgmc.QTempGaussMC.SourceMatchMode.NONE] or 0 otherwise.
        clamp: Clamp the sharpening strength of
            [SharpMode.UNSHARP_MINMAX][vsdeinterlace.qtgmc.QTempGaussMC.SharpMode.UNSHARP_MINMAX] to the min/max
            average plus/minus this.
        thin: How much to vertically thin edges.
    """

    self.sharpen_mode = mode
    self.sharpen_strength = strength
    self.sharpen_clamp = normalize_seq(clamp, 2)
    self.sharpen_thin = thin

    return self

sharpen_limit

sharpen_limit(
    *,
    mode: SharpenLimitMode = TEMPORAL_PRESMOOTH,
    radius: int | None = None,
    clamp: float | tuple[float, float] = 0,
    comp_args: Compensate | None = None
) -> Self

Configure parameters for the sharpen_limit stage.

Parameters:

Source code in vsdeinterlace/qtgmc.py
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
def sharpen_limit(
    self,
    *,
    mode: SharpenLimitMode = SharpenLimitMode.TEMPORAL_PRESMOOTH,
    radius: int | None = None,
    clamp: float | tuple[float, float] = 0,
    comp_args: QTGMCArgs.Compensate | None = None,
) -> Self:
    """
    Configure parameters for the sharpen_limit stage.

    Args:
        mode: Specifies type of limiting & at which stage to perform it.
        radius: Radius of sharpness limiting. Defaults to 1 for
            [SourceMatchMode.NONE][vsdeinterlace.qtgmc.QTempGaussMC.SourceMatchMode.NONE] or 0 otherwise.
        clamp: How much undershoot/overshoot to allow.
        comp_args: Arguments passed to [MVTools.compensate][vsdenoise.mvtools.mvtools.MVTools.compensate] for
            temporal limiting.
    """

    self.sharpen_limit_mode = mode
    self.sharpen_limit_radius = radius
    self.sharpen_limit_clamp = clamp
    self.sharpen_limit_comp_args = fallback(comp_args, QTGMCArgs.Compensate())

    return self

source_match

source_match(
    *,
    tr: int = 1,
    bobber: BobberLike | None = None,
    mode: SourceMatchMode = NONE,
    similarity: float = 0.5,
    enhance: float = 0.5,
    degrain_args: Degrain | None = None
) -> Self

Configure parameters for the source_match stage.

Parameters:

  • tr

    (int, default: 1 ) –

    Temporal radius of the refinement motion compensated binomial smooth.

  • bobber

    (BobberLike | None, default: None ) –

    Bobber to use for refined spatial interpolation. Defaults to the basic bobber.

  • mode

    (SourceMatchMode, default: NONE ) –

    Specifies number of refinement steps to perform.

  • similarity

    (float, default: 0.5 ) –

    Temporal similarity of the error created by smoothing.

  • enhance

    (float, default: 0.5 ) –

    Sharpening strength prior to source match refinement.

  • degrain_args

    (Degrain | None, default: None ) –

    Arguments passed to the binomial_degrain call.

Source code in vsdeinterlace/qtgmc.py
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
def source_match(
    self,
    *,
    tr: int = 1,
    bobber: BobberLike | None = None,
    mode: SourceMatchMode = SourceMatchMode.NONE,
    similarity: float = 0.5,
    enhance: float = 0.5,
    degrain_args: QTGMCArgs.Degrain | None = None,
) -> Self:
    """
    Configure parameters for the source_match stage.

    Args:
        tr: Temporal radius of the refinement motion compensated binomial smooth.
        bobber: Bobber to use for refined spatial interpolation. Defaults to the basic bobber.
        mode: Specifies number of refinement steps to perform.
        similarity: Temporal similarity of the error created by smoothing.
        enhance: Sharpening strength prior to source match refinement.
        degrain_args: Arguments passed to the binomial_degrain call.
    """

    self.source_match_tr = tr
    self.source_match_bobber = bobber
    self.source_match_mode = mode
    self.source_match_similarity = similarity
    self.source_match_enhance = enhance
    self.source_match_degrain_args = fallback(degrain_args, QTGMCArgs.Degrain())

    return self