Patch Detail
Show a patch.
GET /api/patches/21954/?format=api
{ "id": 21954, "url": "https://patchwork.libcamera.org/api/patches/21954/?format=api", "web_url": "https://patchwork.libcamera.org/patch/21954/", "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": "<20241118000738.18977-13-laurent.pinchart@ideasonboard.com>", "date": "2024-11-18T00:07:38", "name": "[RFC,v2,12/12] ipa: rkisp1: awb: Replace manual calculations with Vector and Matrix", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "dea0723f381fe15426824a337671079d0681fe9a", "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/21954/mbox/", "series": [ { "id": 4796, "url": "https://patchwork.libcamera.org/api/series/4796/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4796", "date": "2024-11-18T00:07:26", "name": "Improve linear algebra helpers in libipa", "version": 2, "mbox": "https://patchwork.libcamera.org/series/4796/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/21954/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/21954/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 8178FC330D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 18 Nov 2024 00:08:15 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E3784658C6;\n\tMon, 18 Nov 2024 01:08:14 +0100 (CET)", "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 E9895658C9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 18 Nov 2024 01:08:03 +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 8BBA775A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 18 Nov 2024 01:07:47 +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=\"EaKr/AZl\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1731888467;\n\tbh=WCWQ1ytFDfwIUcJc4NNhZUm+kRukHTBU/uqKoqO54G4=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=EaKr/AZlG+h5wuDhrhPNqBfnaGQ+w0KLdWgCaLTYRCTMS5tTFz8bxyiUzBQY0ZVLJ\n\tV6uelKE70j1l7fGEeGsSqTiJCVDIu0eMXwpzNjJPqFoAaR9PgbATrSSe1tWztrXO61\n\tz7b9CkpPNs3E7X1fVjUk5mtiSoKg74tsKWwE8RIs=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Subject": "[RFC PATCH v2 12/12] ipa: rkisp1: awb: Replace manual calculations\n\twith Vector and Matrix", "Date": "Mon, 18 Nov 2024 02:07:38 +0200", "Message-ID": "<20241118000738.18977-13-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.45.2", "In-Reply-To": "<20241118000738.18977-1-laurent.pinchart@ideasonboard.com>", "References": "<20241118000738.18977-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---\nChanges since v1:\n\n- Adapt to Vector::normalize() being dropped\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..97163e0fa45c 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 divide by\n+\t * the sum of X, Y and Z to calculate the CIE xy chromaticity.\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 /= xyz.sum();\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", "v2", "12/12" ] }