Interlace

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

Interlace turns progressive video into interlaced video with top or bottom field first, e.g. 50p into 25i. An optional prefilter (BBC R&D White Paper WHP 315) suppresses line twitter and interlacing aliases.

Filtering → (De-)Interlace/Telecine → Interlace

Interlace controls in Hybrid
Interlace controls in Hybrid

What it does

Two progressive frames become one interlaced frame: the first frame (in time) gives one field, the second gives the other. The frame rate and frame count are halved, so 50 progressive frames per second become 25 interlaced frames (50 fields) per second. top field first takes the top field from the first frame, bottom field first the bottom field.

Weaving fields from progressive frames without filtering leaves fine vertical detail that flickers on interlaced displays (line twitter) and shows aliasing. With Prefilter on, a vertical-temporal low-pass filter (19 lines × 5 frames) is applied before the lines are dropped. The filter is shaped by measurements of how sensitive people are to interlacing artifacts, so it removes the visible artifacts while keeping as much detail as possible.

The feature works in the Vapoursynth and the AviSynth branch. Both use the same interlace plugin.

Settings

Control Parameter Range / values Hybrid default Meaning
Interlace – on/off off Convert the progressive input to interlaced output. Only available when the input scan type is progressive (detected or set with Overwrite input scan type).
Field order tff top field first, bottom field first top field first Field order of the output. Only available with Interlace on.
Prefilter filter on/off on Apply the WHP 315 vertical-temporal low-pass before the fields are woven. Off: the fields are woven without filtering. Available with Interlace on, or when progressive input is encoded as interlaced output.

Example

Default settings (top field first, Prefilter on) on a progressive 10-bit YUV 4:2:0 source (640x356, 25 fps, 429 frames); the result has 215 frames at 12.5 fps:

# making sure the detected scan type is set (detected: progressive)
clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # scan type: progressive
# converting full-height progressive to interlaced (top field first)  for 'progressive to interlaced'
clip = misc.Interlace(clip, tff=True, prefilter=True)
# set output frame rate to 12.5fps (top field first)
clip = core.std.AssumeFPS(clip=clip, fpsnum=12000, fpsden=960)

With bottom field first and Prefilter off the line is clip = misc.Interlace(clip, tff=False, prefilter=False).

How Hybrid uses it

  • Vapoursynth: the conversion is the last step of the filter chain, after all filters and resizing. misc.Interlace calls the interlace plugin (core.interlace.Interlace(clip, tff, filter)); if the plugin is not loaded, it weaves the fields with core functions and cannot prefilter.
  • AviSynth: with Prefilter on, Hybrid writes Interlace(tff=…, filter=true); with Prefilter off, a SeparateFields().SelectEvery(4, …).Weave() line.
  • With an odd frame count the last frame is repeated, so the output has half the frames rounded up (Vapoursynth, and AviSynth with Prefilter).
  • The encoder gets the chosen field order; x264, for example, encodes with --tff or --bff.
  • Progressive input with interlaced output set in the encoder is also interlaced at half rate (top field first); the Prefilter setting applies there too.
  • The prefilter is only used for real progressive-to-interlaced conversion. When Hybrid bobs an interlaced source only so that a filter that needs progressive input can run (Filter interlace handling) and the output stays interlaced, the original fields are woven back without the prefilter, because filtering there would change the original fields.
  • Without Vapoursynth or AviSynth, ffmpeg's own interlace filter does the conversion; the Prefilter control has no effect there.
  • Interlace does no spatial scaling; the video must be resized while it is still progressive. In the Vapoursynth branch this is always the case, because the conversion comes after resizing.
  • The plugin works on 8–16-bit integer and 16/32-bit float formats. Each plane height must be even, so 4:2:0 needs a height divisible by 4. It needs at least 2 frames.

Background

BBC WHP 315

BBC R&D White Paper WHP 315 (K. C. Noland, "Optimal Interlacing using Human Sensitivity Measurements", 2016) describes a perceptually optimal interlacing filter: a linear vertical-temporal low-pass applied to the progressive frames before alternate lines are dropped. Its pass-band follows the measured human sensitivity to interlacing aliases from WHP 230. The interlace plugin implements it with the same filter on all planes and no timing shift between luma and chroma. For 4:2:0 it also moves the chroma to the sample positions interlaced 4:2:0 uses, based on the clip's chroma location.

To go the other way (interlaced to progressive) see the deinterlacers, e.g. Vapoursynth QTGMC or Vapoursynth BWDIF. If the input is detected with the wrong scan type, set it with Overwrite input scan type.

Sources