Show a patch.

GET /api/1.1/patches/14064/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 14064,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/14064/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/14064/",
    "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": "<20211006140041.964542-11-jeanmichel.hautbois@ideasonboard.com>",
    "date": "2021-10-06T14:00:40",
    "name": "[libcamera-devel,v3,10/12] ipa: ipu3: awb: Introduce Black Level Correction",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "421fcef14abb8446c6db7613bbe4ce28868236e4",
    "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/14064/mbox/",
    "series": [
        {
            "id": 2605,
            "url": "https://patchwork.libcamera.org/api/1.1/series/2605/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2605",
            "date": "2021-10-06T14:00:30",
            "name": "Improve ImgU statistics usage",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/2605/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/14064/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/14064/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 A839EC323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  6 Oct 2021 14:01:12 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5C868691E3;\n\tWed,  6 Oct 2021 16:01:12 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3CB9B691B9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  6 Oct 2021 16:01:03 +0200 (CEST)",
            "from tatooine.ideasonboard.com (unknown\n\t[IPv6:2a01:e0a:169:7140:843b:c831:54de:6e8c])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B584C1909;\n\tWed,  6 Oct 2021 16:01:02 +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=\"HfXZ/lio\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1633528862;\n\tbh=2YCuR9APHq6A/RiU6Vp0nBlesxn1903OFYld5uk3tyU=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=HfXZ/liosrXbCnBktz+xdeqNQ581hff3yloUzEhGHNCq+EGVBe5dnpolMESKzB1sS\n\tH90/XOJRuadxTmKt3+uNvAxmpNekoinXz2ieOsj+eH4MNiB+zr8KEH8iMuSn9IF9pG\n\tSrNhX3i+B2/ZcB3mUYp5izb3Y1B9QmQhxh2USs3E=",
        "From": "Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed,  6 Oct 2021 16:00:40 +0200",
        "Message-Id": "<20211006140041.964542-11-jeanmichel.hautbois@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.30.2",
        "In-Reply-To": "<20211006140041.964542-1-jeanmichel.hautbois@ideasonboard.com>",
        "References": "<20211006140041.964542-1-jeanmichel.hautbois@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v3 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 resulting 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>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/ipa/ipu3/algorithms/blc.cpp     | 66 +++++++++++++++++++++++++++++\n src/ipa/ipu3/algorithms/blc.h       | 28 ++++++++++++\n src/ipa/ipu3/algorithms/meson.build |  1 +\n src/ipa/ipu3/ipu3.cpp               |  2 +\n 4 files changed, 97 insertions(+)\n create mode 100644 src/ipa/ipu3/algorithms/blc.cpp\n create mode 100644 src/ipa/ipu3/algorithms/blc.h",
    "diff": "diff --git a/src/ipa/ipu3/algorithms/blc.cpp b/src/ipa/ipu3/algorithms/blc.cpp\nnew file mode 100644\nindex 00000000..df56e292\n--- /dev/null\n+++ b/src/ipa/ipu3/algorithms/blc.cpp\n@@ -0,0 +1,66 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2021, Google inc.\n+ *\n+ * blc.cpp - IPU3 Black Level Correction control\n+ */\n+\n+#include \"blc.h\"\n+\n+#include <string.h>\n+\n+/**\n+ * \\file blc.h\n+ */\n+\n+namespace libcamera {\n+\n+namespace ipa::ipu3::algorithms {\n+\n+/**\n+ * \\class BlackLevelCorrection\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. To achieve that, the ImgU BLC\n+ * algorithm subtracts a configurable offset from all pixels.\n+ *\n+ * The black level can be measured at runtime from an optical dark region of the\n+ * camera sensor, or measured during the camera tuning process. The first option\n+ * isn't currently supported.\n+ */\n+\n+BlackLevelCorrection::BlackLevelCorrection()\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 BlackLevelCorrection::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 rough 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/blc.h b/src/ipa/ipu3/algorithms/blc.h\nnew file mode 100644\nindex 00000000..4b7cb483\n--- /dev/null\n+++ b/src/ipa/ipu3/algorithms/blc.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 Black Level Correction control\n+ */\n+#ifndef __LIBCAMERA_IPU3_ALGORITHMS_BLC_H__\n+#define __LIBCAMERA_IPU3_ALGORITHMS_BLC_H__\n+\n+#include \"algorithm.h\"\n+\n+namespace libcamera {\n+\n+namespace ipa::ipu3::algorithms {\n+\n+class BlackLevelCorrection : public Algorithm\n+{\n+public:\n+\tBlackLevelCorrection();\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_BLC_H__ */\ndiff --git a/src/ipa/ipu3/algorithms/meson.build b/src/ipa/ipu3/algorithms/meson.build\nindex deae225b..3ec42f72 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+    'blc.cpp',\n     'tone_mapping.cpp',\n ])\ndiff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\nindex 06f53fbe..6d9bbf39 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/blc.h\"\n #include \"algorithms/tone_mapping.h\"\n #include \"libipa/camera_sensor_helper.h\"\n \n@@ -282,6 +283,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::BlackLevelCorrection>());\n \talgorithms_.push_back(std::make_unique<algorithms::ToneMapping>());\n \n \treturn 0;\n",
    "prefixes": [
        "libcamera-devel",
        "v3",
        "10/12"
    ]
}