This is how the pixels are placed for 4:2:0 and 4:2:2 (normally)
This is the correct way to interpolate chroma between 4:2:2 and 4:2:0 (luma is already at correct resolution)
Code can be downloaded from http://www.mpeg.org/MPEG/video/mssg-free-mpeg-software.html
Code below from file readpic.c
/* vertical filter and 2:1 subsampling */
static void conv422to420(src,dst)
unsigned char *src, *dst;
{
int w, i, j, jm6, jm5, jm4, jm3, jm2, jm1;
int jp1, jp2, jp3, jp4, jp5, jp6;
w = width>>1;
if (prog_frame)
{
/* intra frame */
for (i=0; i<w; i++)
{
for (j=0; j<height; j+=2)
{
jm5 = (j<5) ? 0 : j-5;
jm4 = (j<4) ? 0 : j-4;
jm3 = (j<3) ? 0 : j-3;
jm2 = (j<2) ? 0 : j-2;
jm1 = (j<1) ? 0 : j-1;
jp1 = (j<height-1) ? j+1 : height-1;
jp2 = (j<height-2) ? j+2 : height-1;
jp3 = (j<height-3) ? j+3 : height-1;
jp4 = (j<height-4) ? j+4 : height-1;
jp5 = (j<height-5) ? j+5 : height-1;
jp6 = (j<height-5) ? j+6 : height-1;
/* FIR filter with 0.5 sample interval phase shift */
dst[w*(j>>1)] = clp[(int)(228*(src[w*j]+src[w*jp1])
+70*(src[w*jm1]+src[w*jp2])
-37*(src[w*jm2]+src[w*jp3])
-21*(src[w*jm3]+src[w*jp4])
+11*(src[w*jm4]+src[w*jp5])
+ 5*(src[w*jm5]+src[w*jp6])+256)>>9];
}
src++;
dst++;
}
}
}
Hope it helps.