[v4,11/21] test: libipa: Provide ScaledFixedPoint tests
diff mbox series

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

Commit Message

Kieran Bingham Nov. 14, 2025, 12:54 a.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 | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

Comments

Isaac Scott Nov. 18, 2025, 12:40 p.m. UTC | #1
Hi Kieran,

Thank you for the patch!

Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>

Quoting Kieran Bingham (2025-11-14 00:54:15)
> 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 | 30 ++++++++++++++++++++++++++++++
>  1 file changed, 30 insertions(+)
> 
> diff --git a/test/ipa/libipa/fixedpoint.cpp b/test/ipa/libipa/fixedpoint.cpp
> index f3773dfe6ad4..e3428272fae5 100644
> --- a/test/ipa/libipa/fixedpoint.cpp
> +++ b/test/ipa/libipa/fixedpoint.cpp
> @@ -235,6 +235,33 @@ 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>>;
> +
> +               /* HueQ (Scaled Q1_7 * 90) (-90 .. 89.2969)  Min: [0x80:-90] -- Max: [0x7f:89.2969] Step:0.703125 */
> +               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;
> @@ -246,6 +273,9 @@ protected:
>                 if (testFixedPointQuantizers() != TestPass)
>                         fails++;
>  
> +               if (testScaledFixedPointQuantizers() != TestPass)
> +                       fails++;
> +
>                 return fails ? TestFail : TestPass;
>         }
>  };
> -- 
> 2.51.1
>

Patch
diff mbox series

diff --git a/test/ipa/libipa/fixedpoint.cpp b/test/ipa/libipa/fixedpoint.cpp
index f3773dfe6ad4..e3428272fae5 100644
--- a/test/ipa/libipa/fixedpoint.cpp
+++ b/test/ipa/libipa/fixedpoint.cpp
@@ -235,6 +235,33 @@  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>>;
+
+		/* HueQ (Scaled Q1_7 * 90) (-90 .. 89.2969)  Min: [0x80:-90] -- Max: [0x7f:89.2969] Step:0.703125 */
+		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;
@@ -246,6 +273,9 @@  protected:
 		if (testFixedPointQuantizers() != TestPass)
 			fails++;
 
+		if (testScaledFixedPointQuantizers() != TestPass)
+			fails++;
+
 		return fails ? TestFail : TestPass;
 	}
 };