From fa2dfd55cc9e86589e505f9edc82a94b57405677 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Thu, 26 Sep 2024 03:19:50 +0300 Subject: libcamera: Replace usage of lroundf() with std::lround() 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(-) diff --git a/Documentation/guides/pipeline-handler.rst b/Documentation/guides/pipeline-handler.rst index 26aea433..69e832a5 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 6b32fa18..7fa01bb7 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 325174b9..2165bae8 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)); } -- cgit v1.2.1