PDA

View Full Version : Extend borders to mod8 (not addborders)


foxyshadis
1st March 2006, 10:39
Meant to ask this a while ago but slipped my mind. A lot of filters need mod8 or mod16, but I realllly don't want to crop anymore, while at the same time running fft3dfilter on a block that's half black from addborders is bound to hurt whatever's in it. I know x264 and xvi extend the last pixel out to mod16, I was wondering if there was a filter that would do that for me in avisynth?

If I missed an obvious filter, sorry about that.

hanfrunz
1st March 2006, 11:18
Meant to ask this a while ago but slipped my mind. A lot of filters need mod8 or mod16, but I realllly don't want to crop anymore, while at the same time running fft3dfilter on a block that's half black from addborders is bound to hurt whatever's in it. I know x264 and xvi extend the last pixel out to mod16, I was wondering if there was a filter that would do that for me in avisynth?

If I missed an obvious filter, sorry about that.

try this script:


border=10
video=avisource("filename.avi").converttorgb32()
row_right=video.crop(video.Width-1,0,0,video.height).pointresize(border,video.height)
stackhorizontal(video,row_right)

Didée
1st March 2006, 12:41
Nice, except for the forced colorspace conversion. :|

foxyshadis: this comment (http://forum.doom9.org/showthread.php?p=579249#post579249) of Manao is very interesting. ;)

(This one had slipped me, too - just found it, accidentially, while searching for BorderMirror (http://forum.doom9.org/showthread.php?p=518131#post518131))

foxyshadis
1st March 2006, 12:52
Thanks for the inspiration, I made this:


function makemod(clip c,int "mod") {
mod=default(mod,16)
ox=c.width
oy=c.height
w=c.isrgb32() || c.isrgb24() ? 1 : 2
right=c.crop(ox-w,0,0,0)
right=right.stackhorizontal(right,right,right)
right=mod>8 ? right.stackhorizontal(right,right,right) : right
vx=ox % mod==0 ? c : stackhorizontal(c,right.crop(0,0,ox % mod,0))
bottom=vx.crop(0,oy-w,0,0)
bottom=bottom.stackvertical(bottom,bottom,bottom)
bottom=mod>8 ? right.stackvertical(bottom,bottom,bottom) : bottom
vy=oy % mod==0 ? vx : stackvertical(vx,bottom.crop(0,0,0,oy % mod))
return vy
}


Edit: Oh well, bad timing. Bordermirror and padding look better anyway. :p
Edit2: Padding is yv12 only, which is sort of suboptimal (needs mod4 already) for me even if it's faster. I modded Mirror to have the same semantics as mine, but I think I messed up (I'm just too tired for this right now), I'll try again tomorrow:

function makemod( clip c, int "mod") {
mod=default(mod,16)
ox=c.width
oy=c.height

bot=oy % mod==0 ? c : stackvertical(c,c.crop(0,mod-oy%mod,-0,-0).flipvertical())
right=oy % mod==0 ? bot : stackhorizontal(bot,bot.crop(mod-ox%mod,0,-0,-0).fliphorizontal())

return right
}

IanB
1st March 2006, 14:39
W=(Width()+7)/8*8 # or +15)/16*16
PointResize(W, Height(), 0, 0, W, Height())