Log in

View Full Version : Wierd AviSynth Error


Tuesday
26th April 2006, 18:45
Hey i'm having some trouble while experimenting with my fist semi-adavanced clip in avisynth.

I'm trying to make a resize function that will resize by AR and mod, i havn't got round to "functionising" it yet as i've run in to this brick wall.


clip=mpeg2source("c:\vid.d2v")

#Resizer

AR = 2
block= 16

y = clip.height
ydiff = y % block
y = (ydiff < (block/2)) ? y - ydiff : y + (block - ydiff)

x = clip.height*AR
xdiff = x % block
x = (xdiff < (block/2)) ? x - xdiff : x + (block - xdiff)


BicubicResize(clip,x,y,0.333,0.666)

# End Resizer

This code works fine when AR is an interger value, but when i try a float Vdub returns ther error:

Avisynth open failure:
Evaluate: operands of `' must be integers
(c:\test.avs, line 13)

which corresponds to the line xdiff = x % block

I've read up on the the docs and LogicalOperators's page in the manual says mod accepts floats so i can't see whats wrong :S

Can anyone help?

(I'm using Avisynth version 2.56)

Wilbert
26th April 2006, 21:08
I've read up on the the docs and LogicalOperators's page in the manual says mod accepts floats so i can't see whats wrong :S
It means the docs are wrong. I will correct it, thanks! mod doesn't really makes sense for floats.

If you use

...
x = int(clip.height*AR)
xdiff = x % block
...

is that good enough in order to do what you want?

Tuesday
26th April 2006, 23:06
Thanks Wilbert!

Glad to know it wasn't just me being dumb.

That works perfectly, i didn't know you could specify the type of a variable like that.

foxyshadis
27th April 2006, 00:41
A little task or IanB as well, since the message should be:

Evaluate: operands of `%' must be integers

IanB
27th April 2006, 03:45
@foxyshadis, Ta! Fixed!

@Tuesday,

There are also Round(), Ceil() and Floor() functions for converting floats to ints as well as just Int().

And you may get better results calculating X from Y rather than Width.