Patch Detail
Show a patch.
GET /api/patches/9642/?format=api
{ "id": 9642, "url": "https://patchwork.libcamera.org/api/patches/9642/?format=api", "web_url": "https://patchwork.libcamera.org/patch/9642/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20200916145254.1644-7-laurent.pinchart@ideasonboard.com>", "date": "2020-09-16T14:52:53", "name": "[libcamera-devel,6/7] qcam: viewfinder_gl: Merge the semi-planar UV and VU shaders", "commit_ref": "ae9e7fbf3a8bf45b08951b650aec3f91997fafc3", "pull_url": null, "state": "accepted", "archived": false, "hash": "249992029f503fec7ec54dfd56148722e257e771", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/9642/mbox/", "series": [ { "id": 1293, "url": "https://patchwork.libcamera.org/api/series/1293/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1293", "date": "2020-09-16T14:52:47", "name": "qcam: Accelerate packed YUV rendering with OpenGL", "version": 1, "mbox": "https://patchwork.libcamera.org/series/1293/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/9642/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/9642/checks/", "tags": {}, "headers": { "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>", "X-Original-To": "parsemail@patchwork.libcamera.org", "Delivered-To": "parsemail@patchwork.libcamera.org", "Received": [ "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 2C0E5BF01C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 16 Sep 2020 14:54:55 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EEA9D62EB1;\n\tWed, 16 Sep 2020 16:54:54 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B1ECF60533\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 16 Sep 2020 16:54:53 +0200 (CEST)", "from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C8E04A62;\n\tWed, 16 Sep 2020 16:54:32 +0200 (CEST)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"Ge8m6cmq\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1600268073;\n\tbh=485I6IT6smpMLwSR+mxTL2V9vLytl8jg4JbKkusw+Ak=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=Ge8m6cmqqoLDOtyZ28yzj9y/oLxnHe6BMiK/tZUBtg1J3tDbj6uFD+NDXLpvbAW1I\n\tCY5wXlcB9oZ8HzlNznKKvs5l112ZiaGcXMl9TdggIuzsJgrqJiBdAc9IagMoaQeNDC\n\tHUp5vHQ50/Lk1u6hdPtWJI+IX8cf0V+uVrYo2JE0=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 16 Sep 2020 17:52:53 +0300", "Message-Id": "<20200916145254.1644-7-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.27.0", "In-Reply-To": "<20200916145254.1644-1-laurent.pinchart@ideasonboard.com>", "References": "<20200916145254.1644-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH 6/7] qcam: viewfinder_gl: Merge the\n\tsemi-planar UV and VU shaders", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "<libcamera-devel.lists.libcamera.org>", "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>", "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>", "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>", "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>", "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Use macros to select the U and V pattern, to avoid code duplication\nbetween the two semi-planar shaders.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n ...YUV_2_planes_UV.frag => YUV_2_planes.frag} | 9 +++++-\n src/qcam/assets/shader/YUV_2_planes_VU.frag | 32 -------------------\n src/qcam/assets/shader/shaders.qrc | 3 +-\n src/qcam/viewfinder_gl.cpp | 18 +++++++----\n 4 files changed, 21 insertions(+), 41 deletions(-)\n rename src/qcam/assets/shader/{YUV_2_planes_UV.frag => YUV_2_planes.frag} (68%)\n delete mode 100644 src/qcam/assets/shader/YUV_2_planes_VU.frag", "diff": "diff --git a/src/qcam/assets/shader/YUV_2_planes_UV.frag b/src/qcam/assets/shader/YUV_2_planes.frag\nsimilarity index 68%\nrename from src/qcam/assets/shader/YUV_2_planes_UV.frag\nrename to src/qcam/assets/shader/YUV_2_planes.frag\nindex 081caea9214b..125f1c850a33 100644\n--- a/src/qcam/assets/shader/YUV_2_planes_UV.frag\n+++ b/src/qcam/assets/shader/YUV_2_planes.frag\n@@ -2,7 +2,7 @@\n /*\n * Copyright (C) 2020, Linaro\n *\n- * YUV_2_planes_UV.frag - Fragment shader code for NV12, NV16 and NV24 formats\n+ * YUV_2_planes.frag - Fragment shader code for NV12, NV16 and NV24 formats\n */\n \n #ifdef GL_ES\n@@ -24,8 +24,15 @@ void main(void)\n \t);\n \n \tyuv.x = texture2D(tex_y, textureOut).r - 0.063;\n+#if defined(YUV_PATTERN_UV)\n \tyuv.y = texture2D(tex_u, textureOut).r - 0.500;\n \tyuv.z = texture2D(tex_u, textureOut).g - 0.500;\n+#elif defined(YUV_PATTERN_VU)\n+\tyuv.y = texture2D(tex_u, textureOut).g - 0.500;\n+\tyuv.z = texture2D(tex_u, textureOut).r - 0.500;\n+#else\n+#error Invalid pattern\n+#endif\n \n \trgb = yuv2rgb_bt601_mat * yuv;\n \tgl_FragColor = vec4(rgb, 1.0);\ndiff --git a/src/qcam/assets/shader/YUV_2_planes_VU.frag b/src/qcam/assets/shader/YUV_2_planes_VU.frag\ndeleted file mode 100644\nindex f4a5a5ac46c0..000000000000\n--- a/src/qcam/assets/shader/YUV_2_planes_VU.frag\n+++ /dev/null\n@@ -1,32 +0,0 @@\n-/* SPDX-License-Identifier: LGPL-2.1-or-later */\n-/*\n- * Copyright (C) 2020, Linaro\n- *\n- * YUV_2_planes_VU.frag - Fragment shader code for NV21, NV61 and NV42 formats\n- */\n-\n-#ifdef GL_ES\n-precision mediump float;\n-#endif\n-\n-varying vec2 textureOut;\n-uniform sampler2D tex_y;\n-uniform sampler2D tex_u;\n-\n-void main(void)\n-{\n-\tvec3 yuv;\n-\tvec3 rgb;\n-\tmat3 yuv2rgb_bt601_mat = mat3(\n-\t\tvec3(1.164, 1.164, 1.164),\n-\t\tvec3(0.000, -0.392, 2.017),\n-\t\tvec3(1.596, -0.813, 0.000)\n-\t);\n-\n-\tyuv.x = texture2D(tex_y, textureOut).r - 0.063;\n-\tyuv.y = texture2D(tex_u, textureOut).g - 0.500;\n-\tyuv.z = texture2D(tex_u, textureOut).r - 0.500;\n-\n-\trgb = yuv2rgb_bt601_mat * yuv;\n-\tgl_FragColor = vec4(rgb, 1.0);\n-}\ndiff --git a/src/qcam/assets/shader/shaders.qrc b/src/qcam/assets/shader/shaders.qrc\nindex 533396d1fb28..7010d8433c9b 100644\n--- a/src/qcam/assets/shader/shaders.qrc\n+++ b/src/qcam/assets/shader/shaders.qrc\n@@ -2,8 +2,7 @@\n <!DOCTYPE RCC><RCC version=\"1.0\">\n <qresource>\n \t<file>YUV.vert</file>\n-\t<file>YUV_2_planes_UV.frag</file>\n-\t<file>YUV_2_planes_VU.frag</file>\n+\t<file>YUV_2_planes.frag</file>\n \t<file>YUV_3_planes.frag</file>\n </qresource>\n </RCC>\ndiff --git a/src/qcam/viewfinder_gl.cpp b/src/qcam/viewfinder_gl.cpp\nindex 7cb5fb63656f..b8a4827267c3 100644\n--- a/src/qcam/viewfinder_gl.cpp\n+++ b/src/qcam/viewfinder_gl.cpp\n@@ -106,32 +106,38 @@ bool ViewFinderGL::selectFormat(const libcamera::PixelFormat &format)\n \tcase libcamera::formats::NV12:\n \t\thorzSubSample_ = 2;\n \t\tvertSubSample_ = 2;\n-\t\tfragmentShaderFile_ = \":YUV_2_planes_UV.frag\";\n+\t\tfragmentShaderDefines_.append(\"#define YUV_PATTERN_UV\");\n+\t\tfragmentShaderFile_ = \":YUV_2_planes.frag\";\n \t\tbreak;\n \tcase libcamera::formats::NV21:\n \t\thorzSubSample_ = 2;\n \t\tvertSubSample_ = 2;\n-\t\tfragmentShaderFile_ = \":YUV_2_planes_VU.frag\";\n+\t\tfragmentShaderDefines_.append(\"#define YUV_PATTERN_VU\");\n+\t\tfragmentShaderFile_ = \":YUV_2_planes.frag\";\n \t\tbreak;\n \tcase libcamera::formats::NV16:\n \t\thorzSubSample_ = 2;\n \t\tvertSubSample_ = 1;\n-\t\tfragmentShaderFile_ = \":YUV_2_planes_UV.frag\";\n+\t\tfragmentShaderDefines_.append(\"#define YUV_PATTERN_UV\");\n+\t\tfragmentShaderFile_ = \":YUV_2_planes.frag\";\n \t\tbreak;\n \tcase libcamera::formats::NV61:\n \t\thorzSubSample_ = 2;\n \t\tvertSubSample_ = 1;\n-\t\tfragmentShaderFile_ = \":YUV_2_planes_VU.frag\";\n+\t\tfragmentShaderDefines_.append(\"#define YUV_PATTERN_VU\");\n+\t\tfragmentShaderFile_ = \":YUV_2_planes.frag\";\n \t\tbreak;\n \tcase libcamera::formats::NV24:\n \t\thorzSubSample_ = 1;\n \t\tvertSubSample_ = 1;\n-\t\tfragmentShaderFile_ = \":YUV_2_planes_UV.frag\";\n+\t\tfragmentShaderDefines_.append(\"#define YUV_PATTERN_UV\");\n+\t\tfragmentShaderFile_ = \":YUV_2_planes.frag\";\n \t\tbreak;\n \tcase libcamera::formats::NV42:\n \t\thorzSubSample_ = 1;\n \t\tvertSubSample_ = 1;\n-\t\tfragmentShaderFile_ = \":YUV_2_planes_VU.frag\";\n+\t\tfragmentShaderDefines_.append(\"#define YUV_PATTERN_VU\");\n+\t\tfragmentShaderFile_ = \":YUV_2_planes.frag\";\n \t\tbreak;\n \tcase libcamera::formats::YUV420:\n \t\thorzSubSample_ = 2;\n", "prefixes": [ "libcamera-devel", "6/7" ] }