From patchwork Fri Oct 17 15:44:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 24703 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 A87A5C3259 for ; Fri, 17 Oct 2025 15:44:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A5C5A606CD; Fri, 17 Oct 2025 17:44:24 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="LzvYrbkE"; 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 17AF1606B2 for ; Fri, 17 Oct 2025 17:44:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760715860; 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=NAGMMrq8fYXVMiA0fQOwHuXILdPRnvAZ68a+RO/iZxo=; b=LzvYrbkETGQykMeJRA+Sw8EH3rrP085hZOUpR3exhyV6ldHwGOLAhs5Bc/J7Ld6Tgw+0Bi eHWO4st/xrFsMCS61DmMfY0WgXhEcmyAxNvNaEdUcXHvdcKu8oil8OP5RAQ0snmLK69RH5 q7LRDPIl3JUVsdXmgY0LVBTOFCuepNg= Received: from mx-prod-mc-01.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-37-uy8C7I27PwOgUxFTeGyRQw-1; Fri, 17 Oct 2025 11:44:18 -0400 X-MC-Unique: uy8C7I27PwOgUxFTeGyRQw-1 X-Mimecast-MFC-AGG-ID: uy8C7I27PwOgUxFTeGyRQw_1760715857 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9700F1956094 for ; Fri, 17 Oct 2025 15:44:17 +0000 (UTC) Received: from mzamazal-thinkpadp1gen7.tpbc.com (unknown [10.45.224.66]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6F5291956056; Fri, 17 Oct 2025 15:44:16 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal Subject: [PATCH] libcamera: software_isp: Apply CCM swap also on green Date: Fri, 17 Oct 2025 17:44:12 +0200 Message-ID: <20251017154412.41430-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: C7_bBpeCAX1qIZGhCqh1lQB3mD3w76xFxnzInCYyIkE_1760715857 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" When CPU ISP is asked to apply the CCM matrix [0 1 0] [0 0 0] [0 0 0] for a format that requires swapping red and blue channels, the resulting image has a wrong colour. The CCM matrix above should take green from pixels and make it red. Instead, the image is blue. The problem is that the lookup tables setup in CPU debayering swaps red and blue in the lookup tables for red and blue, but not for green. The colours must be swapped also in the lookup table for green, which this patch adds. Signed-off-by: Milan Zamazal Reviewed-by: Bryan O'Donoghue Reviewed-by: Kieran Bingham --- src/libcamera/software_isp/debayer_cpu.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp index c2fb11bae..67a303c65 100644 --- a/src/libcamera/software_isp/debayer_cpu.cpp +++ b/src/libcamera/software_isp/debayer_cpu.cpp @@ -803,6 +803,7 @@ void DebayerCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output blueCcm_ = params.redCcm; for (unsigned int i = 0; i < 256; i++) { std::swap(redCcm_[i].r, redCcm_[i].b); + std::swap(greenCcm_[i].r, greenCcm_[i].b); std::swap(blueCcm_[i].r, blueCcm_[i].b); } } else {