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. |
29th April 2017, 18:10 | #3341 | Link |
Soul Architect
Join Date: Apr 2014
Posts: 2,559
|
I was thinking about the issue with "last" and global vars.
"last" isn't used within script functions so script libraries won't be affected by any issue here. If there are problems, it's going to happen at the main script level. If it works within script functions (without implicit "last"), then it's a huge improvement already. Once that is working, we can give it some more thoughts about how to handle variables like "last", as well as produce bogus scripts for testing. I think we're better to leave that one for later. If we're going to change it, we'll have to do it right, and for now we have no right solution. Still, that doesn't prevent conditional functions from being supported. |
29th April 2017, 20:03 | #3343 | Link |
Soul Architect
Join Date: Apr 2014
Posts: 2,559
|
Code:
Fct1() # uses implicit last -- possible issue with dynamic evaluation of expressions like Eval which reset "last" Fct2() function Fct1(clip c) { c = c.Fct2() # here we need to define the clip explicitely return Fct3(c) } |
29th April 2017, 20:22 | #3344 | Link |
Retried Guesser
Join Date: Jun 2012
Posts: 1,373
|
I once told a guy -- can't find the link right now -- about the easy way to create a function from a bunch of script lines. Something like:
Code:
function foo(clip C) { C ## Last==C Filter1 Filter2 Filter3 return Last } EDIT - I always use explicit Last with BlankClip and ScriptClip; maybe Eval should get special treatment (from the user) also. Last edited by raffriff42; 29th April 2017 at 20:29. |
29th April 2017, 20:29 | #3345 | Link |
German doom9/Gleitz SuMo
Join Date: Oct 2001
Location: Germany, rural Altmark
Posts: 6,784
|
Or so:
Code:
function Fct1(clip c) { c # means explicitly: last = c Fct2() return Fct3() } Fortunately, last is not "super-global". At least I hope so. |
29th April 2017, 21:10 | #3346 | Link |
Soul Architect
Join Date: Apr 2014
Posts: 2,559
|
Right -- sorry my mistake.
We're not changing anything to "last". We're just worried it might have some of the same issues as "current_frame" with MT -- although we're not clear on how such problem manifests. We haven't seen any issue so far. |
29th April 2017, 21:18 | #3347 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Code:
function Fct1(clip c) { c # means explicitly: last = c Fct2() x=sin(.5) sin(.5) # EDIT: added return Last # return result of Fct2() # Assuming it was a clip }
__________________
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; 29th April 2017 at 21:21. |
30th April 2017, 08:22 | #3349 | Link |
Registered User
Join Date: Jan 2014
Posts: 2,314
|
That deadlock thing is hard to catch. I was working on the problem during December, now I have returned to it.
In my test code the variables last and current_frame were passed to the invoke with guards of mutex. That specific TLS (Thread Local Storage) Invoke - I had linked earlier which was doing context switch and made "current_frame" and "last" out of scope - was modified a bit to re-set those variables in the scope of the core. But this was only the first small step which only allowed the script not to fail in YDifferenceFromPrevious's constructor (which so far was complaining "current_frame" does not exists) ScriptClip MT test script, which I'm using to ensure that last is always right. Frames should follow each other displaying 16-32-48-96-16-32-48-96 sequence if frame order is OK. There is a second ScriptClip line, because it makes our life shorter and increases the stress level a bit. We have another parallel work in runtime evaluation. Case #1 happyness When the second ScriptClip line is independent from the first ScriptClip(commented out c1=, c2= lines in code below), then there is no problem, I'm doing Prefetch(300) and nothing fails. Case#2 deadlock But when the second ScriptClip is using the output of the first ScriptClip, sometimes deadlock occurs. Depending on the clip size, additional filters at the end, they all modify internal timings, order of cache hits, this "sometimes" can be never or 10 or 100 frames. I have experimented with a few hundred variants. Deadlock can be eliminated when ScriptClip is defined as "DONT_CACHE_ME", but this is no-go of course. Sometimes Prefetch(80) is OK, but Prefetch(90) deadlocks. In other timing conditions the limit is Prefetch(8), etc. Code:
len=1 w=64 h=48 c1=BlankClip(width=w,height=h,length=len,pixel_type="YV24",color_yuv=$008080) c2=BlankClip(width=w,height=h,length=len,pixel_type="YV24",color_yuv=$108080) # diff 16 c3=BlankClip(width=w,height=h,length=len,pixel_type="YV24",color_yuv=$308080) # diff 32 c4=BlankClip(width=w,height=h,length=len,pixel_type="YV24",color_yuv=$608080) # diff 48 -> diff (-)96 c=c1+c2+c3+c4 c.Loop(100) # this will deadlock sooner or later or never, more Prefetch makes deadlock to appear, even more -> deadlock sooner ScriptClip(last, "Subtitle(String(YDifferenceFromPrevious()))") ScriptClip(last, "Subtitle(String(YDifferenceFromPrevious()),X=0,Y=30)") /* This works for any Prefetch, no dependancy between them c1=ScriptClip(last, "Subtitle(String(YDifferenceFromPrevious()))") c2=ScriptClip(last, "Subtitle(String(YDifferenceFromPrevious()),X=0,Y=30)") Stackvertical(c1,c2) */ ConvertToRGB32() #additional filters modify timing thus, frame evaluation order/cache hit order in MT ConvertToRGB24() ConvertToRGB32() ConvertToRGB24() Prefetch(60) |
30th April 2017, 15:30 | #3350 | Link |
Soul Architect
Join Date: Apr 2014
Posts: 2,559
|
I tried doing a bit of multi-threading in C++ until I realized how much of a pain it was. I was reading many articles saying how MT was only for experts, and I then understood why.
My recommendation: write the thread management in .NET (no "undefined" state!!) but that's not really an option -- if rewriting was an option, it's VapourSynth all the way so... Good luck |
30th April 2017, 16:41 | #3351 | Link | |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Quote:
Code:
function Fct2(clip c) {return c.info} function Fct1(clip c) { c # means explicitly: last = c Fct2() z=c.Invert x=sin(.5) sin(.5) return Last # return result of Fct2(), Colorbars with Info } Colorbars.killaudio Fct1()
__________________
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; 30th April 2017 at 17:03. |
|
30th April 2017, 18:17 | #3352 | Link | |
Excessively jovial fellow
Join Date: Jun 2004
Location: rude
Posts: 1,100
|
Quote:
See here and the surrounding posts for an extensive earlier discussion on attempting to make it less weird. The tl;dr is that Avisynth script kinda needs an assignment operator that is actually a real operator rather than a special type of expression, but good luck with that. Last edited by TheFluff; 30th April 2017 at 18:25. |
|
30th April 2017, 18:56 | #3353 | Link | |
German doom9/Gleitz SuMo
Join Date: Oct 2001
Location: Germany, rural Altmark
Posts: 6,784
|
Quote:
Pascal has the reserved variable "Result" to explicitly assign a return value in the scope of a function. |
|
30th April 2017, 19:06 | #3354 | Link | |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Whoa, that surprised me when removing the 'Return Last' from Fct1(),
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; 30th April 2017 at 19:17. |
|
30th April 2017, 19:37 | #3355 | Link | |
Excessively jovial fellow
Join Date: Jun 2004
Location: rude
Posts: 1,100
|
Quote:
$_ in Perl and last in Avisynth are special in that they act as a default parameter to many functions if no other suitable value is given. For example, in Perl saying "print;" is the same as saying "print($_);" much like how in Avisynth "blur()" is the same as "blur(last)". Since Perl is an imperative language, it doesn't need the implicit assignment part of the equation, though - function calls can just have side effects and mutate $_ with no problems (you still get implicit assignment to $_ when using it as an implicit iterator in loops though, but that's beside the point). Avisynth script, however, is a quite poor excuse for a functional language that wants to pretend it is imperative, or perhaps more accurately, it's a schizophrenian language that has one data type that is purely functional and lazily evaluated, paired with a bunch of imperative scripting functionality that very much isn't. What you're writing in Avisynth script is a composition of functions (in other words, the filter chain), so from the script's point of view, clip variables are effectively immutable. Hence you get the hack that is the implicit assignment to last based on what the expression evaluates to - the clip data type is effectively living in a different programming language than everything else in Avisynth script and has its own semantics. Arguably, the entire "assignment" part of clip variables is confusing, since you're not really assigning a value to a variable at all. Last edited by TheFluff; 30th April 2017 at 19:40. |
|
30th April 2017, 21:21 | #3356 | Link | |
Soul Architect
Join Date: Apr 2014
Posts: 2,559
|
Quote:
Here's the x86 library of MT-pfmod with conditional filters, if anyone wants to play with it (no 16-bit stuff in this version). Code:
len=1 w=64 h=48 c1=BlankClip(width=w,height=h,length=len,pixel_type="YV24",color_yuv=$008080) c2=BlankClip(width=w,height=h,length=len,pixel_type="YV24",color_yuv=$108080) # diff 16 c3=BlankClip(width=w,height=h,length=len,pixel_type="YV24",color_yuv=$308080) # diff 32 c4=BlankClip(width=w,height=h,length=len,pixel_type="YV24",color_yuv=$608080) # diff 48 -> diff (-)96 c=c1+c2+c3+c4 c.Loop(10000) # this will deadlock sooner or later or never, more Prefetch makes deadlock to appear, even more -> deadlock sooner ScriptClip(last, "Subtitle(String(YDifferenceFromPrevious()))") ScriptClip(last, "Subtitle(String(YDifferenceFromPrevious()),X=0,Y=30)") /* This works for any Prefetch, no dependancy between them c1=ScriptClip(last, "Subtitle(String(YDifferenceFromPrevious()))") c2=ScriptClip(last, "Subtitle(String(YDifferenceFromPrevious()),X=0,Y=30)") Stackvertical(c1,c2) */ ConvertToRGB32() #additional filters modify timing thus, frame evaluation order/cache hit order in MT ConvertToRGB24() ConvertToRGB32() ConvertToRGB24() Prefetch(100) Code:
FPS (min | max | average): 87.34 | 14329 | 1564 Memory usage (phys | virt): 32 | 28 MiB Thread count: 112 CPU usage (average): 17% In contrast, the latest release of Avisynth causes occasional crashes even without MT.
__________________
FrameRateConverter | AvisynthShader | AvsFilterNet | Natural Grounding Player with Yin Media Encoder, 432hz Player, Powerliminals Player and Audio Video Muxer Last edited by MysteryX; 30th April 2017 at 21:38. |
|
30th April 2017, 22:41 | #3357 | Link |
Registered User
Join Date: Apr 2016
Posts: 27
|
Trouble with i386 r2455.
Hi,
Cannot get this script to run to completion w/ i386 r2455: Code:
SetFilterMTMode("DEFAULT_MT_MODE", 2) SetFilterMTMode("DGDecodeNV", 3) Import("\MKVideo Encoder NV\AVS Scripts MT\LoadPlugins.avs") LoadPlugin("\MKVideo Encoder NV\DGDec\DGDecodeNV.dll") DGSource("\MKVideo Files\Input_Video_File.dgi") Spline64Resize(1280, 720) RoboCrop(Laced=False, Align=True) LSFmod(defaults="slow", preblur="DeGrainMedian(limitY=4, limitUV=6, mode=1, interlaced=false)", strength=200, smode=5, secure=true) Prefetch(6) Thanks. |
30th April 2017, 22:58 | #3358 | Link | ||
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,431
|
Quote:
Quote:
|
||
30th April 2017, 22:59 | #3359 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Clever Cloggs
__________________
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 ??? |
30th April 2017, 23:08 | #3360 | Link | |
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,431
|
Also note:
Quote:
|
|
|
|