From patchwork Tue Nov 19 10:37:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 21989 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 4292AC326B for ; Tue, 19 Nov 2024 10:37:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DB95365EF6; Tue, 19 Nov 2024 11:37:49 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="wRkOH51w"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EDC8265EEB for ; Tue, 19 Nov 2024 11:37:47 +0100 (CET) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:bf40:cdab:103d:2270]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A5C70641; Tue, 19 Nov 2024 11:37:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1732012650; bh=9nWoK2660pxA3G59PHoi5Nhr1CLLES81bM6EpEgxTK0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wRkOH51wHn8/715CJjB4hQH8mMvdZuYHtDlw0fUSo7y6HZzJceZEAW69xgEyCo5aI QqM8W4veNZmBZFiuPQlkGxgBLT1csdGe9CplArAJqvb5Uzyxb76tZu6ZlYkK26+QtU oCs+trx2ws/19T7d9pYzQv4ZdM6R90NpITsAhNVQ= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v2 1/9] ipa: rpi: Rename Matrix to Matrix3x3 Date: Tue, 19 Nov 2024 11:37:28 +0100 Message-ID: <20241119103740.1919807-2-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241119103740.1919807-1-stefan.klug@ideasonboard.com> References: <20241119103740.1919807-1-stefan.klug@ideasonboard.com> 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" The upcoming patches will introduce a Matrix class into libcamera/internal. That name clashes with the Matrix class from the RaspeberryPi ccm implementation. Rename the rpi version to Matrix3x3 to prevent the name clash. Matrix3x3 will be replaced by the generic implementation later. Signed-off-by: Stefan Klug Reviewed-by: Laurent Pinchart --- src/ipa/rpi/controller/rpi/ccm.cpp | 18 +++++++++--------- src/ipa/rpi/controller/rpi/ccm.h | 20 ++++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/ipa/rpi/controller/rpi/ccm.cpp b/src/ipa/rpi/controller/rpi/ccm.cpp index aefa580c9a4b..7f63f3fdb702 100644 --- a/src/ipa/rpi/controller/rpi/ccm.cpp +++ b/src/ipa/rpi/controller/rpi/ccm.cpp @@ -29,17 +29,17 @@ LOG_DEFINE_CATEGORY(RPiCcm) #define NAME "rpi.ccm" -Matrix::Matrix() +Matrix3x3::Matrix3x3() { memset(m, 0, sizeof(m)); } -Matrix::Matrix(double m0, double m1, double m2, double m3, double m4, double m5, +Matrix3x3::Matrix3x3(double m0, double m1, double m2, double m3, double m4, double m5, double m6, double m7, double m8) { m[0][0] = m0, m[0][1] = m1, m[0][2] = m2, m[1][0] = m3, m[1][1] = m4, m[1][2] = m5, m[2][0] = m6, m[2][1] = m7, m[2][2] = m8; } -int Matrix::read(const libcamera::YamlObject ¶ms) +int Matrix3x3::read(const libcamera::YamlObject ¶ms) { double *ptr = (double *)m; @@ -125,7 +125,7 @@ bool getLocked(Metadata *metadata, std::string const &tag, T &value) return true; } -Matrix calculateCcm(std::vector const &ccms, double ct) +Matrix3x3 calculateCcm(std::vector const &ccms, double ct) { if (ct <= ccms.front().ct) return ccms.front().ccm; @@ -141,13 +141,13 @@ Matrix calculateCcm(std::vector const &ccms, double ct) } } -Matrix applySaturation(Matrix const &ccm, double saturation) +Matrix3x3 applySaturation(Matrix3x3 const &ccm, double saturation) { - Matrix RGB2Y(0.299, 0.587, 0.114, -0.169, -0.331, 0.500, 0.500, -0.419, + Matrix3x3 RGB2Y(0.299, 0.587, 0.114, -0.169, -0.331, 0.500, 0.500, -0.419, -0.081); - Matrix Y2RGB(1.000, 0.000, 1.402, 1.000, -0.345, -0.714, 1.000, 1.771, + Matrix3x3 Y2RGB(1.000, 0.000, 1.402, 1.000, -0.345, -0.714, 1.000, 1.771, 0.000); - Matrix S(1, 0, 0, 0, saturation, 0, 0, 0, saturation); + Matrix3x3 S(1, 0, 0, 0, saturation, 0, 0, 0, saturation); return Y2RGB * S * RGB2Y * ccm; } @@ -170,7 +170,7 @@ void Ccm::prepare(Metadata *imageMetadata) LOG(RPiCcm, Warning) << "no colour temperature found"; if (!luxOk) LOG(RPiCcm, Warning) << "no lux value found"; - Matrix ccm = calculateCcm(config_.ccms, awb.temperatureK); + Matrix3x3 ccm = calculateCcm(config_.ccms, awb.temperatureK); double saturation = saturation_; struct CcmStatus ccmStatus; ccmStatus.saturation = saturation; diff --git a/src/ipa/rpi/controller/rpi/ccm.h b/src/ipa/rpi/controller/rpi/ccm.h index 4e5b33fefa4e..8e7f9616c2ab 100644 --- a/src/ipa/rpi/controller/rpi/ccm.h +++ b/src/ipa/rpi/controller/rpi/ccm.h @@ -16,22 +16,22 @@ namespace RPiController { /* Algorithm to calculate colour matrix. Should be placed after AWB. */ -struct Matrix { - Matrix(double m0, double m1, double m2, double m3, double m4, double m5, +struct Matrix3x3 { + Matrix3x3(double m0, double m1, double m2, double m3, double m4, double m5, double m6, double m7, double m8); - Matrix(); + Matrix3x3(); double m[3][3]; int read(const libcamera::YamlObject ¶ms); }; -static inline Matrix operator*(double d, Matrix const &m) +static inline Matrix3x3 operator*(double d, Matrix3x3 const &m) { - return Matrix(m.m[0][0] * d, m.m[0][1] * d, m.m[0][2] * d, + return Matrix3x3(m.m[0][0] * d, m.m[0][1] * d, m.m[0][2] * d, m.m[1][0] * d, m.m[1][1] * d, m.m[1][2] * d, m.m[2][0] * d, m.m[2][1] * d, m.m[2][2] * d); } -static inline Matrix operator*(Matrix const &m1, Matrix const &m2) +static inline Matrix3x3 operator*(Matrix3x3 const &m1, Matrix3x3 const &m2) { - Matrix m; + Matrix3x3 m; for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) m.m[i][j] = m1.m[i][0] * m2.m[0][j] + @@ -39,9 +39,9 @@ static inline Matrix operator*(Matrix const &m1, Matrix const &m2) m1.m[i][2] * m2.m[2][j]; return m; } -static inline Matrix operator+(Matrix const &m1, Matrix const &m2) +static inline Matrix3x3 operator+(Matrix3x3 const &m1, Matrix3x3 const &m2) { - Matrix m; + Matrix3x3 m; for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) m.m[i][j] = m1.m[i][j] + m2.m[i][j]; @@ -50,7 +50,7 @@ static inline Matrix operator+(Matrix const &m1, Matrix const &m2) struct CtCcm { double ct; - Matrix ccm; + Matrix3x3 ccm; }; struct CcmConfig {