Patch Detail
Show a patch.
GET /api/patches/20018/?format=api
{ "id": 20018, "url": "https://patchwork.libcamera.org/api/patches/20018/?format=api", "web_url": "https://patchwork.libcamera.org/patch/20018/", "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": "<20240508103546.693219-1-paul.elder@ideasonboard.com>", "date": "2024-05-08T10:35:46", "name": "[v3] ipa: libipa: histogram: Add transform parameter to constructor", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "836a5952e2afd253029617ce257336128d976a73", "submitter": { "id": 17, "url": "https://patchwork.libcamera.org/api/people/17/?format=api", "name": "Paul Elder", "email": "paul.elder@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/20018/mbox/", "series": [ { "id": 4294, "url": "https://patchwork.libcamera.org/api/series/4294/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4294", "date": "2024-05-08T10:35:46", "name": "[v3] ipa: libipa: histogram: Add transform parameter to constructor", "version": 3, "mbox": "https://patchwork.libcamera.org/series/4294/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/20018/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/20018/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 77876C3226\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 8 May 2024 10:36:02 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 700FA62C9F;\n\tWed, 8 May 2024 12:36:01 +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 E7D6761A73\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 8 May 2024 12:35:58 +0200 (CEST)", "from neptunite.hamster-moth.ts.net\n\t(h175-177-049-156.catv02.itscom.jp [175.177.49.156])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B79D0B0B;\n\tWed, 8 May 2024 12:35:54 +0200 (CEST)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"VvQBQtn1\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1715164555;\n\tbh=/61b3jqyQUMa8JE9mpDHJnO4gi1lBL/x6la2PxplWXo=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=VvQBQtn1c8jvdCt9uVSXfTUmY3q2zOFFTdB0/CYW4MHchYRx2+wBRBfiUWYLCtbjj\n\tK5ppZVTxiFNg9ULPNXOf2QOPOAUfh63GGO3jF7TSBvS6l7cwGIl9QlNIlkKdm3d3GX\n\tbr5xQ3ssXgYFITc6d1ZwWUTEuvblx7E7QRY9XuH4=", "From": "Paul Elder <paul.elder@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Paul Elder <paul.elder@ideasonboard.com>", "Subject": "[PATCH v3] ipa: libipa: histogram: Add transform parameter to\n\tconstructor", "Date": "Wed, 8 May 2024 19:35:46 +0900", "Message-Id": "<20240508103546.693219-1-paul.elder@ideasonboard.com>", "X-Mailer": "git-send-email 2.39.2", "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": "Add a parameter to the histogram constructor that takes a transformation\nfunction to apply to all the bins upon construction.\n\nThis is necessary notably for the rkisp1, as the values reported from\nthe hardware are 20 bits where the upper 16-bits are meaningful integer\nvalues and the lower 4 bits are fractional and meant to be discarded. As\nadding a right-shift parameter is probably too specialized, a generic\nfunction is added as a parameter instead.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n\n---\nChanges in v3:\n- make the transform function a template parameter, and optimize the\n constructor\n\nThis used to be \"ipa: libipa: histogram: Add rshift parameter to\nconstructor\"\n\nChanges in v2:\n- change rshift parameter to a function parameter\n---\n src/ipa/libipa/histogram.cpp | 8 +-------\n src/ipa/libipa/histogram.h | 14 ++++++++++++--\n 2 files changed, 13 insertions(+), 9 deletions(-)", "diff": "diff --git a/src/ipa/libipa/histogram.cpp b/src/ipa/libipa/histogram.cpp\nindex c1aac59b..628e3755 100644\n--- a/src/ipa/libipa/histogram.cpp\n+++ b/src/ipa/libipa/histogram.cpp\n@@ -40,14 +40,8 @@ namespace ipa {\n /**\n * \\brief Create a cumulative histogram\n * \\param[in] data A pre-sorted histogram to be passed\n+ * \\param[in] transform The transformation function to apply to every bin\n */\n-Histogram::Histogram(Span<const uint32_t> data)\n-{\n-\tcumulative_.reserve(data.size());\n-\tcumulative_.push_back(0);\n-\tfor (const uint32_t &value : data)\n-\t\tcumulative_.push_back(cumulative_.back() + value);\n-}\n \n /**\n * \\fn Histogram::bins()\ndiff --git a/src/ipa/libipa/histogram.h b/src/ipa/libipa/histogram.h\nindex 54bb2a19..26326125 100644\n--- a/src/ipa/libipa/histogram.h\n+++ b/src/ipa/libipa/histogram.h\n@@ -10,10 +10,10 @@\n #include <assert.h>\n #include <limits.h>\n #include <stdint.h>\n-\n #include <vector>\n \n #include <libcamera/base/span.h>\n+#include <libcamera/base/utils.h>\n \n namespace libcamera {\n \n@@ -23,7 +23,17 @@ class Histogram\n {\n public:\n \tHistogram() { cumulative_.push_back(0); }\n-\tHistogram(Span<const uint32_t> data);\n+\n+\ttemplate<typename Transform>\n+\tHistogram(Span<const uint32_t> data,\n+\t\t Transform transform = [](uint32_t x) { return x; })\n+\t{\n+\t\tcumulative_.resize(data.size() + 1);\n+\t\tcumulative_[0] = 0;\n+\t\tfor (const auto &[i, value] : utils::enumerate(data))\n+\t\t\tcumulative_[i + 1] = cumulative_[i] + transform(value);\n+\t}\n+\n \tsize_t bins() const { return cumulative_.size() - 1; }\n \tuint64_t total() const { return cumulative_[cumulative_.size() - 1]; }\n \tuint64_t cumulativeFrequency(double bin) const;\n", "prefixes": [ "v3" ] }