Log in

View Full Version : Getting error with BalanceBorders()


TheVillageIdiot
13th August 2015, 06:11
Hi,

I am trying to use BalanceBorders to fix some dirty lines, but I get this cache error after loading it -> http://i1.someimage.com/D0klYUG.png

Script -

import("C:\Program Files (x86)\AviSynth 2.5\plugins\BalanceBorders.avs")
FFVideoSource("G:\test.mkv")
BalanceBorders(2,0,0,0,thresh=28)

BalanceBorders.avs is as under :

function BalanceBorders(clip c, int cTop, int cBottom, int cLeft, int cRight, int "thresh", int "blur")
{
Assert(isYV12(c), "This is not an YV12 clip. Convert color space to YV12 before using BalanceBorders().")

thresh = Default(thresh, 128)
blur = Default(blur, 999)

Assert(blur > 0, "Blur parameter in BalanceBorders() must be > 0")
Assert(thresh > 0, "Thresh parameter in BalanceBorders() must be > 0")

c
cTop >0 ? BalanceTopBorder(cTop, thresh, blur).TurnRight() : last.TurnRight()
cLeft >0 ? BalanceTopBorder(cLeft, thresh, blur).TurnRight() : last.TurnRight()
cBottom >0 ? BalanceTopBorder(cBottom, thresh, blur).TurnRight() : last.TurnRight()
cRight >0 ? BalanceTopBorder(cRight, thresh, blur).TurnRight() : last.TurnRight()
}

function BalanceTopBorder(clip c, int cTop, int "thresh", int "blur")
{
cWidth = c.width
cHeight = c.height
cTop = min(cTop,cHeight-1)
blurWidth = max(4,floor(cWidth/blur))

c2 = c.PointResize(cWidth*2,cHeight*2)

c2.\
Crop(0,cTop*2,cWidth*2,2)
PointResize(cWidth*2,cTop*2)
BilinearResize(blurWidth*2,cTop*2)
mt_convolution("1 1 1","0 1 0",y=3,u=3,v=3)
BilinearResize(cWidth*2,cTop*2)
referenceBlur = last

original = c2.Crop(0,0,cWidth*2,cTop*2)

original
BilinearResize(blurWidth*2,cTop*2)
mt_convolution("1 1 1","0 1 0",y=3,u=3,v=3)
BilinearResize(cWidth*2,cTop*2)
originalBlur = last

balanced = mt_lutXYZ(original,originalBlur,referenceBlur,"z y - x +",y=3,u=3,v=3)
difference = mt_makeDiff(balanced,original,y=3,u=3,v=3)

tp = string(128+thresh)
tm = string(128-thresh)
difference = difference.mt_lut("x "+tp+" > "+tp+" x ?",y=3,u=3,v=3)
difference = difference.mt_lut("x "+tm+" < "+tm+" x ?",y=3,u=3,v=3)

mt_addDiff(original,difference,y=3,u=3,v=3)

StackVertical(last,c2.Crop(0,cTop*2,cWidth*2,(cHeight-cTop)*2)).PointResize(cWidth,cHeight)
}

I'm on Avisynth 2.60, How do I fix this? Please help!

*Apologies if this is the incorrect section*

Desbreko
13th August 2015, 07:30
You might have an outdated version of MaskTools2 (http://avisynth.nl/index.php/MaskTools2). Try getting the b1 version, and make sure there are no other masktools dlls in your autoload folder.

TheVillageIdiot
13th August 2015, 07:43
You might have an outdated version of MaskTools2 (http://avisynth.nl/index.php/MaskTools2). Try getting the b1 version, and make sure there are no other masktools dlls in your autoload folder.

That did it, thank you lots! :)