Patch Detail
Show a patch.
GET /api/1.1/patches/24984/?format=api
{ "id": 24984, "url": "https://patchwork.libcamera.org/api/1.1/patches/24984/?format=api", "web_url": "https://patchwork.libcamera.org/patch/24984/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/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": "<20251107152025.18434-1-mzamazal@redhat.com>", "date": "2025-11-07T15:20:25", "name": "libcamera: software_isp: Fix gamma table when CCM is used", "commit_ref": "443e5a6c311f6acecee16611eebd58c9f92b4f73", "pull_url": null, "state": "accepted", "archived": false, "hash": "133e1f04ae2d290f1e9ba1e2353c9140295bb2e5", "submitter": { "id": 177, "url": "https://patchwork.libcamera.org/api/1.1/people/177/?format=api", "name": "Milan Zamazal", "email": "mzamazal@redhat.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/24984/mbox/", "series": [ { "id": 5568, "url": "https://patchwork.libcamera.org/api/1.1/series/5568/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5568", "date": "2025-11-07T15:20:25", "name": "libcamera: software_isp: Fix gamma table when CCM is used", "version": 1, "mbox": "https://patchwork.libcamera.org/series/5568/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/24984/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/24984/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 DBEB8BDE4C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 7 Nov 2025 15:20:36 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DB409608CF;\n\tFri, 7 Nov 2025 16:20:35 +0100 (CET)", "from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.129.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5A275608CF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 7 Nov 2025 16:20:34 +0100 (CET)", "from mx-prod-mc-05.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-653-YmxudqN7OZmq99gR4qLe3Q-1;\n\tFri, 07 Nov 2025 10:20:31 -0500", "from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com\n\t(mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com\n\t[10.30.177.93])\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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTPS\n\tid BDFCB1955F44 for <libcamera-devel@lists.libcamera.org>;\n\tFri, 7 Nov 2025 15:20:30 +0000 (UTC)", "from mzamazal-thinkpadp1gen7.tpbc.com (unknown [10.44.33.41])\n\tby mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTP id A0A601800298; Fri, 7 Nov 2025 15:20:29 +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=\"TuWeDPV9\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1762528833;\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=A9Kb1mfgtnt5C6hD3ZfwCW9mX9y3jA/zo5lRUGy9wFM=;\n\tb=TuWeDPV9R18EywsRMWZHcSVAKQ6xKTWdVGE7cFjUwBu9yUovfQz2vhaUWocorxvoxJGfE5\n\t/zVo0zPgsC8wbW7jlhLn7zCMdG9SSiybFJ0hXTrod/RhpOTRQEZkpDL2vgkVBnTbcCfR6V\n\ttC9XWc4rLV6O9Vj/zk0Rly9pMKfloLY=", "X-MC-Unique": "YmxudqN7OZmq99gR4qLe3Q-1", "X-Mimecast-MFC-AGG-ID": "YmxudqN7OZmq99gR4qLe3Q_1762528830", "From": "Milan Zamazal <mzamazal@redhat.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Milan Zamazal <mzamazal@redhat.com>", "Subject": "[PATCH] libcamera: software_isp: Fix gamma table when CCM is used", "Date": "Fri, 7 Nov 2025 16:20:25 +0100", "Message-ID": "<20251107152025.18434-1-mzamazal@redhat.com>", "MIME-Version": "1.0", "X-Scanned-By": "MIMEDefang 3.4.1 on 10.30.177.93", "X-Mimecast-Spam-Score": "0", "X-Mimecast-MFC-PROC-ID": "U-Kt29uuclvwzek2x3rC9YiCDSHDLeymrTz8-COmSv8_1762528830", "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": "Software CPU ISP computes a gamma lookup table. The table incorporates\nblack level and contrast. All entries in the table below the black\nlevel are set to 0. This is not necessarily correct all the time.\n\nLet's consider this case: The CCM is\n\n [1 0 0]\n [0 1 0]\n [0 0 0]\n\nand contrast is set to zero. The gamma table has all the entries above\nthe black level set to 186 (due to zero contrast) and all the entries\nbelow the black level set to 0. CCM is applied before gamma, a\nnon-black level pixel has the blue component set to 0 with the CCM\nabove. Now, when the gamma lookup is applied, the red and green\ncomponents are set to 186, while the blue component is set to 0. The\nresulting pixel is then yellow rather than grey (as it should be with\nzero contrast).\n\nThere are two ways to fix this: Either clamping pixel colour channels to\nthe black level in debayering or setting the below black level entries\nin the gamma lookup table to the lowest value of the gamma table rather\nthan 0. Both should have the same effect. Let's opt for the latter for\nits simplicity.\n\nSigned-off-by: Milan Zamazal <mzamazal@redhat.com>\n---\n src/ipa/simple/algorithms/lut.cpp | 9 ++++++++-\n 1 file changed, 8 insertions(+), 1 deletion(-)", "diff": "diff --git a/src/ipa/simple/algorithms/lut.cpp b/src/ipa/simple/algorithms/lut.cpp\nindex d1d5f7271..d4a79e101 100644\n--- a/src/ipa/simple/algorithms/lut.cpp\n+++ b/src/ipa/simple/algorithms/lut.cpp\n@@ -61,7 +61,6 @@ void Lut::updateGammaTable(IPAContext &context)\n \tconst unsigned int blackIndex = blackLevel * gammaTable.size() / 256;\n \tconst auto contrast = context.activeState.knobs.contrast.value_or(1.0);\n \n-\tstd::fill(gammaTable.begin(), gammaTable.begin() + blackIndex, 0);\n \tconst float divisor = gammaTable.size() - blackIndex - 1.0;\n \tfor (unsigned int i = blackIndex; i < gammaTable.size(); i++) {\n \t\tdouble normalized = (i - blackIndex) / divisor;\n@@ -75,6 +74,14 @@ void Lut::updateGammaTable(IPAContext &context)\n \t\tgammaTable[i] = UINT8_MAX *\n \t\t\t\tstd::pow(normalized, context.configuration.gamma);\n \t}\n+\t/*\n+\t * Due to CCM operations, the table lookup may reach indices below the black\n+\t * level. Let's set the table values below black level to the minimum\n+\t * non-black value to prevent problems when the minimum value is\n+\t * significantly non-zero (for example, when the image should be all grey).\n+\t */\n+\tstd::fill(gammaTable.begin(), gammaTable.begin() + blackIndex,\n+\t\t gammaTable[blackIndex]);\n \n \tcontext.activeState.gamma.blackLevel = blackLevel;\n \tcontext.activeState.gamma.contrast = contrast;\n", "prefixes": [] }