]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
[media] v4l: Fix colorspace conversion error in sample code
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Wed, 19 Jun 2013 00:41:59 +0000 (21:41 -0300)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Sun, 18 Aug 2013 11:49:07 +0000 (08:49 -0300)
The sample code erroneously scales the y1, pb and pr variables from the
[0.0 .. 1.0] and [-0.5 .. 0.5] ranges to [0 .. 255] and [-128 .. 127].
Fix it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Documentation/DocBook/media/v4l/pixfmt.xml

index 16db350848afc74bf244c6180a998d219fd36b12..72d72bd67d0a9eb00836b5495a0b9e6c4821d5f3 100644 (file)
@@ -391,9 +391,9 @@ clamp (double x)
        else               return r;
 }
 
-y1 = (255 / 219.0) * (Y1 - 16);
-pb = (255 / 224.0) * (Cb - 128);
-pr = (255 / 224.0) * (Cr - 128);
+y1 = (Y1 - 16) / 219.0;
+pb = (Cb - 128) / 224.0;
+pr = (Cr - 128) / 224.0;
 
 r = 1.0 * y1 + 0     * pb + 1.402 * pr;
 g = 1.0 * y1 - 0.344 * pb - 0.714 * pr;