diff options
Diffstat (limited to 'utils/meson.build')
0 files changed, 0 insertions, 0 deletions
![]() |
index : libcamera/jmondi/libcamera.git | |
Jacopo Mondi's clone of libcamera | git repository hosting on libcamera.org |
summaryrefslogtreecommitdiff |
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2024, Paul Elder <paul.elder@ideasonboard.com>
*
* Helper class that performs computations relating to exposure
*/
#include "exposure_mode_helper.h"
#include <algorithm>
#include <libcamera/base/log.h>
/**
* \file exposure_mode_helper.h
* \brief Helper class that performs computations relating to exposure
*
* AEGC algorithms have a need to split exposure between shutter time, analogue
* and digital gain. Multiple implementations do so based on paired stages of
* shutter time and gain limits; provide a helper to avoid duplicating the code.
*/
namespace libcamera {
using namespace std::literals::chrono_literals;
LOG_DEFINE_CATEGORY(ExposureModeHelper)
namespace ipa {
/**
* \class ExposureModeHelper
* \brief Class for splitting exposure into shutter time and total gain
*
* The ExposureModeHelper class provides a standard interface through which an
* AEGC algorithm can divide exposure between shutter time and gain. It is
* configured with a set of shutter time and gain pairs and works by initially
* fixing gain at 1.0 and increasing shutter time up to the shutter time value
* from the first pair in the set in an attempt to meet the required exposure
* value.
*
* If the required exposure is not achievable by the first shutter time value
* alone it ramps gain up to the value from the first pair in the set. If the
* required exposure is still not met it then allows shutter time to ramp up to
* the shutter time value from the second pair in the set, and continues in this
* vein until either the required exposure time is met, or else the hardware's
* shutter time or gain limits are reached.
*
* This method allows users to strike a balance between a well-exposed image and
* an acceptable frame-rate, as opposed to simply maximising shutter time
* followed by gain. The same helpers can be used to perform the latter
* operation if needed by passing an empty set of pairs to the initialisation
* function.
*
* The gain values may exceed a camera sensor's analogue gain limits if either
* it or the IPA is also capable of digital gain. The configure() function must
* be called with the hardware's limits to inform the helper of those
* constraints. Any gain that is needed will be applied as analogue gain first
* until the hardware's limit is reached, following which digital gain will be
* used.
*/
/**
* \brief Construct an ExposureModeHelper instance
* \param[in] stages The vector of paired shutter time and gain limits
*
* The input stages are shutter time and _total_ gain pairs; the gain
* encompasses both analogue and digital gain.
*
* The vector of stages may be empty. In that case, the helper will simply use
* the runtime limits set through setShutterGainLimits() instead.
*/
ExposureModeHelper::ExposureModeHelper(const Span<std::pair<utils::Duration, double>> stages)
{
minShutter_ = 0us;
maxShutter_ = 0us;
minGain_ = 0;
maxGain_ = 0;
for (const auto &[s, g] : stages) {
shutters_.push_back(s);
gains_.push_back(g);
}
}
/**
* \brief Set the shutter time and gain limits
* \param[in] minShutter The minimum shutter time supported
* \param[in] maxShutter The maximum shutter time supported
* \param[in] minGain The minimum analogue gain supported
* \param[in] maxGain The maximum analogue gain supported
*
* This function configures the shutter time and analogue gain limits that need
* to be adhered to as the helper divides up exposure. Note that this function
* *must* be called whenever those limits change and before splitExposure() is
* used.
*
* If the algorithm using the helpers needs to indicate that either shutter time
* or analogue gain or both should be fixed it can do so by setting both the
* minima and maxima to the same value.
*/
void ExposureModeHelper::setLimits(utils::Duration minShutter,
utils::Duration maxShutter,
double minGain, double maxGain)
{
minShutter_ = minShutter;
maxShutter_ = maxShutter;
minGain_ = minGain;
maxGain_ = maxGain;
}
utils::Duration ExposureModeHelper::clampShutter(utils::Duration shutter) const
{
return std::clamp(shutter, minShutter_, maxShutter_);
}
double ExposureModeHelper::clampGain(double gain) const