From patchwork Thu Sep 26 00:23:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 21374 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id DCBB6C3257 for ; Thu, 26 Sep 2024 00:23:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E77336350E; Thu, 26 Sep 2024 02:23:39 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="JCpI8aDL"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 03CD3634FB for ; Thu, 26 Sep 2024 02:23:37 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0C324169 for ; Thu, 26 Sep 2024 02:22:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1727310130; bh=4QgfbP6sMNIa/z4R0U/svIc8EzqcPup2zZK8NpDTctY=; h=From:To:Subject:Date:From; b=JCpI8aDLU3CVmzwcC8JEGNoZg89NFjtH65bg9FDju45jMcOk68CzUi8FdwMzACRPp V0L7xc9KTDL/b9Xlk9ZcILU87yPkdV3G4divrQbR1gTQ/cV7JqUDIlEGBlRFAc1tps we37hrC+odjTnxBBne8FFQp28ytsLq7tZQRad7q8= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH] libcamera: Replace usage of lroundf() with std::lround() Date: Thu, 26 Sep 2024 03:23:35 +0300 Message-ID: <20240926002335.27509-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" As explained in the coding style document, usage of std::lround() is preferred over lroundf() as it picks the correct function based on the argument type. Replace calls to lroundf() with std::lround() through libcamera. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi --- Documentation/guides/pipeline-handler.rst | 4 ++-- src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 8 ++++---- src/libcamera/pipeline/vimc/vimc.cpp | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) base-commit: f2088eb91fd6477b152233b9031cb115ca1ae824 diff --git a/Documentation/guides/pipeline-handler.rst b/Documentation/guides/pipeline-handler.rst index 26aea43341d4..69e832a5587e 100644 --- a/Documentation/guides/pipeline-handler.rst +++ b/Documentation/guides/pipeline-handler.rst @@ -1350,7 +1350,7 @@ before being set. continue; } - int32_t value = lroundf(it.second.get() * 128 + offset); + int32_t value = std::lround(it.second.get() * 128 + offset); controls.set(cid, std::clamp(value, 0, 255)); } @@ -1414,7 +1414,7 @@ value translation operations: .. code-block:: cpp - #include + #include Frame completion and event handling ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp index 6b32fa18799b..7fa01bb71744 100644 --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp @@ -6,9 +6,9 @@ */ #include +#include #include #include -#include #include #include #include @@ -320,14 +320,14 @@ int PipelineHandlerUVC::processControl(ControlList *controls, unsigned int id, case V4L2_CID_BRIGHTNESS: { float scale = std::max(max - def, def - min); float fvalue = value.get() * scale + def; - controls->set(cid, static_cast(lroundf(fvalue))); + controls->set(cid, static_cast(std::lround(fvalue))); break; } case V4L2_CID_SATURATION: { float scale = def - min; float fvalue = value.get() * scale + min; - controls->set(cid, static_cast(lroundf(fvalue))); + controls->set(cid, static_cast(std::lround(fvalue))); break; } @@ -354,7 +354,7 @@ int PipelineHandlerUVC::processControl(ControlList *controls, unsigned int id, } float fvalue = (value.get() - p) / m; - controls->set(cid, static_cast(lroundf(fvalue))); + controls->set(cid, static_cast(std::lround(fvalue))); break; } diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp index 325174b90087..2165bae890cb 100644 --- a/src/libcamera/pipeline/vimc/vimc.cpp +++ b/src/libcamera/pipeline/vimc/vimc.cpp @@ -6,9 +6,9 @@ */ #include +#include #include #include -#include #include #include @@ -420,7 +420,7 @@ int PipelineHandlerVimc::processControls(VimcCameraData *data, Request *request) continue; } - int32_t value = lroundf(it.second.get() * 128 + offset); + int32_t value = std::lround(it.second.get() * 128 + offset); controls.set(cid, std::clamp(value, 0, 255)); }