summaryrefslogtreecommitdiff
path: root/src/ipa/rkisp1
diff options
context:
space:
mode:
Diffstat (limited to 'src/ipa/rkisp1')
-rw-r--r--src/ipa/rkisp1/algorithms/ccm.cpp4
-rw-r--r--src/ipa/rkisp1/meson.build1
-rw-r--r--src/ipa/rkisp1/utils.cpp42
-rw-r--r--src/ipa/rkisp1/utils.h65
4 files changed, 2 insertions, 110 deletions
diff --git a/src/ipa/rkisp1/algorithms/ccm.cpp b/src/ipa/rkisp1/algorithms/ccm.cpp
index 6b7d2e2c..e2b5cf4d 100644
--- a/src/ipa/rkisp1/algorithms/ccm.cpp
+++ b/src/ipa/rkisp1/algorithms/ccm.cpp
@@ -18,7 +18,7 @@
#include "libcamera/internal/yaml_parser.h"
-#include "../utils.h"
+#include "libipa/fixedpoint.h"
#include "libipa/interpolator.h"
/**
@@ -72,7 +72,7 @@ void Ccm::setParameters(struct rkisp1_cif_isp_ctk_config &config,
for (unsigned int i = 0; i < 3; i++) {
for (unsigned int j = 0; j < 3; j++)
config.coeff[i][j] =
- utils::floatingToFixedPoint<4, 7, uint16_t, double>(matrix[i][j]);
+ floatingToFixedPoint<4, 7, uint16_t, double>(matrix[i][j]);
}
for (unsigned int i = 0; i < 3; i++)
diff --git a/src/ipa/rkisp1/meson.build b/src/ipa/rkisp1/meson.build
index 34844f14..26a9fa40 100644
--- a/src/ipa/rkisp1/meson.build
+++ b/src/ipa/rkisp1/meson.build
@@ -9,7 +9,6 @@ rkisp1_ipa_sources = files([
'ipa_context.cpp',
'params.cpp',
'rkisp1.cpp',
- 'utils.cpp',
])
rkisp1_ipa_sources += rkisp1_ipa_algorithms
diff --git a/src/ipa/rkisp1/utils.cpp b/src/ipa/rkisp1/utils.cpp
deleted file mode 100644
index 960ec64e..00000000
--- a/src/ipa/rkisp1/utils.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/* SPDX-License-Identifier: LGPL-2.1-or-later */
-/*
- * Copyright (C) 2024, Paul Elder <paul.elder@ideasonboard.com>
- *
- * Miscellaneous utility functions specific to rkisp1
- */
-
-#include "utils.h"
-
-/**
- * \file utils.h
- */
-
-namespace libcamera {
-
-namespace ipa::rkisp1::utils {
-
-/**
- * \fn R floatingToFixedPoint(T number)
- * \brief Convert a floating point number to a fixed-point representation
- * \tparam I Bit width of the integer part of the fixed-point
- * \tparam F Bit width of the fractional part of the fixed-point
- * \tparam R Return type of the fixed-point representation
- * \tparam T Input type of the floating point representation
- * \param number The floating point number to convert to fixed point
- * \return The converted value
- */
-
-/**
- * \fn R fixedToFloatingPoint(T number)
- * \brief Convert a fixed-point number to a floating point representation
- * \tparam I Bit width of the integer part of the fixed-point
- * \tparam F Bit width of the fractional part of the fixed-point
- * \tparam R Return type of the floating point representation
- * \tparam T Input type of the fixed-point representation
- * \param number The fixed point number to convert to floating point
- * \return The converted value
- */
-
-} /* namespace ipa::rkisp1::utils */
-
-} /* namespace libcamera */
diff --git a/src/ipa/rkisp1/utils.h b/src/ipa/rkisp1/utils.h
deleted file mode 100644
index 5f38b50b..00000000
--- a/src/ipa/rkisp1/utils.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* SPDX-License-Identifier: LGPL-2.1-or-later */
-/*
- * Copyright (C) 2024, Paul Elder <paul.elder@ideasonboard.com>
- *
- * Miscellaneous utility functions specific to rkisp1
- */
-
-#pragma once
-
-#include <cmath>
-#include <type_traits>
-
-namespace libcamera {
-
-namespace ipa::rkisp1::utils {
-
-#ifndef __DOXYGEN__
-template<unsigned int I, unsigned int F, typename R, typename T,
- std::enable_if_t<std::is_integral_v<R> &&
- std::is_floating_point_v<T>> * = nullptr>
-#else
-template<unsigned int I, unsigned int F, typename R, typename T>
-#endif
-constexpr R floatingToFixedPoint(T number)
-{
- static_assert(sizeof(int) >= sizeof(R));
- static_assert(I + F <= sizeof(R) * 8);
-
- /*
- * The intermediate cast to int is needed on arm platforms to properly
- * cast negative values. See
- * https://embeddeduse.com/2013/08/25/casting-a-negative-float-to-an-unsigned-int/
- */
- R mask = (1 << (F + I)) - 1;
- R frac = static_cast<R>(static_cast<int>(std::round(number * (1 << F)))) & mask;
-
- return frac;
-}
-
-#ifndef __DOXYGEN__
-template<unsigned int I, unsigned int F, typename R, typename T,
- std::enable_if_t<std::is_floating_point_v<R> &&
- std::is_integral_v<T>> * = nullptr>
-#else
-template<unsigned int I, unsigned int F, typename R, typename T>
-#endif
-constexpr R fixedToFloatingPoint(T number)
-{
- static_assert(sizeof(int) >= sizeof(T));
- static_assert(I + F <= sizeof(T) * 8);
-
- /*
- * Recreate the upper bits in case of a negative number by shifting the sign
- * bit from the fixed point to the first bit of the unsigned and then right shifting
- * by the same amount which keeps the sign bit in place.
- * This can be optimized by the compiler quite well.
- */
- int remaining_bits = sizeof(int) * 8 - (I + F);
- int t = static_cast<int>(static_cast<unsigned>(number) << remaining_bits) >> remaining_bits;
- return static_cast<R>(t) / static_cast<R>(1 << F);
-}
-
-} /* namespace ipa::rkisp1::utils */
-
-} /* namespace libcamera */