mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-12 23:09:45 +03:00
libcamera: matrix: Add read-only accessor to internal data
Add a data() function to the Matrix class to access the internal data. This is useful for code that needs to use the matrix contents as a linear array, as shown by the RkISP1::Ccm::process() function that needs to copy the matrix data to a local variable. Simplify that function by using the new accessor. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
This commit is contained in:
parent
7fdfe648a4
commit
7e5d811842
3 changed files with 14 additions and 6 deletions
|
@ -66,6 +66,8 @@ public:
|
||||||
return out.str();
|
return out.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Span<const T, Rows * Cols> data() const { return data_; }
|
||||||
|
|
||||||
Span<const T, Cols> operator[](size_t i) const
|
Span<const T, Cols> operator[](size_t i) const
|
||||||
{
|
{
|
||||||
return Span<const T, Cols>{ &data_.data()[i * Cols], Cols };
|
return Span<const T, Cols>{ &data_.data()[i * Cols], Cols };
|
||||||
|
|
|
@ -120,12 +120,7 @@ void Ccm::process([[maybe_unused]] IPAContext &context,
|
||||||
[[maybe_unused]] const rkisp1_stat_buffer *stats,
|
[[maybe_unused]] const rkisp1_stat_buffer *stats,
|
||||||
ControlList &metadata)
|
ControlList &metadata)
|
||||||
{
|
{
|
||||||
float m[9];
|
metadata.set(controls::ColourCorrectionMatrix, frameContext.ccm.ccm.data());
|
||||||
for (unsigned int i = 0; i < 3; i++) {
|
|
||||||
for (unsigned int j = 0; j < 3; j++)
|
|
||||||
m[i * 3 + j] = frameContext.ccm.ccm[i][j];
|
|
||||||
}
|
|
||||||
metadata.set(controls::ColourCorrectionMatrix, m);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
REGISTER_IPA_ALGORITHM(Ccm, "Ccm")
|
REGISTER_IPA_ALGORITHM(Ccm, "Ccm")
|
||||||
|
|
|
@ -52,6 +52,17 @@ LOG_DEFINE_CATEGORY(Matrix)
|
||||||
* \return A string describing the matrix
|
* \return A string describing the matrix
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \fn Matrix::data()
|
||||||
|
* \brief Access the matrix data as a linear array
|
||||||
|
*
|
||||||
|
* Access the contents of the matrix as a one-dimensional linear array of
|
||||||
|
* values in row-major order. The size of the array is equal to the product of
|
||||||
|
* the number of rows and columns of the matrix (Rows x Cols).
|
||||||
|
*
|
||||||
|
* \return A span referencing the matrix data as a linear array
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \fn Span<const T, Cols> Matrix::operator[](size_t i) const
|
* \fn Span<const T, Cols> Matrix::operator[](size_t i) const
|
||||||
* \brief Index to a row in the matrix
|
* \brief Index to a row in the matrix
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue