wrong colors with Xv extension and image format id: 0x59565955 (UYVY) from an rgb mapping

Tomas Carnecky tom at dbservice.com
Thu Jan 22 02:12:20 PST 2009


On 01/22/2009 06:15 AM, Amos Tibaldi wrote:
>
> Hello,
> I am trying to use the Xv extension in order to display images on
> windows. I have obtained the image formats with
> xvc.fo <http://xvc.fo> = XvListImageFormats( xvc.display, xvc.port, (int
> *)&formats );
> and I have chosen the format
> id: 0x59565955 (UYVY)
> guid: 55595659-0000-0010-8000-00aa00389b71
> bits per pixel: 16
> number of planes: 1
> type: YUV (packed)

[snip]

> and to display the image with
> void XVWindow::Redraw()
> {
> unsigned short int u, y, v;
> RGBToUYVY(255,255,0,&u,&y,&v);
> unsigned short int thecolor = u << 12 | y << 8 | v << 4 | y;
>
> for ( int y=0; y<ImageHeight; y++ )
> for ( int x=0; x<ImageWidth; x++ )
> ((unsigned short int *)BGimage->data)[ y * ImageWidth + x ] = thecolor;
>
> counter++;
> XvPutImage( xvc.display, xvc.port, window, gc,
> BGimage, 0, 0, ImageWidth, ImageHeight,
> 0, 0, WindowWidth, WindowHeight );
> }

I think you are confused by 'bits per pixel: 16' in the Xv format list. 
Your code in :Redraw() that composes the pixel is wrong. I know I 
couldn't explain it better, so I'm including a link to a website that 
explains it pretty well:
http://www.fourcc.org/yuv.php#YUY2
(Each macropixel is 32 bits, so each of the YUV components is 8 bit and 
not 4 like you used in your code)

tom





More information about the xorg mailing list