Patch Detail
Show a patch.
GET /api/patches/22721/?format=api
{ "id": 22721, "url": "https://patchwork.libcamera.org/api/patches/22721/?format=api", "web_url": "https://patchwork.libcamera.org/patch/22721/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20250202235634.3776-1-laurent.pinchart@ideasonboard.com>", "date": "2025-02-02T23:56:34", "name": "ipa: libipa: vector: Add element-wise division operator", "commit_ref": null, "pull_url": null, "state": "rejected", "archived": false, "hash": "10ad9f1871c0d17235a026ff8af7743c6d634db5", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/22721/mbox/", "series": [ { "id": 4986, "url": "https://patchwork.libcamera.org/api/series/4986/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4986", "date": "2025-02-02T23:56:34", "name": "ipa: libipa: vector: Add element-wise division operator", "version": 1, "mbox": "https://patchwork.libcamera.org/series/4986/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/22721/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/22721/checks/", "tags": {}, "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 E77BCC0F1B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 2 Feb 2025 23:56:40 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id F055868576;\n\tMon, 3 Feb 2025 00:56:39 +0100 (CET)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id EEF2361876\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 3 Feb 2025 00:56:37 +0100 (CET)", "from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 77D6A227\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 3 Feb 2025 00:55:26 +0100 (CET)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"clZMBHvg\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1738540526;\n\tbh=by8ucSt7EqFqhlnCLqxZWVt9KdRo9gwU078KUcOkFV4=;\n\th=From:To:Subject:Date:From;\n\tb=clZMBHvg6QWK8pzYyyS7YCAcxVQaPIoNMsQ2BarmadHWNNpzM4CAvq1jpc5bzPYpq\n\tfcgNgTfQsC76SDGKQCP90LwxRmGWQOugmvAJPFlnQQHGlYI1HjscidRMsCDV2Z9XyO\n\tN/bUY4nmK7dZgPhl/QpUrj8BxOdcmsvExgCwkRI8=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Subject": "[PATCH] ipa: libipa: vector: Add element-wise division operator", "Date": "Mon, 3 Feb 2025 01:56:34 +0200", "Message-ID": "<20250202235634.3776-1-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.45.3", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "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>" }, "content": "Add an operator to divide a scaler by a vector element-wise. Use it in\nthe rkisp1 AWB algorithm to replace manual operation on individual RGB\ncomponents.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/ipa/libipa/vector.cpp | 10 ++++++++++\n src/ipa/libipa/vector.h | 11 +++++++++++\n src/ipa/rkisp1/algorithms/awb.cpp | 6 +-----\n 3 files changed, 22 insertions(+), 5 deletions(-)\n\n\nbase-commit: 9bc8b6a573a63b8c9f5588cdea6da5ae71abd138\n--\nRegards,\n\nLaurent Pinchart", "diff": "diff --git a/src/ipa/libipa/vector.cpp b/src/ipa/libipa/vector.cpp\nindex 8019f8cfdc85..f665813c24d6 100644\n--- a/src/ipa/libipa/vector.cpp\n+++ b/src/ipa/libipa/vector.cpp\n@@ -312,6 +312,16 @@ namespace ipa {\n * \\return Product of matrix \\a m and vector \\a v\n */\n\n+/**\n+ * \\fn Vector<T, Rows> operator/(T scalar, const Vector<T, Rows> &vector)\n+ * \\brief Divide a scalar by a vector element-wise\n+ * \\tparam T Numerical type of the contents of the vector\n+ * \\tparam Rows The number of rows in the vector\n+ * \\param scalar The scalar\n+ * \\param vector The vector\n+ * \\return The element-wise division of \\a scaler by the \\a vector\n+ */\n+\n /**\n * \\typedef RGB\n * \\brief A Vector of 3 elements representing an RGB pixel value\ndiff --git a/src/ipa/libipa/vector.h b/src/ipa/libipa/vector.h\nindex fe33c9d6fbd1..25882616ba8a 100644\n--- a/src/ipa/libipa/vector.h\n+++ b/src/ipa/libipa/vector.h\n@@ -308,6 +308,17 @@ Vector<T, Rows> operator*(const Matrix<T, Rows, Cols> &m, const Vector<T, Cols>\n \treturn result;\n }\n\n+template<typename T, unsigned int Rows>\n+Vector<T, Rows> operator/(T scalar, const Vector<T, Rows> &vector)\n+{\n+\tVector<T, Rows> result;\n+\n+\tfor (unsigned int i = 0; i < Rows; i++)\n+\t\tresult[i] = scalar / vector[i];\n+\n+\treturn result;\n+}\n+\n template<typename T, unsigned int Rows>\n bool operator==(const Vector<T, Rows> &lhs, const Vector<T, Rows> &rhs)\n {\ndiff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\nindex cffaa06a22c1..319f7e0b5ef2 100644\n--- a/src/ipa/rkisp1/algorithms/awb.cpp\n+++ b/src/ipa/rkisp1/algorithms/awb.cpp\n@@ -316,11 +316,7 @@ void Awb::process(IPAContext &context,\n \t * gain is hardcoded to 1.0. Avoid divisions by zero by clamping the\n \t * divisor to a minimum value of 1.0.\n \t */\n-\tRGB<double> gains({\n-\t\trgbMeans.g() / std::max(rgbMeans.r(), 1.0),\n-\t\t1.0,\n-\t\trgbMeans.g() / std::max(rgbMeans.b(), 1.0)\n-\t});\n+\tRGB<double> gains = rgbMeans.g() / rgbMeans.max(1.0);\n\n \t/*\n \t * Clamp the gain values to the hardware, which expresses gains as Q2.8\n", "prefixes": [] }