Patch Detail
Show a patch.
GET /api/1.1/patches/14618/?format=api
{ "id": 14618, "url": "https://patchwork.libcamera.org/api/1.1/patches/14618/?format=api", "web_url": "https://patchwork.libcamera.org/patch/14618/", "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": "<20211116162615.27777-3-laurent.pinchart@ideasonboard.com>", "date": "2021-11-16T16:26:12", "name": "[libcamera-devel,2/5] ipa: ipu3: agc: Standardize vocabulary on \"relative luminance\"", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "d5d9c5c7d5a06a5e45192a979d79fb50b5be19d4", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/14618/mbox/", "series": [ { "id": 2722, "url": "https://patchwork.libcamera.org/api/1.1/series/2722/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2722", "date": "2021-11-16T16:26:10", "name": "ipa: ipu3: agc: Misc improvements", "version": 1, "mbox": "https://patchwork.libcamera.org/series/2722/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/14618/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/14618/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 6BF89BDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 16 Nov 2021 16:26:49 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 74E1760398;\n\tTue, 16 Nov 2021 17:26:47 +0100 (CET)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id F34D46033C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 16 Nov 2021 17:26:42 +0100 (CET)", "from localhost.localdomain (117.145-247-81.adsl-dyn.isp.belgacom.be\n\t[81.247.145.117])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id ABDFD1449\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 16 Nov 2021 17:26:42 +0100 (CET)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"QGt3etA3\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1637080002;\n\tbh=yikkiY1KKoBAZHU6oA+rNxIXX8MYRYJlY7WOnWpBLlU=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=QGt3etA3RakkQlQaTrMN0u+Trv0hDW9w2rozz9IFEFb7sjKsEY0uF1OVydlBmFJ+Y\n\t88spzqI748Qk3CBGX3VFVx3As7pYSN16EXv2qjUFTG7ltXsQiSFU6WWzPYE2eMdHt7\n\tZfhAhsVE1ZwmeMMFy7GU4ufel7cWB88mkWyEu/YE=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 16 Nov 2021 18:26:12 +0200", "Message-Id": "<20211116162615.27777-3-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.32.0", "In-Reply-To": "<20211116162615.27777-1-laurent.pinchart@ideasonboard.com>", "References": "<20211116162615.27777-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 2/5] ipa: ipu3: agc: Standardize\n\tvocabulary on \"relative luminance\"", "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 AGC computes the average relative luminance of the frame and calls\nthe value \"normalized luma\", \"brightness\" or \"initialY\". The latter is\nthe most accurate term, as the relative luminance is abbreviated Y, but\nthe \"initial\" prefix isn't accurate.\n\nStandardize the vocabulary on \"relative luminance\" in code and comments,\nabbreviating it to Y when needed.\n\nWhile at it, rename variables to match the libcamera coding style.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/ipa/ipu3/algorithms/agc.cpp | 44 ++++++++++++++++-----------------\n src/ipa/ipu3/algorithms/agc.h | 8 +++---\n 2 files changed, 26 insertions(+), 26 deletions(-)", "diff": "diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp\nindex 43a39ffd57d6..d5840fb0aa97 100644\n--- a/src/ipa/ipu3/algorithms/agc.cpp\n+++ b/src/ipa/ipu3/algorithms/agc.cpp\n@@ -62,12 +62,12 @@ static constexpr double kEvGainTarget = 0.5;\n static constexpr uint32_t kNumStartupFrames = 10;\n \n /*\n- * Normalized luma value target.\n+ * Relative luminance target.\n *\n * It's a number that's chosen so that, when the camera points at a grey\n * target, the resulting image brightness is considered right.\n */\n-static constexpr double kNormalizedLumaTarget = 0.16;\n+static constexpr double kRelativeLuminanceTarget = 0.16;\n \n Agc::Agc()\n \t: frameCount_(0), iqMean_(0.0), lineDuration_(0s), minShutterSpeed_(0s),\n@@ -250,12 +250,12 @@ void Agc::computeExposure(IPAFrameContext &frameContext, double currentYGain)\n }\n \n /**\n- * \\brief Estimate the average brightness of the frame\n+ * \\brief Estimate the relative luminance of the frame with a given gain\n * \\param[in] frameContext The shared IPA frame context\n * \\param[in] grid The grid used to store the statistics in the IPU3\n * \\param[in] stats The IPU3 statistics and ISP results\n * \\param[in] currentYGain The gain calculated on the current brightness level\n- * \\return The normalized luma\n+ * \\return The relative luminance\n *\n * Luma is the weighted sum of gamma-compressed R′G′B′ components of a color\n * video. The luma values are normalized as 0.0 to 1.0, with 1.0 being a\n@@ -263,12 +263,12 @@ void Agc::computeExposure(IPAFrameContext &frameContext, double currentYGain)\n * luma here.\n *\n * More detailed information can be found in:\n- * https://en.wikipedia.org/wiki/Luma_(video)\n+ * https://en.wikipedia.org/wiki/Relative_luminance\n */\n-double Agc::computeInitialY(IPAFrameContext &frameContext,\n-\t\t\t const ipu3_uapi_grid_config &grid,\n-\t\t\t const ipu3_uapi_stats_3a *stats,\n-\t\t\t double currentYGain)\n+double Agc::estimateLuminance(IPAFrameContext &frameContext,\n+\t\t\t const ipu3_uapi_grid_config &grid,\n+\t\t\t const ipu3_uapi_stats_3a *stats,\n+\t\t\t double currentYGain)\n {\n \tdouble redSum = 0, greenSum = 0, blueSum = 0;\n \n@@ -288,14 +288,14 @@ double Agc::computeInitialY(IPAFrameContext &frameContext,\n \t}\n \n \t/*\n-\t * Estimate the sum of the brightness values, weighted with the gains\n-\t * applied on the channels in AWB as the Rec. 601 luma.\n+\t * Compute the relative luminance using the Rec. 601 formula, and\n+\t * normalize it.\n \t */\n-\tdouble Y_sum = redSum * frameContext.awb.gains.red * .299 +\n-\t\t greenSum * frameContext.awb.gains.green * .587 +\n-\t\t blueSum * frameContext.awb.gains.blue * .114;\n+\tdouble ySum = redSum * frameContext.awb.gains.red * .299 +\n+\t\t greenSum * frameContext.awb.gains.green * .587 +\n+\t\t blueSum * frameContext.awb.gains.blue * .114;\n \n-\treturn Y_sum / (grid.height * grid.width) / 255;\n+\treturn ySum / (grid.height * grid.width) / 255;\n }\n \n /**\n@@ -311,22 +311,22 @@ void Agc::process(IPAContext &context, const ipu3_uapi_stats_3a *stats)\n \tmeasureBrightness(stats, context.configuration.grid.bdsGrid);\n \n \tdouble currentYGain = 1.0;\n-\tdouble targetY = kNormalizedLumaTarget;\n+\tdouble yTarget = kRelativeLuminanceTarget;\n \n \t/*\n \t * Do this calculation a few times as brightness increase can be\n \t * non-linear when there are saturated regions.\n \t */\n-\tfor (int i = 0; i < 8; i++) {\n-\t\tdouble initialY = computeInitialY(context.frameContext,\n+\tfor (unsigned int i = 0; i < 8; i++) {\n+\t\tdouble yValue = estimateLuminance(context.frameContext,\n \t\t\t\t\t\t context.configuration.grid.bdsGrid,\n \t\t\t\t\t\t stats, currentYGain);\n-\t\tdouble extra_gain = std::min(10.0, targetY / (initialY + .001));\n+\t\tdouble extra_gain = std::min(10.0, yTarget / (yValue + .001));\n \n \t\tcurrentYGain *= extra_gain;\n-\t\tLOG(IPU3Agc, Debug) << \"Initial Y \" << initialY\n-\t\t\t\t << \" target \" << targetY\n-\t\t\t\t << \" gives gain \" << currentYGain;\n+\t\tLOG(IPU3Agc, Debug) << \"Y value: \" << yValue\n+\t\t\t\t << \", Y target: \" << yTarget\n+\t\t\t\t << \", gives gain \" << currentYGain;\n \t\tif (extra_gain < 1.01)\n \t\t\tbreak;\n \t}\ndiff --git a/src/ipa/ipu3/algorithms/agc.h b/src/ipa/ipu3/algorithms/agc.h\nindex 31c5a6e519d4..943c354a820e 100644\n--- a/src/ipa/ipu3/algorithms/agc.h\n+++ b/src/ipa/ipu3/algorithms/agc.h\n@@ -35,10 +35,10 @@ private:\n \t\t\t const ipu3_uapi_grid_config &grid);\n \tvoid filterExposure();\n \tvoid computeExposure(IPAFrameContext &frameContext, double currentYGain);\n-\tdouble computeInitialY(IPAFrameContext &frameContext,\n-\t\t\t const ipu3_uapi_grid_config &grid,\n-\t\t\t const ipu3_uapi_stats_3a *stats,\n-\t\t\t double currentYGain);\n+\tdouble estimateLuminance(IPAFrameContext &frameContext,\n+\t\t\t\t const ipu3_uapi_grid_config &grid,\n+\t\t\t\t const ipu3_uapi_stats_3a *stats,\n+\t\t\t\t double currentYGain);\n \n \tuint64_t frameCount_;\n \n", "prefixes": [ "libcamera-devel", "2/5" ] }