wrong colors with Xv extension and image format id: 0x59565955 (UYVY) from an rgb mapping
Simon Farnsworth
simon.farnsworth at onelan.co.uk
Thu Jan 22 02:49:16 PST 2009
Amos Tibaldi wrote:
> unsigned short int thecolor = u << 12 | y << 8 | v << 4 | y;
>
This is completely wrong. In a UYVY image, you have two different 8-bit
Y components, sharing an 8-bit U component, and an 8-bit V component. In
pseudocode, creating a 32-bit UYVY pixel pair from two RGB pixels:
(y, u, v) RGBtoYUV( r, g, b )
{
y = 0.299 * r +
0.587 * g +
0.114 * b;
u = -0.147 * r +
-0.289 * g +
0.436 * b;
v = 0.615 * r +
-0.515 * g +
-0.100 * b;
}
uyvy RGBtoUYUV( r1, g1, b1, r2, g2, b2 )
{
(y1,u1,v1) = RGBtoYUV( r1, g1, b1 )
(y2,u2,v2) = RGBtoYUV( r2, g2, b2 )
u = (u1 + u2) / 2; // Or other decimation strategy
v = (v1 + v2) / 2; // Or other decimation strategy
uyvy = 8bits(u) << 24;
uyvy |= 8bits(y1) << 16;
uyvy |= 8bits(v) << 8;
uyvy |= 8bits(y2);
}
--
Simon Farnsworth
More information about the xorg
mailing list