StainlessS
6th December 2018, 23:32
Morpheus.avs v0.02 Part 2 of 2.
Function Morpheus(clip c,String Cmd,Bool "Inclusive",
\ Int "Prefilter", [* Prefilter *]
\ Int "SPad", Int "SPel", Bool "SChroma", Int "SSharp", Int "SRFilter", [* MSuper *]
\ Int "ABlkSize", Int "ABlkSizeV", [* MAnalyse *]
\ Int "ASearch", Int "ASearchParam", Int "APelSearch", [* MAnalyse *]
\ Bool "AChroma", Bool "ATrueMotion", [* MAnalyse *]
\ Int "AOverlap", Int "AOverlapV", [* MAnalyse *]
\ Int "ADct", Bool "ATryMany", [* MAnalyse *]
\ Int "RthSAD", Int "RBlkSize", Int "RBlkSizeV", [* MRecalculate *]
\ Int "RSearch", Int "RSearchParam", [* MRecalculate *]
\ Bool "RChroma", Bool "RTrueMotion", [* MRecalculate *]
\ Int "ROverlap", Int "ROverlapV", Int "RDct", [* MRecalculate *]
\ Float "Iml", Bool "IBlend", Int "IthSCD1", Int "IthSCD2", [* MFlowInter *]
\ Bool "Show"
\ ) {
c myName="Morpheus: "
IsAvsPlus=(FindStr(UCase(versionString),"AVISYNTH+")!=0) HasGScript=RT_FunctionExist("GScript")
HasGRunt =RT_FunctionExist("GScriptClip") HasMvTools=RT_FunctionExist("MSuper")
HasRemoveGrain=RT_FunctionExist("RemoveGrain") HasCallCmd =RT_FunctionExist("CallCmd")
IsAvs26=VersionNumber>=2.6
Assert(IsAvsPlus || HasGScript,RT_String("%sNeed either GScript or AVS+",myName))
Assert(HasGRunt,RT_String("%sNeed GRunt:-https://forum.doom9.org/showthread.php?t=139337 ",myName))
Assert(HasMVTools,RT_String("%sNeed MvTools2:-http://forum.doom9.org/showthread.php?t=131033",myName))
Assert(HasRemoveGrain,RT_String("%sNeed RemoveGrain",myName))
Assert(IsYV12||(IsAvs26&&(IsY8||IsYV16||IsYV24)),RT_String("%sOnly Standard v2.6 Planar Supported (excepting YV411)",myname))
Assert(Cmd!="",String("%sCmd cannot be ''",myName))
#
Inclusive = Default(Inclusive,True)
PreFilter=Default(PreFilter,1) # 0=Blur(0.6), 1=RemoveGrain(22), 2=RemoveGrain(1).RemoveGrain(22)
SPad=Default(SPad,16) SPel=Default(SPel,2)
SChroma=Default(SChroma,True)
SSharp=Default(SSharp,1) SRFilter= Default(SRFilter,4)
ABlkSize=Default(ABlkSize,c.Width>1920?32:c.Width>1100?24:c.Width>720?16:8) ABlkSizeV=Default(ABlkSizeV,ABlkSize)
ASearch=Default(ASearch,3) ASearchParam=Default(ASearchParam,2) APelSearch=Default(APelSearch,SPel)
AChroma=Default(AChroma,SChroma) ATrueMotion=Default(ATrueMotion,ABlksize<16)
AOverlap=Default(AOverlap,4) AOverlapV=Default(AOverlapV,AOverlap)
ADct=Default(ADct,0) ATryMany=Default(ATryMany,False)
RthSAD=Default(RthSAD,100) RBlkSize=Default(RBlkSize,ABlkSize/4*2) RBlkSizeV=Default(RBlkSizeV,RBlkSize)
RSearch=Default(RSearch,ASearch) RSearchParam=Default(RSearchParam,ASearchParam)
RChroma=Default(RChroma,AChroma) RTrueMotion=Default(RTrueMotion,ATrueMotion)
ROverlap=Default(ROverlap,RBlkSize>2?2:0) ROverlapV=Default(ROverlapV,ROverlap) RDct=Default(RDct,ADct)
Iml=Default(Iml,200.0) IBlend=Default(IBlend,True)
IthSCD1=Default(IthSCD1,400) IthSCD2= Default(IthSCD2,130)
Show=Default(Show,False)
####
FuncS="""
Function ChrIsNul(String S) {return RT_Ord(S)== 0}
Function ChrIsHash(String S) {return RT_Ord(S)==35}
Function ChrIsStar(String S) {return RT_Ord(S)==42}
Function ChrIsComma(String S) {return RT_Ord(S)==44}
Function ChrIsHyphen(String S) {return RT_Ord(S)==45}
Function ChrIsDigit(String S) {C=RT_Ord(S) return C>=48&&C<=57}
Function ChrEatWhite(String S) {i=1 C=RT_Ord(S,i) While(C==32||C>=8&&C<=13) {i=i+1 C=RT_Ord(S,i)} return i>1?MidStr(S,i):S}
Function ChrEatDigits(String S) {i=1 C=RT_Ord(S,i) While(C>=48&&C<=57) {i=i+1 C=RT_Ord(S,i)} return i>1?MidStr(S,i):S}
Function Fn@@@(clip c,String DB,Bool Show,String Fmt1,String Fmt2) {
c n=current_frame
if(RT_DBaseGetField(DB,n,0)) { # Is an Interpolated frame
Start = RT_DBaseGetField(DB,n,1) # Start of Interpolated Frames (Inclusive)
End = RT_DBaseGetField(DB,n,2) # End of Interpolated Frames (Inclusive)
Count = End - Start + 1 # Count of Interpolated frames in this run
Index = n-Start # Index into Count (0 relative, 0 -> Count-1)
OFrms=4 # Max number of frames to use from either side of Interpolated run (Src Frames, before & after)
LS=Max(Start-OFrms,0)
LCnt=Start-LS RCnt=Min(c.FrameCount-1-End,OFrms)
TmpC = c.Trim(LS,-LCnt) + c.Trim(End+1,-RCnt) # Src used for interpolation, (with some extra frames[higher quality sometimes])
FixFrm=LCnt-1 # Frame where Interpolated frame will be created
PreFilter=PreFilter@@@
PreFilt=Prefilter==0?TmpC.Blur(0.6):Prefilter==1?TmpC.RemoveGrain(22):TmpC.RemoveGrain(1).RemoveGrain(22)
SPad=SPad@@@ SPel=SPel@@@ SChroma=SChroma@@@
SSharp=SSharp@@@ SRfilter=SRFilter@@@
Super=TmpC.MSuper(hpad=SPad,vpad=SPad,pel=SPel,levels=1,Chroma=SChroma,sharp=SSharp,rfilter=SRfilter)
Superfilt=Prefilt.MSuper(hpad=SPad,vpad=SPad,pel=SPel,chroma=SChroma,sharp=SSharp,rfilter=SRfilter)
ABlksize=ABlkSize@@@ ABlksizeV=ABlkSizeV@@@
ASearch=ASearch@@@ ASearchParam=ASearchParam@@@ APelSearch=APelSearch@@@
AChroma=AChroma@@@ ATrueMotion=ATrueMotion@@@
AOverLap=AOverLap@@@ AOverLapV=AOverLapV@@@
ADct=ADct@@@ ATryMany=ATryMany@@@
bv=Superfilt.MAnalyse(isb=true ,delta=1,blksize=ABlksize,blksizeV=ABlksizeV,
\ search=ASearch,searchParam=ASearchParam,pelSearch=APelSearch,
\ chroma=AChroma,trueMotion=ATrueMotion,overlap=AOverLap,overlapV=AOverLapV,dct=ADct,trymany=ATryMany)
fv=Superfilt.MAnalyse(isb=false,delta=1,blksize=ABlksize,blksizeV=ABlksizeV,
\ search=ASearch,searchParam=ASearchParam,pelSearch=APelSearch,
\ chroma=AChroma,trueMotion=ATrueMotion,overlap=AOverLap,overlapV=AOverLapV,dct=ADct,trymany=ATryMany)
RBlkSize=RBlkSize@@@
if(RBlkSize>0) {
RthSAD=RthSAD@@@ RBlkSizeV=RBlkSizeV@@@
RSearch=RSearch@@@ RSearchParam=RSearchParam@@@ RChroma=RChroma@@@
RTrueMotion=RTrueMotion@@@ ROverLap=ROverLap@@@ ROverLapV=ROverLapV@@@ RDct=RDct@@@
bv=Super.MRecalculate(bv,thSAD=RthSAD,blksize=RBlkSize,blksizeV=RBlkSizeV,
\ Search=RSearch,searchParam=RSearchParam,chroma=RChroma,truemotion=RTrueMotion,
\ overlap=ROverLap,overlapV=ROverLapV,dct=RDct)
fv=Super.MRecalculate(fv,thSAD=RthSAD,blksize=RBlkSize,blksizeV=RBlkSizeV,
\ Search=RSearch,searchParam=RSearchParam,chroma=RChroma,truemotion=RTrueMotion,
\ overlap=ROverLap,overlapV=ROverLapV,dct=RDct)
}
TmpC=TmpC.MFlowInter(Super,bv,fv,time=100.0*(Index+1)/(Count+1),ml=Iml@@@,blend=IBlend@@@,thSCD1=IthSCD1@@@,thSCD2=IthSCD2@@@)
TmpC.Trim(FixFrm,-1) # Interpolated Frame to return
if(Show) { RT_Subtitle(Fmt2,n,Index+1,Count) }
} Else if(Show) { RT_Subtitle(Fmt1,n) }
Return Last
}
if(ChrIsStar(CMD)) {
CMD=MidStr(CMD,2)
} else {
Cmd=RT_GetFullPathName(Cmd)
Assert(Exist(CMD),RT_String("%sCMD File does not exist",myName))
CMD=RT_ReadTxtFromFile(CMD)
}
LINES=RT_TxtQueryLines(CMD) FC=Framecount
DB = RT_GetFullPathName("~@@@_"+RT_LocalTimeString+".DB") RT_DBaseAlloc(DB,FrameCount,"bii")
for(i=0,LINES-1) {
SS=RT_TxtGetLine(CMD,i).ChrEatWhite
S=SS
if(!S.ChrIsNul && !S.ChrIsHash) {
if(S.ChrIsDigit) {
StartF = S.RT_NumberValue
EndF=StartF
S=S.ChrEatDigits.ChrEatWhite
if(S.ChrIsComma) {S=S.MidStr(2).ChrEatWhite}
IsNeg = S.ChrIsHyphen
if(IsNeg) {S=S.MidStr(2).ChrEatWhite}
if(S.ChrIsDigit) {
EndF=S.RT_NumberValue
if(IsNeg) {
Assert(Inclusive,RT_String("%sCMD: Error@Line_%d, Exclusive End Frame Cannot be -ve\n%s",myName,i+1,SS))
EndF=StartF+EndF-1
}
S=S.ChrEatDigits
} Else if(!Inclusive) {
Assert(False,RT_String("%sCMD: Error@Line_%d, Exclusive must have End Frame\n%s",myName,i+1,SS))
} Else if(IsNeg) { Assert(False,RT_String("%sCMD: Error@Line_%d, Expecting End Frame\n%s",myName,i+1,SS)) }
Start_I = (Inclusive) ? StartF : StartF+1
End_I = (Inclusive) ? EndF : EndF-1
Assert(Start_I>0,RT_String("%sCMD: Error@Line_%d, Illegal Start frame\n%s",myName,i+1,SS))
Assert(End_I<FC-1,RT_String("%sCMD: Error@Line_%d, EndFrame(%d)+1 Out Of Clip\n%s",myName,i+1,End_I+1,SS))
Inclusive
\ ? Assert(Start_I<=End_I,RT_String("%sCMD: Error@Line_%d, StartFrame(%d) <= EndFrame(%d)\n%s",myName,i+1,Start_I,End_I,SS))
\ : Assert(StartF<EndF-1,RT_String("%sCMD: Error@Line_%d, None to interpolate, Start(%d) End(%d)\n%s",myName,i+1,StartF,EndF,SS))
Assert(!(RT_DBaseGetField(DB,Start_I-1,0)||RT_DBaseGetField(DB,End_I+1,0)),
\ RT_String("%sCMD: Error@Line_%d, Adjacent Interpolation\n%s",myName,i+1,SS))
for(n=Start_I,End_I) {
if(RT_DBaseGetField(DB,n,0)) {
if(RT_DBaseGetField(DB,n,1)!=Start_I || RT_DBaseGetField(DB,n,2)!=End_I) {
Assert(False,RT_String("%sCMD: Error@Line_%d, Overlapping Interpolation\n%s",myName,i+1,SS))
}
}
RT_DBaseSet(DB,n,True,Start_I,End_I)
}
S=S.ChrEatWhite
}
if(!S.ChrIsHash) { Assert(S.ChrIsNul,RT_String("%sCMD: Error@Line_%d, *** NON-PARSE ***\n'%s'",myName,i+1,SS)) }
}
}
Global PreFilter@@@=PreFilter
Global SPad@@@=SPad Global SPel@@@=SPel Global SChroma@@@=SChroma
Global SSharp@@@=SSharp Global SRFilter@@@=SRFilter
Global ABlkSize@@@=ABlkSize Global ABlkSizeV@@@=ABlkSizeV
Global ASearch@@@=ASearch Global ASearchParam@@@=ASearchParam Global APelSearch@@@=APelSearch
Global AChroma@@@=AChroma Global ATrueMotion@@@=ATrueMotion
Global AOverLap@@@=AOverLap Global AOverLapV@@@=AOverLapV Global ADct@@@=ADct Global ATryMany@@@=ATryMany
Global RthSAD@@@=RthSAD Global RBlkSize@@@=RBlkSize Global RBlkSizeV@@@=RBlkSizeV
Global RSearch@@@=RSearch Global RSearchParam@@@=RSearchParam
Global RChroma@@@=RChroma Global RTrueMotion@@@=RTrueMotion
Global ROverLap@@@=ROverLap Global ROverLapV@@@=ROverLapV Global RDct@@@=RDct
Global Iml@@@=Iml Global IBlend@@@=IBlend Global IthSCD1@@@=IthSCD1 Global IthSCD2@@@=IthSCD2
###
Fmt1="%d]"
Fmt2="%d] I%d/%d"
ARGS = "DB,Show,Fmt1,Fmt2"
ScriptLine = "Fn@@@("+ARGS+")"
Last.GScriptClip(ScriptLine, local=true, args=ARGS)
"""
GIFunc="MORPHEUS" # Function Name, Supply unique name for your multi-instance function.
GIName=GIFunc+"_InstanceNumber" # Name of the Instance number Global
RT_IncrGlobal(GIName) # Increment Instance Global (init to 1 if not already exists)
GID = GIFunc + "_" + String(Eval(GIName))
InstS = RT_StrReplace(FuncS,"@@@","_"+GID)
# Write Debug GScript File to current directory (line numbers will correspond to error messages)
# RT_WriteFile("DEBUG_"+GID+".TXT","%s",InstS)
HasGScript ? GScript(InstS) : Eval(InstS,"GS_EVAL") # Use GSCript if installed (loaded plugs override builtin)
# if CallCmd available, Auto delete DBase file on clip closure.
HasCallCmd?CallCmd(close=RT_String("""CMD /C chcp 1252 && del "%s" """,DB), hide=true, Synchronous=7):NOP
Return Last
}
EDIT: Added some checking for overlapping commands in BLUE.
Client
#Import(".\Morpheus.avs") # or put in plugins dir
Colorbars(Pixel_type="YV12").KillAudio.ShowFrameNumber
INCLUSIVE=True
SHOW=True
INCLUSIVE_CMD="""* # <<<<==== Asterisk(Star) is first character, ie is a String Command, else is a Filename.
10 11 # This Is a Comment
15
20 -2
"""
EXCLUSIVE_CMD="""* # <<<<==== Asterisk(Star) is first character, ie is a String Command, else is a Filename.
9 12
14 16
19 22
"""
# Select Inclusive or Exclusive CMD depending upon value of INCLUSIVE
CMD = (INCLUSIVE) ? INCLUSIVE_CMD : EXCLUSIVE_CMD
Morpheus(Cmd,Inclusive=INCLUSIVE,Show=SHOW)
Function Morpheus(clip c,String Cmd,Bool "Inclusive",
\ Int "Prefilter", [* Prefilter *]
\ Int "SPad", Int "SPel", Bool "SChroma", Int "SSharp", Int "SRFilter", [* MSuper *]
\ Int "ABlkSize", Int "ABlkSizeV", [* MAnalyse *]
\ Int "ASearch", Int "ASearchParam", Int "APelSearch", [* MAnalyse *]
\ Bool "AChroma", Bool "ATrueMotion", [* MAnalyse *]
\ Int "AOverlap", Int "AOverlapV", [* MAnalyse *]
\ Int "ADct", Bool "ATryMany", [* MAnalyse *]
\ Int "RthSAD", Int "RBlkSize", Int "RBlkSizeV", [* MRecalculate *]
\ Int "RSearch", Int "RSearchParam", [* MRecalculate *]
\ Bool "RChroma", Bool "RTrueMotion", [* MRecalculate *]
\ Int "ROverlap", Int "ROverlapV", Int "RDct", [* MRecalculate *]
\ Float "Iml", Bool "IBlend", Int "IthSCD1", Int "IthSCD2", [* MFlowInter *]
\ Bool "Show"
\ ) {
c myName="Morpheus: "
IsAvsPlus=(FindStr(UCase(versionString),"AVISYNTH+")!=0) HasGScript=RT_FunctionExist("GScript")
HasGRunt =RT_FunctionExist("GScriptClip") HasMvTools=RT_FunctionExist("MSuper")
HasRemoveGrain=RT_FunctionExist("RemoveGrain") HasCallCmd =RT_FunctionExist("CallCmd")
IsAvs26=VersionNumber>=2.6
Assert(IsAvsPlus || HasGScript,RT_String("%sNeed either GScript or AVS+",myName))
Assert(HasGRunt,RT_String("%sNeed GRunt:-https://forum.doom9.org/showthread.php?t=139337 ",myName))
Assert(HasMVTools,RT_String("%sNeed MvTools2:-http://forum.doom9.org/showthread.php?t=131033",myName))
Assert(HasRemoveGrain,RT_String("%sNeed RemoveGrain",myName))
Assert(IsYV12||(IsAvs26&&(IsY8||IsYV16||IsYV24)),RT_String("%sOnly Standard v2.6 Planar Supported (excepting YV411)",myname))
Assert(Cmd!="",String("%sCmd cannot be ''",myName))
#
Inclusive = Default(Inclusive,True)
PreFilter=Default(PreFilter,1) # 0=Blur(0.6), 1=RemoveGrain(22), 2=RemoveGrain(1).RemoveGrain(22)
SPad=Default(SPad,16) SPel=Default(SPel,2)
SChroma=Default(SChroma,True)
SSharp=Default(SSharp,1) SRFilter= Default(SRFilter,4)
ABlkSize=Default(ABlkSize,c.Width>1920?32:c.Width>1100?24:c.Width>720?16:8) ABlkSizeV=Default(ABlkSizeV,ABlkSize)
ASearch=Default(ASearch,3) ASearchParam=Default(ASearchParam,2) APelSearch=Default(APelSearch,SPel)
AChroma=Default(AChroma,SChroma) ATrueMotion=Default(ATrueMotion,ABlksize<16)
AOverlap=Default(AOverlap,4) AOverlapV=Default(AOverlapV,AOverlap)
ADct=Default(ADct,0) ATryMany=Default(ATryMany,False)
RthSAD=Default(RthSAD,100) RBlkSize=Default(RBlkSize,ABlkSize/4*2) RBlkSizeV=Default(RBlkSizeV,RBlkSize)
RSearch=Default(RSearch,ASearch) RSearchParam=Default(RSearchParam,ASearchParam)
RChroma=Default(RChroma,AChroma) RTrueMotion=Default(RTrueMotion,ATrueMotion)
ROverlap=Default(ROverlap,RBlkSize>2?2:0) ROverlapV=Default(ROverlapV,ROverlap) RDct=Default(RDct,ADct)
Iml=Default(Iml,200.0) IBlend=Default(IBlend,True)
IthSCD1=Default(IthSCD1,400) IthSCD2= Default(IthSCD2,130)
Show=Default(Show,False)
####
FuncS="""
Function ChrIsNul(String S) {return RT_Ord(S)== 0}
Function ChrIsHash(String S) {return RT_Ord(S)==35}
Function ChrIsStar(String S) {return RT_Ord(S)==42}
Function ChrIsComma(String S) {return RT_Ord(S)==44}
Function ChrIsHyphen(String S) {return RT_Ord(S)==45}
Function ChrIsDigit(String S) {C=RT_Ord(S) return C>=48&&C<=57}
Function ChrEatWhite(String S) {i=1 C=RT_Ord(S,i) While(C==32||C>=8&&C<=13) {i=i+1 C=RT_Ord(S,i)} return i>1?MidStr(S,i):S}
Function ChrEatDigits(String S) {i=1 C=RT_Ord(S,i) While(C>=48&&C<=57) {i=i+1 C=RT_Ord(S,i)} return i>1?MidStr(S,i):S}
Function Fn@@@(clip c,String DB,Bool Show,String Fmt1,String Fmt2) {
c n=current_frame
if(RT_DBaseGetField(DB,n,0)) { # Is an Interpolated frame
Start = RT_DBaseGetField(DB,n,1) # Start of Interpolated Frames (Inclusive)
End = RT_DBaseGetField(DB,n,2) # End of Interpolated Frames (Inclusive)
Count = End - Start + 1 # Count of Interpolated frames in this run
Index = n-Start # Index into Count (0 relative, 0 -> Count-1)
OFrms=4 # Max number of frames to use from either side of Interpolated run (Src Frames, before & after)
LS=Max(Start-OFrms,0)
LCnt=Start-LS RCnt=Min(c.FrameCount-1-End,OFrms)
TmpC = c.Trim(LS,-LCnt) + c.Trim(End+1,-RCnt) # Src used for interpolation, (with some extra frames[higher quality sometimes])
FixFrm=LCnt-1 # Frame where Interpolated frame will be created
PreFilter=PreFilter@@@
PreFilt=Prefilter==0?TmpC.Blur(0.6):Prefilter==1?TmpC.RemoveGrain(22):TmpC.RemoveGrain(1).RemoveGrain(22)
SPad=SPad@@@ SPel=SPel@@@ SChroma=SChroma@@@
SSharp=SSharp@@@ SRfilter=SRFilter@@@
Super=TmpC.MSuper(hpad=SPad,vpad=SPad,pel=SPel,levels=1,Chroma=SChroma,sharp=SSharp,rfilter=SRfilter)
Superfilt=Prefilt.MSuper(hpad=SPad,vpad=SPad,pel=SPel,chroma=SChroma,sharp=SSharp,rfilter=SRfilter)
ABlksize=ABlkSize@@@ ABlksizeV=ABlkSizeV@@@
ASearch=ASearch@@@ ASearchParam=ASearchParam@@@ APelSearch=APelSearch@@@
AChroma=AChroma@@@ ATrueMotion=ATrueMotion@@@
AOverLap=AOverLap@@@ AOverLapV=AOverLapV@@@
ADct=ADct@@@ ATryMany=ATryMany@@@
bv=Superfilt.MAnalyse(isb=true ,delta=1,blksize=ABlksize,blksizeV=ABlksizeV,
\ search=ASearch,searchParam=ASearchParam,pelSearch=APelSearch,
\ chroma=AChroma,trueMotion=ATrueMotion,overlap=AOverLap,overlapV=AOverLapV,dct=ADct,trymany=ATryMany)
fv=Superfilt.MAnalyse(isb=false,delta=1,blksize=ABlksize,blksizeV=ABlksizeV,
\ search=ASearch,searchParam=ASearchParam,pelSearch=APelSearch,
\ chroma=AChroma,trueMotion=ATrueMotion,overlap=AOverLap,overlapV=AOverLapV,dct=ADct,trymany=ATryMany)
RBlkSize=RBlkSize@@@
if(RBlkSize>0) {
RthSAD=RthSAD@@@ RBlkSizeV=RBlkSizeV@@@
RSearch=RSearch@@@ RSearchParam=RSearchParam@@@ RChroma=RChroma@@@
RTrueMotion=RTrueMotion@@@ ROverLap=ROverLap@@@ ROverLapV=ROverLapV@@@ RDct=RDct@@@
bv=Super.MRecalculate(bv,thSAD=RthSAD,blksize=RBlkSize,blksizeV=RBlkSizeV,
\ Search=RSearch,searchParam=RSearchParam,chroma=RChroma,truemotion=RTrueMotion,
\ overlap=ROverLap,overlapV=ROverLapV,dct=RDct)
fv=Super.MRecalculate(fv,thSAD=RthSAD,blksize=RBlkSize,blksizeV=RBlkSizeV,
\ Search=RSearch,searchParam=RSearchParam,chroma=RChroma,truemotion=RTrueMotion,
\ overlap=ROverLap,overlapV=ROverLapV,dct=RDct)
}
TmpC=TmpC.MFlowInter(Super,bv,fv,time=100.0*(Index+1)/(Count+1),ml=Iml@@@,blend=IBlend@@@,thSCD1=IthSCD1@@@,thSCD2=IthSCD2@@@)
TmpC.Trim(FixFrm,-1) # Interpolated Frame to return
if(Show) { RT_Subtitle(Fmt2,n,Index+1,Count) }
} Else if(Show) { RT_Subtitle(Fmt1,n) }
Return Last
}
if(ChrIsStar(CMD)) {
CMD=MidStr(CMD,2)
} else {
Cmd=RT_GetFullPathName(Cmd)
Assert(Exist(CMD),RT_String("%sCMD File does not exist",myName))
CMD=RT_ReadTxtFromFile(CMD)
}
LINES=RT_TxtQueryLines(CMD) FC=Framecount
DB = RT_GetFullPathName("~@@@_"+RT_LocalTimeString+".DB") RT_DBaseAlloc(DB,FrameCount,"bii")
for(i=0,LINES-1) {
SS=RT_TxtGetLine(CMD,i).ChrEatWhite
S=SS
if(!S.ChrIsNul && !S.ChrIsHash) {
if(S.ChrIsDigit) {
StartF = S.RT_NumberValue
EndF=StartF
S=S.ChrEatDigits.ChrEatWhite
if(S.ChrIsComma) {S=S.MidStr(2).ChrEatWhite}
IsNeg = S.ChrIsHyphen
if(IsNeg) {S=S.MidStr(2).ChrEatWhite}
if(S.ChrIsDigit) {
EndF=S.RT_NumberValue
if(IsNeg) {
Assert(Inclusive,RT_String("%sCMD: Error@Line_%d, Exclusive End Frame Cannot be -ve\n%s",myName,i+1,SS))
EndF=StartF+EndF-1
}
S=S.ChrEatDigits
} Else if(!Inclusive) {
Assert(False,RT_String("%sCMD: Error@Line_%d, Exclusive must have End Frame\n%s",myName,i+1,SS))
} Else if(IsNeg) { Assert(False,RT_String("%sCMD: Error@Line_%d, Expecting End Frame\n%s",myName,i+1,SS)) }
Start_I = (Inclusive) ? StartF : StartF+1
End_I = (Inclusive) ? EndF : EndF-1
Assert(Start_I>0,RT_String("%sCMD: Error@Line_%d, Illegal Start frame\n%s",myName,i+1,SS))
Assert(End_I<FC-1,RT_String("%sCMD: Error@Line_%d, EndFrame(%d)+1 Out Of Clip\n%s",myName,i+1,End_I+1,SS))
Inclusive
\ ? Assert(Start_I<=End_I,RT_String("%sCMD: Error@Line_%d, StartFrame(%d) <= EndFrame(%d)\n%s",myName,i+1,Start_I,End_I,SS))
\ : Assert(StartF<EndF-1,RT_String("%sCMD: Error@Line_%d, None to interpolate, Start(%d) End(%d)\n%s",myName,i+1,StartF,EndF,SS))
Assert(!(RT_DBaseGetField(DB,Start_I-1,0)||RT_DBaseGetField(DB,End_I+1,0)),
\ RT_String("%sCMD: Error@Line_%d, Adjacent Interpolation\n%s",myName,i+1,SS))
for(n=Start_I,End_I) {
if(RT_DBaseGetField(DB,n,0)) {
if(RT_DBaseGetField(DB,n,1)!=Start_I || RT_DBaseGetField(DB,n,2)!=End_I) {
Assert(False,RT_String("%sCMD: Error@Line_%d, Overlapping Interpolation\n%s",myName,i+1,SS))
}
}
RT_DBaseSet(DB,n,True,Start_I,End_I)
}
S=S.ChrEatWhite
}
if(!S.ChrIsHash) { Assert(S.ChrIsNul,RT_String("%sCMD: Error@Line_%d, *** NON-PARSE ***\n'%s'",myName,i+1,SS)) }
}
}
Global PreFilter@@@=PreFilter
Global SPad@@@=SPad Global SPel@@@=SPel Global SChroma@@@=SChroma
Global SSharp@@@=SSharp Global SRFilter@@@=SRFilter
Global ABlkSize@@@=ABlkSize Global ABlkSizeV@@@=ABlkSizeV
Global ASearch@@@=ASearch Global ASearchParam@@@=ASearchParam Global APelSearch@@@=APelSearch
Global AChroma@@@=AChroma Global ATrueMotion@@@=ATrueMotion
Global AOverLap@@@=AOverLap Global AOverLapV@@@=AOverLapV Global ADct@@@=ADct Global ATryMany@@@=ATryMany
Global RthSAD@@@=RthSAD Global RBlkSize@@@=RBlkSize Global RBlkSizeV@@@=RBlkSizeV
Global RSearch@@@=RSearch Global RSearchParam@@@=RSearchParam
Global RChroma@@@=RChroma Global RTrueMotion@@@=RTrueMotion
Global ROverLap@@@=ROverLap Global ROverLapV@@@=ROverLapV Global RDct@@@=RDct
Global Iml@@@=Iml Global IBlend@@@=IBlend Global IthSCD1@@@=IthSCD1 Global IthSCD2@@@=IthSCD2
###
Fmt1="%d]"
Fmt2="%d] I%d/%d"
ARGS = "DB,Show,Fmt1,Fmt2"
ScriptLine = "Fn@@@("+ARGS+")"
Last.GScriptClip(ScriptLine, local=true, args=ARGS)
"""
GIFunc="MORPHEUS" # Function Name, Supply unique name for your multi-instance function.
GIName=GIFunc+"_InstanceNumber" # Name of the Instance number Global
RT_IncrGlobal(GIName) # Increment Instance Global (init to 1 if not already exists)
GID = GIFunc + "_" + String(Eval(GIName))
InstS = RT_StrReplace(FuncS,"@@@","_"+GID)
# Write Debug GScript File to current directory (line numbers will correspond to error messages)
# RT_WriteFile("DEBUG_"+GID+".TXT","%s",InstS)
HasGScript ? GScript(InstS) : Eval(InstS,"GS_EVAL") # Use GSCript if installed (loaded plugs override builtin)
# if CallCmd available, Auto delete DBase file on clip closure.
HasCallCmd?CallCmd(close=RT_String("""CMD /C chcp 1252 && del "%s" """,DB), hide=true, Synchronous=7):NOP
Return Last
}
EDIT: Added some checking for overlapping commands in BLUE.
Client
#Import(".\Morpheus.avs") # or put in plugins dir
Colorbars(Pixel_type="YV12").KillAudio.ShowFrameNumber
INCLUSIVE=True
SHOW=True
INCLUSIVE_CMD="""* # <<<<==== Asterisk(Star) is first character, ie is a String Command, else is a Filename.
10 11 # This Is a Comment
15
20 -2
"""
EXCLUSIVE_CMD="""* # <<<<==== Asterisk(Star) is first character, ie is a String Command, else is a Filename.
9 12
14 16
19 22
"""
# Select Inclusive or Exclusive CMD depending upon value of INCLUSIVE
CMD = (INCLUSIVE) ? INCLUSIVE_CMD : EXCLUSIVE_CMD
Morpheus(Cmd,Inclusive=INCLUSIVE,Show=SHOW)