From patchwork Thu Oct 31 16:07:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Scally X-Patchwork-Id: 21793 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 9BDF7C330B for ; Thu, 31 Oct 2024 16:08:26 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5D0D6653B6; Thu, 31 Oct 2024 17:08:23 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="wVr+K0+G"; 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 277BD653A1 for ; Thu, 31 Oct 2024 17:08:13 +0100 (CET) Received: from mail.ideasonboard.com (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net [86.13.91.161]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1B3E21014; Thu, 31 Oct 2024 17:08:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1730390889; bh=f8uOKekUrzhwjcGWvj4o7L4uQ0ayFCkha2W3VJgG6Eg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wVr+K0+GU/7kpJfqHymZ1sc2rFhIWZpMcaryS4uHEPZF3+ZuisrSS8GY6y5LCYY6m 0IWJxHCDjQwSnLFK/+NdUUp91PuMQ7ynWm3S1PnaksQeKHAk6EatE8MjlKe/98TY+F KyL9BUuZL5DCtZp1wDHSr1EZovVESs9sNL3mIMME= From: Daniel Scally To: libcamera-devel@lists.libcamera.org Cc: mike.rudenko@gmail.com, Daniel Scally Subject: [PATCH 3/6] ipa: rkisp1: Use centralised libipa helpers Date: Thu, 31 Oct 2024 16:07:38 +0000 Message-Id: <20241031160741.253855-4-dan.scally@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031160741.253855-1-dan.scally@ideasonboard.com> References: <20241031160741.253855-1-dan.scally@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" Use the centralised libipa helpers instead of open-coding common functions. Signed-off-by: Daniel Scally Reviewed-by: Jacopo Mondi --- src/ipa/rkisp1/algorithms/awb.cpp | 20 +++----------------- src/ipa/rkisp1/algorithms/awb.h | 2 -- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp index b3c00bef..623c4eb2 100644 --- a/src/ipa/rkisp1/algorithms/awb.cpp +++ b/src/ipa/rkisp1/algorithms/awb.cpp @@ -16,6 +16,8 @@ #include +#include "libipa/helpers.h" + /** * \file awb.h */ @@ -178,22 +180,6 @@ void Awb::prepare(IPAContext &context, const uint32_t frame, } } -uint32_t Awb::estimateCCT(double red, double green, double blue) -{ - /* Convert the RGB values to CIE tristimulus values (XYZ) */ - double X = (-0.14282) * (red) + (1.54924) * (green) + (-0.95641) * (blue); - double Y = (-0.32466) * (red) + (1.57837) * (green) + (-0.73191) * (blue); - double Z = (-0.68202) * (red) + (0.77073) * (green) + (0.56332) * (blue); - - /* Calculate the normalized chromaticity values */ - double x = X / (X + Y + Z); - double y = Y / (X + Y + Z); - - /* Calculate CCT */ - double n = (x - 0.3320) / (0.1858 - y); - return 449 * n * n * n + 3525 * n * n + 6823.3 * n + 5520.33; -} - /** * \copydoc libcamera::ipa::Algorithm::process */ @@ -279,7 +265,7 @@ void Awb::process(IPAContext &context, blueMean < kMeanMinThreshold) return; - activeState.awb.temperatureK = estimateCCT(redMean, greenMean, blueMean); + activeState.awb.temperatureK = ipa::estimateCCT(redMean, greenMean, blueMean); /* Metadata shall contain the up to date measurement */ metadata.set(controls::ColourTemperature, activeState.awb.temperatureK); diff --git a/src/ipa/rkisp1/algorithms/awb.h b/src/ipa/rkisp1/algorithms/awb.h index b3b2c0bb..6ac3a5c3 100644 --- a/src/ipa/rkisp1/algorithms/awb.h +++ b/src/ipa/rkisp1/algorithms/awb.h @@ -32,8 +32,6 @@ public: ControlList &metadata) override; private: - uint32_t estimateCCT(double red, double green, double blue); - bool rgbMode_; };