F3kdb

From Avisynth wiki
Jump to: navigation, search
Abstract
Author SAPikachu
Version v1.5.1 / v2.0
Download [x86]: flash3kyuu_deband_1.5.1_x86.7z

[x64]: flash3kyuu_deband_1.5.1_x64.7z


2.0pre2 [x86/x64]


Category Debanding
License GPLv2
Discussion Doom9 Thread

Contents

[edit] Description

f3kdb (a.k.a. flash3kyuu_deband) is a deband library and AviSynth / VapourSynth filter. It was originally written for AviUtl by bunyuchan a.k.a flash3kyuu.

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

  • For native AviSynth+ high bit-depth support and a few more features, see neo_f3kdb.


[edit] Requirements


[edit] Syntax and Parameters

f3kdb (clip c, 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 "input_mode", int "input_depth", int "output_mode", 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.
  • 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


bool  mt =
Only available in AviSynth
Multi-threaded processing. If set to true, U and V plane will be proccessed in parallel with Y plane to speed up processing.
Default: true if host has more than 1 CPU/cores, false otherwise.


int  dither_algo =
  • 1: No dithering, LSB is truncated
  • 2: Ordered dithering
  • 3: Floyd-Steinberg dithering
Notes:
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  input_mode =
Specify source video type.
  • 0 : Regular 8 bit video
  • 1 : 9 ~ 16 bit high bit-depth video, stacked format (Stack16)
  • 2 : 9 ~ 16 bit high bit-depth video, interleaved format
Default: 0 (input_depth = 8 or not specified) / 1 (input_depth > 8)


int  input_depth =
Specify bit-depth of source video.
Range: 8 ~ 16
Default: 8 (input_mode = 0 or not specified) / 16 (input_mode = 1 or 2)


int  output_mode =
Specify output video type. Meaning of values are the same as input_mode.
When output_mode = 2, frames will be 2x wider and look garbled on preview, it will return to normal after correctly encoded by high bit-depth x264).
Default: 0 (output_depth = 8 or not specified) / 1 (output_depth > 8)


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 .


[edit] Examples

f3kdb with default settings:

AviSource("blah.avi")
f3kdb()


[edit] Changelog

2.0.0
* Support VapourSynth natively
* New parameter: preset
* C++ API support
* Dropped YUY2 support, please process in YV16 instead
* Dropped f3kdb_dither, please use f3kdb(preset="depth", ...) for bitdepth conversion
* Dropped several deprecated parameter values (sample_mode=0 and dither_algo=0)

1.5.1 (2012-04-07)
* Supports setting StdDev (sigma) for the Gaussian random number generator

1.5.0 (2012-03-12)
* (There isn't any new feature in this version, only some parameters are modified to reduce user confusion)
* ditherY/ditherC are renamed to grainY/grainC
* dynamic_dither_noise is renamed to dynamic_grain
* precision_mode is renamed to dither_algo, mode 4 and 5 are removed
* random_algo_dither is renamed to random_algo_grain
* enable_fast_skip_plane is removed, this optimization will be enabled mplicitly whenever possible (Filter result won't be changed by this optimization)

1.4.2 (2011-11-10)
* Fixed crash on some non-mod16 videos

1.4.1 (2011-11-05)
* Fixed broken YUY2 support (still slow)
* Improved default value handling of bitdepth-related parameters
* precision_mode 4 / 5 are now deprecated and may be removed in future versions, you can use output_mode 1 / 2 to achieve the same result

1.4.0 (2011-10-30)
* 9 ~ 16 bit-depth input/output
** Related parameters: input_mode/input_depth/output_mode/output_depth
* New random number generator, reference position and dither noise can be generated in uniform or gaussian distribution
** Related parameters: random_algo_ref / random_algo_dither
* diff_seed is replaced with dynamic_dither_noise, when enabled, noise pattern will be different for each frame
* Another new parameter: enable_fast_skip_plane
* Short filter alias: f3kdb
* Now the ICC-compiled DLL should be runnable on pre-SSE2 systems (untested)
* Several bug fixes

1.3.0 (2011-09-07)
* Added x64 version
* Added a downsample filter: f3kdb_dither
* Internal precision is increased to 16bit
* New parameter: keep_tv_range, please see readme.txt for details
* Default sample_mode is changed to 2 as it is better in most cases
* Fixed: Floyd-Steinberg dithering may produce incorrect result for full-range videos
* Fixed: Broken YUY2 debanding
* Minor optimizations

1.2.0 (2011-08-01)
* Added support for YUY2 (not optimized yet)
* Added support for all planar YUV format in AviSynth 2.6
* The filter is now compatible with both AviSynth 2.5 and 2.6
* 16bit output (precision_mode = 4/5)
* Note: The internal processing precision is still 14bit, this will be
improved in future versions

1.1.0 (2011-06-18)
* Fixed a bug that high threshold values would produce incorrect result in high precision modes.
* Threshold values was scaled based on other parameter in previous versions, it is unscaled now to increase flexibility. 
  Using same value has weaker effect in new version. Effect of default parameter set is also changed.
* SSE optimization for high precision mode.
* Rejects some invalid parameter combination instead of silently skips them

1.0.2
* High precision mode
(currently non-optimized, SSE routine will be added later)
* Frame edges are properly processed now
* Fix crash in some cases (unaligned frames are handled correctly)
* Other bug fixes


[edit] Archived Downloads

Version Download
2.0pre2 [x86/x64]
v1.5.1

[x86]:


[x64]:


[edit] External Links

  • GitHub - Source code repository.




Back to External Filters


Personal tools