Patch Detail
Show a patch.
GET /api/1.1/patches/10855/?format=api
{ "id": 10855, "url": "https://patchwork.libcamera.org/api/1.1/patches/10855/?format=api", "web_url": "https://patchwork.libcamera.org/patch/10855/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/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": "<20210113130832.15549-5-andrey.konovalov@linaro.org>", "date": "2021-01-13T13:08:32", "name": "[libcamera-devel,4/4] qcam: viewfinder_gl: Add support for RAW12 packed formats", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "d052028fcb287e836aaab5ff978a6ae4f5e5d68e", "submitter": { "id": 25, "url": "https://patchwork.libcamera.org/api/1.1/people/25/?format=api", "name": "Andrey Konovalov", "email": "andrey.konovalov@linaro.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/10855/mbox/", "series": [ { "id": 1576, "url": "https://patchwork.libcamera.org/api/1.1/series/1576/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1576", "date": "2021-01-13T13:08:28", "name": "qcam: viewfinder_gl: add RAW10P and RAW12P format support", "version": 1, "mbox": "https://patchwork.libcamera.org/series/1576/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/10855/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/10855/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 00F83BD80C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 13 Jan 2021 13:09:04 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C1546680E4;\n\tWed, 13 Jan 2021 14:09:03 +0100 (CET)", "from mail-lf1-x129.google.com (mail-lf1-x129.google.com\n\t[IPv6:2a00:1450:4864:20::129])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 02BD0680D5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 13 Jan 2021 14:09:03 +0100 (CET)", "by mail-lf1-x129.google.com with SMTP id m12so2645886lfo.7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 13 Jan 2021 05:09:02 -0800 (PST)", "from localhost.localdomain ([85.249.43.69])\n\tby smtp.googlemail.com with ESMTPSA id\n\td2sm179477ljg.39.2021.01.13.05.09.00\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 13 Jan 2021 05:09:01 -0800 (PST)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=linaro.org header.i=@linaro.org\n\theader.b=\"ncc5HYkp\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=vfbBToVN87uQ5A/29HWO7lvbJuMk/InA3sQYu3SoI5Q=;\n\tb=ncc5HYkp7gXsRsPosvUqip7GDTzJAaSNfCd8EsivnCUai2OuAuPoYVP3SQzzaWFWAs\n\tg+bYv4oo2HyUQGpfG9abaRa6WExxMigTUNZSgkVS+0dUL7UywTG1clm7pXYuaeMIjdoT\n\t1zI9bW0dsfK0rBXdLBzcp0AJFqF4X32svaLowqE4vhe9ZQQMngadRbFoqn0lchAVNopN\n\tVpP7nBCFxUBmIpWqFIpNKarMFP0Gb1KSoRviM4RywsCIHbZddo7U1RHzwhwpHxyK+OoV\n\tyNV2wMRP89Ohj5P1RODCBM1aA9ih6diV7YSDLtLcM2vRFYF/Qz9VMlASVzxZ/Bb8n7n1\n\txo5w==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=vfbBToVN87uQ5A/29HWO7lvbJuMk/InA3sQYu3SoI5Q=;\n\tb=YYTgFqf02G/cav6piGZ8UuSxDFLMmCPMxeMq6O9G3cz7CTz1UB0UvKSEzX2HtXdth/\n\ttKzzq+8R/4rHH15yPq5jOUSRFh2qNMLOZ5GbcwbVVHe4b+rkyNDqXxBSbdSxLsNkM4Of\n\tlnY6Dgi+PQn0hYogC/FKn6rxP7WmqMv7GJugy+l+Dyt80QAhXcFRV+5xwPXPnDo5wst6\n\tsTojMi6ZkjRd9T/s3Yx6NxPCx8LPWKYOqlRzYJMdNbMOXNpBY52ZFNQzhywVsQvwpS3+\n\tnluJPJlXyXx3RqKhpSM09ogzw30cXBWpkZCz3BCnckfQf8qlMEgqgVipoUzRbtN/YVrh\n\tGkKg==", "X-Gm-Message-State": "AOAM533z4u85GsodfmadUbkMCeedgbecG0TW8RlQZ1Ur5dkndDxTGxU7\n\twHB44TzHaaImQbN6gp3GDiEyqHmyxldxdw==", "X-Google-Smtp-Source": "ABdhPJwipTBw5QoWpei2ygAvXutG3vNmmIbxjjPX6U+unP02AQl1VHPnCbTDxMJO3GhPOPnMAqh50g==", "X-Received": "by 2002:a05:6512:312b:: with SMTP id\n\tp11mr881591lfd.446.1610543341824; \n\tWed, 13 Jan 2021 05:09:01 -0800 (PST)", "From": "Andrey Konovalov <andrey.konovalov@linaro.org>", "To": "libcamera-devel@lists.libcamera.org,\n\tlaurent.pinchart@ideasonboard.com", "Date": "Wed, 13 Jan 2021 16:08:32 +0300", "Message-Id": "<20210113130832.15549-5-andrey.konovalov@linaro.org>", "X-Mailer": "git-send-email 2.17.1", "In-Reply-To": "<20210113130832.15549-1-andrey.konovalov@linaro.org>", "References": "<20210113130832.15549-1-andrey.konovalov@linaro.org>", "Subject": "[libcamera-devel] [PATCH 4/4] qcam: viewfinder_gl: Add support for\n\tRAW12 packed formats", "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>", "Cc": "morgan@casual-effects.com", "MIME-Version": "1.0", "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": "All the four Bayer orders are supported.\nThe 4 LS bits of the 12-bit colour values are dropped as the RGBA\nformat we convert into has only 8 bits per colour.\n\nSigned-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>\n---\n src/qcam/assets/shader/bayer_1x_packed.frag | 43 ++++++++++++++---\n src/qcam/viewfinder_gl.cpp | 53 +++++++++++++++++----\n 2 files changed, 82 insertions(+), 14 deletions(-)", "diff": "diff --git a/src/qcam/assets/shader/bayer_1x_packed.frag b/src/qcam/assets/shader/bayer_1x_packed.frag\nindex 0a87c6db..d09c6fce 100644\n--- a/src/qcam/assets/shader/bayer_1x_packed.frag\n+++ b/src/qcam/assets/shader/bayer_1x_packed.frag\n@@ -23,6 +23,40 @@\n precision mediump float;\n #endif\n \n+/*\n+ * These constants are used to select the bytes containing the HS part of\n+ * the pixel value:\n+ * BPP - bytes per pixel,\n+ * THRESHOLD_L = fract(BPP) * 0.5 + 0.02\n+ * THRESHOLD_H = 1.0 - fract(BPP) * 1.5 + 0.02\n+ * Let X is the x coordinate in the texture measured in bytes (so that the\n+ * range is from 0 to (stride_-1)) aligned on the nearest pixel.\n+ * E.g. for RAW10P:\n+ * -------------+-------------------+-------------------+--\n+ * pixel No | 0 1 2 3 | 4 5 6 7 | ...\n+ * -------------+-------------------+-------------------+--\n+ * byte offset | 0 1 2 3 4 | 5 6 7 8 9 | ...\n+ * -------------+-------------------+-------------------+--\n+ * X | 0.0 1.25 2.5 3.75 | 5.0 6.25 7.5 8.75 | ...\n+ * -------------+-------------------+-------------------+--\n+ * If fract(X) < THRESHOLD_L then the previous byte contains the LS\n+ * bits of the pixel values and needs to be skipped.\n+ * If fract(X) > THRESHOLD_H then the next byte contains the LS bits\n+ * of the pixel values and needs to be skipped.\n+ */\n+#if defined(RAW10P)\n+#define BPP 1.25\n+#define THRESHOLD_L 0.14\n+#define THRESHOLD_H 0.64\n+#elif defined(RAW12P)\n+#define BPP 1.5\n+#define THRESHOLD_L 0.27\n+#define THRESHOLD_H 0.27\n+#else\n+#error Invalid raw format\n+#endif\n+\n+\n varying vec2 textureOut;\n \n /* the texture size: tex_size.xy is in bytes, tex_size.zw is in pixels */\n@@ -64,10 +98,7 @@ void main(void)\n \t * Add a small number (a few mantissa's LSBs) to avoid float\n \t * representation issues. Maybe paranoic.\n \t */\n-\tcenter.x = BPP_X * center.z + 0.02;\n-\n-\tconst float threshold_l = 0.127 /* fract(BPP_X) * 0.5 + 0.02 */;\n-\tconst float threshold_h = 0.625 /* 1.0 - fract(BPP_X) * 1.5 */;\n+\tcenter.x = BPP * center.z + 0.02;\n \n \tfloat fract_x = fract(center.x);\n \t/*\n@@ -86,13 +117,13 @@ void main(void)\n * of the previous group of the pixels, move xcoords[0] one\n \t * byte back.\n \t */\n-\txcoords[0] += (fract_x < threshold_l) ? -tex_step.x : 0.0;\n+\txcoords[0] += (fract_x < THRESHOLD_L) ? -tex_step.x : 0.0;\n \t/*\n \t * If xcoords[1] points at the byte containing the LS bits\n * of the current group of the pixels, move xcoords[1] one\n \t * byte forward.\n \t */\n-\txcoords[1] += (fract_x > threshold_h) ? tex_step.x : 0.0;\n+\txcoords[1] += (fract_x > THRESHOLD_H) ? tex_step.x : 0.0;\n \n \tvec2 alternate = mod(center.zw + tex_bayer_first_red, 2.0);\n \tbool even_col = alternate.x < 1.0;\ndiff --git a/src/qcam/viewfinder_gl.cpp b/src/qcam/viewfinder_gl.cpp\nindex 9db536a6..13ab31aa 100644\n--- a/src/qcam/viewfinder_gl.cpp\n+++ b/src/qcam/viewfinder_gl.cpp\n@@ -41,6 +41,11 @@ static const QList<libcamera::PixelFormat> supportedFormats{\n \tlibcamera::formats::SGBRG10_CSI2P,\n \tlibcamera::formats::SGRBG10_CSI2P,\n \tlibcamera::formats::SRGGB10_CSI2P,\n+\t/* Raw Bayer 12-bit packed */\n+\tlibcamera::formats::SBGGR12_CSI2P,\n+\tlibcamera::formats::SGBRG12_CSI2P,\n+\tlibcamera::formats::SGRBG12_CSI2P,\n+\tlibcamera::formats::SRGGB12_CSI2P,\n };\n \n ViewFinderGL::ViewFinderGL(QWidget *parent)\n@@ -218,28 +223,56 @@ bool ViewFinderGL::selectFormat(const libcamera::PixelFormat &format)\n \tcase libcamera::formats::SBGGR10_CSI2P:\n \t\tfirstRed_.setX(1.0);\n \t\tfirstRed_.setY(1.0);\n-\t\tfragmentShaderDefines_.append(\"#define BPP_X 1.25\");\n+\t\tfragmentShaderDefines_.append(\"#define RAW10P\");\n \t\tfragmentShaderFile_ = \":bayer_1x_packed.frag\";\n \t\ttextureMinMagFilters_ = GL_NEAREST;\n \t\tbreak;\n \tcase libcamera::formats::SGBRG10_CSI2P:\n \t\tfirstRed_.setX(0.0);\n \t\tfirstRed_.setY(1.0);\n-\t\tfragmentShaderDefines_.append(\"#define BPP_X 1.25\");\n+\t\tfragmentShaderDefines_.append(\"#define RAW10P\");\n \t\tfragmentShaderFile_ = \":bayer_1x_packed.frag\";\n \t\ttextureMinMagFilters_ = GL_NEAREST;\n \t\tbreak;\n \tcase libcamera::formats::SGRBG10_CSI2P:\n \t\tfirstRed_.setX(1.0);\n \t\tfirstRed_.setY(0.0);\n-\t\tfragmentShaderDefines_.append(\"#define BPP_X 1.25\");\n+\t\tfragmentShaderDefines_.append(\"#define RAW10P\");\n \t\tfragmentShaderFile_ = \":bayer_1x_packed.frag\";\n \t\ttextureMinMagFilters_ = GL_NEAREST;\n \t\tbreak;\n \tcase libcamera::formats::SRGGB10_CSI2P:\n \t\tfirstRed_.setX(0.0);\n \t\tfirstRed_.setY(0.0);\n-\t\tfragmentShaderDefines_.append(\"#define BPP_X 1.25\");\n+\t\tfragmentShaderDefines_.append(\"#define RAW10P\");\n+\t\tfragmentShaderFile_ = \":bayer_1x_packed.frag\";\n+\t\ttextureMinMagFilters_ = GL_NEAREST;\n+\t\tbreak;\n+\tcase libcamera::formats::SBGGR12_CSI2P:\n+\t\tfirstRed_.setX(1.0);\n+\t\tfirstRed_.setY(1.0);\n+\t\tfragmentShaderDefines_.append(\"#define RAW12P\");\n+\t\tfragmentShaderFile_ = \":bayer_1x_packed.frag\";\n+\t\ttextureMinMagFilters_ = GL_NEAREST;\n+\t\tbreak;\n+\tcase libcamera::formats::SGBRG12_CSI2P:\n+\t\tfirstRed_.setX(0.0);\n+\t\tfirstRed_.setY(1.0);\n+\t\tfragmentShaderDefines_.append(\"#define RAW12P\");\n+\t\tfragmentShaderFile_ = \":bayer_1x_packed.frag\";\n+\t\ttextureMinMagFilters_ = GL_NEAREST;\n+\t\tbreak;\n+\tcase libcamera::formats::SGRBG12_CSI2P:\n+\t\tfirstRed_.setX(1.0);\n+\t\tfirstRed_.setY(0.0);\n+\t\tfragmentShaderDefines_.append(\"#define RAW12P\");\n+\t\tfragmentShaderFile_ = \":bayer_1x_packed.frag\";\n+\t\ttextureMinMagFilters_ = GL_NEAREST;\n+\t\tbreak;\n+\tcase libcamera::formats::SRGGB12_CSI2P:\n+\t\tfirstRed_.setX(0.0);\n+\t\tfirstRed_.setY(0.0);\n+\t\tfragmentShaderDefines_.append(\"#define RAW12P\");\n \t\tfragmentShaderFile_ = \":bayer_1x_packed.frag\";\n \t\ttextureMinMagFilters_ = GL_NEAREST;\n \t\tbreak;\n@@ -595,9 +628,13 @@ void ViewFinderGL::doRender()\n \tcase libcamera::formats::SGBRG10_CSI2P:\n \tcase libcamera::formats::SGRBG10_CSI2P:\n \tcase libcamera::formats::SRGGB10_CSI2P:\n+\tcase libcamera::formats::SBGGR12_CSI2P:\n+\tcase libcamera::formats::SGBRG12_CSI2P:\n+\tcase libcamera::formats::SGRBG12_CSI2P:\n+\tcase libcamera::formats::SRGGB12_CSI2P:\n \t\t/*\n-\t\t * Packed raw Bayer 10-bit formats are stored in GL_RED texture.\n-\t\t * The texture width is 10/8 of the image width.\n+\t\t * Packed raw Bayer 10-bit and 12-bit formats are stored in\n+\t\t * GL_RED texture.\n \t\t */\n \t\tglActiveTexture(GL_TEXTURE0);\n \t\tconfigureTexture(*textures_[0]);\n@@ -614,9 +651,9 @@ void ViewFinderGL::doRender()\n \t\tshaderProgram_.setUniformValue(textureUniformBayerFirstRed_,\n \t\t\t\t\t firstRed_);\n \t\tshaderProgram_.setUniformValue(textureUniformSize_,\n-\t\t\t\t\t stride_,\n+\t\t\t\t\t stride_, /* width in bytes */\n \t\t\t\t\t size_.height(),\n-\t\t\t\t\t size_.width(),\n+\t\t\t\t\t size_.width(), /* in pixels */\n \t\t\t\t\t size_.height());\n \t\tshaderProgram_.setUniformValue(textureUniformStep_,\n \t\t\t\t\t 1.0f / (stride_ - 1),\n", "prefixes": [ "libcamera-devel", "4/4" ] }