Hi,
I'm trying to convert yuv420p to rgb24 myself, could some one please
tell me what am I doing wrong ? here's the code I have so far ( I got
all the equations from wikipedia ) thanks.
void yuv2rgb(AVPicture *src, PixelFormat src_pix_fmt, AVPicture *dst,
PixelFormat dst_pix_fmt, int width, int height)
{
unsigned char y, u,v;
char *rgb = dst->data[0];
unsigned char *yptr = src->data[0];
unsigned char *uptr = src->data[1];
unsigned char *vptr = src->data[2];
int length = width * height;
for( int i = 0; i < length; i++ )
{
y = yptr[ i ];
u = uptr[ i / 4 ];
v = vptr[ i / 4 ];
//I tried both they don't worl
//rgb[ 3 * i ] = 1.164f * (y - 16) + 1.596f * (v - 128);
//rgb[ 3 * i+1] = 1.164f * (y - 16) - 0.813f * (v - 128) -
0.391f * (u - 128);
//rgb[ 3 * i+2] = 1.164f * (y - 16) + 2.018f * (u - 128);
rgb[ 3 * i] = y + 1.140 * v;
rgb[ 3 * i+1] = y - 0.395 *u - 0.581 *v;
rgb[ 3 * i+2] = y + 2.032 * u;
}
}
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user