[v4,11/15] libcamera: ipa: simple: Use float type for adjustment controls
diff mbox series

Message ID 20260122161935.208562-12-mzamazal@redhat.com
State New
Headers show
Series
  • Simple pipeline IPA cleanup
Related show

Commit Message

Milan Zamazal Jan. 22, 2026, 4:19 p.m. UTC
control_ids.h defines the contrast type as float, let's use the same in
simple IPA, instead of double.  Saturation and gamma already use float,
except for the knobs initializers, let's use float for the knobs too.

Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
---
 include/libcamera/internal/software_isp/debayer_params.h | 2 +-
 src/ipa/simple/algorithms/adjust.cpp                     | 4 ++--
 src/ipa/simple/algorithms/lut.cpp                        | 2 +-
 src/ipa/simple/ipa_context.h                             | 8 ++++----
 4 files changed, 8 insertions(+), 8 deletions(-)

Patch
diff mbox series

diff --git a/include/libcamera/internal/software_isp/debayer_params.h b/include/libcamera/internal/software_isp/debayer_params.h
index 256c7d43d..2d69bd295 100644
--- a/include/libcamera/internal/software_isp/debayer_params.h
+++ b/include/libcamera/internal/software_isp/debayer_params.h
@@ -59,7 +59,7 @@  struct DebayerParams {
 	Matrix<float, 3, 3> ccm;
 	RGB<float> blackLevel;
 	float gamma;
-	double contrastExp;
+	float contrastExp;
 };
 
 } /* namespace libcamera */
diff --git a/src/ipa/simple/algorithms/adjust.cpp b/src/ipa/simple/algorithms/adjust.cpp
index a067f7b84..a8b7c5ab6 100644
--- a/src/ipa/simple/algorithms/adjust.cpp
+++ b/src/ipa/simple/algorithms/adjust.cpp
@@ -34,8 +34,8 @@  int Adjust::configure(IPAContext &context,
 		      [[maybe_unused]] const IPAConfigInfo &configInfo)
 {
 	context.activeState.knobs.gamma = kDefaultGamma;
-	context.activeState.knobs.contrast = std::optional<double>();
-	context.activeState.knobs.saturation = std::optional<double>();
+	context.activeState.knobs.contrast = std::optional<float>();
+	context.activeState.knobs.saturation = std::optional<float>();
 
 	return 0;
 }
diff --git a/src/ipa/simple/algorithms/lut.cpp b/src/ipa/simple/algorithms/lut.cpp
index d8e92c613..fd442259a 100644
--- a/src/ipa/simple/algorithms/lut.cpp
+++ b/src/ipa/simple/algorithms/lut.cpp
@@ -40,7 +40,7 @@  void Lut::updateGammaTable(IPAContext &context)
 	const auto gamma = 1.0 / context.activeState.knobs.gamma;
 	const auto contrast = context.activeState.knobs.contrast.value_or(1.0);
 	/* Convert 0..2 to 0..infinity; avoid actual inifinity at tan(pi/2) */
-	double contrastExp = tan(std::clamp(contrast * M_PI_4, 0.0, M_PI_2 - 0.00001));
+	float contrastExp = tan(std::clamp(contrast * M_PI_4, 0.0, M_PI_2 - 0.00001));
 
 	if (!context.gpuIspEnabled) {
 		auto &gammaTable = context.activeState.gamma.gammaTable;
diff --git a/src/ipa/simple/ipa_context.h b/src/ipa/simple/ipa_context.h
index eeade9d35..293e35b71 100644
--- a/src/ipa/simple/ipa_context.h
+++ b/src/ipa/simple/ipa_context.h
@@ -58,8 +58,8 @@  struct IPAActiveState {
 		std::array<double, kGammaLookupSize> gammaTable;
 		uint8_t blackLevel;
 		float gamma;
-		double contrast;
-		double contrastExp;
+		float contrast;
+		float contrastExp;
 	} gamma;
 
 	Matrix<float, 3, 3> combinedMatrix;
@@ -68,7 +68,7 @@  struct IPAActiveState {
 	struct {
 		float gamma;
 		/* 0..2 range, 1.0 = normal */
-		std::optional<double> contrast;
+		std::optional<float> contrast;
 		std::optional<float> saturation;
 	} knobs;
 };
@@ -87,7 +87,7 @@  struct IPAFrameContext : public FrameContext {
 	} gains;
 
 	float gamma;
-	std::optional<double> contrast;
+	std::optional<float> contrast;
 	std::optional<float> saturation;
 };