求高手给一个c语言yuv420转rgb24的函数
谢谢了 最好能给个调用方法
下面这个程序是从网上找的 不过好像转了之后结果不对:
void YUV420toRGB24(unsigned char *src0,unsigned char *src1,unsigned char *src2, unsigned char *rgb24, int width, int height)
{
int R,G,B,Y,U,V;
int x,y;
int nWidth = width>>1; //色度信号宽度
for (y=0;y<height;y++)
{
for (x=0;x<width;x++)
{
Y = *(src0 + y*width + x);
U = *(src1 + ((y>>1)*nWidth) + (x>>1));
V = *(src2 + ((y>>1)*nWidth) + (x>>1));
R = Y + 1.402*(V-128);
G = Y - 0.34414*(U-128) - 0.71414*(V-128);
B = Y + 1.772*(U-128);
//防止越界
if (R>255)
R=255;
if (R<0)
R=0;
if (G>255)
G=255;
if (G<0)
G=0;
if (B>255)
B=255;
if (B<0)
B=0;
*(rgb24 + ((height-y-1)*width + x)*3) = B;
*(rgb24 + ((height-y-1)*width + x)*3 + 1) = G;
*(rgb24 + ((height-y-1)*width + x)*3 + 2) = R;
// *(rgb24 + (y*width + x)*3) = B;
// *(rgb24 + (y*width + x)*3 + 1) = G;
// *(rgb24 + (y*width + x)*3 + 2) = R;
}
}
}
c yuv420 rgb24
[解决办法]
http://linfengdu.blog.163.com/blog/static/11771073201032802654678/
看这个能不能用