From patchwork Mon Aug 26 15:22:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 21012 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 00B8FC324C for ; Mon, 26 Aug 2024 15:22:37 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 43CB5633CF; Mon, 26 Aug 2024 17:22:37 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="gMpvL65Z"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 479CB633D3 for ; Mon, 26 Aug 2024 17:22:34 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:58b7:f3d:c9d4:defa]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 04092741; Mon, 26 Aug 2024 17:21:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1724685688; bh=gGbKCUnL0zdjVvdtW3FyYzk6c9CQehRnjgwIVoMvyuM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gMpvL65Z/pjq3XXSNHYQIfhteZ9vP9IWlPvZ60UMFoIT93ToLGoUJd/4xMjmzF4xM nvXO85Ff8Nrj3a+B9KKXa3KMvhzifF2vZmbId0dVWjkLmI/LIS+mrf5v9/pu26UTe2 VThqP8r1SjzwwjIe94wvqXvvAiKPHpyP4o0TVDhQ= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v1 2/8] ipa: rkisp1: Use generic Interpolator class Date: Mon, 26 Aug 2024 17:22:00 +0200 Message-ID: <20240826152224.362773-3-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240826152224.362773-1-stefan.klug@ideasonboard.com> References: <20240826152224.362773-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" Replace all occurrences of the MatrixInterpolator with the generic one. Signed-off-by: Stefan Klug --- src/ipa/rkisp1/algorithms/awb.cpp | 4 ++-- src/ipa/rkisp1/algorithms/awb.h | 5 +++-- src/ipa/rkisp1/algorithms/ccm.cpp | 18 ++++++------------ src/ipa/rkisp1/algorithms/ccm.h | 6 +++--- 4 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp index d482eda5b541..9b181c163e0b 100644 --- a/src/ipa/rkisp1/algorithms/awb.cpp +++ b/src/ipa/rkisp1/algorithms/awb.cpp @@ -53,7 +53,7 @@ int Awb::init(IPAContext &context, const YamlObject &tuningData) kMaxColourTemperature, kDefaultColourTemperature); - MatrixInterpolator gains; + Interpolator> gains; int ret = gains.readYaml(tuningData["gains"], "ct", "gains"); if (ret < 0) LOG(RkISP1Awb, Warning) @@ -124,7 +124,7 @@ void Awb::queueRequest(IPAContext &context, const auto &colourTemperature = controls.get(controls::ColourTemperature); if (colourTemperature && !awb.autoEnabled && gains_ && !colourGains) { - Matrix gains = gains_->get(*colourTemperature); + Matrix gains = gains_->getInterpolated(*colourTemperature); awb.gains.manual.red = gains[0][0]; awb.gains.manual.blue = gains[1][0]; diff --git a/src/ipa/rkisp1/algorithms/awb.h b/src/ipa/rkisp1/algorithms/awb.h index a010e6d1cb3c..9e44f1c278ab 100644 --- a/src/ipa/rkisp1/algorithms/awb.h +++ b/src/ipa/rkisp1/algorithms/awb.h @@ -9,7 +9,8 @@ #include -#include "libipa/matrix_interpolator.h" +#include "libipa/interpolator.h" +#include "libipa/matrix.h" #include "algorithm.h" @@ -39,7 +40,7 @@ public: private: uint32_t estimateCCT(double red, double green, double blue); - std::optional> gains_; + std::optional>> gains_; bool rgbMode_; }; diff --git a/src/ipa/rkisp1/algorithms/ccm.cpp b/src/ipa/rkisp1/algorithms/ccm.cpp index fe7246f8b185..5a29d20e6cdb 100644 --- a/src/ipa/rkisp1/algorithms/ccm.cpp +++ b/src/ipa/rkisp1/algorithms/ccm.cpp @@ -23,7 +23,7 @@ #include "libcamera/internal/yaml_parser.h" #include "../utils.h" -#include "libipa/matrix_interpolator.h" +#include "libipa/interpolator.h" /** * \file ccm.h @@ -50,7 +50,7 @@ int Ccm::init([[maybe_unused]] IPAContext &context, const YamlObject &tuningData LOG(RkISP1Ccm, Warning) << "Failed to parse 'ccm' " << "parameter from tuning file; falling back to unit matrix"; - ccm_.reset(); + ccm_.setData({ { 0, Matrix::identity() } }); } ret = offsets_.readYaml(tuningData["ccms"], "ct", "offsets"); @@ -58,14 +58,8 @@ int Ccm::init([[maybe_unused]] IPAContext &context, const YamlObject &tuningData LOG(RkISP1Ccm, Warning) << "Failed to parse 'offsets' " << "parameter from tuning file; falling back to zero offsets"; - /* - * MatrixInterpolator::reset() resets to identity matrices - * while here we need zero matrices so we need to construct it - * ourselves. - */ - Matrix m({ 0, 0, 0 }); - std::map> matrices = { { 0, m } }; - offsets_ = MatrixInterpolator(matrices); + + offsets_.setData({ { 0, Matrix({ 0, 0, 0 }) } }); } return 0; @@ -117,8 +111,8 @@ void Ccm::prepare(IPAContext &context, const uint32_t frame, } ct_ = ct; - Matrix ccm = ccm_.get(ct); - Matrix offsets = offsets_.get(ct); + Matrix ccm = ccm_.getInterpolated(ct); + Matrix offsets = offsets_.getInterpolated(ct); context.activeState.ccm.ccm = ccm; frameContext.ccm.ccm = ccm; diff --git a/src/ipa/rkisp1/algorithms/ccm.h b/src/ipa/rkisp1/algorithms/ccm.h index 30cb882180cc..4efe9c00c3c9 100644 --- a/src/ipa/rkisp1/algorithms/ccm.h +++ b/src/ipa/rkisp1/algorithms/ccm.h @@ -9,8 +9,8 @@ #include +#include "libipa/interpolator.h" #include "libipa/matrix.h" -#include "libipa/matrix_interpolator.h" #include "algorithm.h" @@ -40,8 +40,8 @@ private: const Matrix &offsets); unsigned int ct_; - MatrixInterpolator ccm_; - MatrixInterpolator offsets_; + Interpolator> ccm_; + Interpolator> offsets_; }; } /* namespace ipa::rkisp1::algorithms */