Show a patch.

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

{
    "id": 10438,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/10438/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/10438/",
    "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": "<20201116164918.2055-10-david.plowman@raspberrypi.com>",
    "date": "2020-11-16T16:49:17",
    "name": "[libcamera-devel,09/10] libcamera: src: ipa: raspberrypi: agc: Improve gain update calculation for partly saturated images",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "c841bda91c7e4fca0c2877cf948a1fadcb5c0499",
    "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/10438/mbox/",
    "series": [
        {
            "id": 1464,
            "url": "https://patchwork.libcamera.org/api/1.1/series/1464/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1464",
            "date": "2020-11-16T16:49:08",
            "name": "Raspberry Pi AGC",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/1464/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/10438/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/10438/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 915CDBE088\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 16 Nov 2020 16:49:38 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5C9C0632DC;\n\tMon, 16 Nov 2020 17:49:38 +0100 (CET)",
            "from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com\n\t[IPv6:2a00:1450:4864:20::42b])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 706F1632E2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 16 Nov 2020 17:49:33 +0100 (CET)",
            "by mail-wr1-x42b.google.com with SMTP id k2so19457248wrx.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 16 Nov 2020 08:49:33 -0800 (PST)",
            "from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72])\n\tby smtp.gmail.com with ESMTPSA id\n\tq16sm23716973wrn.13.2020.11.16.08.49.32\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 16 Nov 2020 08:49:32 -0800 (PST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"Rgg51cvT\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=Jr6QAPf1iUIZbFIQfkDfohO+vSzKEvj6JIaoOlTvUoc=;\n\tb=Rgg51cvTaovB8Dp6I780n9mCSQwyLhqIqRHL4gBJdQXWdPe/rXRiceR4U95RYXiz1R\n\tCrCicfSbPevVWq23m6uEVZHaUuZrBhOnJb/3Fx2K2rfn+rv1hbXakrwlImwOVj10W6BK\n\tSKLrOyj3X32Q8JTWtSqNZwqkYgoMnY40XnfgcopI3kap+/n+CNmdA8WPtSo8d/5ZxkI5\n\tk10SuBJGbRvAyZu2AgOPyO8ArJT8pV6/kNE1HDP5obMHoDsINu4h5ookO+JU+l2nUwUK\n\tt2T4i6hSzT17jbMBz9MIsOiqqOyIcQEzPo/LV3vA5frsACTDvVmIQwtp9yOaVg4P3bm9\n\tgoLw==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=Jr6QAPf1iUIZbFIQfkDfohO+vSzKEvj6JIaoOlTvUoc=;\n\tb=JxPL6RGrxjxyjDso9uvaOaRqw5anIpwMvVk19uBgK2xPbECY2Qd5LS0EPlo1SnBw/n\n\tGV1bNzO3ewNgjrS8Ym0KWbBMlI+dC6jNTf6n0b8SmpInOwNWu8gHMmQ1CKRUZ/s9a3Dv\n\t4zXm5GlBnq0IdIfqekDLB3prVQSEz5tJ+P+nVK4k42bhLeePu42QhbcF3RMgShv/URIO\n\tKnz6o1MDA9R1eHgBHRH4swAJacEJY1Gj7fxpsRMb+7wGubsWcvgo8V/IsBPFxhwTHJQk\n\tskJJPJ2TDoVdczlVn1d+Dnw2ThBVZ0HNveddQ7xJa0n9bylkhb2hbl3GqIRFbbHepOXx\n\tjCCg==",
        "X-Gm-Message-State": "AOAM531g33PAiljWdQJeksCuHQ44DeDvy+hhiUeCbb+d7LeDEtUMA25M\n\toqtyF2Zo1qF1eiQBSchnuxkv0Fsq/qNiow==",
        "X-Google-Smtp-Source": "ABdhPJwgfcxfcDUiDhnMMUwPAGuu/kiRsxNvwNoYcjiE7axU39hApTG1MhkH3TwID8F7cCHu2NTxfw==",
        "X-Received": "by 2002:a5d:698c:: with SMTP id\n\tg12mr20066181wru.36.1605545372908; \n\tMon, 16 Nov 2020 08:49:32 -0800 (PST)",
        "From": "David Plowman <david.plowman@raspberrypi.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Mon, 16 Nov 2020 16:49:17 +0000",
        "Message-Id": "<20201116164918.2055-10-david.plowman@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.20.1",
        "In-Reply-To": "<20201116164918.2055-1-david.plowman@raspberrypi.com>",
        "References": "<20201116164918.2055-1-david.plowman@raspberrypi.com>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH 09/10] libcamera: src: ipa: raspberrypi:\n\tagc: Improve gain update calculation for partly saturated images",
        "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>",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "When parts of an image saturate then the image brightness no longer\nincreases linearly with increased exposure/gain. Having calculated a\nlinear gain value it's better then to try it, allowing for saturating\nregions, and if necessary increase the gain some more. We repeat this\nseveral times.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\n---\n src/ipa/raspberrypi/controller/rpi/agc.cpp | 34 +++++++++++++++-------\n 1 file changed, 24 insertions(+), 10 deletions(-)",
    "diff": "diff --git a/src/ipa/raspberrypi/controller/rpi/agc.cpp b/src/ipa/raspberrypi/controller/rpi/agc.cpp\nindex 1037f968..93b46a28 100644\n--- a/src/ipa/raspberrypi/controller/rpi/agc.cpp\n+++ b/src/ipa/raspberrypi/controller/rpi/agc.cpp\n@@ -422,17 +422,21 @@ void Agc::fetchAwbStatus(Metadata *image_metadata)\n }\n \n static double compute_initial_Y(bcm2835_isp_stats *stats, AwbStatus const &awb,\n-\t\t\t\tdouble weights[])\n+\t\t\t\tdouble weights[], double gain)\n {\n \tbcm2835_isp_stats_region *regions = stats->agc_stats;\n \t// Note how the calculation below means that equal weights give you\n \t// \"average\" metering (i.e. all pixels equally important).\n \tdouble R_sum = 0, G_sum = 0, B_sum = 0, pixel_sum = 0;\n \tfor (int i = 0; i < AGC_STATS_SIZE; i++) {\n-\t\tR_sum += regions[i].r_sum * weights[i];\n-\t\tG_sum += regions[i].g_sum * weights[i];\n-\t\tB_sum += regions[i].b_sum * weights[i];\n-\t\tpixel_sum += regions[i].counted * weights[i];\n+\t\tdouble counted = regions[i].counted;\n+\t\tdouble r_sum = std::min(regions[i].r_sum * gain, ((1 << PIPELINE_BITS) - 1) * counted);\n+\t\tdouble g_sum = std::min(regions[i].g_sum * gain, ((1 << PIPELINE_BITS) - 1) * counted);\n+\t\tdouble b_sum = std::min(regions[i].b_sum * gain, ((1 << PIPELINE_BITS) - 1) * counted);\n+\t\tR_sum += r_sum * weights[i];\n+\t\tG_sum += g_sum * weights[i];\n+\t\tB_sum += b_sum * weights[i];\n+\t\tpixel_sum += counted * weights[i];\n \t}\n \tif (pixel_sum == 0.0) {\n \t\tLOG(RPiAgc, Warning) << \"compute_initial_Y: pixel_sum is zero\";\n@@ -476,11 +480,21 @@ void Agc::computeGain(bcm2835_isp_stats *statistics, Metadata *image_metadata,\n \ttarget_Y =\n \t\tconfig_.Y_target.Eval(config_.Y_target.Domain().Clip(lux.lux));\n \ttarget_Y = std::min(EV_GAIN_Y_TARGET_LIMIT, target_Y * ev_gain);\n-\tdouble initial_Y = compute_initial_Y(statistics, awb_,\n-\t\t\t\t\t     metering_mode_->weights);\n-\tgain = std::min(10.0, target_Y / (initial_Y + .001));\n-\tLOG(RPiAgc, Debug) << \"Initially Y \" << initial_Y << \" target \" << target_Y\n-\t\t\t   << \" gives gain \" << gain;\n+\n+\t// Do this calculation a few times as brightness increase can be\n+\t// non-linear when there are saturated regions.\n+\tgain = 1.0;\n+\tfor (int i = 0; i < 8; i++) {\n+\t\tdouble initial_Y = compute_initial_Y(statistics, awb_,\n+\t\t\t\t\t\t     metering_mode_->weights, gain);\n+\t\tdouble extra_gain = std::min(10.0, target_Y / (initial_Y + .001));\n+\t\tgain *= extra_gain;\n+\t\tLOG(RPiAgc, Debug) << \"Initial Y \" << initial_Y << \" target \" << target_Y\n+\t\t\t\t   << \" gives gain \" << gain;\n+\t\tif (extra_gain < 1.01) // close enough\n+\t\t\tbreak;\n+\t}\n+\n \tfor (auto &c : *constraint_mode_) {\n \t\tdouble new_target_Y;\n \t\tdouble new_gain =\n",
    "prefixes": [
        "libcamera-devel",
        "09/10"
    ]
}