Log in

View Full Version : why is this crashing?


FredThompson
13th July 2003, 07:27
This works. However if the guts of the function are replaced with the commented-out lines, it does not. AviSynth appears to have problems creating the variable SwitchThreshold. The name, itself, is irrelevant. AviSynth reports:

I don't know what SwitchThreshold means
([ScriptClip], line 4)

I'm stumped. Since the variable name is irrelevant, it can't be an operator or definition scope problem. Any ideas?

ConvertToYV12()
even=SelectEven(SeparateFields()).KVCD_Filter()
odd=SelectOdd(SeparateFields()).KVCD_Filter()
Interleave(even,odd).Weave()

Limiter(min_luma=16)

function KVCD_Filter(clip c){

MaxTreshold = 1.50
Max=5
nf = 0 # Current frame.

undot(c)
asharp(1,4)
STMedianFilter(8, 32, 0, 0 )
MergeChroma(blur(MaxTreshold))
MergeLuma(blur(0.1))


ScriptClip("nf = YDifferenceToNext()"+chr(13)+ "nf > 2 ? \
unfilter( -(fmin(round(nf)*2, 100)), -(fmin(round(nf)*2, 100)) ) : \
TemporalSoften( fmin( round(2/nf), 6), round(1/nf) , round(3/nf) , 1, 1) ")

#SwitchThreshold = (Width<=352) ? 4 : (Width<=480) ? 3 : 2
#ScriptClip("nf = YDifferenceToNext()"+chr(13)+ "nf >= SwitchThreshold ? \
#unfilter( -(fmin(round(nf)*2, 100)), -(fmin(round(nf)*2, 100)) ) : \
#TemporalSoften( fmin( round(2/nf), 6), round(1/nf) , round(3/nf) , 1, 1) ")

return last}

function fmin( int f1, int f2) {
return ( f1<f2 ) ? f1 : f2}

HomiE FR
13th July 2003, 08:02
I've not a full understanding of the conditional functions (I believe only sh0dan who designed them has, in fact :) ), but you should put global for the parameter SwitchThreshold like this:

global SwitchThreshold = (Width<=352) ? 4 : (Width<=480) ? 3 : 2

I've played a lot with these functions (see the thread QMF & FMF v1.5 b1 ;) ) and even though I've not tested your script I really believe this should work. Good luck (you'll need it :p )!

FredThompson
13th July 2003, 08:12
Huh, that's really odd.

It works, and a HUGE THANK YOU for helping me, but it shouldn't work.

The variable should be local and private to the function. It's really no different, from a grammatical sense, than Max or MaxThreshold.

FredThompson
13th July 2003, 08:24
Oh, I think I know the answer but I don't like it.

ScriptClip must have it's own realm for variables. That's the only thing which makes sense, assuming there's not a major bug in how ConditionalFilter is coded.

Thus, the variable has to be declared as a global to be available to ConditionalFilter.

The grammar would indicate ConditionalFilter should treat the passed arguments as available.

ConditionalFilter must be more of a kludge than I initially realized, sort of a way to "trick" AviSynth into doing something it's not really designed to do.

Hmmm...

C'mon AviSynth 3!!!

HomiE FR
13th July 2003, 10:53
I was as disappointed as you when I first found out that I needed to put global variables everytime I wanna play with them inside a conditional function. :)

But you got some info about Avisynth 3 and improved conditional functions? Tell me everything! :p I wish it'll be possible to go through the current problems with FrameEvaluate/ScriptClip (the memory leaks which fill up system memory when used inside these functions).

Wilbert
13th July 2003, 13:26
ConditionalFilter must be more of a kludge than I initially realized, sort of a way to "trick" AviSynth into doing something it's not really designed to do.
Yup. It's a kind of matrix in a matrix :)

Some more info (http://forum.doom9.org/showthread.php?s=&threadid=56810).

Bidoche
13th July 2003, 14:27
Expected 3.0 syntax for ConditionalFilter and ScriptClip (without me or Sh0dan really investigating it)ConditionalFilter(clip left, clip right, function condition)
throws an error if condition is not bool (int)

ScriptClip(clip c, function pipe)
where pipe must be frame (frame) or frame (frame, int)