Patch Detail
Show a patch.
GET /api/patches/21941/?format=api
{ "id": 21941, "url": "https://patchwork.libcamera.org/api/patches/21941/?format=api", "web_url": "https://patchwork.libcamera.org/patch/21941/", "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": "<20241117221712.29616-12-laurent.pinchart@ideasonboard.com>", "date": "2024-11-17T22:17:12", "name": "[RFC,11/11] ipa: rkisp1: awb: Replace manual calculations with Vector and Matrix", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "4476f8db356cd565e32aea816494267f8020e218", "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/21941/mbox/", "series": [ { "id": 4795, "url": "https://patchwork.libcamera.org/api/series/4795/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4795", "date": "2024-11-17T22:17:01", "name": "Improve linear algebra helpers in libipa", "version": 1, "mbox": "https://patchwork.libcamera.org/series/4795/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/21941/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/21941/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 B2606C330D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 17 Nov 2024 22:17:52 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EE294658BE;\n\tSun, 17 Nov 2024 23:17:51 +0100 (CET)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1A631658B6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 17 Nov 2024 23:17:37 +0100 (CET)", "from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id BE0FF7FE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 17 Nov 2024 23:17:20 +0100 (CET)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"apKS5xEk\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1731881840;\n\tbh=gY1N0wr/j2OIR5CqPCYhbeXK/zUwOmhaUddN+9jd/fw=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=apKS5xEkFDjsAKIZY2WQTCKyAkl3MSiZU1mBGnM9A/SMVMkhF2nyOmA4vNGDcIyYp\n\tP/5qPVeopxoMcerP4GFW7qU1tdYs3HdlHmCP31x2rOjfHdXmgOWpuk04LKYlNdh6KX\n\t0MyWc2mLTRGL6prtbREC6aWjLu+w+qGJ8cMiAHnU=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Subject": "[RFC PATCH 11/11] ipa: rkisp1: awb: Replace manual calculations with\n\tVector and Matrix", "Date": "Mon, 18 Nov 2024 00:17:12 +0200", "Message-ID": "<20241117221712.29616-12-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.45.2", "In-Reply-To": "<20241117221712.29616-1-laurent.pinchart@ideasonboard.com>", "References": "<20241117221712.29616-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "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>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Processing of the statistics and estimation of the colour temperature\ninvolve linear algebra. Replace the manual calculations with usage of\nthe Vector and Matrix classes.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/ipa/rkisp1/algorithms/awb.cpp | 44 +++++++++++++++++++------------\n 1 file changed, 27 insertions(+), 17 deletions(-)", "diff": "diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\nindex 1c572055acdd..c089523c8bde 100644\n--- a/src/ipa/rkisp1/algorithms/awb.cpp\n+++ b/src/ipa/rkisp1/algorithms/awb.cpp\n@@ -169,17 +169,21 @@ void Awb::prepare(IPAContext &context, const uint32_t frame,\n \n uint32_t Awb::estimateCCT(const RGB<double> &rgb)\n {\n-\t/* Convert the RGB values to CIE tristimulus values (XYZ) */\n-\tdouble X = -0.14282 * rgb.r() + 1.54924 * rgb.g() - 0.95641 * rgb.b();\n-\tdouble Y = -0.32466 * rgb.r() + 1.57837 * rgb.g() - 0.73191 * rgb.b();\n-\tdouble Z = -0.68202 * rgb.r() + 0.77073 * rgb.g() + 0.56332 * rgb.b();\n+\t/*\n+\t * Convert the RGB values to CIE tristimulus values (XYZ) and normalize\n+\t * it (xyz).\n+\t */\n+\tstatic const Matrix<double, 3, 3> rgb2xyz({\n+\t\t-0.14282, 1.54924, -0.95641,\n+\t\t-0.32466, 1.57837, -0.73191,\n+\t\t-0.68202, 0.77073, 0.56332\n+\t});\n \n-\t/* Calculate the normalized chromaticity values */\n-\tdouble x = X / (X + Y + Z);\n-\tdouble y = Y / (X + Y + Z);\n+\tVector<double, 3> xyz = rgb2xyz * rgb;\n+\txyz.normalize();\n \n \t/* Calculate CCT */\n-\tdouble n = (x - 0.3320) / (0.1858 - y);\n+\tdouble n = (xyz.x() - 0.3320) / (0.1858 - xyz.y());\n \treturn 449 * n * n * n + 3525 * n * n + 6823.3 * n + 5520.33;\n }\n \n@@ -215,9 +219,11 @@ void Awb::process(IPAContext &context,\n \t\trgbMeans.b() = awb->awb_mean[0].mean_cb_or_b;\n \t} else {\n \t\t/* Get the YCbCr mean values */\n-\t\tdouble yMean = awb->awb_mean[0].mean_y_or_g;\n-\t\tdouble cbMean = awb->awb_mean[0].mean_cb_or_b;\n-\t\tdouble crMean = awb->awb_mean[0].mean_cr_or_r;\n+\t\tVector<double, 3> yuvMeans({\n+\t\t\tstatic_cast<double>(awb->awb_mean[0].mean_y_or_g),\n+\t\t\tstatic_cast<double>(awb->awb_mean[0].mean_cb_or_b),\n+\t\t\tstatic_cast<double>(awb->awb_mean[0].mean_cr_or_r)\n+\t\t});\n \n \t\t/*\n \t\t * Convert from YCbCr to RGB.\n@@ -231,12 +237,16 @@ void Awb::process(IPAContext &context,\n \t\t * [1,1636, -0,4045, -0,7949]\n \t\t * [1,1636, 1,9912, -0,0250]]\n \t\t */\n-\t\tyMean -= 16;\n-\t\tcbMean -= 128;\n-\t\tcrMean -= 128;\n-\t\trgbMeans.r() = 1.1636 * yMean - 0.0623 * cbMean + 1.6008 * crMean;\n-\t\trgbMeans.g() = 1.1636 * yMean - 0.4045 * cbMean - 0.7949 * crMean;\n-\t\trgbMeans.b() = 1.1636 * yMean + 1.9912 * cbMean - 0.0250 * crMean;\n+\t\tstatic const Matrix<double, 3, 3> yuv2rgbMatrix({\n+\t\t\t1.1636, -0.0623, 1.6008,\n+\t\t\t1.1636, -0.4045, -0.7949,\n+\t\t\t1.1636, 1.9912, -0.0250\n+\t\t});\n+\t\tstatic const Vector<double, 3> yuv2rgbOffset({\n+\t\t\t16, 128, 128\n+\t\t});\n+\n+\t\trgbMeans = yuv2rgbMatrix * (yuvMeans - yuv2rgbOffset);\n \n \t\t/*\n \t\t * Due to hardware rounding errors in the YCbCr means, the\n", "prefixes": [ "RFC", "11/11" ] }