Log in

View Full Version : Encoding 4:4:4 with higher quantizer for UV channels


Joachim Buambeki
7th September 2016, 03:41
Hello,

while reading up on other things I stumbled across those interesting statements from Dark Shikari:

4:4:4 is more efficient than 4:2:0, in that lowering chroma resolution is a very inefficient way of saving bits on chroma. ... in practical situations... it should be better to encode chroma with the same number of bits, but with a higher quantizer.
Downscaling is equivalent to lowpassing the input, i.e. removing all the high frequency coefficients. Quantization can do this much more efficiently because it can avoid removing the few that matter (e.g. on sharp edges) while just as easily removing those that don't.

According to its documentation x264 doesn't have a setting to adjust the the quantizer/CRF of the UV channels separately, or am I mistaken?


Is there a way to actually do this as an end user?
What delta between the Y and the UV channels would be recommended? +3? (Y= CRF 15, UV= CRF 18 for example)
What about deblocking? Wouldn't it be advised to use stronger deblocking for the UV channels (if possible)?


I am curious about this and would like to try this for my own uncompressed 4:4:4 content, also in 10 bit. Could someone advise me how to do it?


Thanks in advance
JB

raffriff42
7th September 2016, 04:40
Try '--chroma-qp-offset'
https://en.wikibooks.org/wiki/MeGUI/x264_Settings#chroma-qp-offset

Joachim Buambeki
7th September 2016, 13:47
Thanks, I should have looked from "chroma" then... :p

I found another quote:
x264 already gives +6 to chroma QP offset in 4:4:4 mode. This is completely arbitrary and probably not an ideal choice.

So x264 is already doing what I am looking for? If I am not mistaken +6 is about the same reduction of bandwidth as sub sampling to 4:2:0, right? Because encoding with CRF+3 will give an encode of about half the size, correct?

Asmodian
7th September 2016, 21:59
Yes, I wouldn't go above the default myself. I actually like only +2-4 when starting from full resolution chroma (RGB generally). e.g --chroma-qp-offset -4

Joachim Buambeki
8th September 2016, 00:57
Yes, I wouldn't go above the default myself. I actually like only +2-4 when starting from full resolution chroma (RGB generally). e.g --chroma-qp-offset -4
I am not sure if I understand you correctly - are you saying you decrease the CRF and increase the chroma-qp compared to what you would use for a 4:2:0 source?

As an example:

"--crf 18 --chroma-qp-offset -4" for a high quality 4:4:4 source
"--crf 16" if the same source would be 4:2:0


Thanks!

Asmodian
9th September 2016, 02:10
I am not sure if I understand you correctly - are you saying you decrease the CRF and increase the chroma-qp compared to what you would use for a 4:2:0 source?

As an example:

"--crf 18 --chroma-qp-offset -4" for a high quality 4:4:4 source
"--crf 16" if the same source would be 4:2:0


Thanks!

No, if starting from RGB and encoding to 4:4:4 I would use "--crf 16 --chroma-qp-offset -4" while for a 4:2:0 I might use "--crf 16". However, when encoding 4:4:4 I also target a larger file than if I had converted to 4:2:0 or left the chroma offset at the default of +6. I am trying to preserve the chroma quality as best I can, not using the offset to get better chroma quality at the same size as a 4:2:0 encode. That said, as Dark Shikari stated, the +6 is a bit arbitrary, and it is a little too high IMO. In a similar manner I think 4:2:0 is a bit too much compression for chroma, obviously chroma is less important than luma but 4:2:0 was picked due to technical simplicity, not as the optimal trade-off between luma and chroma bandwidth.

Maybe use -1 or -2 instead of -4. I generally target sizes a bit above the "optimal". Optimal meaning right at that point where any smaller starts to obviously hurt the quality.

Or ideally test a few values and decide where you think chroma quality is not too damaged and the file isn't too large. This is somewhat source dependent. Also the optimal chroma-qp-offset is probably relative to the average luma quantizer, at high crf values the offset should be lower than at low crf values. Though I tend to encode in the lower range of crf, e.g. 14-18, I just like wasting bits. ;)

Joachim Buambeki
11th September 2016, 20:07
Maybe use -1 or -2 instead of -4. I generally target sizes a bit above the "optimal". Optimal meaning right at that point where any smaller starts to obviously hurt the quality.
Thanks, I will try it out.

BTW: I can only assume but my guess why +6 for the chroma was chosen is that it pretty much represents the same reduction in final bandwidth as a 4:2:0 source with the same CRF would need (if I am not mistaken..) - while providing a better visual fidelity because the quantisation is better than dumb low passing (according the posts from Dark Shikari quoted above.).

benwaggoner
13th September 2016, 12:20
Thanks, I will try it out.

BTW: I can only assume but my guess why +6 for the chroma was chosen is that it pretty much represents the same reduction in final bandwidth as a 4:2:0 source with the same CRF would need (if I am not mistaken..) - while providing a better visual fidelity because the quantisation is better than dumb low passing (according the posts from Dark Shikari quoted above.).
CRF itself is basically QP nudged one way or another some based on frame complexity. So it has the same log properties of QP, where the actual quantization divider doubles. So an offset of -6 would mean double the actual quantization of chroma, which makes sense as you are doubling the chroma resolution. However, I don't know that you'd actually net out as more efficient with a -6 offset. Higher might be needed, because you actually have 4x as many samples. But chroma info is typically lower frequency (excepting the highly artificial test patterns that always get cited as why 4:2:0 subsampling is bad).

On net, I doubt you're going to save more than 2-3% this way, because chroma is already a small fraction of the total bitstream. Luma is 2/3rd the samples in 4:2:0, and chroma gets quantized much more severely.