Log in

View Full Version : Jeremy Duncan's version of Seesaw and Limitedsharpenfaster


Jeremy Duncan
8th November 2008, 03:33
ntsc version
Meant for standard definition dvd.

Quad core version


# SeeSaw( modified for standard definition dvds and quad core cpus. by jeremy duncan november 11, 2008 )
# If you don't use supersampling there is no difference between the dual and quad core versions.
#
# (Full Name: "Denoiser-and-Sharpener-are-riding-the-SeeSaw" )
#
# This function provides a (simple) implementation of the "crystality sharpen" principle.
# In conjunction with a user-specified denoised clip, the aim is to enhance
# weak detail, hopefully without oversharpening or creating jaggies on strong
# detail, and produce a result that is temporally stable without detail shimmering,
# while keeping everything within reasonable bitrate requirements.
# This is done by intermixing source, denoised source and a modified sharpening process,
# in a seesaw-like manner.
#
# This version is considered alpha.
#
# Usage:
#
# a = TheNoisySource
# b = a.YourPreferredDenoising()
# SeeSaw( a, b, [parameters] )
#
# You're very much encouraged to feed your own custom denoised clip into SeeSaw.
# If the "denoised" clip parameter is omitted, a simple "spatial pressdown" filter is used.
#
#
# Fiddled together by Didée, for your pleasure.
#
# - If you use a different resolution than standard definition dvd. Disable supersampling ssx setting it to 1.0


# ======= Main function =======

function SeeSaw( clip clp, clip "denoised",
\ int "NRlimit",int "NRlimit2",
\ float "Sstr", int "Slimit", float "Spower", float "SdampLo", float "SdampHi", float "Szp",
\ float "bias", int "Smode", int "sootheT", int "sootheS", float "ssx", float "ssy")
{
ssx = default( ssx, 1.00 ) # supersampling factor x / for ntsc supersampling set this to 1.24. For pal supersampling set this to 1.17
# for a superspeed, set ssx to 1.0

ssy = default( ssy, ssx ) # supersampling factor y / if at all, small values ~1.25 seem to be enough.
NRlimit = default( NRlimit, 0 ) # absolute limit for pixel change by denoising
NRlimit2 = default( NRlimit2, 5 ) # limit for intermediate denoising
Sstr = default( Sstr, 1.30 ) # Sharpening strength (don't touch this too much)
Slimit = default( Slimit, 40 ) # positive: absolute limit for pixel change by sharpening
# negative: pixel's sharpening difference is reduced to diff=pow(diff,1/abs(limit))
Spower = default( Spower, 1 ) # exponent for modified sharpener
Szp = default( Szp, 1 ) # zero point - below: overdrive sharpening - above: reduced sharpening
SdampLo = default( SdampLo, 25 ) # reduces overdrive sharpening for very small changes
SdampHi = default( SdampHi, 52 ) # further reduces sharpening for big sharpening changes. Try 15~30. "0" disables.
bias = default( bias, 49 ) # bias towards detail ( >= 50 ) , or towards calm result ( < 50 )
Smode = default( Smode, ssx<1.35 ? 11 : ssx<1.51 ? 20 : 19 )
sootheT = default( sootheT, 55 ) # 0=minimum, 100=maximum soothing of sharpener's temporal instableness.
# (-100 .. -1 : will chain 2 instances of temporal soothing.)
sootheS = default( sootheS, 0 ) # 0=minimum, 100=maximum smoothing of sharpener's spatial effect.

Szp = Szp / pow(Sstr, 1.0/4.0) / pow( (ssx+ssy)/2.0, 1.0/2.0 )
SdampLo = SdampLo / pow(Sstr, 1.0/4.0) / pow( (ssx+ssy)/2.0, 1.0/2.0 )

ox=clp.width
oy=clp.height
xss = md(ox*ssx)
yss = md(oy*ssy)
NRL = string( NRlimit )
NRL2 = string( NRlimit2 )
NRLL = string( int(round( NRlimit2 * 100.0/bias - 1.0 )) )
SLIM = string( abs(Slimit) )
BIAS1 = string( bias )
BIAS2 = string( 100-bias )
#ZRP = string( abs(Szp) )
#PWR = string( abs(Spower) )
#DMP = string( SdampLo )

denoised = defined(denoised) ? denoised : mt_lutxy(clp,clp.removegrain(1,-1),"x "+NRL+" + y < x "+NRL+" + x "+NRL+" - y > x "+NRL+" - y ? ?",chroma="copy first")

NRdiff = mt_makediff(clp,denoised,chroma="process")
tame = mt_lutxy(clp,denoised,"x "+NRLL+" + y < x "+NRL2+" + x "+NRLL+" - y > x "+NRL2+" - x "+BIAS1+" * y "+BIAS2+" * + 100 / ? ?")
head = tame.sharpen2(Sstr,Spower,Szp,SdampLo,SdampHi,4)
# head = head.mt_merge(tame,tame.prewitt(multiplier=1.0).mt_expand().removegrain(1))

(ssx==1.0 && ssy==1.0) ? repair(tame.sharpen2(Sstr,Spower,Szp,SdampLo,SdampHi,Smode),head,1,-1,-1)
\ : repair(tame.MT("spline64resize(xss, last.height)",4).MT("spline64resize(last.width, yss)",5, splitvertical=true).sharpen2(Sstr,Spower,Szp,SdampLo,SdampHi,Smode),head.MT("bicubicresize(xss, last.height)",4).MT("bicubicresize(last.width, yss,0.75,1.0)",5, splitvertical=true),1,-1,-1).lanczosresize(ox,oy)

SootheSS(last,tame,sootheT,sootheS)
sharpdiff= mt_makediff(tame,last)

(NRlimit==0) ? clp : \
mt_lutxy(clp,NRdiff, "y 128 "+NRL+" + > x "+NRL+" - y 128 "+NRL+" - < x "+NRL+" + x y 128 - - ? ?",chroma="process")

Slimit>=0 ? mt_lutxy(last,sharpdiff,"y 128 "+SLIM+" + > x "+SLIM+" - y 128 "+SLIM+" - < x "+SLIM+" + x y 128 - - ? ?",chroma="copy first")
\ : mt_lutxy(last,sharpdiff,"y 128 == x x y 128 - abs 1 "+SlIM+" / ^ y 128 - y 128 - abs / * - ?",chroma="copy first")

return( last )
}


# ======= Modified sharpening function =======

function sharpen2(clip clp, float strength, int power, float zp, float lodmp, float hidmp, int rgmode)
{
STR = string( strength )
PWR = string( 1.0/float(power) )
ZRP = string( ZP )
DMP = string( lodmp )
HDMP = (hidmp==0) ? "1" : "1 x y - abs "+string(hidmp)+" / 4 ^ +"

mt_lutxy( clp, clp.RemoveGrain(rgmode,-1,-1), \
"x y == x x x y - abs "+ZRP+" / "+PWR+" ^ "+ZRP+" * "+STR+" * x y - 2 ^ x y - 2 ^ "+DMP+" + / * x y - x y - abs / * "+HDMP+" / + ?",chroma="copy first")
return( last )
}


# ======= Soothe() function to stabilze sharpening =======

function SootheSS(clip sharp, clip orig, int "sootheT", int "sootheS")
{
sootheT = default(sootheT, 25 )
sootheS = default(sootheS, 0 )
sootheT = (sootheT > 100) ? 100 : (sootheT < -100) ? -100 : sootheT
sootheS = (sootheS > 100) ? 100 : (sootheS < 0) ? 0 : sootheS
ST = string( 100 - abs(sootheT))
SSPT = string( 100 - abs(sootheS))

mt_makediff(orig,sharp)

(sootheS==0) ? last
\ : mt_lutxy( last, last.removegrain(1,-1,-1),
\ "x 128 - y 128 - * 0 < x 128 - 100 / "+SSPT+" * 128 + x 128 - abs y 128 - abs > x "+SSPT+" * y 100 "+SSPT+" - * + 100 / x ? ?", chroma="ignore")

(sootheT==0) ? last
\ : mt_lutxy( last, last.temporalsoften(1,255,0,32,2),
\ "x 128 - y 128 - * 0 < x 128 - 100 / "+ST+" * 128 + x 128 - abs y 128 - abs > x "+ST+" * y 100 "+ST+" - * + 100 / x ? ?", chroma="ignore")

(sootheT > -1) ? last
\ : mt_lutxy( last, last.temporalsoften(1,255,0,32,2),
\ "x 128 - y 128 - * 0 < x 128 - 100 / "+ST+" * 128 + x 128 - abs y 128 - abs > x "+ST+" * y 100 "+ST+" - * + 100 / x ? ?",chroma="ignore")

mt_makediff(orig,last)
# mergechroma(sharp) # not needed in SeeSaw
return( last )
}


# ======= MODd-and-atleast-16 helper function =======

function md(float x) {x<16?16:int(round(x/5)*12)} # for pal supersampling set the number 5 to 4

dual core


# SeeSaw ( modified for standard definition dvds and dual core cpus. by jeremy duncan november 11, 2008 )
# If you don't use supersampling there is no difference between the dual and quad core versions.
#
# (Full Name: "Denoiser-and-Sharpener-are-riding-the-SeeSaw" )
#
# This function provides a (simple) implementation of the "crystality sharpen" principle.
# In conjunction with a user-specified denoised clip, the aim is to enhance
# weak detail, hopefully without oversharpening or creating jaggies on strong
# detail, and produce a result that is temporally stable without detail shimmering,
# while keeping everything within reasonable bitrate requirements.
# This is done by intermixing source, denoised source and a modified sharpening process,
# in a seesaw-like manner.
#
# This version is considered alpha.
#
# Usage:
#
# a = TheNoisySource
# b = a.YourPreferredDenoising()
# SeeSaw( a, b, [parameters] )
#
# You're very much encouraged to feed your own custom denoised clip into SeeSaw.
# If the "denoised" clip parameter is omitted, a simple "spatial pressdown" filter is used.
#
#
# Fiddled together by Didée, for your pleasure.
#
# - If you use a different resolution than standard definition dvd. Disable supersampling ssx by setting it to 1.0


# ======= Main function =======

function SeeSaw( clip clp, clip "denoised",
\ int "NRlimit",int "NRlimit2",
\ float "Sstr", int "Slimit", float "Spower", float "SdampLo", float "SdampHi", float "Szp",
\ float "bias", int "Smode", int "sootheT", int "sootheS", float "ssx", float "ssy")
{
ssx = default( ssx, 1.0 ) # supersampling factor x / Set this to 1.24 for ntsc supersampling. Set this to 1.17 for Pal supersampling.
# for a superspeed, set ssx to 1.00

ssy = default( ssy, ssx ) # supersampling factor y / if at all, small values ~1.25 seem to be enough.
NRlimit = default( NRlimit, 0 ) # absolute limit for pixel change by denoising
NRlimit2 = default( NRlimit2, 5 ) # limit for intermediate denoising
Sstr = default( Sstr, 1.30 ) # Sharpening strength (don't touch this too much)
Slimit = default( Slimit, 40 ) # positive: absolute limit for pixel change by sharpening
# negative: pixel's sharpening difference is reduced to diff=pow(diff,1/abs(limit))
Spower = default( Spower, 1 ) # exponent for modified sharpener
Szp = default( Szp, 1 ) # zero point - below: overdrive sharpening - above: reduced sharpening
SdampLo = default( SdampLo, 25 ) # reduces overdrive sharpening for very small changes
SdampHi = default( SdampHi, 52 ) # further reduces sharpening for big sharpening changes. Try 15~30. "0" disables.
bias = default( bias, 49 ) # bias towards detail ( >= 50 ) , or towards calm result ( < 50 )
Smode = default( Smode, ssx<1.35 ? 11 : ssx<1.51 ? 20 : 19 )
sootheT = default( sootheT, 55 ) # 0=minimum, 100=maximum soothing of sharpener's temporal instableness.
# (-100 .. -1 : will chain 2 instances of temporal soothing.)
sootheS = default( sootheS, 0 ) # 0=minimum, 100=maximum smoothing of sharpener's spatial effect.

Szp = Szp / pow(Sstr, 1.0/4.0) / pow( (ssx+ssy)/2.0, 1.0/2.0 )
SdampLo = SdampLo / pow(Sstr, 1.0/4.0) / pow( (ssx+ssy)/2.0, 1.0/2.0 )

ox=clp.width
oy=clp.height
xss = md(ox*ssx)
yss = md(oy*ssy)
NRL = string( NRlimit )
NRL2 = string( NRlimit2 )
NRLL = string( int(round( NRlimit2 * 100.0/bias - 1.0 )) )
SLIM = string( abs(Slimit) )
BIAS1 = string( bias )
BIAS2 = string( 100-bias )
#ZRP = string( abs(Szp) )
#PWR = string( abs(Spower) )
#DMP = string( SdampLo )

denoised = defined(denoised) ? denoised : mt_lutxy(clp,clp.removegrain(1,-1),"x "+NRL+" + y < x "+NRL+" + x "+NRL+" - y > x "+NRL+" - y ? ?",chroma="copy first")

NRdiff = mt_makediff(clp,denoised,chroma="process")
tame = mt_lutxy(clp,denoised,"x "+NRLL+" + y < x "+NRL2+" + x "+NRLL+" - y > x "+NRL2+" - x "+BIAS1+" * y "+BIAS2+" * + 100 / ? ?")
head = tame.sharpen2(Sstr,Spower,Szp,SdampLo,SdampHi,4)
# head = head.mt_merge(tame,tame.prewitt(multiplier=1.0).mt_expand().removegrain(1))

(ssx==1.0 && ssy==1.0) ? repair(tame.sharpen2(Sstr,Spower,Szp,SdampLo,SdampHi,Smode),head,1,-1,-1)
\ : repair(tame.MT("spline64resize(xss, last.height)",2).MT("spline64resize(last.width, yss)",3, splitvertical=true).sharpen2(Sstr,Spower,Szp,SdampLo,SdampHi,Smode),head.MT("bicubicresize(xss, last.height)",2).MT("bicubicresize(last.width, yss,0.75,1.0)",3, splitvertical=true),1,-1,-1).lanczosresize(ox,oy)

SootheSS(last,tame,sootheT,sootheS)
sharpdiff= mt_makediff(tame,last)

(NRlimit==0) ? clp : \
mt_lutxy(clp,NRdiff, "y 128 "+NRL+" + > x "+NRL+" - y 128 "+NRL+" - < x "+NRL+" + x y 128 - - ? ?",chroma="process")

Slimit>=0 ? mt_lutxy(last,sharpdiff,"y 128 "+SLIM+" + > x "+SLIM+" - y 128 "+SLIM+" - < x "+SLIM+" + x y 128 - - ? ?",chroma="copy first")
\ : mt_lutxy(last,sharpdiff,"y 128 == x x y 128 - abs 1 "+SlIM+" / ^ y 128 - y 128 - abs / * - ?",chroma="copy first")

return( last )
}


# ======= Modified sharpening function =======

function sharpen2(clip clp, float strength, int power, float zp, float lodmp, float hidmp, int rgmode)
{
STR = string( strength )
PWR = string( 1.0/float(power) )
ZRP = string( ZP )
DMP = string( lodmp )
HDMP = (hidmp==0) ? "1" : "1 x y - abs "+string(hidmp)+" / 4 ^ +"

mt_lutxy( clp, clp.RemoveGrain(rgmode,-1,-1), \
"x y == x x x y - abs "+ZRP+" / "+PWR+" ^ "+ZRP+" * "+STR+" * x y - 2 ^ x y - 2 ^ "+DMP+" + / * x y - x y - abs / * "+HDMP+" / + ?",chroma="copy first")
return( last )
}


# ======= Soothe() function to stabilze sharpening =======

function SootheSS(clip sharp, clip orig, int "sootheT", int "sootheS")
{
sootheT = default(sootheT, 25 )
sootheS = default(sootheS, 0 )
sootheT = (sootheT > 100) ? 100 : (sootheT < -100) ? -100 : sootheT
sootheS = (sootheS > 100) ? 100 : (sootheS < 0) ? 0 : sootheS
ST = string( 100 - abs(sootheT))
SSPT = string( 100 - abs(sootheS))

mt_makediff(orig,sharp)

(sootheS==0) ? last
\ : mt_lutxy( last, last.removegrain(1,-1,-1),
\ "x 128 - y 128 - * 0 < x 128 - 100 / "+SSPT+" * 128 + x 128 - abs y 128 - abs > x "+SSPT+" * y 100 "+SSPT+" - * + 100 / x ? ?", chroma="ignore")

(sootheT==0) ? last
\ : mt_lutxy( last, last.temporalsoften(1,255,0,32,2),
\ "x 128 - y 128 - * 0 < x 128 - 100 / "+ST+" * 128 + x 128 - abs y 128 - abs > x "+ST+" * y 100 "+ST+" - * + 100 / x ? ?", chroma="ignore")

(sootheT > -1) ? last
\ : mt_lutxy( last, last.temporalsoften(1,255,0,32,2),
\ "x 128 - y 128 - * 0 < x 128 - 100 / "+ST+" * 128 + x 128 - abs y 128 - abs > x "+ST+" * y 100 "+ST+" - * + 100 / x ? ?",chroma="ignore")

mt_makediff(orig,last)
# mergechroma(sharp) # not needed in SeeSaw
return( last )
}


# ======= MODd-and-atleast-16 helper function =======

function md(float x) {x<16?16:int(round(x/5)*12)} # for pal supersampling set the number 5 to 4.

In order to use spline, I use Foxyshadis plugin: Newresize.dll
And you need to have mt installed on your pc too.
If you look a few posts down you can get the needed plugins.

Jeremy Duncan
8th November 2008, 09:01
ntsc version
Meant for standard definition dvd.

lsf quad core version


# LimitedSharpen() ( modified for standard definition dvds and quad core cpus. by jeremy duncan november 11, 2008 )
#
# A multi-purpose sharpener by Didée
#
#
# Changes in this mod:
#
# - RemoveGrain >= v0.9 IS REQUIRED!!
# ==================================
#
# - If you use a different resolution than standard definition dvd. Disable supersampling ss_x and ss_y by setting them to 1.0
# - Smode=4 / sometimes does the magic ;-)
# - a separate "undershoot" parameter, to allow for some line darkening in comic or Anime
# - Lmode=3 / on edges, limited sharpening with zero OS & US. On not-edges, limited sharpening with specified OS + LS
# - "soft" acts different now: no more boolean true/false, but instead integer 0 - 100 (or -1 -> automatic)
# instead of blurring before finding minima/maxima, it now softens the "effect-of-sharpening"
# - edgemode=-1 now shows the edgemask. (scaling still not implemented :p )
# - for ntsc supersampling set ss_x to 1.2, set ss_y to 1.2
# - for pal supersampling set ss_x to 1.3 set ss_y to 1.1
#
## - MODIFIED version using MaskTools 2.0 and dedicated support plugin LimitedSupport

function LimitedSharpenFaster( clip clp,
\ float "ss_x", float "ss_y",
\ int "dest_x", int "dest_y",
\ int "Smode" , int "strength", int "radius",
\ int "Lmode", bool "wide", int "overshoot", int "undershoot",
\ int "soft", int "edgemode", bool "special",
\ int "exborder" )
{
ox = clp.width
oy = clp.height

Smode = default( Smode, 3 )
ss_x = (Smode==4)
\ ? default( ss_x, 1.0)
\ : default( ss_x, 1.0 )
ss_y = (Smode==4)
\ ? default( ss_y, 1.0)
\ : default( ss_y, 1.0 )
dest_x = default( dest_x, ox )
dest_y = default( dest_y, oy )
strength = (Smode==1)
\ ? default( strength, 127 )
\ : default( strength, 127 )
strength = (Smode==2&&strength>100) ? 100 : strength
radius = default( radius, 2 )
Lmode = default( Lmode, 1 )
wide = default( wide, false )
overshoot = default( overshoot, 0)
undershoot= default( undershoot, overshoot)
softdec = default( soft, 60 )
soft = softdec!=-1 ? softdec : sqrt( (((ss_x+ss_y)/2.0-1.0)*100.0) ) * 10
soft = soft>100 ? 100 : soft
edgemode = default( edgemode, 0 )
special = default( special, false )
exborder = default( exborder, 0)
#radius = round( radius*(ss_x+ss_y)/2) # If it's you, Mug Funky - feel free to activate it again
xxs=round(ox*ss_x/12)*10
yys=round(oy*ss_y/12)*10
smx=exborder==0?dest_x:round(dest_x/Exborder/4)*4
smy=exborder==0?dest_y:round(dest_y/Exborder/4)*4

clp.isYV12() ? clp : clp.converttoyv12()

ss_x != 1.0 || ss_y != 1.0 ? last.MT("spline64resize(xxs, last.height)",4).MT("spline64resize(last.width, yys)",5, splitvertical=true) : last
tmp = last

edge = mt_logic( tmp.mt_edge(thY1=0,thY2=255,"8 16 8 0 0 0 -8 -16 -8 4")
\ ,tmp.mt_edge(thY1=0,thY2=255,"8 0 -8 16 0 -16 8 0 -8 4")
\ ,"max") .mt_lut("x 128 / 0.86 ^ 255 *") #.levels(0,0.86,128,0,255,false)

tmpsoft = tmp.removegrain(1,-1)
dark_limit1 = tmp.mt_inpand()
bright_limit1 = tmp.mt_expand()
dark_limit = (wide==false) ? dark_limit1 : dark_limit1 .removegrain(1,-1).mt_inpand()
bright_limit = (wide==false) ? bright_limit1 : bright_limit1.removegrain(1,-1).mt_expand()
minmaxavg = special==false
\ ? SimpleAverage(dark_limit1, bright_limit1)
\ : mt_merge(dark_limit,bright_limit,tmp.removegrain(1,-1),Y=3,U=-128,V=-128)

Str=string(float(strength)/100.0)
normsharp = Smode==1 ? unsharpmask(strength,radius,0)
\ : Smode==2 ? sharpen(float(strength)/100.0)
\ : Smode==3 ? mt_lutxy(tmp,minmaxavg,yexpr="x x y - "+Str+" * +")
\ : mt_lutxy(tmp,tmpsoft,"x y == x x x y - abs 16 / 1 2 / ^ 16 * "+Str+
\ " * x y - 2 ^ x y - 2 ^ "+Str+" 100 * 25 / + / * x y - x y - abs / * + ?")

OS = string(overshoot)
US = string(undershoot)
mt_lutxy( bright_limit, normsharp, yexpr="y x "+OS+" + < y x y x - "+OS+" - 1 2 / ^ + "+OS+" + ?")
mt_lutxy( dark_limit, last, yexpr="y x "+US+" - > y x x y - "+US+" - 1 2 / ^ - "+US+" - ?")

Lmode==1 ? clamp(normsharp, bright_limit, dark_limit, overshoot, undershoot) : last

normal = last
zero = clamp(normsharp, bright_limit, dark_limit, 0,0)

Lmode==3 ? mt_merge(normal,zero,edge.mt_inflate()) : normal

edgemode==0 ? last
\ : edgemode==1 ? mt_merge(tmp,last,edge.mt_inflate().mt_inflate().removegrain(1,-1),Y=3,U=1,V=1)
\ : mt_merge(last,tmp,edge.mt_inflate().mt_inflate().removegrain(1,-1),Y=3,U=1,V=1)

AMNT = string(soft)
AMNT2 = string(100-soft)
sharpdiff=MakeDiff(tmp,last)
sharpdiff2=mt_lutxy(sharpdiff,sharpdiff.removegrain(1,-1),
\ "x 128 - abs y 128 - abs > y "+AMNT+" * x "+AMNT2+" * + 100 / x ?")

soft==0 ? last : SubtractDiff(tmp,sharpdiff2)

(ss_x != 1.0 || ss_y != 1.0)
\ || (dest_x != ox || dest_y != oy) ? MT("spline64resize(dest_x, last.height)",4).MT("spline64resize(last.width, dest_y)",5, splitvertical=true) : last

ex=blankclip(last,width=smx,height=smy,color=$FFFFFF).addborders(2,2,2,2).coloryuv(levels="TV->PC")
\.blur(1.3).mt_inpand().blur(1.3).MT("bicubicresize(dest_x, last.height)",4).MT("bicubicresize(last.width, dest_y,0.6,.0)",5, splitvertical=true)
tmp = clp.MT("spline64resize(dest_x, last.height)",4).MT("spline64resize(last.width, dest_y)",5, splitvertical=true)

clp.isYV12() ? ( exborder==0 ? tmp.mergeluma(last)
\ : mt_merge(tmp,last,ex,Y=3,U=1,V=1) )
\ : ( exborder==0 ? tmp.mergeluma(last.converttoyuy2())
\ : tmp.mergeluma( mt_merge(tmp.converttoyv12(),last,ex,Y=3,U=1,V=1)
\ .converttoyuy2()) )

(edgemode!= -1) ? last : edge.MT("spline64resize(dest_x, last.height)",4).MT("spline64resize(last.width, dest_y)",5, splitvertical=true).greyscale

return last
}


dual core


# LimitedSharpen() ( modified for standard definition dvds and dual core cpus. by jeremy duncan november 11, 2008 )
#
# A multi-purpose sharpener by Didée
#
#
# Changes in this mod:
#
# - RemoveGrain >= v0.9 IS REQUIRED!!
# ==================================
#
# - Smode=4 / sometimes does the magic ;-)
# - a separate "undershoot" parameter, to allow for some line darkening in comic or Anime
# - Lmode=3 / on edges, limited sharpening with zero OS & US. On not-edges, limited sharpening with specified OS + LS
# - "soft" acts different now: no more boolean true/false, but instead integer 0 - 100 (or -1 -> automatic)
# instead of blurring before finding minima/maxima, it now softens the "effect-of-sharpening"
# - edgemode=-1 now shows the edgemask. (scaling still not implemented :p )
# - If you use a different resolution than standard definition dvd. Disable supersampling ss_x and ss_y by setting them to 1.0
# - for ntsc supersampling set ss_x to 1.2, set ss_y to 1.2
# - for pal supersampling set ss_x to 1.3 set ss_y to 1.1
#
## - MODIFIED version using MaskTools 2.0 and dedicated support plugin LimitedSupport

function LimitedSharpenFaster( clip clp,
\ float "ss_x", float "ss_y",
\ int "dest_x", int "dest_y",
\ int "Smode" , int "strength", int "radius",
\ int "Lmode", bool "wide", int "overshoot", int "undershoot",
\ int "soft", int "edgemode", bool "special",
\ int "exborder" )
{
ox = clp.width
oy = clp.height

Smode = default( Smode, 3 )
ss_x = (Smode==4)
\ ? default( ss_x, 1.0)
\ : default( ss_x, 1.0 )
ss_y = (Smode==4)
\ ? default( ss_y, 1.0)
\ : default( ss_y, 1.0 )
dest_x = default( dest_x, ox )
dest_y = default( dest_y, oy )
strength = (Smode==1)
\ ? default( strength, 127 )
\ : default( strength, 127 )
strength = (Smode==2&&strength>100) ? 100 : strength
radius = default( radius, 2 )
Lmode = default( Lmode, 1 )
wide = default( wide, false )
overshoot = default( overshoot, 0)
undershoot= default( undershoot, overshoot)
softdec = default( soft, 60 )
soft = softdec!=-1 ? softdec : sqrt( (((ss_x+ss_y)/2.0-1.0)*100.0) ) * 10
soft = soft>100 ? 100 : soft
edgemode = default( edgemode, 0 )
special = default( special, false )
exborder = default( exborder, 0)
#radius = round( radius*(ss_x+ss_y)/2) # If it's you, Mug Funky - feel free to activate it again
xxs=round(ox*ss_x/12)*10
yys=round(oy*ss_y/12)*10
smx=exborder==0?dest_x:round(dest_x/Exborder/4)*4
smy=exborder==0?dest_y:round(dest_y/Exborder/4)*4

clp.isYV12() ? clp : clp.converttoyv12()

ss_x != 1.0 || ss_y != 1.0 ? last.MT("spline64resize(xxs, last.height)",2).MT("spline64resize(last.width, yys)",3, splitvertical=true) : last
tmp = last

edge = mt_logic( tmp.mt_edge(thY1=0,thY2=255,"8 16 8 0 0 0 -8 -16 -8 4")
\ ,tmp.mt_edge(thY1=0,thY2=255,"8 0 -8 16 0 -16 8 0 -8 4")
\ ,"max") .mt_lut("x 128 / 0.86 ^ 255 *") #.levels(0,0.86,128,0,255,false)

tmpsoft = tmp.removegrain(1,-1)
dark_limit1 = tmp.mt_inpand()
bright_limit1 = tmp.mt_expand()
dark_limit = (wide==false) ? dark_limit1 : dark_limit1 .removegrain(1,-1).mt_inpand()
bright_limit = (wide==false) ? bright_limit1 : bright_limit1.removegrain(1,-1).mt_expand()
minmaxavg = special==false
\ ? SimpleAverage(dark_limit1, bright_limit1)
\ : mt_merge(dark_limit,bright_limit,tmp.removegrain(1,-1),Y=3,U=-128,V=-128)

Str=string(float(strength)/100.0)
normsharp = Smode==1 ? unsharpmask(strength,radius,0)
\ : Smode==2 ? sharpen(float(strength)/100.0)
\ : Smode==3 ? mt_lutxy(tmp,minmaxavg,yexpr="x x y - "+Str+" * +")
\ : mt_lutxy(tmp,tmpsoft,"x y == x x x y - abs 16 / 1 2 / ^ 16 * "+Str+
\ " * x y - 2 ^ x y - 2 ^ "+Str+" 100 * 25 / + / * x y - x y - abs / * + ?")

OS = string(overshoot)
US = string(undershoot)
mt_lutxy( bright_limit, normsharp, yexpr="y x "+OS+" + < y x y x - "+OS+" - 1 2 / ^ + "+OS+" + ?")
mt_lutxy( dark_limit, last, yexpr="y x "+US+" - > y x x y - "+US+" - 1 2 / ^ - "+US+" - ?")

Lmode==1 ? clamp(normsharp, bright_limit, dark_limit, overshoot, undershoot) : last

normal = last
zero = clamp(normsharp, bright_limit, dark_limit, 0,0)

Lmode==3 ? mt_merge(normal,zero,edge.mt_inflate()) : normal

edgemode==0 ? last
\ : edgemode==1 ? mt_merge(tmp,last,edge.mt_inflate().mt_inflate().removegrain(1,-1),Y=3,U=1,V=1)
\ : mt_merge(last,tmp,edge.mt_inflate().mt_inflate().removegrain(1,-1),Y=3,U=1,V=1)

AMNT = string(soft)
AMNT2 = string(100-soft)
sharpdiff=MakeDiff(tmp,last)
sharpdiff2=mt_lutxy(sharpdiff,sharpdiff.removegrain(1,-1),
\ "x 128 - abs y 128 - abs > y "+AMNT+" * x "+AMNT2+" * + 100 / x ?")

soft==0 ? last : SubtractDiff(tmp,sharpdiff2)

(ss_x != 1.0 || ss_y != 1.0)
\ || (dest_x != ox || dest_y != oy) ? MT("spline64resize(dest_x, last.height)",2).MT("spline64resize(last.width, dest_y)",3, splitvertical=true) : last

ex=blankclip(last,width=smx,height=smy,color=$FFFFFF).addborders(2,2,2,2).coloryuv(levels="TV->PC")
\.blur(1.3).mt_inpand().blur(1.3).MT("bicubicresize(dest_x, last.height)",2).MT("bicubicresize(last.width, dest_y,0.6,.0)",3, splitvertical=true)
tmp = clp.MT("spline64resize(dest_x, last.height)",2).MT("spline64resize(last.width, dest_y)",3, splitvertical=true)

clp.isYV12() ? ( exborder==0 ? tmp.mergeluma(last)
\ : mt_merge(tmp,last,ex,Y=3,U=1,V=1) )
\ : ( exborder==0 ? tmp.mergeluma(last.converttoyuy2())
\ : tmp.mergeluma( mt_merge(tmp.converttoyv12(),last,ex,Y=3,U=1,V=1)
\ .converttoyuy2()) )

(edgemode!= -1) ? last : edge.MT("spline64resize(dest_x, last.height)",2).MT("spline64resize(last.width, dest_y)",3, splitvertical=true).greyscale

return last
}


If you supersize, just use the default supersize.
If you use a different supersize, this part of the code needs to be tweaked for the new supersize:
xxs=round(ox*ss_x/12)*10
yys=round(oy*ss_y/12)*10

Namely the numbers 12 and 10.
I suggest you use my calibration disks I made (use search function), if you use a different supersize and need to calibrate the part mentioned.

pitch.fr
8th November 2008, 10:23
what is MT exactly ?
only the resize ? I use ss1.0 in ffdshow.

there's a slightly faster version of LSF that uses an external dll called limitedsupport.dll :
http://forum.doom9.org/showpost.php?p=1207897&postcount=13

what's the point to add MT in the script itself when you can do MT("LSF",4) :confused:

Jeremy Duncan
8th November 2008, 11:41
what is MT exactly ?
only the resize ? I use ss1.0 in ffdshow.

there's a slightly faster version of LSF that uses an external dll called limitedsupport.dll :
http://forum.doom9.org/showpost.php?p=1207897&postcount=13

what's the point to add MT in the script itself when you can do MT("LSF",4) :confused:

mt("lanczosresize(1920, 1080)",3)

You cannot multithread the lanczosresize. And the example shown with no mt is how it's written in these scripts. So how does these scripts use mt? answer is it must not multithread the parts I multithreaded.

ash925
8th November 2008, 12:39
I am getting an error that there is no function named xxs.
I have all the plugins you mentioned.

pitch.fr
8th November 2008, 17:03
I know it's not too easy to find the limitedsupport.dll so here's the package I use.

-latest version of LS.dll(that does some of the computing of the original script in low level asm)
-the original LSF script from mg262
-with the fix from Foxyshady
-latest version of RemoveGrainSSE3(I have a Q6600 on XP SP3)
-some old version of MT2(the newer ones crash randomly for me)

Didee has been pretty clear that if SS was not used, lanczos/spline was not used either...it's only used for SS!

I personally ran several tests, and SS doesn't appeal to me.

SS1.0 does some jaggies, but at least the picture is razor sharp.
with SS enabled, it's not as sharp and seems to increase small defects from the original source :(

you can benchmark all these versions in VDUB, the version I'm posting is always the fastest from my tests(with SS disabled) :cool:

pitch.fr
8th November 2008, 20:05
I know it's not too easy to find the limitedsupport.dll so here's the package I use.
oops, didn't know adding attachment required credentials..
here's a mirror :
http://www.yousendit.com/download/Y2o4SU5LbEorV3hjR0E9PQ

ACrowley
9th November 2008, 14:05
Ive a Question.

I use your Seesaw Version to upscale SD DVD PAL Content, 704x428 to to 720p. It wokrs nice for realtime upscaling with ffdshow.
But i want to reencode Mpeg2 to x264 with 720p upscaling...i know its more or less Senseless..However i want do it

With the Seesaw command :

setmemorymax(1024)
MT("
SeeSaw(NRlimit=0, NRlimit2=5, Sstr=0.67, Szp=1, Slimit=100, Sdamplo=25, Spower=1, sootheT=55, SdampHi=52)
",4)
MT("spline64resize(1920, last.height)",4)
MT("spline64resize(last.width, 1080)",4, splitvertical=true) # Source is 2.35:1 so i resize/upscale to 1280x544


Script is very simple :

DGDecode_mpeg2source("E:\VTS_01_0.d2v",info=3)
ColorMatrix(hints=true)
trim(90000,92000)
crop( 8, 72, -8, -76)
setmemorymax(1024)
MT("
SeeSaw(NRlimit=0, NRlimit2=6, Sstr=0.67, Szp=1, Slimit=100, Sdamplo=25, Spower=1, sootheT=55, SdampHi=52)
",4)
MT("spline64resize(1280, last.height)",4)
MT("spline64resize(last.width, 544)",4, splitvertical=true)

Can you tell me if your seesaw Version is good choice to upscale SD to 720p/1080p ?
The Result looks very good

Fizick
9th November 2008, 14:42
Jeremy Duncan,
if you modified a script, please add clear note about it to the script itself (comment), increment a version, date, etc.
To take (part of) responsibility and prevent mess.

Jeremy Duncan
9th November 2008, 15:17
ACrowley,

It's meant for upscaling sd dvd.

Fizick,

I have done as you've said. They are now named.

ACrowley
9th November 2008, 16:12
ACrowley,

It's meant for upscaling sd dvd.

Fizick,

I have done as you've said. They are now named.

Yeah THX

I noticed that it looks sharper with lsffaster :

MT("LimitedSharpenFaster(ss_x=1.0, ss_y=1.0, Smode=3, strength=90, overshoot=0, soft=60)",2)
MT("spline64resize(1280, last.height)",4)
MT("spline64resize(last.width, 544)",4, splitvertical=true)

Which values should i increase in my seesaw command to get a litte bit higher sharpening?

setmemorymax(1024)
MT("
SeeSaw(NRlimit=0, NRlimit2=5, Sstr=0.67, Szp=1, Slimit=100, Sdamplo=25, Spower=1, sootheT=55, SdampHi=52)
",4)
MT("spline64resize(1280, last.height)",4)
MT("spline64resize(last.width, 544)",4, splitvertical=true) # Source is 2.35:1 so i resize/upscale to 1280x544


And are you working on limitedsharpen function too ?

Jeremy Duncan
9th November 2008, 16:25
ACrowley,

in seesaw, raise sstr to from 0.67, to a higher value. Maybe 0.87

Nikos
9th November 2008, 18:59
Szp=1 :eek:

According to Didee:
Szp=1 : drives sharpening strength way beyond sanity.
Useful is 8 ~ 64

LaTo
9th November 2008, 21:18
Szp=1 :eek:
It's not a problem, because Spower=1... So no effect ;)

ACrowley
10th November 2008, 10:28
ACrowley,

in seesaw, raise sstr to from 0.67, to a higher value. Maybe 0.87

Ok THX

Jeremy Duncan
10th November 2008, 11:07
I realized that the Seesaw would use the resizing only if I used ssx parameter > 1.00. So I spent a few hours first gett ing the mt to work, then the grueling job of find the right ssx number to match with the m4 code for the best result. If you use a different ssx than the one in the code, or if you use a pal and not a ntsc dvd. You will need to fiddle with the m4 code:
function m4(float x) {x<16?16:int(round(x/5)*12)}
namely the numbers 5 and 12, to match your new setting.
It was very difficult to find where to turn the knob to adjust the setting for ssx quality too, I say.

Also, the ssx/supersample quality of seesaw is really poor compared to limitedsharpenfaster's supersampling.
I spent a lot of time proving this to myself today.
And the default from didée's original script is not too good, but I won't say to much about that. :)

So, in the process of tweaking the code to get seesaw supersampling to work, I figured out how to get more detail from seesaw.
So, without supersampling, seesaw is now mure detailed. And the sharpness is more than it was before as well.

It was a lot more work to do this than Ioriginally though, but it's done and now I'm happy. :)

ACrowley
10th November 2008, 11:19
or if you use a pal and not a ntsc dvd. You will need to fiddle with the m4 code:
function m4(float x) {x<16?16:int(round(x/5)*12)}
namely the numbers 5 and 12, to match your new setting.


It is fixed in you latest seesaw above, right ? its already changed from :
function m4(float x) {x<16?16:int(round(x/4.0)*4)}

to
function m4(float x) {x<16?16:int(round(x/5)*12)}

correct ?

Ah, it means that the Resizing wasnt working properly before ?
Now your seesaw looks very nice :)

Jeremy Duncan
10th November 2008, 13:47
ACrowley,

I updated the seesaw dual core and quad core plugins again.
For some odd reason I uploaded and showed the wrong one I was working on, and deleted the version I had made, so I had to redo all my work all over again...:)
But this time if you supersample in seesaw the results are comparable to limitedsharpens results.
And I made a pal version too.

link to plugins: link (http://files.filefront.com/pluginszip/;12334518;/fileinfo.html)

I been working on this all day and night. Since I got up 23 hours ago.
Now I'm done. :)

Comatose
10th November 2008, 15:15
Fizick,

I have done as you've said. They are now named.
SeeSaw isn't... and you should really slightly change the name of the function itself, just like how LimitedSharpen turned into LimitedSharpenFaster, FastLineDarken into FastLineDarkenMOD, etc...

Didée
10th November 2008, 15:44
You will need to fiddle with the m4 code:
function m4(float x) {x<16?16:int(round(x/5)*12)}
Heaven help.

If you need to do s-th like that, then you introduce a new function that replaces m4(), and use that instead.

You do NOT alter the m4() function itself!!

"m4" stands for "make modulo-4 compliant", and should keep doing exactly that.

When people import your function with that short-sighted modification, they might experience that other scripts all of a sudden do not work anymore ...

Gavino
10th November 2008, 20:57
If you need to do s-th like that, then you introduce a new function that replaces m4(), and use that instead.
Quite so - and the comment
# ======= MOD4-and-atleast-16 helper function =======
should be changed too.

I wonder though. Presumably the original code had a reason to use mod4, the new version uses what appears at first sight to be an arbitrary factor of 12/5. Is there a thought-out reason for this, or just trial and error to fit a particular example? Does it really work for arbitrary input clips?

Jeremy Duncan
11th November 2008, 04:58
Gavino,

That depends on using it within Seesaw. So I don't recommend importing that bit of code to other plugins.

And I made a ntsc and pal calibration disk. Many people helped me with that right here in this very forum.
I used those calibration disks to help me remold these plugins Didée made.
They were designed with those disks in mind.
A forum rule is: there is no best.
So I can't say my setting is best in all clip conditions. :)

I edited the scripts posts to show they were built for standard definition dvd.

ACrowley
11th November 2008, 09:29
Seesaw, pal version
Meant for standard definition dvd.


Do you have a AR Settings in your avsi ?

Or what the Difference between your NTSC and PAL Script ?
I encode 704x428 to 1280x544. So the Output AR is 1:1, without a extra x264 SAR Switch

And is it a Problem when i use non mod16 Resolutions with your Seesaw ?

Gavino
11th November 2008, 11:31
Seesaw, pal version...
Forgive me if I am missing something, but this approach seems like madness to me.

We now have 4 different versons of Seesaw and LimitedSharpenFaster (+ Didée's originals), all called the same.
Surely it would make more sense to have a single version with parameters to select PAL/NTSC, quad/dual/single core?
If you want to make it easier to use, have 4 separate wrappers, with different names, to call the single unified function.

Jeremy Duncan
11th November 2008, 19:12
ACrowley,

Well, the test disk was 4:3 aspect ratio, but was calibrated on a 16:9 monitor.
Nothing really special, as my other calibration showed no different between either one if I first calibrated on 4:3.

What is the different between pal and ntsc?
The difference is not in the cores used, but in how super sampling is modified to get a nice result from the different resolutions.
So, if your source you want to use these plugins on isn't standard definition dvd resolution, you would disable supersampling by setting it to 1.0
Then it's not using any special resizing or cores.
Then the only thing different about these plugins is the way it's setup by default: sstr, etc.

Gavino,

I thought about what you for a while now.
I have edited the scripts to show if they are for pal, etc.

The way the supersampling is made in seesaw it would be too hard for somebody to reliably be expected to manually switch from pal to ntsc, and the same for the cores.

Gavino
11th November 2008, 21:35
The way the supersampling is made in seesaw it would be too hard for somebody to reliably be expected to manually switch from pal to ntsc, and the same for the cores.
Huh? I'm not suggesting people should switch manually, but that you should provide a single function that covers all the different combinations (that's what functions are for, right?).

Looking at the differences between them, it should be a simple matter to parameterise the processing, eg have a parameter ncores and use that to decide how (or even if) to MT the resize. Similarly for the supersampling.

Jeremy Duncan
11th November 2008, 23:03
Gavino,

I don't know how.
I do know how to tweak, but actually designing code from scratch is too much to ask me to do.

And to your previous question of if I did the m4 mod by some math or trial and error: trial and error.
I tried a bunch of various ones.
The number you quoted isn't the only principle involved.
If I had chosen a different ssx, ssx=4, then the whole math below would have to be changed too.
So if you import that function, you need to make it for supersampling that is the number for pal or ntsc.

But to the first point.
I don't know the avisynth language, not very well anyway to write what you requested.
Maybe Didée can help me with that and post the one you asked for, using my parameters of course? :)

ACrowley
12th November 2008, 13:08
Thx for your limitedsharpenfaster:)

What are the advantages compared to other lsf Scripts ..

By the Way..it looks very good

pitch.fr
12th November 2008, 20:55
Right now the lsf is more detailed than the regular lsf.
~
The result is they are now faster as they have less denoising to do.
there's no denoising in LSF I think...is it faster than the version with limitedsupport.dll ? more details only if SS is being used ?

Jeremy Duncan
12th November 2008, 22:00
there's no denoising in LSF I think...is it faster than the version with limitedsupport.dll ? more details only if SS is being used ?

I'm sorry. I was wrong with that statement.
My version, with the same settings on both version of the fast lsf, in Not faster than the regular fast lsf.
Nor more detailed.

Edit,
But, the difference in removegrain does affect the speed between the two.
The regular fast lsf is about a half frame faster using ss, and 1/3 frame faster with no ss.
So it looks like the regular fast lsf takes out some grain and this makes the speed difference.
because the only difference between the two is the removegrain noise removal power.
The more removegrain removes grain, the faster lsf is.
My version removes less grain than the regular fast lsf, and so keeps more detail from less grain being removed.

Jeremy Duncan
13th November 2008, 02:33
Using this code below looks pretty good in ffdshow, and might in encoding too.
Óf course this is with the lsf and seesaw from the first page.

MT("
a= last
b=a.Spresso()
SeeSaw(a, b,sstr=1.45)
LimitedSharpenFaster(strength=47)
YV12toRGB24HQ
",2)


If you use this code, resize after the above code.

Here's my spresso, with the parameters different than the original.

function SPresso(clip clp, int "limit", int "bias", int "RGmode", int "limitC", int "biasC", int "RGmodeC")
{
limit = default( limit, 2 )
limitC = default( limitC, 3 )
bias = default( bias, 27 )
biasC = default( biasC, 27 )
RGmode = default( RGmode, 17 )
RGmodeC = default( RGmodeC, 17 )

yy = (RGmode ==0) ? 2 : 3
uv = (RGmodeC==0) ? 2 : 3
LIM1 = (limit>0) ? string( round(limit*100.0/bias-1.0) ) : string( round(100.0/bias) )
LIM2 = (limit<0) ? "1" : string(limit)
BIA = string(bias)
LIM1c = (limitC>0) ? string( round(limitC*100.0/biasC-1.0) ) : string( round(100.0/biasC) )
LIM2c = (limitC<0) ? "1" : string(limitC)
BIAc = string(biasC)

expr = (limit<0) ? "x y - abs "+LIM1+" < x x 1 x y - x y - abs / * - ?"
\ : "x y - abs 0 <= x x "+LIM1+" + y < x "+LIM2+" + x "+LIM1+" - y > x "+LIM2+" - " \
+ "x 100 "+BIA+" - * y "+BIA+" * + 100 / ? ? ?"
exprC = (limit<0) ? "x y - abs "+LIM1c+" < x x 1 x y - x y - abs / * - ?"
\ : "x y - abs 0 <= x x "+LIM1c+" + y < x "+LIM2c+" + x "+LIM1c+" - y > x "+LIM2c+" - " \
+ "x 100 "+BIAc+" - * y "+BIAc+" * + 100 / ? ? ?"

# For (old) MaskTools v1.5.8 :
# yv12lutxy( clp, clp.removegrain(RGmode,RGmodeC), expr,exprC,exprC, Y=yy,U=uv,V=uv)

# For (new) MaskTools v2.x :
mt_lutxy( clp, clp.removegrain(RGmode,RGmodeC), yexpr=expr,uexpr=exprC,vexpr=exprC, Y=yy,U=uv,V=uv)

return( last )
}

Nessessary plugins in post 18.

ACrowley
13th November 2008, 09:23
Ok, when i use your Spresso...

MT("
a= last
b=a.Spresso()
SeeSaw(a, b)
LimitedSharpenFaster(strength=127)
YV12toRGB24HQ
",2)

-which Resizer should i use "after" spresso ?

-And do i need YV12toRGB24HQ ? I mean my DVD Source is Rec 601 with a TV Scale luma Range of 16-235. Generally I dont change the Levels from TV to PC scale (0-255) in my encodes, so the Picture is brighter on PC..i fix it via Playback with ffdshow RGB32Output with YV12-RGB HQ Conversion.
When i use YV12toRGB24HQ with spresso, it will do the same ,correct ?

Jeremy Duncan
14th November 2008, 04:13
ACrowley,

I made a configuration for ffdshow and will post it below. And to my understanding, the yv12torgb24hq does Not change the levels.

________ advanced ffdshow ________

Codecs tab
Set Mpeg2 to Libmpeg2, and check "DVD decoding".
Set Avisynth to Avisynth, Raw video to All supported

Subtitles tab, Unchecked
Uncheck "Decode closed captions"
Uncheck "Accept embedded subs"
Uncheck "Accept SSA, ASS, ASS2 Subtitle (experimental)
Vobsub subpage, uncheck Vobsub Enable.

Avisynth tab checked
YV12 checked,
Add FFdshow Video source checked,
3:2 Pulldown box: Ignore Pulldown checked,
check Buffer back/Ahead: 1, 1

MT("
a= last
b=a.Spresso()
SeeSaw(a, b,sstr=1.45)
LimitedSharpenFaster(strength=47)
YV12toRGB24HQ
",2)

Resize & aspect tab checked
check Specify horizontal and vertical size:
1280x720 16:9
or
1920x1080 16:9
Process Pixel aspect ratio internally checked
No aspect ratio correction checked
spline
Luma Sharpen: 0.00
Luma Gaussian Blur: 0.50
Accurate rounding checked

Queue & Output tab
Queue output samples checked

Output tab
rgb32 checked
high quality yv12 to rgb conversion checked

rgb conversion tab
ycbcr: itu-bt 601
contrast: standard

Also, this uses the haali renderer. So install the Matroska splitter, then in mpc output select haali.

I edited the avisynth part. Deleted my old post and reposted with new avisynth in script, the sstr and strength are tweaked.