Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 1st July 2009, 09:31   #261  |  Link
Terka
Registered User
 
Join Date: Jan 2005
Location: cz
Posts: 704
Your math is wrong.
1fps,1fps, together 0,5fps? Lets assume PAL (50fps). MCbob is 1/50realtime. And after it every frame of MCbob is done again with speed of 1/50realtime. So 1fps is processing again, (again 50times slower than realtime).
1/50*1/50=1/2500
so you get 1 frame /50 s=0,02fps
I already tried it myselve few months ago, if you want, try mvbobmod instead of MCbob. Maybee its better.
Terka is offline   Reply With Quote
Old 1st July 2009, 10:22   #262  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
Quote:
Originally Posted by Terka View Post
Your math is wrong.
1fps,1fps, together 0,5fps? Lets assume PAL (50fps). MCbob is 1/50realtime. And after it every frame of MCbob is done again with speed of 1/50realtime. So 1fps is processing again, (again 50times slower than realtime).
1/50*1/50=1/2500
so you get 1 frame /50 s=0,02fps
Your logic is wrong.
Realtime is irrelevant. Filters don't slow things down by some constant factor, they just take the time they need. By your argument, you could make MCbob run at 50fps by adding AssumeFPS(2500).

1fps + 1fps = 0.5fps is correct.
Each frame takes 1 sec in the 1st filter and 1 sec in the 2nd, so 2 secs in total.
1 frame in 2 secs = 0.5fps.
Gavino is offline   Reply With Quote
Old 1st July 2009, 10:40   #263  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,391
Hmh ... I never actually tried it that way (MCBob as internal basic bobber for TGMC), but ... thinking about it, that's using a sledgehammer to break a nut. I'd guess you had a similar result by adjusting the "repX" parameters of TGMC - which would come for free, instead of slowing the processing down to the speed of tectonic plate shift ...

In respect to "residual bob flicker", it is pretty much unimportant which kind of basic bobber is used. For that part in TGMC, even a simple bob() gives about the same stability as the more advanced bobbers. (Stability of the motion vector field is achieved mainly by the temporal gauss filter -- after which, there is hardly any important difference left over between bobber X or Y).

If you have a sample on which TGMC leaves noticeable flickering behind, just for fun try again with settings like TGMC(2,2,2,rep0=0,rep1=0,rep2=0, ...).

Does it still flicker? ... Ah, see!

Ofcourse, all rep's at zero is quite dangerous to produce artifacts in areas with non-predictable motion. The rep's have to be balanced for a suitable compromise between [risk-of-artifacts] and [flicker removal]. It's also highly dependent on the characteristics of the source. It's a long way from a 10th-gen VHS copy up to a HD DV-cam capture.
That's why there *are* parameters, instead of just hard-wiring everything.
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 1st July 2009, 13:20   #264  |  Link
Terka
Registered User
 
Join Date: Jan 2005
Location: cz
Posts: 704
Yes, i have a bug there, instead 0,02fps
should be 0,02 realtime.
sorry.
but the equation is ok. the numbers has to be multiplied.
Terka is offline   Reply With Quote
Old 1st July 2009, 13:26   #265  |  Link
Terka
Registered User
 
Join Date: Jan 2005
Location: cz
Posts: 704
When deciding to feed TGMC with something
We can say, there are 2 inputs to TGMC.
bob() for vectors creating
edi,nnedi etc. which is used for filtering and thus seen filtered in output.
So in fact we can change input 1) or 2).
Didee, am i correct?

so if you will go extra slow, put as:
input 1) something extra stable (TGMC with long temporal filtering)
input 2) something with original rows untouched and good resolution (MCbob or mvbobmod)
you will get it aproximately 4 times slower, hopefully also a small bit better than TGMC.

Last edited by Terka; 1st July 2009 at 14:05.
Terka is offline   Reply With Quote
Old 1st July 2009, 14:53   #266  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
Quote:
Originally Posted by Terka View Post
Yes, i have a bug there, instead 0,02fps
should be 0,02 realtime.
sorry.
but the equation is ok. the numbers has to be multiplied.
If your logic was correct, it would in any case be 0,0004 realtime (1/2500).
But this is just wrong. The frame rate of the clip has no effect whatsoever on how long it takes the filter to process a frame, so please explain what realtime has to do with any of this. And where exactly does the multiplication come from?

As I said before, by your logic, you could make a script run 100 times faster by putting AssumeFPS(100*framerate()) at the start, which would be very nice, but is clearly nonsense.
Gavino is offline   Reply With Quote
Old 1st July 2009, 17:40   #267  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,391
Did anybody ever use "draft = 1" (or 2) in TGMC, and spend some minutes to reflect about the result? That's the searchclip, guys. draft=2 is the naked temporal gauss, and draft=1 is the repaired (by "rep0") version that is used to do the motion search on ...


Quote:
Originally Posted by Terka View Post
Didee, am i correct?
Halfway between right and wrong. With more weight at the right than at the left.

TGMC uses only one internal bob filter. Depending on "EdiMode", that is either NNEDI or EEDI2 or Yadif, or none of them (plain bicubic). That's what is used both for final rendering *and* for constructing the searchclip for motion search. The choice of interpolator influences the final rendering, sure. But for the motion search, again, it does hardly matter.

Moreover, the searchclip already IS flicker-free (basically...it depends on "rep0", as mentioned previously). So there's little sense to feed an "external" super-duper-flickerfree clip for motion search ... because you don't *have* such a one. That's a chicken-and-egg problem. TGMC tries to produce a flickerfree result from interlaced input. So you basically suggest to make use of a result before you have it ...

Of course, one could do something along the lines of

Code:
TGMC( prefiltered = TGMC( prefiltered = TGMC( prefiltered= ..... ))..)
Whether that makes much sense remains to be proven ... but most likely not.
(For error elimination, usually one should combine different, "perpendicular", methods. Combining one method with itself can't eliminate an error inherent to the method.)
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 15th August 2009, 22:15   #268  |  Link
Terka
Registered User
 
Join Date: Jan 2005
Location: cz
Posts: 704
Find out that TG with blocksize 32 is good for some of my DV vids (static parts), but for moving parts are better smaller blocksizes.
Want to try mrecalculate for this, correct me, if im wrong.
Code:
function TempGaussMC_beta1modii(clip clp, int "tr0", int "tr1", int "tr2", int "rep0", int "rep1", int "rep2", string "EdiMode", int "EEDI2maxd",
 \                          float "sharpness", int "Smode", int "SLmode", int "SLrad", float "Sbb", float "SVthin", int "Sovs", 
 \                          int "blocksize",int "blocksizec", int "overlap", bool "truemotion", bool "globalmtn",
 \                          int "search", int "searchparam", int "pelsearch", int "sharp", int "lambda", int "DCT", int "pnew", int "plevel", int "lsad",
 \                          int "SCth1", int "SCth2", int "thSAD1", int "thSAD2",
 \                          float "pel2hr", bool "border", int "draft",
 \			    bool "MT")
{
clp

# Defaults for temporal gauss filtering
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)

# Defaults for EDI interpolation
EdiMode   = default( EdiMode,"EEDI2")  #  interpolator to use: "NNEDI", "EEDI2" "Yadif". Any other string: use plain bicubic bob (fast!)
EEDI2maxd = default( EEDI2maxd, 8 )    #  EEDI2 interpolation only: spatial search distance value  

# Defaults for temp-gauss reparation
rep0      = default( rep0,      4 )    #  repair temporalsoften-defects for searchclip
rep1      = default( rep1,      0 )    #  repair MVDegrain-defects for output (stage1)
rep2      = default( rep2,      4 )    #  repair MVDegrain-defects for output (stage2)

# Defaults for contra-sharpening of the temp-gauss'ed clip
sharp0    = default( sharpness, 0.25+(tr1+tr2)/6.) # strength of sharpening, 0.0 to 1.0, or more if you like
Smode     = default( Smode,     2 )    #  Which method to use for re-sharpening the MC'ed temporal gauss:
                                       #    0 = not at all
                                       #    1 = 3x3 kernel
                                       #    2 = vertical min/max  plus  3x3 kernel
SLmode    = default( SLmode,    2 )    #  How to limit the sharpening: 
                                       #    0 = not at all
                                       #    1 = spatial, before 2nd MV stage      (fast)
                                       #    2 = MC-temporal, before 2nd MV stage  (slow)
                                       #    3 = spatial, after 2nd MV stage       (fast)
                                       #    4 = MC-temporal, after 2nd MV stage   (slow)
SLrad     = default( SLrad,     1 )    #  How much prev+next temporal neighbors to consider for sharpness limiting (SLmode = 2|4),
                                       #  resp. spatial radius for spatial sharpness limiting mode (SLmode = 1|3)
Sbb       = default( Sbb,       1 )    #  Back-blending of gauss-blurred sharpen's difference (slightly increases visual fidelity)
                                       #    0 = no back-blending
                                       #    1 = before sharp-limiting
                                       #    2 = after sharp-limiting
                                       #    3 = before AND after sharp-limiting
SVthin    = default( SVthin,  1.0 )    #  Vertical thinning of broadened horizontal edges. 0.0=OFF  0.5=weak  3.0=strrrong
Sovs      = default( Sovs,      0 )    #  Allowed "overshoot" for sharpness limiting (a little cheating, that is)

# Defaults for important MV-parameters
_bs       = default( blocksize,16 )    #  Blocksize for motion search
_ovlp     = default( overlap,_bs/2)    #  Overlap size for ME blocks
_bsc      = default( blocksizec ,0 )     #  Blocksize for motion search MRECALCULATE
_ovlpc    = default( overlap,_bsc/2)    #  Overlap size for ME blocks
_tm       = default( truemotion,false) #  Whether to use MVAnalyse's "truemotion" defaults
_global   = default( globalmtn, true)  #  "global" parameter of MVAnalyse

# Defaults for "less important" MV-parameters
_search   = default( search,    2 )    #  search method
_ME       = default( searchparam,2)    #  search depth
_pelsrch  = default( pelsearch, 2 )    #  accuracy of pel level search: 1 = fast, 2 = accurate
_shrp     = default( sharp,     2 )    #  sharpness of subpel interpolation
_DCT      = default( DCT,       0 )    #  DCT mode. Various modes may help or may harm ... default is 0 = OFF
_lambda   = default( lambda, _tm ? 1000* _bs*_bs /64 : 0 )   # vector coherence
_lambdac   = default( lambda, _tm ? 1000* _bsc*_bsc /64 : 0 )   # vector coherence
_pnew     = default( pnew,   _tm ? 50 : 0 )                  # penalty for new vectors over predicted vectors
_plevel   = default( plevel, _tm ?  1 : 0 )                  # lamda level scaling mode
_lsad     = default( lsad,   _tm ? 1200*_bs*_bs/64 : 400*_bs*_bs/64 ) # local lambda resetting threshold
_lsadc     = default( lsad,   _tm ? 1200*_bs*_bs/64 : 400*_bsc*_bsc/64 ) # local lambda resetting threshold

# Scenechange thresholds and MVDegrain thSAD value. 
# ***** DO NOT TOUCH WITHOUT SPECIFIC REASON *****
_SCth1    = default( SCth1,     180 )  #  SAD threshold for "bad blocks" 
_SCth2    = default( SCth2,      98 )  #  percentage of bad blocks to trigger a scenechange
_thSAD1   = default( thSAD1, 5* 128 )  #  SAD threshold for 1st MVDegrain (gaussian stage)  
_thSAD2   = default( thSAD2, 2* 128 )  #  SAD threshold for 2nd MVDegrain (linear stage)

# other stuff
border    = default( border,   true )  #  true = padd borders internally to catch "half scanlines" at top + bottom (broadcast material)
draft     = default( draft,       0 )  #  '1' outputs a quick draft, and '2' is even more draft'ier  :p
pel2hr    = default( pel2hr,    0.0 )  #  0.0 is OFF.  0.1 ~ 0.3 can be useful to reduce halo-amplifying of pel=2 subsampling 
MT	  = default( MT,      false )  #  true = use the multithreaded branch of MVtools
ST	  = mt ? false : true 		# Single-thread
RefineMotion = (_bsc!=0) ? true : false  #use recalculate?


# parameter adjustments for internal usage
sharpness = default(sharpness, (SLmode==1||SLmode==3) ? sharp0 : 2*sharp0 ) # temporal limiting can afford more than spatial limiting
ed0       = rep0<10 ? rep0 : rep0/10
od0       = rep0<10 ?    0 : rep0-ed0*10
ed1       = rep1<10 ? rep1 : rep1/10
od1       = rep1<10 ?    0 : rep1-ed1*10
ed2       = rep2<10 ? rep2 : rep2/10
od2       = rep2<10 ?    0 : rep2-ed2*10
trmax     = (tr1 > tr2) ? tr1 : tr2
use1      = (trmax > 0) ? true : false
use2      = (trmax > 1) ? true : false
use3      = (trmax > 2 || SLrad>1) ? true : false
thinn     = SVthin * 6.0


#---------------------------------------------------------------------------------------------------
# Let's start doing something.

nullclip  = blankclip(clp,width=16,height=16) 

# if "border" is requested, apply padding by 4 pixels at top & bottom
clp = (border) ? clp.pointresize(clp.width(),clp.height()+8, 0,-4,-0,clp.height()+8.001 )
 \             : clp
ox = clp.width()
oy = clp.height()

# Create spatially interpolated bob-clips
dbob = clp.bob(0,0.5)
edi  = (EdiMode=="NNEDI") ? clp.nnedi(field=-2)
 \   : (EdiMode=="EEDI2") ? clp.SeparateFields().EEDI2(field=-2, maxd=EEDI2maxd) 
 \   : (EdiMode=="Yadif") ? clp.Yadif(mode=1)
 \   : (EdiMode=="NNEDI2")? clp.nnedi2(field=-2)
 \                        : dbob

# create linearily weighted temporal averaging
t1 = dbob.temporalsoften(1,255,255,28,2)
t2 = dbob.temporalsoften(2,255,255,28,2)

# construct temporal gaussian average from linear averages
t  = (tr0==0) ? dbob
 \ : (tr0==1) ? t1.merge(dbob,0.25)
 \            : t1.merge(t2,0.357).merge(dbob,0.125)

# IF rep0=true: Allow only bob-typical vertical differences
t1 = t.VCRep(dbob,ed=ed0,od=od0)
t2 = (rep0!=0) ? t1 : t

# Create clip for motion search.
# Trick: weight-in a gaussian blur, to reduce local contrast of searchclip. (Needed to later make MVDegrain work as expected ...the "SAD concept" doesn't fit
#                                                                            to the realities -- so, let's tailor the realities to fit the darn concept ...)
t3=mt_lutxy(t2,dbob,"x 3 + y < x 3 + x 3 - y > x 3 - y ? ?",U=3,V=3) # small cheat for better motion search
searchclip = t2.removegrain(11).gaussresize(ox,oy,0,0,ox+.0001,oy+.0001,p=2)
 \             .merge(t2,0.1).mt_lutxy(t3,"x 7 + y < x 2 + x 7 - y > x 2 - x 51 * y 49 * + 100 / ? ?",U=3,V=3)


# Get motion vectors
_pel  = 2

searchclipsuper = searchclip.msuper(pel=_pel,sharp=_shrp, levels=0)
recalculate     = searchclip.MSuper(pel=_pel,sharp=_shrp, levels=1)



allv = 	 nullclip

bvec3   = (use3) ?  searchclipsuper.MAnalyse(isb=true, delta=3,truemotion=_tm,blksize=_bs,overlap=_ovlp,lambda=_lambda,pnew=_pnew,
 \                                           global=_global,search=_search,searchparam=_ME,pelsearch=_pelsrch,DCT=_DCT,plevel=_plevel,lsad=_lsad) : nullclip  # ,sadx264=3
bvec3   = (use3&&RefineMotion) ? MRecalculate(recalculate, bvec3,isb=true, delta=3,truemotion=_tm,  blksize=_bsc,  overlap=_ovlpc,lambda=_lambdac,pnew=_pnew,
 \                                           global=_global,search=_search,searchparam=_ME,pelsearch=_pelsrch,DCT=_DCT,plevel=_plevel,lsad=_lsadc) : nullclip  # ,sadx264=3
bvec2   = (use2) ? 	searchclipsuper.MAnalyse(isb=true, delta=2,truemotion=_tm,blksize=_bs,overlap=_ovlp,lambda=_lambda,pnew=_pnew,
 \                                           global=_global,search=_search,searchparam=_ME,pelsearch=_pelsrch,DCT=_DCT,plevel=_plevel,lsad=_lsad) : nullclip  # ,sadx264=3
bvec2   = (use2&&RefineMotion) ? MRecalculate(recalculate, bvec3,isb=true, delta=2,truemotion=_tm,  blksize=_bsc,  overlap=_ovlpc,lambda=_lambdac,pnew=_pnew,
 \                                           global=_global,search=_search,searchparam=_ME,pelsearch=_pelsrch,DCT=_DCT,plevel=_plevel,lsad=_lsadc) : nullclip  # ,sadx264=3

bvec1   = (use1) ?	searchclipsuper.MAnalyse(isb=true, delta=1,truemotion=_tm,blksize=_bs,overlap=_ovlp,lambda=_lambda,pnew=_pnew,
 \                                           global=_global,search=_search,searchparam=_ME,pelsearch=_pelsrch,DCT=_DCT,plevel=_plevel,lsad=_lsad) : nullclip  # ,sadx264=3
bvec1   = (use1&&RefineMotion) ? MRecalculate(recalculate, bvec3,isb=true, delta=1,truemotion=_tm,  blksize=_bsc,  overlap=_ovlpc,lambda=_lambdac,pnew=_pnew,
 \                                           global=_global,search=_search,searchparam=_ME,pelsearch=_pelsrch,DCT=_DCT,plevel=_plevel,lsad=_lsadc) : nullclip  # ,sadx264=3

fvec1   = (use1) ? 	searchclipsuper.MAnalyse(isb=false,delta=1,truemotion=_tm,blksize=_bs,overlap=_ovlp,lambda=_lambda,pnew=_pnew,
 \                                           global=_global,search=_search,searchparam=_ME,pelsearch=_pelsrch,DCT=_DCT,plevel=_plevel,lsad=_lsad) : nullclip  # ,sadx264=3
fvec1   = (use1&&RefineMotion) ? MRecalculate(recalculate, fvec1,isb=false, delta=1,truemotion=_tm,  blksize=_bsc,  overlap=_ovlpc,lambda=_lambdac,pnew=_pnew,
 \                                           global=_global,search=_search,searchparam=_ME,pelsearch=_pelsrch,DCT=_DCT,plevel=_plevel,lsad=_lsadc) : nullclip  # ,sadx264=3

fvec2   = (use2) ? 	searchclipsuper.MAnalyse(isb=false,delta=2,truemotion=_tm,blksize=_bs,overlap=_ovlp,lambda=_lambda,pnew=_pnew,
 \                                           global=_global,search=_search,searchparam=_ME,pelsearch=_pelsrch,DCT=_DCT,plevel=_plevel,lsad=_lsad) : nullclip  # ,sadx264=3
fvec2   = (use2&&RefineMotion) ? MRecalculate(recalculate, fvec2,isb=false, delta=2,truemotion=_tm,  blksize=_bsc,  overlap=_ovlpc,lambda=_lambdac,pnew=_pnew,
 \                                           global=_global,search=_search,searchparam=_ME,pelsearch=_pelsrch,DCT=_DCT,plevel=_plevel,lsad=_lsadc) : nullclip  # ,sadx264=3

fvec3   = (use3) ? 	searchclipsuper.                    MAnalyse(isb=false,delta=3,truemotion=_tm,blksize=_bs,overlap=_ovlp,lambda=_lambda,pnew=_pnew,
 \                                           global=_global,search=_search,searchparam=_ME,pelsearch=_pelsrch,DCT=_DCT,plevel=_plevel,lsad=_lsad) : nullclip  # ,sadx264=3
fvec3   = (use3&&RefineMotion) ? MRecalculate(recalculate, fvec3,isb=false, delta=3,truemotion=_tm,  blksize=_bsc,  overlap=_ovlpc,lambda=_lambdac,pnew=_pnew,
 \                                           global=_global,search=_search,searchparam=_ME,pelsearch=_pelsrch,DCT=_DCT,plevel=_plevel,lsad=_lsadc) : nullclip  # ,sadx264=3

vec1	= nullclip
vec2	= nullclip
deg2	= nullclip


# create motion compensated temporal averaging with linear weighting
   #tr1  temporal radius for temporal Gauss with motion compensation (1 or 2)
edisuper= st ? edi.msuper(pel=_pel,sharp=_shrp, levels=1) : nullclip
mvdg1   =     	    edi.MDegrain1(edisuper,bvec1,fvec1,            thSAD=_thSAD1,thSCD1=_SCth1,thSCD2=_SCth2)
mvdg2   = (tr1>1) ? edi.MDegrain1(edisuper,            bvec2,fvec2,thSAD=_thSAD1,thSCD1=_SCth1,thSCD2=_SCth2) : nullclip

# create explicit motion compensations (needed for SLmode = 2|4)
comp_fw1 = (SLmode==2 || SLmode==4)         ?  st ? edi.MCompensate(edisuper,fvec1,thSCD1=_SCth1,thSCD2=_SCth2) : edi.MVCompensate(fvec1,thSCD1=_SCth1,thSCD2=_SCth2,idx=7) : nullclip
comp_bw1 = (SLmode==2 || SLmode==4)         ?  st ? edi.MCompensate(edisuper,bvec1,thSCD1=_SCth1,thSCD2=_SCth2) : edi.MVCompensate(bvec1,thSCD1=_SCth1,thSCD2=_SCth2,idx=7) : nullclip
comp_fw3 = (SLmode==2 || SLmode==4)&& use3  ?  st ? edi.MCompensate(edisuper,fvec3,thSCD1=_SCth1,thSCD2=_SCth2) : edi.MVCompensate(fvec3,thSCD1=_SCth1,thSCD2=_SCth2,idx=7) : nullclip
comp_bw3 = (SLmode==2 || SLmode==4)&& use3  ?  st ? edi.MCompensate(edisuper,bvec3,thSCD1=_SCth1,thSCD2=_SCth2) : edi.MVCompensate(bvec3,thSCD1=_SCth1,thSCD2=_SCth2,idx=7) : nullclip
Terka is offline   Reply With Quote
Old 15th August 2009, 22:17   #269  |  Link
Terka
Registered User
 
Join Date: Jan 2005
Location: cz
Posts: 704
the continue:

Code:
    
# cheap halo-reduction for sharp pel modes (for Lmode=2|4)
cx1=comp_fw1.width()
cx3=comp_fw3.width()
cy1=comp_fw1.height()
cy3=comp_fw3.width()
comp_fw1 = (pel2hr==0.0) ?  comp_fw1 :  comp_fw1.mergeluma(comp_fw1.removegrain(11,-1).gaussresize(cx1,cy1,0,0,cx1+.0001,cy1+.0001,p=5),pel2hr)
comp_fw3 = (pel2hr==0.0) ?  comp_fw3 :  comp_fw3.mergeluma(comp_fw3.removegrain(11,-1).gaussresize(cx3,cy3,0,0,cx3+.0001,cy3+.0001,p=5),pel2hr)
comp_bw1 = (pel2hr==0.0) ?  comp_bw1 :  comp_bw1.mergeluma(comp_bw1.removegrain(11,-1).gaussresize(cx1,cy1,0,0,cx1+.0001,cy1+.0001,p=5),pel2hr)
comp_bw3 = (pel2hr==0.0) ?  comp_bw3 :  comp_bw3.mergeluma(comp_bw3.removegrain(11,-1).gaussresize(cx3,cy3,0,0,cx3+.0001,cy3+.0001,p=5),pel2hr)
     
# figure local min & max over given temporal window (for Lmode=2|4)
pmax = (SLrad>0) ? edi .mt_logic(comp_fw1,"max",U=3,V=3).mt_logic(comp_bw1,"max",U=3,V=3) : edi
pmax = (SLrad>1) ? pmax.mt_logic(comp_fw3,"max",U=3,V=3).mt_logic(comp_bw3,"max",U=3,V=3) : pmax
pmin = (SLrad>0) ? edi .mt_logic(comp_fw1,"min",U=3,V=3).mt_logic(comp_bw1,"min",U=3,V=3) : edi
pmin = (SLrad>1) ? pmin.mt_logic(comp_fw3,"min",U=3,V=3).mt_logic(comp_bw3,"min",U=3,V=3) : pmin

# create motion-compensated temporal gaussian blur
stage1  = (tr1==0) ? edi
 \      : (tr1==1) ? mvdg1.merge(edi,0.25)
 \                 : mvdg1.merge(mvdg2,0.2).merge(edi,0.0625)

# IF rep1=true: Allow only bob-typical vertical differences
stage1 = (rep1!=0) ? stage1.VCRep(edi,ed=ed1,od=od1) : stage1


# calculate vertical median (for thinning), and vertical min-max-average (for sharpening)
vmedD   = mt_luts(stage1,stage1,mode="median",pixels="0 -1 0 0 0 1",yexpr="128 x y - "+string(thinn)+" * -",U=1,V=1).blur(1,0)
vmedDD  = mt_lutxy(vmedD,vmedD.removegrain(11,-1),"y 128 - abs x 128 - abs > y 128 ?")
st1mmavg =  mt_average( stage1.mt_expand(mode="vertical",U=3,V=3),stage1.mt_inpand(mode="vertical",U=3,V=3),U=3,V=3 )
 \         .mt_lutxy(stage1,"x y < x 1 + x y > x 1 - x ? ?",U=3,V=3)

# re-sharpen the temporal gaussian blur 
stage1a = (Smode==0) ? stage1
 \      : (Smode==1) ? stage1.mt_lutxy(stage1.removegrain(11),"x x y - "+string(sharpness)+" * +",U=3,V=3)
 \                   : stage1.mt_lutxy(st1mmavg.removegrain(11),"x x y - "+string(sharpness)+" * +",U=3,V=3)

# apply vertical thinning?
stage1a = (SVthin==0.0) ? stage1a : stage1a.mt_adddiff(vmedDD,U=2,V=2)

# apply 1st sharpening back-blending?
stage1a = ((Sbb==1 || Sbb==3) && Smode!=0 && sharpness!=0.0) 
 \       ? stage1a.mt_makediff(mt_makediff(stage1a,stage1,U=1,V=1).removegrain(11,-1).gaussresize(ox,oy,0,0,ox+.0001,oy+.0001,p=5),U=2,V=2) 
 \       : stage1a

# apply sharpening limiting? (SLmode 1|2)
stage1b = (sharpness==0.0) ? stage1 
 \                         : (SLmode==1) ? ( (SLrad<2) ? stage1a.repair(edi,1) : stage1a.repair(stage1a.repair(edi,12),1) )
 \                         : (SLmode==2) ? stage1a.mt_clamp(pmax,pmin,Sovs,Sovs,U=3,V=3)
 \                                       : stage1a

# apply 2nd sharpening back-blending?
stage1b = ((Sbb==2 || Sbb==3) && Smode!=0 && sharpness!=0.0) 
 \       ? stage1b.mt_makediff(mt_makediff(stage1b,stage1,U=1,V=1).gaussresize(ox,oy,0,0,ox+.0001,oy+.0001,p=5),U=2,V=2) 
 \       : stage1b
    
# final temporal filter for stabilisation, motion-compensated
stage1bsuper= st ? stage1b.msuper(pel=_pel,sharp=_shrp, levels=1) : nullclip
stage2  = (tr2==0) ? stage1b
 \      : (tr2==1 && MT) ? stage1b.MVDegrainMulti(vec1,thSAD=_thSAD2,thSCD1=_SCth1,thSCD2=_SCth2,idx=8) : (tr2==1) ? stage1b.MDegrain1(stage1bsuper,bvec1,fvec1,                        thSAD=_thSAD2,thSCD1=_SCth1,thSCD2=_SCth2)
 \      : (tr2==2 && MT) ? stage1b.MVDegrainMulti(deg2,thSAD=_thSAD2,thSCD1=_SCth1,thSCD2=_SCth2,idx=8) : (tr2==2) ? stage1b.MDegrain2(stage1bsuper,bvec1,fvec1,bvec2,fvec2,            thSAD=_thSAD2,thSCD1=_SCth1,thSCD2=_SCth2)
 \                 : MT  ? stage1b.MVDegrainMulti(allv,thSAD=_thSAD2,thSCD1=_SCth1,thSCD2=_SCth2,idx=8) : 	     stage1b.MDegrain3(stage1bsuper,bvec1,fvec1,bvec2,fvec2,bvec3,fvec3,thSAD=_thSAD2,thSCD1=_SCth1,thSCD2=_SCth2)

# IF rep2=true: Allow only bob-typical vertical differences
stage2  = (rep2!=0) ? stage2.VCRep(edi,ed=ed2,od=od2) : stage2

## MVDegrain causes a chroma shift (yes it does, with pel>1 !)  We compensate by shifting chroma towards plain EDI by a small notch 
##   [ 1+(x-1)/(1+(x/5)^4) ] on 128-centered diff-clip (x-y) ==>  [ x y - abs 2 < y x x y - abs 1 - 1 x y - abs 5 / 4 ^ + / 1 + x y - x y - abs 0.0001 + / * + ? ]
#mod : disabled with MVTools2 since it has been corrected in MVTools 1.10.2.1
stage2 = mt ? stage2.mt_lutxy(edi,"x y - abs 2 < y x x y - abs 1 - 1 x y - abs 5 / 4 ^ + / 1 + x y - x y - abs 0.0001 + / * - ?",Y=2,U=3,V=3) : stage2
 
# apply sharpness limiting (SLmode 3|4), or has "draft" been requested?
stage3  = (draft==2)   ?  t  .subtitle("Draft 2")
 \      : (draft==1)   ?  t1 .subtitle("Draft 1")
 \      : (SLmode==3)  ?  ( (SLrad<2) ? stage2.repair(edi,1) : stage2.repair(stage2.repair(edi,12),1) )
 \      : (SLmode==4)  ?  stage2.mt_clamp(pmax,pmin,Sovs,Sovs,U=3,V=3)
 \                     :  stage2


##########################################
# if "border" was active, crop it back again
(border) ? stage3.crop(0,4,-0,-4)
 \       : stage3


 
return( last )
}
but getting invalid vector stream error. Where is the bug sitting there?
Terka is offline   Reply With Quote
Old 16th August 2009, 13:42   #270  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,391
Copy/paste woes ... like e.g.

Code:
bvec2   = (use2&&RefineMotion) ? MRecalculate(recalculate, bvec3,isb=true, delta=2,truemotion=.....
there's more of those, check them all.
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 17th August 2009, 09:21   #271  |  Link
Terka
Registered User
 
Join Date: Jan 2005
Location: cz
Posts: 704
sorry, i put wrong file.
but when mrecalculating only bvec1 (to have only 1 line containing possible error, other mrec lines are commented):
Code:
 bvec1 =                           searchclipsuper.MRecalculate( bvec1 )
still got error at line:
mvdg1 = edi.MDegrain1(edisuper,bvec1,fvec1, thSAD=_thSAD1,thSCD1=_SCth1,thSCD2=_SCth2)
"mvbw`s block size is incorrect"
my fault- have to change BOTH bvec1 and also fvec2

Last edited by Terka; 17th August 2009 at 10:07.
Terka is offline   Reply With Quote
Old 17th August 2009, 10:12   #272  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,391
Sorry, but I can't tell what's causing that problem for you. The following simple code does work for me:
(Using MVtools2 - v2.4.7, just downloaded a few minutes ago)

Code:
o     = last 
osup  = o.msuper()
bv1   = osup.manalyse(isb=true, blksize=32,overlap=16)
fv1   = osup.manalyse(isb=false,blksize=32,overlap=16)
bv1a  = osup.mrecalculate(bv1,thSAD=200,blksize=8,overlap=4) 
fv1a  = osup.mrecalculate(fv1,thSAD=200,blksize=8,overlap=4) 

dg1   = o.mdegrain1(osup,bv1,fv1)
dg1a  = o.mdegrain1(osup,bv1a,fv1a)

stackhorizontal(dg1,dg1a)
Right now, the only advice is: check all your syntax & parameters very carefully.

Note that you need either *all* or *none* of the vector clips to be recalculated (at least when changing the block-size). It will not work if some of the vector clips are mrecalculate'd and some are not.

___

edit - saw your edit only after submitting my post. Seems the problem is solved.
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)

Last edited by Didée; 17th August 2009 at 10:14.
Didée is offline   Reply With Quote
Old 17th August 2009, 13:45   #273  |  Link
Terka
Registered User
 
Join Date: Jan 2005
Location: cz
Posts: 704
Didee, thank you. its solved now. It looks like that the logic - first 32, then 4 blocksize looks better. now i have to check on different sources.
maybee there is a question, if also change the "calmclip" for the mrecalculate, or have same clip for both searches.
And there is a question, which setting to change for 2nd search (blocksize,..)?
Terka is offline   Reply With Quote
Old 17th August 2009, 14:26   #274  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,391
Yes ... when using vector re-calculation in such a way, it might be better to use a less aggressively (or not at all) filtered searchclip for the re-calculation. Or it might not, you never know. That's question hard to answer from a theoretical point of view ... meaningful answers would come only by doing lots of experimentation.
(Which I'm not about to do these days - it's up to y'all, folks.)
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 17th August 2009, 15:14   #275  |  Link
Terka
Registered User
 
Join Date: Jan 2005
Location: cz
Posts: 704
Didee,
i am testing alot
btw:
ed0 = rep0<10 ? rep0 : rep0/10
od0 = rep0<10 ? 0 : rep0-ed0*10

gives me od0 always 0. I suppose this is not the expected behaviour?
Terka is offline   Reply With Quote
Old 17th August 2009, 19:05   #276  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,391
That piece of code does exactly what it's supposed to do. The numbers for "repX" may carry two parameters in one number. The first part is the erosion distance, the 2nd part is the distance for over-dilation - e.g.

rep0 = 13

doesn't read "thirteen", but it reads "one-three", and means

"for repairing the difference mask of stage 0, use erosion = 1 , overdilation = 3".

As long as a single-digit is specified (like e.g. "rep0=2"), the overdilation distance is zero. (i.e. the dilation distance is equivalent to the erosion distance)

The motivation behind was that, in case of very strict repairing of the difference mask (i.e. allowing only very little error), over-dilation might give a bit more headroom to rescue more of the wished effect from being erroneously repaired.

Honestly, I can't tell whether over-dilation makes any noticeable improvement or not. I did put it in just in case ... the theoretical POV is that it might help occasionally, while it's almost impossible to do any harm.
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 18th August 2009, 11:57   #277  |  Link
Terka
Registered User
 
Join Date: Jan 2005
Location: cz
Posts: 704
i see.
i couldnot chceck myself, because i dont know how to see a value of numeric variable. following doesnot work:
Code:
var=5
clp.subtitle(var)
so the divide is provided on integers, so for
ed0 = rep0<10 ? rep0 : rep0/10
od0 = rep0<10 ? 0 : rep0-ed0*10
rep0=13, ed0=1 not 1.3?

Last edited by Terka; 18th August 2009 at 12:00.
Terka is offline   Reply With Quote
Old 18th August 2009, 13:51   #278  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
Quote:
Originally Posted by Terka View Post
i couldnot chceck myself, because i dont know how to see a value of numeric variable.
clp.Subtitle(string(var))
Quote:
so the divide is provided on integers, so for
ed0 = rep0<10 ? rep0 : rep0/10
od0 = rep0<10 ? 0 : rep0-ed0*10
rep0=13, ed0=1 not 1.3?
Assuming rep0 is type integer, yes.
To get 1.3, you would need to convert it to a float
float(rep0)/10

You should read this page about types and variables.
Gavino is offline   Reply With Quote
Old 18th August 2009, 14:35   #279  |  Link
Terka
Registered User
 
Join Date: Jan 2005
Location: cz
Posts: 704
Thank you!
Terka is offline   Reply With Quote
Old 1st October 2009, 14:12   #280  |  Link
vorob
Registered User
 
Join Date: Apr 2004
Posts: 34
Got XR500E camera, and "steps" on some lines in video was my real headache. But now, using this deinterlace method I've got real 50fps video without any crap.

The only problem is speed. Got 0,5 fps on my pc
http://vorobfiles.narod.ru/Config/config.htm

My question is, are development stopped or not? Any info on speeding this process via video card?
vorob is offline   Reply With Quote
Reply

Tags
deinterlace, flickering

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 17:06.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.