FW: Error in V4L2 API Spec Chapter 2.2 Rev 0.24??
- Date: Tue, 16 Feb 2010 09:35:02 +0000
- From: "Owen O' Hehir" <oo_hehir@xxxxxxxxxxx>
- Subject: FW: Error in V4L2 API Spec Chapter 2.2 Rev 0.24??
I've been using your V4L2 API spec and think I've come across an error you may wish to know about. Its the conversion routine from YCbCr -> RGB (Inverse Transformation) Chapter 2.2. As far as I can make out there's no need for the multiplying by 255 at the end. I've run both functions back to back and the image is only correct when these are removed. (Highlighted below).
int Y1, Cb, Cr; /* gamma pre-corrected input [0;255] */
int ER, EG, EB; /* output [0;255] */
double r, g, b; /* temporaries */
double y1, pb, pr;
clamp (double x)
int r = x; /* round to nearest */
if (r < 0) return 0;
else if (r > 255) return 255;
else return r;
y1 = (255 / 219.0) * (Y1 - 16);
pb = (255 / 224.0) * (Cb - 128);
pr = (255 / 224.0) * (Cr - 128);
r = 1.0 * y1 + 0 * pb + 1.402 * pr;
g = 1.0 * y1 - 0.344 * pb - 0.714 * pr;
b = 1.0 * y1 + 1.772 * pb + 0 * pr;
ER = clamp (r * 255); /* [ok? one should prob. limit y1,pb,pr] */
EG = clamp (g * 255);
EB = clamp (b * 255);
Hotmail: Powerful Free email with security by Microsoft.
video4linux-list mailing list