Log in

View Full Version : Using ColorMatrix only when I need it in my function


sumawo13
6th August 2010, 06:38
I made a function that can convert HD square pixels to SD non-square pixels and vice versa, however it is possible to do a conversion from SD to SD or HD to HD, so sometimes the colorimetry conversion isn't needed. How do I only call ColorMatrix when I need it in my function?

Here is my code so far:

function resize(clip c,float par,float dar,int stdw,int stdh,int "cl",int "ct",int "cr",int "cb",string "cm")
{
cl=default(cl,0)
ct=default(ct,0)
cr=default(cr,0)
cb=default(cb,0)

c=c.crop(cl,ct,cr,cb)
c

wid=c.width()*par
hit=c.height()
vdar=float(wid)/hit

plr=dar>vdar?round(hit*dar-wid)/2:0
ptb=dar<vdar?round(wid/dar-hit)/2:0

addborders(plr,ptb,plr,ptb)
spline64resize(stdw,stdh)
colormatrix(cm,clamp=false)
}

It seems that even if I don't specify "cm", which is a string that sets the mode for ColorMatrix, it still does a conversion.

Gavino
6th August 2010, 09:39
Do this:
Defined(cm) ? colormatrix(cm,clamp=false) : last

sumawo13
6th August 2010, 10:52
I actually figured this out about a while ago messing around some more, of course it was something simple. Thanks for your help though, I appreciate it. :)