[{"id":12114,"web_url":"https://patchwork.libcamera.org/comment/12114/","msgid":"<b7f9037f-f5c3-9184-0b16-c2f614b2487c@ideasonboard.com>","date":"2020-08-24T09:54:40","subject":"Re: [libcamera-devel] [PATCH 2/5] libcamera: Replace utils::clamp()\n\twith std::clamp()","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi Laurent,\n\nOn 22/08/2020 21:00, Laurent Pinchart wrote:\n> Now that libcamera uses C++17, the C++ standard library provides\n> std::clamp(). Drop our custom utils::clamp() function.\n> \n\nThis one makes me happy. The less code we have to duplicate from\nstandard libraries the better ;-)\n\n\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\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(-)\n> \n> diff --git a/include/libcamera/internal/utils.h b/include/libcamera/internal/utils.h\n> index 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;\n> diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\n> index 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}\n> diff --git a/src/libcamera/pipeline/ipu3/imgu.cpp b/src/libcamera/pipeline/ipu3/imgu.cpp\n> index 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);\n> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> index 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);\n> diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp\n> index 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)\n> diff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp\n> index 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>","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 A3B70BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 24 Aug 2020 09:54:46 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4203D61ED9;\n\tMon, 24 Aug 2020 11:54:46 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A727460387\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 24 Aug 2020 11:54:44 +0200 (CEST)","from [192.168.0.20]\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id AE7BD279;\n\tMon, 24 Aug 2020 11:54:42 +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=\"PCs96jDk\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1598262882;\n\tbh=0Eud7OODIrvUTRi1NN51bmNv61So2Y2eXdGhrB0DtVo=;\n\th=Reply-To:Subject:To:References:From:Date:In-Reply-To:From;\n\tb=PCs96jDkSgC0T3krU7vZrcUqDlN7b2M6NzoS4iD2pTQQdBDL3r3gEtUdbkN/7CAe1\n\t1VGTA/lCqMMqgVI1QDxWm2fMKmSpcQlYYE2pxeKiSdnr/6I9hadOEAL6YntsaVT72i\n\t3dVCm9MKhF5YTpAphbnnuHDZ3OAsMz0SYqqHbT3A=","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20200822200037.20892-1-laurent.pinchart@ideasonboard.com>\n\t<20200822200037.20892-3-laurent.pinchart@ideasonboard.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Autocrypt":"addr=kieran.bingham@ideasonboard.com; keydata=\n\tmQINBFYE/WYBEACs1PwjMD9rgCu1hlIiUA1AXR4rv2v+BCLUq//vrX5S5bjzxKAryRf0uHat\n\tV/zwz6hiDrZuHUACDB7X8OaQcwhLaVlq6byfoBr25+hbZG7G3+5EUl9cQ7dQE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X8pwXEMCjz0h6qWNpGwJ0/tYIgQJZh6bqkvBrDogAvuhf60Sogw+mH8b+PBlx1L\n\toeTK396wc+4c3BfiC6pNtUS5GpsPMMjYMk7kVvEAEQEAAYkCPAQYAQoAJgIbDBYhBJAt15g/\n\tvSj943LUeqEeRnIQpGH9BQJdizzIBQkLSKZiAAoJEKEeRnIQpGH9eYgQAJpjaWNgqNOnMTmD\n\tMJggbwjIotypzIXfhHNCeTkG7+qCDlSaBPclcPGYrTwCt0YWPU2TgGgJrVhYT20ierN8LUvj\n\t6qOPTd+Uk7NFzL65qkh80ZKNBFddx1AabQpSVQKbdcLb8OFs85kuSvFdgqZwgxA1vl4TFhNz\n\tPZ79NAmXLackAx3sOVFhk4WQaKRshCB7cSl+RIng5S/ThOBlwNlcKG7j7W2MC06BlTbdEkUp\n\tECzuuRBv8wX4OQl+hbWbB/VKIx5HKlLu1eypen/5lNVzSqMMIYkkZcjV2SWQyUGxSwq0O/sx\n\tS0A8/atCHUXOboUsn54qdxrVDaK+6jIAuo8JiRWctP16KjzUM7MO0/+4zllM8EY57rXrj48j\n\tsbEYX0YQnzaj+jO6kJtoZsIaYR7rMMq9aUAjyiaEZpmP1qF/2sYenDx0Fg2BSlLvLvXM0vU8\n\tpQk3kgDu7kb/7PRYrZvBsr21EIQoIjXbZxDz/o7z95frkP71EaICttZ6k9q5oxxA5WC6sTXc\n\tMW8zs8avFNuA9VpXt0YupJd2ijtZy2mpZNG02fFVXhIn4G807G7+9mhuC4XG5rKlBBUXTvPU\n\tAfYnB4JBDLmLzBFavQfvonSfbitgXwCG3vS+9HEwAjU30Bar1PEOmIbiAoMzuKeRm2LVpmq4\n\tWZw01QYHU/GUV/zHJSFk","Organization":"Ideas on Board","Message-ID":"<b7f9037f-f5c3-9184-0b16-c2f614b2487c@ideasonboard.com>","Date":"Mon, 24 Aug 2020 10:54:40 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101\n\tThunderbird/68.10.0","MIME-Version":"1.0","In-Reply-To":"<20200822200037.20892-3-laurent.pinchart@ideasonboard.com>","Content-Language":"en-GB","Subject":"Re: [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>","Reply-To":"kieran.bingham@ideasonboard.com","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>"}},{"id":12125,"web_url":"https://patchwork.libcamera.org/comment/12125/","msgid":"<20200824211131.GB594558@oden.dyn.berto.se>","date":"2020-08-24T21:11:31","subject":"Re: [libcamera-devel] [PATCH 2/5] libcamera: Replace utils::clamp()\n\twith std::clamp()","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Laurent,\n\nThanks for your work.\n\nOn 2020-08-22 23:00:34 +0300, Laurent Pinchart wrote:\n> Now that libcamera uses C++17, the C++ standard library provides\n> std::clamp(). Drop our custom utils::clamp() function.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\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(-)\n> \n> diff --git a/include/libcamera/internal/utils.h b/include/libcamera/internal/utils.h\n> index 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;\n> diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\n> index 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}\n> diff --git a/src/libcamera/pipeline/ipu3/imgu.cpp b/src/libcamera/pipeline/ipu3/imgu.cpp\n> index 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);\n> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> index 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);\n> diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp\n> index 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)\n> diff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp\n> index 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> -- \n> Regards,\n> \n> Laurent Pinchart\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","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 8484DBD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 24 Aug 2020 21:11:34 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1F6B462818;\n\tMon, 24 Aug 2020 23:11:34 +0200 (CEST)","from mail-lj1-x242.google.com (mail-lj1-x242.google.com\n\t[IPv6:2a00:1450:4864:20::242])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4B5EE616B1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 24 Aug 2020 23:11:33 +0200 (CEST)","by mail-lj1-x242.google.com with SMTP id t23so11340735ljc.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 24 Aug 2020 14:11:33 -0700 (PDT)","from localhost (h-209-203.A463.priv.bahnhof.se. [155.4.209.203])\n\tby smtp.gmail.com with ESMTPSA id\n\ti1sm2391179ljg.94.2020.08.24.14.11.31\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 24 Aug 2020 14:11:31 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=ragnatech-se.20150623.gappssmtp.com\n\theader.i=@ragnatech-se.20150623.gappssmtp.com\n\theader.b=\"om3EDa0G\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to;\n\tbh=FZfdt1ZLf5KDprN6h0CyCAwHRJxfqntTX6dXhHITbIU=;\n\tb=om3EDa0GNaLRARzi8Z8R6algTJdEIN8T5n7QxJS+rpGTVhtSHYGOKrgjX7oKrVWh4e\n\tba48wsygoLlLJgPoeS2YQpCkNJKgCccjArSrVEAdxqrj3WACCy03MzM0KlUSU4YTatfi\n\tLGlaXnK4zoi8SusjULUPPOH8FA6AV7ImAXsxqxECjSFfS413MhCAaNxs0ZiDjGNO8ujh\n\trwWizHBGgiMeCqMaXOq1wpcmPbGWRt9rQRMwQY9Vlj0Rl2KyhPTnh3nGSoBMcdYBtVLi\n\t78cA6J7CfVFsQ+lu/j87OnYBQ5860mUkgQuCxlRwxwjm6NK6JUKO1h0JgrLhmH0p8qa2\n\t2Uvw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to;\n\tbh=FZfdt1ZLf5KDprN6h0CyCAwHRJxfqntTX6dXhHITbIU=;\n\tb=VjZrtNl3rJ22JmnCWX2KfNmEHMgsxbXDwJ1Bj31EZuH56VySP/bo4ba3vSmxw6z3L9\n\tPCTPaN40ZLdiN6eESZ5A7tvUvMHqHINq3o2VhKIRrq3YfLH1XDFY12NrhVRPtWB/+0pv\n\tuPhRgKl8uju4petRImpzPnFbZiPxgX2Hs1gJw+D7n5E0e/C1Zrj1Gxc7YNN9admHPEZ8\n\t8EzegpKZr4Ws5mlJxo4BTcavXbkxi9j/+DNVH/d9bVtUKmhTyznY/fyVyQ/vli/KeFwK\n\tKhsqJk74n0PDwnDgJFFv3UbNxXn76wX6EUAMHUU75Q3avw4Hp4bljymWuMvf6MPTIHu7\n\t9NlQ==","X-Gm-Message-State":"AOAM531X6i3peOJL8Ogvy6/iL1MQfxRYCT33YsdM76EvgHF1VSYDHaq2\n\tcJ40XikBoO9AvyHGT6y8oSbGXw==","X-Google-Smtp-Source":"ABdhPJx7+7MyM6ponnNKPBXRU0opagaB1TRixMt4PQJURQ80vQYZx+vUUrAkhRJ+9hVv/Oqh5TPHQw==","X-Received":"by 2002:a2e:a58b:: with SMTP id\n\tm11mr3339354ljp.135.1598303492472; \n\tMon, 24 Aug 2020 14:11:32 -0700 (PDT)","Date":"Mon, 24 Aug 2020 23:11:31 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20200824211131.GB594558@oden.dyn.berto.se>","References":"<20200822200037.20892-1-laurent.pinchart@ideasonboard.com>\n\t<20200822200037.20892-3-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200822200037.20892-3-laurent.pinchart@ideasonboard.com>","Subject":"Re: [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>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"iso-8859-1\"","Content-Transfer-Encoding":"quoted-printable","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]