[v2,08/13] test: libipa: Provide ScaledFixedPoint tests
diff mbox series

Message ID 20251029172439.1513907-9-kieran.bingham@ideasonboard.com
State New
Headers show
Series
  • libipa: Introduce a Quantized type
Related show

Commit Message

Kieran Bingham Oct. 29, 2025, 5:24 p.m. UTC
Use the new ScaledFixedPointQTraits to create a HueQ representing
the equivalent scale used by the RKISP1 Hue control to validate
the scaling capabilities of the new quantized type.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 test/ipa/libipa/fixedpoint.cpp | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

Patch
diff mbox series

diff --git a/test/ipa/libipa/fixedpoint.cpp b/test/ipa/libipa/fixedpoint.cpp
index 4bffd40f5a63..f8be1e4bf70f 100644
--- a/test/ipa/libipa/fixedpoint.cpp
+++ b/test/ipa/libipa/fixedpoint.cpp
@@ -221,6 +221,32 @@  protected:
 		return TestPass;
 	}
 
+	int testScaledFixedPointQuantizers()
+	{
+		unsigned int fails = 0;
+		cerr << std::endl
+		     << "Scaled Fixed-Point Quantizer tests:" << std::endl;
+
+		using HueQ = Quantized<ScaledFixedPointQTraits<Q1_7::TraitsType, 90>>;
+
+		fails += introduce<HueQ>("HueQ (Scaled Q1_7 * 90) ");
+
+		/* clang-format off */
+
+		fails += quantizedCheck<HueQ>(-90.0f, -128, -90.0f);	/* Min */
+		fails += quantizedCheck<HueQ>(-45.0f,  -64, -45.0f);	/* Mid negative */
+		fails += quantizedCheck<HueQ>(  0.0f,    0,   0.0f);	/* Zero */
+		fails += quantizedCheck<HueQ>( 45.0f,   64,  45.0f);	/* Mid positive */
+		fails += quantizedCheck<HueQ>( 90.0f,  127,  89.2969f);	/* Max */
+
+		fails += quantizedCheck<HueQ>(-99.0f, -128, -90.0f);	/* Clamp low */
+		fails += quantizedCheck<HueQ>( 99.0f,  127,  89.2969f);	/* Clamp high */
+
+		/* clang-format on */
+
+		return fails ? TestFail : TestPass;
+	}
+
 	int run()
 	{
 		unsigned int fails = 0;
@@ -232,6 +258,9 @@  protected:
 		if (testFixedPointQuantizers() != TestPass)
 			fails++;
 
+		if (testScaledFixedPointQuantizers() != TestPass)
+			fails++;
+
 		return fails ? TestFail : TestPass;
 	}
 };