PDA

View Full Version : Flickering Blocking in Background Areas of Dark Gradients


CarlEdman
8th February 2010, 18:34
I have been using x264 to encode DVDs for a couple of years now and have finally settled on a set of parameters/scripts:

x264 --tune [animation or film] --preset slower --crf 19.0 --sar [e.g., 32:27] --fps [e.g., 23.976023976024] --profile high --level 3.1

SetMTMode(2,0)
DGDecode_mpeg2source("FUBAR.d2v", info=3, idct=3, cpu=6)
ColorMatrix(d2v="FUBAR.d2v", interlaced=true)
tfm().tdecimate(hybrid=1) # Or TomsMoComp for Interlaced Sources
autocrop(threshold=30,wMultOf=4, hMultOf=2,samples=51, mode=0) # crop(left,top,-right,-bottom)
Interleaved2Planar()
super = MSuper(planar=true)
bv1 = MAnalyse(super, isb = true, delta = 1, overlap=4)
fv1 = MAnalyse(super, isb = false, delta = 1, overlap=4)
bv2 = MAnalyse(super, isb = true, delta = 2, overlap=4)
fv2 = MAnalyse(super, isb = false, delta = 2, overlap=4)
bv3 = MAnalyse(super, isb = true, delta = 3, overlap=4)
fv3 = MAnalyse(super, isb = false, delta = 3, overlap=4)
MDegrain3(super,bv1,fv1,bv2,fv2,bv3,fv3,thSAD=400,planar=true)
Planar2Interleaved()
Distributor()


This results (for me) in reasonable file size and better-than-original-DVD image quality played on large 1080p plasmas.
Almost all the rest can be handled with minimal and rare tweaking (e.g., lower CRF for unusually clean sources, higher CRF for unusually noisy sources, etc.). With only minor adjustments, this has served me well for hundreds of x264 versions (x86 and x64) through most recently r1414.

So what am I complaining about? One particular type of artifact I just can't seem to get a handle on: In dark backgrounds with small gradients, it looks like whole macroblocks are coded with one of a small number of dark shades of gray. This results in sharp edges between macroblocks, where there should be gentle gradients. What is worse, blocks on the edge between two gray shades, jump between them from frame to frame, resulting in square blocks of image visibly flickering.

This happens with all displays and decoding software/hardware I've used.

Is there anything which can be done about this? I don't care about the details in those areas--blurry gradients which don't visibly pop would be just fine.

Thanks in advance.:thanks:

Dark Shikari
8th February 2010, 20:09
blocks on the edge between two gray shadesThat's because it is jumping between two shades, since there's nothing in between. As things are, you can't have a pixel of brightness 14.7, so the encoder has to use 14 or 15. This is completely unavoidable and cannot be solved in an 8-bit colorspace. It, however, can be covered up, by doing one of the following:

1) Adding dither prior to encoding and using settings designed to retain dither (psy trellis, no dct decimate, strong AQ, low CRF, qpmin 0)
2) Adding dither during playback (using gradfun2db aka FFDshow deband)
3) Adding grain prior to encoding (using AddGrain or similar)
4) Properly calibrating your monitor's gamma

CarlEdman
8th February 2010, 21:18
Thanks for the quick and authoritative answer to this question, Dark Shikari!:thanks:

Unfortunately, as you probably guessed from my filters, I am very much in the anti-grain camp. In experiments, it is hell on compression and makes the resulting output actually look worse than without it (the latter is of course a subjective judgment and I'll gladly concede that there are many fine people with the opposite view).

I'm a little surprised that the standard decoders don't automatically dither blocks when constrained by the bit-depth of the output buffer, but as long as this is something sufficiently good renderers can fix, I'm willing to live with the occasional blockiness until the decoder software gets there.

Dark Shikari
8th February 2010, 21:24
I'm a little surprised that the standard decoders don't automatically dither blocks when constrained by the bit-depth of the output bufferBecause it's not part of the spec, and the decoder has to do exactly what the spec says.

Checking the "deband" box in FFDshow will probably do what you want. You can also "fix" it by adding very weak grain on playback--weak enough that it's hardly noticeable, but it will serve to dither dark areas.