[{"id":36335,"web_url":"https://patchwork.libcamera.org/comment/36335/","msgid":"<988deb05-0500-4c92-be1d-44fb4e303fb2@linaro.org>","date":"2025-10-17T16:24:25","subject":"Re: [PATCH] libcamera: software_isp: Apply CCM swap also on green","submitter":{"id":175,"url":"https://patchwork.libcamera.org/api/people/175/","name":"Bryan O'Donoghue","email":"bryan.odonoghue@linaro.org"},"content":"On 17/10/2025 16:44, Milan Zamazal wrote:\n> When CPU ISP is asked to apply the CCM matrix\n> \n>    [0 1 0]\n>    [0 0 0]\n>    [0 0 0]\n> \n> for a format that requires swapping red and blue channels, the resulting\n> image has a wrong colour.  The CCM matrix above should take green from\n> pixels and make it red.  Instead, the image is blue.\n> \n> The problem is that the lookup tables setup in CPU debayering swaps red\n> and blue in the lookup tables for red and blue, but not for green.  The\n> colours must be swapped also in the lookup table for green, which this\n> patch adds.\n> \n> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>\n> ---\n>   src/libcamera/software_isp/debayer_cpu.cpp | 1 +\n>   1 file changed, 1 insertion(+)\n> \n> diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp\n> index c2fb11bae..67a303c65 100644\n> --- a/src/libcamera/software_isp/debayer_cpu.cpp\n> +++ b/src/libcamera/software_isp/debayer_cpu.cpp\n> @@ -803,6 +803,7 @@ void DebayerCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output\n>   \t\tblueCcm_ = params.redCcm;\n>   \t\tfor (unsigned int i = 0; i < 256; i++) {\n>   \t\t\tstd::swap(redCcm_[i].r, redCcm_[i].b);\n> +\t\t\tstd::swap(greenCcm_[i].r, greenCcm_[i].b);\n>   \t\t\tstd::swap(blueCcm_[i].r, blueCcm_[i].b);\n>   \t\t}\n>   \t} else {\n> --\n> 2.51.0\n> \nReviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>","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 0C08ABE080\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 17 Oct 2025 16:24:31 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6D5E9606BD;\n\tFri, 17 Oct 2025 18:24:30 +0200 (CEST)","from mail-wm1-x329.google.com (mail-wm1-x329.google.com\n\t[IPv6:2a00:1450:4864:20::329])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 34022606B4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 17 Oct 2025 18:24:28 +0200 (CEST)","by mail-wm1-x329.google.com with SMTP id\n\t5b1f17b1804b1-46b303f7469so16348435e9.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 17 Oct 2025 09:24:28 -0700 (PDT)","from [192.168.0.19] (188-141-3-146.dynamic.upc.ie. [188.141.3.146])\n\tby smtp.gmail.com with ESMTPSA id\n\tffacd0b85a97d-427f00ce08asm10300f8f.44.2025.10.17.09.24.26\n\t(version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n\tFri, 17 Oct 2025 09:24:27 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=linaro.org header.i=@linaro.org\n\theader.b=\"I5RzaoFV\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=linaro.org; s=google; t=1760718268; x=1761323068;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:in-reply-to:content-language:from\n\t:references:to:subject:user-agent:mime-version:date:message-id:from\n\t:to:cc:subject:date:message-id:reply-to;\n\tbh=o7qdwsnkxmwXiEuAuoZYt+GHXUz/ZuBgVnnH6FpiFgA=;\n\tb=I5RzaoFVMm4FX6uZ3gFsQyX5r/rp0XFY6bGwCcIS/egGrlIiHcJ+XNT5nNzmwOJgQm\n\tnkHXCc8Uru9wgVolo7jjXmqBrwrzbXrogsZsLIPQVGlDawlQLPvx0dyDb46MWUd8ay59\n\tUBOYOWgnwuH5n6m8sl2VslW+T0RQyruJVtBbpYS1AmJroIH66kKxyHqkjnvzR7RG8BqB\n\t+93nm0rmZVnpAe2Xpc1/fFjMfyxzeVyevoJaBPL8k/G+IMSIbbzNhIWxCF8u6UgggKMS\n\t5lLoR/icDVFoIRCO7rS+bFBya9KEQN8Ob8IqwdwAWLZGX/4Ih9pNjb6bgxZvwcVu2FXD\n\tdIKg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1760718268; x=1761323068;\n\th=content-transfer-encoding:in-reply-to:content-language:from\n\t:references:to:subject:user-agent:mime-version:date:message-id\n\t:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;\n\tbh=o7qdwsnkxmwXiEuAuoZYt+GHXUz/ZuBgVnnH6FpiFgA=;\n\tb=s5ngyeskmpTw6v76OzYriyDwkIN1Y707HXDo5PWWMhUDBQgWvYSX22VBUsBgnS9hos\n\tki+6e4Apk+TRuFPmkM5aLSGkpJQHgDmvNK42xHFICFPEZWm2aGO97Rm3H6cBCAmkp4Mo\n\tEehu0Rj2cxh24KZAu2iHS2spCK/cYgqEnMQAa3emHPWNSPWdagblZ8KZBGEwbHk2C3pA\n\t9hqByC7wFxu7zSXewugjKwQGYO7fzt9fj03ftbNIDX++ekKzTOoQO6nnp19rZaRby2YJ\n\tvtoDq2JX/fbyZvrMBLZvLLa+agQAgvdD6RsSYFRphGQPHJO8Tlc9gCfj1QeT29aD1mki\n\tR6aA==","X-Forwarded-Encrypted":"i=1;\n\tAJvYcCVshYF3KTptIXjK4yMYmMTXpZ8oSZbEjKySPoiqZ+ic9FIRmUAL5i4IcWiWtJ7U2XA6VXuZ0DeMfHIk8EE2tNs=@lists.libcamera.org","X-Gm-Message-State":"AOJu0YxhTuq6aIl4niPwJvPeEVPqWEU/TrrcS3GAm8pWZDy+KBMAvFFH\n\tM03ZqxHo7VdBvZfjCPXZe9G3Rw7exK7JhPutg7dzi+GZPPE8csySDBKYvw/uGdEwSkU=","X-Gm-Gg":"ASbGncu+xkKdWHRsmm7ofp8kZ3USbm/8daPVcd3sWuP3zHodRjVJTjgAY7G1I8olvC2\n\tchSkTvrx7FtZ9sPtfCjgzO5lr7tCHJFKIPxim/gL30h2YHXXUtXQz4kOZ4/rfV4ZpD61T0OlU8O\n\tDu2CtkQvNDNSRjW1BvPHqXTaeZxHikYkIciuMybXSD4cmGXSGz/BBPQRjdAQr8q8k09L5s65Rgx\n\tjebvQUfuk7//P4wF8NCsKLPbA2dmW+pyiULpraXrzJBJbYA9Tf0Ag0tMYT8QdegM3+iHKUmSb1i\n\tPcwOPHJBJWAVoDHeMVIXQ6t+Nejqz9U7CVHv+c2DdrKiYkAs5FgwygvxN8hT1HNAoC+qHYSBmXW\n\tEYa/tOX5VN6IAtUcuVQ889fBFCkLsnrGy9ZhBDr4WOjv7c/KmcbejBPb2PAH2IT9rCHFZ8YvS4/\n\ty4YX4HRXTO3TGq0Ixqce6taq45k+DFr01ldNukes47WA==","X-Google-Smtp-Source":"AGHT+IG8vOvLJzqqH+KplNBi7kumYjdtyEWkRTFgqJcfrenAKKcXDIW7SN2PUN5l5gK1SCXh8g9ulA==","X-Received":"by 2002:a05:6000:2c0b:b0:427:84a:6db6 with SMTP id\n\tffacd0b85a97d-427084a6fe3mr1842290f8f.51.1760718267554; \n\tFri, 17 Oct 2025 09:24:27 -0700 (PDT)","Message-ID":"<988deb05-0500-4c92-be1d-44fb4e303fb2@linaro.org>","Date":"Fri, 17 Oct 2025 17:24:25 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH] libcamera: software_isp: Apply CCM swap also on green","To":"Milan Zamazal <mzamazal@redhat.com>, libcamera-devel@lists.libcamera.org","References":"<VK2uBizhcA9XMmnsOE3GZAJuK9bVYAEee5JJVy5vlo5mi-G1G47fDB-7EIb1lyqzl-1jpqDaD1tARkeemxKorw==@protonmail.internalid>\n\t<20251017154412.41430-1-mzamazal@redhat.com>","From":"Bryan O'Donoghue <bryan.odonoghue@linaro.org>","Content-Language":"en-US","In-Reply-To":"<20251017154412.41430-1-mzamazal@redhat.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","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>"}},{"id":36342,"web_url":"https://patchwork.libcamera.org/comment/36342/","msgid":"<176078590000.1203891.7693140801750147006@ping.linuxembedded.co.uk>","date":"2025-10-18T11:11:40","subject":"Re: [PATCH] libcamera: software_isp: Apply CCM swap also on green","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Milan Zamazal (2025-10-17 16:44:12)\n> When CPU ISP is asked to apply the CCM matrix\n> \n>   [0 1 0]\n>   [0 0 0]\n>   [0 0 0]\n> \n> for a format that requires swapping red and blue channels, the resulting\n> image has a wrong colour.  The CCM matrix above should take green from\n> pixels and make it red.  Instead, the image is blue.\n> \n> The problem is that the lookup tables setup in CPU debayering swaps red\n> and blue in the lookup tables for red and blue, but not for green.  The\n> colours must be swapped also in the lookup table for green, which this\n> patch adds.\n> \n> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>\n> ---\n>  src/libcamera/software_isp/debayer_cpu.cpp | 1 +\n>  1 file changed, 1 insertion(+)\n> \n> diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp\n> index c2fb11bae..67a303c65 100644\n> --- a/src/libcamera/software_isp/debayer_cpu.cpp\n> +++ b/src/libcamera/software_isp/debayer_cpu.cpp\n> @@ -803,6 +803,7 @@ void DebayerCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output\n>                 blueCcm_ = params.redCcm;\n>                 for (unsigned int i = 0; i < 256; i++) {\n>                         std::swap(redCcm_[i].r, redCcm_[i].b);\n> +                       std::swap(greenCcm_[i].r, greenCcm_[i].b);\n>                         std::swap(blueCcm_[i].r, blueCcm_[i].b);\n\nI haven't looked at the full context surrounding this - but it seems\nreasonable - and it sounds like this fixes an issue for you in the\nSoftISP too.\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n>                 }\n>         } else {\n> -- \n> 2.51.0\n>","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 1321DBE080\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 18 Oct 2025 11:11:46 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 58A0B606DA;\n\tSat, 18 Oct 2025 13:11:45 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8816D606CF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 18 Oct 2025 13:11:43 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 40F94192C;\n\tSat, 18 Oct 2025 13:10:02 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"G6LUEs99\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1760785802;\n\tbh=0fdIlBAs2kox0+P0S9G6z/ZCClCLRtibIXghloxpuFw=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=G6LUEs99fuGyh/We9XquTLFU1rF9RrAw8EbmZ3IylhdXxMqk5jzsi54hCve1+hw/Q\n\tr6/xAytD5fuxDr2FJOKLlA6C7N/wxmaJ90jDRR5t3bGDkX0mXFARAwQ7XPRuEG08gP\n\tECbfg92PFUav9MCbmYCBBc8KmEedJeaig571SUQU=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20251017154412.41430-1-mzamazal@redhat.com>","References":"<20251017154412.41430-1-mzamazal@redhat.com>","Subject":"Re: [PATCH] libcamera: software_isp: Apply CCM swap also on green","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Milan Zamazal <mzamazal@redhat.com>","To":"Milan Zamazal <mzamazal@redhat.com>, libcamera-devel@lists.libcamera.org","Date":"Sat, 18 Oct 2025 12:11:40 +0100","Message-ID":"<176078590000.1203891.7693140801750147006@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","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>"}}]