| Message ID | 20251114005428.90024-8-kieran.bingham@ideasonboard.com |
|---|---|
| State | New |
| Headers | show |
| Series |
|
| Related | show |
Hi Kieran, Thank you for the patch! Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com> Quoting Kieran Bingham (2025-11-14 00:54:11) > Provide a FixedPoint Quantized type to support the Q5.4 format > representing values in the range [-16.0, 15.9375] with a resolution of > 1/16. > > Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > > --- > This format is used by the RKISP1 for Chromatic Abberation Correction > handling > > v4: > - Fix grammar in type documentation > > src/ipa/libipa/fixedpoint.cpp | 9 +++++++++ > src/ipa/libipa/fixedpoint.h | 2 ++ > test/ipa/libipa/fixedpoint.cpp | 5 +++++ > 3 files changed, 16 insertions(+) > > diff --git a/src/ipa/libipa/fixedpoint.cpp b/src/ipa/libipa/fixedpoint.cpp > index 4c3ea33497bf..967b00bcd7c2 100644 > --- a/src/ipa/libipa/fixedpoint.cpp > +++ b/src/ipa/libipa/fixedpoint.cpp > @@ -139,6 +139,15 @@ namespace ipa { > * values in the range [0.0, 1.992] with a resolution of 1/128. > */ > > +/** > + * \typedef Q5_4 > + * \brief 5.4 signed fixed-point quantizer > + * > + * A Quantized type using 5 bits for the integer part and 4 bits for the > + * fractional part, stored in a signed 16-bit integer (\c int16_t). Represents > + * values in the range [-16.0, 15.9375] with a resolution of 1/16. > + */ > + > /** > * \typedef Q12_4 > * \brief 12.4 signed fixed-point quantizer > diff --git a/src/ipa/libipa/fixedpoint.h b/src/ipa/libipa/fixedpoint.h > index d97e6d6135ad..ce621cb01a5a 100644 > --- a/src/ipa/libipa/fixedpoint.h > +++ b/src/ipa/libipa/fixedpoint.h > @@ -105,6 +105,8 @@ struct FixedPointQTraits { > using Q1_7 = Quantized<FixedPointQTraits<1, 7, int8_t>>; > using UQ1_7 = Quantized<FixedPointQTraits<1, 7, uint8_t>>; > > +using Q5_4 = Quantized<FixedPointQTraits<5, 4, int16_t>>; > + > using Q12_4 = Quantized<FixedPointQTraits<12, 4, int16_t>>; > using UQ12_4 = Quantized<FixedPointQTraits<12, 4, uint16_t>>; > > diff --git a/test/ipa/libipa/fixedpoint.cpp b/test/ipa/libipa/fixedpoint.cpp > index 338571e38f68..1d018c0128df 100644 > --- a/test/ipa/libipa/fixedpoint.cpp > +++ b/test/ipa/libipa/fixedpoint.cpp > @@ -190,6 +190,11 @@ protected: > fails += quantizedCheck<Q4_7>(-0.4f, 0b1111'1001101, -0.398438f); /* 0x7cd */ > fails += quantizedCheck<Q4_7>(-1.4f, 0b1110'1001101, -1.39844f); /* 0x74d */ > > + /* Q5_4(-16 .. 15.9375) Min: [0x0100:-16] -- Max: [0x00ff:15.9375] Step:0.0625 */ > + introduce<Q5_4>("Q5_4"); > + fails += quantizedCheck<Q5_4>(-16.00f, 0b10000'0000, -16.00f); > + fails += quantizedCheck<Q5_4>( 15.94f, 0b01111'1111, 15.9375f); > + > /* Q12.4(-2048 .. 2047.94) Min: [0x8000:-2048] -- Max: [0x7fff:2047.94] Step:0.0625 */ > introduce<Q12_4>("Q12_4"); > fails += quantizedCheck<Q12_4>(0.0f, 0b000000000000'0000, 0.0f); > -- > 2.51.1 >
diff --git a/src/ipa/libipa/fixedpoint.cpp b/src/ipa/libipa/fixedpoint.cpp index 4c3ea33497bf..967b00bcd7c2 100644 --- a/src/ipa/libipa/fixedpoint.cpp +++ b/src/ipa/libipa/fixedpoint.cpp @@ -139,6 +139,15 @@ namespace ipa { * values in the range [0.0, 1.992] with a resolution of 1/128. */ +/** + * \typedef Q5_4 + * \brief 5.4 signed fixed-point quantizer + * + * A Quantized type using 5 bits for the integer part and 4 bits for the + * fractional part, stored in a signed 16-bit integer (\c int16_t). Represents + * values in the range [-16.0, 15.9375] with a resolution of 1/16. + */ + /** * \typedef Q12_4 * \brief 12.4 signed fixed-point quantizer diff --git a/src/ipa/libipa/fixedpoint.h b/src/ipa/libipa/fixedpoint.h index d97e6d6135ad..ce621cb01a5a 100644 --- a/src/ipa/libipa/fixedpoint.h +++ b/src/ipa/libipa/fixedpoint.h @@ -105,6 +105,8 @@ struct FixedPointQTraits { using Q1_7 = Quantized<FixedPointQTraits<1, 7, int8_t>>; using UQ1_7 = Quantized<FixedPointQTraits<1, 7, uint8_t>>; +using Q5_4 = Quantized<FixedPointQTraits<5, 4, int16_t>>; + using Q12_4 = Quantized<FixedPointQTraits<12, 4, int16_t>>; using UQ12_4 = Quantized<FixedPointQTraits<12, 4, uint16_t>>; diff --git a/test/ipa/libipa/fixedpoint.cpp b/test/ipa/libipa/fixedpoint.cpp index 338571e38f68..1d018c0128df 100644 --- a/test/ipa/libipa/fixedpoint.cpp +++ b/test/ipa/libipa/fixedpoint.cpp @@ -190,6 +190,11 @@ protected: fails += quantizedCheck<Q4_7>(-0.4f, 0b1111'1001101, -0.398438f); /* 0x7cd */ fails += quantizedCheck<Q4_7>(-1.4f, 0b1110'1001101, -1.39844f); /* 0x74d */ + /* Q5_4(-16 .. 15.9375) Min: [0x0100:-16] -- Max: [0x00ff:15.9375] Step:0.0625 */ + introduce<Q5_4>("Q5_4"); + fails += quantizedCheck<Q5_4>(-16.00f, 0b10000'0000, -16.00f); + fails += quantizedCheck<Q5_4>( 15.94f, 0b01111'1111, 15.9375f); + /* Q12.4(-2048 .. 2047.94) Min: [0x8000:-2048] -- Max: [0x7fff:2047.94] Step:0.0625 */ introduce<Q12_4>("Q12_4"); fails += quantizedCheck<Q12_4>(0.0f, 0b000000000000'0000, 0.0f);
Provide a FixedPoint Quantized type to support the Q5.4 format representing values in the range [-16.0, 15.9375] with a resolution of 1/16. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> --- This format is used by the RKISP1 for Chromatic Abberation Correction handling v4: - Fix grammar in type documentation src/ipa/libipa/fixedpoint.cpp | 9 +++++++++ src/ipa/libipa/fixedpoint.h | 2 ++ test/ipa/libipa/fixedpoint.cpp | 5 +++++ 3 files changed, 16 insertions(+)