From patchwork Mon Apr 14 17:32:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 23180 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 EC94AC327D for ; Mon, 14 Apr 2025 17:32:55 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 26EC968AB9; Mon, 14 Apr 2025 19:32:55 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="XMgDcDiB"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0B636627F2 for ; Mon, 14 Apr 2025 19:32:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1744651973; 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; bh=D9hbbTOfLbfQHO8mHsAfvr3LxAd9DRMh4zvTL/TeDzM=; b=XMgDcDiBk9c/VDPWIJTv9TfNGj0E8ao6lpbgiUZIhbUBNKUXtvKOVJuzchc6UzxNvKeLUb LUMSMkU2fhH2+hvGs96Dqc6Q7VMTmHHObodANfFZ6tGNb2nQnnetxfkm2v/0uJJqo3dc+h J9rePnDMYmSJMj+dHh+2IK5jt5eFDUI= Received: from mx-prod-mc-04.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-488-50glIWCBMKG0CDcceKrIUQ-1; Mon, 14 Apr 2025 13:32:51 -0400 X-MC-Unique: 50glIWCBMKG0CDcceKrIUQ-1 X-Mimecast-MFC-AGG-ID: 50glIWCBMKG0CDcceKrIUQ_1744651969 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 98B901956048; Mon, 14 Apr 2025 17:32:49 +0000 (UTC) Received: from mzamazal-thinkpadp1gen7.tpbc.com (unknown [10.44.32.41]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 17D4F1801A6D; Mon, 14 Apr 2025 17:32:47 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal , Kieran Bingham Subject: [PATCH] libcamera: software_isp: Fix CCM multiplication Date: Mon, 14 Apr 2025 19:32:44 +0200 Message-ID: <20250414173244.118560-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: HetPHZAtF5TBcDFWupPy7l2PzeCmblCLUtBChm3wW3w_1744651969 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" A colour correction matrix (CCM) is applied like this to an RGB pixel vector P: CCM * P White balance must be applied before CCM. If CCM is used, software ISP makes a combined matrix by multiplying the CCM by a white balance gains CCM-like matrix (WBG). The multiplication should be as follows to do it in the correct order: CCM * (WBG * P) = (CCM * WBG) * P The multiplication order in Lut software ISP algorithm is reversed, resulting in colour casts. Let's fix the order. Signed-off-by: Milan Zamazal Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham Tested-by: Kieran Bingham --- src/ipa/simple/algorithms/lut.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ipa/simple/algorithms/lut.cpp b/src/ipa/simple/algorithms/lut.cpp index e8638f27..d1d5f727 100644 --- a/src/ipa/simple/algorithms/lut.cpp +++ b/src/ipa/simple/algorithms/lut.cpp @@ -122,7 +122,7 @@ void Lut::prepare(IPAContext &context, Matrix gainCcm = { { gains.r(), 0, 0, 0, gains.g(), 0, 0, 0, gains.b() } }; - auto ccm = gainCcm * context.activeState.ccm.ccm; + auto ccm = context.activeState.ccm.ccm * gainCcm; auto &red = params->redCcm; auto &green = params->greenCcm; auto &blue = params->blueCcm;