Show a patch.

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

{
    "id": 12912,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/12912/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/12912/",
    "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": "<20210712131630.73914-2-jeanmichel.hautbois@ideasonboard.com>",
    "date": "2021-07-12T13:16:29",
    "name": "[libcamera-devel,1/2] ipa: libipa: Introduce Metadata class",
    "commit_ref": null,
    "pull_url": null,
    "state": "rejected",
    "archived": false,
    "hash": "9660b2ee60f32828cebe12147df2ca035e318464",
    "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/12912/mbox/",
    "series": [
        {
            "id": 2228,
            "url": "https://patchwork.libcamera.org/api/1.1/series/2228/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2228",
            "date": "2021-07-12T13:16:28",
            "name": "Introduce Metadata class in ipa",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/2228/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/12912/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/12912/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 3533DC3225\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 12 Jul 2021 13:16:41 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7550168524;\n\tMon, 12 Jul 2021 15:16:40 +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 F3F8B68521\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 12 Jul 2021 15:16:35 +0200 (CEST)",
            "from tatooine.ideasonboard.com (unknown\n\t[IPv6:2a01:e0a:169:7140:8515:881:eba9:bd61])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id A3EFFCC;\n\tMon, 12 Jul 2021 15:16:35 +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=\"Q9Kt5cxX\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1626095795;\n\tbh=5y59I+QOvMANoWNw+lKLAIekraM98dQs6W9KlRAlfdU=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=Q9Kt5cxXm2n4i21TmWSBxUNAiFyxIEBGk1eIPtbn7zwbHHDcCqUNtgynGYyziJiRK\n\tGzVT8DPM2G/q0ioVg541Vk5f28cvR5XdYeex7z2V15fOdrWUumnMoVYS4oSF1WQoZZ\n\tCMtgjBbIx4DfSiZldzAaNJJdaLXALf3XG1DoKzAc=",
        "From": "Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Mon, 12 Jul 2021 15:16:29 +0200",
        "Message-Id": "<20210712131630.73914-2-jeanmichel.hautbois@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.30.2",
        "In-Reply-To": "<20210712131630.73914-1-jeanmichel.hautbois@ideasonboard.com>",
        "References": "<20210712131630.73914-1-jeanmichel.hautbois@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 1/2] ipa: libipa: Introduce Metadata 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>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "The Metadata class comes from RPi from which a bit has been removed\nbecause we don't need it for now.\nAll functions are inlined in metadata.h because of the template usage.\n\nSigned-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n---\n src/ipa/ipu3/ipu3.cpp       |   1 +\n src/ipa/libipa/meson.build  |   6 ++-\n src/ipa/libipa/metadata.cpp | 101 ++++++++++++++++++++++++++++++++++++\n src/ipa/libipa/metadata.h   |  90 ++++++++++++++++++++++++++++++++\n 4 files changed, 196 insertions(+), 2 deletions(-)\n create mode 100644 src/ipa/libipa/metadata.cpp\n create mode 100644 src/ipa/libipa/metadata.h",
    "diff": "diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\nindex 71698d36..091856f5 100644\n--- a/src/ipa/ipu3/ipu3.cpp\n+++ b/src/ipa/ipu3/ipu3.cpp\n@@ -25,6 +25,7 @@\n #include \"ipu3_agc.h\"\n #include \"ipu3_awb.h\"\n #include \"libipa/camera_sensor_helper.h\"\n+#include \"libipa/metadata.h\"\n \n static constexpr uint32_t kMaxCellWidthPerSet = 160;\n static constexpr uint32_t kMaxCellHeightPerSet = 56;\ndiff --git a/src/ipa/libipa/meson.build b/src/ipa/libipa/meson.build\nindex 3fda7c00..cc4e1cc9 100644\n--- a/src/ipa/libipa/meson.build\n+++ b/src/ipa/libipa/meson.build\n@@ -3,13 +3,15 @@\n libipa_headers = files([\n     'algorithm.h',\n     'camera_sensor_helper.h',\n-    'histogram.h'\n+    'histogram.h',\n+    'metadata.h'\n ])\n \n libipa_sources = files([\n     'algorithm.cpp',\n     'camera_sensor_helper.cpp',\n-    'histogram.cpp'\n+    'histogram.cpp',\n+    'metadata.cpp'\n ])\n \n libipa_includes = include_directories('..')\ndiff --git a/src/ipa/libipa/metadata.cpp b/src/ipa/libipa/metadata.cpp\nnew file mode 100644\nindex 00000000..b6aef897\n--- /dev/null\n+++ b/src/ipa/libipa/metadata.cpp\n@@ -0,0 +1,101 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Based on the implementation from the Raspberry Pi IPA,\n+ * Copyright (C) 2019-2021, Raspberry Pi (Trading) Ltd.\n+ * Copyright (C) 2021, Ideas On Board\n+ *\n+ * metadata.cpp -  libipa metadata class\n+ */\n+\n+#include \"metadata.h\"\n+\n+/**\n+ * \\file metadata.h\n+ * \\brief A metadata class to share objects\n+ */\n+\n+namespace libcamera {\n+\n+namespace ipa {\n+\n+/**\n+ * \\class Metadata\n+ * \\brief A simple class for carrying arbitrary metadata, for example\n+ * about an image. It is used to exchange data between algorithms.\n+ */\n+\n+/**\n+ * \\fn Metadata::Metadata(Metadata const &other)\n+ * \\param[in] other A Metadata object\n+ *\n+ * Stores the data from one Metadata to another one\n+ */\n+\n+/**\n+ * \\fn Metadata::set(std::string const &tag, T const &value)\n+ * \\param[in] tag A string used as the key in a map\n+ * \\param[in] value The value to set into the map\n+ *\n+ * Sets the value in the map to the tag key. The mutex is\n+ * taken for the duration of the block.\n+ */\n+\n+/**\n+ * \\fn Metadata::get(std::string const &tag, T &value)\n+ * \\param[in] tag A string used as the key in a map\n+ * \\param[in] value The value to set into the map\n+ *\n+ * Gets the value in the map of the tag key. The mutex is\n+ * taken for the duration of the block.\n+ *\n+ * \\return 0 if value is found, -1 if not existent\n+ */\n+\n+/**\n+ * \\fn Metadata::clear()\n+ * Clear the Metadata map. The mutex is taken for the duration of\n+ * the block.\n+ */\n+\n+/**\n+ * \\fn Metadata::merge(Metadata &other)\n+ * \\param[in] other A metadata to merge with\n+ * Merge two Metadata maps. The mutex is taken for the duration of\n+ * the block.\n+ */\n+\n+/**\n+ * \\fn Metadata::getLocked(std::string const &tag)\n+ * \\param[in] tag A string used as the key in a map\n+ *\n+ * Get the value of the tag key in the map.\n+ * This allows in-place access to the Metadata contents,\n+ * for which you should be holding the lock.\n+ */\n+\n+/**\n+ * \\fn Metadata::setLocked(std::string const &tag, T const &value)\n+ * \\param[in] tag A string used as the key in a map\n+ * \\param[in] value The value to set into the map\n+ *\n+ * Set the value to the tag key in the map.\n+ * This allows in-place access to the Metadata contents,\n+ * for which you should be holding the lock.\n+ */\n+\n+/**\n+ * \\fn Metadata::lock()\n+ * Lock the mutex with the standard classes.\n+ * e.g. std::lock_guard<RPiController::Metadata> lock(metadata)\n+ */\n+\n+/**\n+ * \\fn Metadata::unlock()\n+ * Unlock the mutex with the standard classes.\n+ * e.g. std::lock_guard<RPiController::Metadata> lock(metadata)\n+ */\n+\n+} /* namespace ipa */\n+\n+} /* namespace libcamera */\n+\ndiff --git a/src/ipa/libipa/metadata.h b/src/ipa/libipa/metadata.h\nnew file mode 100644\nindex 00000000..9801bece\n--- /dev/null\n+++ b/src/ipa/libipa/metadata.h\n@@ -0,0 +1,90 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Based on the implementation from the Raspberry Pi IPA,\n+ * Copyright (C) 2019-2021, Raspberry Pi (Trading) Ltd.\n+ * Copyright (C) 2021, Ideas On Board\n+ *\n+ * metadata.h - libipa metadata class\n+ */\n+#ifndef __LIBCAMERA_IPA_LIBIPA_METADATA_H__\n+#define __LIBCAMERA_IPA_LIBIPA_METADATA_H__\n+\n+#include <any>\n+#include <map>\n+#include <memory>\n+#include <mutex>\n+#include <string>\n+\n+namespace libcamera {\n+\n+namespace ipa {\n+\n+class Metadata\n+{\n+public:\n+\tMetadata() = default;\n+\n+\tMetadata(Metadata const &other)\n+\t{\n+\t\tstd::scoped_lock other_lock(other.mutex_);\n+\t\tdata_ = other.data_;\n+\t}\n+\n+\ttemplate<typename T>\n+\tvoid set(std::string const &tag, T const &value)\n+\t{\n+\t\tstd::scoped_lock lock(mutex_);\n+\t\tdata_[tag] = value;\n+\t}\n+\n+\ttemplate<typename T>\n+\tint get(std::string const &tag, T &value) const\n+\t{\n+\t\tstd::scoped_lock lock(mutex_);\n+\t\tauto it = data_.find(tag);\n+\t\tif (it == data_.end())\n+\t\t\treturn -1;\n+\t\tvalue = std::any_cast<T>(it->second);\n+\t\treturn 0;\n+\t}\n+\n+\tvoid clear()\n+\t{\n+\t\tstd::scoped_lock lock(mutex_);\n+\t\tdata_.clear();\n+\t}\n+\n+\tvoid merge(Metadata &other)\n+\t{\n+\t\tstd::scoped_lock lock(mutex_, other.mutex_);\n+\t\tdata_.merge(other.data_);\n+\t}\n+\n+\ttemplate<typename T>\n+\tT *getLocked(std::string const &tag)\n+\t{\n+\t\tauto it = data_.find(tag);\n+\t\tif (it == data_.end())\n+\t\t\treturn nullptr;\n+\t\treturn std::any_cast<T>(&it->second);\n+\t}\n+\n+\ttemplate<typename T>\n+\tvoid setLocked(std::string const &tag, T const &value)\n+\t{\n+\t\tdata_[tag] = value;\n+\t}\n+\n+\tvoid lock() { mutex_.lock(); }\n+\tvoid unlock() { mutex_.unlock(); }\n+\n+private:\n+\tmutable std::mutex mutex_;\n+\tstd::map<std::string, std::any> data_;\n+};\n+\n+} /* namespace ipa */\n+\n+} /* namespace libcamera */\n+\n+#endif /* __LIBCAMERA_IPA_LIBIPA_METADATA_H__ */\n",
    "prefixes": [
        "libcamera-devel",
        "1/2"
    ]
}