| Message ID | 20260826181953.261754-3-mzamazal@redhat.com |
|---|---|
| State | Superseded |
| Headers | show |
| Series |
|
| Related | show |
Quoting Milan Zamazal (2026-08-26 19:19:49) > From: Xander Pronk <xander.c.pronk@gmail.com> > > Add a lookup table for grid-based lens shading correction to debayer > params. The lookup table is in the format of an RGBA texture to be > passed to debayering. The alpha value serves only for padding and can > be arbitrary; OpenGL wants by default rows aligned to 4 bytes and using > RGBA format is the simplest way to achieve it. > > The parameter is filled in by Lsc algorithm implemented in a follow-up > patch. If the algorithm is not enabled, the table is filled in with > values corresponding to identity multiplication (1.0). > > In order the image processing would be able to update its internal > data (e.g. the GPU texture) on and only on the lookup table changes, > lscLutVersion parameter is added, which is incremented on each lookup > table change. > > The parameters are currently unused, their handling is implemented in > follow-up patches. > > The grid size is selected to be the same as in the tuning files already > present in rkisp1. Another popular grid size in other pipelines is 32. Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> I'm keen to get this series in now for 0.8. As far as I can tell, there's no possible regressions in this series, and CI is only blocked on the merge check from some missing tags. Lets fix that: Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > > Co-developed-by: Rick ten Wolde <rick_libcamera@wolde.info> > Signed-off-by: Rick ten Wolde <rick_libcamera@wolde.info> > Signed-off-by: Xander Pronk <xander.c.pronk@gmail.com> > Signed-off-by: Milan Zamazal <mzamazal@redhat.com> > --- > .../internal/software_isp/debayer_params.h | 13 +++++++++ > src/libcamera/software_isp/debayer.cpp | 28 +++++++++++++++++++ > 2 files changed, 41 insertions(+) > > diff --git a/include/libcamera/internal/software_isp/debayer_params.h b/include/libcamera/internal/software_isp/debayer_params.h > index 1074720d7..0d9196874 100644 > --- a/include/libcamera/internal/software_isp/debayer_params.h > +++ b/include/libcamera/internal/software_isp/debayer_params.h > @@ -10,6 +10,7 @@ > > #pragma once > > +#include <array> > #include <stdint.h> > > #include "libcamera/internal/matrix.h" > @@ -25,6 +26,18 @@ struct DebayerParams { > float gamma = 1.0; > float contrastExp = 1.0; > RGB<double> gains = RGB<double>({ 1.0, 1.0, 1.0 }); > + > + /** > + * To prevent OpenGL alignment issues, the number of bytes in each row > + * must be a multiple of 4 (the initial value of GL_UNPACK_ALIGNMENT) > + * and lscLut is also aligned to 4 bytes. > + **/ > + static constexpr unsigned int kLscGridSize = 17; > + static constexpr unsigned int kLscValuesPerCell = 4; > + using LscLookupTable = > + std::array<uint8_t, kLscGridSize * kLscGridSize * kLscValuesPerCell>; > + alignas(4) LscLookupTable lscLut{}; > + uint64_t lscLutVersion = 0; > }; > > } /* namespace libcamera */ > diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp > index a4854e51b..82cdf1dc2 100644 > --- a/src/libcamera/software_isp/debayer.cpp > +++ b/src/libcamera/software_isp/debayer.cpp > @@ -43,6 +43,34 @@ namespace libcamera { > * \brief Contrast value to be used as an exponent > */ > > +/** > + * \var DebayerParams::kLscGridSize > + * \brief Number of lens shading grid areas in one direction > + */ > + > +/** > + * \var DebayerParams::kLscValuesPerCell > + * \brief Number of pixel values per each of the lens shading grid areas > + */ > + > +/** > + * \typedef DebayerParams::LscLookupTable > + * \brief Lookup table for lens shading correction > + * > + * It's an array of values to be later used as a texture. > + * The values are in row - column - RGB order. > + */ > + > +/** > + * \var DebayerParams::lscLut > + * \brief Lens shading lookup table > + */ > + > +/** > + * \var DebayerParams::lscLutVersion > + * \brief Incremented on each \a lscLut change > + */ > + > /** > * \class Debayer > * \brief Base debayering class > -- > 2.55.0 >
diff --git a/include/libcamera/internal/software_isp/debayer_params.h b/include/libcamera/internal/software_isp/debayer_params.h index 1074720d7..0d9196874 100644 --- a/include/libcamera/internal/software_isp/debayer_params.h +++ b/include/libcamera/internal/software_isp/debayer_params.h @@ -10,6 +10,7 @@ #pragma once +#include <array> #include <stdint.h> #include "libcamera/internal/matrix.h" @@ -25,6 +26,18 @@ struct DebayerParams { float gamma = 1.0; float contrastExp = 1.0; RGB<double> gains = RGB<double>({ 1.0, 1.0, 1.0 }); + + /** + * To prevent OpenGL alignment issues, the number of bytes in each row + * must be a multiple of 4 (the initial value of GL_UNPACK_ALIGNMENT) + * and lscLut is also aligned to 4 bytes. + **/ + static constexpr unsigned int kLscGridSize = 17; + static constexpr unsigned int kLscValuesPerCell = 4; + using LscLookupTable = + std::array<uint8_t, kLscGridSize * kLscGridSize * kLscValuesPerCell>; + alignas(4) LscLookupTable lscLut{}; + uint64_t lscLutVersion = 0; }; } /* namespace libcamera */ diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp index a4854e51b..82cdf1dc2 100644 --- a/src/libcamera/software_isp/debayer.cpp +++ b/src/libcamera/software_isp/debayer.cpp @@ -43,6 +43,34 @@ namespace libcamera { * \brief Contrast value to be used as an exponent */ +/** + * \var DebayerParams::kLscGridSize + * \brief Number of lens shading grid areas in one direction + */ + +/** + * \var DebayerParams::kLscValuesPerCell + * \brief Number of pixel values per each of the lens shading grid areas + */ + +/** + * \typedef DebayerParams::LscLookupTable + * \brief Lookup table for lens shading correction + * + * It's an array of values to be later used as a texture. + * The values are in row - column - RGB order. + */ + +/** + * \var DebayerParams::lscLut + * \brief Lens shading lookup table + */ + +/** + * \var DebayerParams::lscLutVersion + * \brief Incremented on each \a lscLut change + */ + /** * \class Debayer * \brief Base debayering class