Log in

View Full Version : New Sharpening Function from Didée -'SeeSaw'


Pages : 1 2 3 4 5 6 7 8 9 [10] 11 12 13

hannah
2nd July 2007, 03:00
I found this post within this post explaining different parameters.

http://forum.doom9.org/showthread.php?p=920642#post920642

Thanks anyway guys.

Nikos
26th July 2007, 01:11
In main function the default setting for sootheT is 49
sootheT = default( sootheT, 49 ) # 0=minimum, 100=maximum soothing of sharpener's temporal instableness.
# (-100 .. -1 : will chain 2 instances of temporal soothing.)

In Soothe function the default setting for sootheT is 25.
sootheT = default(sootheT, 25 )

Also a little help for Smode and Spower settings please.

radar
14th September 2007, 02:06
hi.
im trying to use seesaw.ive read this entire thread and have some understanding what seesaw dose.im using the filters from the first page,heres my error.

import:couldnt open "c:\program files\avisynth 2.5\plugins\seesaw\seesaw.avs"
(c:\dvd-rb\workin~1\d2vavs\v01000~1.avs,line 14)


#------------------
# AVS File Created by DVD Rebuilder
# VOBID:01, CELLID:01
#------------------
LoadPlugin("C:\Program Files\DVD-RB PRO\DGDecode.dll")
mpeg2source("C:\DVD-RB\WORKING FILES\D2VAVS\V01.D2V")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\SeeSaw\mt_masktools.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\SeeSaw\MaskTools.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\SeeSaw\mvtools.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\SeeSaw\RemoveGrainS.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\SeeSaw\degrainmedian.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\SeeSaw\RepairSSE2.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\SeeSaw\VagueDenoiser.dll")
import("C:\Program Files\AviSynth 2.5\plugins\SeeSaw\SeeSaw.avs")
a= last
b=a.VagueDenoiser.dll()
SeeSaw(a,b, NRlimit=3, NRlimit2=4, Sstr=1.5, Slimit=5, Spower=5, Sdamplo=6, Szp=16)
trim(0,647)
ConvertToYUY2()
AudioDub(BlankClip())


rb ini if this helps

[Status]
version=v1.26.3
mode=1
MovieOnly=1
VTS_MIN_SIZE=25625
VTSM_MIN_SIZE=25625
Original_Size=13174
NavPack_Sectors=55
Excluded_Audio_Sub_Size=0
Space_For_Video=2236025
MainVTS=01
minTiming=11218
Reduction=100.00
VTS_01_SIZE=12781
Progress=2
CCEType=3
Summary=- HIGH/LOW/TYPICAL Bitrates: 7,747/7,747/7,748 Kbs
Encode_Progress=1
[V0100001]
Last_Sector=13156
[V01000000001001]
Action=0
SCR=16890880.000
PTS=16923464.000
Frame_Rate_Code=1
Pulldown=1
Structure=3
Frames=648
Playback=810
First_Sector=0
Last_Sector=13156
Reduction=100.00
Aspect_Ratio=3
HalfD1=0
Pan_and_Scan=0
Convert16=0
EndPTM=19355894.000
Sequence_End_Code=0
Audio_Sub_Sectors=322
ILVU=0
Src_Video_Sectors=12779
Video_Sectors=12779

Porsche_fan
15th October 2007, 17:57
No reason to flinch from using it. Pookie had my OK to post it, and after all, there even were quite a few updates since the first post ... ;)

One of the main reasons to hold SeeSaw back was that I wanted to include a tailored halo-protection. Currently, if the source already has slight halos, there is danger that they will be emphasised. (In the script there's a commented "head=head.maskedmerge(..." line, which will help for the problem when it's uncommented. Not the perfect solution, but it's not bad, either.)


I'm trying to use this feature of SeeSaw but I get an error message that there is no function prewitt. I understand from foxyshadis that prewitt is a part of mt_masktools and I already have the mt_masktools.dll installed.


I am using this version of SeeSaw...I believe it is the latest.

# SeeSaw v0.3e (02 Jan 2006)
#
# (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.
#


# ======= 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 / SeeSaw doesn't require supersampling urgently.
ssy = default( ssy, ssx ) # supersampling factor y / if at all, small values ~1.25 seem to be enough.
NRlimit = default( NRlimit, 2 ) # absolute limit for pixel change by denoising
NRlimit2 = default( NRlimit2, NRlimit+1) # limit for intermediate denoising
Sstr = default( Sstr, 1.5 ) # Sharpening strength (don't touch this too much)
Slimit = default( Slimit, NRlimit+2 ) # 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, 4 ) # exponent for modified sharpener
Szp = default( Szp, 16+2 ) # zero point - below: overdrive sharpening - above: reduced sharpening
SdampLo = default( SdampLo, Spower+1 ) # reduces overdrive sharpening for very small changes
SdampHi = default( SdampHi, 24 ) # 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, 49 ) # 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 = m4(ox*ssx)
yss = m4(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(4,-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(20))

(ssx==1.0 && ssy==1.0) ? repair(tame.sharpen2(Sstr,Spower,Szp,SdampLo,SdampHi,Smode),head,1,-1,-1)
\ : repair(tame.lanczosresize(xss,yss).sharpen2(Sstr,Spower,Szp,SdampLo,SdampHi,Smode),head.bicubicresize(xss,yss,-.2,.6),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(20,-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 )
}


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

function m4(float x) {x<16?16:int(round(x/4.0)*4)}

Didée
15th October 2007, 18:39
Ah, a forgotten artefact in SeeSaw.

The edgedetection function Prewitt() was implemented by mg262 (aka Clouded) before it made it's way into MaskTools. Either consider it an exercise of searching abilities (to go out and find prewitt.dll somewhere ;) ...)

... or more quickly, exchange

# head = head.mt_merge(tame,tame.prewitt(multiplier=1.0).mt_expand().removegrain(20))

with
head = head.mt_merge(tame,tame.mt_edge("prewitt",0,255,0,0,U=1,V=1).mt_expand().removegrain(20,-1))

Porsche_fan
15th October 2007, 19:29
Thanks Didée for the quick reply and the help. I had made a futile attempt to find prewitt.dll yesterday so I opted for the easier changes.:)


After making the change to the SeeSaw function I still get an error message that reads “Invalid arguments to function mt_edge”.

Didée
15th October 2007, 19:34
Gnnnrgh ... my fault, wrong order of parameters. Above post has been corrected.

adhoya
2nd November 2007, 13:02
hi guys i've read the whole threads for 2 days. i've tested seesaw for a hd movie 1080p, generally it's too slow i feel. it has blocknoise on it slightly. speed is almost 0.1 fps for x264 encoding. am i wrong for some parts. i'll appreciate for your help
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\masktools.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\RemoveGrainsse3.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\degrainmedian.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\repairsse3.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\mvtools\mvtools.dll")

DirectShowSource("d:\movie.grf",fps=23.976, audio=false)
crop( 0, 144, 0, -136)
spline36resize(1920,800)

backward_vec2 = last.MVAnalyse(isb = true, delta = 2, pel = 2, overlap=4, sharp=1, idx = 1)
backward_vec1 = last.MVAnalyse(isb = true, delta = 1, pel = 2, overlap=4, sharp=1, idx = 1)
forward_vec1 = last.MVAnalyse(isb = false, delta = 1, pel = 2, overlap=4, sharp=1, idx = 1)
forward_vec2 = last.MVAnalyse(isb = false, delta = 2, pel = 2, overlap=4, sharp=1, idx = 1)
a = last.MVDegrain2(backward_vec1,forward_vec1,backward_vec2,forward_vec2,thSAD=400,idx=1)

b = a.degrainmedian(mode=1)
SeeSaw(a,b, NRlimit=5, NRlimit2=6,Sstr=1.5, Slimit=8, Spower=8, Szp=16,soothet=80)

converttoyv12()
i feel it's working with no error messages. but it's too slow encoding even if i have quad core cpu 6600 2.4ghz. for encoding 2 and half movie, it might take a week or more. pls some advises

Didée
2nd November 2007, 13:12
It's not SeeSaw which is that slow. It's MVDegrain with all the motion stuff which is killing your speed on HD content.
Try adding a "blksize=16" to all MVAnalyze() lines - you should see a huge speed increase, like 0.2 or even 0.3 fps instead of 0.1 fps ... ;)

Morte66
2nd November 2007, 14:22
Try adding a "blksize=16" to all MVAnalyze() lines

And change overlap from 4 to 8

- you should see a huge speed increase, like 0.2 or even 0.3 fps instead of 0.1 fps ... ;)

I get almost exactly 1 fps for 1920x800 decode/mvdegrain2/huffYUV on one core of my AthlonX2 3800+.

Oh for a 3GHz quadcore and 4 GB RAM to run four in parallel...

@adhoya:

You've got a ConvertToVV12 on the end. What does DirectShow feed you?

adhoya
2nd November 2007, 14:56
It's not SeeSaw which is that slow. It's MVDegrain with all the motion stuff which is killing your speed on HD content.
Try adding a "blksize=16" to all MVAnalyze() lines - you should see a huge speed increase, like 0.2 or even 0.3 fps instead of 0.1 fps ... ;)

thanks a lot. it's working as you said. and it's faster. now 2.25fps. but still it takes 26hr long for encode. i guess i should omit analysing or use other script. i feel it's definitely sharper than other encoding but without deblocker i have lots of artifacts. i feel it has got to be smoothed. do you have any recommend for it.

b/regards

Didée
2nd November 2007, 16:04
Try adding a "blksize=16" to all MVAnalyze() lines
And change overlap from 4 to 8
That's a "can", not a "must". For speed reasons, I thought quarter-block-overlapping should be sufficient for denoising, compared to half-block-overlapping. ;)


@adhoya:

Use higher values for "SdampLo" in SeeSaw. The default (SdampLo=Spower+1) might be too low for you. Try e.g. SdampLo=20..25..30.
Also, your Spower of "8" is pretty high. Note that the default is "4", and realize it's a power function.
With base=5 as an example: Default: 5^4=652. Yours: 5^8=390625. See a difference in those numbers? Powers are growing very quickly, and the default choice for SdampLo works linear, not exponential.

Depending on how your "blocking" looks like exactly, the usage of a deblocker might be appropriate indeed. This can't be judged from the mere statement "there is blocking".
Throwing in some "SootheS" might help as well. Default is zero (deactivated), try SootheS=20..40..60..75.

adhoya
2nd November 2007, 17:08
where they are gone? (kidding..^^) really nice no blocks and noise. i used SeeSaw(a,b, NRlimit=5, NRlimit2=6,Sstr=1.5, Slimit=8, Sdamplo=30, Spower=4, Szp=16,soothet=80,sootheS=75) i'm gonna try without mvdegrain2 and analysis. thanks.

adhoya
2nd November 2007, 23:04
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\masktools.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\RemoveGrain.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\degrainmedian.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\repair.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\mvtools\mvtools.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\DctFilter\DctFilter.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\mt_masktools.dll")

DirectShowSource("d:\new.grf",fps=23.976, audio=false)
crop( 0, 144, 0, -136)
spline36resize(1920,800)

backward_vec2 = last.MVAnalyse(isb = true, delta = 2, pel = 2, overlap=4, sharp=1, idx = 1,blksize=16)
backward_vec1 = last.MVAnalyse(isb = true, delta = 1, pel = 2, overlap=4, sharp=1, idx = 1,blksize=16)
forward_vec1 = last.MVAnalyse(isb = false, delta = 1, pel = 2, overlap=4, sharp=1, idx = 1,blksize=16)
forward_vec2 = last.MVAnalyse(isb = false, delta = 2, pel = 2, overlap=4, sharp=1, idx = 1,blksize=16)
a = last.MVDegrain2(backward_vec1,forward_vec1,backward_vec2,forward_vec2,thSAD=400,idx=1)
b = a.degrainmedian(mode=1)
SeeSaw(a,b, NRlimit=5, NRlimit2=6,Sstr=1.5, Slimit=8, Sdamplo=40, Spower=4, Szp=16,soothet=100, sootheS=95)

Deblock_QED(quant1=24, quant2=22, aOff1=2, bOff1=4, aOff2=4, bOff2=8, uv=1)


i tried without mvdgrain analysis.

1) fluxsmooth, seesaw and spresso
2) fluxsmooth and seesaw

these combination were not so cool, too rough images with blocks and mosquito noises. no batter than first try, speed is quite fast,though. but first one also has blocks in some dark places in x264 encoding even if i tuned variables of seesaw(a,b, NRlimit=5, NRlimit2=6,Sstr=1.5, Slimit=8, Sdamplo=35, Spower=4, Szp=16,soothet=80,sootheS=100). and finally i decided another filter Deblock _QED. but when i load in megui. it says there's no funtion like Deblock_QED.but i already installed whole plug-ins pls post any ideas if possible.

R3Z
3rd November 2007, 04:54
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\masktools.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\RemoveGrain.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\degrainmedian.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\repair.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\mvtools\mvtools.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\DctFilter\DctFilter.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\mt_masktools.dll")

DirectShowSource("d:\new.grf",fps=23.976, audio=false)
crop( 0, 144, 0, -136)
spline36resize(1920,800)

backward_vec2 = last.MVAnalyse(isb = true, delta = 2, pel = 2, overlap=4, sharp=1, idx = 1,blksize=16)
backward_vec1 = last.MVAnalyse(isb = true, delta = 1, pel = 2, overlap=4, sharp=1, idx = 1,blksize=16)
forward_vec1 = last.MVAnalyse(isb = false, delta = 1, pel = 2, overlap=4, sharp=1, idx = 1,blksize=16)
forward_vec2 = last.MVAnalyse(isb = false, delta = 2, pel = 2, overlap=4, sharp=1, idx = 1,blksize=16)
a = last.MVDegrain2(backward_vec1,forward_vec1,backward_vec2,forward_vec2,thSAD=400,idx=1)
b = a.degrainmedian(mode=1)
SeeSaw(a,b, NRlimit=5, NRlimit2=6,Sstr=1.5, Slimit=8, Sdamplo=40, Spower=4, Szp=16,soothet=100, sootheS=95)

Deblock_QED(quant1=24, quant2=22, aOff1=2, bOff1=4, aOff2=4, bOff2=8, uv=1)


i tried without mvdgrain analysis.


these combination were not so cool, too rough images with blocks and mosquito noises. no batter than first try, speed is quite fast,though. but first one also has blocks in some dark places in x264 encoding even if i tuned variables of seesaw(a,b, NRlimit=5, NRlimit2=6,Sstr=1.5, Slimit=8, Sdamplo=35, Spower=4, Szp=16,soothet=80,sootheS=100). and finally i decided another filter Deblock _QED. but when i load in megui. it says there's no funtion like Deblock_QED.but i already installed whole plug-ins pls post any ideas if possible.


Deblock_QED is an avs script function, save the following as deblock_qed.avsi in your plugins folder;


function Deblock_QED ( clip clp, int "quant1", int "quant2",
\ int "aOff1", int "bOff1", int "aOff2", int "bOff2", int "uv" )
{
quant1 = default( quant1, 20 )
quant2 = default( quant2, 40 )

aOff1 = default( aOff1, quant1/2 ) # I've no clue if these are clever values or not!
bOff1 = default( bOff1, quant1/4 ) # So:
aOff2 = default( aOff2, quant1/4 ) # Also try all these 4 values @ 0 (zero),
bOff2 = default( bOff2, quant1/8 ) # and quant1=30, quant2=40~45 instead.
uv = default( uv, 1 ) # u=3 -> use proposed method for chroma deblocking
# u=2 -> no chroma deblocking at all (fastest method)
ox = clp.width() # u=1|-1 -> directly use chroma debl. from the normal|strong deblock()
oy = clp.height()

# With avisynth scripting, there is no information available about the position of the currently
# processed pixel ... there simply is no such thing like an "actual" processed pixel.
# So first I've to build up a grid covering the transitions between all 8x8 blocks,
# and make some LUTmania with it later. Yes, this is cumbersome.

block = blankclip(clp,width=6*4,height=6*4,color=$000000).addborders(4,4,4,4,color=$FFFFFF)
block = stackhorizontal( block,block,block,block)
block = stackvertical( block,block,block,block) .pointresize(32,32) .binarize(upper=false)
block = stackhorizontal( block,block,block,block,block,block,block,block)
block = stackvertical( block,block,block,block,block,block)
block = stackhorizontal( block,block,block)
block = stackvertical( block,block,block)
block = block .crop(0,0,ox,oy)
block = (uv!=3) ? block
\ : YtoUV(block.crop(0,0,ox/2,oy/2),block.crop(0,0,ox/2,oy/2),block)
block = block.trim(1,1) .loop(framecount(clp))


# create normal deblocking (for block borders) and strong deblocking (for block interiour)
normal = clp.deblock(quant=quant1,aOffset=aOff1,bOffset=bOff1)
strong = clp.deblock(quant=quant2,aOffset=aOff2,bOffset=bOff2)

# build difference maps of both
normalD = yv12lutxy(clp,normal,"x y - 128 +","x y - 128 +","x y - 128 +",U=uv,V=uv)
strongD = yv12lutxy(clp,strong,"x y - 128 +","x y - 128 +","x y - 128 +",U=uv,V=uv)

# separate border values of the difference maps, and set the interiours to '128'
strongD2 = yv12lutxy(StrongD,block,"y 255 = x 128 ?","y 255 = x 128 ?","y 255 = x 128 ?",U=uv,V=uv)
normalD2 = yv12lutxy(normalD,block,"y 255 = x 128 ?","y 255 = x 128 ?","y 255 = x 128 ?",U=uv,V=uv)

# interpolate the border values over the whole block: DCTFilter can do it. (Kiss to Tom Barry!)
# (Note: this is not fully accurate, but a reasonable approximation.)
strongD3 = strongD2.yv12lut("x 128 - 1.01 * 128 +","x 128 - 1.01 * 128 +","x 128 - 1.01 * 128 +",U=uv,V=uv).dctfilter(1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0)# .yv12lut("x 128 - 2 / 128 +")

# apply compensation from "normal" deblocking to the borders of the full-block-compensations calculated
# from "strong" deblocking ...
strongD4 = yv12lutxy(strongD3,normalD2,"y 128 = x y ?","y 128 = x y ?","y 128 = x y ?",U=uv,V=uv)

# ... and apply it.
deblocked= yv12lutxy(clp,strongD4,"x y 128 - -","x y 128 - -","x y 128 - -",U=uv,V=uv)

# simple decisions how to treat chroma
deblocked = (uv<0) ? deblocked.mergechroma(strong) : uv<2 ? deblocked.mergechroma(normal) : deblocked

deblocked
return( last )
}

adhoya
3rd November 2007, 10:38
i tested three options (1pass maxspeed profile x264 encoding with 7520kbps with no built-in x264 filter i.e. deblock filter)
only used below filters. thanks to R3Z and Didée(thru googling i found a script to correct qed by Didée ), i could install deblock_qed correctly


1)orginal encoding(without any filter)
2)only seesaw(MVDegrain2+degrainmedian)
3)only seesaw(MVDegrain2+degrainmedian)+deblock_qed

these are screenshots

original (1 pass maxspeed no x264 analyse )
http://thumbnails.keepmyfile.com/40/1194082279376de3.gif (http://www.keepmyfile.com/image/376de31963159)

seesaw only (1 pass maxspeed no x264 analyse )
http://thumbnails.keepmyfile.com/40/11940822788ad789.gif (http://www.keepmyfile.com/image/8ad7891963158)

seesaw + deblocker (1 pass maxspeed no x264 analyse )
http://thumbnails.keepmyfile.com/40/1194082275cd976f.gif (http://www.keepmyfile.com/image/cd976f1963157)

seesaw+x264 built-in deblocker (2pass hq slow profile, eqm_avc_hr.cfg matrix)
http://thumbnails.keepmyfile.com/40/11940846912bf0b6.gif (http://www.keepmyfile.com/image/2bf0b61963216)

at last blocks gone away.

Didée
3rd November 2007, 14:46
Somehow it seems your image quality problems lie not with SeeSaw, but rather with x264's settings ...

BTW, at that location where you have placed Deblock_qed, it is pretty much useless. That filter deals for removing blocking artefacts that are in the source. After having filtered the whole thing with MVDegrain+DegrainMedian already, there probably is no more blocking there that Deblock_qed could remove (or at least reckognize).
Also, you have a resizer at the start of the script. If that resizer actually does something (i.e. resolution is different than 1920x800 after cropping - not sure if it is, can't tell if your DS decoder spits out 1080p with 1080 or 1088 vertical pixels), then Deblock_qed can no more work correctly no matter what.
Prior to deblocking: NO resizing. NO noise filtering. Cropping only at macroblock boundaries.

adhoya
3rd November 2007, 16:46
resolution is different than 1920x800 after cropping - not sure if it is, can't tell if your DS decoder spits out 1080p with 1080 or 1088 vertical pixels

you're right. i removed resizing script. i got much better results with seesaw itself. now i wonder i got the wrong way. of course, original HD source has perfectly no block but little mosquito noises and it's sharp. with your comment, i realized deblock qed is no use, cause block is generated during encode. only x264 setting can control them. but those filters(i.e mv,degrain,seesaw....) can get rid of other noise and blocks within source, making movie sharper or smooth. just now. but i hoped i could control blocks by encoding within avs scripts. maybe no way~!
and i am wondering why, after encode, colors goes different. it's sharper and has less noise but not that vivid compared to source after encode with seesaw. it could be natural consequense. but i hope to know the method to get back as much as possible. is there any(sharper and vivid)?

Adub
3rd November 2007, 23:04
Are you using Colormatrix?

Fizick
16th November 2007, 17:00
Some bug was found with SeeSaw and Vfapi.
http://forum.doom9.org/showthread.php?t=128611

Didée, here is my bug report :)

VFapi catch all exception internally and report about error in float operation. (Avisynth itselft for some reason skip it).

I tried Sharpen2 function alone: it produce the bug too.
Then I try read your the extra long yv12lutxy expression. :)
It is really expressive expresion! :)

But now I know what is error. It is substring like:

"x y - x y - abs /"

In normal notation it is: (x-y)/abs(x-y)

Probably you wanted to construct the "sign" function.

But if x=y then you have 0/0
What is the result?

VFapi works fine (without error) when I replace the expression by "x < y -1 1 ?" or "x y - x y - abs 0.01 + /" or some other,
but i do not know your intention about value of 0/0.
Please correct it and similar substring like "y 128 - y 128 - abs /"

Didée
16th November 2007, 19:05
How could that be? Note the start of the expression:
"x y == x [...] x y - x y - abs / * + ?"

The case of "division by zero" can only take place if x equals y. But that case is explicitely checked for as first condition. So, IF x equals y, then the part with the division should not even be evaluated.
Same goes for the similar expression with "y 128 -".

Moreover, it's "only" in a mt_lutxy call: even if I overlooked something, then the hypothetical division-by-zero occurs only during the LUT building (which is handled by MaskTools without producing an error).

There is no reason why there should be a problem from that side. Either the script evaluates, or it does not. From my experience, it does.

Fizick
16th November 2007, 20:08
yes, it is during LUT building (at constructor).
yes, masktools for some reason do not report.

The order of internal calulations may differ ( i do not know why).
Probably even if you write condition at the left, evaluator may firstly calculate right part of expression. (to produce intermediate LUT).

And quite probably, that Avisynth or MaskTools skip "weak" exception like division by 0.

It is better to fix even potential bugs. They may appear in some case (next versions etc).



From my experience, the script does not evaluated with VFApi (see post above), but modified script does.
:)

Simple script:

a=version().converttoyv12()
b=a.blur(1)
yv12lutxy(b,a,"x y /",u=2,v=2)

produce the same results. (works itself but do not work with VFapi)

Fizick
16th November 2007, 20:30
Mostly for programmers. DGFapi use:

try {
...
*(j->clip) = j->avsEnv->Invoke("Import", AVSValue(args1, 1)).AsClip();
...
}

catch (AvisynthError e)
{
OutputDebugString("DGVfapi: error (Avisynth Error) loading avisynth script!\n");
sprintf(buf,"DGVfapi: %s.\n", e.msg);
OutputDebugString(buf);
closeAVS(j);
return VF_ERROR;
}
catch (...)
{
OutputDebugString("DGVfapi: error (Unknown) loading avisynth script!\n");
closeAVS(j);
return VF_ERROR;
}


Debugview log:
[3556] DGVfapi: error (Avisynth Error) loading avisynth script!
[3556] DGVfapi: Evaluate: System exception - Float Invalid Operation

Manao
16th November 2007, 20:55
The case of "division by zero" can only take place if x equals y. But that case is explicitely checked for as first condition. So, IF x equals y, then the part with the division should not even be evaluated.Actually it is. Let's take the following expression :
x y = y x y / ?
The expression will be processed as follow :

? -> fetch next three values
/ -> fetch next two values
y -> return y
x -> return x
-> return x / y
y -> return y
= -> fetch next two values
y -> return y
x -> return x
-> return abs(x-y) < 0.000001 ? 1 : -1
-> return abs(x-y) < 0.000001 ? y : x / y

So if in the previous code, y = 0, then it does compute x / 0 even if x = 0.

Alain2
17th November 2007, 15:10
Interesting, thanks for the explanation of how the code is interpreted :) I never use very complex formula in my scripts so I (think I) never came across such problems, but I will keep that in mind now ^^ I think this example would be worth being added to the masktools doc in the section V) Reverse polish notation

cheshire2k
16th January 2008, 23:34
please could someone tell me what i need and how i put a movie thru this seesaw filter I like the quality pictures of it I have virtualdub virtualdubmod and avisynht installed i alreadty downloaded the first 3 files the seesaw one masktools and the other one i just dont know how to do it.

Thanks

CHESH

cheshire2k
23rd January 2008, 15:57
ive got the filter working but how do i get the file size to stay the same. I tried lowering the bitirate but is there any calc to do it. Thanks

CHESH

Adub
26th January 2008, 04:28
Yah. It's called a bitrate calculator.

But, that might not help you, as with the increased sharpness comes the necessity for increased bitrate, meaning larger file size.

In short, if you want sharpness, you are going to have to pay for it with bits.

cyspur
26th January 2008, 10:06
Forgive my ignorance, with which program would one load the following?


LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\MaskTools158\MaskTools.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\VagueDenoiser\VagueDenoiser.dll")
Import("C:\Program Files\AviSynth 2.5\plugins\mvbob\mvbob.avs")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\DGDecode.dll")
MPEG2Source("Z:\DestB\VTS_01_2.d2v")
mvbob()
Import("C:\Program Files\AviSynth 2.5\plugins\SeeSaw.avs")
ConvertToYv12()
a = last
b=a.VagueDenoiser(threshold=0.8, method=1, nsteps=6, chromaT=0.8)
SeeSaw(a,b, NRlimit=6, NRlimit2=7, Sstr=1.5, Slimit=5, Spower=5, Szp=16)
Lanczos4Resize(640,372)

Sagekilla
27th January 2008, 02:19
What exactly do you mean "load?" If you mean view it, you can use VirtualDubMod to view your video file, windows media player (yuck) , or media player classic.

cyspur
27th January 2008, 12:27
Hi Sagekilla.

I would like to preview the applied filter (script) effect on a vob video file. Can i do this with MPC & if so how would i go about it please. Thanks.

J_Darnley
27th January 2008, 12:49
Open the AviSynth Script in MPC then. File -> Open , drag and drop, or do what I did and associate the avs extension with MPC.

Or are you asking how to create the script in the fist place? They are just plain text files so use any text editor such as notepad to create it and then save the file with an avs extension.

cyspur
28th January 2008, 10:19
Thanks a lot J_Darney, i am starting to understand how these things are working.

McCauley
5th February 2008, 12:42
Hi,

i already searched for an answer, but i haven't found this discussed, so please excuse if it has been brought up before.

Is there a reason that SeeSaw has no inbuilt resizer like LimitedSharpenFaster? If no, could someone point me out how i have to modify the script? I already tried it, but didn't succeed.

Regards and thanks in advance
McCauley

foxyshadis
5th February 2008, 15:27
Because seesaw doesn't need internal supersampling like LSF does, except in extreme cases, there isn't a need for combining all the resizing into one step. You can just resize and call seesaw after that.

McCauley
6th February 2008, 14:45
Hi,

SeeSaw may not urgently need Supersampling, that's right. In fact it is able to sharpen a lot more than LSF while keeping edges very halofree. BUT: The overall sharpening is way too strong for my taste. Changing the sharpening parameter isn't reducing the applied sharpening as much as i want it. The only way too tame it for my needs i found out is using supersampling.

Regards
McCauley

foxyshadis
6th February 2008, 18:09
In that case change the final LanczosResize to use the final width and height, instead of the original.

Vesi
7th February 2008, 14:35
If I want to use other denoiser then seesaw light denoising function, what should I do to turn it off that seesaw denoising function does not effect the Degrainmedian (mode=1), or any other denoiser I use?

foxyshadis
8th February 2008, 08:53
Seesaw only denoises when you don't supply a denoised clip. If you do, it's disabled.

Jeremy Duncan
9th February 2008, 12:29
I wonder how Didée is doing with that new Seesaw he was making?

Adub
10th February 2008, 05:45
He is making a new Seesaw? I thought that was just a rumor that got spread around which ended up being false?

Didee, can you confirm?

Nikos
12th March 2008, 15:32
From SeeSaw function:
SdampHi = default( SdampHi, 24 ) # further reduces sharpening for big sharpening changes. Try 15~30. "0" disables.
My question:
Big or small number mean strong reduction for differences above Szp ?

From Didee's post #318 i thing that small number mean strong reduction for differences above Szp but i wish a confirm :)

For High Definition sources, with relatively good quality, the recommended values are high(~30) or low(~15)?

In previous post #462 Didee wrote for HD sources:

Use higher values for "SdampLo" in SeeSaw. The default (SdampLo=Spower+1) might be too low for you. Try e.g. SdampLo=20..25..30.

zee944
22nd March 2008, 13:57
Hey,

I'm trying to use SeeSaw for a rather clean source, and SeeSaw smoothes it out too strongly. I don't want to turn it off, I just need a little less smoothing. How can I do that? At the moment it seems I can't really adjust the smoothing strength with NRlimit and NRlimit2 (apart from turning off of course). If I have to use a very simple external smoother for SeeSaw, a few recommendations?

foxyshadis
24th March 2008, 08:11
You can try something like removegrain, fluxsmooth, degrainmedian, fft3dfilter/fft3dgpu, vaguedenoiser, mvdegrain.... all depends on the speed and smoothness you're looking for.

saint-francis
18th June 2008, 14:23
Can anyone help me understand why I can't get seesaw to work? When I try this script, or any script like it, I completely loose multithreading and encoding speeds drop down
to about .01 fps and after about 6 hours or so drop down so low that the progress window in MeGUI can't even display a number. After 9 hours of encoding the resulting
file is still less than 1 MB. :confused:

setMTmode (2,0)
DGDecode_mpeg2source("D:\any\video.d2v",info=3)
colormatrix(hints=true)
crop( 6, 102, -4, -104)
Spline36Resize(720,304)
a = last
b=a.TTempSmooth (maxr=6, lthresh=4, cthresh=5, lmdiff=2, cmdiff=3, strength=2, scthresh=12.0, fp=true, vis_blur=0, debug=false, interlaced=false).FFT3DFILTER(sigma=1.6, ncpu=2, bw=14, bh=14, ow=7, oh=7, bt=5, hr=1).Gradfun2db ()
SeeSaw(a,b, NRlimit=5, NRlimit2=6,Sstr=1.5, Slimit=8, Sdamplo=30, Spower=4, Szp=16,soothet=80,sootheS=75)

jeffy
18th June 2008, 23:14
@saint-francis: try putting SetMemoryMax(512) or a lower value at the beginning.

kandrey89
30th June 2008, 23:21
I'm trying to sharpen a pretty clean MPEG2 DVD source, hoowever when I use SeeSaw, I can't get the settings right.

If I sharpen it enough, the pictures looks clean and great, but in some places on certain frames I find oversharpening artefacts.

If I try to get rid of the artifacts, I do a SootheS. But it reduces the sharpness of the picture while removing the artifacts(oversharpened pixels)

Could anyone suggest a setting for SeeSaw that will sharpen but avoid oversharpening single pixels or pixels on a flat color?

Nikos
1st August 2008, 17:18
Sharpen anamorphic source
I want to sharpen with SeeSaw or LSF an Anamorphic (16:9) NTSC DVD (720x480) and then encode anamorphicaly with x264.
The anamorphic sources have different characteristics in both directions.
The resolution after cropping the black bars is 720x360. The normal display resolution with proper (non ITU) stretch is 852x360.

I have four options:

1.SeeSaw without supersampling.

source = last # the resolution is 720x360
a = source
b = source.degrainMedian(mode=3)

SeeSaw( a, b, ........)

2. SeeSaw with horizontal only external supersampling.

source = last # the resolution is 720x360
a= source.spline36Resize(852,360)
b = source.degrainMedian(mode=3).spline36Resize(852,360) # I prefer first denoise, then resize

SeeSaw( a, b, ........) # i don't use the internal supersampling

spline36Resize(720,360)


3. LSF with same ss_x, ss_y.

source = last # the resolution is 720x360
source.degrainMedian(mode=3)
LSF(smode=4, ss_x=1.5, ss_y=1.5) # internal resizer is spline36Resize


4. LSF with differents ss_x, ss_y.
ss_x=1.5*852/720 = 1.775, ss_y = 1.5

source = last # the resolution is 720x360
source.degrainMedian(mode=3)
LSF(smode=4, ss_x=1.775, ss_y=1.5) # internal resizer is spline36Resize


Which is the prefered way ?

foxyshadis
3rd August 2008, 18:09
There is no preferred. It comes down to your taste, and different sources will be better with different things. Look at all four, pick the one you like; we can't do that for you.

I can only say that I tend to prefer #1 myself, and hardly notice any difference in #3 & #4. ss of 1.5 for smode 4 will make it somewhat softer as it is, which is why 1.25 is default.

Nikos
3rd August 2008, 18:58
Thanks foxyshadis for the reply. The 1.5 was just for example. I know that differences are small. The question is, from technical view which is the correct way because of different characteristics in each direction.