Patch Detail
Show a patch.
GET /api/1.1/patches/16269/?format=api
{ "id": 16269, "url": "https://patchwork.libcamera.org/api/1.1/patches/16269/?format=api", "web_url": "https://patchwork.libcamera.org/patch/16269/", "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": "<20220617212854.11369-1-jeanmichel.hautbois@ideasonboard.com>", "date": "2022-06-17T21:28:54", "name": "[libcamera-devel,v2] ipa: ipu3: awb: Correct the gains calculation", "commit_ref": "4bb284e0fa5669bbf6adda93e2f770014834c8cb", "pull_url": null, "state": "accepted", "archived": false, "hash": "bfb1e4ebdccd4271726d96c930cd9eac65c95d9d", "submitter": { "id": 75, "url": "https://patchwork.libcamera.org/api/1.1/people/75/?format=api", "name": "Jean-Michel Hautbois", "email": "jeanmichel.hautbois@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/16269/mbox/", "series": [ { "id": 3190, "url": "https://patchwork.libcamera.org/api/1.1/series/3190/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3190", "date": "2022-06-17T21:28:54", "name": "[libcamera-devel,v2] ipa: ipu3: awb: Correct the gains calculation", "version": 2, "mbox": "https://patchwork.libcamera.org/series/3190/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/16269/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/16269/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 E9A8ABD808\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 17 Jun 2022 21:29:01 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 52E1065633;\n\tFri, 17 Jun 2022 23:29:01 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 92B5065632\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 17 Jun 2022 23:28:59 +0200 (CEST)", "from tatooine.ideasonboard.com (unknown\n\t[IPv6:2a01:e0a:169:7140:dd2e:f9c7:5350:5a2c])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 19FC6268;\n\tFri, 17 Jun 2022 23:28:59 +0200 (CEST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1655501341;\n\tbh=sbhHyIi+zg22qUphlR1OGHJzHiyg9bsDbXNXocO3Ytg=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=EzvdtXOAofmrKfscE5hBo7wMIVfddBBNeN71ezKn51a97WXZaMyQQZKzrm32xL14Y\n\tMlwuRQ6paScND1DafKhwR/2HAe0Du1ZcL2by5Tm5C0P1U0TvwH+snFGXAqnzZmN+0l\n\t6MSekRzqKZUbFUm3BOylKhyMyC14vNEUVHM2vH24/39N/hF74tXk51Q/NYAVtxI7+n\n\t/lxOA7DFGGSpr8vDdncHe+Ba3vcr113vc4ll8If0KePGMsliSt6emVLc1LRDyjwiuD\n\tvTQYnvfXZQQPmQYX2U92ZpCNCIHmQ5JuNq9DWUAR+k+R8ZFgRRO5b5cGYjMCurOi2r\n\tVkcK2l2rzDJSA==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1655501339;\n\tbh=sbhHyIi+zg22qUphlR1OGHJzHiyg9bsDbXNXocO3Ytg=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=VbkRAeu5vwSGhATqjzMQKVTSwl316eIXQvSk8KdTeDJAOWzljh6jfchjm2vnug9r4\n\tiCK/Z97q/HooKJpFKr6g77vtPk01lgsWMCAhvBUQlTzHOMEElcGxctiy3JWofjT/W4\n\tkAAizykiPs4rFM+qtPHrorzs43Znn5R8LPWSdA0c=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"VbkRAeu5\"; dkim-atps=neutral", "To": "libcamera-devel@lists.libcamera.org", "Date": "Fri, 17 Jun 2022 23:28:54 +0200", "Message-Id": "<20220617212854.11369-1-jeanmichel.hautbois@ideasonboard.com>", "X-Mailer": "git-send-email 2.34.1", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2] ipa: ipu3: awb: Correct the gains\n\tcalculation", "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>", "From": "Jean-Michel Hautbois via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>", "Reply-To": "Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "The factor used right now in the IPU3 is 8192, as a multiplier of the\nestimated gain. This is wrong, as the isp is adding 1.0 to the gain\napplied, ie Pout = { Pin * (1 + Gx) }.\n\nFix it, and to ease the reading, introduce a small helper function.\n\nSigned-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/ipa/ipu3/algorithms/awb.cpp | 27 ++++++++++++++++++++++-----\n src/ipa/ipu3/algorithms/awb.h | 1 +\n 2 files changed, 23 insertions(+), 5 deletions(-)", "diff": "diff --git a/src/ipa/ipu3/algorithms/awb.cpp b/src/ipa/ipu3/algorithms/awb.cpp\nindex 5c232d92..70426722 100644\n--- a/src/ipa/ipu3/algorithms/awb.cpp\n+++ b/src/ipa/ipu3/algorithms/awb.cpp\n@@ -409,6 +409,23 @@ constexpr uint16_t Awb::threshold(float value)\n \treturn value * 8191;\n }\n \n+constexpr uint16_t Awb::gainValue(double gain)\n+{\n+\t/*\n+\t * The colour gains applied by the BNR for the four channels (Gr, R, B\n+\t * and Gb) are expressed in the parameters structure as 16-bit integers\n+\t * that store a fixed-point U3.13 value in the range [0, 8[.\n+\t *\n+\t * The real gain value is equal to the gain parameter plus one, i.e.\n+\t *\n+\t * Pout = Pin * (1 + gain / 8192)\n+\t *\n+\t * where 'Pin' is the input pixel value, 'Pout' the output pixel value,\n+\t * and 'gain' the gain in the parameters structure as a 16-bit integer.\n+\t */\n+\treturn std::clamp((gain - 1.0) * 8192, 0.0, 65535.0);\n+}\n+\n /**\n * \\copydoc libcamera::ipa::Algorithm::prepare\n */\n@@ -450,11 +467,11 @@ void Awb::prepare(IPAContext &context, ipu3_uapi_params *params)\n \t\t\t\t\t\t\t* params->acc_param.bnr.opt_center.x_reset;\n \tparams->acc_param.bnr.opt_center_sqr.y_sqr_reset = params->acc_param.bnr.opt_center.y_reset\n \t\t\t\t\t\t\t* params->acc_param.bnr.opt_center.y_reset;\n-\t/* Convert to u3.13 fixed point values */\n-\tparams->acc_param.bnr.wb_gains.gr = 8192 * context.activeState.awb.gains.green;\n-\tparams->acc_param.bnr.wb_gains.r = 8192 * context.activeState.awb.gains.red;\n-\tparams->acc_param.bnr.wb_gains.b = 8192 * context.activeState.awb.gains.blue;\n-\tparams->acc_param.bnr.wb_gains.gb = 8192 * context.activeState.awb.gains.green;\n+\n+\tparams->acc_param.bnr.wb_gains.gr = gainValue(context.activeState.awb.gains.green);\n+\tparams->acc_param.bnr.wb_gains.r = gainValue(context.activeState.awb.gains.red);\n+\tparams->acc_param.bnr.wb_gains.b = gainValue(context.activeState.awb.gains.blue);\n+\tparams->acc_param.bnr.wb_gains.gb = gainValue(context.activeState.awb.gains.green);\n \n \tLOG(IPU3Awb, Debug) << \"Color temperature estimated: \" << asyncResults_.temperatureK;\n \ndiff --git a/src/ipa/ipu3/algorithms/awb.h b/src/ipa/ipu3/algorithms/awb.h\nindex 9a50a985..0acd2148 100644\n--- a/src/ipa/ipu3/algorithms/awb.h\n+++ b/src/ipa/ipu3/algorithms/awb.h\n@@ -73,6 +73,7 @@ private:\n \tvoid awbGreyWorld();\n \tuint32_t estimateCCT(double red, double green, double blue);\n \tstatic constexpr uint16_t threshold(float value);\n+\tstatic constexpr uint16_t gainValue(double gain);\n \n \tstd::vector<RGB> zones_;\n \tAccumulator awbStats_[kAwbStatsSizeX * kAwbStatsSizeY];\n", "prefixes": [ "libcamera-devel", "v2" ] }