Patch Detail
Show a patch.
GET /api/1.1/patches/18240/?format=api
{ "id": 18240, "url": "https://patchwork.libcamera.org/api/1.1/patches/18240/?format=api", "web_url": "https://patchwork.libcamera.org/patch/18240/", "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": "<20230203091734.22803-2-naush@raspberrypi.com>", "date": "2023-02-03T09:17:30", "name": "[libcamera-devel,v4,1/5] ipa: raspberrypi: Generalise statistics", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "f2da56e6e6957c27a5dd32c128332ac98eb55e5e", "submitter": { "id": 34, "url": "https://patchwork.libcamera.org/api/1.1/people/34/?format=api", "name": "Naushir Patuck", "email": "naush@raspberrypi.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/18240/mbox/", "series": [ { "id": 3738, "url": "https://patchwork.libcamera.org/api/1.1/series/3738/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3738", "date": "2023-02-03T09:17:29", "name": "Raspberry Pi: Generalise statistics", "version": 4, "mbox": "https://patchwork.libcamera.org/series/3738/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/18240/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/18240/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 075BFBEFBE\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 3 Feb 2023 09:17:44 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id F4158625EE;\n\tFri, 3 Feb 2023 10:17:41 +0100 (CET)", "from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com\n\t[IPv6:2a00:1450:4864:20::32a])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7728761EF4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 3 Feb 2023 10:17:40 +0100 (CET)", "by mail-wm1-x32a.google.com with SMTP id\n\tm5-20020a05600c4f4500b003db03b2559eso3327931wmq.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 03 Feb 2023 01:17:40 -0800 (PST)", "from localhost.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\taz24-20020a05600c601800b003dc4baaedd3sm7468864wmb.37.2023.02.03.01.17.39\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 03 Feb 2023 01:17:39 -0800 (PST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1675415862;\n\tbh=gnjOLxwHnFSU2iGTu7KO1N3RlVXKuSggoauFfbGNjrI=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=TveAgHmL/hZO7OFwSR3Xam2d8PJSz47M5wWQB4VeILCc30vKlRJWDgHAvJdX6ZrZ7\n\tog3Dht7HeGAQGzF2pI+hdqiUDR8X4dxZZMo/xa/4h7fiD2FGM5U5GuYWlFdLBAJ/11\n\th+5a9NHnwUyur4A/YU6/W36itBEGKzZL9dwy8c0ZwmS40IJ383rZ9YDiP2XW+yI/Hu\n\t9PRY1jGpdcVH+MN6VglAFk3F9DndouxaU+7Yy2Y2FnzC0wvuKrMLRlyVGDiiMl3L2c\n\tKGLqbLAdG51sbxfSDsbvtPq/XsXR9gxvi+TB1PQDzoZ8w2XDgCyao2eShLN/z18sDX\n\tVEJPyK5JvCVfw==", "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=cFKCg+ZE+nhe2cGJPAWdDIMNRxjiykJzy0Pv0P4gmyY=;\n\tb=XAjSdPzxrRaAYn5n9SnykQbJk04dkhF9ux0jIhrfo/sLHL60V2vbzR47WzYJCNyEYr\n\tlM96hZ1DKePJ6MhjI1eYty4VmxtrF7EvtVHHKgScvKfhA02iswi+OapC8zGp/1052Jbh\n\tzKvXX/z5p/U4eEwxyqrZEXy8Ea5fAHa7gX9MvPJDTgiMjnU+QKAKqaahX5CpwJbI/Kl9\n\t0qc8Har2pBiSJvyDQY4LEZWgauJ6yTnkbtD8tYhMVWfJ1AAxBgRhxeudl9QXhLvAiiDj\n\tMW+BPqVhoX3bpxNGhGL6t8m1xrmDSGtr39cIDwxVyk6I/eKv3e9qtGKddV9xtTrFC0FW\n\trDaA==" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"XAjSdPzx\"; dkim-atps=neutral", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=cFKCg+ZE+nhe2cGJPAWdDIMNRxjiykJzy0Pv0P4gmyY=;\n\tb=ae9T6bLiFdJBb4fxkbMJqT/URW0KAZ3ilC/ysPkt0fFllR6HCrp246uSySOMQpfZim\n\tmvdbY8wzQ4nvKyOXLwjZpmma6xEtZ3I9HYyJbSP4fK1P/Iv/m+aHWB2z6Z/CS4aYPu+1\n\tZ/oOyvC6NgILlZ+ipnJGBVIxuPRcqYoW5LVFYEKx9H1wgt5IQ7rAyr03uzBbI46j+AOI\n\te/ifgzXFQ5RAxod48ip/L58EziQID+tivo65LhGXqhroCuPnlpa4fwqnIb4ODZ3EPATH\n\tyN41A5lPDEfq5lxY9ptfe1VDM5onVOb8bghHByAum7KbBVLv7qmUNiFJsxB7qCtMPQyt\n\tDp9w==", "X-Gm-Message-State": "AO0yUKXnRI9Wv1gcl1zrAcNtsr7k7jqEQPljDE72jJ8GQvfy+ObVZoJf\n\tUiKi23IVGpsm/f+pWbVUR18jIFMLrbK+w9WGvjnMnA==", "X-Google-Smtp-Source": "AK7set/H/+V1VTQR06YTnEHPb5NVNR6CNF6XJkebH+pLS01w/XHD9mhkLm7cc1n2HmutrziY3HoJzQ==", "X-Received": "by 2002:a1c:4c08:0:b0:3de:b1ec:7f95 with SMTP id\n\tz8-20020a1c4c08000000b003deb1ec7f95mr8978810wmf.18.1675415859843; \n\tFri, 03 Feb 2023 01:17:39 -0800 (PST)", "To": "libcamera-devel@lists.libcamera.org", "Date": "Fri, 3 Feb 2023 09:17:30 +0000", "Message-Id": "<20230203091734.22803-2-naush@raspberrypi.com>", "X-Mailer": "git-send-email 2.25.1", "In-Reply-To": "<20230203091734.22803-1-naush@raspberrypi.com>", "References": "<20230203091734.22803-1-naush@raspberrypi.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v4 1/5] ipa: raspberrypi: Generalise\n\tstatistics", "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>", "From": "Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>", "Reply-To": "Naushir Patuck <naush@raspberrypi.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "At present, the controller algorithms access the bcm2835_isp_stats structure,\nwhich is hardware specific. It would be desirable to abstract out the statistics\nstructure to remove hardware specific headers from the algorithms source files.\n\nDefine a new templated RegionStats class that encompasses region based\nstatistics generated by the ISP. For the VC4 ISP, this can be used to hold\nRGB sums and focus FoM values.\n\nDefine a new Statistics structure that holds all the VC4 ISP statistics output.\nThis includes AGC histograms, AGC/AWB region sums and focus FoM regions.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/ipa/raspberrypi/controller/region_stats.h | 123 ++++++++++++++++++\n src/ipa/raspberrypi/statistics.h | 76 +++++++++++\n 2 files changed, 199 insertions(+)\n create mode 100644 src/ipa/raspberrypi/controller/region_stats.h\n create mode 100644 src/ipa/raspberrypi/statistics.h", "diff": "diff --git a/src/ipa/raspberrypi/controller/region_stats.h b/src/ipa/raspberrypi/controller/region_stats.h\nnew file mode 100644\nindex 000000000000..9aaf3a58a6f7\n--- /dev/null\n+++ b/src/ipa/raspberrypi/controller/region_stats.h\n@@ -0,0 +1,123 @@\n+/* SPDX-License-Identifier: BSD-2-Clause */\n+/*\n+ * Copyright (C) 2022, Raspberry Pi Ltd\n+ *\n+ * region_stats.h - Raspberry Pi region based statistics container\n+ */\n+#pragma once\n+\n+#include <array>\n+#include <stdint.h>\n+#include <vector>\n+\n+#include <libcamera/geometry.h>\n+\n+namespace RPiController {\n+\n+template<typename T>\n+class RegionStats\n+{\n+public:\n+\tstruct Region {\n+\t\tT val;\n+\t\tuint32_t counted;\n+\t\tuint32_t uncounted;\n+\t};\n+\n+\tRegionStats()\n+\t\t: size_({}), numFloating_(0), default_({})\n+\t{\n+\t}\n+\n+\tvoid init(const libcamera::Size &size, unsigned int numFloating = 0)\n+\t{\n+\t\tsize_ = size;\n+\t\tnumFloating_ = numFloating;\n+\t\tregions_.clear();\n+\t\tregions_.resize(size_.width * size_.height + numFloating_);\n+\t}\n+\n+\tvoid init(unsigned int num)\n+\t{\n+\t\tsize_ = libcamera::Size(num, 1);\n+\t\tnumFloating_ = 0;\n+\t\tregions_.clear();\n+\t\tregions_.resize(num);\n+\t}\n+\n+\tunsigned int numRegions() const\n+\t{\n+\t\treturn size_.width * size_.height;\n+\t}\n+\n+\tunsigned int numFloatingRegions() const\n+\t{\n+\t\treturn numFloating_;\n+\t}\n+\n+\tlibcamera::Size size() const\n+\t{\n+\t\treturn size_;\n+\t}\n+\n+\tvoid set(unsigned int index, const Region ®ion)\n+\t{\n+\t\tif (index >= numRegions())\n+\t\t\treturn;\n+\t\tset_(index, region);\n+\t}\n+\n+\tvoid set(const libcamera::Point &pos, const Region ®ion)\n+\t{\n+\t\tset(pos.y * size_.width + pos.x, region);\n+\t}\n+\n+\tvoid setFloating(unsigned int index, const Region ®ion)\n+\t{\n+\t\tif (index >= numFloatingRegions())\n+\t\t\treturn;\n+\t\tset(numRegions() + index, region);\n+\t}\n+\n+\tconst Region &get(unsigned int index) const\n+\t{\n+\t\tif (index >= numRegions())\n+\t\t\treturn default_;\n+\t\treturn get_(index);\n+\t}\n+\n+\tconst T &get(const libcamera::Point &pos) const\n+\t{\n+\t\treturn get(pos.y * size_.width + pos.x);\n+\t}\n+\n+\tconst T &getFloating(unsigned int index) const\n+\t{\n+\t\tif (index >= numFloatingRegions())\n+\t\t\treturn default_;\n+\t\treturn get_(numRegions() + index);\n+\t}\n+\n+\ttypename std::vector<Region>::iterator begin() { return regions_.begin(); }\n+\ttypename std::vector<Region>::iterator end() { return regions_.end(); }\n+\ttypename std::vector<Region>::const_iterator begin() const { return regions_.begin(); }\n+\ttypename std::vector<Region>::const_iterator end() const { return regions_.end(); }\n+\n+private:\n+\tvoid set_(unsigned int index, const Region ®ion)\n+\t{\n+\t\tregions_[index] = region;\n+\t}\n+\n+\tconst Region &get_(unsigned int index) const\n+\t{\n+\t\treturn regions_[index];\n+\t}\n+\n+\tlibcamera::Size size_;\n+\tunsigned int numFloating_;\n+\tstd::vector<Region> regions_;\n+\tRegion default_;\n+};\n+\n+} /* namespace RPiController */\ndiff --git a/src/ipa/raspberrypi/statistics.h b/src/ipa/raspberrypi/statistics.h\nnew file mode 100644\nindex 000000000000..ad486534b216\n--- /dev/null\n+++ b/src/ipa/raspberrypi/statistics.h\n@@ -0,0 +1,76 @@\n+/* SPDX-License-Identifier: BSD-2-Clause */\n+/*\n+ * Copyright (C) 2022, Raspberry Pi Ltd\n+ *\n+ * statistics.h - Raspberry Pi generic statistics structure\n+ */\n+#pragma once\n+\n+#include <memory>\n+#include <stdint.h>\n+#include <vector>\n+\n+#include \"histogram.h\"\n+#include \"region_stats.h\"\n+\n+namespace RPiController {\n+\n+struct RgbySums {\n+\tRgbySums(uint64_t _rSum = 0, uint64_t _gSum = 0, uint64_t _bSum = 0, uint64_t _ySum = 0)\n+\t\t: rSum(_rSum), gSum(_gSum), bSum(_bSum), ySum(_ySum)\n+\t{\n+\t}\n+\tuint64_t rSum;\n+\tuint64_t gSum;\n+\tuint64_t bSum;\n+\tuint64_t ySum;\n+};\n+\n+using RgbyRegions = RegionStats<RgbySums>;\n+using FocusRegions = RegionStats<uint64_t>;\n+\n+struct Statistics {\n+\t/*\n+\t * All region based statistics are normalised to 16-bits, giving a\n+\t * maximum value of (1 << NormalisationFactorPow2) - 1.\n+\t */\n+\tstatic constexpr unsigned int NormalisationFactorPow2 = 16;\n+\n+\t/*\n+\t * Positioning of the AGC statistics gathering in the pipeline:\n+\t * Pre-WB correction or post-WB correction.\n+\t * Assume this is post-LSC.\n+\t */\n+\tenum class AgcStatsPos { PreWb, PostWb };\n+\tconst AgcStatsPos agcStatsPos;\n+\n+\t/*\n+\t * Positioning of the AWB/ALSC statistics gathering in the pipeline:\n+\t * Pre-LSC or post-LSC.\n+\t */\n+\tenum class ColourStatsPos { PreLsc, PostLsc };\n+\tconst ColourStatsPos colourStatsPos;\n+\n+\tStatistics(AgcStatsPos a, ColourStatsPos c)\n+\t\t: agcStatsPos(a), colourStatsPos(c)\n+\t{\n+\t}\n+\n+\t/* Histogram statistics. Not all histograms may be populated! */\n+\tHistogram rHist;\n+\tHistogram gHist;\n+\tHistogram bHist;\n+\tHistogram yHist;\n+\n+\t/* Row sums for flicker avoidance. */\n+\tstd::vector<RgbySums> rowSums;\n+\n+\t/* Region based colour sums. */\n+\tRgbyRegions agcRegions;\n+\tRgbyRegions awbRegions;\n+\n+\t/* Region based focus FoM. */\n+\tFocusRegions focusRegions;\n+};\n+\n+} /* namespace RPiController */\n", "prefixes": [ "libcamera-devel", "v4", "1/5" ] }