summaryrefslogtreecommitdiff
path: root/src/ipa/rpi/controller/rpi/hdr.h
diff options
context:
space:
mode:
authorNaushir Patuck <naush@raspberrypi.com>2023-10-13 08:48:32 +0100
committerKieran Bingham <kieran.bingham@ideasonboard.com>2023-10-18 11:01:22 +0100
commitded9004e91dd2487f3ec1827eaab8c80b0e02e68 (patch)
treef508bb314903a3f99063f3b0f92720f4db231618 /src/ipa/rpi/controller/rpi/hdr.h
parentc9fb1d44d850904a95d73e8773548485de1de081 (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/hdr.h')
-rw-r--r--src/ipa/rpi/controller/rpi/hdr.h72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/ipa/rpi/controller/rpi/hdr.h b/src/ipa/rpi/controller/rpi/hdr.h
new file mode 100644
index 00000000..01ba45f1
--- /dev/null
+++ b/src/ipa/rpi/controller/rpi/hdr.h
@@ -0,0 +1,72 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+/*
+ * Copyright (C) 2023, Raspberry Pi Ltd
+ *
+ * hdr.h - HDR control algorithm
+ */
+#pragma once
+
+#include <map>
+#include <string>
+#include <vector>
+
+#include "../hdr_algorithm.h"
+#include "../hdr_status.h"
+#include "../pwl.h"
+
+/* This is our implementation of an HDR algorithm. */
+
+namespace RPiController {
+
+struct HdrConfig {
+ std::string name;
+ std::vector<unsigned int> cadence;
+ std::map<unsigned int, std::string> channelMap;
+
+ /* Tonemap related parameters. */
+ bool tonemapEnable;
+ uint16_t detailConstant;
+ double detailSlope;
+ double iirStrength;
+ double strength;
+ /* We must have either an explicit tonemap curve, or the other parameters. */
+ Pwl tonemap;
+ Pwl target; /* maps histogram quatile to desired target output value */
+ Pwl maxSlope; /* the maximum slope allowed at each point in the mapping */
+ double minSlope; /* the minimum allowed slope */
+ double maxGain; /* limit to the max absolute gain */
+ double step; /* the histogram granularity for building the mapping */
+ double speed; /* rate at which tonemap is updated */
+
+ /* Stitch related parameters. */
+ bool stitchEnable;
+ uint16_t thresholdLo;
+ uint8_t diffPower;
+ double motionThreshold;
+
+ void read(const libcamera::YamlObject &params, const std::string &name);
+};
+
+class Hdr : public HdrAlgorithm
+{
+public:
+ Hdr(Controller *controller);
+ char const *name() const override;
+ void switchMode(CameraMode const &cameraMode, Metadata *metadata) override;
+ int read(const libcamera::YamlObject &params) override;
+ void process(StatisticsPtr &stats, Metadata *imageMetadata) override;
+ int setMode(std::string const &mode) override;
+ std::vector<unsigned int> getChannels() const override;
+
+private:
+ void updateAgcStatus(Metadata *metadata);
+ bool updateTonemap(StatisticsPtr &stats, HdrConfig &config);
+
+ std::map<std::string, HdrConfig> config_;
+ HdrStatus status_; /* track the current HDR mode and channel */
+ HdrStatus delayedStatus_; /* track the delayed HDR mode and channel */
+ std::string previousMode_;
+ Pwl tonemap_;
+};
+
+} /* namespace RPiController */