Plugin for Avisynth 2.5
Version 0.2 - 26 October, 2005
Copyright (C)2005 Alexander G. Balakhnin aka Fizick.
http://bag.hotmail.ru
Great motion compensation plugin MVTools by Manao often produces local blocking artifactes on compensated clip.
BlockOverlap plugin deblock it by using two input compensated clips with shifted block positions.
This plugin make blocks windowed overlapping (uniform or kernel non-uniform blending).
It uses high weight of central (kernel) parts of blocks of two frames, and lower weight of edges parts of blocks to form more smooth output frame.
The blending also greatly decreases the noise on compensated frame.
The deblocked and denoised output can improve the temporal motion compensated filtering of original clip.
Of course, the processing speed is halved due to two motion estimation and compensation.
This plugin may be also useful for other filters with block artifactes (Dust, FFT3Dfilter ?).
BlockOverlap
(clip, clip "shifted", int "xblocksize", int "yblocksize",
float "kernel")
first parameter - first input clip
shifted - second clip, its blocks must be shifted by half of block diagonal (no default)
xblocksize - horizontal block size (integer, default=8)
yblocksize - vertical block size (integer, default=8).
kernel - blending window form (float, from 0.0 (uniform) to 1.0 (cosine kernel), default =0.5).
Avisynth command Overlay
with
opacity=0.5. In this mode the filter can not remove all block
artifactes, but it halve them, try use some additional deblock
filter.loadplugin("BlockOverlap.dll") loadplugin("MVTools.dll") function MVOverlap(clip source, int "blksize", float "kernel", bool "isb", int "lambda", bool "chroma", int "delta", int "thSCD1") { # Overlapped block motion compensation by shifted clips processing and windowed blending # Fizick, 2005 # Uses BlockOverlap plugin by Fizick # Uses MVTools plugin by Manao # source clip must have YV12 format, # all other parameters are optional blksize=default(blksize,8) kernel=default(kernel,0.5) isb = default(isb,false) # backward compensation? lambda=default(lambda,2000) # vector smooth chroma=default(chroma,false) # use chroma delta=default(delta,1) # frame step thSCD1=default(thSCD1,300) # scenechange threshold add = (blksize>=8) ? blksize : 8 vec = source.MVAnalyse(blksize=blksize, isb = isb, lambda = lambda, chroma=chroma, delta=delta) comp = source.MVCompensate(vec,thSCD1=thscd1) shifted = source.addborders(blksize/2,blksize/2,add-blksize/2,add-blksize/2) # diagonal shift by half of block vecshifted = shifted.MVAnalyse(blksize=blksize, isb = isb, lambda = lambda, chroma=chroma, delta=delta) compshifted = shifted.MVCompensate(vecshifted, thSCD1=thscd1) compshiftedback = compshifted.crop(blksize/2,blksize/2,blksize/2-add,blksize/2-add) # remove shifting borders ov = BlockOverlap(comp,compshiftedback,xblksize=blksize, yblksize=blksize, kernel=kernel) return ov } avisource("video.avi") src=ConvertToYV12(interlaced=false) # progressive clip example blksize=8 MVOverlap(src, blksize, 0.5, false, 1000, true, 1, 500) # forward overlapped motion compensation
loadplugin("BlockOverlap.dll") loadplugin("MVTools.dll") # use the same MVOverlap function as above # ... put it here loadplugin("degraimedian.dll") # if you use it loadplugin("fft3dfilter.dll") # if you use it AviSource("video.avi") src=ConvertToYV12(interlaced=false) # progressive clip example fo = MVOverlap(src, blksize=8, kernel=0.5, isb=false) # forward overlapped motion compensation bo = MVOverlap(src, blksize=8, kernel=0.5, isb=true) # backward overlapped motion compensation Interleave(fo,src,bo) # 3-length interleaved clip, every source has 2 motion compensated neigbours DegrainMedian(mode=0) # use any temporal 3-frames denoising filter (FluxSmoothT, Despot, etc) fft3dfilter(sigma=2.0) # or more filters SelectEvery(3,1) # get filtered result
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as published by
the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Please consider to make some donation to be registered user.