View Full Version : New fast DeBanding filter
Soulhunter
14th March 2006, 22:14
GradFun2db: A new fast debanding filter made for realtime post-processing...
Source:
http://img20.imageshack.us/img20/5271/banding1zp.png
Filtered:
http://img20.imageshack.us/img20/9710/filtered6rv.png
-> The binary... (http://kosmos.kawaii-shoujo.net/gradfun2db/gradfun2db-v1.0.zip)
Please post feedback regarding its debanding abilitys and speed!
Tia n' Bye
Fizick
15th March 2006, 06:04
what is banding? Abrupt level gradation instead of smooth transition?
MfA
15th March 2006, 06:26
Had to turn up my brightness to max to even see it in that image.
HOLiC
15th March 2006, 07:07
wow, the filtered image looks great! But do we just use like this, gradfun2db()? anyway, this is how I used in my script ^^.. I can't wait to see the result.
foxyshadis
15th March 2006, 09:40
It seems that show has become the poster child of painful banding, hasn't it? :p Thanks! I'll test as soon as I crank through my next filter session, too busy atm.
Soulhunter
15th March 2006, 15:07
@ Fizick
No banding:
http://img124.imageshack.us/img124/9458/source24az.th.png (http://img124.imageshack.us/img124/9458/source24az.png)
Strong banding:
http://img124.imageshack.us/img124/3313/broken21db.th.png (http://img124.imageshack.us/img124/3313/broken21db.png)
@ HOLiC
Nooo! As I wrote in my first post, this filter is meant for post-processing... If you use it for pre-processing, the encoder will destroy most of the fine gradients again (well, except if you'd use a "all 8" CQM at fixed Quantizer 1, lol). So, simply put this filter in ffdshows AviSynth section and use it while playback!
@ MfA
If you watch it in fullscreen (or with a black background) its much more visible... ;)
@ foxyshadis
Thx! :)
Bye
Daodan
15th March 2006, 15:49
I'll check it also. I hope that 'fast' is not a misleading name, considering your last filter.:thanks:
Soulhunter
15th March 2006, 16:01
Not mine! But anyway, I guess the fps will please ya... ^^
Bye
Zarxrax
15th March 2006, 20:44
This is a nice filter. How does it work?
Soulhunter
15th March 2006, 21:56
Uhm, it averages gradients to increase bitdepth...
Bye
Soulhunter
15th March 2006, 22:41
Update: Optimized version by Manao + Source... (http://www.sendspace.com/file/59n0t4) ^^
Bye
Manao
15th March 2006, 23:05
I didn't actually optimized it. I cleaned it up to make it portable, and speed was increased in the process.
guada 2
15th March 2006, 23:07
Hello Soulhunter and Manao, :)
Is it efficient on all types of scenes?
What are the privileged sources?
HOLiC
15th March 2006, 23:17
Nooo! As I wrote in my first post, this filter is meant for post-processing... If you use it for pre-processing, the encoder will destroy most of the fine gradients again (well, except if you'd use a "all 8" CQM at fixed Quantizer 1, lol). So, simply put this filter in ffdshows AviSynth section and use it while playback!
Oopse.. ○=_=○ 13hr encoding time loss for not paying attention..(hehe) Thanks for the great filter!!
Soulhunter
15th March 2006, 23:31
@ guada 2
It should work for nearly all stuff that contains banding!
So far I tested it with 1 anime and 2 movies...
Bye
foxyshadis
15th March 2006, 23:44
If it's so bad that it's like Ergo Proxy, pre-encoding could help, otherwise you have to use a high-bitrate matrix or add a little ripple/noise to low-contrast areas. Having a highspeed playback filter makes that less important though. =D
Dreassica
16th March 2006, 00:24
Care to upload it to a host that doesn't give me a "too many users downloading" msg every time?
Soulhunter
16th March 2006, 00:54
1 (http://www.sendspace.com/file/jmz09j) <(^^<)
(>^^)> 2 (http://www.sendspace.com/file/ydexo4)
3 (http://www.sendspace.com/file/sa7dc7) <(^^<)
(>^^)> 4 (http://www.sendspace.com/file/xc4wwp)
5 (http://www.sendspace.com/file/9eejzp) <(^^<)
Bye
dbzgundam
16th March 2006, 00:59
Holy crap!
This actually is JUST the filter I've been looking for! :D Great work, Soulhunter, and it's fast too (a great change from Broadsword...).
Didée
16th March 2006, 01:19
>> Great work, Soulhunter
The summoner's fate ... the news are good, he gets praised ... the news are bad, he looses a head.
What a luck it's a good filter ... :D
___
Anyone else could imagine this one becoming a built-in into ffdshow?
Could also have a positive effect on blocking, possibly. Depending on how things are done, DB perhaps should be adjustable. (?)
Soulhunter
16th March 2006, 01:43
@ dbzgundam
Thanks! But Im not the author, I just posts for him... :)
@ Didée
Already wrote a requested to milan... ;)
Bye
DeathWolf
16th March 2006, 07:27
for those that need an alternate url for the 1.0(since sendspace is inneficient):
gradfun2db-v1.0.zip (http://kosmos.kawaii-shoujo.net/gradfun2db/gradfun2db-v1.0.zip)
Scarfac3
18th March 2006, 16:41
Thanks DeathWolf ^^
Inc
19th March 2006, 02:50
I also know this banding fiasko from Photoshop.
Exactly on those smooth gradients where Image contrast/saturation manipulations where done on 8bit/channel RGB images instead on 16bit/channel.
So if you want to also use it as preprocessor, after the postprocessing do apply a "minimal" touch of noise spray on such areas. Thats why in Photoshop in the gradient tool the option "dither" exists.
mla0
28th March 2006, 01:53
is there a documentation for this? or at least something that would tell the required things for this filter to work?
DeathWolf
28th March 2006, 02:34
is there a documentation for this? or at least something that would tell the required things for this filter to work?
It's made to be used in the avisynth section of ffdshow.
Go in there and just write grad2funb() after placing the filter in the avisynth plugins directory and it should auto-apply.
Technically you could use it normally in avisynth too but the effects get cancelled by any typical compressions. It's made to be used when viewing(and is optimized for speed in that optic)
Alain2
28th March 2006, 10:52
Technically you could use it normally in avisynth too but the effects get cancelled by any typical compressions.
Is this for sure? (Meaning is the effect completely canceled when encoding in yv12 in x264 for instance?)
Foxyshadis said in his thread we could replace the last addgrain of his deband script with this GradFun2db...
Soulhunter
28th March 2006, 11:12
Is this for sure? (Meaning is the effect completely canceled when encoding in yv12 in x264 for instance?)
Yes, quantization (destroys the fine +/-1 differences) + in-loop filtering (smoothing) = banding!
Bye
foxyshadis
28th March 2006, 11:46
It's only for high bitrate matrices, where such fine details would be kept, not for normal compression where it gets eaten for lunch. It makes some noticeable difference at mid-high bitrates but it's not really good until exorborantly high. Or at playback, of course. (At the time I thought it was more of a dither+grain filter, but it's dither-only.) Since I'm not working on that show now, I haven't had the incentive to improve the last step of the filter (which I think is quite suboptimal).
Really, YV16/YV24 is the only way to truly remove visible banding in encodes. (If lavc could decode to YV24 and convert straight to RGB that would be awesome.)
CruNcher
29th March 2006, 01:41
Something is strange it looks like the filter misses regions of the right and left side btw overused you get a really nice (Dream Effect) :)
Didée
29th March 2006, 08:10
True. Try gradfun2db(str=255) to "see" how&where it processes, and where not. ;)
Soulhunter
29th March 2006, 08:46
Yeah, it leaves a 16pix border on each side... :\
Bye
Mug Funky
29th March 2006, 09:28
quick and hacky workaround (hope you like black edges)
function gradfunk (clip c, float "strength")
{
strength=default(strength,1.2)
c.addborders(16,16,16,16)
gradfun2db(strength)
crop(16,16,-16,-16)
}
btw, this is a very fast filter. perhaps it could form the basis of a rewrite of spatialsoften, which is very very slow in comparison.
[edit]
strength is a float, not an int. d'oh
mimage
29th March 2006, 23:11
Thanks a bunch for this filter! It is so awesome and is very helpful for me. :D
I hope it's ok to ask here.. is there any filter like this for Vdub?
Jeremy Duncan
30th March 2006, 04:37
I tried it a few days ago, and my Celeron M 1.4 Ghz Notebook could not play it without stutter. And I saw a bit of banding still. If only it could be optimized to play on my Notebook.
Jeremy Duncan
30th March 2006, 04:39
{
strength=default(strength,1.2)
c.addborders(16,16,16,16)
gradfun2db(strength)
crop(16,16,-16,-16)
}[/code]
Is this added to the .dll, or in the avisynth section of ffdshow ?
Mug Funky
30th March 2006, 05:21
it goes in your avs script, then you call "gradfunk" instead of "gradfun2b".
actually, it just occured to me that that workaround will not do anything unless you have a very dark frame.
reason - the black on the edges gets blurred exactly 16 pixels, making the first 16 pixels very likely to be over the threshold, and not used. you can confirm this by using it on some grainy footage with a high threshold.
i think edge mirror-ing will make it a lot better, but that might just slow it down such that it's not as useful.
Jeremy Duncan
11th April 2006, 11:43
it goes in your avs script, then you call "gradfunk" instead of "gradfun2b".
Can somebody Please post the notepad script with the changes Mug Funky made.
I want to copy and paste it into a notepad file called gradfunk.avs
:thanks:
DeathWolf
11th April 2006, 13:23
http://kosmos.kawaii-shoujo.net/gradfunk.avsi
there you go
the function to use with mirroring is: gradfunkmirror
Jeremy Duncan
11th April 2006, 14:25
http://kosmos.kawaii-shoujo.net/gradfunk.avsi
there you go
the function to use with mirroring is: gradfunkmirror
This is what I'm doing. I'm putting this in FFDShow:
Import("G:\Program Files\AviSynth 2.5\plugins\gradfunkmirror.avs")
And opening Media Player Classic to play X-men 2.
As soon as I open Media player Classic and open the dvd, it closes.
And I doing it right ?
:thanks:
foxyshadis
11th April 2006, 15:05
You don't need this filter for DVDs. Or at least, I've never seen a DVD without some film grain, and almost always lots of it, and it slows playback WAY down.
As for why it crashes, it's really hard to say since there's no error message.
Alain2
11th April 2006, 23:34
Corrected version:
Function gradfunkmirror( clip c, int "strength" )
{
strength = default( strength, 1.2 )
w = c.width()
h = c.height()
vflip = c.FlipVertical()
hflip = c.FlipHorizontal()
stackhorizontal( hflip.crop( w-16, 0, 16, h ).addborders( 0, 16, 0, 16 ),
\ stackvertical( vflip.crop( 0, h-16, w, 16 ), c, vflip.crop( 0, 0, w, 16 ) ),
\ hflip.crop( 0, 0, 16, h ).addborders( 0, 16, 0, 16 ) )
gradfun2db( strength )
crop( 16, 16, -16, -16 )
Return last
}
It does work realtime on my computer (xp3700+), but takes a bit more cpu (mpc+gradfun2db = ~13%, mpc+gradfunkmirror=~25%)
DeathWolf
11th April 2006, 23:52
isnt that the same though?
it does look proper on my original script iirc
from h-16 to 0 or starting from h-16 with a 16 offset is the same
at least it was in the quick test i just did
Alain2
12th April 2006, 01:55
I think you should have put -0 if you wanted to get the same than (h-16)->+16, but i may be wrong
Jeremy Duncan
12th April 2006, 03:04
##Standard gradfunk
function gradfunk(clip c, int strength) {
strength=default(strength,1.2)
return c.addborders(16,16,16,16).gradfun2db(strength).crop(16,16,-16,-16)
}
##Corners will be ignored
function gradfunkmirror(clip c, int strength) {
strength=default(strength,1.2)
vflip = c.FlipVertical()
hflip = c.FlipHorizontal()
return stackhorizontal(hflip.crop(c.width-16,0,16,c.height).addborders(0,16,0,16),stackvertical(vflip.crop(0,c.height-16,c.width,16),c,vflip.crop(0,0,c.width,16)),hflip.crop(0,0,16,c.height).addborders(0,16,0,16)).gradfun2db(strength).crop(16,16,-16,-16)
}
http://img81.imageshack.us/img81/8438/15yd2.jpg
Above the picture is what I'm using.
The picture shows the problem I'm having.
It also shows my ffdshow avisynth setting, and the file.
What am I doing wrong ?
Jeremy Duncan
12th April 2006, 03:11
I think you should have put -0 if you wanted to get the same than (h-16)->+16, but i may be wrong
Are you talking about here ?
(vflip.crop(0,c.height-16,c.width,16)
Xicor
12th April 2006, 16:08
Your script might be called "script.avs.txt" instead of the correct "script.avs".
Alain2
12th April 2006, 22:57
Are you talking about here ?
(vflip.crop(0,c.height-16,c.width,16)
The function you posted is incorporating the correction I made, but original DeathWolf's function contains:
vflip.crop(0,c.height-16,c.width,0)
It is this zero I was talking about.
Oh btw in the function you have you started with
function gradfunkmirror(clip c, int strength)
but then in ffdshow you don't specify a strength... You should write the header as i did (Function gradfunkmirror( clip c, int "strength" )) if you want to be able to omit the strength parameter when calling the function
Jeremy Duncan
13th April 2006, 03:27
http://img153.imageshack.us/img153/6940/16cs1.jpg
Same script I posted before with the other picture.
Jeremy Duncan
13th April 2006, 03:30
Here's my setup so you can try it.
http://www.avsforum.com/avs-vb/showthread.php?p=7476913#post7476913
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.