diff options
Diffstat (limited to 'src/ipa')
-rw-r--r-- | src/ipa/ipu3/algorithms/awb.h | 2 | ||||
-rw-r--r-- | src/ipa/libipa/colours.h | 2 | ||||
-rw-r--r-- | src/ipa/libipa/meson.build | 2 | ||||
-rw-r--r-- | src/ipa/libipa/pwl.h | 2 | ||||
-rw-r--r-- | src/ipa/libipa/vector.cpp | 351 | ||||
-rw-r--r-- | src/ipa/libipa/vector.h | 370 | ||||
-rw-r--r-- | src/ipa/rkisp1/algorithms/agc.cpp | 12 | ||||
-rw-r--r-- | src/ipa/rkisp1/algorithms/awb.h | 3 | ||||
-rw-r--r-- | src/ipa/rkisp1/algorithms/ccm.cpp | 7 | ||||
-rw-r--r-- | src/ipa/rkisp1/ipa_context.h | 2 | ||||
-rw-r--r-- | src/ipa/rpi/common/ipa_base.cpp | 18 | ||||
-rw-r--r-- | src/ipa/rpi/controller/rpi/agc_channel.cpp | 7 |
12 files changed, 29 insertions, 749 deletions
diff --git a/src/ipa/ipu3/algorithms/awb.h b/src/ipa/ipu3/algorithms/awb.h index 1916990a..dbf69c90 100644 --- a/src/ipa/ipu3/algorithms/awb.h +++ b/src/ipa/ipu3/algorithms/awb.h @@ -13,7 +13,7 @@ #include <libcamera/geometry.h> -#include "libipa/vector.h" +#include "libcamera/internal/vector.h" #include "algorithm.h" diff --git a/src/ipa/libipa/colours.h b/src/ipa/libipa/colours.h index fa6a8b57..d39b2ca8 100644 --- a/src/ipa/libipa/colours.h +++ b/src/ipa/libipa/colours.h @@ -9,7 +9,7 @@ #include <stdint.h> -#include "vector.h" +#include "libcamera/internal/vector.h" namespace libcamera { diff --git a/src/ipa/libipa/meson.build b/src/ipa/libipa/meson.build index f2b2f4be..12d8d15b 100644 --- a/src/ipa/libipa/meson.build +++ b/src/ipa/libipa/meson.build @@ -14,7 +14,6 @@ libipa_headers = files([ 'lux.h', 'module.h', 'pwl.h', - 'vector.h', ]) libipa_sources = files([ @@ -31,7 +30,6 @@ libipa_sources = files([ 'lux.cpp', 'module.cpp', 'pwl.cpp', - 'vector.cpp', ]) libipa_includes = include_directories('..') diff --git a/src/ipa/libipa/pwl.h b/src/ipa/libipa/pwl.h index d4ec9f4f..8fdc7053 100644 --- a/src/ipa/libipa/pwl.h +++ b/src/ipa/libipa/pwl.h @@ -12,7 +12,7 @@ #include <utility> #include <vector> -#include "vector.h" +#include "libcamera/internal/vector.h" namespace libcamera { diff --git a/src/ipa/libipa/vector.cpp b/src/ipa/libipa/vector.cpp deleted file mode 100644 index 8019f8cf..00000000 --- a/src/ipa/libipa/vector.cpp +++ /dev/null @@ -1,351 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* - * Copyright (C) 2024, Paul Elder <paul.elder@ideasonboard.com> - * - * Vector and related operations - */ - -#include "vector.h" - -#include <libcamera/base/log.h> - -/** - * \file vector.h - * \brief Vector class - */ - -namespace libcamera { - -LOG_DEFINE_CATEGORY(Vector) - -namespace ipa { - -/** - * \class Vector - * \brief Vector class - * \tparam T Type of numerical values to be stored in the vector - * \tparam Rows Number of dimension of the vector (= number of elements) - */ - -/** - * \fn Vector::Vector() - * \brief Construct an uninitialized vector - */ - -/** - * \fn Vector::Vector(T scalar) - * \brief Construct a vector filled with a \a scalar value - * \param[in] scalar The scalar value - */ - -/** - * \fn Vector::Vector(const std::array<T, Rows> &data) - * \brief Construct vector from supplied data - * \param data Data from which to construct a vector - * - * The size of \a data must be equal to the dimension size Rows of the vector. - */ - -/** - * \fn T Vector::operator[](size_t i) const - * \brief Index to an element in the vector - * \param i Index of element to retrieve - * \return Element at index \a i from the vector - */ - -/** - * \fn T &Vector::operator[](size_t i) - * \copydoc Vector::operator[](size_t i) const - */ - -/** - * \fn Vector::operator-() const - * \brief Negate a Vector by negating both all of its coordinates - * \return The negated vector - */ - -/** - * \fn Vector::operator+(Vector const &other) const - * \brief Calculate the sum of this vector and \a other element-wise - * \param[in] other The other vector - * \return The element-wise sum of this vector and \a other - */ - -/** - * \fn Vector::operator+(T scalar) const - * \brief Calculate the sum of this vector and \a scalar element-wise - * \param[in] scalar The scalar - * \return The element-wise sum of this vector and \a other - */ - -/** - * \fn Vector::operator-(Vector const &other) const - * \brief Calculate the difference of this vector and \a other element-wise - * \param[in] other The other vector - * \return The element-wise subtraction of \a other from this vector - */ - -/** - * \fn Vector::operator-(T scalar) const - * \brief Calculate the difference of this vector and \a scalar element-wise - * \param[in] scalar The scalar - * \return The element-wise subtraction of \a scalar from this vector - */ - -/** - * \fn Vector::operator*(const Vector &other) const - * \brief Calculate the product of this vector and \a other element-wise - * \param[in] other The other vector - * \return The element-wise product of this vector and \a other - */ - -/** - * \fn Vector::operator*(T scalar) const - * \brief Calculate the product of this vector and \a scalar element-wise - * \param[in] scalar The scalar - * \return The element-wise product of this vector and \a scalar - */ - -/** - * \fn Vector::operator/(const Vector &other) const - * \brief Calculate the quotient of this vector and \a other element-wise - * \param[in] other The other vector - * \return The element-wise division of this vector by \a other - */ - -/** - * \fn Vector::operator/(T scalar) const - * \brief Calculate the quotient of this vector and \a scalar element-wise - * \param[in] scalar The scalar - * \return The element-wise division of this vector by \a scalar - */ - -/** - * \fn Vector::operator+=(Vector const &other) - * \brief Add \a other element-wise to this vector - * \param[in] other The other vector - * \return This vector - */ - -/** - * \fn Vector::operator+=(T scalar) - * \brief Add \a scalar element-wise to this vector - * \param[in] scalar The scalar - * \return This vector - */ - -/** - * \fn Vector::operator-=(Vector const &other) - * \brief Subtract \a other element-wise from this vector - * \param[in] other The other vector - * \return This vector - */ - -/** - * \fn Vector::operator-=(T scalar) - * \brief Subtract \a scalar element-wise from this vector - * \param[in] scalar The scalar - * \return This vector - */ - -/** - * \fn Vector::operator*=(const Vector &other) - * \brief Multiply this vector by \a other element-wise - * \param[in] other The other vector - * \return This vector - */ - -/** - * \fn Vector::operator*=(T scalar) - * \brief Multiply this vector by \a scalar element-wise - * \param[in] scalar The scalar - * \return This vector - */ - -/** - * \fn Vector::operator/=(const Vector &other) - * \brief Divide this vector by \a other element-wise - * \param[in] other The other vector - * \return This vector - */ - -/** - * \fn Vector::operator/=(T scalar) - * \brief Divide this vector by \a scalar element-wise - * \param[in] scalar The scalar - * \return This vector - */ - -/** - * \fn Vector::min(const Vector &other) const - * \brief Calculate the minimum of this vector and \a other element-wise - * \param[in] other The other vector - * \return The element-wise minimum of this vector and \a other - */ - -/** - * \fn Vector::min(T scalar) const - * \brief Calculate the minimum of this vector and \a scalar element-wise - * \param[in] scalar The scalar - * \return The element-wise minimum of this vector and \a scalar - */ - -/** - * \fn Vector::max(const Vector &other) const - * \brief Calculate the maximum of this vector and \a other element-wise - * \param[in] other The other vector - * \return The element-wise maximum of this vector and \a other - */ - -/** - * \fn Vector::max(T scalar) const - * \brief Calculate the maximum of this vector and \a scalar element-wise - * \param[in] scalar The scalar - * \return The element-wise maximum of this vector and \a scalar - */ - -/** - * \fn Vector::dot(const Vector<T, Rows> &other) const - * \brief Compute the dot product - * \param[in] other The other vector - * \return The dot product of the two vectors - */ - -/** - * \fn constexpr T &Vector::x() - * \brief Convenience function to access the first element of the vector - * \return The first element of the vector - */ - -/** - * \fn constexpr T &Vector::y() - * \brief Convenience function to access the second element of the vector - * \return The second element of the vector - */ - -/** - * \fn constexpr T &Vector::z() - * \brief Convenience function to access the third element of the vector - * \return The third element of the vector - */ - -/** - * \fn constexpr const T &Vector::x() const - * \copydoc Vector::x() - */ - -/** - * \fn constexpr const T &Vector::y() const - * \copydoc Vector::y() - */ - -/** - * \fn constexpr const T &Vector::z() const - * \copydoc Vector::z() - */ - -/** - * \fn constexpr T &Vector::r() - * \brief Convenience function to access the first element of the vector - * \return The first element of the vector - */ - -/** - * \fn constexpr T &Vector::g() - * \brief Convenience function to access the second element of the vector - * \return The second element of the vector - */ - -/** - * \fn constexpr T &Vector::b() - * \brief Convenience function to access the third element of the vector - * \return The third element of the vector - */ - -/** - * \fn constexpr const T &Vector::r() const - * \copydoc Vector::r() - */ - -/** - * \fn constexpr const T &Vector::g() const - * \copydoc Vector::g() - */ - -/** - * \fn constexpr const T &Vector::b() const - * \copydoc Vector::b() - */ - -/** - * \fn Vector::length2() - * \brief Get the squared length of the vector - * \return The squared length of the vector - */ - -/** - * \fn Vector::length() - * \brief Get the length of the vector - * \return The length of the vector - */ - -/** - * \fn Vector::sum() const - * \brief Calculate the sum of all the vector elements - * \tparam R The type of the sum - * - * The type R of the sum defaults to the type T of the elements, but can be set - * explicitly to use a different type in case the type T would risk - * overflowing. - * - * \return The sum of all the vector elements - */ - -/** - * \fn Vector<T, Rows> operator*(const Matrix<T, Rows, Cols> &m, const Vector<T, Cols> &v) - * \brief Multiply a matrix by a vector - * \tparam T Numerical type of the contents of the matrix and vector - * \tparam Rows The number of rows in the matrix - * \tparam Cols The number of columns in the matrix (= rows in the vector) - * \param m The matrix - * \param v The vector - * \return Product of matrix \a m and vector \a v - */ - -/** - * \typedef RGB - * \brief A Vector of 3 elements representing an RGB pixel value - */ - -/** - * \fn bool operator==(const Vector<T, Rows> &lhs, const Vector<T, Rows> &rhs) - * \brief Compare vectors for equality - * \return True if the two vectors are equal, false otherwise - */ - -/** - * \fn bool operator!=(const Vector<T, Rows> &lhs, const Vector<T, Rows> &rhs) - * \brief Compare vectors for inequality - * \return True if the two vectors are not equal, false otherwise - */ - -#ifndef __DOXYGEN__ -bool vectorValidateYaml(const YamlObject &obj, unsigned int size) -{ - if (!obj.isList()) - return false; - - if (obj.size() != size) { - LOG(Vector, Error) - << "Wrong number of values in YAML vector: expected " - << size << ", got " << obj.size(); - return false; - } - - return true; -} -#endif /* __DOXYGEN__ */ - -} /* namespace ipa */ - -} /* namespace libcamera */ diff --git a/src/ipa/libipa/vector.h b/src/ipa/libipa/vector.h deleted file mode 100644 index fe33c9d6..00000000 --- a/src/ipa/libipa/vector.h +++ /dev/null @@ -1,370 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* - * Copyright (C) 2024, Paul Elder <paul.elder@ideasonboard.com> - * - * Vector and related operations - */ -#pragma once - -#include <algorithm> -#include <array> -#include <cmath> -#include <functional> -#include <numeric> -#include <optional> -#include <ostream> - -#include <libcamera/base/log.h> -#include <libcamera/base/span.h> - -#include "libcamera/internal/matrix.h" -#include "libcamera/internal/yaml_parser.h" - -namespace libcamera { - -LOG_DECLARE_CATEGORY(Vector) - -namespace ipa { - -#ifndef __DOXYGEN__ -template<typename T, unsigned int Rows, - std::enable_if_t<std::is_arithmetic_v<T>> * = nullptr> -#else -template<typename T, unsigned int Rows> -#endif /* __DOXYGEN__ */ -class Vector -{ -public: - constexpr Vector() = default; - - constexpr explicit Vector(T scalar) - { - data_.fill(scalar); - } - - constexpr Vector(const std::array<T, Rows> &data) - { - for (unsigned int i = 0; i < Rows; i++) - data_[i] = data[i]; - } - - const T &operator[](size_t i) const - { - ASSERT(i < data_.size()); - return data_[i]; - } - - T &operator[](size_t i) - { - ASSERT(i < data_.size()); - return data_[i]; - } - - constexpr Vector<T, Rows> operator-() const - { - Vector<T, Rows> ret; - for (unsigned int i = 0; i < Rows; i++) - ret[i] = -data_[i]; - return ret; - } - - constexpr Vector operator+(const Vector &other) const - { - return apply(*this, other, std::plus<>{}); - } - - constexpr Vector operator+(T scalar) const - { - return apply(*this, scalar, std::plus<>{}); - } - - constexpr Vector operator-(const Vector &other) const - { - return apply(*this, other, std::minus<>{}); - } - - constexpr Vector operator-(T scalar) const - { - return apply(*this, scalar, std::minus<>{}); - } - - constexpr Vector operator*(const Vector &other) const - { - return apply(*this, other, std::multiplies<>{}); - } - - constexpr Vector operator*(T scalar) const - { - return apply(*this, scalar, std::multiplies<>{}); - } - - constexpr Vector operator/(const Vector &other) const - { - return apply(*this, other, std::divides<>{}); - } - - constexpr Vector operator/(T scalar) const - { - return apply(*this, scalar, std::divides<>{}); - } - - Vector &operator+=(const Vector &other) - { - return apply(other, [](T a, T b) { return a + b; }); - } - - Vector &operator+=(T scalar) - { - return apply(scalar, [](T a, T b) { return a + b; }); - } - - Vector &operator-=(const Vector &other) - { - return apply(other, [](T a, T b) { return a - b; }); - } - - Vector &operator-=(T scalar) - { - return apply(scalar, [](T a, T b) { return a - b; }); - } - - Vector &operator*=(const Vector &other) - { - return apply(other, [](T a, T b) { return a * b; }); - } - - Vector &operator*=(T scalar) - { - return apply(scalar, [](T a, T b) { return a * b; }); - } - - Vector &operator/=(const Vector &other) - { - return apply(other, [](T a, T b) { return a / b; }); - } - - Vector &operator/=(T scalar) - { - return apply(scalar, [](T a, T b) { return a / b; }); - } - - constexpr Vector min(const Vector &other) const - { - return apply(*this, other, [](T a, T b) { return std::min(a, b); }); - } - - constexpr Vector min(T scalar) const - { - return apply(*this, scalar, [](T a, T b) { return std::min(a, b); }); - } - - constexpr Vector max(const Vector &other) const - { - return apply(*this, other, [](T a, T b) { return std::max(a, b); }); - } - - constexpr Vector max(T scalar) const - { - return apply(*this, scalar, [](T a, T b) -> T { return std::max(a, b); }); - } - - constexpr T dot(const Vector<T, Rows> &other) const - { - T ret = 0; - for (unsigned int i = 0; i < Rows; i++) - ret += data_[i] * other[i]; - return ret; - } - -#ifndef __DOXYGEN__ - template<bool Dependent = false, typename = std::enable_if_t<Dependent || Rows >= 1>> -#endif /* __DOXYGEN__ */ - constexpr const T &x() const { return data_[0]; } -#ifndef __DOXYGEN__ - template<bool Dependent = false, typename = std::enable_if_t<Dependent || Rows >= 2>> -#endif /* __DOXYGEN__ */ - constexpr const T &y() const { return data_[1]; } -#ifndef __DOXYGEN__ - template<bool Dependent = false, typename = std::enable_if_t<Dependent || Rows >= 3>> -#endif /* __DOXYGEN__ */ - constexpr const T &z() const { return data_[2]; } -#ifndef __DOXYGEN__ - template<bool Dependent = false, typename = std::enable_if_t<Dependent || Rows >= 1>> -#endif /* __DOXYGEN__ */ - constexpr T &x() { return data_[0]; } -#ifndef __DOXYGEN__ - template<bool Dependent = false, typename = std::enable_if_t<Dependent || Rows >= 2>> -#endif /* __DOXYGEN__ */ - constexpr T &y() { return data_[1]; } -#ifndef __DOXYGEN__ - template<bool Dependent = false, typename = std::enable_if_t<Dependent || Rows >= 3>> -#endif /* __DOXYGEN__ */ - constexpr T &z() { return data_[2]; } - -#ifndef __DOXYGEN__ - template<bool Dependent = false, typename = std::enable_if_t<Dependent || Rows >= 1>> -#endif /* __DOXYGEN__ */ - constexpr const T &r() const { return data_[0]; } -#ifndef __DOXYGEN__ - template<bool Dependent = false, typename = std::enable_if_t<Dependent || Rows >= 2>> -#endif /* __DOXYGEN__ */ - constexpr const T &g() const { return data_[1]; } -#ifndef __DOXYGEN__ - template<bool Dependent = false, typename = std::enable_if_t<Dependent || Rows >= 3>> -#endif /* __DOXYGEN__ */ - constexpr const T &b() const { return data_[2]; } -#ifndef __DOXYGEN__ - template<bool Dependent = false, typename = std::enable_if_t<Dependent || Rows >= 1>> -#endif /* __DOXYGEN__ */ - constexpr T &r() { return data_[0]; } -#ifndef __DOXYGEN__ - template<bool Dependent = false, typename = std::enable_if_t<Dependent || Rows >= 2>> -#endif /* __DOXYGEN__ */ - constexpr T &g() { return data_[1]; } -#ifndef __DOXYGEN__ - template<bool Dependent = false, typename = std::enable_if_t<Dependent || Rows >= 3>> -#endif /* __DOXYGEN__ */ - constexpr T &b() { return data_[2]; } - - constexpr double length2() const - { - double ret = 0; - for (unsigned int i = 0; i < Rows; i++) - ret += data_[i] * data_[i]; - return ret; - } - - constexpr double length() const - { - return std::sqrt(length2()); - } - - template<typename R = T> - constexpr R sum() const - { - return std::accumulate(data_.begin(), data_.end(), R{}); - } - -private: - template<class BinaryOp> - static constexpr Vector apply(const Vector &lhs, const Vector &rhs, BinaryOp op) - { - Vector result; - std::transform(lhs.data_.begin(), lhs.data_.end(), - rhs.data_.begin(), result.data_.begin(), - op); - - return result; - } - - template<class BinaryOp> - static constexpr Vector apply(const Vector &lhs, T rhs, BinaryOp op) - { - Vector result; - std::transform(lhs.data_.begin(), lhs.data_.end(), - result.data_.begin(), - [&op, rhs](T v) { return op(v, rhs); }); - - return result; - } - - template<class BinaryOp> - Vector &apply(const Vector &other, BinaryOp op) - { - auto itOther = other.data_.begin(); - std::for_each(data_.begin(), data_.end(), - [&op, &itOther](T &v) { v = op(v, *itOther++); }); - - return *this; - } - - template<class BinaryOp> - Vector &apply(T scalar, BinaryOp op) - { - std::for_each(data_.begin(), data_.end(), - [&op, scalar](T &v) { v = op(v, scalar); }); - - return *this; - } - - std::array<T, Rows> data_; -}; - -template<typename T> -using RGB = Vector<T, 3>; - -template<typename T, unsigned int Rows, unsigned int Cols> -Vector<T, Rows> operator*(const Matrix<T, Rows, Cols> &m, const Vector<T, Cols> &v) -{ - Vector<T, Rows> result; - - for (unsigned int i = 0; i < Rows; i++) { - T sum = 0; - for (unsigned int j = 0; j < Cols; j++) - sum += m[i][j] * v[j]; - result[i] = sum; - } - - return result; -} - -template<typename T, unsigned int Rows> -bool operator==(const Vector<T, Rows> &lhs, const Vector<T, Rows> &rhs) -{ - for (unsigned int i = 0; i < Rows; i++) { - if (lhs[i] != rhs[i]) - return false; - } - - return true; -} - -template<typename T, unsigned int Rows> -bool operator!=(const Vector<T, Rows> &lhs, const Vector<T, Rows> &rhs) -{ - return !(lhs == rhs); -} - -#ifndef __DOXYGEN__ -bool vectorValidateYaml(const YamlObject &obj, unsigned int size); -#endif /* __DOXYGEN__ */ - -} /* namespace ipa */ - -#ifndef __DOXYGEN__ -template<typename T, unsigned int Rows> -std::ostream &operator<<(std::ostream &out, const ipa::Vector<T, Rows> &v) -{ - out << "Vector { "; - for (unsigned int i = 0; i < Rows; i++) { - out << v[i]; - out << ((i + 1 < Rows) ? ", " : " "); - } - out << " }"; - - return out; -} - -template<typename T, unsigned int Rows> -struct YamlObject::Getter<ipa::Vector<T, Rows>> { - std::optional<ipa::Vector<T, Rows>> get(const YamlObject &obj) const - { - if (!ipa::vectorValidateYaml(obj, Rows)) - return std::nullopt; - - ipa::Vector<T, Rows> vector; - - unsigned int i = 0; - for (const YamlObject &entry : obj.asList()) { - const auto value = entry.get<T>(); - if (!value) - return std::nullopt; - vector[i++] = *value; - } - - return vector; - } -}; -#endif /* __DOXYGEN__ */ - -} /* namespace libcamera */ diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index 1680669c..45ec7218 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -149,13 +149,13 @@ int Agc::init(IPAContext &context, const YamlObject &tuningData) return ret; context.ctrlMap[&controls::ExposureTimeMode] = - ControlInfo(static_cast<int32_t>(controls::ExposureTimeModeAuto), - static_cast<int32_t>(controls::ExposureTimeModeManual), - static_cast<int32_t>(controls::ExposureTimeModeAuto)); + ControlInfo({ { ControlValue(controls::ExposureTimeModeAuto), + ControlValue(controls::ExposureTimeModeManual) } }, + ControlValue(controls::ExposureTimeModeAuto)); context.ctrlMap[&controls::AnalogueGainMode] = - ControlInfo(static_cast<int32_t>(controls::AnalogueGainModeAuto), - static_cast<int32_t>(controls::AnalogueGainModeManual), - static_cast<int32_t>(controls::AnalogueGainModeAuto)); + ControlInfo({ { ControlValue(controls::AnalogueGainModeAuto), + ControlValue(controls::AnalogueGainModeManual) } }, + ControlValue(controls::AnalogueGainModeAuto)); /* \todo Move this to the Camera class */ context.ctrlMap[&controls::AeEnable] = ControlInfo(false, true, true); context.ctrlMap.merge(controls()); diff --git a/src/ipa/rkisp1/algorithms/awb.h b/src/ipa/rkisp1/algorithms/awb.h index e4248048..34ec42cb 100644 --- a/src/ipa/rkisp1/algorithms/awb.h +++ b/src/ipa/rkisp1/algorithms/awb.h @@ -9,8 +9,9 @@ #include <optional> +#include "libcamera/internal/vector.h" + #include "libipa/interpolator.h" -#include "libipa/vector.h" #include "algorithm.h" diff --git a/src/ipa/rkisp1/algorithms/ccm.cpp b/src/ipa/rkisp1/algorithms/ccm.cpp index e2b5cf4d..eb8ca39e 100644 --- a/src/ipa/rkisp1/algorithms/ccm.cpp +++ b/src/ipa/rkisp1/algorithms/ccm.cpp @@ -120,12 +120,7 @@ void Ccm::process([[maybe_unused]] IPAContext &context, [[maybe_unused]] const rkisp1_stat_buffer *stats, ControlList &metadata) { - float m[9]; - for (unsigned int i = 0; i < 3; i++) { - for (unsigned int j = 0; j < 3; j++) - m[i * 3 + j] = frameContext.ccm.ccm[i][j]; - } - metadata.set(controls::ColourCorrectionMatrix, m); + metadata.set(controls::ColourCorrectionMatrix, frameContext.ccm.ccm.data()); } REGISTER_IPA_ALGORITHM(Ccm, "Ccm") diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h index 5d5b79fa..c765b928 100644 --- a/src/ipa/rkisp1/ipa_context.h +++ b/src/ipa/rkisp1/ipa_context.h @@ -22,10 +22,10 @@ #include "libcamera/internal/debug_controls.h" #include "libcamera/internal/matrix.h" +#include "libcamera/internal/vector.h" #include <libipa/camera_sensor_helper.h> #include <libipa/fc_queue.h> -#include <libipa/vector.h> namespace libcamera { diff --git a/src/ipa/rpi/common/ipa_base.cpp b/src/ipa/rpi/common/ipa_base.cpp index bd3c2200..6734c32e 100644 --- a/src/ipa/rpi/common/ipa_base.cpp +++ b/src/ipa/rpi/common/ipa_base.cpp @@ -61,12 +61,13 @@ const ControlInfoMap::Map ipaControls{ ControlInfo(static_cast<int32_t>(controls::ExposureTimeModeAuto), static_cast<int32_t>(controls::ExposureTimeModeManual), static_cast<int32_t>(controls::ExposureTimeModeAuto)) }, - { &controls::ExposureTime, ControlInfo(0, 66666) }, + { &controls::ExposureTime, + ControlInfo(1, 66666, static_cast<int32_t>(defaultExposureTime.get<std::micro>())) }, { &controls::AnalogueGainMode, ControlInfo(static_cast<int32_t>(controls::AnalogueGainModeAuto), static_cast<int32_t>(controls::AnalogueGainModeManual), static_cast<int32_t>(controls::AnalogueGainModeAuto)) }, - { &controls::AnalogueGain, ControlInfo(1.0f, 16.0f) }, + { &controls::AnalogueGain, ControlInfo(1.0f, 16.0f, 1.0f) }, { &controls::AeMeteringMode, ControlInfo(controls::AeMeteringModeValues) }, { &controls::AeConstraintMode, ControlInfo(controls::AeConstraintModeValues) }, { &controls::AeExposureMode, ControlInfo(controls::AeExposureModeValues) }, @@ -80,7 +81,9 @@ const ControlInfoMap::Map ipaControls{ { &controls::HdrMode, ControlInfo(controls::HdrModeValues) }, { &controls::Sharpness, ControlInfo(0.0f, 16.0f, 1.0f) }, { &controls::ScalerCrop, ControlInfo(Rectangle{}, Rectangle(65535, 65535, 65535, 65535), Rectangle{}) }, - { &controls::FrameDurationLimits, ControlInfo(INT64_C(33333), INT64_C(120000)) }, + { &controls::FrameDurationLimits, + ControlInfo(INT64_C(33333), INT64_C(120000), + static_cast<int64_t>(defaultMinFrameDuration.get<std::micro>())) }, { &controls::draft::NoiseReductionMode, ControlInfo(controls::draft::NoiseReductionModeValues) }, { &controls::rpi::StatsOutputEnable, ControlInfo(false, true, false) }, }; @@ -259,15 +262,18 @@ int32_t IpaBase::configure(const IPACameraSensorInfo &sensorInfo, const ConfigPa ControlInfoMap::Map ctrlMap = ipaControls; ctrlMap[&controls::FrameDurationLimits] = ControlInfo(static_cast<int64_t>(mode_.minFrameDuration.get<std::micro>()), - static_cast<int64_t>(mode_.maxFrameDuration.get<std::micro>())); + static_cast<int64_t>(mode_.maxFrameDuration.get<std::micro>()), + static_cast<int64_t>(defaultMinFrameDuration.get<std::micro>())); ctrlMap[&controls::AnalogueGain] = ControlInfo(static_cast<float>(mode_.minAnalogueGain), - static_cast<float>(mode_.maxAnalogueGain)); + static_cast<float>(mode_.maxAnalogueGain), + static_cast<float>(defaultAnalogueGain)); ctrlMap[&controls::ExposureTime] = ControlInfo(static_cast<int32_t>(mode_.minExposureTime.get<std::micro>()), - static_cast<int32_t>(mode_.maxExposureTime.get<std::micro>())); + static_cast<int32_t>(mode_.maxExposureTime.get<std::micro>()), + static_cast<int32_t>(defaultExposureTime.get<std::micro>())); /* Declare colour processing related controls for non-mono sensors. */ if (!monoSensor_) diff --git a/src/ipa/rpi/controller/rpi/agc_channel.cpp b/src/ipa/rpi/controller/rpi/agc_channel.cpp index e79184b7..a5562760 100644 --- a/src/ipa/rpi/controller/rpi/agc_channel.cpp +++ b/src/ipa/rpi/controller/rpi/agc_channel.cpp @@ -12,8 +12,9 @@ #include <libcamera/base/log.h> +#include "libcamera/internal/vector.h" + #include "libipa/colours.h" -#include "libipa/vector.h" #include "../awb_status.h" #include "../device_status.h" @@ -700,7 +701,7 @@ static double computeInitialY(StatisticsPtr &stats, AwbStatus const &awb, * Note that the weights are applied by the IPA to the statistics directly, * before they are given to us here. */ - ipa::RGB<double> sum{ 0.0 }; + RGB<double> sum{ 0.0 }; double pixelSum = 0; for (unsigned int i = 0; i < stats->agcRegions.numRegions(); i++) { auto ®ion = stats->agcRegions.get(i); @@ -716,7 +717,7 @@ static double computeInitialY(StatisticsPtr &stats, AwbStatus const &awb, /* Factor in the AWB correction if needed. */ if (stats->agcStatsPos == Statistics::AgcStatsPos::PreWb) - sum *= ipa::RGB<double>{{ awb.gainR, awb.gainR, awb.gainB }}; + sum *= RGB<double>{ { awb.gainR, awb.gainR, awb.gainB } }; double ySum = ipa::rec601LuminanceFromRGB(sum); |