Patch Detail
Show a patch.
GET /api/patches/26487/?format=api
{ "id": 26487, "url": "https://patchwork.libcamera.org/api/patches/26487/?format=api", "web_url": "https://patchwork.libcamera.org/patch/26487/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20260407-kbingham-awb-split-v1-4-a39af3f4dc20@ideasonboard.com>", "date": "2026-04-07T22:01:07", "name": "[04/13] libcamera: software_isp: Apply gains in CPU ISP", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "8ce98322df6a5509ed63bce0be843081de0f61da", "submitter": { "id": 4, "url": "https://patchwork.libcamera.org/api/people/4/?format=api", "name": "Kieran Bingham", "email": "kieran.bingham@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/26487/mbox/", "series": [ { "id": 5874, "url": "https://patchwork.libcamera.org/api/series/5874/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5874", "date": "2026-04-07T22:01:03", "name": "ipa: simple: Convert to libipa AWB implementation", "version": 1, "mbox": "https://patchwork.libcamera.org/series/5874/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/26487/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/26487/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 A2C2BC32BB\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 7 Apr 2026 22:02:57 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 072C862DDA;\n\tWed, 8 Apr 2026 00:02:49 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9DF0662CEB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 8 Apr 2026 00:02:41 +0200 (CEST)", "from [192.168.0.204] (ams.linuxembedded.co.uk [209.38.108.23])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E5A371C3F;\n\tWed, 8 Apr 2026 00:01:13 +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=\"P093AwE+\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1775599274;\n\tbh=iZAHoQLS2AsifD7XmJAW9+6UedqcEBhtvRK5onvL/+M=;\n\th=From:Date:Subject:References:In-Reply-To:To:Cc:From;\n\tb=P093AwE+OoflH4csdp5ywjudXoK++JZFCDLxpzGylT82YcGMqNzFO8vp8q08XIyb7\n\tseAs/mnJzHrBpuHJCysUwkQ8XmQBuctNOvAFTNCcvBFmv+1lyGzu4OgxYDG3mCL8Ik\n\tycB9tHDElUDt6pTTusQxxxubYN/mNgNoiCiQTukk=", "From": "Kieran Bingham <kieran.bingham@ideasonboard.com>", "Date": "Tue, 07 Apr 2026 23:01:07 +0100", "Subject": "[PATCH 04/13] libcamera: software_isp: Apply gains in CPU ISP", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"utf-8\"", "Content-Transfer-Encoding": "7bit", "Message-Id": "<20260407-kbingham-awb-split-v1-4-a39af3f4dc20@ideasonboard.com>", "References": "<20260407-kbingham-awb-split-v1-0-a39af3f4dc20@ideasonboard.com>", "In-Reply-To": "<20260407-kbingham-awb-split-v1-0-a39af3f4dc20@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Kieran Bingham <kieran.bingham@ideasonboard.com>, \n\tMilan Zamazal <mzamazal@redhat.com>", "X-Mailer": "b4 0.14.2", "X-Developer-Signature": "v=1; a=ed25519-sha256; t=1775599359; l=4292;\n\ti=kieran.bingham@ideasonboard.com; s=20260204;\n\th=from:subject:message-id; \n\tbh=/qHwlJH4HM+aP5KdyZDAbML9TLl/S2aWLr0jTOIFApY=;\n\tb=t94QFNq9U/XuWPGm+5FO2FgHBHXHcSlYLGZ4ZRYQezwUA9X1L2Zv56bppl8BVYHmcqFdKq7qu\n\tmRaiRoIbEKSATVmR3gCyW2Rrx8zO/fJAnDBXJOHAZeD0fmRh8eRVsTK", "X-Developer-Key": "i=kieran.bingham@ideasonboard.com; a=ed25519;\n\tpk=IOxS2C6nWHNjLfkDR71Iesk904i6wJDfEERqV7hDBdY=", "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": "From: Milan Zamazal <mzamazal@redhat.com>\n\nOne of the preceding patches removed white balance gains from the\ncombined matrix. Which is correct but the gains are not applied now in\nCPU ISP when a CCM is used.\n\nThis patch applies the gains in the CCM table. It also clamps the pixel\nvalues if they are out of range after applying the gains.\n\nSigned-off-by: Milan Zamazal <mzamazal@redhat.com>\n---\n src/libcamera/software_isp/debayer_cpu.cpp | 45 +++++++++++++++---------------\n 1 file changed, 23 insertions(+), 22 deletions(-)", "diff": "diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp\nindex 5356d6bbec11c30fa0b05659d44a91e69e2b79d0..2dc0df5597938cc19317187f7b1ed8a10b1cc111 100644\n--- a/src/libcamera/software_isp/debayer_cpu.cpp\n+++ b/src/libcamera/software_isp/debayer_cpu.cpp\n@@ -911,45 +911,46 @@ void DebayerCpu::updateLookupTables(const DebayerParams ¶ms)\n \t};\n \tconst unsigned int gammaTableSize = gammaTable_.size();\n \tRGB<float> blackIndex = params.blackLevel * kRGBLookupSize;\n+\tRGB<float> gains = params.gains;\n+\tconst RGB<float> div = (RGB<float>(kRGBLookupSize) - blackIndex).max(1.0);\n \n \tif (ccmEnabled_) {\n \t\tif (gammaUpdateNeeded ||\n-\t\t matrixChanged(params.combinedMatrix, params_.combinedMatrix)) {\n+\t\t matrixChanged(params.combinedMatrix, params_.combinedMatrix) ||\n+\t\t params.gains != params_.gains) {\n \t\t\tauto &red = swapRedBlueGains_ ? blueCcm_ : redCcm_;\n \t\t\tauto &green = greenCcm_;\n \t\t\tauto &blue = swapRedBlueGains_ ? redCcm_ : blueCcm_;\n-\t\t\tconst unsigned int redIndex = swapRedBlueGains_ ? 2 : 0;\n-\t\t\tconst unsigned int greenIndex = 1;\n-\t\t\tconst unsigned int blueIndex = swapRedBlueGains_ ? 0 : 2;\n-\t\t\tconst RGB<float> div =\n-\t\t\t\t(RGB<float>(kRGBLookupSize) - blackIndex).max(1.0) /\n-\t\t\t\tkRGBLookupSize;\n \t\t\tfor (unsigned int i = 0; i < kRGBLookupSize; i++) {\n-\t\t\t\tconst RGB<float> rgb = ((RGB<float>(i) - blackIndex) / div).max(0.0);\n-\t\t\t\tred[i].r = std::round(rgb.r() * params.combinedMatrix[redIndex][0]);\n-\t\t\t\tred[i].g = std::round(rgb.g() * params.combinedMatrix[greenIndex][0]);\n-\t\t\t\tred[i].b = std::round(rgb.b() * params.combinedMatrix[blueIndex][0]);\n-\t\t\t\tgreen[i].r = std::round(rgb.r() * params.combinedMatrix[redIndex][1]);\n-\t\t\t\tgreen[i].g = std::round(rgb.g() * params.combinedMatrix[greenIndex][1]);\n-\t\t\t\tgreen[i].b = std::round(rgb.b() * params.combinedMatrix[blueIndex][1]);\n-\t\t\t\tblue[i].r = std::round(rgb.r() * params.combinedMatrix[redIndex][2]);\n-\t\t\t\tblue[i].g = std::round(rgb.g() * params.combinedMatrix[greenIndex][2]);\n-\t\t\t\tblue[i].b = std::round(rgb.b() * params.combinedMatrix[blueIndex][2]);\n+\t\t\t\tconst RGB<float> rgb =\n+\t\t\t\t\t(gains * (RGB<float>(i) - blackIndex) * kRGBLookupSize / div)\n+\t\t\t\t\t\t.min(kRGBLookupSize - 1)\n+\t\t\t\t\t\t.max(0.0);\n+\t\t\t\tred[i].r = std::round(rgb.r() * params.combinedMatrix[0][0]);\n+\t\t\t\tred[i].g = std::round(rgb.g() * params.combinedMatrix[1][0]);\n+\t\t\t\tred[i].b = std::round(rgb.b() * params.combinedMatrix[2][0]);\n+\t\t\t\tgreen[i].r = std::round(rgb.r() * params.combinedMatrix[0][1]);\n+\t\t\t\tgreen[i].g = std::round(rgb.g() * params.combinedMatrix[1][1]);\n+\t\t\t\tgreen[i].b = std::round(rgb.b() * params.combinedMatrix[2][1]);\n+\t\t\t\tblue[i].r = std::round(rgb.r() * params.combinedMatrix[0][2]);\n+\t\t\t\tblue[i].g = std::round(rgb.g() * params.combinedMatrix[1][2]);\n+\t\t\t\tblue[i].b = std::round(rgb.b() * params.combinedMatrix[2][2]);\n+\t\t\t\tif (swapRedBlueGains_) {\n+\t\t\t\t\tstd::swap(red[i].r, red[i].b);\n+\t\t\t\t\tstd::swap(green[i].r, green[i].b);\n+\t\t\t\t\tstd::swap(blue[i].r, blue[i].b);\n+\t\t\t\t}\n \t\t\t\tgammaLut_[i] = gammaTable_[i * gammaTableSize / kRGBLookupSize];\n \t\t\t}\n \t\t}\n \t} else {\n \t\tif (gammaUpdateNeeded || params.gains != params_.gains) {\n-\t\t\tauto &gains = params.gains;\n \t\t\tauto &red = swapRedBlueGains_ ? blue_ : red_;\n \t\t\tauto &green = green_;\n \t\t\tauto &blue = swapRedBlueGains_ ? red_ : blue_;\n-\t\t\tconst RGB<float> div =\n-\t\t\t\t(RGB<float>(kRGBLookupSize) - blackIndex).max(1.0) /\n-\t\t\t\tgammaTableSize;\n \t\t\tfor (unsigned int i = 0; i < kRGBLookupSize; i++) {\n \t\t\t\tconst RGB<float> lutGains =\n-\t\t\t\t\t(gains * (RGB<float>(i) - blackIndex) / div)\n+\t\t\t\t\t(gains * (RGB<float>(i) - blackIndex) * gammaTableSize / div)\n \t\t\t\t\t\t.min(gammaTableSize - 1)\n \t\t\t\t\t\t.max(0.0);\n \t\t\t\tred[i] = gammaTable_[lutGains.r()];\n", "prefixes": [ "04/13" ] }