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 22nd April 2008, 18:44   #1  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,666
x264: Film Grain Optimization

example:
with, without

fprofiled win32 build
patch (updated to work on latest revision and on 64-bit)
explanation (how it works, etc)

usage:

--fgo, see --help for more info. Requires RDO, i.e. --subme 6 or higher and --b-rdo. Obviously doesn't work well on non-grainy sources.

Last edited by Dark Shikari; 3rd May 2008 at 10:50.
Dark Shikari is offline   Reply With Quote
Old 22nd April 2008, 19:15   #2  |  Link
Sagittaire
Testeur de codecs
 
Sagittaire's Avatar
 
Join Date: May 2003
Location: France
Posts: 2,484
You use nssd?
Come from libavcodec?
__________________
Le Sagittaire ... ;-)

1- Ateme AVC or x264
2- VP7 or RV10 only for anime
3- XviD, DivX or WMV9
Sagittaire is offline   Reply With Quote
Old 22nd April 2008, 19:56   #3  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,666
Quote:
Originally Posted by Sagittaire View Post
You use nssd?
Come from libavcodec?
Yes, I ported NSSD from libavcodec and drastically simplified the assembly. Other changes include some modifications to RD thresholds.
Dark Shikari is offline   Reply With Quote
Old 22nd April 2008, 20:17   #4  |  Link
IgorC
Registered User
 
Join Date: Apr 2004
Posts: 1,315
Is it good idea if I try to encode with fgo enabled and trellis 2 + deblock -1:-1?
IgorC is offline   Reply With Quote
Old 22nd April 2008, 20:18   #5  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,666
Quote:
Originally Posted by IgorC View Post
Is it good idea if I try to encode with fgo enabled and trellis 2 + deblock -1:-1?
It should work fine with trellis 2. I haven't experimented much, so feel free to do whatever you want and see how well it works.
Dark Shikari is offline   Reply With Quote
Old 22nd April 2008, 20:38   #6  |  Link
Adub
Fighting spam with a fish
 
Adub's Avatar
 
Join Date: Sep 2005
Posts: 2,698
So, would this be used instead of your Grain Optimizer? Or in conjunction with?
__________________
FAQs:Bond's AVC/H.264 FAQ
Site:Adubvideo
Adub is offline   Reply With Quote
Old 22nd April 2008, 21:05   #7  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,666
Quote:
Originally Posted by Merlin7777 View Post
So, would this be used instead of your Grain Optimizer? Or in conjunction with?
Unrelated, though I really don't think grainoptimizer is that effective nor that reliable.
Dark Shikari is offline   Reply With Quote
Old 22nd April 2008, 21:12   #8  |  Link
ToS_Maverick
x264 Tester
 
Join Date: Dec 2005
Location: Austria, near Vienna
Posts: 223
now that you created another mysteriously patch, would you please explain how it is supposed to work? i'm very interested, and can only trust a patch if i know what it does
ToS_Maverick is offline   Reply With Quote
Old 22nd April 2008, 21:15   #9  |  Link
Blue_MiSfit
Derek Prestegard IRL
 
Blue_MiSfit's Avatar
 
Join Date: Nov 2003
Location: Los Angeles
Posts: 5,986
<3!!!!

I've been waiting for this one for a long time!!

I was under the impression that FGM had to be supported decoder side as well?

~misfit
__________________
These are all my personal statements, not those of my employer :)
Blue_MiSfit is offline   Reply With Quote
Old 22nd April 2008, 21:19   #10  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,666
Quote:
Originally Posted by ToS_Maverick View Post
now that you created another mysteriously patch, would you please explain how it is supposed to work? i'm very interested, and can only trust a patch if i know what it does
RDO normally uses sum of squared differences as its metric. That is, it rewards modes which approximate the source the most accurately according to that metric, and which don't cost too many bits.

FGO uses NSSD instead. NSSD consists of two components:

1) SSD as before.

2) abs( Noise(Reference Block) - Noise(Coded Block) ) * Weight, where "weight" is the --fgo parameter (this parameter also controls a few other things in FGO).

The resulting score is SSD + ND (Noise Difference).

Noise is measured as follows:

If X(i,j) is a pixel in a block, the noise score for that pixel is abs(X(i,j) - X(i+1,j) - X(i,j+1) + X(i+1,j+1)). This is summed up over all pixels in the block.

In other words, NSSD rewards modes which have a similar amount of noise and approximate the source reasonably well. This noise need not be exactly like the source's noise; it merely needs to be good enough.

Quote:
Originally Posted by Blue_MiSfit View Post
I was under the impression that FGM had to be supported decoder side as well?
This isn't FGM, its FGO.
Dark Shikari is offline   Reply With Quote
Old 22nd April 2008, 21:21   #11  |  Link
Blue_MiSfit
Derek Prestegard IRL
 
Blue_MiSfit's Avatar
 
Join Date: Nov 2003
Location: Los Angeles
Posts: 5,986
ooooo...

right

I guess I mis-read it.

I like the results, at any rate!
__________________
These are all my personal statements, not those of my employer :)
Blue_MiSfit is offline   Reply With Quote
Old 22nd April 2008, 21:32   #12  |  Link
mahsah
Registered User
 
Join Date: Jun 2006
Posts: 273
The pictures and Binary are down... anyone got a mirror?

Also should this be used with AQ or not...?

and for that matter, how exactly does it work (in layman's terms perhaps? )
mahsah is offline   Reply With Quote
Old 22nd April 2008, 21:36   #13  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,666
Quote:
Originally Posted by mahsah View Post
The pictures and Binary are down... anyone got a mirror?

Also should this be used with AQ or not...?

and for that matter, how exactly does it work (in layman's terms perhaps? )
It should be used with AQ, the server isn't down (works fine here), and a somewhat simple explanation was posted above.

In incredibly simple terms: it measures only that the amount of noise in a candidate block is the same as it should be, not that its the same noise as in the source.
Dark Shikari is offline   Reply With Quote
Old 22nd April 2008, 21:54   #14  |  Link
K0zi
Registered User
 
Join Date: Nov 2007
Location: PL
Posts: 26
What CQM's would you recommend to use with FGO?
How about prestige?
K0zi is offline   Reply With Quote
Old 22nd April 2008, 21:57   #15  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,666
Quote:
Originally Posted by K0zi View Post
What CQM's would you recommend to use with FGO?
How about prestige?
I have no idea; I haven't tried any.

I've never really had good experiences with Prestige.
Dark Shikari is offline   Reply With Quote
Old 22nd April 2008, 22:18   #16  |  Link
ToS_Maverick
x264 Tester
 
Join Date: Dec 2005
Location: Austria, near Vienna
Posts: 223
OMG Dark Shikari, you just wrote the XviD-KILLER!!!

everything that was better with xvid is GONE! with FGO i simply got the best encode of the BlackPearl-Sample. looks like 60 mb, at only 32 mb!!!

and forget about matrices, who needs matrices now?

if you don't believe it, here are some screens
Left AQ (29,4 MB), Right AQ + FGO (32,1 MB)





and the most amazing image-pair:


commandline:
Code:
 --crf 20.0 --level 4.1 --keyint 100 --min-keyint 1 --ref 3 --mixed-refs --no-fast-pskip --bframes 2 --b-pyramid --b-rdo --bime --weightb --filter -2,-2 --subme 6 --trellis 1 --analyse p8x8,b8x8,i4x4,i8x8 --8x8dct --vbv-bufsize 9781 --vbv-maxrate 29400 --threads auto --thread-input --progress --no-dct-decimate --output "output" "input" --fgo 10
ToS_Maverick is offline   Reply With Quote
Old 22nd April 2008, 22:48   #17  |  Link
Sagittaire
Testeur de codecs
 
Sagittaire's Avatar
 
Join Date: May 2003
Location: France
Posts: 2,484
Quote:
Originally Posted by Dark Shikari View Post

--fgo, see --help for more info. Requires RDO, i.e. --subme 6 or higher and --b-rdo. Obviously doesn't work well on non-grainy sources.

The resulting score is SSD + ND (Noise Difference).
Perhaps SSD problem here (with non-grainy source certainely that ND ~ 0). Why not choose other metric like SAD/SATD if ND ~ 0 or if ND < Threshold. Why not SAD + ND or SATD + ND too.
__________________
Le Sagittaire ... ;-)

1- Ateme AVC or x264
2- VP7 or RV10 only for anime
3- XviD, DivX or WMV9
Sagittaire is offline   Reply With Quote
Old 22nd April 2008, 22:58   #18  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,666
Quote:
Originally Posted by Sagittaire View Post
Perhaps SSD problem here (with non-grainy source certainely that ND ~ 0). Why not choose other metric like SAD/SATD if ND ~ 0 or if ND < Threshold. Why not SAD + ND or SATD + ND too.
SAD/SATD are really measures of bit cost, not distortion.
Dark Shikari is offline   Reply With Quote
Old 23rd April 2008, 00:16   #19  |  Link
Inventive Software
Turkey Machine
 
Join Date: Jan 2005
Location: Lowestoft, UK (but visit lots of places with bribes [beer])
Posts: 1,953
Wow, Dark Shikari with another wonder-patch that'll surely make it's way to SVN within a matter of weeks!

How optimised is it? And do I now have to re-encode most of my movies to fit?
__________________
On Discworld it is clearly recognized that million-to-one chances happen 9 times out of 10. If the hero did not overcome huge odds, what would be the point? Terry Pratchett - The Science Of Discworld
Inventive Software is offline   Reply With Quote
Old 23rd April 2008, 00:34   #20  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,666
Quote:
Originally Posted by Inventive Software View Post
Wow, Dark Shikari with another wonder-patch that'll surely make it's way to SVN within a matter of weeks!

How optimised is it? And do I now have to re-encode most of my movies to fit?
How optimized?

Its probably erring on the side of caution in the disabling of certain RD thresholds; I'm guessing I might want to reinstate them, just at a higher level than normal.

The "noise" operation is SIMD-optimized but its not nearly as optimized as it could be; it can definitely get faster.
Dark Shikari 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 10:24.


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