summaryrefslogtreecommitdiff
path: root/aiq/aiq_results.h
diff options
context:
space:
mode:
authorHan-Lin Chen <hanlinchen@chromium.org>2021-11-11 18:49:04 +0800
committerKieran Bingham <kieran.bingham@ideasonboard.com>2021-11-19 15:31:59 +0000
commit8966fdb06ec2a07c8094cea478739df96eaef038 (patch)
tree4175919daff926b53e7584853e5ef4a3e4cc343b /aiq/aiq_results.h
parent12635873d164e16feb4068919771833309dc3010 (diff)
ipu3: Add a class AiqResultsRingBuffer to reserve AiqResults history
The AIQ algorithm expects the statstistics comes with the effective AiqResults applied on the sensor, which may not always be the latest AiqResults, since pipeline handler may delay setting the controls based on SOF. Add a class to reserve the history of the AiqResults generated for previous frames, so IPA can have a chance to look for the suitable one backwards. In details, the patch adds following to AiqResult Class. - Make the parameters to setXXX() functions const. - Implement copy constructors - Implement a RingBuffer to maintain AiqResults History Signed-off-by: Han-Lin Chen <hanlinchen@chromium.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'aiq/aiq_results.h')
-rw-r--r--aiq/aiq_results.h43
1 files changed, 35 insertions, 8 deletions
diff --git a/aiq/aiq_results.h b/aiq/aiq_results.h
index ae19a6c..8c95852 100644
--- a/aiq/aiq_results.h
+++ b/aiq/aiq_results.h
@@ -8,6 +8,8 @@
* of the aiq result structures.
*/
+#include <array>
+#include <functional>
#include <vector>
#include <ia_imaging/ia_aiq.h>
@@ -37,6 +39,10 @@ class AiqResults
{
public:
AiqResults();
+ AiqResults(const AiqResults &other);
+ AiqResults &operator=(const AiqResults &other);
+ AiqResults(const AiqResults &&other) = delete;
+ AiqResults &operator=(const AiqResults &&other) = delete;
const ia_aiq_ae_results *ae() { return &ae_; }
ia_aiq_af_results *af() { return &af_; }
@@ -46,14 +52,14 @@ public:
const ia_aiq_pa_results *pa() { return &pa_; }
const ia_aiq_sa_results *sa() { return &sa_; }
- void setAe(ia_aiq_ae_results *ae);
- void setAf(ia_aiq_af_results *af);
- void setAfBracket(ia_aiq_af_bracket_results *afBracket);
- void setAwb(ia_aiq_awb_results *awb);
- void setGbce(ia_aiq_gbce_results *gbce);
- void setDetectedSceneMode(ia_aiq_scene_mode dsm);
- void setPa(ia_aiq_pa_results *pa);
- void setSa(ia_aiq_sa_results *sa);
+ void setAe(const ia_aiq_ae_results *ae);
+ void setAf(const ia_aiq_af_results *af);
+ void setAfBracket(const ia_aiq_af_bracket_results *afBracket);
+ void setAwb(const ia_aiq_awb_results *awb);
+ void setGbce(const ia_aiq_gbce_results *gbce);
+ void setDetectedSceneMode(const ia_aiq_scene_mode dsm);
+ void setPa(const ia_aiq_pa_results *pa);
+ void setSa(const ia_aiq_sa_results *sa);
private:
ia_aiq_ae_results ae_;
@@ -109,6 +115,27 @@ private:
std::vector<float> channelGb_;
};
+static constexpr unsigned int bufferSize = 16;
+class AiqResultsRingBuffer: public std::array<AiqResults, bufferSize>
+{
+public:
+ AiqResults &operator[](unsigned int index);
+ const AiqResults &operator[](unsigned int index) const;
+ void reset();
+ void extendOne();
+ AiqResults& latest();
+ unsigned int size() { return size_; }
+ AiqResults& searchBackward(const std::function<bool(AiqResults&)> pred,
+ AiqResults& def);
+
+private:
+ void incrementSize();
+
+ unsigned int start_ = 0;
+ unsigned int end_ = 0;
+ unsigned int size_ = 0;
+};
+
} /* namespace libcamera::ipa::ipu3::aiq */
#endif /* IPA_IPU3_AIQ_RESULTS_H */