Log in

View Full Version : Building a function - newbie question


Pages : 1 [2]

MatLz
23rd November 2009, 13:23
Same problem with your suggestion.:confused:

Gavino
23rd November 2009, 19:12
I've tried various combinations and I still can't reproduce your problem. To help me narrow down the possible cause, please tell me:

1)Does it only happen when Assert should produce an error, or in all cases when Assert is present?
2)I notice you have your del function in an avsi. Do you still have the problem when declaring it directly in your script instead?
3)Do you have any other avsi files in your plugins folder that use GScript outside of a function?
4)Are you using AvsP? Does the error still occur when using something else, like MPC or VDub?

MatLz
23rd November 2009, 19:31
Thanks for your interest!
1.Only when assert should produce an error
2.I tried, same problem
3.I tried too and remove all my plugins and avsi (except GScript of course!)
4.all my previewing methods crashe (vdub and Mod, avsp, mpc)
:devil: my pc is possessed?!

Gavino
23rd November 2009, 19:39
Thanks - one more question I forgot to ask: which version of Avisynth are you running? (use Version() to make sure)

MatLz
23rd November 2009, 19:46
2.5.8.5 22december2008

Gavino
23rd November 2009, 20:03
Here's what I get, running on 2.5.8 with this script:
GScript("""
function del(clip IN,int a,int b)
{
Assert(a!=13, "NO NO NO 13 IS NOT ALLOWED!!!")

loop(IN,0,a,b)
}
""")

BlankClip()
del(13,20)
Does this crash for you?

MatLz
23rd November 2009, 20:22
I don't know if this can help but I tried a simple encode, here is the window after launch:C:\>C:\l.bat

C:\>"C:\x264.exe" --pass 1 --bitrate 1000 --output NUL "C:\s.avs"

C:\>"C:\x264.exe" --pass 2 --bitrate 1000 --output "C:\v.264" "C:\s.avs"

C:\>_Nothing really happened! That jump directly to 2nd pass and jump directly to next line...Is it really a "crashe"?
Windows of mpc, vd, avsp appear a fraction of second and disappear...

MatLz
23rd November 2009, 20:29
I found a tip...but not resolve the main problem:

Function del...
{
Assert...
GScript("""funtion""")
}

In this order it works.

Gavino
23rd November 2009, 21:49
OK - well, at least you have a workaround for now.

I still can't reproduce the problem, and I can't see any reason why Assert shouldn't work. There's nothing really special about Assert, it just reports an error like any other function potentially could.

What result do you get with these examples?

1)
GScript("Assert(false)")

2)
Gscript("Garbage")

MatLz
23rd November 2009, 22:03
Assert(false) and garbage crashe. All two simply puted before a source.

What is garbage? A GScript secret weapon?

Gavino
23rd November 2009, 22:30
OK, it looks like GScript somehow screws up any kind of error reporting on your system, but not on mine. The next step is to find out why...

"Garbage" was just any old rubbish to provoke an error. :)
It should have reported 'I don't know what "Garbage" means'.

MatLz
23rd November 2009, 22:43
Ok ok that's clever!!
So on my system I can't have an error message if I use GScript and if there is a mistake in the GScript's part of my script....so I have been very lucky when I did the 4 ranges function on the first attempt!:cool:

So...I'm on XP 32bits sp2 core2duo...what else?...ha yes I know why it doesn't work...Windows is Microsoft's no?:devil:

MatLz
23rd November 2009, 23:59
Updated to 4 zones and invalid ranges fixed.
The real question is "Why this function ?"
Hmm...for exampledel(10,20,30,40,50,60,70,80)can replace:trim(0,9)+trim(21,29)+trim(41,49)+trim(61,69)+trim(81,0)We focus on the range frames to delete, not on the range frames to keep. So, less to write!
With sorting the variables in the function, we can also do that in the order we want (by pairs), if we've forget a zone for example.(while previewing the entire clip of course)

Gavino
24th November 2009, 00:02
I'd like to be able to blame Bill Gates for this one, but somehow I think the problem lies somewhere else. :)

Still don't know where though.
Is anyone else reading this who has GScript installed?
If so, please try this one-line script:
GScript("Assert(false)")
and see if it works for you.

Reuf Toc
24th November 2009, 00:55
Same for me, it crash. as well as Gscript("Garbage") .
I'm on windows xp sp3, avisynth 2.58, 22Dec 2008 08:46:51.
Decoding is done by FFDshow but I suppose it doesn't matter

MatLz
24th November 2009, 05:29
@Reuf Toc
Welcome to the :devil: issue!

@Gavino
Do you know a text editor which can reverse selected lines?
I ask for that because I've finish the 5 ranges:cool:...and I think a really small speed-up is possible with that.(put inverse ranges first)
Thanks.

Gavino
24th November 2009, 11:05
@Reuf Toc

Thanks for the info. That confirms there is a problem somewhere, but for some reason it works OK for me. I am wondering if it is a processor-related thing (perhaps associated with Avisynth's exception handling mechanism). I am running on a Pentium 4.

@MatLz

I don't know of an editor that can do that (possibly emacs?).
BTW it occurs to me now that a simpler way of accommodating multiple ranges is to use recursion, eg
GScript("""
function del(clip IN,int a,int b,int "c",int "d",int "e",int "f")
{
if (!defined(c)) { # single range
loop(IN,0,a,b)
}
else if (!defined(e)) { # 2 ranges
a > c ? loop(IN,0,a,b).loop(0,c,d) : loop(IN,0,c,d).loop(0,a,b)
}
else { # 3 ranges
m = max(a,c,e)
if (m == a) { loop(IN,0,a,b).del(c,d,e,f) }
else if (m == c) { loop(IN,0,c,d).del(a,b,e,f) }
else { loop(IN,0,e,f).del(a,b,c,d) }
}
}
""")
I think you can see how to extend this to 4 or more ranges with much fewer lines than before.

I will continue to investigate the GScript/Assert problem.

MatLz
24th November 2009, 18:58
Well I can't find a tool which can reverse lines, even Emacs...
Anyway, no more perfectionism...it seems it's not really a stressing process to search the range on only 120 lines.
I simply puted the first order on top

So updated to 5 ranges.
Last update with the "old new method"....it's enough brain suffering!

@Gavino: I will take a look at the new you pointed out.

Ps: Is someone else interested by this function?
Is it wasted time to continue for more ranges?

Reuf Toc
25th November 2009, 18:45
My processor is a Sempron Palermo 2800+ (MMX, SSE, SSE2 SSE3). I tried to run the same script under avisynth 2.57 and 2.56 and the same problem occurs.

Would it be possible to know what happen with some tool (DebugView or something else) ?

Gavino
25th November 2009, 21:40
Thanks for the details, Reuf Toc.
I still can't reproduce the problem, so please try running with DebugView and see if you can obtain info on the nature of the crash.

Gavino
28th November 2009, 20:29
MatLz, Reuf Toc and anyone else interested:

I am unable to reproduce the GScript problem on my system, but I have an idea what might be the cause.
Please try the following version and see if it works OK:
http://www.mediafire.com/file/2qmwdhmd2nu/GScript_10a.zip

As before, try with GScript("Assert(false)") or anything that should produce an error.

Reuf Toc
29th November 2009, 21:01
It doesn't crash anymore for me :thanks:

Just by curiosity, even if I'm not a programmer, what was the problem ?

I tried to run DebugView but it didn't display any message. Maybe a debug build is needed or I didn't use it correctly...

Gavino
29th November 2009, 21:37
Thanks, Reuf Toc.

The problem was connected with the way Avisynth handles exceptions, together with changes introduced in Windows XP SP2*. When building GScript, I had to add the linker parameter /SAFESEH:NO.

I will release a new 'official' version of GScript soon, including this fix and other minor changes.

* So in a way, MatLz was right, it was Microsoft's fault. :D

MatLz
1st December 2009, 11:59
Thanks for the sendspace link.
So now it does work. I get the error messages. Nice debuging work!
Your code in your last PM is pretty close than my latest! I just return to last in the last else.
I will update to 13 ranges (26 letters in the alphabet if I'm wright?:) )
I think it will be enough...

MatLz
6th December 2009, 09:49
Done for 13 ranges with new error messages.
Last update of this useless function? Maybe. (personnaly I find it easier than a lot of trim's successions...)

MatLz
29th December 2009, 14:02
Hi! Here is my new usual question in this thread!:D

Isint(x/2)...will be always true if x is an integer....even if x is odd!!...if I want to do a conditional sorting for even or odd, so it doesn't work...
Maybe it's obvious but THX for the tip!

Edit: ok forget me! I found the tip:
Frac(x/2.)==0

kemuri-_9
29th December 2009, 16:45
Hi! Here is my new usual question in this thread!:D

Isint(x/2)...will be always true if x is an integer....even if x is odd!!...if I want to do a conditional sorting for even or odd, so it doesn't work...
Maybe it's obvious but THX for the tip!

Edit: ok forget me! I found the tip:
Frac(x/2.)==0

the modulus operator % exists for a reason:
x%2 will either be 1 or 0; 1 if odd, 0 if even

MatLz
29th December 2009, 21:55
%2
Thx Kemuri-_9!
You're too strong!
Or it's me who had not correctly read the doc...;)