View Full Version : How To Use Mpeg4 AVC Deblocking Effectively (Small FAQ)
*.mp4 guy
8th April 2006, 17:28
In X264 there are two deblocking parameters, called Deblocking strength and Deblocking threshold. The strength parameter refers to Alpha Deblocking, while the Threshold Parameter refers to Beta Deblocking (Alpha and Beta Deblocking are the official names). When a deblock setting is written as X:X (for instance 0:0 or 2:-2) the first number is alpha deblocking, while the second is beta deblocking.
Alpha deblocking effects the overal amount of deblocking to be applied to the picture, higher values deblock more effectively, but also destroy more detail and cause the entire image to be softened. The default value of 0 is almost always sufficient to get rid of most blocking (especialy when using a cqm), but leaves the picture noticibly blurier. In general use this value should be no lower then -3 and no higher then 3. When using a cqm the authors recomended settings should be used as the default value, and shouldn't be altered by more then +/-2. Alpha Deblocking is the most important parameter in determining the overal sharpness of your encode.
Beta Deblocking is a bit more tricky to use, Beta Deblocking determines whether something in a block is a detail or not when deblocking is aplied to it. Lower values of Beta Deblocking apply less deblocking to more flat blocks with details present (but more deblocking to blocks without details), while Higher values cause more deblocking to be applied to less flat blocks with details present. Generally Beta Deblocking shouldn't be altered unless you are haveing problems with the default setting. Raising Beta deblocking is a good way to help get rid of ringing artifacts by aplying more aggressive filtering to blocks that aren't very flat. Lowering beta Deblocking is a good way to reduce the amount of DCT blocks without bluring the entire picture. A high value of beta deblocking will cause nonflat blocks to be deblocked more aggressively, while a low value will cause the opposite.
If you wan't to give your encodes a more detailed look and don't mind the occasional block try a setting of -2:-1. If you like a clean picture and don't mind a little bluriness try 1:2. A nice trick for anime is to use lower beta deblocking setting because it won't blur out lines as much that way.
Hyper Shinchan
8th April 2006, 18:03
Thanks for the easy faq! In effect I was using in the wrong way the beta deblocking until now (I haven't ever used beta deblocking under 0 XD).
Thank you, I'll try them (the fact is that generally my AVC encodings are made at low bitrate, only occasionally I made DVD back-ups at full screen, generally are PSP videos at 200kbps max XD, so I use high values of alpha and beta deblocking).
*.mp4 guy
8th April 2006, 18:05
I'm glad I could help, I think a lot of people misunderstand how Beta Deblocking works, that was one of the main reasons why I made this FQ.
smok3
8th April 2006, 20:03
Thanks for the easy faq! In effect I was using in the wrong way the beta deblocking until now
same here :thanks:
When using a cqm the authors recomended settings should be used as the default value, and shouldn't be altered by more then +/-2.
would that mean that inloop filter (--filter) is optimized for default matric?
*.mp4 guy
8th April 2006, 20:08
Different Matrices exhibit different levels of blocking relative to the standard matrix. The inloop filter isn't optimized for the default matrix, but the strength it is set at is optimized for the default matrix.
shon3i
8th April 2006, 20:27
So *.mp4 guy what do you recommend for DVD Backups in bitrate range 600-900kbps. Thanks
*.mp4 guy
8th April 2006, 20:54
Thats a very hard question to answer. If you are using the standard matrix you are safest with the default settings. I would have to have more information about your source and the settings you are using to be able to give you a thorough answer. furthermore Deblocking is to a large extent personal preference.
shon3i
8th April 2006, 21:24
Yes i using standard matrix and currently this settings for movie "Just Friends", i am very happy with results but always must some scene looks very blockly so
x264.exe --pass 2 --bitrate 914 --stats ".stats" --ref 3 --mixed-refs --no-fast-pskip --bframes 3 --b-pyramid --b-rdo --bime --weightb --subme 6 --trellis 1 --analyse all --8x8dct --direct auto --me umh --progress --no-psnr --output "JustFriends.mkv" "JustFriends.avs"
The avs looks like this
DGDecode_mpeg2source("JustFriends.d2v")
ColorMatrix()
crop( 6, 12, -8, -10)
LanczosResize(640,352)
I try several denoisers but i don't know what denoiser is good for DVD backup.
Sirber
8th April 2006, 21:26
If I'd want 3 settings, like Low, Medium and High, for anime, what would you recommend?
*.mp4 guy
8th April 2006, 22:59
@Shon3i
Denoising should be avoided when you have problems with blocking, because it will only make things worse. I'm assuming you are having problems with blocks on gradients and flat areas as that is the most common problem. A setting of 2:-2 should get rid of most of the blocking without influencing detail to much. If your willing to use a cqm try this one (http://rapidshare.de/files/17527550/LRM-0.2.4.cfg.html) It should reduce your blocking without introducing any other problems, If you want a sharper picture you could try -2:-2 with the cqm.
@Sirber
I don't encode anime much, but I've got some general ideas that might work for you, of coarse deblocking is quite subjective...
Low- 0:3
Medium- 1:-1
High- 0:-3
Sirber
8th April 2006, 23:11
I presently use 1:1 and it seems to do a great job.
Should I set a higher Beta for "higher filtering", aka more smooting?
*.mp4 guy
8th April 2006, 23:34
Setting a higher Beta level is most helpful when You have exessive ringing or line degredation, its also usefull in removing misquito noise. So If you have a significant amount of those artifacts setting beta higher could help. When aiming for complete transparency lowering beta helps retain all the available details.
riggits
9th April 2006, 11:41
it might help some ppl to think in terms of XviD or ASP:
the alpha deblocking is kinda like your post-processing, with deblocking applied impartially over the whole frame. Then the beta deblocking is like the codec's own inbuilt smoothing algorithm which is used during compression.
or am i way off?
shon3i
9th April 2006, 11:57
*.mp4 guy Thanks, is that matrix good for my bitrate range
DarkZell666
9th April 2006, 12:28
Thx *.mp4 guy for this FAQ ;)
But I think this says it all, really :
In X264 there are two deblocking parameters, called Deblocking strength and Deblocking threshold. The strength parameter refers to Alpha Deblocking, while the Threshold Parameter refers to Beta Deblocking (Alpha and Beta Deblocking are the official names). When a deblock setting is written as X:X (for instance 0:0 or 2:-2) the first number is alpha deblocking, while the second is beta deblocking.
Strength and Threshold ...
The bigger the strength (alpha), the more details you lose on each processed macrobloc ...
The bigger the threshold (beta), the more macroblocs get processed ...
Note : -6:-6 is nearly identical to turning the inloop filter off. Negative values don't sharpen the picture more than it is, they just remove less detail than the default 0:0
But obviously, throwing "return avisource("yourclip.avi").Trim(500)" into x264 and testing ourselves is the way to go ;)
PS : if anyone wants to compare ALL the inloop settings, be prepared to do (6+1+6)² = 169 encodes. Havefun ^^
foxyshadis
9th April 2006, 12:41
No, I thought it worked like that once too, until manao chastized me. ;) All macroblocks with quant > 15 are always processed.
Like, say if normally, a block with twice as many (high frequency) details was smoothed twice as hard as one with fewer details. By lowering beta you could make that be smoothed 1/4 as hard, or by raising it make it smoothed just as hard. So it changes the way the smoothing scales, which is already based on the detail present.
This is what I get out of it, so far, anyway.
DarkZell666
9th April 2006, 12:48
So it changes the way the smoothing scales, which is already based on the detail present.
Hmm ... so the deblocking acts relatively to a predefined amount of detail (hardcoded or something ?) ?
*.mp4 guy
9th April 2006, 15:09
@DarkZell666
Something like that, its very hard to explain properly. Basically it determines whether something in a block is an artifact and should be smoothed or whether it is a detail and should be kept. lowering it causes only blocks with few details/artifacts to be smoothed more, while raising it causes blocks with more detail/artifacts to be smoothed more.
@shon3i
Yes it should work well in your bitrate range, but it shouldn't be used on anime.
Manao
10th April 2006, 08:16
All macroblocks with quant > 15 are always processed.Nope.
All macroblocks whose [quantizer + min(alpha,beta)] > 15 may be processed. And, in those macroblocks, some conditions can make the deblocking not to be applied ( for example, borders of skips with same motion vectors aren't deblocked ).
akupenguin
10th April 2006, 18:03
All macroblocks whose [quantizer + min(alpha,beta)] > 15 may be processed. And, in those macroblocks, some conditions can make the deblocking not to be applied ( for example, borders of skips with same motion vectors aren't deblocked ).
The [qp + 2*min(alpha,beta)] > 15 is simply a conservative approximation, to avoid computing the exact formula as often.
The real criterion is: there is a threshold based on [qp + 2*alpha] and another threshold based on [qp + 2*beta]. The texture/gradient/whatever must pass both thresholds before any filtering is applied. The thresholds are 0 when [qp + 2*(alpha or beta)] <= 15. But they are still small for only slightly above 15, so most pixels will fail the threshold then too.
If a given pixel passes both thresholds, then it is filtered with strength dependent on [qp + 2*alpha].
Both thresholds and strength also depend on motion vectors and dct residuals. (This is what disqualifies Skip blocks with uniform motion.)
jellysandwich
10th April 2006, 21:53
Would someone mind posting a few screenshot examples? I tried doing a test on a small clip, but I can't really tell any differences... I think I'm picking bad scenes or something.
js
akupenguin
10th April 2006, 22:37
http://forum.doom9.org/showthread.php?p=689115#post689115
lovelove
31st March 2010, 17:23
...Threshold Parameter refers to Beta Deblocking (Alpha and Beta Deblocking are the official names). [...]
Lower values of Beta Deblocking apply less deblocking to more flat blocks with details present (but more deblocking to blocks without details), while Higher values cause more deblocking to be applied to less flat blocks with details present.
If beta deblocking is indeed a treshold parameter, then your abovementioned explanation is wrong. A treshold is not gradual but a specific level/value dividing the basic set in two subsets: all values below the treshold and all values above the treshold. Now given a function with 2 parameters (strength and threshold), 'strength' will be applied to all values below (or above) the threshold.
Thus the correct explanation is (assuming the parameters work as you describe, which I have NOT tested in practice):
Deblocking is applied with alpha strength to blocks with less detail than the (beta) threshold.
Therefore:
The higher the alpha parameter, the higher the deblocking strength applied.
The higher the beta parameter, the more blocks are deblocked (namely with strength alpha).
PS: In order for your explanation to be more correct, you would have to replace all red words above (i.e. "less deblocking" and "more deblocking") by "deblocking with alpha strength". But then you are still contradicting yourself when saying "to more flat blocks with details present" vs. "to less flat blocks with details present". So I would stick to my shorter and correct version ;-)
EDIT: having read the remainder of the thread, I add that DarkZell666 gives the same (correct) explanation.
infoeater
12th April 2010, 17:02
(...)more flat blocks with details present(...)
Is it antagonism or deblocking filter has some other method to measure amount of details then flatness?
asarian
29th August 2014, 14:26
Does --deblock require the existence of conventional block sizes (like 8x8) to work properly? Or does it work as effectively on upscaled material too? (with still some visible blocking, but with what would now be larger, non-standard block sizes).
Thanks.
Andouille
29th August 2014, 14:38
Does --deblock require the existence of conventional block sizes (like 8x8) to work properly? Or does it work as effectively on upscaled material too? (with still some visible blocking, but with what would now be larger, non-standard block sizes).
Thanks.
x264's "deblock" does not filter your blocky source. It is a part of the encoding.
So resolution does not matter.
asarian
29th August 2014, 14:46
x264's "deblock" does not filter your blocky source. It is a part of the encoding.
So resolution does not matter.
Not sure I fully understand the answer. Obviously x264 does deblocking on what invariably takes my source for input, right?
Or are you saying it does not look at the source per se to deblock, but just generally deblocks on what it encodes? (Which would still leave me with a deblocked movie, right?)
detmek
29th August 2014, 15:56
X264 divides image into diferent block sizes, 16x16, 8x8, 4x4. Internal deblocking deblocks these macroblocks to prevent hard edges between those, and in general to prevent blocking as a result of encoding. It also removes a bit of details and makes picture softer when used with higher values. It does not remove blocking from source. Usd avisynth deblock or unblock plugin if you want to deblock source.
Read first post for more detailed explanation.
asarian
29th August 2014, 16:32
X264 divides image into diferent block sizes, 16x16, 8x8, 4x4. Internal deblocking deblocks these macroblocks to prevent hard edges between those, and in general to prevent blocking as a result of encoding. It also removes a bit of details and makes picture softer when used with higher values. It does not remove blocking from source. Usd avisynth deblock or unblock plugin if you want to deblock source.
Read first post for more detailed explanation.
Ah, thank you! It's a lot more clear now. :)
Thunderbolt8
13th April 2015, 02:32
what are the deblocking effects on encoding speed? is it logical to assume that the lowest values -3;-3 are fastest, because the least amount of deblocking is applied then?
foxyshadis
13th April 2015, 20:09
Depends on high low your crf and how high your rd level is. The more blocks with quants below or barely above the deblocking threshold, the less get deblocked. The higher your rd level, the more times each block is checked, so the more helpful less deblocking is. Any benchmarks will be heavily weighted toward the video and settings you use, but will be a rather small part of the overall speed.
You can actually go all the way down to -6,-6, at which point you might as well just turn deblocking off completely.
Lathe
16th January 2017, 08:05
Sort of along the topic of this thread... :)
If I lower the deblock settings and slightly raise the Psy Trellis, this is pretty much encoding at high bitrates with Blu-rays using a CRF around 20 and x264 settings around 'Slow', does that increase the amount of bitrate used and thus increase the file size?
Say I use a setting of --deblock -3:-3 --psy-rd 1.00:0.25, will this inherently raise the amount of bitrate 'needed' while encoding and thus increase the overall resulting file size?
Thanks!
***EDIT
Hmmm, well, I THINK I got the answer to my question here from reading a few more threads. Apparently, YES, the bitrate will indeed go up even using --tune film according to other threads, so -3, -3 AND raising the Psy Trellis is BOUND to increase it even more, I guess...
I was bloody wondering WHY my encodes were coming out so big... :rolleyes:
Kill3rWolf
1st January 2022, 14:56
Sort of along the topic of this thread... :)
If I lower the deblock settings and slightly raise the Psy Trellis, this is pretty much encoding at high bitrates with Blu-rays using a CRF around 20 and x264 settings around 'Slow', does that increase the amount of bitrate used and thus increase the file size?
Say I use a setting of --deblock -3:-3 --psy-rd 1.00:0.25, will this inherently raise the amount of bitrate 'needed' while encoding and thus increase the overall resulting file size?
Thanks!
***EDIT
Hmmm, well, I THINK I got the answer to my question here from reading a few more threads. Apparently, YES, the bitrate will indeed go up even using --tune film according to other threads, so -3, -3 AND raising the Psy Trellis is BOUND to increase it even more, I guess...
I was bloody wondering WHY my encodes were coming out so big... :rolleyes:
Could you explain more about how you got your answers & your test results? What about animation film x265 encoding? Deblock=1:-3:-3 can be used?
benwaggoner
3rd January 2022, 16:30
Could you explain more about how you got your answers & your test results? What about animation film x265 encoding? Deblock=1:-3:-3 can be used?
Note the post you responded to was nearly 5 years ago.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.