encoding.info
You are hereSourcePredictionTransformEntropy codingFiltersFramesDecisionsRate controlPerceptionQualityBitstreamSettingsEncoder map
Page 1 of 4 in Frame structure

Intra, predicted and bidirectional frames

Frame structure · concept · added 2026-11-15

In Brief:
An intra frame predicts only within its own picture. A predicted frame's blocks may also use a frame decoded earlier, and a bidirectional frame's blocks may combine two such predictions. References are decoded first, so the decoding order can differ from the order frames are shown in.

A frame can be predicted in three ways, and each way gives the frame a type. An intra (I) frame uses only pixels of its own picture. In a predicted (P) frame a block may also be predicted from a frame decoded before it. In a bidirectional (B) frame a block may also combine two such predictions, often one from a frame shown before it and one from a frame shown after it. The types differ in how much is left to code and in what a decoder must already have.

Three types, two orders

Display order
IBBP 1234
Coded order
IPBB 1423
coral box: I frame gray box: P frame teal boxes: B frames small numbers: place in display order
Conceptual illustration. Each arrow runs from a frame to a frame it is predicted from: arrows to the later P frame pass above the boxes, arrows to the earlier I frame below. These B frames need the P frame that follows them on screen, so that P frame is coded first and the decoder holds it until its turn to be shown.

The names describe what a frame is allowed to use, not what every block does. A block in a P or B frame can still be coded as intra when nothing in the references matches it, and a block in a B frame can use a single prediction. Blocks of one frame can also use different references. x264 sets a slice type from each frame's type; this page uses I, P and B as names for whole frames.

Code one frame three ways

The cat walks a third of a pixel per frame. The demo codes frame 13 of the walk at quantization parameter (QP) 28, three ways. Intra predicts each 4×4 block from the reconstructed pixels above and to its left. P copies the block from the frame Distance frames earlier. B takes, block by block, the earlier frame, the frame the same distance later, or their average, whichever has the smallest sum of absolute differences from the source. Neither P nor B falls back to intra here, as a real encoder's blocks can. There is no motion search, so a reference further away is a worse match. Type chooses the frame shown in the four pictures; the table always lists all three types at the chosen Distance. It counts nonzero levels, the integers left after quantization, and gives the error: the mean squared error of the reconstruction against the source, in squared 8-bit levels.

1
← 1: the neighboring frame4 frames away →
Source
Prediction
Residual
Reconstructed
TypeNonzero levelsError
Intra (I)
Predicted (P)
Bidirectional (B)
Nonzero levels
Error
Past, future, both
Simplified demo: the cat and its motion are invented, and the transform is a floating-point 4×4 cosine transform at the nominal H.264 step for QP 28. The intra prediction is one invented mode (a block average of its neighbors); real encoders choose among many. The references are the neighboring frames coded as intra frames at the same QP. In the Residual panel mid-gray is zero. "Past, future, both" counts how many of the 64 blocks took each choice. A count of nonzero levels is not a bitrate: it leaves out motion vectors, block types and the size of each level.

For this cat at QP 28:

The types in x264

x264 normally keeps I and P frames as references for later frames and marks an ordinary B frame as disposable: nothing is predicted from it. Leaving such a frame out takes no reference away from another frame, but it does remove a moment from what is shown. --bframes sets the most B frames x264 will place in a row, 3 by default; the lookahead decides how many to use at each point. The ultrafast preset, the zerolatency tuning and the Baseline profile set it to 0, veryslow uses 8 and placebo 16. x265's default is 4. B frames that are kept as references are the subject of Hierarchical B-frames.

Trade-offs

Sources

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