void yuv420_to_rgb24(unsigned char *pdata, int stride, int width, int height, unsigned char *pdst)
{
const unsigned char *Y, *U, *V;
unsigned char *RGB;
int x, y;
if (stride < 0) {
Y = pdata - stride * (height - 1);
U = pdata - (stride / 2) * (height * 5 / 2 - 1);
V = pdata - (stride / 2) * (height * 3 - 1);
} else {
Y = pdata;
U = pdata + stride * height;
V = pdata + stride * height * 5 / 4;
}
RGB = pdst;
for(y=0; y<height/2; y++)
{
unsigned char *pDst1 = RGB;
unsigned char *pDst2 = RGB+width*3;
const unsigned char *pYSrc1 = Y;
const unsigned char *pYSrc2 = Y + stride;
for(x=0; x<width/2; x++)
{
const int Uo = U[x]-128;
const int Vo = V[x]-128;
const int Ro = (91181*Uo)>>16;
const int Go = (22553*Vo + 46801*Uo)>>16;
const int Bo = (116129*Vo)>>16;
TO_RGB24(pDst1, pYSrc1)
pDst1 +=6;
pYSrc1+=2;
TO_RGB24(pDst2, pYSrc2)
pDst2 +=6;
pYSrc2+=2;
}
RGB += width*6;
Y += 2*stride;
U += stride/2;
V += stride/2;
}
}