diff options
author | Naushir Patuck <naush@raspberrypi.com> | 2023-10-13 08:48:32 +0100 |
---|---|---|
committer | Kieran Bingham <kieran.bingham@ideasonboard.com> | 2023-10-18 11:01:22 +0100 |
commit | ded9004e91dd2487f3ec1827eaab8c80b0e02e68 (patch) | |
tree | f508bb314903a3f99063f3b0f92720f4db231618 /src/ipa/rpi/controller/rpi/cac.cpp | |
parent | c9fb1d44d850904a95d73e8773548485de1de081 (diff) |
ipa: rpi: Add new algorithms for PiSP
Add new CAC, HDR, Saturation and Tonemapping algorithms.
Add a new Denoise algorithm that handles spatial/temporal/colour denoise
through one interface. With this change, the old SDN algorithm is now
considered deprecated and a warning message will be displayed if it is
enabled.
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src/ipa/rpi/controller/rpi/cac.cpp')
-rw-r--r-- | src/ipa/rpi/controller/rpi/cac.cpp | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/src/ipa/rpi/controller/rpi/cac.cpp b/src/ipa/rpi/controller/rpi/cac.cpp new file mode 100644 index 00000000..7c123da1 --- /dev/null +++ b/src/ipa/rpi/controller/rpi/cac.cpp @@ -0,0 +1,81 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ +/* + * Copyright (C) 2023 Raspberry Pi Ltd + * + * cac.cpp - Chromatic Aberration Correction algorithm + */ +#include "cac.h" + +#include <libcamera/base/log.h> + +#include "cac_status.h" + +using namespace RPiController; +using namespace libcamera; + +LOG_DEFINE_CATEGORY(RPiCac) + +#define NAME "rpi.cac" + +Cac::Cac(Controller *controller) + : Algorithm(controller) +{ +} + +char const *Cac::name() const +{ + return NAME; +} + +int Cac::read(const libcamera::YamlObject ¶ms) +{ + arrayToSet(params["lut_rx"], config_.lutRx); + arrayToSet(params["lut_ry"], config_.lutRy); + arrayToSet(params["lut_bx"], config_.lutBx); + arrayToSet(params["lut_by"], config_.lutBy); + cacStatus_.lutRx = config_.lutRx; + cacStatus_.lutRy = config_.lutRy; + cacStatus_.lutBx = config_.lutBx; + cacStatus_.lutBy = config_.lutBy; + double strength = params["strength"].get<double>(1); + setStrength(config_.lutRx, cacStatus_.lutRx, strength); + setStrength(config_.lutBx, cacStatus_.lutBx, strength); + setStrength(config_.lutRy, cacStatus_.lutRy, strength); + setStrength(config_.lutBy, cacStatus_.lutBy, strength); + return 0; +} + +void Cac::initialise() +{ +} + +void Cac::arrayToSet(const libcamera::YamlObject ¶ms, std::vector<double> &inputArray) +{ + int num = 0; + const Size &size = getHardwareConfig().cacRegions; + inputArray.resize((size.width + 1) * (size.height + 1)); + for (const auto &p : params.asList()) { + inputArray[num++] = p.get<double>(0); + } +} + +void Cac::setStrength(std::vector<double> &inputArray, std::vector<double> &outputArray, + double strengthFactor) +{ + int num = 0; + for (const auto &p : inputArray) { + outputArray[num++] = p * strengthFactor; + } +} + +void Cac::prepare(Metadata *imageMetadata) +{ + imageMetadata->set("cac.status", cacStatus_); +} + +// Register algorithm with the system. +static Algorithm *Create(Controller *controller) +{ + return (Algorithm *)new Cac(controller); +} +static RegisterAlgorithm reg(NAME, &Create); |