From patchwork Thu Jan 30 18:14:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 22699 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 E7D72BD808 for ; Thu, 30 Jan 2025 18:15:14 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 246CC68567; Thu, 30 Jan 2025 19:15:14 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="isXUIdoB"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7B7B668563 for ; Thu, 30 Jan 2025 19:15:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738260910; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ceQPRgUK6ICSDIECjjI2lTGnIS5aYCLRU6Jdnw239fc=; b=isXUIdoB6CeWKqDhAgOZDKYtQMpd8ateol0rDA9Kq89OWV7NIpwz7rV64kjJ4c0tDYyc4+ YPivQM8eEJVDrhyPs2ysJHo0gM2Pb4Bm+jkUJNgz5aSFMpHDQbgeiEH3pvnG6fhbIP5yFC RTaf9od8ovs+RNSuuYydXb8lPnmrwwg= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-245-XJmq8yx-N3q9WIlVhTlrlA-1; Thu, 30 Jan 2025 13:15:09 -0500 X-MC-Unique: XJmq8yx-N3q9WIlVhTlrlA-1 X-Mimecast-MFC-AGG-ID: XJmq8yx-N3q9WIlVhTlrlA Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 101101955F36; Thu, 30 Jan 2025 18:15:08 +0000 (UTC) Received: from mzamazal-thinkpadp1gen3.tpbc.com (unknown [10.45.224.122]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C755830001BE; Thu, 30 Jan 2025 18:15:05 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal , Robert Mader , Hans de Goede , Laurent Pinchart , Kieran Bingham Subject: [PATCH v5 02/10] libcamera: software_isp: Use RGB type to represent gains Date: Thu, 30 Jan 2025 19:14:39 +0100 Message-ID: <20250130181449.130492-3-mzamazal@redhat.com> In-Reply-To: <20250130181449.130492-1-mzamazal@redhat.com> References: <20250130181449.130492-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: CyIuelf57qydP2Xc5_zVpQnHrvdfCwdVYYasC1OpP6Y_1738260908 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true 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" Rather than using a custom struct to represent RGB values, let's use the corresponding type. Signed-off-by: Milan Zamazal Reviewed-by: Laurent Pinchart --- src/ipa/simple/algorithms/awb.cpp | 14 ++++++++------ src/ipa/simple/algorithms/lut.cpp | 6 +++--- src/ipa/simple/ipa_context.h | 7 ++----- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/ipa/simple/algorithms/awb.cpp b/src/ipa/simple/algorithms/awb.cpp index 1efc7090..9c85b3f8 100644 --- a/src/ipa/simple/algorithms/awb.cpp +++ b/src/ipa/simple/algorithms/awb.cpp @@ -25,7 +25,7 @@ int Awb::configure(IPAContext &context, [[maybe_unused]] const IPAConfigInfo &configInfo) { auto &gains = context.activeState.awb.gains; - gains.red = gains.green = gains.blue = 1.0; + gains = { { 1.0, 1.0, 1.0 } }; return 0; } @@ -56,15 +56,17 @@ void Awb::process(IPAContext &context, * Clamp max gain at 4.0, this also avoids 0 division. */ auto &gains = context.activeState.awb.gains; - gains.red = sumR <= sumG / 4 ? 4.0 : static_cast(sumG) / sumR; - gains.blue = sumB <= sumG / 4 ? 4.0 : static_cast(sumG) / sumB; - /* Green gain is fixed to 1.0 */ + gains = { { + sumR <= sumG / 4 ? 4.0 : static_cast(sumG) / sumR, + 1.0, + sumB <= sumG / 4 ? 4.0 : static_cast(sumG) / sumB, + } }; - RGB rgbGains{ { 1 / gains.red, 1 / gains.green, 1 / gains.blue } }; + RGB rgbGains{ { 1 / gains.r(), 1 / gains.g(), 1 / gains.b() } }; context.activeState.awb.temperatureK = estimateCCT(rgbGains); LOG(IPASoftAwb, Debug) - << "gain R/B: " << gains.red << "/" << gains.blue + << "gain R/B: " << gains.r() << "/" << gains.b() << "; temperature: " << context.activeState.awb.temperatureK; } diff --git a/src/ipa/simple/algorithms/lut.cpp b/src/ipa/simple/algorithms/lut.cpp index d75ff710..bd37a955 100644 --- a/src/ipa/simple/algorithms/lut.cpp +++ b/src/ipa/simple/algorithms/lut.cpp @@ -104,13 +104,13 @@ void Lut::prepare(IPAContext &context, gammaTableSize; /* Apply gamma after gain! */ unsigned int idx; - idx = std::min({ static_cast(i * gains.red / div), + idx = std::min({ static_cast(i * gains.r() / div), gammaTableSize - 1 }); params->red[i] = gammaTable[idx]; - idx = std::min({ static_cast(i * gains.green / div), + idx = std::min({ static_cast(i * gains.g() / div), gammaTableSize - 1 }); params->green[i] = gammaTable[idx]; - idx = std::min({ static_cast(i * gains.blue / div), + idx = std::min({ static_cast(i * gains.b() / div), gammaTableSize - 1 }); params->blue[i] = gammaTable[idx]; } diff --git a/src/ipa/simple/ipa_context.h b/src/ipa/simple/ipa_context.h index 607af45a..df0552db 100644 --- a/src/ipa/simple/ipa_context.h +++ b/src/ipa/simple/ipa_context.h @@ -14,6 +14,7 @@ #include #include +#include namespace libcamera { @@ -36,11 +37,7 @@ struct IPAActiveState { } blc; struct { - struct { - double red; - double green; - double blue; - } gains; + RGB gains; unsigned int temperatureK; } awb;