Block partitioning
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.
- In this picture the small blocks collect on the kite. At lambda 32 there are 97 blocks: 48 are 4×4, on the kite and the top of its string. The rest are 48 of 8×8, which is enough for most of the thin string, and one 16×16 in the lower left.
- The weight on a bit decides the cut. At lambda 1 the demo uses 256 blocks, all 4×4, and 4,181 modeled bits for a mean squared error of 67.3. At lambda 4,096 it uses 10 blocks and 173 bits, and the error is 185.8. Nothing about the picture changed.
- Merging the sky costs almost nothing. From lambda 1 to 32 the block count falls from 256 to 97 and the error only moves from 67.3 to 70.5. A flat value already fitted those blocks, so splitting them reduced the error only slightly for the added modeled bits.
What the codecs allow
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:
| Setting | Medium preset | Other presets |
|---|---|---|
--ctu | 64 | 32 in the two fastest |
--min-cu-size | 8 | 16 in ultrafast |
--rect | off | on from slow |
--amp | off | on 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
- Smaller partitions can need more signaling. How much depends on what is coded, since modes and vectors can be predicted or inferred. The demo's fixed charge isolates the trade-off: small blocks are worth their bits only where they remove more error than they cost.
- The search multiplies. Each allowed shape is more candidates per block, each with its own motion search. Encoders prune, and a preset sets how much is searched along with other tools.
- Block edges are where predictions change. Neighboring predictions can differ along a shared edge. Residual coding can correct the mismatch; error that remains can show as a visible block boundary. Filtering it is a later unit, In-loop filters.
- Large blocks pay off where one prediction describes the region well. A detailed region that moves as one piece can be one large block; a smooth-looking one holding two motions cannot. How often one prediction fits a 64×64 block, the area of 16 macroblocks, depends on resolution and content, and is not measured here.
Sources
Read 2026-11-13, at the commits linked.
- x264 at commit c24e06c (GitHub mirror): the default partitions, how
--partitionsis read, the presets,p4x4dropped withoutp8x8, the order of the partition search in a predicted frame. - x265 at commit 4191822: the defaults, the presets, the allowed sizes, the partition shapes, where
--rectand--ampadd candidates. - Not checked: the H.264 and HEVC specifications, how x265 searches its tree, partitions in bidirectional frames, and AV1. The trade-offs are general reasoning, not measurements.