Vapoursynth Flash3kDB

From wiki.selur.net
Revision as of 09:49, 16 November 2026 by Selur (talk | contribs) (Update to current Hybrid behaviour; code as <pre> (via update-page on MediaWiki MCP Server))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Flash3kDB (f3kdb, flash3kyuu_deband) removes banding, the visible steps in smooth gradients, and can add grain so the smoothed areas keep some texture through encoding.

Filtering → Vapoursynth → DeBand

Flash3kDB controls in Hybrid
Flash3kDB controls in Hybrid

What it does

For every pixel a few reference pixels are picked at random positions within Range. If the pixel differs from them by less than the detection threshold, it counts as banded and is replaced by their average; otherwise it stays. Afterwards grain (random dither) is added, which hides the remaining steps and keeps the gradient from banding again after lossy compression.

Settings

Control Parameter Range / values Hybrid default Meaning
Range range 1 – 255 15 Distance in pixels in which the reference pixels are searched.
Threshold (Y/Cb/Cr) y, cb, cr / thr 0 – 511 64 / 64 / 64 Pixels that differ less than this from the references are debanded; higher is stronger and loses more detail. Plugin scale (f3kdb units, independent of the bit depth); 0 = plane is not debanded.
Grain (Y/C) grainy, grainc / grain 0 – 511 64 / 64 Grain added after debanding; 0 = none.
Sample Mode sample_mode 2px column, 4px square, 2px row, 4px average, 4px average plus, 4px average multi-threshold, 4px average angle check 4px square Pattern of the reference pixels: two pixels in a column or row, four in a square, the average of column and row, or one of the detail-preserving 4px average variants: "plus" (several thresholds), "multi-threshold" (mode 6) and "angle check" (mode 7).
Blur first blur_first on/off on On: the pixel is compared with the average of the references; off: every single reference must be within the threshold. Not used (and disabled) with the modes "4px average plus", "multi-threshold" and "angle check" (modes 5 – 7).
dynamic dynamic_grain on/off off New grain pattern in every frame instead of a static one.
Algorithms Ref / Grain random_algo_ref, random_algo_grain old, uniform, gaussian uniform Random generator for the reference positions and for the grain.
Params Ref / Grain random_param_ref, random_param_grain 0 – 255 1.0 Standard deviation of the gaussian generator; only enabled with "gaussian".
Force output bit depth – auto, 8bit, 16bit off (auto) Converts the clip to this bit depth before the filter, so it runs and outputs at that depth; auto = no change.
Tools: F3kdb – vszip, neo_smo vszip Implementation.

Example

Default settings on a 10-bit YUV 4:2:0 source (640x356):

# debanding using f3kdb
clip = core.vszip.Deband(clip, thr=(0.996155,0.996155,0.996155), grain=(0.996155,0.996155), keep_tv_range=True)

How Hybrid calls it

  • Flash3kDB works on YUV and gray clips (8–16-bit integer, with vszip also 32-bit float); vszip also accepts RGB. neo_smo also takes 32-bit float. Other formats are converted.
  • Thresholds and grain are entered in the classic f3kdb units. neo_smo gets them as entered; for vszip they are converted to its 8-bit scale (× 255/16383, so 64 becomes about 0.996) and always written. Neither plugin needs a per-bit-depth scaling.
  • All other values are only written when they differ from the defaults, which are the plugins' own.
  • The TV range flag follows the clip: limited range unless the clip is flagged as full (PC) range.
  • If the chosen implementation is not available, Hybrid falls back to the other one and notes it in the log.
  • Flash3kDB also offers the common options (Masked, ApplyOnlyTo, Merge, OnRegion, Gimmick).

Background

vszip and neo_smo

Both are compiled CPU plugins for Windows, Linux and macOS. vszip's Deband is a reimplementation of f3kdb on an 8-bit threshold scale; neo_smo's F3kdb follows SAPikachu's original flash3kyuu_deband (as neo_f3kdb does for AviSynth+) and uses its classic units. Both plugins also know sample modes 6 and 7 (extra thresholds, angle check).

Gaussian generator

With the gaussian algorithm the parameter is the standard deviation of the random numbers; drawn values outside −1 … 1 are rejected by the plugin. The uniform generator ignores the parameter.

Sources