Show a patch.

GET /api/1.1/patches/24093/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 24093,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/24093/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/24093/",
    "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": "<20250812133856.3981-1-david.plowman@raspberrypi.com>",
    "date": "2025-08-12T13:38:56",
    "name": "ipa: rpi:: denoise: Implement TDN back-off for CDN deviation",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "70cb063215679956f7e0603f9a81ce9ef7a49a7a",
    "submitter": {
        "id": 42,
        "url": "https://patchwork.libcamera.org/api/1.1/people/42/?format=api",
        "name": "David Plowman",
        "email": "david.plowman@raspberrypi.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/24093/mbox/",
    "series": [
        {
            "id": 5368,
            "url": "https://patchwork.libcamera.org/api/1.1/series/5368/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5368",
            "date": "2025-08-12T13:38:56",
            "name": "ipa: rpi:: denoise: Implement TDN back-off for CDN deviation",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/5368/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/24093/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/24093/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 887FABDCC1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 12 Aug 2025 13:39:03 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 224CA69249;\n\tTue, 12 Aug 2025 15:39:02 +0200 (CEST)",
            "from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com\n\t[IPv6:2a00:1450:4864:20::32a])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 461836921A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 12 Aug 2025 15:39:00 +0200 (CEST)",
            "by mail-wm1-x32a.google.com with SMTP id\n\t5b1f17b1804b1-45a0dc77a15so11370905e9.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 12 Aug 2025 06:39:00 -0700 (PDT)",
            "from raspberrypi.pitowers.org\n\t([2a00:1098:3142:1f:ffc9:aff6:7f7f:893b])\n\tby smtp.gmail.com with ESMTPSA id\n\t5b1f17b1804b1-459e58553f8sm317546545e9.14.2025.08.12.06.38.58\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 12 Aug 2025 06:38:58 -0700 (PDT)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"GjuETK1q\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1755005939; x=1755610739;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:message-id:date:subject:cc\n\t:to:from:from:to:cc:subject:date:message-id:reply-to;\n\tbh=Sij2MBaf/bKtegb0DTeP8uRGV0KedpzNM9UKXpwcmlI=;\n\tb=GjuETK1q+vMOPiF6ws3Wzkni17U5yvQMmJ6ir4Mt6vraldtL9AF5m0i0uRSQT8HmfP\n\tBtX9WEU8wsDI0ddLonPBkAiwFtXt/iPI7SWPShx8GjffnL9sJ9u8iYvnTjNckkBIhl+S\n\t99cdteXIbeE0426AejTcMzG9Oh/6Gi+3TQVeFgoTUVYsUg9jXa/yJ0cZeouy7DtSM9yA\n\tj5bnCm/yx5swMPt5tfHhHMBTAZHH5uMmYFRN191d9LaLL4x4WCIDi6XU/I/jxUpEuSxW\n\tbElyPThkbge2XjBEduP5FVjRqCAbL9aYEaxizc1LG9gjfpA9UKSStj9vaSFc4jw7Bi4m\n\tshvg==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1755005939; x=1755610739;\n\th=content-transfer-encoding:mime-version:message-id:date:subject:cc\n\t:to:from:x-gm-message-state:from:to:cc:subject:date:message-id\n\t:reply-to;\n\tbh=Sij2MBaf/bKtegb0DTeP8uRGV0KedpzNM9UKXpwcmlI=;\n\tb=L5/pn3Krqhv1XYUEymaXiUdVq5niihkjuLW3G8O0bHZGV8UVv0vkE/PZcju9rh2J6t\n\tT2V4VxgydEj9kbuOyoeRp94nxsx3Dp2OBAwL9KZaNPjX0vqfP3KFYqwJrb5ylitZZeOS\n\tFSmmRJritJjUIvfcjZq4RaK2Pcg2piRyUzpz8H+Gl9ISagLKeUByu98xD8LRZhmKCWus\n\tgwYfeVXgUnNDTOGIy+avwYluEYbkASwkLwyePCsGyZlvU9o88xoBJ57Yg10UvvCjVIgV\n\tK2LNDLyQ8XgcR3WnhYDduBYNn3YzcH11Q5p5UDYNoh/qf/MnGNMzBrEsAmSPUmq/BJ0f\n\t6f7A==",
        "X-Gm-Message-State": "AOJu0YwxsIfz6AyUEMjmOv0Sf34aZTCDOI3qaXupyV5hEfjNAOaXiICu\n\tOVftMyqec3VHXKlTQ0IWAUA5D+FWKdZQEEO0q5TfcAef2s/rkoAirZAfZ6pfGEOfHVxphgJRa13\n\t99Wo9M8s=",
        "X-Gm-Gg": "ASbGncsgiukdZcvU+s872pF0iOUmKzxmIzmF3qPH23/wQINLokVtfuSTMO2fK8Eo718\n\te3/ZqWZjv/IMJ7z4+Likv4RF2Yi21qcYkM2vAFt/vJRRFqO796pqClzE7t6nDaqyUhb12V3y+5J\n\t6IuifGFEBvktDEkNSZ33jqjC6mqqm9IbHWgGdwVgVvm/FsjtHJV0Nal+HHhsotaLfkSEmTTgURr\n\ttEo4lV7zt+z13yg/CPpWsaRarR1WhnwdXAng9llt3OvWbTVewnVPWAlgFVDFVQSfW+FzI26H1DP\n\t4x/nFcgcUwx9FOEiru5My7pF1URuRhXs55L3Xg9tv70JXXwjRB+aDejRVBYim9VQJmsSTOR26wq\n\tmVjnAcuGG/XkG84us57GP3UiYMv9xylLJEdVf4SwPNIVcd5mAWLH9zQ==",
        "X-Google-Smtp-Source": "AGHT+IGxol9BE1BnFAfHjiJVf3mMgz2To+AvawWxf0saHscYMV6ENjt35YuyS4sp/hKk0MtLJIQZCw==",
        "X-Received": "by 2002:a05:600c:45d0:b0:456:1bae:5470 with SMTP id\n\t5b1f17b1804b1-45a10bb9684mr35996995e9.8.1755005939052; \n\tTue, 12 Aug 2025 06:38:59 -0700 (PDT)",
        "From": "David Plowman <david.plowman@raspberrypi.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "David Plowman <david.plowman@raspberrypi.com>",
        "Subject": "[PATCH] ipa: rpi:: denoise: Implement TDN back-off for CDN deviation",
        "Date": "Tue, 12 Aug 2025 14:38:56 +0100",
        "Message-Id": "<20250812133856.3981-1-david.plowman@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.39.5",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "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": "The CDN (colour denoise) deviation gets gradually reduced frame by\nframe as TDN (temporal denoise) comes in and has more effect. CDN is\nmore harmful to image detail than TDN, so ramping it down in favour of\nTDN is beneficial.\n\nThe tuning file parameters are chosen so that existing tuning files\ndon't have to be updated and will carry on working \"mostly like they\ndid\" (apart from the new back-off).\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\n---\n src/ipa/rpi/controller/rpi/denoise.cpp | 22 +++++++++++++++++++---\n src/ipa/rpi/controller/rpi/denoise.h   |  4 +++-\n 2 files changed, 22 insertions(+), 4 deletions(-)",
    "diff": "diff --git a/src/ipa/rpi/controller/rpi/denoise.cpp b/src/ipa/rpi/controller/rpi/denoise.cpp\nindex ba851658..d9bbeddd 100644\n--- a/src/ipa/rpi/controller/rpi/denoise.cpp\n+++ b/src/ipa/rpi/controller/rpi/denoise.cpp\n@@ -37,7 +37,17 @@ int DenoiseConfig::read(const libcamera::YamlObject &params)\n \tcdnEnable = params.contains(\"cdn\");\n \tif (cdnEnable) {\n \t\tauto &cdnParams = params[\"cdn\"];\n-\t\tcdnDeviation = cdnParams[\"deviation\"].get<double>(120);\n+\t\tcdnDeviationNoTdn = cdnParams[\"deviation_no_tdn\"].get<double>(150);\n+\t\t/*\n+\t\t * For backwards compatibility with existing tuning files, interpret \"deviation\"\n+\t\t * as giving the \"no TDN\" deviation, where present.\n+\t\t */\n+\t\tcdnDeviationNoTdn = cdnParams[\"deviation\"].get<double>(cdnDeviationNoTdn);\n+\t\t/*\n+\t\t * A third the value of the no TDN deviation is about right for with-TDN, if\n+\t\t * the user hasn't specified otherwise.\n+\t\t */\n+\t\tcdnDeviationWithTdn = cdnParams[\"deviation_with_tdn\"].get<double>(cdnDeviationNoTdn / 3);\n \t\tcdnStrength = cdnParams[\"strength\"].get<double>(0.2);\n \t}\n \n@@ -48,13 +58,14 @@ int DenoiseConfig::read(const libcamera::YamlObject &params)\n \t\ttdnThreshold = tdnParams[\"threshold\"].get<double>(0.75);\n \t} else if (sdnEnable) {\n \t\t/*\n-\t\t * If SDN is enabled but TDN isn't, overwrite all the SDN settings\n+\t\t * If SDN is enabled but TDN isn't, overwrite all the SDN/CDN settings\n \t\t * with the \"no TDN\" versions. This makes it easier to enable or\n \t\t * disable TDN in the tuning file without editing all the other\n \t\t * parameters.\n \t\t */\n \t\tsdnDeviation = sdnDeviation2 = sdnDeviationNoTdn;\n \t\tsdnStrength = sdnStrengthNoTdn;\n+\t\tcdnDeviationWithTdn = cdnDeviationNoTdn;\n \t}\n \n \treturn 0;\n@@ -107,6 +118,7 @@ void Denoise::switchMode([[maybe_unused]] CameraMode const &cameraMode,\n \tcurrentSdnDeviation_ = currentConfig_->sdnDeviationNoTdn;\n \tcurrentSdnStrength_ = currentConfig_->sdnStrengthNoTdn;\n \tcurrentSdnDeviation2_ = currentConfig_->sdnDeviationNoTdn;\n+\tcurrentCdnDeviation_ = currentConfig_->cdnDeviationNoTdn;\n }\n \n void Denoise::prepare(Metadata *imageMetadata)\n@@ -159,8 +171,12 @@ void Denoise::prepare(Metadata *imageMetadata)\n \n \tif (currentConfig_->cdnEnable && mode_ != DenoiseMode::ColourOff) {\n \t\tstruct CdnStatus cdn;\n-\t\tcdn.threshold = currentConfig_->cdnDeviation * noiseStatus.noiseSlope + noiseStatus.noiseConstant;\n+\t\tcdn.threshold = currentCdnDeviation_ * noiseStatus.noiseSlope + noiseStatus.noiseConstant;\n \t\tcdn.strength = currentConfig_->cdnStrength;\n+\t\t/* For the next frame, we back off the CDN deviation as TDN ramps up. */\n+\t\tdouble f = currentConfig_->sdnTdnBackoff;\n+\t\tcurrentCdnDeviation_ = f * currentCdnDeviation_ + (1 - f) * currentConfig_->cdnDeviationWithTdn;\n+\n \t\timageMetadata->set(\"cdn.status\", cdn);\n \t\tLOG(RPiDenoise, Debug)\n \t\t\t<< \"programmed cdn threshold \" << cdn.threshold\ndiff --git a/src/ipa/rpi/controller/rpi/denoise.h b/src/ipa/rpi/controller/rpi/denoise.h\nindex 79946c97..e23a2e8f 100644\n--- a/src/ipa/rpi/controller/rpi/denoise.h\n+++ b/src/ipa/rpi/controller/rpi/denoise.h\n@@ -23,7 +23,8 @@ struct DenoiseConfig {\n \tdouble sdnDeviationNoTdn;\n \tdouble sdnStrengthNoTdn;\n \tdouble sdnTdnBackoff;\n-\tdouble cdnDeviation;\n+\tdouble cdnDeviationNoTdn;\n+\tdouble cdnDeviationWithTdn;\n \tdouble cdnStrength;\n \tdouble tdnDeviation;\n \tdouble tdnThreshold;\n@@ -54,6 +55,7 @@ private:\n \tdouble currentSdnDeviation_;\n \tdouble currentSdnStrength_;\n \tdouble currentSdnDeviation2_;\n+\tdouble currentCdnDeviation_;\n };\n \n } // namespace RPiController\n",
    "prefixes": []
}