View Full Version : New FillMargins() filter
trbarry
2nd April 2003, 21:51
I just released a little quick and dirty filter for Avisynth 2.5 that will fill the margins of a clip without having to change the dimensions. Sometimes you have a few pixels of black border or garbage at the edge of the screen and you don't want to crop because you need a multiple of 16 or whatever. My local ABC station has recently been like this. But this looks ugly and doesn't compress well.
The FillMargins(left, top, right, bottom) filter will fill in these margins with the contents of the outer edges of the unfilled area. It's for Avisynth 2.5 YV12 only but doesn't require any special processor, or any numeric multiples. See:
www.trbarry.com/Readme_FillMargins.txt and
www.trbarry.com/FillMargins.zip (source & dll)
This is pretty fast already but will probably go more than 10x faster once Avisynth is fixed so MakeWriteable doesn't need to copy the entire buffer each time.
BTW, FillMargins may likely be a poor mans version of Simon Walters more versatile BorderControl. But I didn't know about that one until I was half done, so I finished it anyway. Mines just a simple one function filter.
Please post any bugs.
- Tom
sh0dan
2nd April 2003, 23:27
There is probably something I don't get, but what does this filter do, that LetterBox() doesn't?
The MMX optimizations sound nice though.
Btw, MakeWritable doesn't copy data since some time before 2.5.1 - so if your frame isn't referenced anywhere else it is simply returned as is.
trbarry
2nd April 2003, 23:55
There is probably something I don't get, but what does this filter do, that LetterBox() doesn't?
The MMX optimizations sound nice though.
Sh0dan -
I have no idea. ;)
I never heard of LetterBox, or BorderControl, before yestterday. I just had some garbage on the edge of my image so I wrote an mmx filter for it. This is actually why I was asking about MakeWriteable a couple months ago but sometimes it takes awhile before I get around to stuff.
Two months of procrastinating and about 2 hours of coding. :o
- Tom
sh0dan
2nd April 2003, 23:56
:) ok! Just thought I was missing something :)
trbarry
2nd April 2003, 23:59
Sh0dan -
Actually I just looked up Letterbox and it is different. Letterbox puts in a solid border of some color, default zero.
FillMargins extends the pixel color of the extended edge so it may compress better and you can't see the border if it's not very large.
- Tom
edit: Like this
LetterBox:
00000
0abc0
0def0
00000
FillMargins:
aabcc
aabcc
ddeff
ddeff
sh0dan
3rd April 2003, 00:01
oh - there was something I was missing - good to know! :D
seewen
3rd April 2003, 00:47
In the HelpFile it's written :
FillMargins(left, top, right, bottom)
But it seems to be :
FillMargins(NOTHING, top, LEFT, bottom)
Bye
P.S.
It works great for little black borders.. ;)
trbarry
3rd April 2003, 06:20
But it seems to be :
FillMargins(NOTHING, top, LEFT, bottom)
seewen -
Thanks for pointing that out.
Everybody please download v 1.0.1 which features a free cure for dyslexic input parms. ;)
Same loc: www.trbarry.com/FillMargins.zip .
- Tom
seewen
3rd April 2003, 13:44
It works much better now ;)
Shayne
4th April 2003, 14:51
Why just yv12 color space i capture in YUY2?
Would be nice not to have to convert back and forth so much and my capture card has the same black bands as you mention,
Thanks for all ur work and great filters
PS I would love to see all your filters posted to a web page so we could check if we are up to date and whats new.
Peace
trbarry
4th April 2003, 19:26
"Why just yv12 color space i capture in YUY2?"
Shayne -
This was just a quick & dirty, and I was lazy (selfish) since I use almost all YV12 now. I guess if there was any real demand I could pretty easily do a YUY2 version.
But check out BorderControl(). I believe it can do the same thing with the right parms and was first designed for VHS caps so it might even be better suited for what you are doing.
- Tom
Shayne
5th April 2003, 05:59
I never really looked at addbourders before but i see how it can helpful when multiples of 8 are required to crop to move black boulders around.
Maybe i misunderstood but i thought FillMargins does not move the frame around but fills black borders by interp or distortion.
trbarry
5th April 2003, 08:10
I was recommending BorderControl, not AddBorders.
FillMargins just fills the margins by taking the outer most pixel (that is not in the margin) and using that as a fill color from there to the edge.
If you were to use AddBorders it's likely the entire frame would have to be copied to a new larger locatation. FillMargins can leave the frame where it is and just fill in the small margins, much faster.
- Tom
@Shayne
BorderControl is another plugin available here (http://www.geocities.com/siwalters_uk/bdrcntrl.html)
regards
Simon
sh0dan
24th April 2003, 14:14
When using "FillMargins(0,0,2,0)" I get a green pixel topleft - seems like a bug. Also it seems like there is garbage on the left side (even when converting to RGB before output).
Edit: Using: int Roffs = (fRightW)
? row_size - fRightW -1
: 0;
Seems to solve it (-1 inserted)
trbarry
24th April 2003, 16:22
Arrrrrg! My life has been plagued by OBO errors. :(
But I think you are correct.
- Tom
wotef
29th April 2003, 18:46
just what i needed for a cap i did last night!
but i seemed to get better results, specifically, a less conspicuous border result with bordercontrol's "smear", than with fillmargin's method
Forteen88
6th March 2011, 17:31
Thanks, but I wonder, is there a FillMargins for x64?
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.