AIC - Block Prediction Implementation Details
This page describes some implementation details for the Block Prediction algorithms implemented in the Advanced Image Coding software.
Let P[x,y] be the block to be predicted, x and y ranging from 0..7.
Let S[x,y] be the source image to predict from, where S[0,0] is anchored at
the current (prediction) position in the image. The source image contains the
previously decoded blocks.
All positions in block P, for x, y = 0..7 are predicted according to one of
the 9 prediction modes:
![]() |
Mode 0: Vertical P[x,y] = S[x,-1] |
![]() |
Mode 1: Horizontal P[x,y] = S[-1,y] |
![]() |
Mode 2: DC P[x,y] = (Sum(S[0..7,-1]) + Sum(S[-1,0..7]) + 8) / 16 If the upper samples are not available, only the left samples are used: P[x,y] = (Sum(S[-1,0..7]) + 4) / 8 If the left samples are not available, only the upper samples are used: P[x,y] = (Sum(S[0..7,-1]) + 4) / 8 If both left and upper samples are not available (first block in image), the value 128 is used (50% gray): P[x,y] = 128 |
![]() ![]() |
Mode 3: Diagonal Down-Left P[7,7] = (S[14,-1] + 3 * S[15,-1] + 2) / 4 For all other pixels, the predicted value is the weighted average of three successive pixels on the top row: P[x,y] = (S[x+y,-1] + 2 * S[x+y+1,-1] + S[x+y+2,-1] + 2) / 4 |
![]() ![]() |
Mode 4: Diagonal Down-Right P[x,y] = (S[-1,0] + 2 * S[-1,-1] + S[0,-1] + 2) / 4 For the pixels in the bottom-left triangle (x<y, the green cells), the predicted value is the weighted average of three pixels on the left column: P[x,y] = (S[-1,y-x-2] + 2 * S[-1,y-x-1] + S[-1,y-x] + 2) / 4 For all other pixels (x>y, the red cells), the predicted value is the weighted average of three pixels on the top row: P[x,y] = (S[x-y-2,-1] + 2 * S[x-y-1,-1] + S[x-y,-1] + 2) / 4 |
![]() ![]() |
Mode 5: Vertical-Right P[x,y] = (S[x-(y/2)-1,-1] + S[x-(y/2),-1] + 1) / 2 For positive odd values of z (the yellow cells), the predicted value is the weighted average of three pixels on the top row: P[x,y] = (S[x-(y/2)-2,-1] + 2 * S[x-(y/2)-1,-1] + S[x-(y/2),-1] + 2) / 4 For z = -1 (the blue cells), the predicted value is the weighted average of the three top-left pixels: P[x,y] = (S[-1,0] + 2 * S[-1,-1] + S[0,-1] + 2) / 4 For all other values of z (the green cells), the predicted value is the weighted average of three pixels on the left column: P[x,y] = (S[-1,y-x-1] + 2 * S[-1,y-x-2] + S[-1,y-x-3] + 2) / 4 |
![]() ![]() |
Mode 6: Horizontal-Down P[x,y] = (S[-1,y-(x/2)-1] + S[-1,y-(x/2)] + 1) / 2 For positive odd values of z (the yellow cells), the predicted value is the weighted average of three pixels on the left column: P[x,y] = (S[-1,y-(x/2)-2] + 2 * S[-1,y-(x/2)-1] + S[-1,y-(x/2)] + 2) / 4 For z = -1 (the blue cells), the predicted value is the weighted average of the three top-left pixels: P[x,y] = (S[-1,0] + 2 * S[-1,-1] + S[0,-1] + 2) / 4 For all other values of z (the green cells), the predicted value is the weighted average of three pixels on the top row: P[x,y] = (S[x-y-1,-1] + 2 * S[x-y-2,-1] + S[x-y-3,-1] + 2) / 4 |
|
Mode 7: Vertical-Left P[x,y] = (S[x+(y/2),-1] + 2 * S[x+(y/2)+1,-1] + S[x+(y/2)+2,-1] + 2) / 4 For the even rows (the green cells), the predicted value is the average of two pixels on the top row: P[x,y] = (S[x+(y/2),-1] + S[x+(y/2)+1,-1] + 1) / 2 |
![]() ![]() |
Mode 8: Horizontal-Up P[x,y] = (S[-1,y+(x/2)] + S[-1,y+(x/2)+1] + 1) / 2 For all odd values of z below 12 (the yellow cells), the predicted value is the weighted average of three pixels on the left column: P[x,y] = (S[-1,y+(x/2)] + 2 * S[-1,y+(x/2)+1] + S[-1,y+(x/2)+2] + 2) / 4 For z=13 (the blue cells), the predicted value is the weighted average of the two left bottommost pixels: P[x,y] = (S[-1,6] + 3 * S[-1,7] + 2) / 4 For all other values of z (the green cells), the predicted value is equal to the left bottommost pixel: P[x,y] = S[-1,7] |