Show a patch.

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

{
    "id": 12410,
    "url": "https://patchwork.libcamera.org/api/patches/12410/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/12410/",
    "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": "<20210525114241.906280-2-naush@raspberrypi.com>",
    "date": "2021-05-25T11:42:38",
    "name": "[libcamera-devel,v5,1/4] libcamera: utils: Add helper class for std::chrono::duration",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "c734afc47bfaf8c1644b6fe93b5402aa11ed7d55",
    "submitter": {
        "id": 34,
        "url": "https://patchwork.libcamera.org/api/people/34/?format=api",
        "name": "Naushir Patuck",
        "email": "naush@raspberrypi.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/12410/mbox/",
    "series": [
        {
            "id": 2066,
            "url": "https://patchwork.libcamera.org/api/series/2066/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2066",
            "date": "2021-05-25T11:42:37",
            "name": "Switch RaspberryPi IPA to use std::chrono::duration",
            "version": 5,
            "mbox": "https://patchwork.libcamera.org/series/2066/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/12410/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/12410/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 5E4E1C3203\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 25 May 2021 11:42:50 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9101668927;\n\tTue, 25 May 2021 13:42:48 +0200 (CEST)",
            "from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com\n\t[IPv6:2a00:1450:4864:20::42b])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E8F3A6050E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 25 May 2021 13:42:46 +0200 (CEST)",
            "by mail-wr1-x42b.google.com with SMTP id x8so31866240wrq.9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 25 May 2021 04:42:46 -0700 (PDT)",
            "from naush-laptop.pitowers.org\n\t([2a00:1098:3142:14:f3e2:c7ee:8a9d:4c3a])\n\tby smtp.gmail.com with ESMTPSA id\n\tv15sm2471443wmj.39.2021.05.25.04.42.45\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 25 May 2021 04:42:45 -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=\"OCV1cbS9\"; 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=XbwArGlWfTb3MkQN+yHRt2+njlOw3CwtqVUMKQwzAaI=;\n\tb=OCV1cbS9W2e07GOkWdQQUt7Muk2gXBZVsI2Gs3s7wL5Sb45GTvywfgIdE5xNtlDvKH\n\tsmF1QHUZldTa/Xh1IUBVVjhwCtmWD2hkJywgLm3y26+meD8FcVif+gFcpybRFVOr3SVC\n\t4LZpKw07VxMA4HI9CmNvK2gEfd86kCl9PU0f5SJQ10Pl9WZ6oMxULXXDMcjL3uUmH/dg\n\tRXdQIz7zoVZ/N9BIOnSmYMHGstb6omh+mUmPg46vducVW+wH1AUv7r8leuhwWGaXZYRU\n\t9ksOo1avTuUVoV3ZrT0Yghpctldu8UxbmdLrUMmOEcR9j06DUElCHvF2tAc3gnz19XLH\n\tpyjA==",
        "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=XbwArGlWfTb3MkQN+yHRt2+njlOw3CwtqVUMKQwzAaI=;\n\tb=gcmP+ITzPYqxjivrJyiI1EW3S/eL5sDFwCeVpb6mxb6qwC+rLE42y65pKp1GD72ElU\n\tnU5YM0c6xz6oroDM1m0OXGZFL1fSPur5vtAi26R4r7XtFfbSUtmZSeaJpD9EK98aI5v9\n\t5eFBVVNVq4YpEtnKwDMRO6RIdbmHSOTGEZeggSo4XnJCazivgIDsg+Lm6jCvqdm7bJRh\n\t9fVeyEps48agdrKgQT3NWx43jbaQrNGJdVUoH4s2TRkLcfeEVsMJ/6LEZJ1J4LlwPE1E\n\tWTr5hmPY+E2Ajc2lEvLn5i2TcfKGqzBkx5198hnMTLH++/rTdqcfIHzmM4RF49uYktY7\n\tV1Cw==",
        "X-Gm-Message-State": "AOAM532oSj6YFkJfVx+b3GOSykPxm1jG2XYHU3b3KrLY7uv53lj58MM8\n\tWqMRiE4qqOrMqSUDUvuJTuqoxzJR8xe8MA==",
        "X-Google-Smtp-Source": "ABdhPJw1kHCzt8PAqsNoLujuaiofMhQajZZxD+clLUKRdSzxbXxdK6Ll5vWVKX1DcgVegbe5ycyrIQ==",
        "X-Received": "by 2002:adf:ed52:: with SMTP id\n\tu18mr26155972wro.379.1621942966386; \n\tTue, 25 May 2021 04:42:46 -0700 (PDT)",
        "From": "Naushir Patuck <naush@raspberrypi.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue, 25 May 2021 12:42:38 +0100",
        "Message-Id": "<20210525114241.906280-2-naush@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20210525114241.906280-1-naush@raspberrypi.com>",
        "References": "<20210525114241.906280-1-naush@raspberrypi.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v5 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>\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n include/libcamera/internal/utils.h | 42 ++++++++++++++++++++++++++++++\n src/libcamera/utils.cpp            | 37 ++++++++++++++++++++++++++\n 2 files changed, 79 insertions(+)",
    "diff": "diff --git a/include/libcamera/internal/utils.h b/include/libcamera/internal/utils.h\nindex 83dada7cc16c..f536f2267d70 100644\n--- a/include/libcamera/internal/utils.h\n+++ b/include/libcamera/internal/utils.h\n@@ -316,8 +316,50 @@ auto enumerate(T (&iterable)[N]) -> details::enumerate_adapter<T *>\n }\n #endif\n \n+class Duration : public std::chrono::duration<double, std::nano>\n+{\n+\tusing BaseDuration = std::chrono::duration<double, std::nano>;\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 } /* namespace utils */\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 utils::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 libcamera */\n \n #endif /* __LIBCAMERA_INTERNAL_UTILS_H__ */\ndiff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp\nindex 826144d3c837..6624ff74cdc7 100644\n--- a/src/libcamera/utils.cpp\n+++ b/src/libcamera/utils.cpp\n@@ -506,6 +506,43 @@ std::string libcameraSourcePath()\n  * loop, iterates over an indexed view of the \\a iterable\n  */\n \n+/**\n+ * \\class Duration\n+ * \\brief Helper class from std::chrono::duration that represents a time\n+ * duration in nanoseconds with double precision\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+ * internally represented in double precision with nanoseconds ticks\n+ */\n+\n+/**\n+ * \\fn Duration::get<Period>()\n+ * \\brief Retrieve the tick count, converted 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 The tick count of the Duration expressed in \\a Period\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",
        "v5",
        "1/4"
    ]
}