Vapoursynth Fix combed with deinterlacer

From wiki.selur.net
Jump to navigation Jump to search

Fix combed with deinterlacer replaces every frame that is still combed after inverse telecine with the output of a deinterlacer; frames without combing stay untouched.

Filtering → (De-)Interlace/Telecine → Extras

Fix combed with deinterlacer controls in Hybrid
Fix combed with deinterlacer controls in Hybrid

What it does

After field matching and decimation some frames can remain combed, for example in video sections, at bad edits or with orphaned fields. A combing detector (IsCombed) checks each frame; where it finds combing, the deinterlaced frame is taken instead of the original. It is an option of VIVTC only.

Settings

Control Parameter Range / values Hybrid default Meaning
(group check box) – on/off off Enables the fix.
Deinterlacer – QTGMC fast / medium / slow / Very Slow, NNEDI3 QTGMC fast Deinterlacer for the replacement frames: QTGMC with the named preset, or NNEDI3.
Threshold cthresh 1 – 256 6 Combing strength threshold.
Block (X/Y) blockx / blocky 4 – 2048 16 / 16 Size of the detection window.
MI mi 0 – Block X × Block Y 64 Combed pixels per block needed for a frame to count as combed.
Metric metric 0 – 1 0 Combing metric.
Chroma chroma on/off off Include chroma in the detection.
Tools – nnedi3 family, or the QTGMC families – Implementations for the chosen deinterlacer.

The detection values are only written when they differ from the defaults (Hybrid's defaults are the plugin's).

Example

VIVTC with default settings and Fix combed with deinterlacer enabled (default settings) on an 8-bit YUV 4:2:0 telecined source (1920x1080, 29.97 fps, detected as top field first):

clip2clip = clip
clip2clip = qtgmc.QTGMC(Input=clip2clip, Preset="fast", tools={'mv': 'mvutensils', 'expr': 'akarin', 'nnedi3': 'znedi3', 'eedi3': 'vszip', 'dfttest': 'neo_fft', 'nlmeans': 'knlm', 'bm3d': 'bm3d', 'rg': 'zsmooth', 'median': 'zsmooth', 'fft3d': 'neo_fft', 'grain': 'noise'}, TFF=True, FPSDivisor=2)
clip = core.vivtc.VFM(clip, order=1)
# VDecimate helper function 
def postprocess(n, f, clip, deinterlaced):
  if f.props['_Combed'] > 0:
    return deinterlaced
  else:
    return clip
clip = core.std.FrameEval(clip=clip, eval=functools.partial(postprocess, clip=clip, deinterlaced=clip2clip), prop_src=clip)
clip = core.vivtc.VDecimate(clip) # new fps: 23.976
# Making sure content is perceived as frame based
clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # scan type: progressive
# Fix combed frames
# adding helper function
def conditionalDeint(n, f, orig, deint):
    if f.props._Combed:
        return deint
    else:
        return orig
clipDeint = qtgmc.QTGMC(Preset="fast", Input=clip, TFF=True, FPSDivisor=2, tools={'mv': 'mvutensils', 'expr': 'akarin', 'nnedi3': 'znedi3', 'eedi3': 'vszip', 'dfttest': 'neo_fft', 'nlmeans': 'knlm', 'bm3d': 'bm3d', 'rg': 'zsmooth', 'median': 'zsmooth', 'fft3d': 'neo_fft', 'grain': 'noise'})
clipCombProps = core.iscombed.IsCombed(clip)
clip = core.std.FrameEval(clip, functools.partial(conditionalDeint, orig=clip, deint=clipDeint), clipCombProps)

How Hybrid calls it

  • Runs on the decimated clip after VIVTC (and after Fix Telecined Fades).
  • Field order: the deinterlacer uses the source's field order (detected scan type or Overwrite input scan type); top field first when it is unknown.
  • QTGMC runs at single rate, so each replacement frame shows the same moment as the frame it replaces. Frame rate and frame count do not change.
  • Works on 8–16-bit YUV.

Background

IsCombed is HolyWu's VapourSynth plugin; it marks combed frames in the frame properties, which a frame-by-frame selection then uses. In AviSynth the same idea is usually built from TIVTC's IsCombedTIVTC and a conditional filter.

Sources