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. |
24th May 2016, 10:38 | #42 | Link | |
Registered User
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,593
|
Quote:
Code:
static const AVS_Linkage* AVS_linkage = nullptr; extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit3(IScriptEnvironment* env, AVS_Linkage* vectors) { AVS_linkage = vectors;
__________________
See My Avisynth Stuff |
|
24th May 2016, 17:22 | #43 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,018
|
yesmanitsbearman,
v2.5 header has this at beginning (after copyright) Code:
#ifndef __AVISYNTH_H__ #define __AVISYNTH_H__ enum { AVISYNTH_INTERFACE_VERSION = 3 }; EDIT: Here link to ApparentFPS dll+source with both v2.58 header and STANDARD Avisynth v2.6 FINAL:- http://www.mediafire.com/download/x4...3_20151217.zip ~148KB EDIT: where AVISYNTH_INTERFACE_VERSION =4, does not exist =5, OLD Pre-final v2.6, will error/crash if dll compiled with this and used via v2.6Alpha3 and prior (I think, anyway, dont use). =6, v2.6 FINAL.
__________________
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; 24th May 2016 at 17:46. |
10th June 2016, 18:49 | #44 | Link |
Registered User
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,593
|
ok, it's avisynth64_8-29-10 fault, avisynth64_4-16-10 work fine
__________________
See My Avisynth Stuff |
19th January 2018, 01:12 | #45 | Link |
Registered User
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,593
|
hi Gavino
is there some way to avoid crash in theses cases with GRunT? Code:
function SFrameBlendX(clip C, int "blendfactor", string "blend_mode", float "blend_opacity") { global SFrameBlendX_blend_mode=blend_mode global SFrameBlendX_blend_opacity=blend_opacity C limit = (blendfactor<=0) ? 1 : Max(1, FrameCount/blendfactor) global SFrameBlendX_limit = limit FrameCount!=1 ? ScriptClip(""" try{bb=isclip(b)} catch(error_msg) {bb=false} b = bb ? SFrameBlendX_limit>1 ? Overlay(b.Loop(2,0,0),last,opacity=float(SFrameBlendX_limit)/FrameCount) : b.Loop(2,0,0) : nop() b = bb ? b.Overlay(last, mode=SFrameBlendX_blend_mode, opacity=SFrameBlendX_blend_opacity) : last return b """) : last } more information https://forum.doom9.org/showthread.p...49#post1829149 it use same method of https://forum.doom9.org/showthread.p...77#post1188377 but the problem seems that the frames from previous didn't ever clean up so it will crash after use all ram, the problem can't be seen in Srestore or any MOmonster function since they not do this with clips so seems ram will not be full easily so, is there any method/idea/update to clean/limit theses data from previous frames process? like Code:
GScriptClip(last, """ global prev = curr global curr = next global next = AverageLuma(last.trim(1,0)) ...outputclip... """, limit=5) Code:
GScriptClip(last, """ global prev = curr global curr = next global next = AverageLuma(last.trim(1,0)).runtimecleanup(5) ...outputclip... """)
__________________
See My Avisynth Stuff |
19th January 2018, 04:23 | #46 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,018
|
Presumably, you are relying on 'b' being at top script level (never did get the hang of that), and so is sort of Global [or maybe 'common'].
I tried removing Globals and using Grunt Args instead, but it stopped working, seemed to interfere with setting non global b, and was not seen as set on subsequent frames. Nope, cant do it, cannot improve on yours. Tried a few things, no go. I'm quite mystified about how it works Only suggestion is that blendfactor cannot be optional. [EDIT: Remove quotes] I dont think you can 'clean up', even if you use blankclip and trim [ie create an additional new clip] while keeping a single previous frame, that frame is reliant on ones prior to itself, and they are reliant upon ones prior to them, etc. With SRestore, etc, I would guess that output is reliant upon [and constructed from] only input frames [or frames synthesized from input frames] , here you are reliant upon all previous output frames. EDIT: Working on Multi-Instance version function, that might work, but will reset if user jumps about.
__________________
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; 19th January 2018 at 14:41. |
20th January 2018, 02:41 | #48 | Link | |
Registered User
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,593
|
Quote:
Code:
function SFrameBlendX(clip C, int "blendfactor", string "blend_mode", float "blend_opacity") { C limit = (blendfactor<=0) ? 1 : Max(1, FrameCount/blendfactor) FrameCount!=1 ? ScriptClip(""" try{bb=isclip(b)} catch(error_msg) {bb=false} b = bb ? limit>1 ? Overlay(b.Loop(2,0,0),last,opacity=float(limit)/FrameCount) : b.Loop(2,0,0) : nop() b = bb ? b.Overlay(last, mode=blend_mode, opacity=blend_opacity) : last return b """,args="blend_mode, blend_opacity, limit", local=false) : last }
__________________
See My Avisynth Stuff Last edited by real.finder; 21st January 2018 at 17:26. |
|
20th January 2018, 11:55 | #49 | Link | |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,018
|
This works for a little bit longer (orig 825 frame, below 845 frames) before crash.
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@@@ = Overlay(B@@@,cf, opacity=float(limit)/FrameCount) } # Else, B@@@ = Previous B@@@ # b.Overlay(last, mode=mode, opacity=opacity) Global B@@@=Overlay(B@@@,cf,mode=Mode,opacity=Opacity) # HOW do we cache only this frame & release all others ? } 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 } Code:
aviSource("Parade.avi").trim(500,0) SBX_MI(5) EDIT: Made same mistake as in original, "Factor" was optional, removed quotes above. EDIT: Perhaps Loop() added somewhere might delay crash ??? [EDIT: Nope, dont seem to work] EDIT: Oops, added Int to Fn@@@(Int Limit). EDIT: Small mods. EDIT: Quote:
EDIT: Yep, default for Local=False, unless Args used, in which case default is True. (I should have read above quote more closely). EDIT: I did above test with AVS Standard, without AVS+ Trim() issue ongoing in Devs forum, Avisynth+ Thread. https://forum.doom9.org/showthread.p...02#post1830902 EDIT: Above, we are using Global B@@@ as a single frame accumulator for all previous frames overlayed, we need some method to cache only that frame, and release all prevous ones.
__________________
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 13:13. |
|
20th January 2018, 15:15 | #51 | Link | |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,018
|
Quote:
The MI stuff, usually poses no problem (no major problem) in functions using quite a few locally created strings during frame serving, but I usually make most of those (eg formatting strings for RT_Subtitle or similar), accessible via constant variables. The MI interface created primarily by Martin53 & Gavino works extremely well. EDIT: Actually, this MI function is way simpler than a lot of MI functions that I've done, using lots of string allocations (and they proved no problem less than maybe 500,000 or more frames). EDIT: On WXP32 4GB Ram, with Task Manager Open, opening script into VDub FilterMod, where all strings already created and VDub displaying frame 0. Code:
Physical Memory (K) Total 3405284 Available 2944132 System Cache 1047929 Page File Usage 512 MB Moving to frame 1, Code:
Physical Memory (K) Total 3405284 Available 2939632 System Cache 1048304 Page File Usage 515 MB
__________________
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 15:37. |
|
20th January 2018, 15:46 | #52 | Link | |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,018
|
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 } EDIT: Also tried append Code:
Global B@@@=Overlay(B@@@,cf,mode=Mode,opacity=Opacity).changefps(c,true) Quote:
__________________
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. |
|
20th January 2018, 23:58 | #53 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,018
|
BELOW LINK UPDATE to TAKE_2 (RGB32 Alpha would contain rubbish, fixed, copies Alpha)
BELOW LINK UPDATE to TAKE_3 (Source fix in dprintf(), not used, No Change to Binary) Here, FrameStore Plugin v0.0, fill your boots real.finder (Incl source, x86 only, ~12KB). http://www.mediafire.com/file/4d74wl...120_TAKE_3.zip FrameStore_ReadMe.txt Code:
FrameStore(clip c) # by StainlessS An Avisynth v2.6, Filter to both take and produce a single frame. All standard AVS v2.6 Colorspaces. The function creates a store for FRAME 0 of the input clip c. The function is intended to sever the link between a frame and any clips that it is reliant upon. A=Colorbars.trim(0,-1) # 1 frame B=A.FlipVertical # B is reliant upon clip A C=A.Overlay(B,Opacity=0.5) # C is reliant upon clips A and B D=C.FrameStore # D is not reliant upon A, or B, or C. return D EDIT: Above machine was newly set up from scratch, on another machine with much more stuff (software/codecs etc), it flatlines at about 620MB. Code:
Function SBX_MI(clip c,int Factor, string "Mode", float "Opacity") { /* Requires, RT_Stats, FrameStore (c) StainlessS. GSCript,Grunt, (c) Gavino. */ 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@@@ = Overlay(B@@@,cf, opacity=float(limit)/FrameCount) } # Else, B@@@ = Previous B@@@ # b.Overlay(last, mode=mode, opacity=opacity) # REMOVE '.FrameStore' from end of next line to remove FrameStore and crash this function when out of memory. Global B@@@=Overlay(B@@@,cf,mode=Mode,opacity=Opacity).FrameStore # Oops, removed .ChangeFps, prev attempt at fix } 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 } AviSource("Parade.avi").trim(500,0) # Some clip SBX_MI(100) Source. Code:
/* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ //#define BUG // Uncomment to enable DPRINTF() output // Version 0.0 FrameStore ///////////////////////////////// #include "compiler.h" #include <windows.h> #include <stdio.h> #include <time.h> #include "avisynth.h" #ifdef BUG int dprintf(char* fmt, ...) { char printString[2048]="FrameStore: "; char *p=printString; for(;*p++;); // These lines added in TAKE3 --p; // @ null term va_list argp; va_start(argp, fmt); vsprintf(p, fmt, argp); va_end(argp); for(;*p++;); --p; // @ null term if(printString == p || p[-1] != '\n') { p[0]='\n'; // append n/l if not there already p[1]='\0'; } OutputDebugString(printString); return p-printString; // strlen printString } #endif class FrameStore : public IClip { private: const VideoInfo vi; PVideoFrame frame; bool parity; // public: FrameStore(const VideoInfo& _vi,PVideoFrame _frame, bool _parity); ~FrameStore(); void __stdcall GetAudio(void* buf, __int64 start, __int64 count, IScriptEnvironment* env) {} const VideoInfo& __stdcall GetVideoInfo() { return vi; } bool __stdcall GetParity(int n) { return (vi.IsFieldBased() ? (n&1) : false) ^ parity; } int __stdcall SetCacheHints(int cachehints,int frame_range) {return 0;} PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env); }; FrameStore::FrameStore(const VideoInfo& _vi,PVideoFrame _frame, bool _parity) : vi(_vi), frame(_frame), parity(_parity) { DPRINTF("Constructor: ENTER/EXIT") } FrameStore::~FrameStore() { DPRINTF("Destructor: ENTER/EXIT") } PVideoFrame __stdcall FrameStore::GetFrame(int n, IScriptEnvironment* env) { DPRINTF("GetFrame: ENTER on frame %d",n) n = 0; // Ignore frame and get frame 0 DPRINTF("GetFrame: EXIT, returning Frame") return frame; } static AVSValue __cdecl Create_FrameStore(AVSValue args, void*, IScriptEnvironment* env) { DPRINTF("Create_FrameStore: ENTER") PClip child = args[0].AsClip(); // clip compulsory arg const VideoInfo &InVi = child->GetVideoInfo(); if(!(InVi.IsRGB24() || InVi.IsRGB32() || InVi.IsYUY2() || InVi.IsYV12() || InVi.IsYV16() || \ InVi.IsYV24() || InVi.IsY8() || InVi.IsYV411())) env->ThrowError("FrameStore: Invalid Colorspace (standard AVS only)"); if(!InVi.HasVideo() || InVi.num_frames<=0) env->ThrowError("FrameStore: No Video"); // VideoInfo vi = InVi; bool parity = child->GetParity(0); // vi.audio_samples_per_second =0; // 0 means no audio vi.sample_type =0; // as of 2.5 vi.num_audio_samples =0; // changed as of 2.5 vi.nchannels =0; // as of 2.5 vi.num_frames =1; // PVideoFrame src = child->GetFrame(0, env); const int rowsize = src->GetRowSize(PLANAR_Y); // PLANAR_Y no effect on RGB or YUY2 const int pitch = src->GetPitch(PLANAR_Y); const int height = src->GetHeight(PLANAR_Y); const BYTE * srcp = src->GetReadPtr(PLANAR_Y); // PVideoFrame dst = env->NewVideoFrame(vi); // Create initial frame const int dpitch = dst->GetPitch(PLANAR_Y); BYTE * dstp = dst->GetWritePtr(PLANAR_Y); // DPRINTF("Create_FrameStore: Making Frame") int x,y; if(vi.IsPlanar()) { // Planar for(y=height;--y>=0;) { for(x=rowsize;--x>=0;) { dstp[x] = srcp[x]; } srcp += pitch; dstp += dpitch; } const int srowsizeUV = src->GetRowSize(PLANAR_U); if(srowsizeUV) { // Not Y8 const int spitchUV = src->GetPitch(PLANAR_U); const int sheightUV = src->GetHeight(PLANAR_U); const BYTE * srcpU = src->GetReadPtr(PLANAR_U); const BYTE * srcpV = src->GetReadPtr(PLANAR_V); // const int dpitchUV = dst->GetPitch(PLANAR_U); BYTE * dstpU = dst->GetWritePtr(PLANAR_U); BYTE * dstpV = dst->GetWritePtr(PLANAR_V); // for(y=sheightUV;--y>=0;) { for(x=srowsizeUV;--x>=0;) { dstpU[x] = srcpU[x]; dstpV[x] = srcpV[x]; } srcpU += spitchUV; srcpV += spitchUV; dstpU += dpitchUV; dstpV += dpitchUV; } } } else if(vi.IsYUY2()) { // YUY2 for(y=height;--y>=0;) { for(x=rowsize;(x-=4)>=0;) { dstp[x + 0] = srcp[x + 0]; dstp[x + 1] = srcp[x + 1]; dstp[x + 2] = srcp[x + 2]; dstp[x + 3] = srcp[x + 3]; } srcp += pitch; dstp += dpitch; } } else { // RGB if(vi.IsRGB24()) { for(y=height;--y>=0;) { for(x=rowsize;(x-=3)>=0;) { dstp[x + 0] = srcp[x + 0]; dstp[x + 1] = srcp[x + 1]; dstp[x + 2] = srcp[x + 2]; } srcp += pitch; dstp += dpitch; } } else { for(y=height;--y>=0;) { for(x=rowsize;(x-=4)>=0;) { dstp[x + 0] = srcp[x + 0]; dstp[x + 1] = srcp[x + 1]; dstp[x + 2] = srcp[x + 2]; dstp[x + 3] = srcp[x + 3]; // Added in TAKE_2, Copy Alpha } srcp += pitch; dstp += dpitch; } } } DPRINTF("Create_FrameStore: Calling Constructor") AVSValue ret = new FrameStore(vi,dst, parity); DPRINTF("Create_FrameStore: returning Framestore filter. EXIT OK") return ret; } /* New 2.6 requirement!!! */ // Declare and initialise server pointers static storage. const AVS_Linkage *AVS_linkage = 0; /* New 2.6 requirement!!! */ // DLL entry point called from LoadPlugin() to setup a user plugin. extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit3(IScriptEnvironment* env, const AVS_Linkage* const vectors) { /* New 2.6 requirment!!! */ // Save the server pointers. AVS_linkage = vectors; DPRINTF("AvisynthPluginInit3: Adding FrameStore plugin") env->AddFunction("FrameStore", "c", Create_FrameStore, 0); DPRINTF("AvisynthPluginInit3: FrameStore plugin Added, Returning to Avisynth") return "`FrameStore' FrameStore plugin"; // A freeform name of the plugin. } EDIT: Arh damn, spotted bug in RGB32, Alpha will hold rubbish, I'll up a another zip in a moment. (HAVE FIXED LINK) EDIT: TAKE_3, Source fix in unused dprintf(), no change to binary. zip updated. EDIT: Somebody wanna test it in AVS+ ? (standard v2.6 colorspaces) EDIT: Real.Finder, any preference, Copy/Nullify Alpha of RGB32 ? (I used Copy, seemed more sensible for frame storage). EDIT: Here a frame from my test script (Not the best choice of clip, it dont stay on scene for more than about 2 secs) SBX_MI(10,"lighten",0.5)
__________________
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; 25th November 2018 at 13:33. |
21st January 2018, 05:51 | #54 | Link |
Registered User
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,593
|
that seems to work StainlessS, thanks
but the problem in runtime should have a Solution too, if someone want to do thing that used the previous frames and that maybe related to crashes that happen sometimes when there are some function that has runtime part when reach some thousands frames (like 80% of 24 fps episode)
__________________
See My Avisynth Stuff Last edited by real.finder; 21st January 2018 at 06:27. |
21st January 2018, 05:53 | #55 | Link | |
Registered User
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,593
|
Quote:
SBX_MI(5,"lighten")
__________________
See My Avisynth Stuff Last edited by real.finder; 21st January 2018 at 05:56. |
|
21st January 2018, 06:13 | #56 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,018
|
A frame cannot be released whilst something else holds a reference to it, things would start exploding.
When SRestore (or whatever) is doing its stuff, it references only input frames, and when it moves on in the clip, those frames are no longer referenced, because it is now references other later frames, and so those input frames can be released. (They would actually not be released until all frames that reference them, including any cached frames, are released). When you instead reference previous OUTPUT frames, where E references D, and D refrences C, and C references B, and B references A, then A cannot be released until EVERY following frame which references it (directly or indirectly) is also released. OverLay, Layer, Stackhorizontal, or any other filter which 'combines' multiple frames, or transforms single frames, will hold a reference to all source frames involved (where source in this case would include previous OUTPUT frames if that was what was used as source the the filter). Any script which does as above, would crash Out Of Memory very quickly, just like your script did (and mine), way before thousands of frames were processed. I dont think that there will likely be any other solution other than something like FrameStore. EDIT: Oh, and nice pic too. EDIT: Where my original script crashed at about 845 frames, thats how many OUTPUT frames were being held in memory, ALL AT ONCE. (In actual fact, there would be additional intermediate frames also held in ram/pagefile).
__________________
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; 21st January 2018 at 06:51. |
21st January 2018, 06:17 | #57 | Link | |
Registered User
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,593
|
Quote:
and make it part for grunt, so I will added it to srestore and others to make it more clean
__________________
See My Avisynth Stuff |
|
21st January 2018, 06:35 | #58 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,018
|
"not only frames"
Its only frames that are the problem. FrameStore only makes a copy of a single frame, so that all frames that it depends upon can be released, I dont know if it would be at all useful in the likes of SRestore. If an output frame cannot be found in cache, then that output frame has to be re-created using the source frames to it, that is why those frames upon which it depends, cannot be released. Gavino is welcome to mod and incorporate the Framestore function/filter into Grunt, but I dont really think they are at all related. EDIT: FrameStore is problably not much use outside of Scriptclip or other runtime functions. EDIT: It is probably a fair candidate for inclusion in RT_Stats though.
__________________
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; 21st January 2018 at 06:53. |
21st January 2018, 07:21 | #59 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 11,018
|
Real.Finder,
I've just tried your last script (with only the non-optional blendfactor fixed, and SFrameBlendX_limit removed), and to my amazement, it goes for about 2,600 frames. It was pretty much what I tried earlier but I only removed Local=true, not knowing that True was the default when args used, so I should have set Local=false and would have got the same result as you. I tried with your script and also SBX_MI, with a subtract and amplify (via ClipDelta function), and we are getting identical results. EDIT: Although, when trying clip again, it sort of stuttered at about 1,600 frames, and then continued, not sure what happened there (try/catch ?). Your script with slight mods. Code:
Function SFrameBlendX(clip C, int blendfactor, string "blend_mode", float "blend_opacity") { C limit = (blendfactor<=0) ? 1 : Max(1, FrameCount/blendfactor) FrameCount!=1 ? ScriptClip(""" try{bb=isclip(b)} catch(error_msg) {bb=false} b = bb ? limit>1 ? Overlay(b.Loop(2,0,0),last,opacity=float(limit)/FrameCount) : b.Loop(2,0,0) : nop() b = bb ? b.Overlay(last, mode=blend_mode, opacity=blend_opacity) : last return b """,args="blend_mode, blend_opacity, limit", local=false) : last } Code:
Function SFrameBlendX(clip C, int blendfactor, string "blend_mode", float "blend_opacity") { C limit = (blendfactor<=0) ? 1 : Max(1, FrameCount/blendfactor) FrameCount!=1 ? ScriptClip(""" try{bb=isclip(b)} catch(error_msg) {bb=false} try { b = bb ? limit>1 ? Overlay(b.Loop(2,0,0),last,opacity=float(limit)/FrameCount) : b.Loop(2,0,0) : nop b = bb ? b.Overlay(last, mode=blend_mode, opacity=blend_opacity) : last } catch(error_msg) { b=Last # attempt at reset, dont work. } return b """,args="blend_mode, blend_opacity, limit", local=false) : last } two copies together, with Local=false in your script, the b variables (and perhaps others) would interfere with each other. EDIT: Suggest that you study the SBX_MI thing, its really not a very complex script and does pretty much exactly what your script does, the Martin53/Gavino Multi-instance interface makes for a very powerful little gizmo, with GScript and Grunt making things easy to acheive, it would be worth your time having a play with it. All you have to remember is to add @@@ to global names and when assigning to them always use Global x@@@=y, and copy the other stuff near the bottom of the SBX_MI script. EDIT: Heres a little MI test script to help you figure out how it works:- https://forum.doom9.org/showthread.p...49#post1805249 Use DebugView (google) to see the messages. Uncomment the RT_WriteFile line near the end to write the resultant script as a text file, it will be different for each instance of the function. Here, is instance 1 of SBX_MI Code:
Function Fn_SBX_MI_1(clip c,Int factor,String mode,Float opacity,Int limit) { n=current_frame if(Prev_SBX_MI_1 != n) { c cf=c.Trim(n,-1) # current frame if(Prev_SBX_MI_1 != n-1) { Global B_SBX_MI_1 = 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_SBX_MI_1 = Overlay(B_SBX_MI_1,cf, opacity=float(limit)/FrameCount) } # Else, B_SBX_MI_1 = Previous B_SBX_MI_1 # b.Overlay(last, mode=mode, opacity=opacity) # REMOVE '.FrameStore' from end of next line to crash this function. Global B_SBX_MI_1=Overlay(B_SBX_MI_1,cf,mode=Mode,opacity=Opacity).FrameStore } Global Prev_SBX_MI_1=n # REM for next time } # Else, Cache failure, repeat request for current frame, just return same as last time Return B_SBX_MI_1 } ####################################### # Unique Global Variables Initialization ####################################### Global Prev_SBX_MI_1=-666 ####################################### # Unique Runtime Call, GScriptClip must be a one-liner: ####################################### ARGS = "Factor,Mode,Opacity,Limit" c.GScriptClip("Fn_SBX_MI_1(last, "+ARGS+")", local=true, args=ARGS) EDIT: Maybe of interest:- https://forum.doom9.org/showthread.php?t=169624 EDIT: Whatever that stutter is, we get different results when it happens. EDIT: Found reason for different results when stutter, I originally used A, and B, instead of AC, and BC below, B was interfering with B in your script. Code:
AviSource("Parade.avi") # Some clip AC=SFrameBlendX(10,"lighten",0.5) BC=SBX_MI(10,"lighten",0.5) ClipDelta(AC,BC,true)
__________________
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; 21st January 2018 at 09:36. |
21st January 2018, 17:28 | #60 | Link |
Registered User
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,593
|
yes, that line
global SFrameBlendX_limit = limit I forget to remove
__________________
See My Avisynth Stuff |
Tags |
conditional, plugin, run-time, scriptclip |
Thread Tools | Search this Thread |
Display Modes | |
|
|