Show a patch.

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

{
    "id": 10617,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/10617/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/10617/",
    "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": "<20201208204441.9356-6-david.plowman@raspberrypi.com>",
    "date": "2020-12-08T20:44:40",
    "name": "[libcamera-devel,v3,5/6] src: ipa: raspberrypi: Estimate the colour temerature if starting with fixed colour gains",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "8c5504a0378751d3efcabdefa8ca48f28e32ed4b",
    "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/10617/mbox/",
    "series": [
        {
            "id": 1515,
            "url": "https://patchwork.libcamera.org/api/1.1/series/1515/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1515",
            "date": "2020-12-08T20:44:35",
            "name": "Raspberry Pi AGC: initial frame drop count",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/1515/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/10617/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/10617/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 658C9BDB20\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  8 Dec 2020 20:44:52 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 26B3F67F18;\n\tTue,  8 Dec 2020 21:44:52 +0100 (CET)",
            "from mail-ed1-x531.google.com (mail-ed1-x531.google.com\n\t[IPv6:2a00:1450:4864:20::531])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B101367F09\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  8 Dec 2020 21:44:49 +0100 (CET)",
            "by mail-ed1-x531.google.com with SMTP id cw27so18999405edb.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 08 Dec 2020 12:44:49 -0800 (PST)",
            "from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72])\n\tby smtp.gmail.com with ESMTPSA id\n\tbe6sm18441471edb.29.2020.12.08.12.44.47\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 08 Dec 2020 12:44:48 -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=\"KSnWEE1n\"; 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=vUfawtU5Ys8cWncdGkHdhCkjx5+l5nzjqt7tZ+fvOL0=;\n\tb=KSnWEE1nLYgJgXDXed7TxUVwN3BadurdXwU1hiyQIcrXpnBUUxlZwGEtDALC5P91mw\n\tHW5cF/PXKZxD4twku71c+NvxJlAKbqCf5kKr4Q9In91UMjCIV+pz+Jdishl5xWjm2EqP\n\tjYOmZXX4ovbZCKbI6/huCQUVs8dNs4oJSJzeMuY14NfKjXjwUHefE9yaej8NYMNcVaSf\n\tXqtyvkLXt5YqLdlzpphq47OGHH+OeZy7r2B2N18RynHztByVbGHtS5TFif1hJbJHU07u\n\ttJDoy0uXDWO2GGEQaiHUmsab9HexIZ1KDJMT7u2B2P8h63wkqooHqVh55Iy0x7C5o64v\n\tzp/A==",
        "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=vUfawtU5Ys8cWncdGkHdhCkjx5+l5nzjqt7tZ+fvOL0=;\n\tb=oJunzBorQ1ULC84/t01mAzqu9HCkyPbBldCHFqa1y+oheFLtuJ6WRtPUSG9cRc1Wlt\n\t55VvbwgXf8MZ9DW/WSqYus1d2uzwKCtdTTHOx7DryThr7ZwwdkHOKTjm+Q4Th2zYydV0\n\tyf945kCR81qyWFq9juat5CnHUSdnHuOr8nb/9sTyUaZVS8g0DpK+9SfNOfOet9WBqV9L\n\tvcdbRtXkr3bg3tn0XpTBJELcq4yklkDnXhu29ljMjFqC+3UaWJP8hFubi6cjcHMx5Kgr\n\t2SYe/zk3SLxisDgjgKJrOnaLZ9nX8Zkh78vTR15aIw4zHJCkhIXL31pQNvEThTkKJcPH\n\tgsAg==",
        "X-Gm-Message-State": "AOAM533qsv4iNbMo5P3Ugrk4A5rB10qRYnNABvGfOUJd8CUVtfWOW5Zo\n\tw9lVlLv7RY/gBb6C/lqEICcF/MuTVwfvonYi",
        "X-Google-Smtp-Source": "ABdhPJz6EcZ/hy9d3BiqrUwSwejJSBfPRSyQaZdDzPv4IxypbKv3elLmKbQ+RmrUw8KAumo0wBRLDw==",
        "X-Received": "by 2002:aa7:c4c2:: with SMTP id p2mr26281712edr.63.1607460288659;\n\tTue, 08 Dec 2020 12:44:48 -0800 (PST)",
        "From": "David Plowman <david.plowman@raspberrypi.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue,  8 Dec 2020 20:44:40 +0000",
        "Message-Id": "<20201208204441.9356-6-david.plowman@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.20.1",
        "In-Reply-To": "<20201208204441.9356-1-david.plowman@raspberrypi.com>",
        "References": "<20201208204441.9356-1-david.plowman@raspberrypi.com>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH v3 5/6] src: ipa: raspberrypi: Estimate\n\tthe colour temerature if starting with fixed colour gains",
        "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 the AWB is started from \"cold\" with fixed colour gains, we try to\nestimate the colour temperature this corresponds to (if a calibrated\nCT curve was supplied). When fixed colour gains are set after the AWB\nhas been running, we leave the CT estimate alone, as the one we have\nis probably sensible.\n\nThis estimated colour is passed out in the metadata for other\nalgorithms - notably ALSC - to use.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\nReviewed-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/ipa/raspberrypi/controller/rpi/alsc.cpp |  6 +++++-\n src/ipa/raspberrypi/controller/rpi/awb.cpp  | 14 ++++++++++++++\n src/ipa/raspberrypi/controller/rpi/awb.hpp  |  1 +\n 3 files changed, 20 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/src/ipa/raspberrypi/controller/rpi/alsc.cpp b/src/ipa/raspberrypi/controller/rpi/alsc.cpp\nindex 183a0c95..c354c985 100644\n--- a/src/ipa/raspberrypi/controller/rpi/alsc.cpp\n+++ b/src/ipa/raspberrypi/controller/rpi/alsc.cpp\n@@ -146,6 +146,7 @@ void Alsc::Read(boost::property_tree::ptree const &params)\n \tconfig_.threshold = params.get<double>(\"threshold\", 1e-3);\n }\n \n+static double get_ct(Metadata *metadata, double default_ct);\n static void get_cal_table(double ct,\n \t\t\t  std::vector<AlscCalibration> const &calibrations,\n \t\t\t  double cal_table[XY]);\n@@ -210,6 +211,9 @@ void Alsc::SwitchMode(CameraMode const &camera_mode,\n \t// change.\n \tbool reset_tables = first_time_ || compare_modes(camera_mode_, camera_mode);\n \n+\t// Believe the colour temperature from the AWB, if there is one.\n+\tct_ = get_ct(metadata, ct_);\n+\n \t// Ensure the other thread isn't running while we do this.\n \twaitForAysncThread();\n \n@@ -254,7 +258,7 @@ void Alsc::fetchAsyncResults()\n \tmemcpy(sync_results_, async_results_, sizeof(sync_results_));\n }\n \n-static double get_ct(Metadata *metadata, double default_ct)\n+double get_ct(Metadata *metadata, double default_ct)\n {\n \tAwbStatus awb_status;\n \tawb_status.temperature_K = default_ct; // in case nothing found\ndiff --git a/src/ipa/raspberrypi/controller/rpi/awb.cpp b/src/ipa/raspberrypi/controller/rpi/awb.cpp\nindex 10600f75..f66c2b29 100644\n--- a/src/ipa/raspberrypi/controller/rpi/awb.cpp\n+++ b/src/ipa/raspberrypi/controller/rpi/awb.cpp\n@@ -19,6 +19,9 @@ using namespace RPiController;\n \n const double Awb::RGB::INVALID = -1.0;\n \n+// todo - the locking in this algorithm needs some tidying up as has been done\n+// elsewhere (ALSC and AGC).\n+\n void AwbMode::Read(boost::property_tree::ptree const &params)\n {\n \tct_lo = params.get<double>(\"lo\");\n@@ -121,6 +124,7 @@ Awb::Awb(Controller *controller)\n \tasync_abort_ = async_start_ = async_started_ = async_finished_ = false;\n \tmode_ = nullptr;\n \tmanual_r_ = manual_b_ = 0.0;\n+\tfirst_switch_mode_ = true;\n \tasync_thread_ = std::thread(std::bind(&Awb::asyncFunc, this));\n }\n \n@@ -199,9 +203,19 @@ void Awb::SwitchMode([[maybe_unused]] CameraMode const &camera_mode,\n \t\tprev_sync_results_.gain_r = manual_r_;\n \t\tprev_sync_results_.gain_g = 1.0;\n \t\tprev_sync_results_.gain_b = manual_b_;\n+\t\t// If we're starting up for the first time, try and\n+\t\t// \"dead reckon\" the corresponding colour temperature.\n+\t\tif (first_switch_mode_ && config_.bayes) {\n+\t\t\tPwl ct_r_inverse = config_.ct_r.Inverse();\n+\t\t\tPwl ct_b_inverse = config_.ct_b.Inverse();\n+\t\t\tdouble ct_r = ct_r_inverse.Eval(ct_r_inverse.Domain().Clip(1 / manual_r_));\n+\t\t\tdouble ct_b = ct_b_inverse.Eval(ct_b_inverse.Domain().Clip(1 / manual_b_));\n+\t\t\tprev_sync_results_.temperature_K = (ct_r + ct_b) / 2;\n+\t\t}\n \t\tsync_results_ = prev_sync_results_;\n \t}\n \tmetadata->Set(\"awb.status\", prev_sync_results_);\n+\tfirst_switch_mode_ = false;\n }\n \n void Awb::fetchAsyncResults()\ndiff --git a/src/ipa/raspberrypi/controller/rpi/awb.hpp b/src/ipa/raspberrypi/controller/rpi/awb.hpp\nindex 6fc045ce..83b81498 100644\n--- a/src/ipa/raspberrypi/controller/rpi/awb.hpp\n+++ b/src/ipa/raspberrypi/controller/rpi/awb.hpp\n@@ -159,6 +159,7 @@ private:\n \tdouble manual_r_;\n \t// manual b setting\n \tdouble manual_b_;\n+\tbool first_switch_mode_; // is this the first call to SwitchMode?\n };\n \n static inline Awb::RGB operator+(Awb::RGB const &a, Awb::RGB const &b)\n",
    "prefixes": [
        "libcamera-devel",
        "v3",
        "5/6"
    ]
}