Show a patch.

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

{
    "id": 12333,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/12333/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/12333/",
    "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": "<20210521080530.37591-2-naush@raspberrypi.com>",
    "date": "2021-05-21T08:05:27",
    "name": "[libcamera-devel,v3,1/4] libcamera: utils: Add helper class for std::chrono::duration",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "e6a3c24c63a4f36fbb983293b580df1a417447d0",
    "submitter": {
        "id": 34,
        "url": "https://patchwork.libcamera.org/api/1.1/people/34/?format=api",
        "name": "Naushir Patuck",
        "email": "naush@raspberrypi.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/12333/mbox/",
    "series": [
        {
            "id": 2040,
            "url": "https://patchwork.libcamera.org/api/1.1/series/2040/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2040",
            "date": "2021-05-21T08:05:26",
            "name": "Switch RaspberryPi IPA to use std::chrono::duration",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/2040/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/12333/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/12333/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 2AD45C31FB\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 21 May 2021 08:05:40 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AC46468923;\n\tFri, 21 May 2021 10:05:39 +0200 (CEST)",
            "from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com\n\t[IPv6:2a00:1450:4864:20::42e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BCE826891B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 21 May 2021 10:05:37 +0200 (CEST)",
            "by mail-wr1-x42e.google.com with SMTP id z17so20081656wrq.7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 21 May 2021 01:05:37 -0700 (PDT)",
            "from naush-laptop.pitowers.org\n\t([2a00:1098:3142:14:de31:dc1f:6be5:f58e])\n\tby smtp.gmail.com with ESMTPSA id\n\tq186sm5159176wme.20.2021.05.21.01.05.36\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 21 May 2021 01:05:36 -0700 (PDT)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"IVfewFgr\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=yRQJD3FtFPwqzHyk8t5WbR7NjNmKo1823QiCzgBqqEg=;\n\tb=IVfewFgrePpL02prm8bD2YxpeG3vFFhYBXwC9LyCbkh2+M3oUVrHfdGikND+HqJMS1\n\ts1ht1grJ8hNjmgZDNL0HgEKUQEsMJMzVZ987dgpwy+F5d96yhdvpuiqBzdEGNP+E46AW\n\tjR3X9k+GEH0Lumn96xVLttxLK6zVQOV2A4GHIiGgkCPITvFXirBAz1DUicjASn0181Zc\n\tGnphrvGchQgrG32RVrQ2PCPjacKRrPlkEYFIPW++MUvfbErF1ipKSp9wkKVErxddp2+b\n\t6oBHtmc4WE2gaPopgjpE9rPFTcSKkArgpgBsbwVHW4PFuBPvMvhrJ2Za8ZSa+l7E5m2w\n\tCSTg==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=yRQJD3FtFPwqzHyk8t5WbR7NjNmKo1823QiCzgBqqEg=;\n\tb=quZIVvwT6H1z2Djc8zxI20ng+t9ltLkz3ZcDsz84dFkWqVFgbKu/iM5eThPj4jZDMx\n\tKb9RV8Ky057/YF8IZbsRIx4IQgl02UG0wlbj5wBQt6KZFqUIVvP2NOecbvJLStFZK9Uw\n\tdW/n1yS0s2kwq4LJWzJ+icxA5oJrjj81K9ezKWEnVebPptu5aAKG+hS+wuhN5UXjpYyG\n\tytUyepUs2gS8B42K1MbIqonuMDlB/DlHS7iuwUoZeJMNFXbLWSKRKOWBPengrdwyB/gJ\n\t1W/kfp7OF6wcYz14VvJAHz04CGZxo4tmxMRdAdkoDlMav8UAhnrzhXuJqmU66CpAS1Ur\n\t3YRw==",
        "X-Gm-Message-State": "AOAM530zSBN7Qnqj7WZONTiZIfd+47mRfk3dJI0ns0ZMFIySpZU8mi83\n\tmdRXg8H25fimOZwuL+WSJnr8QSJUwe80ZA==",
        "X-Google-Smtp-Source": "ABdhPJx7cfi6U+pLfI2++suwRSH5pvOI/+xiauMfN4ST2Gip66k0T3TyTEpX+/p8BxBx6IhdP3Mcmg==",
        "X-Received": "by 2002:a5d:638b:: with SMTP id p11mr8213160wru.90.1621584337297;\n\tFri, 21 May 2021 01:05:37 -0700 (PDT)",
        "From": "Naushir Patuck <naush@raspberrypi.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Fri, 21 May 2021 09:05:27 +0100",
        "Message-Id": "<20210521080530.37591-2-naush@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20210521080530.37591-1-naush@raspberrypi.com>",
        "References": "<20210521080530.37591-1-naush@raspberrypi.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v3 1/4] libcamera: utils: Add helper class\n\tfor std::chrono::duration",
        "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": "A new utils::Duration class is defined to represent a\nstd::chrono::duration type with double precision nanosecond timebase.\nUsing a double minimises the loss of precision when converting timebases.\nThis helper class may be used by IPAs to represent variables such as frame\ndurations and exposure times.\n\nAn operator << overload is define to help with displaying\nutils::Duration value in stream objects. Currently, this will display\nthe duration value in microseconds.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n include/libcamera/internal/utils.h | 42 ++++++++++++++++++++++++++++++\n src/libcamera/utils.cpp            | 36 +++++++++++++++++++++++++\n 2 files changed, 78 insertions(+)",
    "diff": "diff --git a/include/libcamera/internal/utils.h b/include/libcamera/internal/utils.h\nindex 83dada7cc16c..a377d4ea07ab 100644\n--- a/include/libcamera/internal/utils.h\n+++ b/include/libcamera/internal/utils.h\n@@ -316,6 +316,48 @@ auto enumerate(T (&iterable)[N]) -> details::enumerate_adapter<T *>\n }\n #endif\n \n+using BaseDuration = std::chrono::duration<double, std::nano>;\n+\n+class Duration : public BaseDuration\n+{\n+public:\n+\tDuration() = default;\n+\n+\ttemplate<typename Rep, typename Period>\n+\tconstexpr Duration(const std::chrono::duration<Rep, Period> &d)\n+\t\t: BaseDuration(d)\n+\t{\n+\t}\n+\n+\ttemplate<typename Period>\n+\tdouble get() const\n+\t{\n+\t\tauto const c = std::chrono::duration_cast<std::chrono::duration<double, Period>>(*this);\n+\t\treturn c.count();\n+\t}\n+\n+\texplicit constexpr operator bool() const\n+\t{\n+\t\treturn *this != BaseDuration::zero();\n+\t}\n+};\n+\n+#ifndef __DOXYGEN__\n+template<class CharT, class Traits>\n+static inline std::basic_ostream<CharT, Traits> &operator<<(std::basic_ostream<CharT, Traits> &os,\n+\t\t\t\t\t\t\t    const Duration &d)\n+{\n+\tstd::basic_ostringstream<CharT, Traits> s;\n+\n+\ts.flags(os.flags());\n+\ts.imbue(os.getloc());\n+\ts.setf(std::ios_base::fixed, std::ios_base::floatfield);\n+\ts.precision(2);\n+\ts << d.get<std::micro>() << \"us\";\n+\treturn os << s.str();\n+}\n+#endif\n+\n } /* namespace utils */\n \n } /* namespace libcamera */\ndiff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp\nindex 826144d3c837..3131aa2d6666 100644\n--- a/src/libcamera/utils.cpp\n+++ b/src/libcamera/utils.cpp\n@@ -506,6 +506,42 @@ std::string libcameraSourcePath()\n  * loop, iterates over an indexed view of the \\a iterable\n  */\n \n+/**\n+ * \\class Duration\n+ * \\brief Helper for std::chrono::duration types. Derived from \\a BaseDuration\n+ */\n+\n+/**\n+ * \\fn Duration::Duration(const std::chrono::duration<Rep, Period> &d)\n+ * \\brief Copy constructor from a \\a std::chrono::duration type.\n+ * \\param[in] d The std::chrono::duration object to convert from.\n+ *\n+ * Constructs a \\a Duration object from a \\a std::chrono::duration object,\n+ * converting the representation to \\a BaseDuration type.\n+ */\n+\n+/**\n+ * \\fn Duration::get<Period>()\n+ * \\brief Retrieve the tick count, coverted to the timebase provided by the\n+ * template argument Period of type \\a std::ratio.\n+ *\n+ * A typical usage example is given below:\n+ *\n+ * \\code{.cpp}\n+ * utils::Duration d = 5s;\n+ * double d_in_ms = d.get<std::milli>();\n+ * \\endcode\n+ *\n+ * \\return Tick count\n+ */\n+\n+/**\n+ * \\fn Duration::operator bool()\n+ * \\brief Boolean operator to test if a \\a Duration holds a non-zero time value.\n+ *\n+ * \\return True if \\a Duration is a non-zero time value, False otherwise.\n+ */\n+\n } /* namespace utils */\n \n } /* namespace libcamera */\n",
    "prefixes": [
        "libcamera-devel",
        "v3",
        "1/4"
    ]
}