Please help newbie problem with RGB->YUV conversion

Please help newbie problem with RGB->YUV conversion

Post by Maurizi » Wed, 30 Jul 2003 23:14:37

Hi,i-ve a problem with converting rgb in yuv.
I must convert a rgb image into a yuv 420P image, the problem is that
this conversion only green values is c is converted correctly, blue and
red value are gone,maybe not converted (=my image is all in light
green/dark green).
This is my code:
/* Y */
for(y=0;y<height;y++) {
for(x=0;x<width;x++) {
pict->data[0][y * pict->linesize[0] + x] =
/*U and V*/
for(y=0;y<height/2;y++) {
for(x=0;x<width/2;x++) {
pict->data[1][y * pict->linesize[1] + x] =
pict->data[2][y * pict->linesize[2] + x] =

imagedata is my rgb value and pict->data is my yuv 420P picture.
Please help, sorry for my english.
Thanks in advance.

1. RGB to YUV and YUV to RGB Questions

2. How to find color matrix for YUV->RGB conversion

I'm not sure what you mean by "color matrix" but here is a good site which
summarizes YUV and RGB types:

In dshow, if you look at the video media subtype GUID, the first four bytes
tell you the FourCC.

Here is an overview of conversions:

Please read this before replying:
1. Dshow & posting help:
2. Trim & respond inline (please don't top post or snip everything)
3. Benefit others: follow up if you are helped or you found a solution

3. about conversion from YUV to RGB


5. YUV to RGB conversion

6. YUV/RGB conversion and smooth WMV-HD playback

7. YUV to RGB conversion in OV7620

8. YUV/RGB conversion and smooth WMV-HD playback

9. Top posting vs. bottom posting (was ARM ASM YUV RGB CONVERSION)

10. Relation ship of constants in yuv<->rgb formula's ?

11. RGB -> YUV (MMX)

12. Ask for yuv<->rgb transform matrix used in DirectShow

13. RGB->YUV

14. RGB <> Lab <> RGB