Avisynth sRestore

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

sRestore removes blended frames that come from frame rate conversions and restores the original frame rate. The script is by MOmonster.

Filtering → Avisynth → Frame → Deblend

sRestore controls in Hybrid
sRestore controls in Hybrid

What it does

Standards conversions often mix neighbouring frames (blends) instead of repeating them. sRestore detects the blended frames and either removes them (decimation) or replaces them with a clean neighbour. Typical cases are PAL ↔ NTSC conversions with blends: 50 → 23.976, 25 → 11.988, 59.94 → 25 and 29.97 → 12.5 fps. It can also remove simple blends and double blends without changing the frame rate.

sRestore decides frame by frame in order, so seeking and preview are unreliable; encode linearly.

Requirements

CPU only. Needs MaskTools2, Average, GRunT and a helper script; Hybrid ships them. decimate after also needs the Decomb plugin.

Settings

Control Parameter Range Hybrid default Meaning
Restore – on/off off Enables the filter.
Omode omode 1, 2, 3, 4, 5, 6, pp0, pp1, pp2, pp3 6 Output mode. 1–5 replace a detected blend (1: by the previous frame, 2: by the next, 3: by the neighbour with the smaller difference, 4: by the neighbour with the smaller blend probability, 5: best of four frames) and keep the frame rate. 6: blend decimation, the frame rate changes. pp0–pp3: double-blend removal with post-processing from none (pp0, fastest) to the strongest (pp3, slowest).
Speed speed −25–25 0 Speed against detail. High values examine fewer pixels (25 = one of 25); negative values are for HD or high quality. 0 is the script's own default.
Thresh thresh 1–44 16 Weight of the blend detection; lower for clean sources, higher for noisy or aliased ones.
Mode mode −4, −3, −1, 1, 2, 3, 4 2 1: simple, decimation untouched. 2: duplicate detection, picks the better duplicate. 3: like 2 but merges duplicates. Negative values are variants that also use the chroma planes for detection.
Cache cache −1–10 −1 0 or more uses linear access for non-linear frame requests (needed for unstable patterns at 5–10, costs memory).
Frate frate 0.001–999 off / 24 Target frame rate. The check box enables the value. With omode 6 it is passed to the script; with other omodes Hybrid adds ChangeFPS afterwards.
bob before – on/off off Bobs the clip before sRestore; only for interlaced input, which is accepted then.
decimate after – on/off off Appends decimate(cycle=5,quality=0) (Decomb) after sRestore, only for interlaced input. Rate and frame count drop by 20 %.

Example

Default settings on a 10-bit YUV 4:2:0 source:

# removing ghosting
srestore(omode=6)
Preroll(Int(last.FrameRate()))

How Hybrid calls it

  • Hybrid loads masktools2.dll, Average.dll, GRunT, Zs_RF_Shared.avsi and Srestore.avsi (srestore v2.798). Decomb.dll is added for decimate after.
  • Any YUV format is accepted; Hybrid adds no conversion.
  • omode is always written; speed, mode, thresh and cache only when they differ from the defaults. The pp modes are written as quoted strings.
  • The call order is: optional bob, sRestore, optional ChangeFPS, optional decimate, then Preroll (an AviSynth+ core filter) so that the first frames have their history.
  • Hybrid works out the new frame rate and count for the following steps (omode 6 with the PAL/NTSC special cases or Frate, ×0.8 for decimate, ×2 for bob).
  • For field-shifted PAL-from-NTSC and NTSC-from-PAL material Hybrid can switch sRestore on together with TFM.
  • sRestore also offers the common options and can be added to the filter queue several times.

Background

Srestore.avsi 2.798 goes back to MOmonster. Later changes: unique instance globals and GRunT (martin53), 12-bit fixes (StainlessS), high-bit-depth fixes (AmjadSONY, 2026). Without frate the script targets 1001/2400 of the rate for about 29.97/59.94 fps input, otherwise 480/1001 (50 fps → 23.976 fps). A common forum recipe is srestore(omode="pp0") followed by decimate(cycle=5,quality=0). The script's blocks and second clip parameters are not offered.

See also: Vapoursynth sRestore

Sources