Log in

View Full Version : Scripts that require MOD 2/4/8/16


steptoe
16th June 2008, 21:41
Is there a simple function that I could use to get my video source the right MOD for some functions or filters that require the sizes to be a specific size

I know some require it to be say MOD 8 and if it isn't you could end up with strange results or the filter even failing

EG

MOD(1280,1200,8)

Yes I know these values are correct, but its just an example without trying to find some weird source that has strange dimension


Where the first two are you width and height and the third is the actual MOD that you require to get the images sizes as they should be so the filter won't fail or do weird things to the source as its not dimensions that the filter or function was expecting

mikeytown2
16th June 2008, 21:58
Your asking for something that would put this into a easy to use function?

ColorBars(641,481)
#mod 4 example
Mod = 4
OrginalW = width()
OrginalH = height()
ModW = Ceil(Float(OrginalW)/Mod)*Mod
ModH = Ceil(Float(OrginalH)/Mod)*Mod



AddBorders(ModW-OrginalW,ModH-OrginalH,0,0)

#Filter

Crop(ModW-OrginalW,ModH-OrginalH,0,0)

gzarkadas
16th June 2008, 22:04
Either RoundBs (http://avslib.sourceforge.net/functions/r/roundbs.html) or IntBs (http://avslib.sourceforge.net/functions/i/intbs.html) would be suitable. They round / truncate to any base; in your case you should set the base argument to 2, 4, 8, etc. For example:

...
new_width = RoundBs(width, 8)
new_height = RoundBs(height, 8)
xxxResize(new_width, new_height)
# now last is mod-8
...


If you don't want to install AVSLib, you can paste the code of the functions from the related CVS file (http://avslib.cvs.sourceforge.net/avslib/avslib/numeric/rounding.avsi?view=markup); it has no dependencies on other AVSLib modules.

steptoe
18th June 2008, 09:51
Many thanks thats exactly what I was looking for