Avisynth ResampleHQ

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

ResampleHQ resizes in linear light with a high-precision pipeline. This avoids the darkening of fine bright detail and edges that resizing gamma-encoded video causes, which shows mostly on strong downscales.

Filtering → Avisynth → Frame → Resize (tick Resizer: and choose ResampleHQ)

ResampleHQ controls in Hybrid
ResampleHQ controls in Hybrid

What it does

Normal resizers average gamma-encoded values, which is not how light adds up; bright thin lines get too dark. ResampleHQ converts to linear light, scales with the chosen kernel and converts back, so the result is closer to a physically correct scaling. It works on 8-bit data only.

Requirements

  • Windows; 64-bit plugin (resamplehq_x64.dll); no GPU needed.

Settings

Control Parameter Values Hybrid default Meaning
Kernel kernel Bicubic, CatmullRom, MitchellNetravali, SoftCubic, Hermite, Robidoux, Bilinear, Blackman, Lanczos, Sinc, Spline16, Spline36, Spline64, Gaussian Spline36 Kernel for luma and RGB.
Chroma Kernel chroma_kernel same list Bilinear Kernel for subsampled chroma (YV12/YUY2). A softer one than the luma kernel rarely hurts. Has no effect on RGB input.
Blur (x/y) kblur_x / kblur_y -10–10 1 / 1 Scales the kernel support. Positive values below 1 sharpen, above 1 blur; negative values set the scale directly.

Example

Default settings on a 10-bit YUV 4:2:0 source (640x352), enlarged to 1280x704. Hybrid reduces the clip to 8 bit for the resize and back to 10 bit afterwards:

# current resolution: 640x352
# Converting from 10 to 8bit for Resize
ConvertBits(8)
# scaling to 1280x704
ResampleHQ(width=1280,height=704)
# Converting from 8 to 10bit for encoder
ConvertBits(10)

How Hybrid calls it

  • ResampleHQ accepts YV12, YUY2, RGB24 and RGB32 at 8 bit. Hybrid converts other formats first: higher bit depths are dithered to 8 bit, YV16 becomes YUY2, YV24 becomes RGB24 and gray becomes YV12. Supported formats stay as they are, and the output keeps its format.
  • For YUV input Hybrid writes srcmatrix from the clip's matrix: Rec.709 as "TV.709", full-range 709 as "PC.709", full-range 601 as "PC.601". For TV.601 and other matrices nothing is written, which means TV.601. The output matrix follows the input matrix.
  • ResampleHQ(width=W, height=H, …); kernel, chroma_kernel, kblur_x and kblur_y are only written when they differ from the defaults (Spline36, Bilinear, 1).
  • ResampleHQ also offers the common options and can be added to the filter queue several times.

Background

  • resamplehq_x64.dll 1.0.0.7 by Cory Nelson (Int64.org), from 2017.
  • The plugin also has the kernel arguments karg1/karg2 and chroma_karg1/chroma_karg2, a dither switch and src_* cropping parameters; Hybrid does not offer them. Defaults inside the plugin: SoftCubic softness 100, Blackman lobes 2, Gaussian p 30.

See also: Vapoursynth ResampleHQ, Avisynth Resizer

Sources