Avisynth SmoothTweak

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

SmoothTweak adjusts brightness, contrast, saturation and the two hue axes like Tweak, but computes in high precision with interpolation and dithering, so that strong changes do not cause banding. It can also weaken the change in dark/bright or low/high saturated areas. It comes from LaTo's SmoothAdjust plugin.

Filtering → Avisynth → Color → Grading

SmoothTweak controls in Hybrid
SmoothTweak controls in Hybrid

What it does

  • Brightness and Contrast change luma (contrast works like Tweak's).
  • Saturation scales the chroma.
  • Hue is given as two shifts instead of an angle: yellow ↔ blue and green ↔ red.
  • LMode limits the change: mode 1 protects dark areas (luma) and weakly saturated areas (chroma), mode 2 bright and highly saturated areas — the latter works like a "vibrance" control.

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

Settings

Control Parameter Range Hybrid default Meaning
Brightness brightness -255–255 0 Negative darkens, positive brightens.
Contrast contrast 0–10 1.00 < 1 lowers, > 1 raises contrast.
Saturation saturation 0–10 1.00 < 1 lowers, > 1 raises saturation.
Hue (yellow/blue) hue1 -255–255 0 Negative towards yellow, positive towards blue.
Hue (green/red) hue2 -255–255 0 Negative towards green, positive towards red.
Limiter limiter on/off off Clamps the result to 16–235 (luma) and 16–240 (chroma).
TV range TVrange on/off on The clip is limited range; only affects LMode.
LMode Lmode no limiting, dark/low saturated, bright/high saturated no limiting Limits the change, see above.
Limit limitSTR 0–200 100 Strength of the LMode limiting.
ECurve Ecurve sine curve, linear curve sine curve Shape of the limiting.
Interpolation strength interp 0–200 100 0 switches interpolation off (faster).
HQ HQ on/off off Higher quality interpolation, slower.
Dither dither -1–100 75 -1 = off, 0 = ordered pattern, 100 = noise.
Force 16bit – on/off off Uses the 16-bit function also for 8-bit clips; Brightness and Hue then take 16-bit values (-65535–65535).
Debug debug on/off off Shows the plugin's internal view; not for encoding. Enables Screen (W/H) and Scale.
Screen (W/H) screenW / screenH -1–8192 -1 / -1 Size of the debug view.

Example

Contrast 1.1 and saturation 1.2 on a 10-bit YUV 4:2:0 source:

# Converting from 10 to 16bit for SmoothTweak
ConvertBits(16)
ConvertToStacked()
SmoothTweak16(contrast=1.10,saturation=1.20)
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 SmoothTweak() directly. For any other bit depth, or with Force 16bit, Hybrid converts to stacked 16 bit, calls SmoothTweak16() and converts back, because the plugin gives wrong results on AviSynth+'s native high bit depth formats.
  • Without Force 16bit, Brightness and Hue are shifted by 8 bits for the 16-bit call.
  • Only values that differ from Hybrid's defaults are written; LMode and ECurve are written as numbers.
  • 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.
  • SmoothTweak 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. It computes in 32-bit float and is multithreaded.

Sources

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