Avisynth SmoothCurve

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

SmoothCurve applies a freely drawn tone curve to the Y, U and V planes separately. The curve is given as control points; the plugin interpolates between them and smooths the result so that the remapping does not create banding. It comes from LaTo's SmoothAdjust plugin.

Filtering → Avisynth → Color → Grading

SmoothCurve controls in Hybrid
SmoothCurve controls in Hybrid

What it does

A curve is a list of control points input-output, separated by semicolons. 0-0;255-255 leaves the plane unchanged. Examples:

  • 0-0;64-48;192-208;255-255: an S-curve, more contrast in the mid tones.
  • 0-16;255-235: full range (PC) to limited range (TV).
  • 0-0;16-0;235-255;255-255: limited range to full range.

Between the points the curve is interpolated linearly or cubically (Mode).

It works on YUV and gray clips (no RGB, no YUY2).

Settings

Control Parameter Range Hybrid default Meaning
Y-Curve / U-Curve / V-Curve Ycurve / Ucurve / Vcurve control points 0–255 0-0;255-255 Curve per plane.
Mode mode 0–100 100 Interpolation between the points: 0 = linear, 100 = cubic.
Interpolation strength interp 0–200 100 Smoothing against banding; 0 switches it off (faster).
Dither dither -1–100 75 -1 = off, 0 = ordered pattern, 100 = noise.
TV Range TVrange off; on, clip values outside TV range; on, process values outside TV range off With TV range the curve ends are 16/235 instead of 0/255.
HQ HQ on/off off Higher quality interpolation, slower.
Force 16bit – on/off off Uses the 16-bit function also for 8-bit clips; the curves then take 16-bit values (default 0-0;65535-65535).
Debug debug on/off off Draws the curve and the settings into the picture; not for encoding. Enables Screen (W/H) and Scale.
Screen (W/H) screenW / screenH -1–8192 -1 / -1 Size of the debug view.

Example

An S-curve on luma (Y-Curve 0-0;64-48;192-208;255-255) on a 10-bit YUV 4:2:0 source; the 8-bit points are scaled to 16 bit:

# Converting from 10 to 16bit for SmoothCurve
ConvertBits(16)
ConvertToStacked()
SmoothCurve16(Ycurve="0-0;16384-12288;49152-53248;65535-65535")
ConvertFromStacked(16)
# Converting from 16 to 10bit for encoder
ConvertBits(10)

How Hybrid calls it

  • Hybrid loads SmoothAdjust.dll (and ConvertStacked.dll for the 16-bit path).
  • 8-bit clips use SmoothCurve() directly. For any other bit depth, or with Force 16bit, Hybrid converts to stacked 16 bit, calls SmoothCurve16() and converts back, because the plugin gives wrong results on AviSynth+'s native high bit depth formats.
  • Without Force 16bit, the 8-bit curve points are scaled for the 16-bit call: 255 becomes 65535, other values are multiplied by 256 (16 becomes 4096, 235 becomes 60160).
  • Only values that differ from Hybrid's defaults are written; TV Range is written as a number (0–2).
  • Accepted formats: gray, YUV 4:1:1, 4:2:0, 4:2:2 and 4:4:4 with even width and height; other formats are converted first.
  • SmoothCurve also offers the common options and can be added to the filter queue several times.

Background

SmoothAdjust (last version 3.20, 2015) by LaTo contains SmoothLevels, SmoothTweak, SmoothCurve and further tools, each with a 16-bit (stacked) variant. SmoothCurve exists since version 1.00 (2010); the smoother interpolation and the HQ mode were added later.

Sources

  • Doom9: SmoothAdjust thread (LaTo; parameter list, curve syntax and formats)
  • Hybrid's tooltips
  • The AviSynth+ documentation does not cover SmoothAdjust.