Patch Detail
Show a patch.
GET /api/1.1/patches/13994/?format=api
{ "id": 13994, "url": "https://patchwork.libcamera.org/api/1.1/patches/13994/?format=api", "web_url": "https://patchwork.libcamera.org/patch/13994/", "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": "<20210930093715.73293-11-jeanmichel.hautbois@ideasonboard.com>", "date": "2021-09-30T09:37:13", "name": "[libcamera-devel,v2,10/12] ipa: ipu3: awb: Introduce Black Level Correction", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "1cda5e103aa4acea68ad84bdd63e2ca35c67f9df", "submitter": { "id": 75, "url": "https://patchwork.libcamera.org/api/1.1/people/75/?format=api", "name": "Jean-Michel Hautbois", "email": "jeanmichel.hautbois@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/13994/mbox/", "series": [ { "id": 2587, "url": "https://patchwork.libcamera.org/api/1.1/series/2587/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2587", "date": "2021-09-30T09:37:03", "name": "Improve ImgU statistics usage", "version": 2, "mbox": "https://patchwork.libcamera.org/series/2587/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/13994/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/13994/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 07993BDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 30 Sep 2021 09:37:35 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B365A691C7;\n\tThu, 30 Sep 2021 11:37:34 +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 DCC5B691B8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 30 Sep 2021 11:37:21 +0200 (CEST)", "from tatooine.ideasonboard.com (unknown\n\t[IPv6:2a01:e0a:169:7140:bab4:22c5:662d:e478])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7E6C0B2B;\n\tThu, 30 Sep 2021 11:37:21 +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=\"i/KmHXxM\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1632994641;\n\tbh=Hz82vcBRtJaofUifx/6e1lRt2lFJ5rNpThsTC2zIwKU=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=i/KmHXxMQwp+aQVZi8dVTd2+dSudbAzsRnJglWsmRT33rB0qUEX2CO7hvb3z5wsH0\n\tXeUFi3HVy5ehXr+Sa/rdWHQ0cOy9yiYK05nvy34EVzUxqHwjZjp8DwpQgSJFM9/tzJ\n\tE2IoW+6QVBCBWm13fzLQJ5KcxRpQtuvFiDFmxMOw=", "From": "Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Thu, 30 Sep 2021 11:37:13 +0200", "Message-Id": "<20210930093715.73293-11-jeanmichel.hautbois@ideasonboard.com>", "X-Mailer": "git-send-email 2.30.2", "In-Reply-To": "<20210930093715.73293-1-jeanmichel.hautbois@ideasonboard.com>", "References": "<20210930093715.73293-1-jeanmichel.hautbois@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2 10/12] ipa: ipu3: awb: Introduce Black\n\tLevel Correction", "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 pixels output by the camera normally include a black level, because\nsensors do not always report a signal level of '0' for black. Pixels at\nor below this level should be considered black and to achieve that, we\nneed to substract an offset to all the pixels. This can be taken into\naccount by reading the lowest value of a special region on sensors which\nis not exposed to light. This provides a substracting factor to be\nable to adjust the expected black levels in the resultant images.\n\nFor a camera outputting 10-bit pixel values (in the range 0 to 1023) a\ntypical black level might be 64. It is a fixed value, obtained by\ncapturing a raw frame with minimum exposure and gain fixed to 1.0 while\ncovering the sensor (the darker the better). We consider it good enough\nas a very first approximation, until we measure it during a tuning\nprocess and include it in a configuration file\n\nSigned-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/ipa/ipu3/algorithms/black_correction.cpp | 67 ++++++++++++++++++++\n src/ipa/ipu3/algorithms/black_correction.h | 28 ++++++++\n src/ipa/ipu3/algorithms/meson.build | 1 +\n src/ipa/ipu3/ipu3.cpp | 2 +\n 4 files changed, 98 insertions(+)\n create mode 100644 src/ipa/ipu3/algorithms/black_correction.cpp\n create mode 100644 src/ipa/ipu3/algorithms/black_correction.h", "diff": "diff --git a/src/ipa/ipu3/algorithms/black_correction.cpp b/src/ipa/ipu3/algorithms/black_correction.cpp\nnew file mode 100644\nindex 00000000..5b5b5d31\n--- /dev/null\n+++ b/src/ipa/ipu3/algorithms/black_correction.cpp\n@@ -0,0 +1,67 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2021, Google inc.\n+ *\n+ * black_correction.cpp - IPU3 Optical Black Correction control\n+ */\n+\n+#include \"black_correction.h\"\n+\n+#include <string.h>\n+\n+/**\n+ * \\file black_correction.h\n+ */\n+\n+namespace libcamera {\n+\n+namespace ipa::ipu3::algorithms {\n+\n+/**\n+ * \\class BlackCorrection\n+ * \\brief A class to handle optical black correction\n+ *\n+ * The pixels output by the camera normally include a black level, because\n+ * sensors do not always report a signal level of '0' for black. Pixels at or\n+ * below this level should be considered black and to achieve that, we need to\n+ * substract an offset to all the pixels.\n+ *\n+ * This can be taken into account by reading the lowest value of a special\n+ * region on sensors which is not exposed to light. This provides a substracting\n+ * factor to be able to adjust the expected black levels in the resultant\n+ * images.\n+ */\n+\n+BlackCorrection::BlackCorrection()\n+{\n+}\n+\n+/**\n+ * \\brief Fill in the parameter structure, and enable optical black correction\n+ * \\param context The shared IPA context\n+ * \\param params The IPU3 parameters\n+ *\n+ * Populate the IPU3 parameter structure with the correction values for each\n+ * channel and enable the corresponding ImgU block processing.\n+ */\n+void BlackCorrection::prepare([[maybe_unused]] IPAContext &context,\n+\t\t\t ipu3_uapi_params *params)\n+{\n+\t/*\n+\t * The Optical Black Level correction values\n+\t * \\todo The correction values should come from sensor specific\n+\t * tuning processes. This is a first approximation\n+\t */\n+\tparams->obgrid_param.gr = 64;\n+\tparams->obgrid_param.r = 64;\n+\tparams->obgrid_param.b = 64;\n+\tparams->obgrid_param.gb = 64;\n+\n+\t/* Enable the custom optical black correction processing */\n+\tparams->use.obgrid = 1;\n+\tparams->use.obgrid_param = 1;\n+}\n+\n+} /* namespace ipa::ipu3::algorithms */\n+\n+} /* namespace libcamera */\ndiff --git a/src/ipa/ipu3/algorithms/black_correction.h b/src/ipa/ipu3/algorithms/black_correction.h\nnew file mode 100644\nindex 00000000..6486ac5b\n--- /dev/null\n+++ b/src/ipa/ipu3/algorithms/black_correction.h\n@@ -0,0 +1,28 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2021, Google inc.\n+ *\n+ * black_correction.h - IPU3 Optical Black Correction control\n+ */\n+#ifndef __LIBCAMERA_IPU3_ALGORITHMS_BLACK_CORRECTION_H__\n+#define __LIBCAMERA_IPU3_ALGORITHMS_BLACK_CORRECTION_H__\n+\n+#include \"algorithm.h\"\n+\n+namespace libcamera {\n+\n+namespace ipa::ipu3::algorithms {\n+\n+class BlackCorrection : public Algorithm\n+{\n+public:\n+\tBlackCorrection();\n+\n+\tvoid prepare(IPAContext &context, ipu3_uapi_params *params) override;\n+};\n+\n+} /* namespace ipa::ipu3::algorithms */\n+\n+} /* namespace libcamera */\n+\n+#endif /* __LIBCAMERA_IPU3_ALGORITHMS_BLACK_CORRECTION_H__ */\ndiff --git a/src/ipa/ipu3/algorithms/meson.build b/src/ipa/ipu3/algorithms/meson.build\nindex deae225b..66877c1b 100644\n--- a/src/ipa/ipu3/algorithms/meson.build\n+++ b/src/ipa/ipu3/algorithms/meson.build\n@@ -4,5 +4,6 @@ ipu3_ipa_algorithms = files([\n 'agc.cpp',\n 'algorithm.cpp',\n 'awb.cpp',\n+ 'black_correction.cpp',\n 'tone_mapping.cpp',\n ])\ndiff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\nindex b33e8c77..7cc0fb89 100644\n--- a/src/ipa/ipu3/ipu3.cpp\n+++ b/src/ipa/ipu3/ipu3.cpp\n@@ -33,6 +33,7 @@\n #include \"algorithms/agc.h\"\n #include \"algorithms/algorithm.h\"\n #include \"algorithms/awb.h\"\n+#include \"algorithms/black_correction.h\"\n #include \"algorithms/tone_mapping.h\"\n #include \"libipa/camera_sensor_helper.h\"\n \n@@ -279,6 +280,7 @@ int IPAIPU3::init(const IPASettings &settings,\n \t/* Construct our Algorithms */\n \talgorithms_.push_back(std::make_unique<algorithms::Agc>());\n \talgorithms_.push_back(std::make_unique<algorithms::Awb>());\n+\talgorithms_.push_back(std::make_unique<algorithms::BlackCorrection>());\n \talgorithms_.push_back(std::make_unique<algorithms::ToneMapping>());\n \n \treturn 0;\n", "prefixes": [ "libcamera-devel", "v2", "10/12" ] }