Log in

View Full Version : Modern x265 grain tuning


benwaggoner
15th March 2021, 21:47
--tune grain has been around for years now, and is rather a blunderbuss, mainly turning off cu-size recursion and yield a near-constant QP within and between frames. It works for heavy film grain, but really reduces compression efficiency for clean content, and some for light grain. The performance hit of turning off rskip is also substantial.

Since --tune grain was introduced, default x265 is a lot better at light-moderate grain. And we've got newer tools that seem like they should help us to better tune for quality and performance with moderately grainy content. In particular:
--rskip now has a mode 2 based on CU edge density, and with that we have
--rskip-edge-threshold to set what the recursion threshold should be

Has anyone played around with those?

Beyond that, I think --rdoq 20 and --psy-rd 4.0 are likely higher than needed these days.

What tweaks are people using for grainy sources these days?

quietvoid
15th March 2021, 22:07
Beyond that, I think --rdoq 20 and --psy-rd 4.0 are likely higher than needed these days.
What tweaks are people using for grainy sources these days?
I'm pretty sure some people are still using --psy-rdoq 50.0 and --psy-rd 5.0 for UHD BD authoring with x265.
Maybe it was a one-off though..

What I know is that disabling strong intra smoothing is often useful for larger grain.

rwill
15th March 2021, 22:36
Strong intra smoothing is just smoothing the prediction pels at the border of a CU from which the prediction is formed, its better left ON than to have some sharp angular prediction details across a whole CU which then have to be removed by the residual.

What wonders me is that the last x265 versions I tried had SAO badly broken and introducing blocks in slight gradients overlayed with grain. I do not get why the wont fix that. Its probably been in there for years.

benwaggoner
15th March 2021, 23:10
I'm pretty sure some people are still using --psy-rdoq 50.0 and --psy-rd 5.0 for UHD BD authoring with x265.
Maybe it was a one-off though..
UHD BD also can have crazy high bitrates, so --tune grain is perfectly reasonable. Peak Bitrate is 80 Mbps IIRC. And the lowest disc size is 50 GB, which offers a lot of ABR even for long movies.

Of course, UHD resolution masters, especially remasters, often have way more visible grain than the original creatives ever would have seen on a perf screen. Super 35mm movies can look like 720p upsampled to 2160p and then a jacked-up film grain effect applied.

microchip8
16th March 2021, 05:41
I use --psy-rd 4.0 --psy-rdoq 15 -qcomp 0.7 --rskip 2 --rskip-edge-threshold 0.2 --strong-intra-smoothing for both clean and noisy content. Am very happy with these settings for both types of content. I only encode FHD, though. UHD on my fastest PC is too slow to encode

benwaggoner
16th March 2021, 23:44
I use --psy-rd 4.0 --psy-rdoq 15 -qcomp 0.7 --rskip 2 --rskip-edge-threshold 0.2 --strong-intra-smoothing for both clean and noisy content. Am very happy with these settings for both types of content. I only encode FHD, though. UHD on my fastest PC is too slow to encode
Thanks for the tip!

What bitrates are you targeting/getting with what CRF?

microchip8
17th March 2021, 06:07
Thanks for the tip!

What bitrates are you targeting/getting with what CRF?

I always use CRF 21. For clean sources, between 3000 and 6000 kbps. For noisy ones, depends on how noisy they are but bitrate can shootup to 12,000 kbps. Most of the time it's usually less

I've also disabled SAO and lowered deblocking strength to -4,-4. HME is turned on as well (umh,umh,star). Can't virtually never tell a difference between original and the encode

The reason I upped --psy-rd and --psy-rdoq is that at low values, I was able to spot halo's in dark scenes when encoding Blade Runner 2049 which is pretty clean with little mosquito noise. Increasing these values made the problem go away and I stuck at using them

ShortKatz
17th March 2021, 08:00
I also use --rskip 2 for my UHD encodes. But I have --rskip-edge-threshold at the default, because I'm unsure how to tune this setting. And you do not find much information about --rskip-edge-threshold in the internet.

olle83
17th March 2021, 09:10
Wow, you guys are using high psy-values.
I noticed that high psy-setting make grain look sharp and annoying to me, it gets amplified. Lower settings keep it looking natural.

I'm just using this type of settings:
--crf 21.3 --input-res 1664x936 --fps 24000/1001 --frames 12345 --frame-threads 2 --preset slower --ref 6 --ctu 32 --rd 3 --limit-refs 3 --limit-tu 0 --deblock -3:-3 --keyint 360 --min-keyint 24 --merange 26 --no-sao --psy-rd 2.0 --psy-rdoq 1.2 --rc-lookahead 60 --aq-mode 3 --aq-strength 0.85 --no-cutree --qcomp 0.65 --cbqpoffs -1 --crqpoffs -1 --range limited --colorprim 1 --transfer 1 --colormatrix 1 --output-depth 10 --profile main10 --level-idc 5.0 --high-tier --no-open-gop --repeat-headers --aud --hrd

I modify aq-strength according to how much grain source has. If there's little or none I increase it and if there's huge amounts I decrease it.

I'm using 10 bit even for 8 bits sources too.

benwaggoner
17th March 2021, 17:06
I always use CRF 21. For clean sources, between 3000 and 6000 kbps. For noisy ones, depends on how noisy they are but bitrate can shootup to 12,000 kbps. Most of the time it's usually less

I've also disabled SAO and lowered deblocking strength to -4,-4. HME is turned on as well (umh,umh,star). Can't virtually never tell a difference between original and the encode

The reason I upped --psy-rd and --psy-rdoq is that at low values, I was able to spot halo's in dark scenes when encoding Blade Runner 2049 which is pretty clean with little mosquito noise. Increasing these values made the problem go away and I stuck at using them
Are you encoding from 10-bit or 8-bit, and to 10-bit or 8-bit?

microchip8
17th March 2021, 17:15
Are you encoding from 10-bit or 8-bit, and to 10-bit or 8-bit?

I encode 8 bit input to 10 bit HEVC/x265

microchip8
17th March 2021, 17:17
I also use --rskip 2 for my UHD encodes. But I have --rskip-edge-threshold at the default, because I'm unsure how to tune this setting. And you do not find much information about --rskip-edge-threshold in the internet.

The lower, the higher precision/quality and vice versa

RanmaCanada
18th March 2021, 05:48
If we want to find out if it's improved, wouldn't encoding Alien be the best test? I remember previously someone attempted to do it and the result was that the encode came out larger than the original. I do not own the movie, so I personally am not able to do this.

ShortKatz
20th March 2021, 00:04
The lower, the higher precision/quality and vice versa

Thanks. The documentation tells the default is 5. But according to the log, the default is set to "rskip-edge-threshold=0.05". This is kind of confusing. So, this means your 0.2 translates to 20? :confused:

microchip8
20th March 2021, 06:18
Thanks. The documentation tells the default is 5. But according to the log, the default is set to "rskip-edge-threshold=0.05". This is kind of confusing. So, this means your 0.2 translates to 20? :confused:

No, it translates to 2. I wrote 0.2 by mistake. Should be 0.02

Boulder
20th March 2021, 09:31
If we want to find out if it's improved, wouldn't encoding Alien be the best test? I remember previously someone attempted to do it and the result was that the encode came out larger than the original. I do not own the movie, so I personally am not able to do this.

Alien is a very good sample, also many of the old b/w movies are really hard for the encoder. Crisp image and lots of sharp grain. The Bridge on the River Kwai (4K) is also a very tough one.

ReinerSchweinlin
24th March 2021, 14:19
Alien is a very good sample, also many of the old b/w movies are really hard for the encoder. Crisp image and lots of sharp grain. The Bridge on the River Kwai (4K) is also a very tough one.
Stanley Cubrik used to work with very hig ISO Films in order to capture the "natural look of low ambient lighting" in some scenes, resulting in a lot of grain in darker scenes. I can imagine these movies could be a good test-source, too.