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

Intra prediction

Prediction · concept · added 2026-11-13

In Brief:
Intra prediction estimates a block from reconstructed pixels of the same picture, mostly the row above it and the column to its left. The encoder names the mode it used and codes what the prediction missed.

Intra prediction estimates a block from samples of the same picture that are already reconstructed, mostly the row above it and the column to its left. The difference between the source and the prediction is the residual, which is what usually goes on to the transform. The encoder names the mode it used and codes the residual. It is the encoder copying its neighbor's homework, which is allowed here because the decoder sits next to the same neighbor.

Which samples a mode may read

The decoder has to form the identical prediction, so a mode may read only samples the decoder already holds in reconstructed form. Those mostly lie above and to the left. Some modes reach further along the same edges: two of x264's nine 4×4 modes read above and to the right, and x265's planar mode reads one sample above-right and one below-left. Where a neighbor is missing, as at a picture edge, the codec substitutes: x264's average mode has versions for a missing top, a missing left, or both. Every intra mode is a rule for extending the available edge samples across the block.

? Vertical Horizontal Average
Conceptual illustration. Tinted samples are already reconstructed; the dashed areas are not yet coded. Three of the simplest rules: copy the row above downward, copy the left column across, or fill the block with the average of both.

Try the modes

Pick a block and a mode. In the Source and Prediction panels the samples outside the teal line are the neighbors; the Prediction panel fades those the chosen mode does not read. The demo uses source samples as neighbors and assumes all of them are available; a real encoder uses reconstructed neighbors, which can already carry coding error. The residual panel is mid-gray where the prediction is exact and lighter where the source is brighter. The score is the sum of absolute differences (SAD): the absolute difference between each source sample and its prediction, added up.

Source
Prediction
Residual, ×2
SAD, chosen mode
Lowest SAD of the five
Mode with the lowest
Simplified demo: the five blocks are invented. These are five teaching rules modeled on codec intra modes, not the mode set or the exact arithmetic of either codec. The neighbors are not smoothed first. The diagonal rule copies neighbors without interpolating between them. Planar blends the two edges toward the above-right and below-left samples, which are the extra samples drawn past each end of the border; it follows the planar mode of High Efficiency Video Coding (HEVC), and the plane mode of H.264 is a different rule. Codecs call the average mode DC, after the constant component of a transform. Scores use unrounded predictions; the panels show rounded pixels. Residual grays are amplified two times and clipped to the display range; scores use the full differences.

A low SAD is a ranking score, not a bit count: the demo counts no bits for naming the mode or for coding the residual. More on Distortion measures.

Intra modes in x264

x264 has nine modes for 4×4 and 8×8 luma blocks (vertical, horizontal, average and six diagonals) and four for 16×16 luma and for chroma (vertical, horizontal, average and plane). Its fast ranking scores each mode as a distortion measure plus an estimated cost for naming the mode. The mode itself is predicted: for a 4×4 block the expected mode is the smaller-numbered of the modes used to the left and above, or the average mode when either is unavailable, and any other mode adds 3 × lambda to the score. Lambda is the weight x264 puts on a bit; see Rate-distortion optimization. The 3 is the extra bits x264's variable-length coder writes for an unexpected mode; the arithmetic coder's cost is not fixed. It is a ranking estimate: from --subme 6 the leaders are compared again by reconstruction-based cost. --partitions selects which block sizes are tried; i8x8 is dropped when the 8×8 transform is off.

CodecBlockModes
H.264 (x264)4×4, 8×8 luma9
H.264 (x264)16×16 luma, 4:2:0 chroma4
HEVC (x265)luma35

The 35 in x265 are planar, average and 33 directions. Block sizes per codec are on Block partitioning.

Trade-offs

Sources

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