Patch Detail
Show a patch.
GET /api/1.1/patches/19828/?format=api
{ "id": 19828, "url": "https://patchwork.libcamera.org/api/1.1/patches/19828/?format=api", "web_url": "https://patchwork.libcamera.org/patch/19828/", "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": "<20240404084657.353464-9-mzamazal@redhat.com>", "date": "2024-04-04T08:46:45", "name": "[v7,08/18] libcamera: software_isp: Add Debayer base class", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "f5e429e5fbf60fda9447578c582529fe84ad2f73", "submitter": { "id": 177, "url": "https://patchwork.libcamera.org/api/1.1/people/177/?format=api", "name": "Milan Zamazal", "email": "mzamazal@redhat.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/19828/mbox/", "series": [ { "id": 4246, "url": "https://patchwork.libcamera.org/api/1.1/series/4246/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4246", "date": "2024-04-04T08:46:37", "name": "libcamera: introduce Software ISP and Software IPA", "version": 7, "mbox": "https://patchwork.libcamera.org/series/4246/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/19828/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/19828/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 30587C32CD\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 4 Apr 2024 08:47:46 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B522B6338A;\n\tThu, 4 Apr 2024 10:47:45 +0200 (CEST)", "from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.133.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A80AD63389\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 4 Apr 2024 10:47:43 +0200 (CEST)", "from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com\n\t[66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-488-WjihLHTHPb-nL0-oG4vXbg-1; Thu, 04 Apr 2024 04:47:39 -0400", "from smtp.corp.redhat.com\n\t(int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\tkey-exchange X25519 server-signature RSA-PSS (2048 bits)\n\tserver-digest SHA256) (No client certificate requested)\n\tby mimecast-mx02.redhat.com (Postfix) with ESMTPS id 04CB2185A78A;\n\tThu, 4 Apr 2024 08:47:39 +0000 (UTC)", "from nuthatch.brq.redhat.com (unknown [10.43.17.39])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 86B408173;\n\tThu, 4 Apr 2024 08:47:37 +0000 (UTC)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"JVx6sX5d\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1712220462;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tcontent-transfer-encoding:content-transfer-encoding:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=fSszTJQB5gPNmvBm4TcPhdmDraKFa4Z75NzFnB31gjA=;\n\tb=JVx6sX5dktZkzuvyG93++agbvUB9TRn+epc0+jtDXRo02bd/JuFpdqkT+C6o705KXDdRSR\n\tBQLyN/v7XHZH5lNL+OXhxPNUSx4KBymQNo3icsbgaETZHhvbV3nToz1kHhfKWk46VLJ2FB\n\tyjnZq+StDA6tY7n5oQnUuWEsNPe2hQA=", "X-MC-Unique": "WjihLHTHPb-nL0-oG4vXbg-1", "From": "Milan Zamazal <mzamazal@redhat.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Hans de Goede <hdegoede@redhat.com>,\n\tAndrei Konovalov <andrey.konovalov.ynk@gmail.com>,\n\tBryan O'Donoghue <bryan.odonoghue@linaro.org>,\n\tMaxime Ripard <mripard@redhat.com>, Milan Zamazal <mzamazal@redhat.com>, \n\tPavel Machek <pavel@ucw.cz>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tDennis Bonke <admin@dennisbonke.com>,\n\tAndrey Konovalov <andrey.konovalov@linaro.org>", "Subject": "[PATCH v7 08/18] libcamera: software_isp: Add Debayer base class", "Date": "Thu, 4 Apr 2024 10:46:45 +0200", "Message-ID": "<20240404084657.353464-9-mzamazal@redhat.com>", "In-Reply-To": "<20240404084657.353464-1-mzamazal@redhat.com>", "References": "<20240404084657.353464-1-mzamazal@redhat.com>", "MIME-Version": "1.0", "X-Scanned-By": "MIMEDefang 3.4.1 on 10.11.54.5", "X-Mimecast-Spam-Score": "0", "X-Mimecast-Originator": "redhat.com", "Content-Transfer-Encoding": "8bit", "Content-Type": "text/plain; charset=\"US-ASCII\"; x-default=true", "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": "From: Hans de Goede <hdegoede@redhat.com>\n\nAdd a base class for debayer implementations. This is intended to be\nsuitable for both GPU (or otherwise) accelerated debayer implementations\nas well as CPU based debayering.\n\nDoxygen documentation by Dennis Bonke.\n\nTested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> # sc8280xp Lenovo x13s\nTested-by: Pavel Machek <pavel@ucw.cz>\nReviewed-by: Pavel Machek <pavel@ucw.cz>\nReviewed-by: Milan Zamazal <mzamazal@redhat.com>\nCo-developed-by: Dennis Bonke <admin@dennisbonke.com>\nSigned-off-by: Dennis Bonke <admin@dennisbonke.com>\nCo-developed-by: Andrey Konovalov <andrey.konovalov@linaro.org>\nSigned-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>\nSigned-off-by: Hans de Goede <hdegoede@redhat.com>\n---\n .../internal/software_isp/debayer_params.h | 25 ++++\n .../internal/software_isp/meson.build | 1 +\n src/libcamera/software_isp/TODO | 31 ++++\n src/libcamera/software_isp/debayer.cpp | 132 ++++++++++++++++++\n src/libcamera/software_isp/debayer.h | 54 +++++++\n src/libcamera/software_isp/meson.build | 1 +\n 6 files changed, 244 insertions(+)\n create mode 100644 include/libcamera/internal/software_isp/debayer_params.h\n create mode 100644 src/libcamera/software_isp/debayer.cpp\n create mode 100644 src/libcamera/software_isp/debayer.h", "diff": "diff --git a/include/libcamera/internal/software_isp/debayer_params.h b/include/libcamera/internal/software_isp/debayer_params.h\nnew file mode 100644\nindex 00000000..c818ca3a\n--- /dev/null\n+++ b/include/libcamera/internal/software_isp/debayer_params.h\n@@ -0,0 +1,25 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2023, Red Hat Inc.\n+ *\n+ * Authors:\n+ * Hans de Goede <hdegoede@redhat.com>\n+ *\n+ * debayer_params.h - DebayerParams header\n+ */\n+\n+#pragma once\n+\n+namespace libcamera {\n+\n+struct DebayerParams {\n+\tstatic constexpr unsigned int kGain10 = 256;\n+\n+\tunsigned int gainR;\n+\tunsigned int gainG;\n+\tunsigned int gainB;\n+\n+\tfloat gamma;\n+};\n+\n+} /* namespace libcamera */\ndiff --git a/include/libcamera/internal/software_isp/meson.build b/include/libcamera/internal/software_isp/meson.build\nindex 66c9c3fb..a620e16d 100644\n--- a/include/libcamera/internal/software_isp/meson.build\n+++ b/include/libcamera/internal/software_isp/meson.build\n@@ -1,5 +1,6 @@\n # SPDX-License-Identifier: CC0-1.0\n \n libcamera_internal_headers += files([\n+ 'debayer_params.h',\n 'swisp_stats.h',\n ])\ndiff --git a/src/libcamera/software_isp/TODO b/src/libcamera/software_isp/TODO\nindex 1c28fc36..7929e73e 100644\n--- a/src/libcamera/software_isp/TODO\n+++ b/src/libcamera/software_isp/TODO\n@@ -69,3 +69,34 @@ Removing the signal and refactoring those classes doesn't have to be\n addressed now, I think it would be part of a larger refactoring\n (possibly also considering platforms that have no ISP but can produce\n stats in hardware, such as the i.MX7), but please keep it on your radar.\n+\n+---\n+\n+4. Hide internal representation of gains from callers\n+\n+> struct DebayerParams {\n+> \tstatic constexpr unsigned int kGain10 = 256;\n+\n+Forcing the caller to deal with the internal representation of gains\n+isn't nice, especially given that it precludes implementing gains of\n+different precisions in different backend. Wouldn't it be better to pass\n+the values as floating point numbers, and convert them to the internal\n+representation in the implementation of process() before using them ?\n+\n+---\n+\n+5. Store ISP parameters in per-frame buffers\n+\n+> /**\n+> * \\fn void Debayer::process(FrameBuffer *input, FrameBuffer *output, DebayerParams params)\n+> * \\brief Process the bayer data into the requested format.\n+> * \\param[in] input The input buffer.\n+> * \\param[in] output The output buffer.\n+> * \\param[in] params The parameters to be used in debayering.\n+> *\n+> * \\note DebayerParams is passed by value deliberately so that a copy is passed\n+> * when this is run in another thread by invokeMethod().\n+> */\n+\n+Possibly something to address later, by storing ISP parameters in\n+per-frame buffers like we do for hardware ISPs.\ndiff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp\nnew file mode 100644\nindex 00000000..1c035e9b\n--- /dev/null\n+++ b/src/libcamera/software_isp/debayer.cpp\n@@ -0,0 +1,132 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2023, Linaro Ltd\n+ * Copyright (C) 2023, Red Hat Inc.\n+ *\n+ * Authors:\n+ * Hans de Goede <hdegoede@redhat.com>\n+ *\n+ * debayer.cpp - debayer base class\n+ */\n+\n+#include \"debayer.h\"\n+\n+namespace libcamera {\n+\n+/**\n+ * \\struct DebayerParams\n+ * \\brief Struct to hold the debayer parameters.\n+ */\n+\n+/**\n+ * \\var DebayerParams::kGain10\n+ * \\brief const value for 1.0 gain\n+ */\n+\n+/**\n+ * \\var DebayerParams::gainR\n+ * \\brief Red gain\n+ *\n+ * 128 = 0.5, 256 = 1.0, 512 = 2.0, etc.\n+ */\n+\n+/**\n+ * \\var DebayerParams::gainG\n+ * \\brief Green gain\n+ *\n+ * 128 = 0.5, 256 = 1.0, 512 = 2.0, etc.\n+ */\n+\n+/**\n+ * \\var DebayerParams::gainB\n+ * \\brief Blue gain\n+ *\n+ * 128 = 0.5, 256 = 1.0, 512 = 2.0, etc.\n+ */\n+\n+/**\n+ * \\var DebayerParams::gamma\n+ * \\brief Gamma correction, 1.0 is no correction\n+ */\n+\n+/**\n+ * \\class Debayer\n+ * \\brief Base debayering class\n+ *\n+ * Base class that provides functions for setting up the debayering process.\n+ */\n+\n+LOG_DEFINE_CATEGORY(Debayer)\n+\n+Debayer::~Debayer()\n+{\n+}\n+\n+/**\n+ * \\fn int Debayer::configure(const StreamConfiguration &inputCfg, const std::vector<std::reference_wrapper<StreamConfiguration>> &outputCfgs)\n+ * \\brief Configure the debayer object according to the passed in parameters.\n+ * \\param[in] inputCfg The input configuration.\n+ * \\param[in] outputCfgs The output configurations.\n+ *\n+ * \\return 0 on success, a negative errno on failure.\n+ */\n+\n+/**\n+ * \\fn Size Debayer::patternSize(PixelFormat inputFormat)\n+ * \\brief Get the width and height at which the bayer pattern repeats.\n+ * \\param[in] inputFormat The input format.\n+ *\n+ * Valid sizes are: 2x2, 4x2 or 4x4.\n+ *\n+ * \\return Pattern size or an empty size for unsupported inputFormats.\n+ */\n+\n+/**\n+ * \\fn std::vector<PixelFormat> Debayer::formats(PixelFormat inputFormat)\n+ * \\brief Get the supported output formats.\n+ * \\param[in] inputFormat The input format.\n+ *\n+ * \\return All supported output formats or an empty vector if there are none.\n+ */\n+\n+/**\n+ * \\fn std::tuple<unsigned int, unsigned int> Debayer::strideAndFrameSize(const PixelFormat &outputFormat, const Size &size)\n+ * \\brief Get the stride and the frame size.\n+ * \\param[in] outputFormat The output format.\n+ * \\param[in] size The output size.\n+ *\n+ * \\return A tuple of the stride and the frame size, or a tuple with 0,0 if\n+ * there is no valid output config.\n+ */\n+\n+/**\n+ * \\fn void Debayer::process(FrameBuffer *input, FrameBuffer *output, DebayerParams params)\n+ * \\brief Process the bayer data into the requested format.\n+ * \\param[in] input The input buffer.\n+ * \\param[in] output The output buffer.\n+ * \\param[in] params The parameters to be used in debayering.\n+ *\n+ * \\note DebayerParams is passed by value deliberately so that a copy is passed\n+ * when this is run in another thread by invokeMethod().\n+ */\n+\n+/**\n+ * \\fn virtual SizeRange Debayer::sizes(PixelFormat inputFormat, const Size &inputSize)\n+ * \\brief Get the supported output sizes for the given input format and size.\n+ * \\param[in] inputFormat The input format.\n+ * \\param[in] inputSize The input size.\n+ *\n+ * \\return The valid size ranges or an empty range if there are none.\n+ */\n+\n+/**\n+ * \\var Signal<FrameBuffer *> Debayer::inputBufferReady\n+ * \\brief Signals when the input buffer is ready.\n+ */\n+\n+/**\n+ * \\var Signal<FrameBuffer *> Debayer::outputBufferReady\n+ * \\brief Signals when the output buffer is ready.\n+ */\n+\n+} /* namespace libcamera */\ndiff --git a/src/libcamera/software_isp/debayer.h b/src/libcamera/software_isp/debayer.h\nnew file mode 100644\nindex 00000000..42ae58ab\n--- /dev/null\n+++ b/src/libcamera/software_isp/debayer.h\n@@ -0,0 +1,54 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2023, Linaro Ltd\n+ * Copyright (C) 2023, Red Hat Inc.\n+ *\n+ * Authors:\n+ * Hans de Goede <hdegoede@redhat.com>\n+ *\n+ * debayer.h - debayering base class\n+ */\n+\n+#pragma once\n+\n+#include <stdint.h>\n+\n+#include <libcamera/base/log.h>\n+#include <libcamera/base/signal.h>\n+\n+#include <libcamera/geometry.h>\n+#include <libcamera/stream.h>\n+\n+#include \"libcamera/internal/software_isp/debayer_params.h\"\n+\n+namespace libcamera {\n+\n+class FrameBuffer;\n+\n+LOG_DECLARE_CATEGORY(Debayer)\n+\n+class Debayer\n+{\n+public:\n+\tvirtual ~Debayer() = 0;\n+\n+\tvirtual int configure(const StreamConfiguration &inputCfg,\n+\t\t\t const std::vector<std::reference_wrapper<StreamConfiguration>> &outputCfgs) = 0;\n+\n+\tvirtual std::vector<PixelFormat> formats(PixelFormat inputFormat) = 0;\n+\n+\tvirtual std::tuple<unsigned int, unsigned int>\n+\tstrideAndFrameSize(const PixelFormat &outputFormat, const Size &size) = 0;\n+\n+\tvirtual void process(FrameBuffer *input, FrameBuffer *output, DebayerParams params) = 0;\n+\n+\tvirtual SizeRange sizes(PixelFormat inputFormat, const Size &inputSize) = 0;\n+\n+\tSignal<FrameBuffer *> inputBufferReady;\n+\tSignal<FrameBuffer *> outputBufferReady;\n+\n+private:\n+\tvirtual Size patternSize(PixelFormat inputFormat) = 0;\n+};\n+\n+} /* namespace libcamera */\ndiff --git a/src/libcamera/software_isp/meson.build b/src/libcamera/software_isp/meson.build\nindex 281bbf0e..6068a418 100644\n--- a/src/libcamera/software_isp/meson.build\n+++ b/src/libcamera/software_isp/meson.build\n@@ -8,5 +8,6 @@ if not softisp_enabled\n endif\n \n libcamera_sources += files([\n+ 'debayer.cpp',\n 'swstats_cpu.cpp',\n ])\n", "prefixes": [ "v7", "08/18" ] }