Show a patch.

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

{
    "id": 19397,
    "url": "https://patchwork.libcamera.org/api/patches/19397/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/19397/",
    "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": "<20240113142218.28063-8-hdegoede@redhat.com>",
    "date": "2024-01-13T14:22:07",
    "name": "[libcamera-devel,v2,07/18] libcamera: software_isp: Add SwStats base class",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "c606544486d6bab07463614749a217127ed9cfb3",
    "submitter": {
        "id": 102,
        "url": "https://patchwork.libcamera.org/api/people/102/?format=api",
        "name": "Hans de Goede",
        "email": "hdegoede@redhat.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/19397/mbox/",
    "series": [
        {
            "id": 4142,
            "url": "https://patchwork.libcamera.org/api/series/4142/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4142",
            "date": "2024-01-13T14:22:00",
            "name": "[libcamera-devel,v2,01/18] libcamera: pipeline: simple: fix size adjustment in validate()",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/4142/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/19397/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/19397/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 D97FCC32BD\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 13 Jan 2024 14:22:49 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4A2DE628D7;\n\tSat, 13 Jan 2024 15:22:49 +0100 (CET)",
            "from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.129.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1179061D57\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 13 Jan 2024 15:22:47 +0100 (CET)",
            "from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73])\n\tby relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n\tcipher=TLS_AES_256_GCM_SHA384) id us-mta-339-EqBQ_aKLOjqAWpNOs7DCuQ-1;\n\tSat, 13 Jan 2024 09:22:43 -0500",
            "from smtp.corp.redhat.com\n\t(int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1])\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 04E2E1C0CCB8;\n\tSat, 13 Jan 2024 14:22:43 +0000 (UTC)",
            "from localhost.localdomain (unknown [10.39.192.58])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id DA70F3C25;\n\tSat, 13 Jan 2024 14:22:40 +0000 (UTC)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1705155769;\n\tbh=lObTuBQCrBYAxAFT0s3W3uHT3+9ndjnV+qHHBjDRaxk=;\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:Cc:\n\tFrom;\n\tb=e8cxydadbqf1+x1VOa57Xl1MUg+AITNxB8nAUMXECHtLwNdWg4byYCl8fEyy7/TuW\n\tQq4bq/TdR+MbaNHDWbYJ2KLMPdSHoNqM+YA5d9ndxVjQnXCxVuAmbn1lTnpWX2NiYg\n\t76MAeAL2TV4JXyZzDveCGDSGFgeK8b5Dpp0SRNSnryynxUPWHVWWciss2Eb9k0EVF6\n\t5VGAOauB1GbglY91TZMvywe8A8X4Ah1p1vlPegI2+sYPpeUe1+OaX2rA0lbSA4UhAs\n\teRUqLhPbA+jLAiq3M2nwmgj6KmCY7pCO6TuWepJbdPfDsEQqQL4FRMU61kufvYF8wY\n\tGxprT2RcYi3Zw==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1705155767;\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=1dVTJdC2XcSn2yOY5g3dW1cPZNI0Y/weZM4xp5bZgqw=;\n\tb=hOTvaqaiVDX7JdfTnmU3VUUjaBevSxUG2WUenezYda8ufIok9+XMsoKKLL06J6IneTdOWl\n\tTNBi5xR+ppspsKBWKeWKKSRQO5UnNT1NcD/uxzoDWTVigrTH88S5+idDHmob1FfmajV8Dv\n\tUr9yjOAwYjuN1HKQ+3vNYhfq3x9noFs="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=redhat.com\n\theader.i=@redhat.com header.b=\"hOTvaqai\"; \n\tdkim-atps=neutral",
        "X-MC-Unique": "EqBQ_aKLOjqAWpNOs7DCuQ-1",
        "To": "libcamera-devel@lists.libcamera.org,\n\tAndrey Konovalov <andrey.konovalov.ynk@gmail.com>",
        "Date": "Sat, 13 Jan 2024 15:22:07 +0100",
        "Message-ID": "<20240113142218.28063-8-hdegoede@redhat.com>",
        "In-Reply-To": "<20240113142218.28063-1-hdegoede@redhat.com>",
        "References": "<20240113142218.28063-1-hdegoede@redhat.com>",
        "MIME-Version": "1.0",
        "X-Scanned-By": "MIMEDefang 3.4.1 on 10.11.54.1",
        "X-Mimecast-Spam-Score": "0",
        "X-Mimecast-Originator": "redhat.com",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain; charset=\"US-ASCII\"; x-default=true",
        "Subject": "[libcamera-devel] [PATCH v2 07/18] libcamera: software_isp: Add\n\tSwStats base class",
        "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": "Hans de Goede via libcamera-devel <libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Hans de Goede <hdegoede@redhat.com>",
        "Cc": "Maxime Ripard <mripard@redhat.com>, g.martti@gmail.com,\n\tt.langendam@gmail.com, srinivas.kandagatla@linaro.org,\n\tPavel Machek <pavel@ucw.cz>,\n\tBryan O'Donoghue <bryan.odonoghue@linaro.org>, admin@dennisbonke.com",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Add a virtual base class for CPU based software statistics gathering\nimplementations.\n\nThe idea is for the implementations to offer a configure function +\nfunctions to gather statistics on a line by line basis. This allows\nCPU based software debayering to call into interlace debayering and\nstatistics gathering on a line by line bases while the input data\nis still hot in the cache.\n\nThis base class also allows the user of an implementation to specify\na window over which to gather statistics instead of processing the\nwhole frame; and it allows the implementation to choose to only\nprocess 1/2, 1/4th, etc. of the lines instead of processing all\nlines (in the window) by setting y_skip_mask_ from configure().\nSkipping columns is left up the line-processing functions provided\nby the implementation.\n\nDoxygen documentation by Dennis Bonke.\n\nCo-authored-by: Dennis Bonke <admin@dennisbonke.com>\nSigned-off-by: Dennis Bonke <admin@dennisbonke.com>\nCo-authored-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>\nTested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> # sc8280xp Lenovo x13s\nTested-by: Pavel Machek <pavel@ucw.cz>\n---\n include/libcamera/internal/meson.build        |   1 +\n .../internal/software_isp/meson.build         |   6 +\n .../internal/software_isp/swisp_stats.h       |  34 +++\n .../libcamera/internal/software_isp/swstats.h | 215 ++++++++++++++++++\n src/libcamera/meson.build                     |   1 +\n src/libcamera/software_isp/meson.build        |   5 +\n src/libcamera/software_isp/swstats.cpp        |  22 ++\n 7 files changed, 284 insertions(+)\n create mode 100644 include/libcamera/internal/software_isp/meson.build\n create mode 100644 include/libcamera/internal/software_isp/swisp_stats.h\n create mode 100644 include/libcamera/internal/software_isp/swstats.h\n create mode 100644 src/libcamera/software_isp/meson.build\n create mode 100644 src/libcamera/software_isp/swstats.cpp",
    "diff": "diff --git a/include/libcamera/internal/meson.build b/include/libcamera/internal/meson.build\nindex 1325941d..caa533c4 100644\n--- a/include/libcamera/internal/meson.build\n+++ b/include/libcamera/internal/meson.build\n@@ -51,3 +51,4 @@ libcamera_internal_headers = files([\n ])\n \n subdir('converter')\n+subdir('software_isp')\ndiff --git a/include/libcamera/internal/software_isp/meson.build b/include/libcamera/internal/software_isp/meson.build\nnew file mode 100644\nindex 00000000..1c43acc4\n--- /dev/null\n+++ b/include/libcamera/internal/software_isp/meson.build\n@@ -0,0 +1,6 @@\n+# SPDX-License-Identifier: CC0-1.0\n+\n+libcamera_internal_headers += files([\n+    'swisp_stats.h',\n+    'swstats.h',\n+])\ndiff --git a/include/libcamera/internal/software_isp/swisp_stats.h b/include/libcamera/internal/software_isp/swisp_stats.h\nnew file mode 100644\nindex 00000000..07ba7d6a\n--- /dev/null\n+++ b/include/libcamera/internal/software_isp/swisp_stats.h\n@@ -0,0 +1,34 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2023, Linaro Ltd\n+ *\n+ * swisp_stats.h - Statistics data format used by the software ISP and software IPA\n+ */\n+\n+#pragma once\n+\n+namespace libcamera {\n+\n+/**\n+ * \\brief Struct that holds the statistics for the Software ISP.\n+ */\n+struct SwIspStats {\n+\t/**\n+\t * \\brief Holds the sum of all sampled red pixels.\n+\t */\n+\tunsigned long sumR_;\n+\t/**\n+\t * \\brief Holds the sum of all sampled green pixels.\n+\t */\n+\tunsigned long sumG_;\n+\t/**\n+\t * \\brief Holds the sum of all sampled blue pixels.\n+\t */\n+\tunsigned long sumB_;\n+\t/**\n+\t * \\brief A histogram of luminance values.\n+\t */\n+\tunsigned int y_histogram[16];\n+};\n+\n+} /* namespace libcamera */\ndiff --git a/include/libcamera/internal/software_isp/swstats.h b/include/libcamera/internal/software_isp/swstats.h\nnew file mode 100644\nindex 00000000..dcac7064\n--- /dev/null\n+++ b/include/libcamera/internal/software_isp/swstats.h\n@@ -0,0 +1,215 @@\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+ * swstats.h - software statistics 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+\n+namespace libcamera {\n+\n+class PixelFormat;\n+struct SharedFD;\n+struct StreamConfiguration;\n+\n+LOG_DECLARE_CATEGORY(SwStats)\n+\n+/**\n+ * \\class SwStats\n+ * \\brief Base class for the software ISP statistics.\n+ *\n+ * Base class for the software ISP statistics.\n+ */\n+class SwStats\n+{\n+public:\n+\tvirtual ~SwStats() = 0;\n+\n+\t/**\n+\t * \\brief Gets wether the statistics object is valid.\n+\t * \n+\t * \\return true if it's valid, false otherwise.\n+\t */\n+\tvirtual bool isValid() const = 0;\n+\n+\t/**\n+\t * \\brief Configure the statistics object for the passed in input format.\n+\t * \\param[in] inputCfg The input format\n+\t *\n+\t * \\return 0 on success, a negative errno value on failure.\n+\t */\n+\tvirtual int configure(const StreamConfiguration &inputCfg) = 0;\n+\n+\t/**\n+\t * \\brief Get the file descriptor for the statistics.\n+\t *\n+\t * \\return the file descriptor\n+\t */\n+\tvirtual const SharedFD &getStatsFD() = 0;\n+\n+protected:\n+\t/**\n+\t * \\brief Called when there is data to get statistics from.\n+\t * \\param[in] src The input data\n+\t */\n+\ttypedef void (SwStats::*statsProcessFn)(const uint8_t *src[]);\n+\t/**\n+\t * \\brief Called when the statistics gathering is done or when a new frame starts.\n+\t */\n+\ttypedef void (SwStats::*statsVoidFn)();\n+\n+\t/* Variables set by configure(), used every line */\n+\t/**\n+\t * \\brief The function called when a line is ready for statistics processing.\n+\t *\n+\t * Used for line 0 and 1, repeating if there isn't a 3rd and a 4th line in the bayer order.\n+\t */\n+\tstatsProcessFn stats0_;\n+\t/**\n+\t * \\brief The function called when a line is ready for statistics processing.\n+\t *\n+\t * Used for line 3 and 4, only needed if the bayer order has 4 different lines.\n+\t */\n+\tstatsProcessFn stats2_;\n+\n+\t/**\n+\t * \\brief The memory used per pixel in bits.\n+\t */\n+\tunsigned int bpp_;\n+\t/**\n+\t * \\brief Skip lines where this bitmask is set in y.\n+\t */\n+\tunsigned int y_skip_mask_;\n+\n+\t/**\n+\t * \\brief Statistics window, set by setWindow(), used ever line.\n+\t */\n+\tRectangle window_;\n+\n+\t/**\n+\t * \\brief The function called at the start of a frame.\n+\t */\n+\tstatsVoidFn startFrame_;\n+\t/**\n+\t * \\brief The function called at the end of a frame.\n+\t */\n+\tstatsVoidFn finishFrame_;\n+\t/**\n+\t * \\brief The size of the bayer pattern.\n+\t */\n+\tSize patternSize_;\n+\t/**\n+\t * \\brief The offset of x, applied to window_.x for bayer variants.\n+\t *\n+\t * This can either be 0 or 1.\n+\t */\n+\tunsigned int x_shift_;\n+\n+public:\n+\t/**\n+\t * \\brief Get the pattern size.\n+\t *\n+\t * For some input-formats, e.g. Bayer data, processing is done multiple lines\n+\t * and/or columns at a time. Get width and height at which the (bayer) pattern\n+\t * repeats. Window values are rounded down to a multiple of this and the height\n+\t * also indicates if processLine2() should be called or not.\n+\t * This may only be called after a successful configure() call.\n+\t *\n+\t * \\return the pattern size.\n+\t */\n+\tconst Size &patternSize() { return patternSize_; }\n+\n+\t/**\n+\t * \\brief Specify window coordinates over which to gather statistics.\n+\t * \\param[in] window The window object.\n+\t */\n+\tvoid setWindow(Rectangle window)\n+\t{\n+\t\twindow_ = window;\n+\n+\t\twindow_.x &= ~(patternSize_.width - 1);\n+\t\twindow_.x += x_shift_;\n+\t\twindow_.y &= ~(patternSize_.height - 1);\n+\n+\t\t/* width_ - x_shift_ to make sure the window fits */\n+\t\twindow_.width -= x_shift_;\n+\t\twindow_.width &= ~(patternSize_.width - 1);\n+\t\twindow_.height &= ~(patternSize_.height - 1);\n+\t}\n+\n+\t/**\n+\t * \\brief Reset state to start statistics gathering for a new frame.\n+\t * \n+\t * This may only be called after a successful setWindow() call.\n+\t */\n+\tvoid startFrame()\n+\t{\n+\t\t(this->*startFrame_)();\n+\t}\n+\n+\t/**\n+\t * \\brief Process line 0.\n+\t * \\param[in] y The y coordinate.\n+\t * \\param[in] src The input data.\n+\t *\n+\t * This function processes line 0 for input formats with patternSize height == 1.\n+\t * It'll process line 0 and 1 for input formats with patternSize height >= 2.\n+\t * This function may only be called after a successful setWindow() call.\n+\t */\n+\tvoid processLine0(unsigned int y, const uint8_t *src[])\n+\t{\n+\t\tif ((y & y_skip_mask_) || y < (unsigned int)window_.y ||\n+\t\t    y >= (window_.y + window_.height))\n+\t\t\treturn;\n+\n+\t\t(this->*stats0_)(src);\n+\t}\n+\n+\t/**\n+\t * \\brief Process line 2 and 3.\n+\t * \\param[in] y The y coordinate.\n+\t * \\param[in] src The input data.\n+\t *\n+\t * This function processes line 2 and 3 for input formats with patternSize height == 4.\n+\t * This function may only be called after a successful setWindow() call.\n+\t */\n+\tvoid processLine2(unsigned int y, const uint8_t *src[])\n+\t{\n+\t\tif ((y & y_skip_mask_) || y < (unsigned int)window_.y ||\n+\t\t    y >= (window_.y + window_.height))\n+\t\t\treturn;\n+\n+\t\t(this->*stats2_)(src);\n+\t}\n+\n+\t/**\n+\t * \\brief Finish statistics calculation for the current frame.\n+\t * \n+\t * This may only be called after a successful setWindow() call.\n+\t */\n+\tvoid finishFrame()\n+\t{\n+\t\t(this->*finishFrame_)();\n+\t}\n+\n+\t/**\n+\t * \\brief Signals that the statistics are ready.\n+\t *\n+\t * The int parameter isn't actually used.\n+\t */\n+\tSignal<int> statsReady;\n+};\n+\n+} /* namespace libcamera */\ndiff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\nindex 86494663..3d63e8a2 100644\n--- a/src/libcamera/meson.build\n+++ b/src/libcamera/meson.build\n@@ -71,6 +71,7 @@ subdir('converter')\n subdir('ipa')\n subdir('pipeline')\n subdir('proxy')\n+subdir('software_isp')\n \n null_dep = dependency('', required : false)\n \ndiff --git a/src/libcamera/software_isp/meson.build b/src/libcamera/software_isp/meson.build\nnew file mode 100644\nindex 00000000..9359075d\n--- /dev/null\n+++ b/src/libcamera/software_isp/meson.build\n@@ -0,0 +1,5 @@\n+# SPDX-License-Identifier: CC0-1.0\n+\n+libcamera_sources += files([\n+\t'swstats.cpp',\n+])\ndiff --git a/src/libcamera/software_isp/swstats.cpp b/src/libcamera/software_isp/swstats.cpp\nnew file mode 100644\nindex 00000000..e65a7ada\n--- /dev/null\n+++ b/src/libcamera/software_isp/swstats.cpp\n@@ -0,0 +1,22 @@\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+ * swstats.cpp - software statistics base class\n+ */\n+\n+#include \"libcamera/internal/software_isp/swstats.h\"\n+\n+namespace libcamera {\n+\n+LOG_DEFINE_CATEGORY(SwStats)\n+\n+SwStats::~SwStats()\n+{\n+}\n+\n+} /* namespace libcamera */\n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "07/18"
    ]
}