Log in

View Full Version : Debanding filter for encoding


wyti
28th August 2008, 13:53
Hello i'm searching a Debanding filtrer for avisynth that is optimized for encoding (ideally that regenerate the gradiant and not use dithering).
I'm sorry if this post already exit, i searched a bit and the only thing i foud is gradfun2db wich use dithering and isn't very good for encoding (only good for playback)

Mystery Keeper
28th August 2008, 14:55
I came up with an idea, but I don't even know if it would do any good.

1) Remember the clip
2) Apply gradfunk
3) Extract the difference
4) Blur it
5) Reapply to original clip

Would that work?

wyti
28th August 2008, 16:01
Maybe, but how can i extract the differences between 2 clip ?

Didée
28th August 2008, 16:09
Now, that's easy enough to try.

# 1) Remember the clip
source = last

# 2) Apply gradfunk
deband = source.gradfunk(whataretheparameters)

# 3) Extract the difference
diff = mt_makediff( source, deband )

# 4) Blur it
diff_blur = diff.blur(1.0) # 0.0~1.58

# 5) Reapply to original clip
result = source.mt_makediff(diff_blur,U=2,V=2)

return( result )

Graduation Question: Explain why the result is so unpleasing! :D


@ wyti:

AFAIK GradFun2db is the only debanding filter for Avisynth, so you'll probably have a hard time to find another one.;) - Exept for the old-school solution of using a generic noise generator, of course, and just throw noise at the source.

BTW, "regenerate the gradiant and not use dithering" is hardly possible ... usually, banding is not a defect that could be repaired. It's an insufficience of the data format. 8-bit colorspaces (like used in Avisynth) can not reproduce gradients cleanly enough (YUV colorspaces in particular), and the only way to "hide" this insufficience is to hide it with noise. Note that the process of "dithering" does nothing else but adding noise, too. It might use more content-adaptive methods than a generic noise generator, but still, dithering=noise.

burfadel
28th August 2008, 18:36
Even though gradfun2db is suppose to be a decoder side avisynth filter, wouldn't it still be advantageous for encoding? If there is banding in the source, and gradfun2db removes it, wouldn't that be better? whats the point of the encoder encoding the banding?! With the quality that x264 etc produces it would be better not having it banded to start with, right?

Dark Shikari
28th August 2008, 19:22
Even though gradfun2db is suppose to be a decoder side avisynth filter, wouldn't it still be advantageous for encoding? If there is banding in the source, and gradfun2db removes it, wouldn't that be better? whats the point of the encoder encoding the banding?! With the quality that x264 etc produces it would be better not having it banded to start with, right?Most encoders will completely decimate the dither, meaning gradfun2db will do nothing. x264 with AQ and psy-RD is an exception to this rule.

burfadel
28th August 2008, 19:49
Thats put a bit better :) No point AQ in x264 etc wasting bandwidth encoding pre-existing banding! (with aq in x264 it may be even beneficial to have a fast debanding filter as an option...?)

Dark Shikari
28th August 2008, 22:38
Thats put a bit better :) No point AQ in x264 etc wasting bandwidth encoding pre-existing banding! (with aq in x264 it may be even beneficial to have a fast debanding filter as an option...?)"Encoding banding" takes nearly no bits--its the dither that *removes* the banding that costs lots of bits to encode.

Adub
28th August 2008, 23:20
I must say, that with a proper combination of AQ and PsyRD it really works wonders when combined with gradfunkmirror.

I just ran a few tests and am really impressed. Of course, I turned the strengths way down from default. setting aq to 0.5-0.8 and psyrdo 0.5-0.8 works brilliantly. 0.5 for both is usually pretty safe, but if you tweak within the constraints I mentioned you can tune to each source quite well.

Note: This was with an anime source, not "real" footage. I haven't tested nor seen excessive banding in the "real" footage I am dealing with currently, so I can't comment.

burfadel
29th August 2008, 03:57
"Encoding banding" takes nearly no bits--its the dither that *removes* the banding that costs lots of bits to encode.

Thats true, I meant more from a quality standpoint :) I did some testing a while back and it didn't make much difference to the final file size in crf mode (actually it made it less in some cases) while making it look better. I guess it depends exactly how bad the banding is and whether its just banding or a combination of banding and other encoding artifacts...