Smooth Deinterlacer

SmoothDeinterlace.dll contains an adaptive deinterlacer plugin for (AVISynth). It is based on Gunnar Thalin's Smooth Deinterlace plugin for VirtualDub.

Download the latest version for AviSynth 2.5x with support for RGB32, YUY2 and YV12 colorspaces here
or version 1.4 for AviSynth 2.0x here.

Versions 1.0 - 1.4 were developed by Xesdeeni (Xesdeeni2001 at yahoo dot com).
Additions made in versions 1.5 - 1.5.4 were developed by Mikola (niko1999s at mail dot ru).

 

Version 1.5.5

Version 1.5.4

Version 1.5.3

Version 1.5.2

Version 1.5 beta

Version 1.4

New Features:

Version 1.3

Version 1.2

New Features:

Version 1.1

Version 1.0

Features:

Parameters (liberally stolen from Gunnar's description):

Usage

LoadPlugin("SmoothDeinterlacer.dll")
AVISource("Test.avi")
SmoothDeinterlace()
or
LoadPlugin("SmoothDeinterlacer.dll")
AVISource("Test.avi")
SmoothDeinterlace(tff=true, doublerate=true)

Background

I originally searched for an adaptive deinterlacer to assist me in doing standards conversion (PAL->NTSC & NTSC->PAL; see below). I tried several, but I found Gunnar Thalin's Area-Based Deinterlacer plugin for VirtualDub to be the best.

I used AVISynth's support of VirtualDub plugins to create an AVISynth script that would do the standards conversion for me. The results were outstanding! (if a little slow)

However, I had to work around the fact that the Area-Based Deinterlacer only output at the same frame rate as the input. (I also had to work around an AVISynth bug in ChangeFPS(), which has been fixed as of version 2.0.6.) The technique I used for the standards conversion required that I get double the frame rate from the deinterlacer. This was not an option for any VirtualDub plugin, so I decided to port the deinterlacer to an AVISynth plugin, which would support a modification to deliver frames at double the input rate.

After getting this working, I also decided to modify the code to support the YUV format. This made sense, since most sources are in YUV. It also sped up the operation of the deinterlacer, because it removed an internal conversion to luminance that was now not necessary. My conversions were now taking half the time they had taken before!

I wanted to update the standards conversion script for anyone interested, but this involved providing the modified deinterlacer as well. With this in mind, I contacted Gunnar. He was very gratious, but pointed out that his new Smooth Deinterlacer was better and it also output at double the input frame rate. I gave it a try and found that it was what I was looking for. However, I was now spoiled by the extra speed of the AVISynth, YUV version. So I then undertook porting the Smooth Deinterlacer to AVISynth.

Along the way, I made a few minor modifications to the operation. I added a switch to allow the output to be either at the frame rate or at double the frame rate. I also adapted the field polarity issues Gunnar faced in VirtualDub to the different environment in AVISynth. And I did some trickery to remove the requirement that the input be sequential fields (it will actually take fields or frames).

But the baseline algorithm, and indeed most of the actual lines of code, were liberally stolen from Gunnar's source :-) So although I can be held responsible for the AVISynth port, please give Gunnar all due credit for the algorithm itself. Also, thank him for gratiously hosting this page.

Standards Conversion

I had initially intended to segregate my particular use for this deinterlacer from the deinterlacer itself. But at Gunnar's urging, I'm including the standards conversion scripts below. I will release a bit more user-friendly version separately, but this will get the more technical of you on your way.

NOTE 1: These scripts are meant to convert truly interlaced (or hybrid) video. You will achieve MUCH higher quality with progressive content (film) using other methods. See vcdhelp.com or doom9.net for guides.

NOTE 2: I prefer ChangeFPS() when going from PAL to NTSC. This AVISynth filter replicates frames to achieve the new frame rate. This is faster than the ConvertFPS() filter, and it does not introduce the "jutter" common to much converted video, caused by blending of adjacent fields. It does cause a stutter due to the replicated frame (actually, a field), but as hard as I try, I cannot see it. This may be because those of us that watch NTSC are used to the 3:2 pulldown conversion of film to video, which contains the same type of stutter. However, when converting from NTSC to PAL, ChangeFPS() drops frames. This is much less desirable, so I recommend ConvertFPS() when converting in this direction. Perhaps my PAL-land based friends can take a look for themselves and let me know what they think.
# PAL DV (50 fps) to NTSC DV (59.94 fps)
LoadPlugin("SmoothDeinterlacer.dll")
AVISource("PALDV.avi")
SmoothDeinterlace(tff=false, doublerate=true)
BilinearResize(720, 480)
ChangeFPS(59.94)
SeparateFields()
SelectEvery(4, 0, 3)

# NTSC DV (59.94 fps) to PAL DV (50 fps)
LoadPlugin("SmoothDeinterlacer.dll")
AVISource("NTSCDV.avi")
SmoothDeinterlace(tff=false, doublerate=true)
BilinearResize(720, 576)
ConvertFPS(50)
SeparateFields()
SelectEvery(4, 0, 3)

# PAL DVD (50 fps) to NTSC DVD (59.94 fps)
LoadPlugin("SmoothDeinterlacer.dll")
LoadPlugin(PluginPath + "MPEG2DEC.dll")
InputVideo = MPEG2Source("PALDVD.d2v")
SmoothDeinterlace(tff=true, doublerate=true)
BilinearResize(720, 480)
ChangeFPS(59.94)
SeparateFields()
SelectEvery(4, 1, 2)

# NTSC DVD (59.94 fps) to PAL DVD (50 fps)
LoadPlugin("SmoothDeinterlacer.dll")
LoadPlugin(PluginPath + "MPEG2DEC.dll")
InputVideo = MPEG2Source("NTSCDVD.d2v")
SmoothDeinterlace(tff=true, doublerate=true)
BilinearResize(720, 576)
ConvertFPS(50)
SeparateFields()
SelectEvery(4, 1, 2)