encoding.info
You are hereSourcePredictionTransformEntropy codingFiltersFramesDecisionsRate controlPerceptionQualityBitstreamSettingsEncoder map
Page 4 of 4 in Rate control

Quantizer compression and frame-type offsets

Rate control · concept · added 2026-11-15

In Brief:
Quantizer compression controls how strongly a frame's base quantizer responds to its complexity. Frame-type adjustments can favor the frames that help predict others. What both do depends on the rate control mode and on tools such as macroblock-tree.

Inside whatever target a rate control mode sets, two further choices decide which frames get the bits. Quantizer compression says how far the quantization parameter (QP) follows a frame's complexity. Frame-type offsets give I, P and B frames different QPs on purpose, because a better reference can lower the cost of the frames predicted from it.

Two rules

This is x264's baseline path, with macroblock-tree off; with it on, which is the default, both rules change, as the list further down says. x264 sets a frame's quantizer scale, which doubles every 6 QP, from its complexity:

scale = complexity^(1 - qcomp)
        / rate factor

With --qcomp at 1 the exponent is 0 and the base level stops following complexity; the frame types still differ. At 0 the scale is proportional to complexity, which makes frames of one type nearly equal in size. The default of 0.6 sits between.

The frame types are then spread around that level. An I frame's scale comes from a running average of recent P frames' QP, divided by --ipratio; the default 1.4 is 2.9 QP lower. A B frame between two P frames gets their QPs averaged by distance, plus an offset from --pbratio; the default 1.3 is 2.3 QP higher. When one of its neighbors is an I frame it starts from the other's QP. A B frame that is itself a reference gets half that offset.

Move the three settings

The sequence is this unit's: quiet, busy, in between, coded at a constant rate factor of 26. Here it has frame types: an I frame where each section starts, then P, B, B repeating. In the upper plot the gray line is the P frames' QP, the teal line the B frames', and the coral dots the three I frames. The lower plot is the size of each P and B frame.

0.6
← 0: flatter sizes1: flat base quantizer →
1.4
← 1: I frames like P2: I frames 6 QP finer →
1.3
← 1: B frames like P2: B frames 6 QP coarser →
I framesP framesB frames

QP of I, P, B
Bits to I, P, B
Average, kbit/s
Simplified demo: complexities are invented, and a frame's size is modeled as 1.25 × complexity ÷ scale^1.1 kilobits, times an invented 3 for an I frame, 1 for a P frame and 0.5 for a B frame. The conversion from scale to QP and the two ratio offsets follow x264; the choice of base level and the frame sizes are simplified, with macroblock-tree off and no reference B frames. "QP of I, P, B" is the average in the last section. An I frame takes its level from the short-term average of complexity where it stands, which at a change of scene still reflects the frames before it; x264 takes a running average of recent P frames' QP. A B frame's QP is always interpolated between the P levels on either side, where x264 uses the other neighbor's QP when one neighbor is an I frame. The bit shares come from the invented size multipliers: the model does not simulate how a better reference changes later residuals. The lower plot leaves the three I frames out so the rest can be read. The demo cannot show whether any setting makes the video look better.

For this sequence at rate factor 26:

In x264

--qcomp is 0.6, --ipratio 1.4 and --pbratio 1.3 by default. With macroblock-tree on, which is the default, neither rule above is applied as described: x264 sets the B ratio to 1, and --qcomp sets the strength of macroblock-tree instead.

The grain tuning, macroblock-tree and constant quantizer

Trade-offs

Sources

Read 2026-11-15, at the commit linked.