View Single Post
Old 20th January 2018, 15:46   #52  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Test mod to script, highlited in BLUE, (removed Overlays, replaced with simple assignment to self), produces almost no change in ram usage,
when playing script.

Code:
Function SBX_MI(clip c,int Factor, string "Mode", float "Opacity") {
    c
    myName  = "SBX_MI: "
    Mode    = Default(Mode,"lighten")
    Opacity = Default(Opacity,1.0)
    Limit   = (Factor<=0) ? 1 : Max(1, FrameCount/Factor)
    FuncS="""
        Function Fn@@@(clip c,Int factor,String mode,Float opacity,Int limit) {
            n=current_frame
            if(Prev@@@ != n) {
                c
                cf=c.Trim(n,-1)                     # current frame
                if(Prev@@@ != n-1) {
                    Global B@@@ = cf                # First Frame OR User Jumping, Init/Reset to current frame
                } else {
                    # limit>1 ? Overlay(b.Loop(2,0,0),last,opacity=float(limit)/FrameCount) : b.Loop(2,0,0)
                    if(limit > 1) {
                        Global B@@@ = B@@@
                    } # Else, B@@@ = Previous B@@@
                    # b.Overlay(last, mode=mode, opacity=opacity)
                    Global B@@@=B@@@
                }
                Global Prev@@@=n                    # REM for next time
            } # Else, Cache failure, repeat request for current frame, just return same as last time
            Return B@@@
        }
        #######################################
        # Unique Global Variables Initialization
        #######################################
        Global Prev@@@=-666
        #######################################
        # Unique Runtime Call, GScriptClip must be a one-liner:
        #######################################
        ARGS = "Factor,Mode,Opacity,Limit"
        c.GScriptClip("Fn@@@(last, "+ARGS+")", local=true, args=ARGS)
    """
    #######################################
    # Unique Identifier Definition
    #######################################
    GIFunc="SBX_MI"                    # 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)
#   RT_WriteFile("DEBUG_"+GID+".TXT","%s",InstS)
    FrameCount!=1 ? GScript(InstS) : Last
    Return Last
}
But of course it not dont work as required, and only displays frame 0.

EDIT: Also tried append

Code:
Global B@@@=Overlay(B@@@,cf,mode=Mode,opacity=Opacity).changefps(c,true)
Due to this post (did not do anything to help, desparate measure)
Quote:
Originally Posted by raffriff42 View Post
I've heard tell ChangeFPS does some caching; maybe that's the reason it works here -
https://forum.doom9.org/showthread.p...09#post1831109
__________________
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; 20th January 2018 at 16:11.
StainlessS is offline   Reply With Quote