View Full Version : AviSynth function bug
FredThompson
4th July 2003, 08:00
AviSynth is puking on this script replying there is a syntax error on line 27, column 8.
That's the line with the return statement for the KVCD_Filter function.
Would someone please tell me what's causing this problem?
AVISource("Cyrano de Bergerac.avi")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\asharp.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\ReverseFieldDominance.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\STMedianFilter.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\undot.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\unfilter.dll")
KVCD_Filter()
##########################
function KVCD_Filter(){
MaxTreshold = 1.50
nf = 0 # Current frame.
undot()
limiter()
asharp(2, 4)
STMedianFilter(8, 32, 0, 0 )
MergeChroma(blur(MaxTreshold))
MergeLuma(blur(0.2))
ScriptClip("nf = YDifferenceToNext()"+chr(13)+ "nf >= 2 ? unfilter( -(fmin(round(nf)*2, 100)), -(fmin(round(nf)*2, 100)) ) : TemporalSoften(4, round(1/nf) , round(3/nf) ,0, 2) ")
Limiter()
return()}
function fmin( int f1, int f2) {
return ( f1<f2 ) ? f1 : f2}
Wilbert
4th July 2003, 09:35
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\asharp.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\ReverseFieldDominance.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\STMedianFilter.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\undot.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\unfilter.dll")
AVISource("Cyrano de Bergerac.avi")
KVCD_Filter()
##########################
function KVCD_Filter(clip c){
MaxTreshold = 1.50
nf = 0 # Current frame.
undot(c)
limiter()
asharp(2, 4)
STMedianFilter(8, 32, 0, 0 )
MergeChroma(blur(MaxTreshold))
MergeLuma(blur(0.2))
ScriptClip("nf = YDifferenceToNext()"+chr(13)+ "nf >= 2 ? unfilter( -(fmin(round(nf)*2, 100)), -(fmin(round(nf)*2, 100)) ) : TemporalSoften(4, round(1/nf) , round(3/nf) ,0, 2) ")
Limiter()
return last
}
function fmin( int f1, int f2) {
return ( f1<f2 ) ? f1 : f2}
Same error?
FredThompson
4th July 2003, 09:50
oh....yeah....if you're gonna expect return arguments, you have to pass them...uh...yeah...
No, a different error now. Now it's complaining about the arguments being passed in the function call.
See that line "KVCD_Filer()"? That was just for testing. This is what's supposed to be there:
Limiter(min_luma=16)
GetParity() ? nop() : ReverseFieldDominance()
even=SelectEven(SeparateFields()).KVCD_Filter()
odd=SelectOdd(SeparateFields()).KVCD_Filter()
Interleave(even,odd).Weave()
Limiter(min_luma=16)
I'm stumped and it's now almost 5AM so I'm going to sleep. If you could shed soem light on this, I'd sure appreciate it. It's really odd, if those lines were:
even=SelectEven(SeparateFields()).STMedianFilter()
odd=SelectOdd(SeparateFields()).STMedianFilter()
they would be accepted. There must be something different in how the arguments are being passed.
sh0dan
4th July 2003, 10:37
Using KVCD_Filter(last) should work.
FredThompson
4th July 2003, 14:25
Thank you, sir.
FredThompson
4th July 2003, 14:50
well, I just tried this and it's not working. AviSynth is complaing that invalid arguments are being passed to KVCD_Filter. I guess that makes sense because "last" inside the parenthesis is an argument going to the function and the function call should return a single argument, if any. right?
So, I'm still stumped. Ideas?
stickboy
5th July 2003, 01:31
Can you repost your entire script and the exact error message?
FredThompson
5th July 2003, 01:51
Post1 in this thread is the script. Just change the source name to any interlaced source and see what happens. It's hard to describe what, exactly, is triggering the errors.
I'm now wondering if it's a parsing error or one of the filters in the function not knowing which clip to process...maybe a combination.
I don't really care if a function is used to encapsulate that KVCD filtering, just want an alias of some sort so fields can be sent through it. If their code is kept separate, it will be a lot easier to update as they enhance it and the storage/capturing noise can be filtered separately.
I really don't want to do too much capture filtering until their stuff is working. Need to see the results of their stuff on a per-field basis first.
You can remove the ReverseFieldDominance lines if you wish. Those are just to ensure the reverse order of camcorder DV isn't a problem.
stickboy
5th July 2003, 02:05
The script in your original post is not the current version (you even said there are some lines that are not supposed to be there). Could you please repost the entire thing in its current form (or a link to it) so that we're all looking at the same thing?
FredThompson
5th July 2003, 02:24
Oh, you're right, monitoring too many threads.
Apparently, the GetParity call isn't coded properly so I've commented it out. It's only applicable for camcorder DV anyhow
Try this:
AVISource("Cyrano de Bergerac.avi")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\asharp.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\ReverseFieldDominance.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\STMedianFilter.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\undot.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\unfilter.dll")
Limiter(min_luma=16)
# GetParity() ? nop() : ReverseFieldDominance()
even=SelectEven(SeparateFields()).KVCD_Filter()
odd=SelectOdd(SeparateFields()).KVCD_Filter()
Interleave(even,odd).Weave()
Limiter(min_luma=16)
##########################
function KVCD_Filter(){
MaxTreshold = 1.50
nf = 0 # Current frame.
undot()
limiter()
asharp(2, 4)
STMedianFilter(8, 32, 0, 0 )
MergeChroma(blur(MaxTreshold))
MergeLuma(blur(0.2))
ScriptClip("nf = YDifferenceToNext()"+chr(13)+ "nf >= 2 ? unfilter( -(fmin(round(nf)*2, 100)), -(fmin(round(nf)*2, 100)) ) : TemporalSoften(4, round(1/nf) , round(3/nf) ,0, 2) ")
Limiter()
return}
function fmin( int f1, int f2) {
return ( f1<f2 ) ? f1 : f2}
Guest
5th July 2003, 02:46
Like this (stripped down for simplicity):
AVISource("test3.avi")
even=SeparateFields().SelectEven().KVCD_Filter()
odd=SeparateFields().SelectOdd().KVCD_Filter()
Interleave(even,odd).Weave()
function KVCD_Filter(clip c){
nf = 0 # Current frame.
c=ScriptClip(c,"nf = YDifferenceToNext()"+chr(13)+ "nf >= 2 ? unfilter( -(fmin(round(nf)*2, 100)), -(fmin(round(nf)*2, 100)) ) : TemporalSoften(4, round(1/nf) , round(3/nf) ,0, 2) ")
return c}
function fmin( int f1, int f2) {
return ( f1<f2 ) ? f1 : f2}
FredThompson
5th July 2003, 02:57
Funny, thought I'd tried that.
...test update...
ok, now AviSynth is complaining that undot is receiving invalid arguments. If I comment out those functions, leaving only the temporal filtering, AviSynth complains there isn't a chr function.
Geez, how hard can it be to create a functional alias for a number of lines?
Guest
5th July 2003, 03:43
Fred, you have to repost the script after each revision. We are not mind readers.
Did you use:
c=Undot(c)
FredThompson
5th July 2003, 04:41
Sorry, here ya go:
AVISource("Cyrano de Bergerac.avi")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\asharp.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\ReverseFieldDominance.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\STMedianFilter.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\undot.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\unfilter.dll")
Limiter(min_luma=16)
GetParity() ? nop() : ReverseFieldDominance()
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
nf = 0 # Current frame.
#undot()
#limiter()
#asharp(2, 4)
#STMedianFilter(8, 32, 0, 0 )
#MergeChroma(blur(MaxTreshold))
#MergeLuma(blur(0.2))
ScriptClip("nf = YDifferenceToNext()"+chr(13)+ "nf >= 2 ? unfilter( -(fmin(round(nf)*2, 100)), -(fmin(round(nf)*2, 100)) ) : TemporalSoften(4, round(1/nf) , round(3/nf) ,0, 2) ")
#Limiter()
return c()}
function fmin( int f1, int f2) {
return ( f1<f2 ) ? f1 : f2}
--
ok, I've tried c=undot(c) as you suggested. this still pukes on the chr() function.
the readme for undot doesn't list a clip as an argument. Is this a standard assumption of functions, that a clip is passed? How does this affect the function calls which DO include arguments? Maybe that's a lot of the problem, the scope of the default clip.
I've been reading both versions of the AviSynth documentation and some lexical details are hard to find. Can't remember where I was earlier tonight but I saw a note that basic order of parsing and precendence is like C. The sections on format of function calls are quite incomplete. Granted, documenting the grammar of a programming language isn't exactly fun.
Wilbert
5th July 2003, 13:47
It doesn't work, because you are messing up the syntax.
This line is incorrect:
return c()}
If you change it into this line
return c}
It should produce output, but it doesn't do what you want. The clip "c" is directly returned without passing the scriptclip line. While this is not the case in Neuron's example, and also not in mine example below (note that "return last" returns the output from Limiter):
AVISource("e:\pdwork\atomic.avi")
ConvertToYV12
Limiter(min_luma=16)
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
nf = 0 # Current frame.
undot(c)
limiter()
asharp(2, 4)
STMedianFilter(8, 32, 0, 0 )
MergeChroma(blur(MaxTreshold))
MergeLuma(blur(0.2))
ScriptClip("nf = YDifferenceToNext()"+chr(13)+ "nf >= 2 ? unfilter( -(fmin(round(nf)*2, 100)), -(fmin(round(nf)*2, 100)) ) : TemporalSoften(4, round(1/nf) , round(3/nf) ,0, 2) ")
Limiter()
return last}
function fmin( int f1, int f2) {
return ( f1<f2 ) ? f1 : f2}
the readme for undot doesn't list a clip as an argument. Is this a standard assumption of functions, that a clip is passed? How does this affect the function calls which DO include arguments? Maybe that's a lot of the problem, the scope of the default clip.
It is just a sloppy notation, it should list a clip as an argument.
FredThompson
5th July 2003, 13:59
Huh, wonder why I added the parenthesis.
I've copied your post into my copy and it's still puking on the chr() function.
You got it to work? Wonder if I've got a corrupted install of AviSynth.
Wilbert
5th July 2003, 14:07
You got it to work? Wonder if I've got a corrupted install of AviSynth.
Yes it works. I assumed you installed the latest AviSynth?
Does the following script works:
BlankClip
Subtitle(string(chr(13)))
FredThompson
5th July 2003, 14:09
Yeah, I had 2.5.2 installed but just re-installed and rebooted. Now it works. Weird.
Thanks for the help.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.