[PATCH 1/2] ipa: libipa: histogram: Add rshift parameter to constructor
Paul Elder
paul.elder at ideasonboard.com
Tue Mar 19 11:54:02 CET 2024
Add an parameter for right-shifting the values during construction of
the histogram.
This is necessary notably for the rkisp1, as the values reported from
the hardware are 20 bits where the upper 16-bits are meaningful integer
values and the lower 4 bits are fractional and meant to be discarded.
Signed-off-by: Paul Elder <paul.elder at ideasonboard.com>
---
src/ipa/libipa/histogram.cpp | 5 +++--
src/ipa/libipa/histogram.h | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/ipa/libipa/histogram.cpp b/src/ipa/libipa/histogram.cpp
index 6b5cde8e..5cfbb720 100644
--- a/src/ipa/libipa/histogram.cpp
+++ b/src/ipa/libipa/histogram.cpp
@@ -31,13 +31,14 @@ namespace ipa {
/**
* \brief Create a cumulative histogram
* \param[in] data A pre-sorted histogram to be passed
+ * \param[in] rshift Number of bits to right shift the values by
*/
-Histogram::Histogram(Span<const uint32_t> data)
+Histogram::Histogram(Span<const uint32_t> data, uint8_t rshift)
{
cumulative_.reserve(data.size());
cumulative_.push_back(0);
for (const uint32_t &value : data)
- cumulative_.push_back(cumulative_.back() + value);
+ cumulative_.push_back(cumulative_.back() + (value >> rshift));
}
/**
diff --git a/src/ipa/libipa/histogram.h b/src/ipa/libipa/histogram.h
index 05bb4b80..a82e623e 100644
--- a/src/ipa/libipa/histogram.h
+++ b/src/ipa/libipa/histogram.h
@@ -22,7 +22,7 @@ namespace ipa {
class Histogram
{
public:
- Histogram(Span<const uint32_t> data);
+ Histogram(Span<const uint32_t> data, uint8_t rshift = 0);
size_t bins() const { return cumulative_.size() - 1; }
uint64_t total() const { return cumulative_[cumulative_.size() - 1]; }
uint64_t cumulativeFrequency(double bin) const;
--
2.39.2
More information about the libcamera-devel
mailing list