From Avisynth wiki
Jump to: navigation, search
Author Asd-g
Version 1.0.3
Download NNEDI3CL-
Category Deinterlacing
License GPLv2



NNEDI3CL is an OpenCL implementation of nnedi3. It is an intra-field only deinterlacer. It takes a frame, throws away one field, and then interpolates the missing pixels using only information from the remaining field. It has same rate and double rate modes. NNEDI3 is also very good for enlarging images by powers of 2.

This is a port of the VapourSynth plugin NNEDI3CL.


  • [x86] / [x64]: AviSynth+
  • Supported color formats: All planar formats (8/10/12/14/16/32-bit) are supported.
  • The file nnedi3_weights.bin is required. It must be located in the same folder as NNEDI3CL.

Syntax and Parameters

NNEDI3CL (clip input, int field, bool "dh", bool "dw", int[] "planes", int "nsize", int "nns", int "qual", int "etype", int "pscrn", int "device", bool "list_device", bool "info", bool "st")

clip  input =
Input clip; it must be in 8..32-bit planar format.

int  field =
Controls the mode of operation (double vs same rate) and which field is kept.
  • 0 = same rate, keep bottom field
  • 1 = same rate, keep top field
  • 2 = double rate (alternates each frame), starts with bottom
  • 3 = double rate (alternates each frame), starts with top

bool  dh = false
Doubles the height of the input. Each line of the input is copied to every other line of the output and the missing lines are interpolated.
If field=0, the input is copied to the odd lines of the output. If field=1, the input is copied to the even lines of the output.
field must be set to either 0 or 1 when using dh=true.

bool  dw = false
Doubles the width of the input.
field must be set to either 0 or 1 when using dh=true.

int array  planes = [0,1,2]
Sets which planes will be processed.
Planes that are not processed will contain uninitialized memory.

int  nsize = 6
Sets the size of the local neighborhood around each pixel that is used by the predictor neural network.
For image enlargement it is recommended to use 0 or 4. Larger y_diameter settings will result in sharper output. For deinterlacing, larger x_diameter settings will allow connecting lines of smaller slope.
However, what setting to use really depends on the amount of aliasing (lost information) in the source. If the source was heavily low-pass filtered before interlacing then aliasing will be low and a large x_diameter setting wont be needed, and vice versa.
Possible settings (x_diameter x y_diameter):
  • 0 - 8x6
  • 1 - 16x6
  • 2 - 32x6
  • 3 - 48x6
  • 4 - 8x4
  • 5 - 16x4
  • 6 - 32x4

int  nns = 1
Sets the number of neurons in the predictor neural network.
0 is fastest. 4 is slowest, but should give the best quality.
This is a quality vs speed option; however, differences are usually small. The difference in speed will become larger as 'qual' is increased.
  • 0 - 16
  • 1 - 32
  • 2 - 64
  • 3 - 128
  • 4 - 256

int  qual = 1
Controls the number of different neural network predictions that are blended together to compute the final output value.
Each neural network was trained on a different set of training data. Blending the results of these different networks improves generalization to unseen data.
Possible values are 1 or 2. Essentially this is a quality vs speed option. Larger values will result in more processing time, but should give better results.
However, the difference is usually pretty small. I would recommend using qual>1 for things like single image enlargement.

int  etype = 0
Controls which set of weights to use in the predictor nn.
  • 0 - weights trained to minimize absolute error
  • 1 - weights trained to minimize squared error

int  pscrn = 2
Controls whether or not the prescreener neural network is used to decide which pixels should be processed by the predictor neural network and which can be handled by simple cubic interpolation.
The prescreener is trained to know whether cubic interpolation will be sufficient for a pixel or whether it should be predicted by the predictor nn. The computational complexity of the prescreener nn is much less than that of the predictor nn.
Since most pixels can be handled by cubic interpolation, using the prescreener generally results in much faster processing. The prescreener is pretty accurate, so the difference between using it and not using it is almost always unnoticeable.
The new prescreener is faster than the old one, and it also causes more pixels to be handled by cubic interpolation.
  • 1 - old prescreener
  • 2 - new prescreener (unavailable with float input)

int  device =
Sets target OpenCL device.
Use list_device to get the index of the available devices.
By default the default device is selected

bool  list_device = false
Whether to draw the devices list on the frame.

bool  info = false
Whether to draw the OpenCL-related info on the frame.

bool  st = false
Whether to run always in single thread even if prefetch() is used.
In some cases using NNEDI3CL and prefetch() could cause very high cpu usage. In these cases st=true could help without forcing MT_SERIALIZED mode.
Default: false.



NNEDI3CL(1, dh=true) # single rate TFF
#NNEDI3CL(3, dh=true) # double rate TFF

Enlarge by 2x and correct for center shift using Spline36Resize:

NNEDI3CL(1, dh=true, dw=true)
Spline36Resize(Width(), Height(), src_left=-0.5, src_top=-0.5)


Version      Date            Changes
v1.0.3 2022/08/15 - Added parameter st. v1.0.2 2022/07/13 - Fixed memory leak when list_device=true/info=true. v1.0.1 2022/06/26 - Properly handle the clips with one plane only. v1.0.0 2022/06/26 - Initial release.

External Links

  • GitHub - Source code repository.

Back to External Filters

Personal tools