summaryrefslogtreecommitdiff
path: root/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2022-07-11 01:09:09 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2022-07-19 14:23:32 +0300
commitf995ff25a3326db90513d1fa936815653f7cade0 (patch)
treed4362bac38bb83efbe7aa5d936e1d2b858854437 /src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
parent1c4d4801850559d6f919eef5c2ffbaf7675dbc46 (diff)
libcamera: controls: Avoid double lookups
Now that the ControlList::get() function returns an instance of std::optional<>, we can replace the ControlList::contains() calls with a nullopt check on the return value of get(). This avoids double lookups of controls through the code base. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Diffstat (limited to 'src/libcamera/pipeline/raspberrypi/raspberrypi.cpp')
-rw-r--r--src/libcamera/pipeline/raspberrypi/raspberrypi.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
index b5322483..c130260f 100644
--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
@@ -1717,16 +1717,15 @@ void RPiCameraData::statsMetadataComplete(uint32_t bufferId, const ControlList &
* Inform the sensor of the latest colour gains if it has the
* V4L2_CID_NOTIFY_GAINS control (which means notifyGainsUnity_ is set).
*/
- if (notifyGainsUnity_ && controls.contains(libcamera::controls::ColourGains)) {
- libcamera::Span<const float> colourGains =
- *controls.get(libcamera::controls::ColourGains);
+ const auto &colourGains = controls.get(libcamera::controls::ColourGains);
+ if (notifyGainsUnity_ && colourGains) {
/* The control wants linear gains in the order B, Gb, Gr, R. */
ControlList ctrls(sensor_->controls());
std::array<int32_t, 4> gains{
- static_cast<int32_t>(colourGains[1] * *notifyGainsUnity_),
+ static_cast<int32_t>((*colourGains)[1] * *notifyGainsUnity_),
*notifyGainsUnity_,
*notifyGainsUnity_,
- static_cast<int32_t>(colourGains[0] * *notifyGainsUnity_)
+ static_cast<int32_t>((*colourGains)[0] * *notifyGainsUnity_)
};
ctrls.set(V4L2_CID_NOTIFY_GAINS, Span<const int32_t>{ gains });
@@ -2053,8 +2052,9 @@ Rectangle RPiCameraData::scaleIspCrop(const Rectangle &ispCrop) const
void RPiCameraData::applyScalerCrop(const ControlList &controls)
{
- if (controls.contains(controls::ScalerCrop)) {
- Rectangle nativeCrop = *controls.get<Rectangle>(controls::ScalerCrop);
+ const auto &scalerCrop = controls.get<Rectangle>(controls::ScalerCrop);
+ if (scalerCrop) {
+ Rectangle nativeCrop = *scalerCrop;
if (!nativeCrop.width || !nativeCrop.height)
nativeCrop = { 0, 0, 1, 1 };