## Friday, November 20, 2009

### Sub-pixel motion vectors in H.264

The offset between the two areas has 1/4 pixel resolution for the luma component, 1/8 pixel resolution for choma component. In following figure, A,B,C… are regular pixels and b,h,m… are half pixle. The half pixle can be calculated with 6 weighted filter, the weight is (1/32, –5/32, 5/8, 5/8, –5/32, 1/32). To get ‘b’:
b = round ((E – 5F + 20G + 20H –5I + J)/32).
We can get ‘h’ from A,C,G,M,R and T. Then ‘j’ can be calculated from cc, dd, h, m, ee, and ff.

After 1/2 subpixel is calculated, we can get 1/4 subpixle with interpolation. In following figure, a,c,i,k,d,f,n,q are from interpolation. For instance:
a = round((G + b) / 2)

The other 1/4 sub-pixel (p, r…) can be calculated from  diagonal pixels. For instance, e is from b and h.

1/8 sub-pixel is required in choma motion vector component. It also uses linear interpolation.
a=round(( (8-dx)*(8-dy)*A + (8-dy)*B + (8-dx)*dy*C + dx*dy*D) / 64)