[{"id":33251,"web_url":"https://patchwork.libcamera.org/comment/33251/","msgid":"<85a5b3xrb7.fsf@mzamazal-thinkpadp1gen3.tpbc.csb>","date":"2025-02-03T10:20:44","subject":"Re: [PATCH v2] libcamera: matrix: Add read-only accessor to\n\tinternal data","submitter":{"id":177,"url":"https://patchwork.libcamera.org/api/people/177/","name":"Milan Zamazal","email":"mzamazal@redhat.com"},"content":"Hi Laurent,\n\nthank you for the update.\n\nLaurent Pinchart <laurent.pinchart@ideasonboard.com> writes:\n\n> Add a data() function to the Matrix class to access the internal data.\n> This is useful for code that needs to use the matrix contents as a\n> linear array, as shown by the RkISP1::Ccm::process() function that needs\n> to copy the matrix data to a local variable. Simplify that function by\n> using the new accessor.\n>\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nReviewed-by: Milan Zamazal <mzamazal@redhat.com>\n\n> ---\n> Changes since v1:\n>\n> - Expand function documentation\n> ---\n>  include/libcamera/internal/matrix.h |  2 ++\n>  src/ipa/rkisp1/algorithms/ccm.cpp   |  7 +------\n>  src/libcamera/matrix.cpp            | 11 +++++++++++\n>  3 files changed, 14 insertions(+), 6 deletions(-)\n>\n> diff --git a/include/libcamera/internal/matrix.h b/include/libcamera/internal/matrix.h\n> index 7a71028c473a..a055e6926c94 100644\n> --- a/include/libcamera/internal/matrix.h\n> +++ b/include/libcamera/internal/matrix.h\n> @@ -66,6 +66,8 @@ public:\n>  \t\treturn out.str();\n>  \t}\n>\n> +\tSpan<const T, Rows * Cols> data() const { return data_; }\n> +\n>  \tSpan<const T, Cols> operator[](size_t i) const\n>  \t{\n>  \t\treturn Span<const T, Cols>{ &data_.data()[i * Cols], Cols };\n> diff --git a/src/ipa/rkisp1/algorithms/ccm.cpp b/src/ipa/rkisp1/algorithms/ccm.cpp\n> index e2b5cf4d313e..eb8ca39e56a8 100644\n> --- a/src/ipa/rkisp1/algorithms/ccm.cpp\n> +++ b/src/ipa/rkisp1/algorithms/ccm.cpp\n> @@ -120,12 +120,7 @@ void Ccm::process([[maybe_unused]] IPAContext &context,\n>  \t\t  [[maybe_unused]] const rkisp1_stat_buffer *stats,\n>  \t\t  ControlList &metadata)\n>  {\n> -\tfloat m[9];\n> -\tfor (unsigned int i = 0; i < 3; i++) {\n> -\t\tfor (unsigned int j = 0; j < 3; j++)\n> -\t\t\tm[i * 3 + j] = frameContext.ccm.ccm[i][j];\n> -\t}\n> -\tmetadata.set(controls::ColourCorrectionMatrix, m);\n> +\tmetadata.set(controls::ColourCorrectionMatrix, frameContext.ccm.ccm.data());\n>  }\n>\n>  REGISTER_IPA_ALGORITHM(Ccm, \"Ccm\")\n> diff --git a/src/libcamera/matrix.cpp b/src/libcamera/matrix.cpp\n> index 4d95a19bfbb9..e7e027225666 100644\n> --- a/src/libcamera/matrix.cpp\n> +++ b/src/libcamera/matrix.cpp\n> @@ -52,6 +52,17 @@ LOG_DEFINE_CATEGORY(Matrix)\n>   * \\return A string describing the matrix\n>   */\n>\n> +/**\n> + * \\fn Matrix::data()\n> + * \\brief Access the matrix data as a linear array\n> + *\n> + * Access the contents of the matrix as a one-dimensional linear array of\n> + * values in row-major order. The size of the array is equal to the product of\n> + * the number of rows and columns of the matrix (Rows x Cols).\n> + *\n> + * \\return A span referencing the matrix data as a linear array\n> + */\n> +\n>  /**\n>   * \\fn Span<const T, Cols> Matrix::operator[](size_t i) const\n>   * \\brief Index to a row in the matrix\n>\n> base-commit: 9bc8b6a573a63b8c9f5588cdea6da5ae71abd138\n> --\n> Regards,\n>\n> Laurent Pinchart","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 2B37EBD80A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  3 Feb 2025 10:20:53 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 43A7268585;\n\tMon,  3 Feb 2025 11:20:52 +0100 (CET)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.133.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A439D6034B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  3 Feb 2025 11:20:50 +0100 (CET)","from mail-ej1-f72.google.com (mail-ej1-f72.google.com\n\t[209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-146-u6bxWd87PXORMcgyUL9Ifg-1; Mon, 03 Feb 2025 05:20:48 -0500","by mail-ej1-f72.google.com with SMTP id\n\ta640c23a62f3a-ab39f65dc10so451226066b.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 03 Feb 2025 02:20:48 -0800 (PST)","from mzamazal-thinkpadp1gen3.tpbc.csb\n\t(ip-77-48-47-2.net.vodafone.cz. [77.48.47.2])\n\tby smtp.gmail.com with ESMTPSA id\n\t4fb4d7f45d1cf-5dc724c9cffsm7461859a12.74.2025.02.03.02.20.44\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 03 Feb 2025 02:20:45 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"eIGBnzpO\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1738578049;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=Rb/QWWP6NyOYf/nM5qNAU943wJqi4ITNlHJAt48MWMU=;\n\tb=eIGBnzpOzJ0Wmy2tMq82kdza5bVWCXL+1s5wpdQz3T2kROnUYWMMxMCnfFl4HxUCge9tCI\n\tsdvDSozV2qU9Q1qcUIpQeNCmy5tsMbuMPS701vFEkKfGc899ltD7cYTUwIFSIIAi3bzpTp\n\tEm0vchfRsa1OqbEKGBAdokPoQZNePAM=","X-MC-Unique":"u6bxWd87PXORMcgyUL9Ifg-1","X-Mimecast-MFC-AGG-ID":"u6bxWd87PXORMcgyUL9Ifg","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1738578047; x=1739182847;\n\th=mime-version:user-agent:message-id:date:references:in-reply-to\n\t:subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=Rb/QWWP6NyOYf/nM5qNAU943wJqi4ITNlHJAt48MWMU=;\n\tb=CcjcBBC0S2Y2Cgzgy8J8ICLDMIH3/GN1lnJp8uq+gwjkM6mZN4sYSXEH4uupnDL8MD\n\tprUxAsKkvhDhRHv7Vm37SJa5kfyxXjYjEwWzrpziRFFyHwQ/cz5CjgYoCu/FwveZtYTB\n\tijGpMu9M1iveNy7Cg2HiSLg2abq2xRWLT+IVDr0mQQckKZoLV21o4+gs6fdJCk2Zlhx/\n\tos9aUzQxR98VuE0tboKR+/aBbPMZmHzCm2sKNZj+0B6siZ2V1wVj0+j4H/+6TeIpXpPb\n\tT4246gmlr84/bb8sW66OlMcxzHOpMjBtem3SZUv6MUFHqCFccf/jxI9umbXIgqDMrE+2\n\tbYUw==","X-Gm-Message-State":"AOJu0Yxz8I20Ydaw82ydE+QyW6MpYVMgynMtguLHa16om6ar1Xh67+iD\n\tQ7dRSLN60WWIENU5wXF/AczHPabsxvs+6LshwScVEXrdgj3cmuDHFPOCsQW/rG7u0XWi11symSk\n\tj7NZKl/hhYmBoNvfvHOn5vB9TViYKy0kOMu4triMRJYRLafbsTwrRhpKATdNad1SD6WmEMp5Uc0\n\tt9f7QI1fBSc7oKCooDhj5XkSM6CUJvGRbId+WaomqX4v+BuusujZW7ibA=","X-Gm-Gg":"ASbGncu8EeLNU2HaHWwj5+1OpbnBodWlq/ZkHaKKyuOXVkXIjpK9jqUJe+2us+Ola3l\n\tKW/5uM0rSXWJFv0EGAPRO47+Ts/QAg30ERYRe3EGj7pgXTtIoCuUo3XKuN1lzEywpYy5F85Tx90\n\t1jrzp2LSBO6WuzVMw1FGBe0l9wtPnG8gPtA/f85BqPft8DWuRSUVF2FhbbCSMLOWD4PdhKjtcju\n\thJYKlewNKaatjOyZTwbBZQYRyK6dFbIvDQMZ9tHU1bplkbAkPDpOdbQ4dLKdwxpBjN0BTf2Z0XJ\n\tmQ7vWqGfhQw6qQLSD+4elHczRpmnJ1yMCzL8SYfWCYad5noMVxZ27xqHdw==","X-Received":["by 2002:a17:906:4fca:b0:ab7:a4e:8d79 with SMTP id\n\ta640c23a62f3a-ab70a4e9628mr986540566b.36.1738578046780; \n\tMon, 03 Feb 2025 02:20:46 -0800 (PST)","by 2002:a17:906:4fca:b0:ab7:a4e:8d79 with SMTP id\n\ta640c23a62f3a-ab70a4e9628mr986537766b.36.1738578046322; \n\tMon, 03 Feb 2025 02:20:46 -0800 (PST)"],"X-Google-Smtp-Source":"AGHT+IFvjJ+fzIukqf6lxEm3PYa3hJSt70NojWieRP1Emhpm8RfjCZ6t4+u+ncWveSGjoVMHMAY1Ew==","From":"Milan Zamazal <mzamazal@redhat.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v2] libcamera: matrix: Add read-only accessor to\n\tinternal data","In-Reply-To":"<20250202232739.31548-1-laurent.pinchart@ideasonboard.com>\n\t(Laurent Pinchart's message of \"Mon, 3 Feb 2025 01:27:39 +0200\")","References":"<20250202232739.31548-1-laurent.pinchart@ideasonboard.com>","Date":"Mon, 03 Feb 2025 11:20:44 +0100","Message-ID":"<85a5b3xrb7.fsf@mzamazal-thinkpadp1gen3.tpbc.csb>","User-Agent":"Gnus/5.13 (Gnus v5.13)","MIME-Version":"1.0","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"9ZFek5WbVrvkJaStkEyZO3Pe5pVGjTo5KMO5sgBIZsI_1738578047","X-Mimecast-Originator":"redhat.com","Content-Type":"text/plain","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]