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

Thread Tools Search this Thread Display Modes
Old 11th January 2024, 18:30   #1  |  Link
Registered User
hellgauss's Avatar
Join Date: Sep 2002
Location: Italy
Posts: 94
What is the rationale in negative chroma_qp_offset?

I'm doing some tests in x264 8bit, -veryslow presets to encode anime at low bitrates. As known, the most annoyng issue is the poor gradient encode, especially in dark areas. This post is to share results and accept eventually critique and comments from experienced users.

Together with the aq-mode 3, which seems to give a (very) little help at same bitrate, it seems to me that the option -chroma_qp_offset 1 gives some further help, to the point that I think I will use it as a "default" option for my encodes.

Default value for chroma_qp_offset is -2 (-3 if the second psy-rd parameter is not zero). As I understood, it is a sort of offset for the quantizer of chroma channels with respect to luma, i.e. more bitrate given to chroma if <0 . With the option -chroma_qp_offset 1 this value becomes -1. The result is a smaller file size at constant -crf, which can be used to lower the bitrate or to decrease the -crf. Higher values still lower the bitrate, but to a lesser extent, so I do not go further than 1.

Considering that
1) One of the major point of video encode is to degrade the chrominance e.g. it is stored at half the resolution. Even some filters, such as sws bicublin resize, is tuned to keep details in the luma channel. I never heard of a bilincubic resize.
2) It seems to me that most of the annoying block/band in dark gradients are in the luma channel. I think it is a psychovisual effect, or perhaps in dark zones the chrominance does not matter too much.

My questions are

What is the rationale of a default negative chroma_qp_offset? Why give higher bitrate to chroma? Do you use the option -chroma_qp_offset 1 in your encodes? Is my interpretation correct?

Thanks for replies
hellgauss is offline   Reply With Quote
Old 11th January 2024, 19:19   #2  |  Link
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,817
The values adjust the relative qp of chroma versus luma in the encode. Positive offset values will increase chroma QP, reducing chroma bitrate and quality. Negative values will decrease chroma QP, increasing chroma bitrate and quality.

Chroma only gets a minority of the bits in a normal encode anyway (due to subsampling and differently optimized quant/lambda tables), but certainly bits saved from chroma could improve luma, including gradients, when VBV limited. But most of the time it's going to be a small impact at best, with high risk of side effects.

Messing with chroma QP requires careful subjective evaluation, as metrics like SSIM and VMAF are luma only. Setting chroma QP offsets to -6 will score higher in metrics but may look awful. The defaults are empirically based on subjective evaluation and good defaults for most content.

I've never used positive values in practice. I've used negative values with x265 when doing HDR encoding for content with colorful grain.
Ben Waggoner
Principal Video Specialist, Amazon Prime Video

My Compression Book
benwaggoner is offline   Reply With Quote
Old 11th January 2024, 21:07   #3  |  Link
Registered User
Join Date: Jul 2007
Posts: 552
Have you read comments in x264 source code?
MasterNobody is offline   Reply With Quote
Old 12th January 2024, 20:23   #4  |  Link
Registered User
hellgauss's Avatar
Join Date: Sep 2002
Location: Italy
Posts: 94
Thanks Masternobody for the highlighted comment (and following ones). It all make sense. Perhaps i get advantages from the +1 chroma offset because I use the -tune animation presets, which is a quite soft psy-rd.
hellgauss is offline   Reply With Quote
Old 15th January 2024, 22:33   #5  |  Link
Big Bit Savings Now !
Emulgator's Avatar
Join Date: Feb 2007
Location: close to the wall
Posts: 1,590
It would boil down to trying.
If the gradient step exists in luma, you may only earn a few bits by hurting chroma.
IIRC as I tested it back then, TAW5 used qpoffset -2 on x264 for a Blu-ray preset and fared very well with natural content.

Maybe a no-go for clean anime lovers, but I thought I should mention it:
Don't try to save too hard, the encoder will follow your rule and: save hard.
From the moment I was tickling the x264 encoder with a bit added grain it won't try to save that hard in all places anymore.
Just decide to spend some bits on the worst thing: added grain/noise and you earn quality, also in dark areas.
(HF BIAS on magnetic tape did work wonders as well: finally a workaround to carve a perfect shape into a nonlinear responding material)
"To bypass shortcuts and find suffering...is called QUALity" (Die toten Augen von Friedrichshain)
"Data reduction ? Yep, Sir. We're that issue working on. Synce invntoin uf lingöage..."

Last edited by Emulgator; 21st January 2024 at 11:56.
Emulgator is offline   Reply With Quote

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 22:27.

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