Log in

View Full Version : Automatically add borders to reach next multiple of 16?


Thomas2681
8th September 2009, 20:25
Hello fellow Avisynth users,

For the past few weeks I've been using Avisynth to try and find the best (and least cpu-intensive) real-time deinterlacing method.
I've currently settled on a combination of Smart Bob Deinterlacer "SBDeint()" and BlendBob(), which gives a surprisingly sharp picture with no jaggies whatsoever.

However, it would seem that SBDeint() can't handle resolutions that aren't multiples of 16.
Here's a screengrab from a 640x478 clip:
(note the odd green line at the bottom that doesn't come from the source)
http://img43.imageshack.us/img43/7904/snapshot20090908205310.jpg

But if I crop 14 pixels from the bottom to get a multiple of 16 (640x464) before launching SBDeint():
(no more green line)
http://img405.imageshack.us/img405/7310/snapshot20090908205507.jpg

So here's the question:
Is there an Avisynth filter or a script that can automatically add a border to the bottom of the picture to reach the nearest multiple of 16 whenever it's necessary?
(some kind of sophisticated AddBorders() function perhaps?)

Or can you guys think of a better way?
I really like this SBDeint() thing. Hope there's a way so I can use it on all my interlaced videos.

Thanks in advance. :thanks:

leon1789
8th September 2009, 20:53
So here's the question:
Is there an Avisynth filter or a script that can automatically add a border to the bottom of the picture to reach the nearest multiple of 16 whenever it's necessary?
(some kind of sophisticated AddBorders() function perhaps?)

Only to the bottom ? try this

# source is the video

h = source.height
h2 = ceil(h/16.)*16
dh = h2-h
source.addborders(0,0,0,dh) # add border to the bottom


But if you want something more general (process on height and/or width) and add black borders to 0/2/4 borders of the picture, try this

# source is the video

w = source.width
h = source.height
w2 = ceil(w/16.)*16
h2 = ceil(h/16.)*16
dw = w2-w
dh = h2-h
source.addborders(dw/2,dh/2,dw-dw/2,dh-dh/2)


Enjoy :)

Thomas2681
8th September 2009, 21:37
Yeah, I only want to add a border to the bottom for fear that adding one at the top might screw up the field order or something.
*Complete noob here*

Anyway, your first script works like a charm.
Can't believe how simple that was.
*Feels both stupid and grateful*

Merci beaucoup for the quick and efficient response. :)

leon1789
8th September 2009, 21:50
Merci beaucoup [...] :)
:D De rien, ce fut un plaisir

(you're welcome, it was a pleasure)