View Single Post
Old 4th August 2018, 15:13   #23  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Post #2 of Many.

Code:
                                    if(Stat==FLG_DUP@@@) {
                                        if(Frames!="") {
                                            if(!Ranges) { for(j=0,Count-1)   { RT_WriteFile(Frames,"%d",i+j,Append=True) }}
                                            Else if(Count>1)                 { RT_WriteFile(Frames,"%d,%d",i,i+Count-1,Append=True)}
                                            Else if(!FrameAsRange)           { RT_WriteFile(Frames,"%d",i,Append=True)}
                                            Else if(i==0 && Count==1)        { RT_WriteFile(Frames,"%d,-1",i,Append=True)}
                                            Else                             { RT_WriteFile(Frames,"%d,%d",i,i,Append=True)}
                                        }
                                        if(Show) {
                                            Global nDupeSeq@@@=nDupeSeq@@@+1
                                            if(Count > DupeLenMax@@@) {Global DupeLenMax@@@=Count  Global DupePosMax@@@=i}
                                            Global nDupes@@@=nDupes@@@+Count
                                        }
                                    }
                                }
                                for(j=i,i+Count-1) {
                                    Anchor=Max(Anchor,j-LagMax)
                                    RT_DBaseSetField(DB,j,0,Stat,StartU,EndU,Anchor,j-i) # Count Field NOT SET
                                }
                            }
                            RT_DBaseSetField(DB,i,FLD_COUNT@@@,Count) # set SubSequence Start count field
                        }
                        i=i+Count-1    # Last K frame (next time for/next incr to i+1)
                    } # end for i
                    seqLen=(EndU-StartU-1)
                    Global nDone@@@=nDone@@@+seqLen
                    if(nDone@@@==FC) { RT_DBaseSetId(DB,1,FC) }
                    if(Show) {
                        Global nSeq@@@=nSeq@@@+1
                        if(seqLen>MaxSeqLen@@@) { Global MaxSeqLen@@@=seqLen    Global MaxSeqPos@@@=StartU+1 }
                    }
                    Stat=RT_DBaseGetField(DB,n,FLD_STAT@@@) # Get Status of 1st SubSequence
                } # End, If(pG > ThG)
            } # End Stat==0
            ###
            if(Show || (Mode>0 && Stat==FLG_DUP@@@)) {
                Index=RT_DBaseGetField(DB,n,FLD_INDEX@@@)
                SStart=n-Index          # Start of Current SubSequence
                Count=RT_DBaseGetField(DB,SStart,FLD_COUNT@@@)     # Count stored only in first Record of Sub Sequence
                if(Mode == 1 && Stat==FLG_DUP@@@) {     # Mode==1, Exact Dupe
                    c.Trim(SStart-1,-1)
                    ShowDot?RT_Subtitle(DotE@@@):NOP
                } Else if(Mode==2 && Stat==FLG_DUP@@@) {                                              # Mode==2, Interpolate/Blend
                    if(Count > MaxInterp) {                                                           # Blend Morph
                        Weight = (Index + 1).Float / (Count+1)
                        Merge(c.Trim(SStart-1,-1),c.Trim(SStart+Count,-1), Weight)
                        ShowDot?RT_Subtitle(DotB@@@):NOP
                    } else if(InterpFast) {                                                           # Interpolate
                        if      (Count==1) { I10@@@ }
                        Else if (Count==2) { Index==0?I20@@@:I21@@@ }
                        Else if (Count==3) { Index==0?I30@@@:(Index==1)?I31@@@:I32@@@ }
                        Else if (Count==4) { Index==0?I40@@@:(Index==1)?I41@@@:(Index==2)?I42@@@:I43@@@ }
                        Else if (Count==5) { Index==0?I50@@@:(Index==1)?I51@@@:(Index==2)?I52@@@:(Index==3)?I53@@@:I54@@@ }
                        Else if (Count==6) { Index==0?I60@@@:(Index==1)?I61@@@:(Index==2)?I62@@@:(Index==3)?I63@@@:(Index==4)?I64@@@:I65@@@ }
                        Else if (Count==7) { Index==0?I70@@@:(Index==1)?I71@@@:(Index==2)?I72@@@:(Index==3)?I73@@@:(Index==4)?I74@@@:
                            \(Index==5)?I75@@@:I76@@@ }
                        Else if (Count==8) { Index==0?I80@@@:(Index==1)?I81@@@:(Index==2)?I82@@@:(Index==3)?I83@@@:(Index==4)?I84@@@:
                            \ (Index==5)?I85@@@:(Index==6)?I86@@@:I87@@@ }
                        Else if (Count==9) { Index==0?I90@@@:(Index==1)?I91@@@:(Index==2)?I92@@@:(Index==3)?I93@@@:(Index==4)?I94@@@:
                            \ (Index==5)?I95@@@:(Index==6)?I96@@@:(Index==7)?I97@@@:I98@@@ }
                        ShowDot?RT_Subtitle(DotI@@@):NOP
                    } Else {
                        fillMax=3
                        LS=Max(SStart-fillMax,0)  RS=SStart+Count       # Range limit for trim (cannot eg trim prior frame 0)
                        LCnt=SStart-LS      RCnt=Min(FC-RS,fillMax)
                        Tmp_c = c.Trim(LS,-LCnt) + c.Trim(RS,-RCnt)     # Dupes trimmed out, with ideally two frames before & two after.
                        Prefilt=Tmp_c.RemoveGrain(22)
                        Super=Tmp_c.MSuper(hpad=SPad@@@,vpad=SPad@@@,levels=1,sharp=SSharp@@@,rfilter=SRFilter@@@)
                        Superfilt=Prefilt.MSuper(hpad=SPad@@@,vpad=SPad@@@,sharp=SSharp@@@,rfilter=SRFilter@@@)
                        bv=Superfilt.MAnalyse(isb=true  ,blksize=ABlkSize@@@,overlap=AOverLap@@@,search=ASearch@@@,delta=1,dct=ADct@@@)
                        fv=Superfilt.MAnalyse(isb=False ,blksize=ABlkSize@@@,overlap=AOverLap@@@,search=ASearch@@@,delta=1,dct=ADct@@@)
                        if(RBlkSize@@@>0) {
                            bv=Super.MRecalculate(bv,blksize=RBlkSize@@@,overlap=ROverLap@@@,thSAD=RthSAD@@@)
                            fv=Super.MRecalculate(fv,blksize=RBlkSize@@@,overlap=ROverLap@@@,thSAD=RthSAD@@@)
                        }
                        Tmp_I=Tmp_c.MFlowInter(Super,bv,fv,time=100.0*(Index+1)/(Count+1),ml=Iml@@@,blend=IBlend@@@,thSCD1=IthSCD1@@@,thSCD2=IthSCD2@@@)
                        Tmp_I.Trim(LCnt-1,-1)  # NO SHIFT, fixed frame @ LCnt-1 ie same as Left PreDupe frame
                        ShowDot?RT_Subtitle(DotI@@@):NOP
                    } # End, Count > MaxInterp
                } Else If(Mode==0 && Stat==FLG_DUP@@@  && ShowDot) {
                    ShowDot?RT_Subtitle(DotD@@@):NOP
                }
                if(Show&&!ShowDot) {
                    pG = RT_FrameDifference(dc,dc,n=n,n2=n-1,ChromaWeight=CW,chromai=ChromaI) # dif to prev
                    pB = RT_FrameMovement(dc,dc,n=n,n2=n-1,ChromaWeight=CW,AltScan=AltSCan,ChromaI=ChromaI,
                            \ BlkW=BlkW,BlkH=BlkH,OLapX=OLapX,OLapY=OLApY,BlkTh=ThB,Prefix="p@@@")
                    pP = RT_LumaPixelsDifferent(dc,dc,n=n,n2=n-1,Thresh=ThP)
                    kG = RT_YPlaneMinMaxDifference(dc,n=n,Threshold=0.2)
                    if(Stat<=FLG_UU@@@&&Stat>=FLG_OO@@@) {        # Unique-ish (Anchor not tested)
                        if (ShowBlk && pB>0.0) {
                            if(pB>ThB) { Overlay(HitMrk@@@, x=X+p@@@XOFF,y=Y+p@@@YOFF,Mask=HitMsk@@@, Mode="Blend",output=OutCS@@@) }
                            Else       { Overlay(MissMrk@@@,x=X+p@@@XOFF,y=Y+p@@@YOFF,Mask=MissMsk@@@,Mode="Blend",output=OutCS@@@) }
                        }
                        if(Stat==FLG_OO@@@)       { RT_Subtitle(FmtOO@@@,n,pG,pB,pP*100.0/255.0,kG) }   # 1 User Override FLG_OO@@@
                        Else if(Stat==FLG_UK@@@) { RT_Subtitle(FmtUK@@@,n,pG,pB,pP*100.0/255.0,kG) }   # 2 K Override
                        Else if(Stat==FLG_UU@@@)  { RT_Subtitle(FmtUU@@@,n,(pB>ThB)?45:76,(pP>igP)?45:76,pG,pB,pP*100.0/255.0,kG) } # 3 Unique
                    } Else {
                        StartU=RT_DBaseGetField(DB,n,FLD_START@@@)
                        EndU=RT_DBaseGetField(DB,n,FLD_END@@@)
                        Anchor=RT_DBaseGetField(DB,n,FLD_ANCHOR@@@)
                        UIndex=n-StartU         # LoMo Index  relative StartU (1 relative)
                        UCount=EndU-StartU-1    # Total LoMo sequence count
                        aG=RT_FrameDifference(dc,dc,n=n,n2=Anchor,ChromaWeight=CW,chromai=ChromaI)
                        aB=RT_FrameMovement(dc,dc,n=n,n2=Anchor,ChromaWeight=CW,AltScan=AltSCan,ChromaI=ChromaI,
                              \ BlkW=BlkW,BlkH=BlkH,OLapX=OLapX,OLapY=OLApY,BlkTh=ThB,Prefix="a@@@")
                        aP=RT_LumaPixelsDifferent(dc,dc,n=n,n2=Anchor,Thresh=ThP)
                        if (ShowBlk && aB>0.0) {
                            if(aB>ThB)  { Overlay(HitMrk@@@, x=X+a@@@XOFF,y=Y+a@@@YOFF,Mask=HitMsk@@@, Mode="Blend",output=OutCS@@@) }
                            Else        { Overlay(MissMrk@@@,x=X+a@@@XOFF,y=Y+a@@@YOFF,Mask=MissMsk@@@,Mode="Blend",output=OutCS@@@) }
                        }
                        if(Stat==FLG_LM@@@) {        # LoMo
                            GCol=(aG>ThG)?33:76     BCol=(aB>ThB)?33:76     PCol=(aP>IgP)?33:76
                            RT_Subtitle(FmtLM@@@,n,GCol,BCol,PCol,UIndex,UCount,Index+1,Count,StartU,EndU,
                                \ pG,pB,pP*100.0/255.0,GCol==33?33:45,aG,BCol==33?33:45,aB,PCol==33?33:45,aP*100.0/255.0,kG,Anchor,n-Anchor)
                        } Else if(Stat==FLG_DUP@@@) { # Dupe
                            ch=Mode==2?(Count>MaxInterp?66:73):68
                            RT_Subtitle(FmtDUP@@@,n,UIndex,UCount,ch,Index+1,Count,StartU,EndU,pG,pB,pP*100.0/255.0,aG,aB,aP*100.0/255.0,kG,Anchor,n-Anchor)
                        } Else if(Stat==FLG_DE@@@) { # Dupe_EndOfScene_Override FLG_DE@@@
                            RT_Subtitle(FmtDE@@@,n,UIndex,UCount,Index+1,Count,StartU,EndU,pG,pB,pP*100.0/255.0,aG,aB,aP*100.0/255.0,kG,Anchor,n-Anchor)
                        } Else if(Stat==FLG_NUK@@@) { # Dupe_KOverride FLG_NUK@@@
                            RT_Subtitle(FmtNUK@@@,n,UIndex,UCount,Index+1,Count,StartU,EndU,pG,pB,pP*100.0/255.0,aG,aB,aP*100.0/255.0,kG,Anchor,n-Anchor)
                        } Else if(Stat==FLG_DS@@@) { # Dupe_MaxDupLen_Override FLG_DS@@@
                            RT_Subtitle(FmtDS@@@,n,UIndex,UCount,Index+1,Count,StartU,EndU,pG,pB,pP*100.0/255.0,aG,aB,aP*100.0/255.0,kG,Anchor,n-Anchor)
                        } Else {
                            Assert(False,RT_String("%s[%d] Error Unknwn Stat(%d)",myName@@@,n,Stat))
                        }
                    }
                    if(Verb) {
                        EstFps=(nDone@@@-nDupes@@@)*FrameRate/nDone@@@
                        RT_SubTitle(vFmt@@@,
                        \     Mode,ThG,ThB,ThP,IgP*100.0/255.0,ThK,MaxDupLen,MaxInterp,LagMax,nSeq@@@,MaxSeqLen@@@,MaxSeqPos@@@,
                        \     nDupes@@@,DupeLenMax@@@,DupePosMax@@@,nDupeSeq@@@,nDone@@@*100.0/FC,EstFPS,Align=1)
                    }
                }
            } # End, if(Show || (Mode>0 && Stat==FLG_DUP@@@))
            Return Last
        }
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 17th November 2018 at 15:24. Reason: Update
StainlessS is offline   Reply With Quote