Neo f3kdb

From Avisynth wiki
Jump to: navigation, search
Author SAPikachu, MeteorRain
Version r5v2
Category Debanding
License GPLv2
Discussion Doom9 Thread



Neo_f3kdb is a deband filter. It was originally written for AviUtl by bunyuchan and later ported to AviSynth by SAPikachu.

It works by replacing banded pixels with average value of referenced pixels, and optionally add grain (random dithering) to them. See Wikipedia: Color Banding

Neo f3kdb changes:

  • Legacy format support was removed and a few options that are no longer useful were also removed.
  • Due to API change, the project has been renamed from f3kdb to Neo_f3kdb to avoid confusion.
  • Native high bit depth support in AviSynth+.
  • Dual interface plugin, supports both AviSynth+ and VapourSynth.
  • Add sample_mode 3 and 4.
  • SSE4.1 is now required to run optimized routine. SSE4.1 is supported since Intel Penryn (2007) and AMD bulldozer (2011). AVX routine didn't show much performance benefit and is not included.


  • AviSynth+ (x86/x64)
  • Supported color formats: Y8, YV12, YV16, YV24, [all planar Y/YUV formats (8/10/12/14/16bit) are supported]

Syntax and Parameters

neo_f3kdb (clip, int "range", int "Y", int "Cb", int "Cr", int "grainY", int "grainC", int "sample_mode", int "seed", bool "blur_first", bool "dynamic_grain", int "opt", bool "mt", int "dither_algo", bool "keep_tv_range", int "output_depth", int "random_algo_ref", int "random_algo_grain", float "random_param_ref", float "random_param_grain", string "preset")

clip   =
Input clip.

int  range = 15
Banding detection range.
  • Default: 15

int  Y = 64
int  Cb = 64
int  Cr = 64
Banding detection threshold for respective plane. If difference between current pixel and reference pixel is less than threshold, it will be considered as banded.
  • Default: 64

int  grainY = 64
int  grainC = 64
Specifies amount of grains added in the last debanding stage.
  • Default: 64

int  sample_mode = 2
Valid modes are:
  • 1: Take 2 pixels as reference pixel. Reference pixels are in the same column of current pixel. Add grain after processing.
  • 2: Take 4 pixels as reference pixel. Reference pixels are in the square around current pixel. Add grain after processing.
  • 3: Row references.
  • 4: Average of sample mode 1 and 3.
  • Default: 2

int  seed =
Seed for random number generation.

bool  blur_first = true
  • true: Current pixel is compared with average value of all pixels.
  • false: Current pixel is compared with all pixels. The pixel is considered as banded pixel only if all differences are less than threshold.
  • Default: true

bool  dynamic_grain = false
Use different grain pattern for each frame.
  • Default: false

int  opt = -1
Specifies optimization mode.
  • -1: Use highest optimization mode that is supported by host CPU
  • 0: No optimization (Intended for testing only)
  • 1: SSE2 (Pentium 4, AMD K8)
  • 2: SSSE3 (Core 2)
  • 3: SSE4.1 (Core 2 45nm)
  • Default: -1

int  dither_algo =
  • 1: No dithering, LSB is truncated
  • 2: Ordered dithering
  • 3: Floyd-Steinberg dithering
Visual quality of mode 3 is the best, but the debanded pixels may easily be destroyed by x264, you need to carefully tweak the settings to get better result.
Mode 1 and mode 2 don’t look the best, but if you are encoding at low bitrate, they may be better choice since the debanded pixels is easier to survive encoding, mode 3 may look worse than 1/2 after encoding in this situation.
This parameter is ignored if output_depth = 16.
Default: 3

bool  keep_tv_range = false
If set to true, all processed pixels will be clamped to TV range (luma: 16 ~ 235, chroma: 16 ~ 240).
  • It is recommended to set this to true for TV-range videos, since pixel values may overflow/underflow after dithering.
  • DON’T set this to true for full-range videos, as all out-of-range pixels will be clamped to TV range.
  • Default: false

int  output_depth =
Specify output bit-depth.
If output_depth = 16, dither algorithm specified by dither_algo won’t be applied.
Range: 8 ~ 16
  • Default: 8 (output_mode = 0 or not specified) / 16 (output_mode = 1 or 2)

int  random_algo_ref = 1
int  random_algo_grain = 1
Choose random number algorithm for reference positions / grains.
  • 0: Algorithm in old versions
  • 1: Uniform distribution
  • 2: Gaussian distribution
    • (StdDev (sigma) is settable through random_param_ref / random_param_grain, Only values in [-1.0, 1.0] is used for multiplication, numbers outside this range are simply ignored)
Default: 1 / 1

float  random_param_ref = 1.0
float  random_param_grain = 1.0
Parameter for the respective random number generator. Currently only have effect for the Gaussian generator.

string  preset =
Use preset parameters. Preset will be applied before other parameters so that you can easily override individual parameter.
Name Parameters
depth y=0/cb=0/cr=0/grainy=0/grainc=0
low y=32/cb=32/cr=32/grainy=32/grainc=32
medium y=48/cb=48/cr=48/grainy=48/grainc=48
high y=64/cb=64/cr=64/grainy=64/grainc=64
veryhigh y=80/cb=80/cr=80/grainy=80/grainc=80
nograin grainy=0/grainc=0
luma cb=0/cr=0/grainc=0
chroma y=0/grainy=0
Presets can also be combined together, for example “medium/nograin” is the same as y=48/cb=48/cr=48/grainy=0/grainc=0 .


neo_f3kdb with default settings:



Version      Date            Changes
r5v2 2020/04/13 - Latest release r2 2019/09/20 - Add sample_mode 3 and 4.
r1 2019/09/03 - Added AviSynth+ native high bit depth, based on 2.0 branch. - Supporting YUV4xxP8/P10/P12/P14/P16 and I420. - Dropped support for legacy AviSynth versions.

External Links

  • GitHub - Source code repository.

Back to External Filters

Personal tools