This is an automatic generated email to let you know that the following patch 
were queued at the 
http://git.linuxtv.org/cgit.cgi/v4l-utils.git tree:

Subject: v4l2grab: use BT.709 by default on YUV conversion
Author:  Mauro Carvalho Chehab <[email protected]>
Date:    Sat Oct 30 10:46:09 2021 +0100

This is more commonly found those days. Yet, the right approach
would be, instead, to add full support for colorspace. So,
add a note there, while keeping the BT.601 table too.

As the hole idea of v4l2grab is to do quick tests, let's
keep using an integer arithimetic, as this should be faster.
Yet, let's improve its precision.

Signed-off-by: Mauro Carvalho Chehab <[email protected]>

 contrib/test/v4l2grab.c | 31 +++++++++++++++++++++++++------
 1 file changed, 25 insertions(+), 6 deletions(-)

---

http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=1d00c48a42a86d46bc61cbe66a7eec0aeaedab61
diff --git a/contrib/test/v4l2grab.c b/contrib/test/v4l2grab.c
index 70b29da3be57..1f4a098890b9 100644
--- a/contrib/test/v4l2grab.c
+++ b/contrib/test/v4l2grab.c
@@ -217,7 +217,7 @@ static void copy_two_pixels(uint32_t fourcc,
         case V4L2_PIX_FMT_UYVY:
         case V4L2_PIX_FMT_YVYU:
         case V4L2_PIX_FMT_VYUY:
-               int y_off, u_off, u, v;
+               int32_t y_off, u_off, u, v;
 
                y_off = (fourcc == V4L2_PIX_FMT_YUYV || fourcc == 
V4L2_PIX_FMT_YVYU) ? 0 : 1;
                u_off = (fourcc == V4L2_PIX_FMT_YUYV || fourcc == 
V4L2_PIX_FMT_UYVY) ? 0 : 1;
@@ -226,11 +226,30 @@ static void copy_two_pixels(uint32_t fourcc,
                v = src[1 - y_off][1 - u_off] - 128;
 
                for (i = 0; i < 2; i++) {
-                       int y = src[i][y_off] - 16;
-
-                       *(*dst)++ = CLAMP((298 * y + 409 * v + 128) >> 8);
-                       *(*dst)++ = CLAMP((298 * y - 100 * u - 208 * v + 128) 
>> 8);
-                       *(*dst)++ = CLAMP((298 * y + 516 * u + 128) >> 8);
+                       int32_t y = src[i][y_off] - 16;
+#if 0
+                       /* TODO: add colorspace check logic */
+
+                       /*
+                        * ITU-R BT.601 matrix:
+                        *    R = 1.164 * y +    0.0 * u +  1.596 * v
+                        *    G = 1.164 * y + -0.392 * u + -0.813 * v
+                        *    B = 1.164 * y +  2.017 * u +    0.0 * v
+                        */
+                       *(*dst)++ = CLAMP((76284 * y              + 104595 * v 
+ 32768) >> 16);
+                       *(*dst)++ = CLAMP((76284 * y -  25690 * u -  53281 * v 
+ 32768) >> 16);
+                       *(*dst)++ = CLAMP((76284 * y + 132186 * u              
+ 32768) >> 16);
+#else
+                       /*
+                        * ITU-R BT.709 matrix:
+                        *    R = 1.164 * y +    0.0 * u +  1.793 * v
+                        *    G = 1.164 * y + -0.213 * u + -0.533 * v
+                        *    B = 1.164 * y +  2.112 * u +    0.0 * v
+                        */
+                       *(*dst)++ = CLAMP((76284 * y              + 117506 * v 
+ 32768) >> 16);
+                       *(*dst)++ = CLAMP((76284 * y -  13959 * u -  34931 * v 
+ 32768) >> 16);
+                       *(*dst)++ = CLAMP((76284 * y + 138412 * u              
+ 32768) >> 16);
+#endif
                }
                break;
        default:

_______________________________________________
linuxtv-commits mailing list
[email protected]
https://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to