libcamera: Replace utils::clamp() with std::clamp()
Now that libcamera uses C++17, the C++ standard library provides std::clamp(). Drop our custom utils::clamp() function. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
This commit is contained in:
parent
b869d4463e
commit
f2734ff3ab
6 changed files with 14 additions and 29 deletions
|
@ -65,13 +65,6 @@ unsigned int set_overlap(InputIt1 first1, InputIt1 last1,
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* C++11 doesn't provide std::clamp */
|
|
||||||
template <typename T>
|
|
||||||
const T& clamp(const T& v, const T& lo, const T& hi)
|
|
||||||
{
|
|
||||||
return std::max(lo, std::min(v, hi));
|
|
||||||
}
|
|
||||||
|
|
||||||
using clock = std::chrono::steady_clock;
|
using clock = std::chrono::steady_clock;
|
||||||
using duration = std::chrono::steady_clock::duration;
|
using duration = std::chrono::steady_clock::duration;
|
||||||
using time_point = std::chrono::steady_clock::time_point;
|
using time_point = std::chrono::steady_clock::time_point;
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
#include <libipa/ipa_interface_wrapper.h>
|
#include <libipa/ipa_interface_wrapper.h>
|
||||||
|
|
||||||
#include "libcamera/internal/log.h"
|
#include "libcamera/internal/log.h"
|
||||||
#include "libcamera/internal/utils.h"
|
|
||||||
|
|
||||||
namespace libcamera {
|
namespace libcamera {
|
||||||
|
|
||||||
|
@ -234,12 +233,12 @@ void IPARkISP1::updateStatistics(unsigned int frame,
|
||||||
double exposure;
|
double exposure;
|
||||||
|
|
||||||
exposure = factor * exposure_ * gain_ / minGain_;
|
exposure = factor * exposure_ * gain_ / minGain_;
|
||||||
exposure_ = utils::clamp<uint64_t>((uint64_t)exposure,
|
exposure_ = std::clamp<uint64_t>((uint64_t)exposure,
|
||||||
minExposure_,
|
minExposure_,
|
||||||
maxExposure_);
|
maxExposure_);
|
||||||
|
|
||||||
exposure = exposure / exposure_ * minGain_;
|
exposure = exposure / exposure_ * minGain_;
|
||||||
gain_ = utils::clamp<uint64_t>((uint64_t)exposure,
|
gain_ = std::clamp<uint64_t>((uint64_t)exposure,
|
||||||
minGain_, maxGain_);
|
minGain_, maxGain_);
|
||||||
|
|
||||||
setControls(frame + 1);
|
setControls(frame + 1);
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
#include "imgu.h"
|
#include "imgu.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
|
@ -129,7 +130,7 @@ void calculateBDSHeight(ImgUDevice::Pipe *pipe, const Size &iif, const Size &gdc
|
||||||
if (!isSameRatio(pipe->input, gdc)) {
|
if (!isSameRatio(pipe->input, gdc)) {
|
||||||
float estIFHeight = (iif.width * gdc.height) /
|
float estIFHeight = (iif.width * gdc.height) /
|
||||||
static_cast<float>(gdc.width);
|
static_cast<float>(gdc.width);
|
||||||
estIFHeight = utils::clamp<float>(estIFHeight, minIFHeight, iif.height);
|
estIFHeight = std::clamp<float>(estIFHeight, minIFHeight, iif.height);
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
ifHeight = utils::alignUp(estIFHeight, IF_ALIGN_H);
|
ifHeight = utils::alignUp(estIFHeight, IF_ALIGN_H);
|
||||||
|
|
|
@ -240,13 +240,13 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate()
|
||||||
unsigned int limit;
|
unsigned int limit;
|
||||||
limit = utils::alignDown(cio2Configuration_.size.width - 1,
|
limit = utils::alignDown(cio2Configuration_.size.width - 1,
|
||||||
IMGU_OUTPUT_WIDTH_MARGIN);
|
IMGU_OUTPUT_WIDTH_MARGIN);
|
||||||
cfg->size.width = utils::clamp(cfg->size.width,
|
cfg->size.width = std::clamp(cfg->size.width,
|
||||||
IMGU_OUTPUT_MIN_SIZE.width,
|
IMGU_OUTPUT_MIN_SIZE.width,
|
||||||
limit);
|
limit);
|
||||||
|
|
||||||
limit = utils::alignDown(cio2Configuration_.size.height - 1,
|
limit = utils::alignDown(cio2Configuration_.size.height - 1,
|
||||||
IMGU_OUTPUT_HEIGHT_MARGIN);
|
IMGU_OUTPUT_HEIGHT_MARGIN);
|
||||||
cfg->size.height = utils::clamp(cfg->size.height,
|
cfg->size.height = std::clamp(cfg->size.height,
|
||||||
IMGU_OUTPUT_MIN_SIZE.height,
|
IMGU_OUTPUT_MIN_SIZE.height,
|
||||||
limit);
|
limit);
|
||||||
|
|
||||||
|
|
|
@ -360,7 +360,7 @@ int PipelineHandlerVimc::processControls(VimcCameraData *data, Request *request)
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t value = lroundf(it.second.get<float>() * 128 + offset);
|
int32_t value = lroundf(it.second.get<float>() * 128 + offset);
|
||||||
controls.set(cid, utils::clamp(value, 0, 255));
|
controls.set(cid, std::clamp(value, 0, 255));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto &ctrl : controls)
|
for (const auto &ctrl : controls)
|
||||||
|
|
|
@ -146,14 +146,6 @@ std::string dirname(const std::string &path)
|
||||||
* \return The number of elements in the intersection of the two ranges
|
* \return The number of elements in the intersection of the two ranges
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* \fn libcamera::utils::clamp(const T& v, const T& lo, const T& hi)
|
|
||||||
* \param[in] v The value to clamp
|
|
||||||
* \param[in] lo The lower boundary to clamp v to
|
|
||||||
* \param[in] hi The higher boundary to clamp v to
|
|
||||||
* \return lo if v is less than lo, hi if v is greater than hi, otherwise v
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \typedef clock
|
* \typedef clock
|
||||||
* \brief The libcamera clock (monotonic)
|
* \brief The libcamera clock (monotonic)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue