{"id":23180,"url":"https://patchwork.libcamera.org/api/patches/23180/?format=json","web_url":"https://patchwork.libcamera.org/patch/23180/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20250414173244.118560-1-mzamazal@redhat.com>","date":"2025-04-14T17:32:44","name":"libcamera: software_isp: Fix CCM multiplication","commit_ref":"026ed6273969d931d38876345e01de626def8b07","pull_url":null,"state":"accepted","archived":false,"hash":"beaa399837c70dd6ffd3cfbf14a44a709e00e4ff","submitter":{"id":177,"url":"https://patchwork.libcamera.org/api/people/177/?format=json","name":"Milan Zamazal","email":"mzamazal@redhat.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/23180/mbox/","series":[{"id":5127,"url":"https://patchwork.libcamera.org/api/series/5127/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5127","date":"2025-04-14T17:32:44","name":"libcamera: software_isp: Fix CCM multiplication","version":1,"mbox":"https://patchwork.libcamera.org/series/5127/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/23180/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/23180/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id EC94AC327D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 14 Apr 2025 17:32:55 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 26EC968AB9;\n\tMon, 14 Apr 2025 19:32:55 +0200 (CEST)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.133.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0B636627F2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 14 Apr 2025 19:32:53 +0200 (CEST)","from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com\n\t(ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63])\n\tby relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n\tcipher=TLS_AES_256_GCM_SHA384) id us-mta-488-50glIWCBMKG0CDcceKrIUQ-1;\n\tMon, 14 Apr 2025 13:32:51 -0400","from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com\n\t(mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com\n\t[10.30.177.111])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\tkey-exchange X25519 server-signature RSA-PSS (2048 bits)\n\tserver-digest SHA256) (No client certificate requested)\n\tby mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTPS id 98B901956048; Mon, 14 Apr 2025 17:32:49 +0000 (UTC)","from mzamazal-thinkpadp1gen7.tpbc.com (unknown [10.44.32.41])\n\tby mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTP id 17D4F1801A6D; Mon, 14 Apr 2025 17:32:47 +0000 (UTC)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"XMgDcDiB\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1744651973;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tcontent-transfer-encoding:content-transfer-encoding;\n\tbh=D9hbbTOfLbfQHO8mHsAfvr3LxAd9DRMh4zvTL/TeDzM=;\n\tb=XMgDcDiBk9c/VDPWIJTv9TfNGj0E8ao6lpbgiUZIhbUBNKUXtvKOVJuzchc6UzxNvKeLUb\n\tLUMSMkU2fhH2+hvGs96Dqc6Q7VMTmHHObodANfFZ6tGNb2nQnnetxfkm2v/0uJJqo3dc+h\n\tJ9rePnDMYmSJMj+dHh+2IK5jt5eFDUI=","X-MC-Unique":"50glIWCBMKG0CDcceKrIUQ-1","X-Mimecast-MFC-AGG-ID":"50glIWCBMKG0CDcceKrIUQ_1744651969","From":"Milan Zamazal <mzamazal@redhat.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Milan Zamazal <mzamazal@redhat.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>","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-Transfer-Encoding":"8bit","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":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"A colour correction matrix (CCM) is applied like this to an RGB pixel\nvector P:\n\n  CCM * P\n\nWhite balance must be applied before CCM.  If CCM is used, software ISP\nmakes a combined matrix by multiplying the CCM by a white balance gains\nCCM-like matrix (WBG).  The multiplication should be as follows to do it\nin the correct order:\n\n  CCM * (WBG * P) = (CCM * WBG) * P\n\nThe multiplication order in Lut software ISP algorithm is reversed,\nresulting in colour casts.  Let's fix the order.\n\nSigned-off-by: Milan Zamazal <mzamazal@redhat.com>\n---\n src/ipa/simple/algorithms/lut.cpp | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)","diff":"diff --git a/src/ipa/simple/algorithms/lut.cpp b/src/ipa/simple/algorithms/lut.cpp\nindex e8638f27..d1d5f727 100644\n--- a/src/ipa/simple/algorithms/lut.cpp\n+++ b/src/ipa/simple/algorithms/lut.cpp\n@@ -122,7 +122,7 @@ void Lut::prepare(IPAContext &context,\n \t\tMatrix<float, 3, 3> gainCcm = { { gains.r(), 0, 0,\n \t\t\t\t\t\t  0, gains.g(), 0,\n \t\t\t\t\t\t  0, 0, gains.b() } };\n-\t\tauto ccm = gainCcm * context.activeState.ccm.ccm;\n+\t\tauto ccm = context.activeState.ccm.ccm * gainCcm;\n \t\tauto &red = params->redCcm;\n \t\tauto &green = params->greenCcm;\n \t\tauto &blue = params->blueCcm;\n","prefixes":[]}