Patch Detail
Show a patch.
GET /api/1.1/patches/20023/?format=api
{ "id": 20023, "url": "https://patchwork.libcamera.org/api/1.1/patches/20023/?format=api", "web_url": "https://patchwork.libcamera.org/patch/20023/", "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": "<20240508145924.1477599-1-paul.elder@ideasonboard.com>", "date": "2024-05-08T14:59:24", "name": "[v4] ipa: libipa: histogram: Add transform parameter to constructor", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "32c535e20352c218a5b61e634354f06301aef97e", "submitter": { "id": 17, "url": "https://patchwork.libcamera.org/api/1.1/people/17/?format=api", "name": "Paul Elder", "email": "paul.elder@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/20023/mbox/", "series": [ { "id": 4298, "url": "https://patchwork.libcamera.org/api/1.1/series/4298/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4298", "date": "2024-05-08T14:59:24", "name": "[v4] ipa: libipa: histogram: Add transform parameter to constructor", "version": 4, "mbox": "https://patchwork.libcamera.org/series/4298/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/20023/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/20023/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 57446C3226\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 8 May 2024 14:59:40 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5673D6342E;\n\tWed, 8 May 2024 16:59:39 +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 BF36962C9F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 8 May 2024 16:59:36 +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 4D28DB0B;\n\tWed, 8 May 2024 16:59:32 +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=\"lPUL0Dcj\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1715180373;\n\tbh=226FMTMyyzt3UxCrfoebsfkwF8AnGoCKwpW55OLXpN4=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=lPUL0DcjQPwAnHgr1adCMdzSh2B7wA+kk5OcjiIaJmn1jDIkud8FBsjTUk7WzlAr3\n\t+8VnjeHcbPodmqkwlG1WcYOtnalSmyJZnQgpf39CaU7OtzKWt21BU/xUGEM7pJoQj0\n\toroB75SVHsuN1gZpajYJdOyymern8U7ONJjTdc0I=", "From": "Paul Elder <paul.elder@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Paul Elder <paul.elder@ideasonboard.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>,\n\tDaniel Scally <dan.scally@ideasonboard.com>", "Subject": "[PATCH v4] ipa: libipa: histogram: Add transform parameter to\n\tconstructor", "Date": "Wed, 8 May 2024 23:59:24 +0900", "Message-Id": "<20240508145924.1477599-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>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Daniel Scally <dan.scally@ideasonboard.com>\n\n---\nChanges in v4:\n- fix compilation when called with no transform function\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 | 14 ++++++++++----\n src/ipa/libipa/histogram.h | 13 ++++++++++++-\n 2 files changed, 22 insertions(+), 5 deletions(-)", "diff": "diff --git a/src/ipa/libipa/histogram.cpp b/src/ipa/libipa/histogram.cpp\nindex c1aac59b..212acfdf 100644\n--- a/src/ipa/libipa/histogram.cpp\n+++ b/src/ipa/libipa/histogram.cpp\n@@ -43,12 +43,18 @@ namespace ipa {\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+\tcumulative_.resize(data.size() + 1);\n+\tcumulative_[0] = 0;\n+\tfor (const auto &[i, value] : utils::enumerate(data))\n+\t\tcumulative_[i + 1] = cumulative_[i] + value;\n }\n \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+\n /**\n * \\fn Histogram::bins()\n * \\brief Retrieve the number of bins currently used by the Histogram\ndiff --git a/src/ipa/libipa/histogram.h b/src/ipa/libipa/histogram.h\nindex 54bb2a19..0e9bef2a 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@@ -24,6 +24,17 @@ class Histogram\n public:\n \tHistogram() { cumulative_.push_back(0); }\n \tHistogram(Span<const uint32_t> data);\n+\n+\ttemplate<typename Transform,\n+\t\t std::enable_if_t<std::is_invocable_v<Transform, uint32_t>> * = nullptr>\n+\tHistogram(Span<const uint32_t> data, Transform transform)\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": [ "v4" ] }