From patchwork Mon Jan 27 06:47:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 22653 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id B5194BEFBE for ; Mon, 27 Jan 2025 06:47:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AF4E66855D; Mon, 27 Jan 2025 07:47:57 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="acZ1SRgl"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id BE1B561875 for ; Mon, 27 Jan 2025 07:47:56 +0100 (CET) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4FEB7496 for ; Mon, 27 Jan 2025 07:46:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1737960410; bh=aoKpxmkgUfy9nL0MbrUHz/gerjTa8dtZe6K1Eq7Eb68=; h=From:To:Subject:Date:From; b=acZ1SRgl69tC/9tzyDC3aO9KeF0tfazz+36VACA+v/xs4JgXA9lrKSn176NRu9g8b lYwl45wLM04apwgG2JgYEApWS5cyrXeXcVDKaylrhn9985jmd8yzGr5hCb7BOHoYM1 7U4eO35zN6HOhPU4ka8aLqlDf+lT3pw6uqKtfs/I= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH] libcamera: matrix: Add read-only accessor to internal data Date: Mon, 27 Jan 2025 08:47:45 +0200 Message-ID: <20250127064745.5740-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.45.3 MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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 shows 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 Reviewed-by: Kieran Bingham --- include/libcamera/internal/matrix.h | 2 ++ src/ipa/rkisp1/algorithms/ccm.cpp | 7 +------ src/libcamera/matrix.cpp | 6 ++++++ 3 files changed, 9 insertions(+), 6 deletions(-) base-commit: 8aef7b4dfb12f2f9bf0513625231b85a5b8f5440 diff --git a/include/libcamera/internal/matrix.h b/include/libcamera/internal/matrix.h index 7a71028c473a..a055e6926c94 100644 --- a/include/libcamera/internal/matrix.h +++ b/include/libcamera/internal/matrix.h @@ -66,6 +66,8 @@ public: return out.str(); } + Span data() const { return data_; } + Span operator[](size_t i) const { return Span{ &data_.data()[i * Cols], Cols }; diff --git a/src/ipa/rkisp1/algorithms/ccm.cpp b/src/ipa/rkisp1/algorithms/ccm.cpp index e2b5cf4d313e..eb8ca39e56a8 100644 --- a/src/ipa/rkisp1/algorithms/ccm.cpp +++ b/src/ipa/rkisp1/algorithms/ccm.cpp @@ -120,12 +120,7 @@ void Ccm::process([[maybe_unused]] IPAContext &context, [[maybe_unused]] const rkisp1_stat_buffer *stats, ControlList &metadata) { - float m[9]; - 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); + metadata.set(controls::ColourCorrectionMatrix, frameContext.ccm.ccm.data()); } REGISTER_IPA_ALGORITHM(Ccm, "Ccm") diff --git a/src/libcamera/matrix.cpp b/src/libcamera/matrix.cpp index 4d95a19bfbb9..d9d34867b0a3 100644 --- a/src/libcamera/matrix.cpp +++ b/src/libcamera/matrix.cpp @@ -52,6 +52,12 @@ LOG_DEFINE_CATEGORY(Matrix) * \return A string describing the matrix */ +/** + * \fn Matrix::data() + * \brief Access the internal data as a linear array + * \return A span referencing the internal data as a linear array + */ + /** * \fn Span Matrix::operator[](size_t i) const * \brief Index to a row in the matrix