# Yadif

## Abstract

author: Fizick (Alexander Balakhnin)
version: 1.7
download: http://avisynth.org.ru/
category: Deinterlacing & Pulldown Removal
requirements:YV12, YUY2 color formats
license: GPL

Port of YADIF (Yet Another DeInterlacing Filter) from MPlayer by Michael Niedermayer (http://www.mplayerhq.hu). It check pixels of previous, current and next frames to re-create the missed field by some local adaptive method (edge-directed interpolation) and uses spatial check to prevent most artifacts.

## Syntax and parameters

`Yadif` (clip, int "mode", int "order", bool "planar", int "opt")

mode = 0 : temporal and spatial interlacing check (default).

= 1 : double framerate (bob), temporal and spatial interlacing check.

= 2 : skips spatial interlacing check.

= 3 : double framerate (bob), skips spatial interlacing check.

order = -1 : field order as Avisynth assumes (default).

= 0 : Bottom field first.

= 1 : Top field first.

planar = false : usual Avisynth pixel format (default).

= true : flag (ignored for YV12) for (hacked) planar YUY2 color format of input and output clips, compatible with Interleaved2planar and Planar2Interleaved functions from RemoveGrain (SSETools) plugin by Kassandro (for excluding of several conversions).

opt = -1 : CPU optimization - auto (default).

= 0 : slow C version.

= 1 : Integer SSE.

= 2 : SSE2.

= 3 : SSSE3 (some).

## Features and limitations

Implemented as Avisynth C-plugin (not regular Avisynth plugin).
Must be loaded with Load_Stdcall_plugin("yadif.dll") or LoadCplugin("yadif.dll") (not LoadPlugin !). Do not use autoloading. (Note: in Avisynth v2.5.7-2.5.8 there is no need in explicit loading of Avisynth_c.dll by user for such plugins.)

Tested in Avisynth v2.5.7, v2.5.8 (probably works with v2.5.6 and above).

Field parity of source clip must be properly set (use AssumeTFF, AssumeBFF).

Very fast. Assembler SSEMMX optimization from Mplayer (compiled with MinGW GCC). Also SSE2 (some SSSE3) from ffdshow-tryout (fixed).

YV12 planar, YUY2 (both usual and planar) color formats only.

## Discussion

http://forum.doom9.org/showthread.php?t=124284

## License

This plugin is free software released under the GNU GPL license v2 (see file gpl.txt). If you redistribute binary DLL file, then you must also redistribute source code files, gpl.txt license, and please do no forget this documentation file.

## Revisions

Version 0.1 (03.04.2007)

- First version

Version 0.2 (04.04.2007)

- Fixed bug with wrong used parity.
- Added Bob mode=1,3.
- Added order parameter.

Version 0.3 (06.04.2007)

- Finally (?) fixed bug with wrong used parity.
- Set correct FPS for Bob modes.

Version 0.4 (11.04.2007)

- Finally (!) fixed bug with wrong used parity for TFF without AssumeTFF.
- Removed limitation on frames pitches equality.

Version 0.5 (17.04.2007)

- Fixed bug with very first and very last frames.

Version 0.6 (07.05.2007)

- Added YUY2 color format.

Version 0.7 (31.05.2007)

- Processing of first and last lines by spatial average or duplicate (requested by puddy).

Version 0.8 (17.06.2007)

- Probably fixed memory access bug (report by akapuma).

Version 0.9 (22.07.2007)

- Fixed memory access bug some width and height and YUY2 (report by ronnylov).

Version 1.1 (06.08.2009)

- Added faster SSE2 (and some SSSE3) custom optimization by H.Yamagata from ffdshow-tryout. Compiled with GCC versions above 4.1.
- Added a little faster MMX conversion for YUY2 format.
- Added planar hacked YUY2 color format (compatible with SSETools by Kassandro).

Version 1.2 (07.08.2009)

- A little faster SSEMMX conversion for YUY2 format.

Version 1.3 (12.08.2009)

- Added "opt" parameter for manual selecting of CPU optimization.
- Fixed bug in SSE2/SSSE3 code (from ffdshow), now results are same as C/iSSE.

Version 1.4 (13.08.2009)

- Enabled SSEMMX YUY2 conversion for forced SSE2/SSSE3 opt.

Version 1.5 (16.08.2009)

- Fixed detection of SSSE3 (thanks to Shingo Harada for bug report for Athlon).

Version 1.6 (25.08.2009)

- Blind attempt to fix detection of Phenom cpu (thanks to canTsTop for bug report).

Version 1.7 (08.10.2009)

- Blind attempt to fix detection of P4 cpu (thanks to vlada for bug report).

### Download Yadif version 1.7