View Single Post
Old 1st June 2008, 04:42   #62  |  Link
WorBry
Registered User
 
Join Date: Jan 2004
Location: Here, there and everywhere
Posts: 1,197
@Terka, Cant say I fully understand what you are suggesting…..assuming it was directed to me.

Basically, this is what I was thinking of as a working basis for progressive sources (noting disclaimer at end of post):

Either this
Code:
function TempGaussMC_mod(clip clp, int "tr0", int "tr1", int "tr2", float "sharpness", bool "rep0", bool "rep1", int "border", int "blocksize", int "overlap", string "EdiMode", int "draft")
{
tr0       = default( tr0,     2 )  #  temporal radius for temporal Gauss before motion compensation (1 or 2)
tr1       = default( tr1,     2 )  #  temporal radius for temporal Gauss with motion compensation (1 or 2)
tr2       = default( tr2,     1 )  #  temporal radius for final MVDegrain (1, 2 or 3)
rep0      = default( rep0, true )  #  repair temporalsoften-defects for searchclip
rep1      = default( rep1, true )  #  repair MVDegrain-defects for output 
border    = default( border,  1 )  #  1 = padd borders internally to catch "half scanlines" at top + bottom (broadcast material)
bs        = default( blocksize,8)  #  Blocksize for motion search
ovlp      = default( overlap,bs/2) # Overlap size for ME blocks
sharpness = default( sharpness, 0.25+(tr1+tr2)/8.) # "inloop" sharpening to counteract softening, 0.0 to 1.0, or more if you like
EdiMode   = default( EdiMode, "NNEDI") # interpolator to use: "NNEDI", "EEDI2" 
draft     = default( draft, 0 )    #  '1' outputs a quick draft, and '2' is even more draft'ier  :p

trmax     = (tr1 > tr2) ? tr1 : tr2
nullclip  = blankclip(clp,width=16,height=16)

clpo = (border==0) ? clp
 \                : clp.pointresize(clp.width(),clp.height()+8, 0,-4,-0,clp.height()+8.001 )

clps = clpo.AssumeBFF().SeparateFields()

eeddbl   = mt_Average(clps.SelectEven().EEDI2(field=0, maxd=4),
 \                 		clps.SelectOdd().EEDI2(field=1, maxd=4), U=3,V=3 )

nnedbl  =  mt_average(clpo.nnedi(field=0),clpo.nnedi(field=1),U=3,V=3)

edidbl  = (EdiMode=="NNEDI") ? nnedbl
 \                           : eeddbl 

dbdbl = mt_average(clpo.Bob().SelectEven(),clpo.Bob().SelectOdd(),U=3,V=3)

t1 = dbdbl.temporalsoften(1,255,255,32,2)
t2 = dbdbl.temporalsoften(2,255,255,32,2)

t  = (tr0==0) ? dbdbl
 \ : (tr0==1) ? t1.merge(dbdbl,0.25)
 \            : t1.merge(t2,0.357).merge(dbdbl,0.125)

tD  = mt_makediff(dbdbl,t,U=3,V=3) 
tD1 = tD.mt_inpand(mode="vertical",U=3,V=3).mt_deflate(U=3,V=3) .mt_expand(U=3,V=3)
tD2 = tD.mt_expand(mode="vertical",U=3,V=3).mt_inflate(U=3,V=3) .mt_inpand(U=3,V=3)
tDD = tD.mt_lutxy(tD1,"x 129 < x y 128 < 128 y ? ?",U=3,V=3).mt_lutxy(tD2,"x 127 > x y 128 > 128 y ? ?",U=3,V=3)
t2  = (rep0==true) ? t.mt_adddiff(tDD,U=3,V=3)
 \                 : t

searchclip = t2.removegrain(11).removegrain(11)
searchclip = (rep0==true) ? searchclip
 \                        : searchclip.mt_lutxy(edidbl,"x 2 + y < x 2 + x 2 - y > x 2 - y ? ?",U=3,V=3)

#bs   = 16
#ovlp = 4
tm   = false
pel  = 2
shrp = 2

bvec3   = (trmax>=3) ? searchclip.MVAnalyse(isb=true, delta=3,truemotion=tm,pel=pel,sharp=shrp,blksize=bs,overlap=ovlp,idx=6) : nullclip
bvec2   = (trmax>=2) ? searchclip.MVAnalyse(isb=true, delta=2,truemotion=tm,pel=pel,sharp=shrp,blksize=bs,overlap=ovlp,idx=6) : nullclip
bvec1   =              searchclip.MVAnalyse(isb=true, delta=1,truemotion=tm,pel=pel,sharp=shrp,blksize=bs,overlap=ovlp,idx=6)
fvec1   =              searchclip.MVAnalyse(isb=false,delta=1,truemotion=tm,pel=pel,sharp=shrp,blksize=bs,overlap=ovlp,idx=6)
fvec2   = (trmax>=2) ? searchclip.MVAnalyse(isb=false,delta=2,truemotion=tm,pel=pel,sharp=shrp,blksize=bs,overlap=ovlp,idx=6) : nullclip
fvec3   = (trmax>=3) ? searchclip.MVAnalyse(isb=false,delta=3,truemotion=tm,pel=pel,sharp=shrp,blksize=bs,overlap=ovlp,idx=6) : nullclip

mvdg1   =            edidbl.MVDegrain1(bvec1,fvec1,            thSAD=800,idx=7)
mvdg2   = (tr1>1) ?  edidbl.MVDegrain1(            bvec2,fvec2,thSAD=800,idx=7) : nullclip

stage1  = (tr1==0) ? edidbl
 \      : (tr1==1) ? mvdg1.merge(edidbl,0.25)
 \                 : mvdg1.merge(mvdg2,0.2).merge(edidbl,0.0625)
 
stage1a = stage1.mt_lutxy(stage1.removegrain(11),"x x y - "+string(sharpness)+" * +",U=3,V=3)
stage1b = (sharpness==0.0) ? stage1 : stage1a.repair(stage1a.repair(edidbl,12),1)
 
stage2  = (tr2==0) ? stage1b
 \      : (tr2==1) ? stage1b.MVDegrain1(bvec1,fvec1,                        thSAD=400,idx=8)
 \      : (tr2==2) ? stage1b.MVDegrain2(bvec1,fvec1,bvec2,fvec2,            thSAD=400,idx=8)
 \                 : stage1b.MVDegrain3(bvec1,fvec1,bvec2,fvec2,bvec3,fvec3,thSAD=400,idx=8)

tD_2    = mt_makediff(dbdbl,stage2,U=3,V=3) 
tD1_2   = tD_2.mt_inpand(mode="vertical",U=3,V=3).mt_deflate(U=3,V=3) .mt_expand(U=3,V=3)
tD2_2   = tD_2.mt_expand(mode="vertical",U=3,V=3).mt_inflate(U=3,V=3) .mt_inpand(U=3,V=3)
tDD_2   = tD_2.mt_lutxy(tD1_2,"x 129 < x y 128 < 128 y ? ?",U=3,V=3).mt_lutxy(tD2_2,"x 127 > x y 128 > 128 y ? ?",U=3,V=3)

stage3  = (draft==2)    ?  t .subtitle("Draft 2")
 \      : (draft==1)    ?  t2 .subtitle("Draft 1")
 \      : (rep1==true)  ?  stage2.mt_adddiff(tDD_2,U=3,V=3)
 \                      :  stage2

(border==0) ? stage3
 \          : stage3.crop(0,4,-0,-4)

return( last )
}
Or maybe this:

Code:
function TempGaussMC_mod2(clip clp, int "tr0", int "tr1", int "tr2", float "sharpness", bool "rep0", bool "rep1", int "border", int "blocksize", int "overlap", string "EdiMode", int "draft")
{
tr0       = default( tr0,     2 )  #  temporal radius for temporal Gauss before motion compensation (1 or 2)
tr1       = default( tr1,     2 )  #  temporal radius for temporal Gauss with motion compensation (1 or 2)
tr2       = default( tr2,     1 )  #  temporal radius for final MVDegrain (1, 2 or 3)
rep0      = default( rep0, true )  #  repair temporalsoften-defects for searchclip
rep1      = default( rep1, true )  #  repair MVDegrain-defects for output 
border    = default( border,  1 )  #  1 = padd borders internally to catch "half scanlines" at top + bottom (broadcast material)
bs        = default( blocksize,8)  #  Blocksize for motion search
ovlp      = default( overlap,bs/2) # Overlap size for ME blocks
sharpness = default( sharpness, 0.25+(tr1+tr2)/8.) # "inloop" sharpening to counteract softening, 0.0 to 1.0, or more if you like
EdiMode   = default( EdiMode, "NNEDI") # interpolator to use: "NNEDI", "EEDI2" 
draft     = default( draft, 0 )    #  '1' outputs a quick draft, and '2' is even more draft'ier  :p

trmax     = (tr1 > tr2) ? tr1 : tr2
nullclip  = blankclip(clp,width=16,height=16)

clpo = (border==0) ? clp
 \                : clp.pointresize(clp.width(),clp.height()+8, 0,-4,-0,clp.height()+8.001 )

clps = clpo.AssumeBFF().SeparateFields()

eeddbl   = mt_Average(clps.SelectEven().EEDI2(field=0, maxd=4),
 \                 		clps.SelectOdd().EEDI2(field=1, maxd=4), U=3,V=3 )

nnedbl  =  mt_average(clpo.nnedi(field=0),clpo.nnedi(field=1),U=3,V=3)

edidbl  = (EdiMode=="NNEDI") ? nnedbl
 \                           : eeddbl 

t1 = clpo.temporalsoften(1,255,255,32,2)
t2 = clpo.temporalsoften(2,255,255,32,2)

t  = (tr0==0) ? clpo
 \ : (tr0==1) ? t1.merge(clpo,0.25)
 \            : t1.merge(t2,0.357).merge(clpo,0.125)

tD  = mt_makediff(clpo,t,U=3,V=3) 
tD1 = tD.mt_inpand(mode="vertical",U=3,V=3).mt_deflate(U=3,V=3) .mt_expand(U=3,V=3)
tD2 = tD.mt_expand(mode="vertical",U=3,V=3).mt_inflate(U=3,V=3) .mt_inpand(U=3,V=3)
tDD = tD.mt_lutxy(tD1,"x 129 < x y 128 < 128 y ? ?",U=3,V=3).mt_lutxy(tD2,"x 127 > x y 128 > 128 y ? ?",U=3,V=3)
t2  = (rep0==true) ? t.mt_adddiff(tDD,U=3,V=3)
 \                 : t

searchclip = t2.removegrain(11).removegrain(11)
searchclip = (rep0==true) ? searchclip
 \                        : searchclip.mt_lutxy(edidbl,"x 2 + y < x 2 + x 2 - y > x 2 - y ? ?",U=3,V=3)

#bs   = 16
#ovlp = 4
tm   = false
pel  = 2
shrp = 2

bvec3   = (trmax>=3) ? searchclip.MVAnalyse(isb=true, delta=3,truemotion=tm,pel=pel,sharp=shrp,blksize=bs,overlap=ovlp,idx=6) : nullclip
bvec2   = (trmax>=2) ? searchclip.MVAnalyse(isb=true, delta=2,truemotion=tm,pel=pel,sharp=shrp,blksize=bs,overlap=ovlp,idx=6) : nullclip
bvec1   =              searchclip.MVAnalyse(isb=true, delta=1,truemotion=tm,pel=pel,sharp=shrp,blksize=bs,overlap=ovlp,idx=6)
fvec1   =              searchclip.MVAnalyse(isb=false,delta=1,truemotion=tm,pel=pel,sharp=shrp,blksize=bs,overlap=ovlp,idx=6)
fvec2   = (trmax>=2) ? searchclip.MVAnalyse(isb=false,delta=2,truemotion=tm,pel=pel,sharp=shrp,blksize=bs,overlap=ovlp,idx=6) : nullclip
fvec3   = (trmax>=3) ? searchclip.MVAnalyse(isb=false,delta=3,truemotion=tm,pel=pel,sharp=shrp,blksize=bs,overlap=ovlp,idx=6) : nullclip

mvdg1   =            edidbl.MVDegrain1(bvec1,fvec1,            thSAD=800,idx=7)
mvdg2   = (tr1>1) ?  edidbl.MVDegrain1(            bvec2,fvec2,thSAD=800,idx=7) : nullclip

stage1  = (tr1==0) ? edidbl
 \      : (tr1==1) ? mvdg1.merge(edidbl,0.25)
 \                 : mvdg1.merge(mvdg2,0.2).merge(edidbl,0.0625)
 
stage1a = stage1.mt_lutxy(stage1.removegrain(11),"x x y - "+string(sharpness)+" * +",U=3,V=3)
stage1b = (sharpness==0.0) ? stage1 : stage1a.repair(stage1a.repair(edidbl,12),1)
 
stage2  = (tr2==0) ? stage1b
 \      : (tr2==1) ? stage1b.MVDegrain1(bvec1,fvec1,                        thSAD=400,idx=8)
 \      : (tr2==2) ? stage1b.MVDegrain2(bvec1,fvec1,bvec2,fvec2,            thSAD=400,idx=8)
 \                 : stage1b.MVDegrain3(bvec1,fvec1,bvec2,fvec2,bvec3,fvec3,thSAD=400,idx=8)

tD_2    = mt_makediff(clpo,stage2,U=3,V=3) 
tD1_2   = tD_2.mt_inpand(mode="vertical",U=3,V=3).mt_deflate(U=3,V=3) .mt_expand(U=3,V=3)
tD2_2   = tD_2.mt_expand(mode="vertical",U=3,V=3).mt_inflate(U=3,V=3) .mt_inpand(U=3,V=3)
tDD_2   = tD_2.mt_lutxy(tD1_2,"x 129 < x y 128 < 128 y ? ?",U=3,V=3).mt_lutxy(tD2_2,"x 127 > x y 128 > 128 y ? ?",U=3,V=3)

stage3  = (draft==2)    ?  t .subtitle("Draft 2")
 \      : (draft==1)    ?  t2 .subtitle("Draft 1")
 \      : (rep1==true)  ?  stage2.mt_adddiff(tDD_2,U=3,V=3)
 \                      :  stage2

(border==0) ? stage3
 \          : stage3.crop(0,4,-0,-4)

return( last )
}
In both cases, I knocked off the Yadif option as I would never use it in this context. As they stand (with Tr0=2, Tr1=2, Tr2=2), both give quite decent results. The only problem area appears to in preserving uniform definition and integrity of high contrast line patterns (like the striped shirt in scene 3 of the clip I posted), notably when objects move over them. Again, dropping the EEDI2 maxd (from 8 to 4) seems to help a little.

Can’t see what parameters other than maybe the temp gauss weightings might be open for further tweaking, and I didn’t touch them. Any thoughts Didee? (hopefully other than ‘why are you still blindly screwing around with a script that wasn’t created for this purpose’ )

Writes hasty disclaimer: the above scripts are in no way intended to be taken as accepted modifications of the TempGaussMC function created by Didee for interlaced sources. They merely serve to illustrate possible approaches for applying a similar treatment to progressive/frame-based material that exhibits various forms of aliasing artifact.
__________________
Nostalgia's not what it used to be

Last edited by WorBry; 1st June 2008 at 20:57.
WorBry is offline   Reply With Quote