Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > MPEG-4 AVC / H.264

Reply
 
Thread Tools Search this Thread Display Modes
Old 8th April 2006, 17:28   #1  |  Link
*.mp4 guy
Registered User
 
*.mp4 guy's Avatar
 
Join Date: Feb 2004
Posts: 1,348
How To Use Mpeg4 AVC Deblocking Effectively (Small FAQ)

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.

Last edited by *.mp4 guy; 9th April 2006 at 15:14.
*.mp4 guy is offline   Reply With Quote
Old 8th April 2006, 18:03   #2  |  Link
Hyper Shinchan
Registered User
 
Join Date: Mar 2005
Location: Italy
Posts: 286
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).
Hyper Shinchan is offline   Reply With Quote
Old 8th April 2006, 18:05   #3  |  Link
*.mp4 guy
Registered User
 
*.mp4 guy's Avatar
 
Join Date: Feb 2004
Posts: 1,348
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.
*.mp4 guy is offline   Reply With Quote
Old 8th April 2006, 20:03   #4  |  Link
smok3
brontosaurusrex
 
smok3's Avatar
 
Join Date: Oct 2001
Posts: 2,392
Quote:
Originally Posted by Hyper Shinchan
Thanks for the easy faq! In effect I was using in the wrong way the beta deblocking until now
same here

Quote:
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?
smok3 is offline   Reply With Quote
Old 8th April 2006, 20:08   #5  |  Link
*.mp4 guy
Registered User
 
*.mp4 guy's Avatar
 
Join Date: Feb 2004
Posts: 1,348
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.
*.mp4 guy is offline   Reply With Quote
Old 8th April 2006, 20:27   #6  |  Link
shon3i
BluRay Maniac
 
shon3i's Avatar
 
Join Date: Dec 2005
Posts: 2,419
So *.mp4 guy what do you recommend for DVD Backups in bitrate range 600-900kbps. Thanks
shon3i is offline   Reply With Quote
Old 8th April 2006, 20:54   #7  |  Link
*.mp4 guy
Registered User
 
*.mp4 guy's Avatar
 
Join Date: Feb 2004
Posts: 1,348
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.
*.mp4 guy is offline   Reply With Quote
Old 8th April 2006, 21:24   #8  |  Link
shon3i
BluRay Maniac
 
shon3i's Avatar
 
Join Date: Dec 2005
Posts: 2,419
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

Quote:
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

Quote:
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.
shon3i is offline   Reply With Quote
Old 8th April 2006, 21:26   #9  |  Link
Sirber
retired developer
 
Sirber's Avatar
 
Join Date: Oct 2002
Location: Canada
Posts: 8,978
If I'd want 3 settings, like Low, Medium and High, for anime, what would you recommend?
__________________
Detritus Software
Sirber is offline   Reply With Quote
Old 8th April 2006, 22:59   #10  |  Link
*.mp4 guy
Registered User
 
*.mp4 guy's Avatar
 
Join Date: Feb 2004
Posts: 1,348
@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 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

Last edited by *.mp4 guy; 8th April 2006 at 23:08.
*.mp4 guy is offline   Reply With Quote
Old 8th April 2006, 23:11   #11  |  Link
Sirber
retired developer
 
Sirber's Avatar
 
Join Date: Oct 2002
Location: Canada
Posts: 8,978
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?
__________________
Detritus Software
Sirber is offline   Reply With Quote
Old 8th April 2006, 23:34   #12  |  Link
*.mp4 guy
Registered User
 
*.mp4 guy's Avatar
 
Join Date: Feb 2004
Posts: 1,348
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.
*.mp4 guy is offline   Reply With Quote
Old 9th April 2006, 11:41   #13  |  Link
riggits
Registered User
 
Join Date: Nov 2003
Location: vancouver
Posts: 93
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?
__________________
Soulcake. Duck. Mmmm. Good.
riggits is offline   Reply With Quote
Old 9th April 2006, 11:57   #14  |  Link
shon3i
BluRay Maniac
 
shon3i's Avatar
 
Join Date: Dec 2005
Posts: 2,419
*.mp4 guy Thanks, is that matrix good for my bitrate range
shon3i is offline   Reply With Quote
Old 9th April 2006, 12:28   #15  |  Link
DarkZell666
aka XaS
 
DarkZell666's Avatar
 
Join Date: Jun 2005
Location: France
Posts: 1,122
Thx *.mp4 guy for this FAQ

But I think this says it all, really :
Quote:
Originally Posted by *.mp4 guy
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 ^^
__________________

Q9300 OC @ 3.2ghz / Asus P5E3 / 4GB PC10600 / Geforce 8600 GTS

Last edited by DarkZell666; 9th April 2006 at 12:37.
DarkZell666 is offline   Reply With Quote
Old 9th April 2006, 12:41   #16  |  Link
foxyshadis
ангел смерти
 
foxyshadis's Avatar
 
Join Date: Nov 2004
Location: Lost
Posts: 9,558
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.
foxyshadis is offline   Reply With Quote
Old 9th April 2006, 12:48   #17  |  Link
DarkZell666
aka XaS
 
DarkZell666's Avatar
 
Join Date: Jun 2005
Location: France
Posts: 1,122
Quote:
Originally Posted by foxshadis
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 ?) ?
__________________

Q9300 OC @ 3.2ghz / Asus P5E3 / 4GB PC10600 / Geforce 8600 GTS
DarkZell666 is offline   Reply With Quote
Old 9th April 2006, 15:09   #18  |  Link
*.mp4 guy
Registered User
 
*.mp4 guy's Avatar
 
Join Date: Feb 2004
Posts: 1,348
@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.

Last edited by *.mp4 guy; 9th April 2006 at 15:11.
*.mp4 guy is offline   Reply With Quote
Old 10th April 2006, 08:16   #19  |  Link
Manao
Registered User
 
Join Date: Jan 2002
Location: France
Posts: 2,856
Quote:
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 ).
__________________
Manao is offline   Reply With Quote
Old 10th April 2006, 18:03   #20  |  Link
akupenguin
x264 developer
 
akupenguin's Avatar
 
Join Date: Sep 2004
Posts: 2,392
Quote:
Originally Posted by Manao
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.)

Last edited by akupenguin; 10th April 2006 at 18:07.
akupenguin is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:00.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.