Patch Detail
Show a patch.
GET /api/patches/13851/?format=api
{ "id": 13851, "url": "https://patchwork.libcamera.org/api/patches/13851/?format=api", "web_url": "https://patchwork.libcamera.org/patch/13851/", "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": "<20210914163709.85751-3-jeanmichel.hautbois@ideasonboard.com>", "date": "2021-09-14T16:37:06", "name": "[libcamera-devel,v8,2/5] ipa: ipu3: Rename IspStatsRegion to Accumulator", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "ad9674e6e6c61b7293397cc0010f6571acf54185", "submitter": { "id": 75, "url": "https://patchwork.libcamera.org/api/people/75/?format=api", "name": "Jean-Michel Hautbois", "email": "jeanmichel.hautbois@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/13851/mbox/", "series": [ { "id": 2531, "url": "https://patchwork.libcamera.org/api/series/2531/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2531", "date": "2021-09-14T16:37:04", "name": "Move and improve AWB structures", "version": 8, "mbox": "https://patchwork.libcamera.org/series/2531/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/13851/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/13851/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 60A51BDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 14 Sep 2021 16:37:17 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 82FFE69194;\n\tTue, 14 Sep 2021 18:37:15 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id F159F60132\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 14 Sep 2021 18:37:13 +0200 (CEST)", "from tatooine.ideasonboard.com (unknown\n\t[IPv6:2a01:e0a:169:7140:d0a7:2575:a724:b30a])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 83703B2B;\n\tTue, 14 Sep 2021 18:37:13 +0200 (CEST)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"W/JBLMC9\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1631637433;\n\tbh=Aw4KxdC8a77fU/I47il0Yqo1rGcZWltOQiJHUg3eahI=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=W/JBLMC90LagCiGDY+G7VTDP0MUuMs/oqXCNyokEgw5HzALn1iM0rXvfN3vMFesSj\n\tTUEFF4n65DngOVv3BTbgv9zT2/sMrrRt/9a3ia3a9hzHzrEu2xnIc266RAWLF/gvTZ\n\tk/CCqH/7z5viH/ufkH79P7RYIsao0fLzckEoviZg=", "From": "Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 14 Sep 2021 18:37:06 +0200", "Message-Id": "<20210914163709.85751-3-jeanmichel.hautbois@ideasonboard.com>", "X-Mailer": "git-send-email 2.30.2", "In-Reply-To": "<20210914163709.85751-1-jeanmichel.hautbois@ideasonboard.com>", "References": "<20210914163709.85751-1-jeanmichel.hautbois@ideasonboard.com>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v8 2/5] ipa: ipu3: Rename IspStatsRegion\n\tto Accumulator", "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": "The IspStatsRegion structure was introduced as an attempt to prepare for\na generic AWB algorithm structure. The structure name by itself is not\nexplicit and it is too optimistic to try and make a generic one for now.\n\nIts role is to accumulate the pixels in a given zone. Rename it to\naccumulator, and remove the uncounted field at the same time. It is\nalways possible to know how many pixels are not relevant for the\nalgorithm by calculating total-counted. The uncounted field was only\ndeclared and not used. Amend the documentation accordingly.\n\nSigned-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/ipa/ipu3/algorithms/awb.cpp | 77 +++++++++++++++++++++++++--------\n src/ipa/ipu3/algorithms/awb.h | 5 +--\n 2 files changed, 61 insertions(+), 21 deletions(-)", "diff": "diff --git a/src/ipa/ipu3/algorithms/awb.cpp b/src/ipa/ipu3/algorithms/awb.cpp\nindex e05647c9..d780a085 100644\n--- a/src/ipa/ipu3/algorithms/awb.cpp\n+++ b/src/ipa/ipu3/algorithms/awb.cpp\n@@ -21,26 +21,68 @@ static constexpr uint32_t kMinZonesCounted = 16;\n static constexpr uint32_t kMinGreenLevelInZone = 32;\n \n /**\n- * \\struct IspStatsRegion\n- * \\brief RGB statistics for a given region\n+ * \\struct Accumulator\n+ * \\brief RGB statistics for a given zone\n *\n- * The IspStatsRegion structure is intended to abstract the ISP specific\n- * statistics and use an agnostic algorithm to compute AWB.\n+ * - Cells are defined in Pixels\n+ * - Zones are defined in Cells\n *\n- * \\var IspStatsRegion::counted\n- * \\brief Number of pixels used to calculate the sums\n+ * 81 cells\n+ * /───────────── 1296 pixels ───────────\\\n+ * 16 zones\n+ * 16\n+ * ┌────┬────┬────┬────┬────┬─ ──────┬────┐ \\\n+ * │Cell│ │ │ │ │ | │ │ │\n+ * 16 │ px │ │ │ │ │ | │ │ │\n+ * ├────┼────┼────┼────┼────┼─ ──────┼────┤ │\n+ * │ │ │ │ │ │ | │ │\n+ * │ │ │ │ │ │ | │ │ 7\n+ * │ ── │ ── │ ── │ ── │ ── │ ── ── ─┤ ── │ 1 2 4\n+ * │ │ │ │ │ │ | │ │ 2 0 5\n *\n- * \\var IspStatsRegion::uncounted\n- * \\brief Remaining number of pixels in the region\n+ * │ │ │ │ │ │ | │ │ z p c\n+ * ├────┼────┼────┼────┼────┼─ ──────┼────┤ o i e\n+ * │ │ │ │ │ │ | │ │ n x l\n+ * │ │ | │ │ e e l\n+ * ├─── ───┼─ ──────┼────┤ s l s\n+ * │ │ | │ │ s\n+ * │ │ | │ │\n+ * ├─── Zone of Cells ───┼─ ──────┼────┤ │\n+ * │ (5 x 4) │ | │ │ │\n+ * │ │ | │ │ │\n+ * ├── ───┼─ ──────┼────┤ │\n+ * │ │ │ | │ │ │\n+ * │ │ │ │ │ │ | │ │ │\n+ * └────┴────┴────┴────┴────┴─ ──────┴────┘ /\n *\n- * \\var IspStatsRegion::rSum\n- * \\brief Sum of the red values in the region\n+ * The algorithm works with a fixed number of zones \\a kAwbStatsSizeX x\n+ * \\a kAwbStatsSizeY. For example, a frame of 1296x720 is divided into 81x45\n+ * cells of [16x16] pixels. In the case of \\a kAwbStatsSizeX=16 and\n+ * \\a kAwbStatsSizeY=12 the zones are made of [5x4] cells. The cells are\n+ * left-aligned and calculated by IPAIPU3::calculateBdsGrid().\n *\n- * \\var IspStatsRegion::gSum\n- * \\brief Sum of the green values in the region\n+ * Each statistics cell represents the average value of the pixels in that cell\n+ * split by colour components.\n *\n- * \\var IspStatsRegion::bSum\n- * \\brief Sum of the blue values in the region\n+ * The Accumulator structure stores the sum of the average of each cell in a\n+ * zone of the image, as well as the number of cells which were unsaturated and\n+ * therefore included in the average.\n+ * \\todo move this description and structure into a common header\n+ *\n+ * Cells which are saturated beyond the threshold defined in\n+ * ipu3_uapi_awb_config_s are not included in the average.\n+ *\n+ * \\var Accumulator::counted\n+ * \\brief Number of unsaturated cells used to calculate the sums\n+ *\n+ * \\var Accumulator::rSum\n+ * \\brief Sum of the average red values of each unsaturated cell in the zone\n+ *\n+ * \\var Accumulator::gSum\n+ * \\brief Sum of the average green values of each unsaturated cell in the zone\n+ *\n+ * \\var Accumulator::bSum\n+ * \\brief Sum of the average blue values of each unsaturated cell in the zone\n */\n \n /**\n@@ -157,7 +199,7 @@ uint32_t Awb::estimateCCT(double red, double green, double blue)\n \treturn 449 * n * n * n + 3525 * n * n + 6823.3 * n + 5520.33;\n }\n \n-/* Generate an RGB vector with the average values for each region */\n+/* Generate an RGB vector with the average values for each zone */\n void Awb::generateZones(std::vector<RGB> &zones)\n {\n \tfor (unsigned int i = 0; i < kAwbStatsSizeX * kAwbStatsSizeY; i++) {\n@@ -174,7 +216,7 @@ void Awb::generateZones(std::vector<RGB> &zones)\n \t}\n }\n \n-/* Translate the IPU3 statistics into the default statistics region array */\n+/* Translate the IPU3 statistics into the default statistics zone array */\n void Awb::generateAwbStats(const ipu3_uapi_stats_3a *stats,\n \t\t\t const ipu3_uapi_grid_config &grid)\n {\n@@ -215,7 +257,6 @@ void Awb::clearAwbStats()\n \t\tawbStats_[i].rSum = 0;\n \t\tawbStats_[i].gSum = 0;\n \t\tawbStats_[i].counted = 0;\n-\t\tawbStats_[i].uncounted = 0;\n \t}\n }\n \n@@ -304,7 +345,7 @@ void Awb::prepare(IPAContext &context, ipu3_uapi_params *params)\n \n \t/*\n \t * Optical center is column start (respectively row start) of the\n-\t * region of interest minus its X center (respectively Y center).\n+\t * cell of interest minus its X center (respectively Y center).\n \t *\n \t * For the moment use BDS as a first approximation, but it should\n \t * be calculated based on Shading (SHD) parameters.\ndiff --git a/src/ipa/ipu3/algorithms/awb.h b/src/ipa/ipu3/algorithms/awb.h\nindex cc848060..ac8ccc84 100644\n--- a/src/ipa/ipu3/algorithms/awb.h\n+++ b/src/ipa/ipu3/algorithms/awb.h\n@@ -33,9 +33,8 @@ struct Ipu3AwbCell {\n \tunsigned char padding[3];\n } __attribute__((packed));\n \n-struct IspStatsRegion {\n+struct Accumulator {\n \tunsigned int counted;\n-\tunsigned int uncounted;\n \tunsigned long long rSum;\n \tunsigned long long gSum;\n \tunsigned long long bSum;\n@@ -82,7 +81,7 @@ private:\n \tuint32_t estimateCCT(double red, double green, double blue);\n \n \tstd::vector<RGB> zones_;\n-\tIspStatsRegion awbStats_[kAwbStatsSizeX * kAwbStatsSizeY];\n+\tAccumulator awbStats_[kAwbStatsSizeX * kAwbStatsSizeY];\n \tAwbStatus asyncResults_;\n };\n \n", "prefixes": [ "libcamera-devel", "v8", "2/5" ] }