[v4,16/21] ipa: rkisp1: ccm: Use Q4_7 format directly
diff mbox series

Message ID 20251114005428.90024-17-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
Replace the legacy call to floatingToFixedPoint with the new FixedPoint
quantizer to explicitly describe the type used by the RKISP1 Colour
Correction Matrix.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 src/ipa/rkisp1/algorithms/ccm.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Isaac Scott Nov. 18, 2025, 12:41 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:20)
> Replace the legacy call to floatingToFixedPoint with the new FixedPoint
> quantizer to explicitly describe the type used by the RKISP1 Colour
> Correction Matrix.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> ---
>  src/ipa/rkisp1/algorithms/ccm.cpp | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/src/ipa/rkisp1/algorithms/ccm.cpp b/src/ipa/rkisp1/algorithms/ccm.cpp
> index de2b6fe775aa..a99336c478b1 100644
> --- a/src/ipa/rkisp1/algorithms/ccm.cpp
> +++ b/src/ipa/rkisp1/algorithms/ccm.cpp
> @@ -115,10 +115,11 @@ void Ccm::setParameters(struct rkisp1_cif_isp_ctk_config &config,
>          * 4 bit integer and 7 bit fractional, ranging from -8 (0x400) to
>          * +7.9921875 (0x3ff)
>          */
> +       using Q4_7 = Quantized<FixedPointQTraits<4, 7, int16_t>>;
> +
>         for (unsigned int i = 0; i < 3; i++) {
>                 for (unsigned int j = 0; j < 3; j++)
> -                       config.coeff[i][j] =
> -                               floatingToFixedPoint<4, 7, uint16_t, double>(matrix[i][j]);
> +                       config.coeff[i][j] = Q4_7(matrix[i][j]).quantized();
>         }
>  
>         for (unsigned int i = 0; i < 3; i++)
> -- 
> 2.51.1
>
Laurent Pinchart Nov. 19, 2025, 4:30 a.m. UTC | #2
On Fri, Nov 14, 2025 at 12:54:20AM +0000, Kieran Bingham wrote:
> Replace the legacy call to floatingToFixedPoint with the new FixedPoint
> quantizer to explicitly describe the type used by the RKISP1 Colour
> Correction Matrix.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> ---
>  src/ipa/rkisp1/algorithms/ccm.cpp | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/src/ipa/rkisp1/algorithms/ccm.cpp b/src/ipa/rkisp1/algorithms/ccm.cpp
> index de2b6fe775aa..a99336c478b1 100644
> --- a/src/ipa/rkisp1/algorithms/ccm.cpp
> +++ b/src/ipa/rkisp1/algorithms/ccm.cpp
> @@ -115,10 +115,11 @@ void Ccm::setParameters(struct rkisp1_cif_isp_ctk_config &config,
>  	 * 4 bit integer and 7 bit fractional, ranging from -8 (0x400) to
>  	 * +7.9921875 (0x3ff)
>  	 */
> +	using Q4_7 = Quantized<FixedPointQTraits<4, 7, int16_t>>;
> +
>  	for (unsigned int i = 0; i < 3; i++) {
>  		for (unsigned int j = 0; j < 3; j++)
> -			config.coeff[i][j] =
> -				floatingToFixedPoint<4, 7, uint16_t, double>(matrix[i][j]);
> +			config.coeff[i][j] = Q4_7(matrix[i][j]).quantized();
>  	}

Out of curiosity, what's the impact on the generated code ?

>  
>  	for (unsigned int i = 0; i < 3; i++)

Patch
diff mbox series

diff --git a/src/ipa/rkisp1/algorithms/ccm.cpp b/src/ipa/rkisp1/algorithms/ccm.cpp
index de2b6fe775aa..a99336c478b1 100644
--- a/src/ipa/rkisp1/algorithms/ccm.cpp
+++ b/src/ipa/rkisp1/algorithms/ccm.cpp
@@ -115,10 +115,11 @@  void Ccm::setParameters(struct rkisp1_cif_isp_ctk_config &config,
 	 * 4 bit integer and 7 bit fractional, ranging from -8 (0x400) to
 	 * +7.9921875 (0x3ff)
 	 */
+	using Q4_7 = Quantized<FixedPointQTraits<4, 7, int16_t>>;
+
 	for (unsigned int i = 0; i < 3; i++) {
 		for (unsigned int j = 0; j < 3; j++)
-			config.coeff[i][j] =
-				floatingToFixedPoint<4, 7, uint16_t, double>(matrix[i][j]);
+			config.coeff[i][j] = Q4_7(matrix[i][j]).quantized();
 	}
 
 	for (unsigned int i = 0; i < 3; i++)