Log in

View Full Version : Macroblocks settings in X264


DoomNoob
25th May 2006, 02:54
Hi, everyone ;) I have a very simple question to ask:
Is it possible to force the use of 8x8 (or 4x4) macroblocks in X264 ?

I explain: I am very sensitive to macroblocks artefacts ... it has reached the point where it has become an obsession ;)

why ? because no matter if there is really or not macroblocks artefacts in the encoded movie sooner or later your screen resolution will increase & macroblocks will appear naturally with upsampling extrapolation, for example if you watch a 800x600 video at 1600x1200 a single pixel become a 4x4 macroblock & at 3200x2400 a single pixel becomes ... a 8x8 macroblock ...

I know a 3200x2400 video is unrealistic actually but for numeric photo or scans these resolutions are very real ... so in the end it's just a matter of time before the 4ghz CPU & paramagnetic HD limits explodes ... let's say 5 to 10 years.

As a result of this, so far I only used TIFF/PNG/RAW or JPEG 100% or 95% for image because there is no visible macroblocks in these settings & Xvid vfw Unrestricted (Default) Quantizer 2 because this was the nearest thing to jpeg 95% I could find in video.

As I come from the scanning/photo world, I have the bad habbit of always taking screenshots in my video & see if I can find macroblocks to judge the codec ... with Xvid the result is very close to jpeg at maximum zoom it's either there is obvious blocks or not ... but with X264, with beblocking filter turned off, it's a pain because even with the highest quantizer (I tryed up to Quant13), x264 seem to willingly create large blocks off a single color in order to deblock them later ... no matter if the deblock option is activated or not ... so if you disable the deblocking option & zoom, it becomes really ugly ... like overcompressed jpeg ;(

for me macroblocks are like a lowpass filter in audio, pure destruction, & deblocking is like dithering, pure cheat.

so even if I understand that AVC is trying to fake wavelets via clever blocking/deblocking ... & if even if I know that it is very powerfull for low-bitrates ... I am disapointed to be actually unable to change this strategy by switching manual options for high-bitrates ...

so I need to find settings that will either:
- prevents X264 to create large blocks of color even at Xvid Quant2 equivalent bitrates (thinking it will be able to deblock it while I have disabled the deblocking option)
- force 8x8 macroblocks so that I can rise the quantizer until I don't see these blocks (like I do with jpeg/xvid)

I tryed playing with vfw & megui "partition" & "macroblock" options but it doesn't seem to be what I am looking for ...

I am starting to think that AVC is like AAC-HE ... useless for high bitrate qualitywise & that it don't worth the huge horsepower increase ... I recall I heard a news of a company releasing HD content in mpeg2 ... finally it was not as stupid as it first seems ... well maybe HD mpeg4-ASP Quant1 would have done the trick better then mpeg2 but the logic is here ... for high bitrates it's better to have a codec which block proportionnaly to bitrate than a codecs which always blocks ... even cleverly ... in order to deblock later ... because a block of a single color is still a block no matter if its edges are blurred ... all the natural noise is lost ...

Hoping someone can help the complete video noob I am ... see ya' all

foxyshadis
25th May 2006, 03:34
To force 4x4 only: Turn off Adaptive DCT (megui) or take out --8x8dct. You lose a lot of compression efficiency though; ringing, blurring, and 4x4 blocking will all go slightly up.

For high-res upsampling, well, bilinear looks like crap, but it isn't quite point sampling. It has totally different artifacts that look more like blocks with extreme deblocking applied. 4x already has severe stairstepping in bilinear, bicubic, and lanczos (lessening for each), and only looks decent with spline, but could only ever look good with a jensen-xin-li (like EEDI2) with or without DDL, or a fractal-edge, which are all major cpu hogs. Let alone 8x. You just have to hope the artifacts from bilinear/bicubic aren't so noticeable at 300 dpi. But that's fine, because if you really want to print a screenshot you can use the killer tools offline and take your 5 minutes to resize one screen. (Also, may I recommend Alien Skin Image Doctor as the best Jpeg repair filter for photoshop.)

x264 requires deblock. I mean, it's integrated into the encoding and decoding process, so there is no way to remove it on decoding and still have a compliant output. So the output you get with deblock is the output. The AVC deblock algorithm was developed with a lot of psychovisual data, but it does switch off around q10-14, if you want to keep it up above that. Disabling inloop just eliminates a primary advantage over ASP, and the better quant scale and references probably don't make up for it.

If blocking bothers you to the point that you can't watch a video with it and philosophically will not turn on deblocking, it's time to switch to a non-DCT based codec, such as Dirac, or simply use lossless. Of course your sizes balloon anyway. The only way to stop blocking in DCT based codecs is huge bitrates and (pre-AVC) specialized matrices.

Manao
25th May 2006, 06:10
it's a pain because even with the highest quantizer (I tryed up to Quant13), x264 seem to willingly create large blocks off a single color in order to deblock them laterJust to be sure. You did mean "lowest" instead of "highest", didn't you ? The lower the quantizer, the higher the quality.
but it does switch off around q10-14Actually, it switches off at q15 with a strength of 0 ( q21 if the strength is -6, q9 if the strength is 6 ).
So the output you get with deblock is the outputTechnically, nothing prevents you from decoding the picture, showing it, and only then deblocking it for future prediction. That way, you still get the coding efficiency but not the deblocked look that some don't like.
You lose a lot of compression efficiency though; ringing, blurring, and 4x4 blocking will all go slightly up.Actually, ringing is mostly caused by the 8x8 dct. The 4x4 one hardly rings.

DoomNoob : can you show us a screenshot of what you call blocking ? what is your source ( mpeg2 ? sth else ? ), and can you post a screenshot of the source too ? Why don't you want to use deblocking ? And why, if you don't use it, do you complain about blocks ?

akupenguin
25th May 2006, 08:01
Actually, it switches off at q15 with a strength of 0 ( q21 if the strength is -6, q9 if the strength is 6 ).
Nitpick: offset is *2. So strength +6 => q3, strength -6 => q27.

imcold
25th May 2006, 18:54
Ringing in h.264 is reduced by using intra spatial prediction too, isn't it? In my logic, if the block with edge can be good predicted, only low frequency or zero residual remains -> less and lower DCT coefficients - so much less or no ringing effect occurs. Correct me if I'm wrong, please ;) .

bond
25th May 2006, 19:10
--no-fast-pskip ;)

imcold
25th May 2006, 19:14
I don't seem to get your point XD

Manao
25th May 2006, 19:22
Ringing isn't due to abusive skipping. On the contrary. Ringing happens when you quantize too much, while skips don't have coefficients, hence no quantization to speak of.

In any case, any way to improve the prediction and hence reducing the energy contained in the residual will reduce the ringing. So additionnal predictions such as intra prediction is always welcomed. But a motion vector matching the same edge on the previous edge would be as efficient, provided the match was correct.

DoomNoob
25th May 2006, 22:51
Thanks all for quick anwsers ;)

I have done some further personnal tests which have led me to think that I was wrong trying get the same quality as jpeg 95% with x264 ... I realized it when I transcoded an 1080p apple AVC trailer to Xvid Quant1 & noticed I was still getting AVC large color block artefact with ASP wich was anormal ... the conclusion was clear: transcoding AVC to ASP is useless no matter the bitrate ... unlike mpeg2 to ASP ... artefacts are really differents between ASP & AVC ... AVC with deblocking produce artefacts closer to JPEG200 than jpeg ... so AVC to ASP is really not a good idea as you get the worst of both world ... specially with deblocking turned off ...

I am new to video as I never backed-up any DVD because I always considered the resolution was much too low ... with HD I recently get interested as video was suddenly catching the gap with photo & scan ... but due to my image experience I did weird calculation like 1280x720 photo is transparent at jpeg 95% which give around 300ko by frame ... so 300ko x 24fr/s =~7200Kbps for full DTC video transparency ... this kind of calculation works great with xvid as you fall right in between Quant1 & Quant2 ... but it cannot be really expanded to X264 as even if X264 is DCT ... it's both jpeg 50% & 95% on the same frame depending on how x264 judge the "psychovisual" interest of each part ...

my first tests were leading me to think that x264 was useless for HD as it didn't bring any quality improvements at high bitrate over ASP while it was much greedier to decode ... but I was forgetting a major criteria ... HD contents will be coded natively to AVC which make Xvid & ASP useless as they add their own artefacts to the AVC ones ...

I was wrong because HD-DVD & Blue-Ray will natively be AVC (or VC1) ... like it or not (I don't) you cannot use Xvid anymore with HD ... I don't like the huge hardware requirement of AVC but I just understund that I cannot avoid it if I want to optimize my encodes from AVC source ... damn ... now I must rebuy a complete PC with a geforce7 for H264 decoding speed up just for AVC & HD & I really really don't like that !!! It would not be the case if HD-DVD & Blue Ray would be using ASP & VC1 only !!! I suddenly really feel fucked by manufacturers ;( ;( ;(

indeed native AVC artefacts in the source makes forcing 8x8 or turning off deblocking to fake Xvid/jpeg with X264 completly useless ... I will most likely use X264 equivalent to Xvid Q2 now which seems ,at first sight, to be X264 Q18 ...

Thanks again for trying to help
DoomNoob, Newly "Converted Against its Own Will" X264 User ...

nm
26th May 2006, 16:29
now I must rebuy a complete PC with a geforce7 for H264 decoding speed up just for AVC & HD & I really really don't like that !!! It would not be the case if HD-DVD & Blue Ray would be using ASP & VC1 only !!! I suddenly really feel fucked by manufacturers ;( ;( ;(
You could get CoreAVC instead of that GeForce 7 or wait for other software decoders to catch up. Will be a bit cheaper ;)

imcold
26th May 2006, 16:48
Decoding AVC clip from apple's trailer page with CoreAVC is only slightly slower than decoding ASP file created by its reencoding with ffdshow on my box, so imho ASP wouldn't be that much of a win.