PDA

View Full Version : x264: Then and Now


RadicalEd
4th December 2008, 21:45
http://blog.command-q.org/?p=42

Comparison of x264's progress over the years, since its humble beginnings in 2004.

AntiJw
4th December 2008, 22:12
http://blog.command-q.org/html/x264.html
2008 looks worse. Is it because you used AQ for 2008, but 2007 had no AQ? AQ should be disabled for cartoon/anime.

RadicalEd
4th December 2008, 22:17
http://blog.command-q.org/html/x264.html
2008 looks worse. Is it because you used AQ for 2008, but 2007 had no AQ? AQ should be disabled for cartoon/anime.
AQ too? I've been told not to use psy-RD, but I haven't heard anything bad about AQ. At any rate, re-check the blog, I'm running the comparison over without psy-RD. I'll disable AQ if that's bad for anime as well.

AntiJw
4th December 2008, 22:33
AQ too? I've been told not to use psy-RD, but I haven't heard anything bad about AQ. At any rate, re-check the blog, I'm running the comparison over without psy-RD. I'll disable AQ if that's bad for anime as well.Yeah, MeGUI uses --psy-rd 0.6:0 --aq-mode 0 on it's Anime_Toons-settings, so I assume it's bad.

Sagekilla
4th December 2008, 23:26
AQ tends to hurt anime slightly if used at strengths that you would normally use for real life content because it strips bits from sharp transitions (lines, subs for example) gives it to the flatter areas. If you use a very low aq strength, so you can get the benefits of better flat textures, you won't have as bad ringing on anything that isn't a smooth transiton like hard coded subs.

That said, I'd rather go with --aq-strength 0.2 or 0.1 so you can get some of it's benefits without risking the artifacting AQ usually gives.

@AntiJw: It's only bad at higher strengths. If you use a low enough one, you can benefit still.

nm
4th December 2008, 23:46
@RadicalEd:
The quality drop between 2007 and 2008 results seems too great to be explained by AQ and psy-rdo alone. Could you post the full x264 command lines for both? Did you use vanilla x264 or were there additional patches included in the builds?

Dark Shikari
4th December 2008, 23:57
Cartoons aren't generally a good test of quality because they only test one thing: "how well can an encoder store transcients?"

All other features of an encoder are basically ignored.

I don't know of any encoder that has particularly interesting optimizations with regards to transcients, so I would be unsurprised if most H.264 encoders give similar results on cartoon footage.

RadicalEd
5th December 2008, 00:10
Thanks for the comments, all. As stated in the blog post, I don't have the original settings for 2007 anymore. I'll mess around with the settings and see what I can find out, and then re-post the results. Sorry for the botched first try :x

Also, I've fixed some minor glitches with the screenshots page -- the third screen now loads in place instead of as a link, and the one image that was 404ing is now there.

Again, thanks for the comments!

RadicalEd
5th December 2008, 01:39
Alright, re-running all four encodes with the following settings as per suggestions here and on the blog:

--b-pyramid -r 16 --me umh --subme 9 --psy-rd 0.6:0 --aq-strength 0.2 -A all --merange 64 --psy-rd 0 --mixed-refs -8 -t 1 -b 16 -p 3

Will report on the results later.

Edit: I should also mention that this is going to take forever :/

Sagekilla
5th December 2008, 02:36
I hope you're also encoding something more complex than anime this time, even a short 5 minute clip of some real life footage would be far more useful.

RadicalEd
5th December 2008, 02:42
I hope you're also encoding something more complex than anime this time, even a short 5 minute clip of some real life footage would be far more useful.
That would be out of the scope of this project, though. I have a bigger codec comparison planned that will include live action, but this anime clip is the only thing that I have records of from 2004 and 2007. It's my standard test clip due to the super-cleaned nature.

Sagekilla
5th December 2008, 02:45
Well now, if you really wanna go do a 2004 - 2008 comparison, that's trivial: Download a build from each year.

Also, the super clean nature is the exact reason why it's a bad comparison clip. You're only telling if an encoder can cleanly compress sequences with little variation (in other words, transients like DS said).

If you have more detailed and varying source like real life footage, you get an inherent nosiy nature all* the time. Then, you're really testing to see if the encoder can still produce an output that looks similar to the input, noise, grain, and all.



*Extremely exceptional case: Lots of oversampling and absurdly low noise sensors, even then there's still some noise.

RadicalEd
5th December 2008, 03:19
Well now, if you really wanna go do a 2004 - 2008 comparison, that's trivial: Download a build from each year.
Touché :|

Sagekilla
5th December 2008, 03:21
I know (windows wise anyway) there are a few builds floating around that reach back to the very early days of x264 (rev < 100). Everything else is more or less easy to find though.

RadicalEd
5th December 2008, 03:34
Everything else is more or less easy to find though.
I'm not sure if it's the same case with Git, but with SVN it's trivial to checkout any revision.

Sagekilla
5th December 2008, 03:43
Git doesn't have revision numbers per se. You can more or less match it up with the changelog.txt to figure out which one you wanna download.

Still possible, just not immediately obvious though :) The other tricky thing with doing a 2004 - 2008 comparison is picking which revision from that year to compare. Or will you be doing something like use a constant date (i.e. june 12th) and get a revision from that day (or closest to) from every year?


Edit: Also, if you need some good quality sequences I can upload a ~5 min .m2ts cut from one of my blu-rays. One that might be particularly useful would be 300. Plenty of all that good stuff (read: excessive grain) that's hard for encoders to retain.

RadicalEd
5th December 2008, 03:46
Nah, I have a pretty good source here. Honestly I'm probably not going to rip it right now because this comparison is so small, but the 2008 (probably 2009 by the time I get it done) comparison will definitely be something to look for.

Sagekilla
5th December 2008, 03:52
Look forward to it then :)

One other thought: Do you still have the (untouched/muxed/whatever) .264 streams? If you do, you can still figure out what settings you used.

RadicalEd
5th December 2008, 03:59
One other thought: Do you still have the (untouched/muxed/whatever) .264 streams? If you do, you can still figure out what settings you used.

Nope. They went straight to MP4.

kemuri-_9
5th December 2008, 04:17
Nope. They went straight to MP4.

you should still be able to demux the avc stream out, and then use a hex reader to get the x264 signature (that contains the settings used) that was placed into the stream.

AntiJw
5th December 2008, 04:35
Alright, re-running all four encodes with the following settings as per suggestions here and on the blog:

--b-pyramid -r 16 --me umh --subme 9 --psy-rd 0.6:0 --aq-strength 0.2 -A all --merange 64 --psy-rd 0 --mixed-refs -8 -t 1 -b 16 -p 3

Will report on the results later.I hope you don't use two --psy-rd settings :P

Sagekilla: BTW, thanks for the tip about low aq on cartoon/anime.

Sagekilla
5th December 2008, 04:39
.264 streams from x264 normally have a chunk of data (Don't know the name off hand) right near the beginning that gives all the details about how they were encoded. Regardless of what container that stuffed into (.mkv, .mp4, .264) the data will still be present.

You can download mediainfo and just run it on your old files to get what your settings were. I think this should work 99% of the time. Either way, it doesn't hurt to try.

RadicalEd
5th December 2008, 06:04
I hope you don't use two --psy-rd settings :P

Half-way into encoding: FFFFFFFFFUUUUUUUUUUUUUUUUUUUUUUU

Looks like this change is going up in the morning, guys -_-

Sagekilla
5th December 2008, 06:06
How long are the clips you're encoding?

RadicalEd
5th December 2008, 06:14
How long are the clips you're encoding?

Very short. 2073 frames, about 90 seconds I believe.

RadicalEd
8th December 2008, 23:01
Updated, with much better results this time around: http://blog.command-q.org/?p=62

Blue_MiSfit
9th December 2008, 00:00
I'd have to say that in all your test cases the 2008 results look much worse IMO (at least with the 256 and 512kb tests, which show the most obvious differences).

Psy-RD seems to be doing ugly things with these anime.

~MiSfit

Mr VacBob
11th December 2008, 10:45
I think 2008 looks worse at 256kbit but ties above that. 6:6 is a pretty high filter setting, though, maybe too high.

The source also has a really bad case of Deen+xsharpen, so it doesn't look that great in the first place.

burfadel
11th December 2008, 11:34
I agree, and more typical settings would be a better comparison. Having the standard AQ setting, Psy-rd at 1.0, and even psy trellis 1.0 (I know 0 is standard for the moment, maybe a 0 & 1.0 comparison) would be a better approach.

The setting most people are likely to change are the b-frames, ref frames, bitrate, subme, and me, generally speaking. I also thing that the new b-frame decision should be used instead of the older one. For comparison sake, if setting the optimal sensible settings for say 2007, and then for 2008, is still valid since its the highest practical setting for the programme of that time. That is, subme 7 compared to 9, aq, psy rd/trellis, b-adapt 2, etc.

Also a non-anime clip would be good, since the typical use is for non-animation purposes.

Soichiro
12th December 2008, 11:33
If you really want something to use as a test clip, go download the Touhou lossless that's floating around somewhere.

And personally, I don't know what the fuss is about Psy-RD and AQ on anime, because I've only ever had it help. Then again, modern anime also has more gradients, details, and grain compared to the super flat animation from 2004.

Dark Shikari
12th December 2008, 11:37
If you really want something to use as a test clip, go download the Touhou lossless that's floating around somewhere.This is a good test (http://mirror05.x264.nl/Dark/force.php?file=./saextra_predictive_lossless.h264). Note: H.264 predictive lossless.
And personally, I don't know what the fuss is about Psy-RD and AQ on anime, because I've only ever had it help. Then again, modern anime also has more gradients, details, and grain compared to the super flat animation from 2004.Kyoto Animation would like a word with you ;)

Yoshiyuki Blade
13th December 2008, 10:28
If you really want something to use as a test clip, go download the Touhou lossless that's floating around somewhere.

And personally, I don't know what the fuss is about Psy-RD and AQ on anime, because I've only ever had it help. Then again, modern anime also has more gradients, details, and grain compared to the super flat animation from 2004.

I've only noticed the problems occuring on really clean animes with sharp lines and edges. Older animes, particularly film-based ones, seem to benefit from AQ/Psy-RD greatly.

Sagekilla
13th December 2008, 18:04
Because PSY-RD/AQ tend to work better when the source has some texture complexity to it. Dark Shikari's Touhou encodes really show what AQ can do though.

I'm not sure if anyone tried Touhou with: No PSY/AQ, AQ only, PSY only, AQ + PSY, to see how well each can help it.

RadicalEd
15th December 2008, 12:36
I agree, and more typical settings would be a better comparison. Having the standard AQ setting, Psy-rd at 1.0, and even psy trellis 1.0 (I know 0 is standard for the moment, maybe a 0 & 1.0 comparison) would be a better approach.
This was how the original comparison was, and the results were disastrous :/

burfadel
15th December 2008, 23:01
This was how the original comparison was, and the results were disastrous :/

I don't think animation is the best to test the features, as stated before! With film material the results are excellent, and there is good grain retention with these settings.

I think x264 should have in built 'tuning' for animation and film material. It is quite obvious it is currently tuned for film - or at least it seems that way! The way in built tuning would work is when a large percentage of flatness or only gradients are detected, a different bit distribution could occur between the lines and the flat areas in order to preserve line detail. The main problem with the difference between animation and film material is that with film material there is grain which hides line quality somewhat, and also there is less flat areas for the bits to be distributed to, and of course more lines.

With animation there is a large percentage of flat areas, little grain to mask the lines, and much less lines. So it seems for animation too much is taken away from the lines simply due to the effective ratio between the lines and flat areas - so it would seem to be anyway!

Since the flatness threshold is measurable, when a large percentage of flatness is detected, and a small amount of lines (where the aq takes bits from) is detected, the amount of AQ can be scaled back (or differentiated) along with psy-rd and psy-trellis, or at least altered automatically.

This could be an extra option, by default set on, such as 'Automatic Quality Metric' or something

Sagekilla
16th December 2008, 00:33
@burfadel: What happens if it thinks in the middle of a film that it's an anime, and suddenly starts using "anime settings?" No, x264 doesn't need "anime tuning." If the user is smart enough, he should know what settings are good for anime and good for real life content.

Generally speaking, that's very few settings to tweak (I can think of three or four off the top of my head that matter the most).

Edit: In short, the argument against having an "automatic anime" setting basically boiled down to: How do you determine the film is anime? How about if it's film? Yes, there are things that can give this away, but there's plenty of situations in both anime and real life content that can cause the encoder to get confused.

burfadel
16th December 2008, 01:05
Even throughout the same film, depending on what scenes you select the most optimal setting may vary. The suggestion I made wouldn't just be for anime, it would also apply to film where there are a large flatness area and small number of lines. The principal is just to reduce the redistribution of bits in circumstances where it might not be the best to do so. This would largely benefit anime which is why I used that as the example, but on a smaller scale film also benefits. Basically it means automatic adjusting within a certain range for the strengths of those features.

Sagekilla
16th December 2008, 01:58
Uh, you realize AQ is -helps- on scenes with flat textures? Good example: Any dark scene from a movie, the dark areas are considered to be "flat" by x264, and without AQ it ends up raising the quants of those MBs giving a blocky look in those areas. AQ takes bits away from areas of high contrast (typically lines) to lower the quants in those flat areas so it doesn't block up. Only reason this is really noticeable in anime is because people are using too high of a strength for that content. Most anime shouldn't be using the default strength of 1.0 because that takes too many bits from lines.

Alternative solution: Lower your damn quants/raise the bitrate you're using! Use a lower CRF or increase bitrate a bit.

On another note, AQ -does- have some automatic thresholds going on inside. The one setting you change (strength) acts a multiplier for the internals. The internals themselves, though, have automatic sensitivity according to the scene.

burfadel
16th December 2008, 02:39
Thats true, I didn't take that in to consideration :) Maybe it can adjust itself only above a certain luminance level in the flat areas. Its only those that really know what they're doing that choose different settings based on the content, which can still be done if you had the automatic adjusting as an option that can be turned off. That way the majority of people that use it have good settings for both animation and film material. It would also benefit codec comparisons since they typically use the default internal settings, plus some basic manual settings.

Sagekilla
16th December 2008, 02:54
It's not that hard actually: The more complex your source is, the higher AQ and PSY-RD you can use. So, very flat and basic anime shouldn't have very strong AQ or PSY-RD. A simple visual check can give you a rough idea whether it warrants using AQ/PSY-RD.

Note 2: I believe AQ works sort of like a complexity mask. Flatter areas (which are simple, and won't eat up many bits even on low quants) are usually boosted downwards so they don't get blocky.