Show a patch.

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

{
    "id": 9368,
    "url": "https://patchwork.libcamera.org/api/patches/9368/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/9368/",
    "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": "<20200822200037.20892-3-laurent.pinchart@ideasonboard.com>",
    "date": "2020-08-22T20:00:34",
    "name": "[libcamera-devel,2/5] libcamera: Replace utils::clamp() with std::clamp()",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "310611b0b0ce6279cfc8f5b4caad3e6034c9b474",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/9368/mbox/",
    "series": [
        {
            "id": 1235,
            "url": "https://patchwork.libcamera.org/api/series/1235/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1235",
            "date": "2020-08-22T20:00:32",
            "name": "libcamera: Switch to C++17",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/1235/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/9368/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/9368/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 95609BD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 22 Aug 2020 20:01:04 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BD11C62710;\n\tSat, 22 Aug 2020 22:01:02 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4955E61EA0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 22 Aug 2020 22:01:01 +0200 (CEST)",
            "from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D947929E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 22 Aug 2020 22:01:00 +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=\"C4QDNlkt\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1598126461;\n\tbh=/CKj5S48tCgLx9e/ISDOPZmfFLiqUjHaY7h7dtMEeSk=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=C4QDNlktvKV3K7iiTR5/SKKQgYSemwb4bxDLsQEQTaZqxL3pgZ7XWQIwVBTYeyVmG\n\tup3wW/bP59DmKwL/PL1Qo1ek2mbl3zGOwHf0eSvIQsAOg/OOH2ZUOAj9R6YCaunube\n\t372NAup0PyLmdncz+/NArMkMsFJErDk6cirLtjHg=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Sat, 22 Aug 2020 23:00:34 +0300",
        "Message-Id": "<20200822200037.20892-3-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.27.0",
        "In-Reply-To": "<20200822200037.20892-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20200822200037.20892-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH 2/5] libcamera: Replace utils::clamp()\n\twith std::clamp()",
        "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>",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Now that libcamera uses C++17, the C++ standard library provides\nstd::clamp(). Drop our custom utils::clamp() function.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/internal/utils.h   |  7 -------\n src/ipa/rkisp1/rkisp1.cpp            | 11 +++++------\n src/libcamera/pipeline/ipu3/imgu.cpp |  3 ++-\n src/libcamera/pipeline/ipu3/ipu3.cpp | 12 ++++++------\n src/libcamera/pipeline/vimc/vimc.cpp |  2 +-\n src/libcamera/utils.cpp              |  8 --------\n 6 files changed, 14 insertions(+), 29 deletions(-)",
    "diff": "diff --git a/include/libcamera/internal/utils.h b/include/libcamera/internal/utils.h\nindex 45cd6f120c51..a1b644b0345b 100644\n--- a/include/libcamera/internal/utils.h\n+++ b/include/libcamera/internal/utils.h\n@@ -65,13 +65,6 @@ unsigned int set_overlap(InputIt1 first1, InputIt1 last1,\n \treturn count;\n }\n \n-/* C++11 doesn't provide std::clamp */\n-template <typename T>\n-const T& clamp(const T& v, const T& lo, const T& hi)\n-{\n-\treturn std::max(lo, std::min(v, hi));\n-}\n-\n using clock = std::chrono::steady_clock;\n using duration = std::chrono::steady_clock::duration;\n using time_point = std::chrono::steady_clock::time_point;\ndiff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\nindex 4bb1627342fd..3a1c50c4add0 100644\n--- a/src/ipa/rkisp1/rkisp1.cpp\n+++ b/src/ipa/rkisp1/rkisp1.cpp\n@@ -24,7 +24,6 @@\n #include <libipa/ipa_interface_wrapper.h>\n \n #include \"libcamera/internal/log.h\"\n-#include \"libcamera/internal/utils.h\"\n \n namespace libcamera {\n \n@@ -234,13 +233,13 @@ void IPARkISP1::updateStatistics(unsigned int frame,\n \t\t\tdouble exposure;\n \n \t\t\texposure = factor * exposure_ * gain_ / minGain_;\n-\t\t\texposure_ = utils::clamp<uint64_t>((uint64_t)exposure,\n-\t\t\t\t\t\t\t   minExposure_,\n-\t\t\t\t\t\t\t   maxExposure_);\n+\t\t\texposure_ = std::clamp<uint64_t>((uint64_t)exposure,\n+\t\t\t\t\t\t\t minExposure_,\n+\t\t\t\t\t\t\t maxExposure_);\n \n \t\t\texposure = exposure / exposure_ * minGain_;\n-\t\t\tgain_ = utils::clamp<uint64_t>((uint64_t)exposure,\n-\t\t\t\t\t\t       minGain_, maxGain_);\n+\t\t\tgain_ = std::clamp<uint64_t>((uint64_t)exposure,\n+\t\t\t\t\t\t     minGain_, maxGain_);\n \n \t\t\tsetControls(frame + 1);\n \t\t}\ndiff --git a/src/libcamera/pipeline/ipu3/imgu.cpp b/src/libcamera/pipeline/ipu3/imgu.cpp\nindex eb829e096561..a4d74a62f69a 100644\n--- a/src/libcamera/pipeline/ipu3/imgu.cpp\n+++ b/src/libcamera/pipeline/ipu3/imgu.cpp\n@@ -7,6 +7,7 @@\n \n #include \"imgu.h\"\n \n+#include <algorithm>\n #include <cmath>\n #include <limits>\n \n@@ -129,7 +130,7 @@ void calculateBDSHeight(ImgUDevice::Pipe *pipe, const Size &iif, const Size &gdc\n \tif (!isSameRatio(pipe->input, gdc)) {\n \t\tfloat estIFHeight = (iif.width * gdc.height) /\n \t\t\t\t    static_cast<float>(gdc.width);\n-\t\testIFHeight = utils::clamp<float>(estIFHeight, minIFHeight, iif.height);\n+\t\testIFHeight = std::clamp<float>(estIFHeight, minIFHeight, iif.height);\n \t\tbool found = false;\n \n \t\tifHeight = utils::alignUp(estIFHeight, IF_ALIGN_H);\ndiff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 019e50b8f444..2d881fe28f98 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -240,15 +240,15 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate()\n \t\t\tunsigned int limit;\n \t\t\tlimit = utils::alignDown(cio2Configuration_.size.width - 1,\n \t\t\t\t\t\t IMGU_OUTPUT_WIDTH_MARGIN);\n-\t\t\tcfg->size.width = utils::clamp(cfg->size.width,\n-\t\t\t\t\t\t       IMGU_OUTPUT_MIN_SIZE.width,\n-\t\t\t\t\t\t       limit);\n+\t\t\tcfg->size.width = std::clamp(cfg->size.width,\n+\t\t\t\t\t\t     IMGU_OUTPUT_MIN_SIZE.width,\n+\t\t\t\t\t\t     limit);\n \n \t\t\tlimit = utils::alignDown(cio2Configuration_.size.height - 1,\n \t\t\t\t\t\t IMGU_OUTPUT_HEIGHT_MARGIN);\n-\t\t\tcfg->size.height = utils::clamp(cfg->size.height,\n-\t\t\t\t\t\t\tIMGU_OUTPUT_MIN_SIZE.height,\n-\t\t\t\t\t\t\tlimit);\n+\t\t\tcfg->size.height = std::clamp(cfg->size.height,\n+\t\t\t\t\t\t      IMGU_OUTPUT_MIN_SIZE.height,\n+\t\t\t\t\t\t      limit);\n \n \t\t\tcfg->size.alignDownTo(IMGU_OUTPUT_WIDTH_ALIGN,\n \t\t\t\t\t      IMGU_OUTPUT_HEIGHT_ALIGN);\ndiff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp\nindex cf244f11f242..7e237650b448 100644\n--- a/src/libcamera/pipeline/vimc/vimc.cpp\n+++ b/src/libcamera/pipeline/vimc/vimc.cpp\n@@ -360,7 +360,7 @@ int PipelineHandlerVimc::processControls(VimcCameraData *data, Request *request)\n \t\t}\n \n \t\tint32_t value = lroundf(it.second.get<float>() * 128 + offset);\n-\t\tcontrols.set(cid, utils::clamp(value, 0, 255));\n+\t\tcontrols.set(cid, std::clamp(value, 0, 255));\n \t}\n \n \tfor (const auto &ctrl : controls)\ndiff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp\nindex 615df46ac142..a5232902191e 100644\n--- a/src/libcamera/utils.cpp\n+++ b/src/libcamera/utils.cpp\n@@ -146,14 +146,6 @@ std::string dirname(const std::string &path)\n  * \\return The number of elements in the intersection of the two ranges\n  */\n \n-/**\n- * \\fn libcamera::utils::clamp(const T& v, const T& lo, const T& hi)\n- * \\param[in] v The value to clamp\n- * \\param[in] lo The lower boundary to clamp v to\n- * \\param[in] hi The higher boundary to clamp v to\n- * \\return lo if v is less than lo, hi if v is greater than hi, otherwise v\n- */\n-\n /**\n  * \\typedef clock\n  * \\brief The libcamera clock (monotonic)\n",
    "prefixes": [
        "libcamera-devel",
        "2/5"
    ]
}