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 <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
This commit is contained in:
Laurent Pinchart 2024-09-26 03:19:50 +03:00
parent 8b378a5606
commit fa2dfd55cc
3 changed files with 8 additions and 8 deletions

View file

@ -1350,7 +1350,7 @@ before being set.
continue;
}
int32_t value = lroundf(it.second.get<float>() * 128 + offset);
int32_t value = std::lround(it.second.get<float>() * 128 + offset);
controls.set(cid, std::clamp(value, 0, 255));
}
@ -1414,7 +1414,7 @@ value translation operations:
.. code-block:: cpp
#include <math.h>
#include <cmath>
Frame completion and event handling
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View file

@ -6,9 +6,9 @@
*/
#include <algorithm>
#include <cmath>
#include <fstream>
#include <map>
#include <math.h>
#include <memory>
#include <set>
#include <string>
@ -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<float>() * scale + def;
controls->set(cid, static_cast<int32_t>(lroundf(fvalue)));
controls->set(cid, static_cast<int32_t>(std::lround(fvalue)));
break;
}
case V4L2_CID_SATURATION: {
float scale = def - min;
float fvalue = value.get<float>() * scale + min;
controls->set(cid, static_cast<int32_t>(lroundf(fvalue)));
controls->set(cid, static_cast<int32_t>(std::lround(fvalue)));
break;
}
@ -354,7 +354,7 @@ int PipelineHandlerUVC::processControl(ControlList *controls, unsigned int id,
}
float fvalue = (value.get<float>() - p) / m;
controls->set(cid, static_cast<int32_t>(lroundf(fvalue)));
controls->set(cid, static_cast<int32_t>(std::lround(fvalue)));
break;
}

View file

@ -6,9 +6,9 @@
*/
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <math.h>
#include <tuple>
#include <linux/media-bus-format.h>
@ -420,7 +420,7 @@ int PipelineHandlerVimc::processControls(VimcCameraData *data, Request *request)
continue;
}
int32_t value = lroundf(it.second.get<float>() * 128 + offset);
int32_t value = std::lround(it.second.get<float>() * 128 + offset);
controls.set(cid, std::clamp(value, 0, 255));
}