Patch Detail
Show a patch.
GET /api/patches/21972/?format=api
{ "id": 21972, "url": "https://patchwork.libcamera.org/api/patches/21972/?format=api", "web_url": "https://patchwork.libcamera.org/patch/21972/", "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": "<20241118221618.13953-13-laurent.pinchart@ideasonboard.com>", "date": "2024-11-18T22:16:13", "name": "[v3,12/17] ipa: ipu3: awb: Replace Awb::RGB class with ipa::RGB", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "48de9c8d46afecd26ad9452021ec0768c2d33126", "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/21972/mbox/", "series": [ { "id": 4798, "url": "https://patchwork.libcamera.org/api/series/4798/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4798", "date": "2024-11-18T22:16:01", "name": "Improve linear algebra helpers in libipa", "version": 3, "mbox": "https://patchwork.libcamera.org/series/4798/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/21972/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/21972/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 B5102C32EA\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 18 Nov 2024 22:16:58 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6676F65ED8;\n\tMon, 18 Nov 2024 23:16:58 +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 9992465906\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 18 Nov 2024 23:16:44 +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 8E83A6DE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 18 Nov 2024 23:16:27 +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=\"oWFkmIwP\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1731968187;\n\tbh=+ZTXoiMpZm1TAEtU2dsP30+mo6sIv7tz0ORoRHVKbfs=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=oWFkmIwP2hZOqb80LJTWd+lhtAXJQ8My8tqxGgv9lmyGXfO69wUdQ2KIEoG3chYBv\n\tBwQC/PUihuDozc6okF3zBbKTt9FXjoDQ5VmzL/OzpAQYT1Ll0K1RP9SfC6n3spjOxY\n\tWpmxFj5oUE/KdEbdKjRqBctquKUiokFmpqj9in1s=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Subject": "[PATCH v3 12/17] ipa: ipu3: awb: Replace Awb::RGB class with\n\tipa::RGB", "Date": "Tue, 19 Nov 2024 00:16:13 +0200", "Message-ID": "<20241118221618.13953-13-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.45.2", "In-Reply-To": "<20241118221618.13953-1-laurent.pinchart@ideasonboard.com>", "References": "<20241118221618.13953-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": "Now that libipa has a generic RGB class, replaces the local\nimplementation from the IPU3 AWB algorithm.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/ipa/ipu3/algorithms/awb.cpp | 37 ++++++++++++++++++---------------\n src/ipa/ipu3/algorithms/awb.h | 18 +++-------------\n 2 files changed, 23 insertions(+), 32 deletions(-)", "diff": "diff --git a/src/ipa/ipu3/algorithms/awb.cpp b/src/ipa/ipu3/algorithms/awb.cpp\nindex c3c8b0740f36..7c6bff09147c 100644\n--- a/src/ipa/ipu3/algorithms/awb.cpp\n+++ b/src/ipa/ipu3/algorithms/awb.cpp\n@@ -309,15 +309,18 @@ void Awb::generateZones()\n \tzones_.clear();\n \n \tfor (unsigned int i = 0; i < kAwbStatsSizeX * kAwbStatsSizeY; i++) {\n-\t\tRGB zone;\n \t\tdouble counted = awbStats_[i].counted;\n \t\tif (counted >= cellsPerZoneThreshold_) {\n-\t\t\tzone.G = awbStats_[i].sum.green / counted;\n-\t\t\tif (zone.G >= kMinGreenLevelInZone) {\n-\t\t\t\tzone.R = awbStats_[i].sum.red / counted;\n-\t\t\t\tzone.B = awbStats_[i].sum.blue / counted;\n+\t\t\tRGB<double> zone{{\n+\t\t\t\tstatic_cast<double>(awbStats_[i].sum.red),\n+\t\t\t\tstatic_cast<double>(awbStats_[i].sum.green),\n+\t\t\t\tstatic_cast<double>(awbStats_[i].sum.blue)\n+\t\t\t}};\n+\n+\t\t\tzone /= counted;\n+\n+\t\t\tif (zone.g() >= kMinGreenLevelInZone)\n \t\t\t\tzones_.push_back(zone);\n-\t\t\t}\n \t\t}\n \t}\n }\n@@ -384,32 +387,32 @@ void Awb::awbGreyWorld()\n \t * consider some variations, such as normalising all the zones first, or\n \t * doing an L2 average etc.\n \t */\n-\tstd::vector<RGB> &redDerivative(zones_);\n-\tstd::vector<RGB> blueDerivative(redDerivative);\n+\tstd::vector<RGB<double>> &redDerivative(zones_);\n+\tstd::vector<RGB<double>> blueDerivative(redDerivative);\n \tstd::sort(redDerivative.begin(), redDerivative.end(),\n-\t\t [](RGB const &a, RGB const &b) {\n-\t\t\t return a.G * b.R < b.G * a.R;\n+\t\t [](RGB<double> const &a, RGB<double> const &b) {\n+\t\t\t return a.g() * b.r() < b.g() * a.r();\n \t\t });\n \tstd::sort(blueDerivative.begin(), blueDerivative.end(),\n-\t\t [](RGB const &a, RGB const &b) {\n-\t\t\t return a.G * b.B < b.G * a.B;\n+\t\t [](RGB<double> const &a, RGB<double> const &b) {\n+\t\t\t return a.g() * b.b() < b.g() * a.b();\n \t\t });\n \n \t/* Average the middle half of the values. */\n \tint discard = redDerivative.size() / 4;\n \n-\tRGB sumRed(0, 0, 0);\n-\tRGB sumBlue(0, 0, 0);\n+\tRGB<double> sumRed{ 0.0 };\n+\tRGB<double> sumBlue{ 0.0 };\n \tfor (auto ri = redDerivative.begin() + discard,\n \t\t bi = blueDerivative.begin() + discard;\n \t ri != redDerivative.end() - discard; ri++, bi++)\n \t\tsumRed += *ri, sumBlue += *bi;\n \n-\tdouble redGain = sumRed.G / (sumRed.R + 1),\n-\t blueGain = sumBlue.G / (sumBlue.B + 1);\n+\tdouble redGain = sumRed.g() / (sumRed.r() + 1),\n+\t blueGain = sumBlue.g() / (sumBlue.b() + 1);\n \n \t/* Color temperature is not relevant in Grey world but still useful to estimate it :-) */\n-\tasyncResults_.temperatureK = estimateCCT(sumRed.R, sumRed.G, sumBlue.B);\n+\tasyncResults_.temperatureK = estimateCCT(sumRed.r(), sumRed.g(), sumBlue.b());\n \n \t/*\n \t * Gain values are unsigned integer value ranging [0, 8) with 13 bit\ndiff --git a/src/ipa/ipu3/algorithms/awb.h b/src/ipa/ipu3/algorithms/awb.h\nindex a13c49acc1fe..1916990a5364 100644\n--- a/src/ipa/ipu3/algorithms/awb.h\n+++ b/src/ipa/ipu3/algorithms/awb.h\n@@ -13,6 +13,8 @@\n \n #include <libcamera/geometry.h>\n \n+#include \"libipa/vector.h\"\n+\n #include \"algorithm.h\"\n \n namespace libcamera {\n@@ -48,20 +50,6 @@ public:\n \t\t ControlList &metadata) override;\n \n private:\n-\t/* \\todo Make these structs available to all the ISPs ? */\n-\tstruct RGB {\n-\t\tRGB(double _R = 0, double _G = 0, double _B = 0)\n-\t\t\t: R(_R), G(_G), B(_B)\n-\t\t{\n-\t\t}\n-\t\tdouble R, G, B;\n-\t\tRGB &operator+=(RGB const &other)\n-\t\t{\n-\t\t\tR += other.R, G += other.G, B += other.B;\n-\t\t\treturn *this;\n-\t\t}\n-\t};\n-\n \tstruct AwbStatus {\n \t\tdouble temperatureK;\n \t\tdouble redGain;\n@@ -78,7 +66,7 @@ private:\n \tstatic constexpr uint16_t threshold(float value);\n \tstatic constexpr uint16_t gainValue(double gain);\n \n-\tstd::vector<RGB> zones_;\n+\tstd::vector<RGB<double>> zones_;\n \tAccumulator awbStats_[kAwbStatsSizeX * kAwbStatsSizeY];\n \tAwbStatus asyncResults_;\n \n", "prefixes": [ "v3", "12/17" ] }