Intra-frame (spatial) prediction
One of the main innovations of AVC is the introduction of intra-frame (within a frame) prediction. Intra-prediction as it is more commonly known, is used where inter-prediction cannot be used, namely on the I frame. It is applied to all three components: Y, CR and CB. Intra-prediction makes use of the fact that adjacent blocks within a single frame display a degree of similarities. A block is predicted using data of previously scanned block or blocks of the same frame.
Intra-blocks and modes
For the luminance samples, intra-prediction may be carried on each 4 X 4 sub-block or for a 16 X 16 macroblock. The process involves copying pixel values of previously coded blocks (sub-blocks or macroblocks) into the current block. Since block coding is performed in a raster scan order (left to right, top to bottom); the previously encoded blocks used for intra- prediction are those above and to the left of the block being predicted as illustrated in Figure 5.1, namely:
● the lower pixel row of the block immediately above: A, B, C, D;
● the left pixel column of the block immediately to the left: I, J, K, L;
● the lower pixel row of the block above and to the right: E, F, G, H;
● lower right pixel of the block above and to the left (M).
There are a total of nine prediction modes for each 4 X 4 luma block; four modes for a 16 X 16 luma block; and one mode that is always applied to each 4 X 4 chroma block. For example 4 X 4 luma Mode 0 (vertical) copies
lower pixel line of block above (A B C D) to all pixel lines in current block as shown in Figure 5.2. This mode may be used in a picture with a left to right gradient (Figure 5.3).
Mode 1 (horizontal) copies the rightmost column of the block to the left (I J K L) suitable for a picture with a left to right gradient (Figure 5.4).
In Mode 2 (DC or average) Pixels values of previous blocks A B C D E F G H I J K L are averaged and the average (DC) value is copied in all 16 locations of the predicted block as illustrated in Figure 5.5 where P is the calculated average.
The other modes are: Mode 3 (diagonal down-left); Mode 4 (diagonal down-right); Mode 5 (vertical-right); Mode 6 (horizontal-down); Mode 7 (vertical-left) and Mode 8 (horizontal-up).
For a 16 X 16 block, only four modes are available: vertical (mode 0), horizontal (mode 1), DC (mode 2) and plane. Plane mode is a refinement to the DC mode which looks for change in the horizontal brightness in the top row and left column to work out the average value.