encoding.info
You are hereSourcePredictionTransformEntropy codingFiltersFramesDecisionsRate controlPerceptionQualityBitstreamSettingsEncoder map
Page 4 of 5 in Prediction

Block partitioning

Prediction · concept · added 2026-11-13

In Brief:
A frame is predicted in blocks, and the encoder chooses their sizes. Large blocks can need less signaling; small ones let neighboring areas be predicted differently. The choice weighs prediction error against coding cost.

A frame is not predicted in one piece. It is divided into blocks, and each region that shares a prediction gets its own intra mode or its own motion vector. Block partitioning is the choice of those regions. Larger regions can need less signaling; smaller ones can use different predictions where a single prediction fits poorly, and each one comes with its own paperwork. The choice turns on prediction error and coding cost, not only on the edges you can see.

Try pricing the paperwork

A kite against a clear sky, 64×64 pixels. The demo approximates each block by one flat value, the mean of its own source pixels, and charges a fixed number of modeled bits per block. That is not a codec's prediction, which has to be built from samples the decoder already holds; the demo keeps only the trade-off between a closer fit and more description. Starting from the 4×4 blocks, it merges four blocks into one wherever that lowers

model cost = squared error of the approximation + lambda × modeled description bits

Lambda weights bits against error. It plays the same role as lambda in Rate-distortion optimization, but its values here belong to this demo and are not encoder settings. Raise it and watch which regions merge first. The residual panel is mid-gray where the approximation is exact.

← bits are cheapbits are expensive →
Source
Approximation
Residual, ×2
Blocks
Modeled side bits
Mean squared error
Simplified demo: the picture is invented. The approximation (one flat value per block, its source mean) and the price list are invented too: 16 bits per block, plus 1 bit for the split-or-not decision at every block larger than 4×4; a 4×4 block cannot split, so it has no such bit. The demo does not code the mean, or transform and code the residual, so its bits are not an encoded size and its error is not the error of a decoded picture. Block sizes run from 64×64 down to 4×4 by repeated splitting into four. Mean squared error uses the unrounded means; the panels show rounded pixels, and residual grays are amplified two times and clipped to the display range.

What the codecs allow

16×1616×88×168×8 8×88×44×84×4 One macroblock Each 8×8 quarter
The motion partitions of H.264 for a macroblock in a predicted (P) frame, as x264 implements them. A 16×16 macroblock is kept whole, halved either way, or quartered. If quartered, each quarter picks one of the four shapes on the right for itself.

High Efficiency Video Coding (HEVC) replaces the fixed macroblock with a coding tree unit (CTU) of up to 64×64, which is split into four again and again to form coding units; x265's smallest coding unit is 8×8 by default. Prediction partitions are chosen inside each coding unit, and transform blocks are a third structure. The demo's plain quadtree down to 4×4 does not reproduce those rules. The x265 settings that bound the tree:

SettingMedium presetOther presets
--ctu6432 in the two fastest
--min-cu-size816 in ultrafast
--rectoffon from slow
--ampoffon from slower

In x265, --rect lets a coding unit be predicted as two equal halves, and --amp as two unequal parts, one a quarter of the unit and the other three quarters. Neither changes the tree of square coding units.

x264's --partitions is p8x8,b8x8,i8x8,i4x4 in the medium preset. p8x8 switches on all three ways of dividing a macroblock in a predicted frame, not only the quarters, and p4x4 switches on the three ways of dividing a quarter; p4x4 is ignored without p8x8. The slower preset and those after it add p4x4; ultrafast switches off every partition search that --partitions controls.

x264 does not try every shape. It searches 16×16 first, then the quarters, then looks inside a quarter or at the halves only if the costs so far suggest it could pay. The shape used for the transform is a separate choice: see Choosing a transform size.

Trade-offs

Sources

Read 2026-11-13, at the commits linked.